aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/crypto_ecc.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c
index e1608ae55..3db5b19ab 100644
--- a/src/util/crypto_ecc.c
+++ b/src/util/crypto_ecc.c
@@ -388,6 +388,39 @@ GNUNET_CRYPTO_ecdsa_public_key_from_string (
388 388
389 389
390/** 390/**
391 * Convert a string representing a private key to a private key.
392 *
393 * @param enc encoded private key
394 * @param enclen number of bytes in @a enc (without 0-terminator)
395 * @param priv where to store the private key
396 * @return #GNUNET_OK on success
397 */
398int
399GNUNET_CRYPTO_ecdsa_private_key_from_string (
400 const char *enc,
401 size_t enclen,
402 struct GNUNET_CRYPTO_EcdsaPrivateKey *priv)
403{
404 size_t keylen = (sizeof(struct GNUNET_CRYPTO_EcdsaPrivateKey)) * 8;
405
406 if (keylen % 5 > 0)
407 keylen += 5 - keylen % 5;
408 keylen /= 5;
409 if (enclen != keylen)
410 return GNUNET_SYSERR;
411
412 if (GNUNET_OK !=
413 GNUNET_STRINGS_string_to_data (enc,
414 enclen,
415 priv,
416 sizeof(
417 struct GNUNET_CRYPTO_EcdsaPrivateKey)))
418 return GNUNET_SYSERR;
419 return GNUNET_OK;
420}
421
422
423/**
391 * Convert a string representing a public key to a public key. 424 * Convert a string representing a public key to a public key.
392 * 425 *
393 * @param enc encoded public key 426 * @param enc encoded public key
@@ -423,7 +456,7 @@ GNUNET_CRYPTO_eddsa_public_key_from_string (
423/** 456/**
424 * Convert a string representing a private key to a private key. 457 * Convert a string representing a private key to a private key.
425 * 458 *
426 * @param enc encoded public key 459 * @param enc encoded private key
427 * @param enclen number of bytes in @a enc (without 0-terminator) 460 * @param enclen number of bytes in @a enc (without 0-terminator)
428 * @param priv where to store the private key 461 * @param priv where to store the private key
429 * @return #GNUNET_OK on success 462 * @return #GNUNET_OK on success