diff options
Diffstat (limited to 'src/util/crypto_rsa.c')
-rw-r--r-- | src/util/crypto_rsa.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index d1ca760cf..58503b734 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -527,6 +527,32 @@ GNUNET_CRYPTO_rsa_private_key_cmp (struct GNUNET_CRYPTO_rsa_PrivateKey *p1, | |||
527 | 527 | ||
528 | 528 | ||
529 | /** | 529 | /** |
530 | * Obtain the length of the RSA key in bits. | ||
531 | * | ||
532 | * @param key the public key to introspect | ||
533 | * @return length of the key in bits | ||
534 | */ | ||
535 | unsigned int | ||
536 | GNUNET_CRYPTO_rsa_public_key_len (const struct GNUNET_CRYPTO_rsa_PublicKey *key) | ||
537 | { | ||
538 | gcry_mpi_t n; | ||
539 | int ret; | ||
540 | unsigned int rval; | ||
541 | |||
542 | ret = key_from_sexp (&n, key->sexp, "rsa", "n"); | ||
543 | if (0 != ret) | ||
544 | { | ||
545 | /* this is no public RSA key */ | ||
546 | GNUNET_break (0); | ||
547 | return 0; | ||
548 | } | ||
549 | rval = gcry_mpi_get_nbits (n); | ||
550 | gcry_mpi_release (n); | ||
551 | return rval; | ||
552 | } | ||
553 | |||
554 | |||
555 | /** | ||
530 | * Destroy a blinding key | 556 | * Destroy a blinding key |
531 | * | 557 | * |
532 | * @param bkey the blinding key to destroy | 558 | * @param bkey the blinding key to destroy |
@@ -549,7 +575,7 @@ GNUNET_CRYPTO_rsa_blinding_key_free (struct GNUNET_CRYPTO_rsa_BlindingKey *bkey) | |||
549 | */ | 575 | */ |
550 | size_t | 576 | size_t |
551 | GNUNET_CRYPTO_rsa_blinding_key_encode (const struct GNUNET_CRYPTO_rsa_BlindingKey *bkey, | 577 | GNUNET_CRYPTO_rsa_blinding_key_encode (const struct GNUNET_CRYPTO_rsa_BlindingKey *bkey, |
552 | char **buffer) | 578 | char **buffer) |
553 | { | 579 | { |
554 | size_t n; | 580 | size_t n; |
555 | char *b; | 581 | char *b; |