aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_ecc.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-12 14:05:30 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-12 14:05:30 +0000
commiteda539495f872bb2859e68d82384cc421b14cf7b (patch)
tree8d7a93061e253044ab81bda0c1f7efb84b25fe1f /src/util/crypto_ecc.c
parentdfe50afe2bf4365ca66cce552bf8048751f7fcca (diff)
downloadgnunet-eda539495f872bb2859e68d82384cc421b14cf7b.tar.gz
gnunet-eda539495f872bb2859e68d82384cc421b14cf7b.zip
-fix leaks (kind-of related to #2981)
Diffstat (limited to 'src/util/crypto_ecc.c')
-rw-r--r--src/util/crypto_ecc.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c
index 4d949eaf8..a397724f4 100644
--- a/src/util/crypto_ecc.c
+++ b/src/util/crypto_ecc.c
@@ -975,7 +975,7 @@ GNUNET_CRYPTO_ecc_key_derive (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
975 gcry_ctx_t ctx; 975 gcry_ctx_t ctx;
976 976
977 GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, NULL, CURVE)); 977 GNUNET_assert (0 == gcry_mpi_ec_new (&ctx, NULL, CURVE));
978 n = gcry_mpi_ec_get_mpi ("n", ctx, 0 /* no copy */); 978 n = gcry_mpi_ec_get_mpi ("n", ctx, 1);
979 GNUNET_CRYPTO_ecc_key_get_public (priv, &pub); 979 GNUNET_CRYPTO_ecc_key_get_public (priv, &pub);
980 h = derive_h (&pub, label, context); 980 h = derive_h (&pub, label, context);
981 mpi_scan (&x, priv->d, sizeof (priv->d)); 981 mpi_scan (&x, priv->d, sizeof (priv->d));
@@ -983,6 +983,8 @@ GNUNET_CRYPTO_ecc_key_derive (const struct GNUNET_CRYPTO_EccPrivateKey *priv,
983 gcry_mpi_mulm (d, h, x, n); 983 gcry_mpi_mulm (d, h, x, n);
984 gcry_mpi_release (h); 984 gcry_mpi_release (h);
985 gcry_mpi_release (x); 985 gcry_mpi_release (x);
986 gcry_mpi_release (n);
987 gcry_ctx_release (ctx);
986 ret = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey); 988 ret = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
987 mpi_print (ret->d, sizeof (ret->d), d); 989 mpi_print (ret->d, sizeof (ret->d), d);
988 gcry_mpi_release (d); 990 gcry_mpi_release (d);
@@ -1028,7 +1030,7 @@ GNUNET_CRYPTO_ecc_public_key_derive (const struct GNUNET_CRYPTO_EccPublicKey *pu
1028 1030
1029 /* calulcate h_mod_n = h % n */ 1031 /* calulcate h_mod_n = h % n */
1030 h = derive_h (pub, label, context); 1032 h = derive_h (pub, label, context);
1031 n = gcry_mpi_ec_get_mpi ("n", ctx, 0 /* no copy */); 1033 n = gcry_mpi_ec_get_mpi ("n", ctx, 1);
1032 h_mod_n = gcry_mpi_new (256); 1034 h_mod_n = gcry_mpi_new (256);
1033 gcry_mpi_mod (h_mod_n, h, n); 1035 gcry_mpi_mod (h_mod_n, h, n);
1034 /* calculate v = h_mod_n * q */ 1036 /* calculate v = h_mod_n * q */
@@ -1036,6 +1038,7 @@ GNUNET_CRYPTO_ecc_public_key_derive (const struct GNUNET_CRYPTO_EccPublicKey *pu
1036 gcry_mpi_ec_mul (v, h_mod_n, q, ctx); 1038 gcry_mpi_ec_mul (v, h_mod_n, q, ctx);
1037 gcry_mpi_release (h_mod_n); 1039 gcry_mpi_release (h_mod_n);
1038 gcry_mpi_release (h); 1040 gcry_mpi_release (h);
1041 gcry_mpi_release (n);
1039 gcry_mpi_point_release (q); 1042 gcry_mpi_point_release (q);
1040 /* convert point 'v' to public key that we return */ 1043 /* convert point 'v' to public key that we return */
1041 point_to_public_key (v, ctx, result); 1044 point_to_public_key (v, ctx, result);