projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
-fix the fix
[oweals/gnunet.git]
/
src
/
util
/
crypto_kdf.c
diff --git
a/src/util/crypto_kdf.c
b/src/util/crypto_kdf.c
index 056fda52967eaeda7e4e562658786f9361920b48..b62b5c8478fd1168c4a747d26785c6b0d6855bab 100644
(file)
--- a/
src/util/crypto_kdf.c
+++ b/
src/util/crypto_kdf.c
@@
-108,7
+108,7
@@
GNUNET_CRYPTO_kdf (void *result, size_t out_len,
void
GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
gcry_mpi_t n,
void
GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
gcry_mpi_t n,
- const void *xts, size_t xts_len,
+ const void *xts, size_t xts_len,
const void *skm, size_t skm_len,
const char *ctx)
{
const void *skm, size_t skm_len,
const char *ctx)
{
@@
-121,7
+121,8
@@
GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
/* GNUNET_assert (nbits > 512); */
ctr = 0;
/* GNUNET_assert (nbits > 512); */
ctr = 0;
- do {
+ while (1)
+ {
/* Ain't clear if n is always divisible by 8 */
uint8_t buf[ (nbits-1)/8 + 1 ];
/* Ain't clear if n is always divisible by 8 */
uint8_t buf[ (nbits-1)/8 + 1 ];
@@
-144,7
+145,9
@@
GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
gcry_mpi_clear_highbit (*r, nbits);
GNUNET_assert( 0 == gcry_mpi_test_bit (*r, nbits) );
++ctr;
gcry_mpi_clear_highbit (*r, nbits);
GNUNET_assert( 0 == gcry_mpi_test_bit (*r, nbits) );
++ctr;
- } while ( 0 <= gcry_mpi_cmp(*r,n) );
+ /* We reject this FDH if either *r > n and retry with another ctr */
+ if (0 > gcry_mpi_cmp(*r, n))
+ break;
+ gcry_mpi_release (*r);
+ }
}
}
-
-