* @return #GNUNET_YES on success
*/
int
-GNUNET_CRYPTO_kdf_v (void *result, size_t out_len,
- const void *xts, size_t xts_len,
- const void *skm, size_t skm_len,
+GNUNET_CRYPTO_kdf_v (void *result,
+ size_t out_len,
+ const void *xts,
+ size_t xts_len,
+ const void *skm,
+ size_t skm_len,
va_list argp)
{
/*
* http://eprint.iacr.org/2010/264
*/
- return GNUNET_CRYPTO_hkdf_v (result, out_len, GCRY_MD_SHA512, GCRY_MD_SHA256,
- xts, xts_len, skm, skm_len, argp);
+ return GNUNET_CRYPTO_hkdf_v (result,
+ out_len,
+ GCRY_MD_SHA512,
+ GCRY_MD_SHA256,
+ xts,
+ xts_len,
+ skm,
+ skm_len,
+ argp);
}
* @return #GNUNET_YES on success
*/
int
-GNUNET_CRYPTO_kdf (void *result, size_t out_len,
- const void *xts, size_t xts_len,
- const void *skm, size_t skm_len, ...)
+GNUNET_CRYPTO_kdf (void *result,
+ size_t out_len,
+ const void *xts,
+ size_t xts_len,
+ const void *skm,
+ size_t skm_len, ...)
{
va_list argp;
int ret;
va_start (argp, skm_len);
- ret = GNUNET_CRYPTO_kdf_v (result, out_len, xts, xts_len, skm, skm_len, argp);
+ ret = GNUNET_CRYPTO_kdf_v (result,
+ out_len,
+ xts,
+ xts_len,
+ skm,
+ skm_len,
+ argp);
va_end (argp);
return ret;
void
GNUNET_CRYPTO_kdf_mod_mpi (gcry_mpi_t *r,
gcry_mpi_t n,
- const void *xts, size_t xts_len,
- const void *skm, size_t skm_len,
+ const void *xts, size_t xts_len,
+ const void *skm, size_t skm_len,
const char *ctx)
{
gcry_error_t rc;
/* 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 ];
GNUNET_assert( 0 == gcry_mpi_test_bit (*r, nbits) );
++ctr;
/* We reject this FDH if either *r > n and retry with another ctr */
- } while ( 0 <= gcry_mpi_cmp(*r,n) );
+ if (0 > gcry_mpi_cmp(*r, n))
+ break;
+ gcry_mpi_release (*r);
+ }
}
-
+/* end of crypto_kdf.c */