aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_rsa.c
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-03-27 15:35:14 +0200
committerChristian Grothoff <grothoff@gnunet.org>2022-03-30 10:29:16 +0200
commitedf6f59fac12cd6f7d0a14ecf2a47ab82a8beb17 (patch)
treeec0aef032f86628831a8c430dcc1655e9b83b4ca /src/util/crypto_rsa.c
parent4e5747f9a58c382c3fb82de4084b08bc7b5120d6 (diff)
downloadgnunet-edf6f59fac12cd6f7d0a14ecf2a47ab82a8beb17.tar.gz
gnunet-edf6f59fac12cd6f7d0a14ecf2a47ab82a8beb17.zip
-logging, minor memory leak fix
Diffstat (limited to 'src/util/crypto_rsa.c')
-rw-r--r--src/util/crypto_rsa.c20
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 */
499static int 499static int
500rsa_gcd_validate (gcry_mpi_t r, gcry_mpi_t n) 500rsa_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}