diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-11-05 22:44:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-11-05 22:44:07 +0000 |
commit | c21dec79f650b28f3375c015d7647f9e9ebb0441 (patch) | |
tree | 7964e23f62a5bd4d102469833bb2c2e1388d831d /src/util/crypto_ecc.c | |
parent | 6467925954dd99369188e1a767f780c7a838cd8e (diff) | |
download | gnunet-c21dec79f650b28f3375c015d7647f9e9ebb0441.tar.gz gnunet-c21dec79f650b28f3375c015d7647f9e9ebb0441.zip |
-addressing final crypto fixme
Diffstat (limited to 'src/util/crypto_ecc.c')
-rw-r--r-- | src/util/crypto_ecc.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c index dc69a59f3..1fd41b327 100644 --- a/src/util/crypto_ecc.c +++ b/src/util/crypto_ecc.c | |||
@@ -1396,6 +1396,7 @@ GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1396 | gcry_sexp_t pub_sexpr; | 1396 | gcry_sexp_t pub_sexpr; |
1397 | gcry_mpi_t result_x; | 1397 | gcry_mpi_t result_x; |
1398 | unsigned char xbuf[256 / 8]; | 1398 | unsigned char xbuf[256 / 8]; |
1399 | size_t rsize; | ||
1399 | 1400 | ||
1400 | /* first, extract the q = dP value from the public key */ | 1401 | /* first, extract the q = dP value from the public key */ |
1401 | if (0 != gcry_sexp_build (&pub_sexpr, NULL, | 1402 | if (0 != gcry_sexp_build (&pub_sexpr, NULL, |
@@ -1427,8 +1428,16 @@ GNUNET_CRYPTO_ecc_ecdh (const struct GNUNET_CRYPTO_EcdhePrivateKey *priv, | |||
1427 | gcry_mpi_point_release (result); | 1428 | gcry_mpi_point_release (result); |
1428 | gcry_ctx_release (ctx); | 1429 | gcry_ctx_release (ctx); |
1429 | 1430 | ||
1430 | /* FIXME: mpi_print creates an unsigned integer - is that intended | 1431 | rsize = sizeof (xbuf); |
1431 | or should we convert it to a signed integer (2-compl)? */ | 1432 | GNUNET_assert (! gcry_mpi_get_flag (result_x, GCRYMPI_FLAG_OPAQUE)); |
1433 | /* result_x can be negative here, so we do not use 'mpi_print' | ||
1434 | as that does not include the sign bit; x should be a 255-bit | ||
1435 | value, so with the sign it should fit snugly into the 256-bit | ||
1436 | xbuf */ | ||
1437 | GNUNET_assert (0 == | ||
1438 | gcry_mpi_print (GCRYMPI_FMT_STD, xbuf, rsize, &rsize, | ||
1439 | result_x)); | ||
1440 | GNUNET_assert (rsize == sizeof (xbuf)); | ||
1432 | mpi_print (xbuf, sizeof (xbuf), result_x); | 1441 | mpi_print (xbuf, sizeof (xbuf), result_x); |
1433 | GNUNET_CRYPTO_hash (xbuf, sizeof (xbuf), key_material); | 1442 | GNUNET_CRYPTO_hash (xbuf, sizeof (xbuf), key_material); |
1434 | gcry_mpi_release (result_x); | 1443 | gcry_mpi_release (result_x); |