diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-28 18:47:09 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-28 18:47:09 +0000 |
commit | 9d510d2c9b77bede694e7cec5b09eac6aeae8c98 (patch) | |
tree | 5983eea0ffc4bdb4d03873671638ed9c7018ecf3 /src/util/crypto_ecc.c | |
parent | 5b51eac94676e19d2029f00fc8f706b3c33f2c1c (diff) | |
download | gnunet-9d510d2c9b77bede694e7cec5b09eac6aeae8c98.tar.gz gnunet-9d510d2c9b77bede694e7cec5b09eac6aeae8c98.zip |
adding GNUNET_CRYPTO_eddsa_private_key_from_string
Diffstat (limited to 'src/util/crypto_ecc.c')
-rw-r--r-- | src/util/crypto_ecc.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c index 23d6ade7e..baffc8fcc 100644 --- a/src/util/crypto_ecc.c +++ b/src/util/crypto_ecc.c | |||
@@ -409,6 +409,35 @@ GNUNET_CRYPTO_eddsa_public_key_from_string (const char *enc, | |||
409 | 409 | ||
410 | 410 | ||
411 | /** | 411 | /** |
412 | * Convert a string representing a private key to a private key. | ||
413 | * | ||
414 | * @param enc encoded public key | ||
415 | * @param enclen number of bytes in @a enc (without 0-terminator) | ||
416 | * @param priv where to store the private key | ||
417 | * @return #GNUNET_OK on success | ||
418 | */ | ||
419 | int | ||
420 | GNUNET_CRYPTO_eddsa_private_key_from_string (const char *enc, | ||
421 | size_t enclen, | ||
422 | struct GNUNET_CRYPTO_EddsaPrivateKey *pub) | ||
423 | { | ||
424 | size_t keylen = (sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey)) * 8; | ||
425 | |||
426 | if (keylen % 5 > 0) | ||
427 | keylen += 5 - keylen % 5; | ||
428 | keylen /= 5; | ||
429 | if (enclen != keylen) | ||
430 | return GNUNET_SYSERR; | ||
431 | |||
432 | if (GNUNET_OK != GNUNET_STRINGS_string_to_data (enc, enclen, | ||
433 | pub, | ||
434 | sizeof (struct GNUNET_CRYPTO_EddsaPrivateKey))) | ||
435 | return GNUNET_SYSERR; | ||
436 | return GNUNET_OK; | ||
437 | } | ||
438 | |||
439 | |||
440 | /** | ||
412 | * @ingroup crypto | 441 | * @ingroup crypto |
413 | * Clear memory that was used to store a private key. | 442 | * Clear memory that was used to store a private key. |
414 | * | 443 | * |