diff options
Diffstat (limited to 'src/util/crypto_rsa.c')
-rw-r--r-- | src/util/crypto_rsa.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c index 43e6eedac..610e5febc 100644 --- a/src/util/crypto_rsa.c +++ b/src/util/crypto_rsa.c | |||
@@ -497,7 +497,8 @@ GNUNET_CRYPTO_rsa_public_key_decode (const char *buf, | |||
497 | * @return True if gcd(r,n) = 1, False means RSA key is malicious | 497 | * @return True if gcd(r,n) = 1, False means RSA key is malicious |
498 | */ | 498 | */ |
499 | static int | 499 | static int |
500 | rsa_gcd_validate (gcry_mpi_t r, gcry_mpi_t n) | 500 | rsa_gcd_validate (gcry_mpi_t r, |
501 | gcry_mpi_t n) | ||
501 | { | 502 | { |
502 | gcry_mpi_t g; | 503 | gcry_mpi_t g; |
503 | int t; | 504 | int t; |
@@ -525,24 +526,29 @@ rsa_blinding_key_derive (const struct GNUNET_CRYPTO_RsaPublicKey *pkey, | |||
525 | gcry_mpi_t n; | 526 | gcry_mpi_t n; |
526 | 527 | ||
527 | blind = GNUNET_new (struct RsaBlindingKey); | 528 | blind = GNUNET_new (struct RsaBlindingKey); |
528 | GNUNET_assert (NULL != blind); | ||
529 | 529 | ||
530 | /* Extract the composite n from the RSA public key */ | 530 | /* Extract the composite n from the RSA public key */ |
531 | GNUNET_assert (0 == key_from_sexp (&n, pkey->sexp, "rsa", "n")); | 531 | GNUNET_assert (0 == |
532 | key_from_sexp (&n, | ||
533 | pkey->sexp, | ||
534 | "rsa", | ||
535 | "n")); | ||
532 | /* Assert that it at least looks like an RSA key */ | 536 | /* Assert that it at least looks like an RSA key */ |
533 | GNUNET_assert (0 == gcry_mpi_get_flag (n, GCRYMPI_FLAG_OPAQUE)); | 537 | GNUNET_assert (0 == |
534 | 538 | gcry_mpi_get_flag (n, | |
539 | GCRYMPI_FLAG_OPAQUE)); | ||
535 | GNUNET_CRYPTO_kdf_mod_mpi (&blind->r, | 540 | GNUNET_CRYPTO_kdf_mod_mpi (&blind->r, |
536 | n, | 541 | n, |
537 | xts, strlen (xts), | 542 | xts, strlen (xts), |
538 | bks, sizeof(*bks), | 543 | bks, sizeof(*bks), |
539 | "Blinding KDF"); | 544 | "Blinding KDF"); |
540 | if (0 == rsa_gcd_validate (blind->r, n)) | 545 | if (0 == rsa_gcd_validate (blind->r, |
546 | n)) | ||
541 | { | 547 | { |
548 | gcry_mpi_release (blind->r); | ||
542 | GNUNET_free (blind); | 549 | GNUNET_free (blind); |
543 | blind = NULL; | 550 | blind = NULL; |
544 | } | 551 | } |
545 | |||
546 | gcry_mpi_release (n); | 552 | gcry_mpi_release (n); |
547 | return blind; | 553 | return blind; |
548 | } | 554 | } |