X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Fcrypto_hkdf.c;h=494f3d0ab9efcda76f4fc560bfb3ccbecefde1de;hb=bb83cd2d04ff5a3f7a8d05fc9a724b0246e958b6;hp=96ff3804bfd8cabab35cadccdb03bb464b0d27c1;hpb=5695665772107f5c5b088f957a277efc9e3d089e;p=oweals%2Fgnunet.git diff --git a/src/util/crypto_hkdf.c b/src/util/crypto_hkdf.c index 96ff3804b..494f3d0ab 100644 --- a/src/util/crypto_hkdf.c +++ b/src/util/crypto_hkdf.c @@ -26,14 +26,39 @@ * @see http://www.rfc-editor.org/rfc/rfc5869.txt * @todo remove GNUNET references * @author Nils Durner + * + * The following list of people have reviewed this code and considered + * it correct on the date given (if you reviewed it, please + * have your name added to the list): + * + * - Christian Grothoff (08.10.2010) + * - Nathan Evans (08.10.2010) + * - Matthias Wachs (08.10.2010) */ -#include +/** + * Set this to 0 if you compile this code outside of GNUnet. + */ +#define GNUNET_BUILD 1 + +/** + * Enable debugging. + */ +#define DEBUG_HKDF 0 + +#if GNUNET_BUILD #include "platform.h" #include "gnunet_crypto_lib.h" +#else +#define GNUNET_NO 0 +#define GNUNET_YES 1 +#define GNUNET_SYSERR -1 +#include +#endif + +#include -#define DEBUG_HKDF GNUNET_NO /** * @brief Compute the HMAC @@ -136,10 +161,6 @@ GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, if (k == 0) return GNUNET_SYSERR; - // FIXME: what is the check for? - if (out_len > (2 ^ 32 * k)) - return GNUNET_SYSERR; - if (gcry_md_open(&xtr, xtr_algo, GCRY_MD_FLAG_HMAC) != GPG_ERR_NO_ERROR) return GNUNET_SYSERR; @@ -221,8 +242,11 @@ GNUNET_CRYPTO_hkdf_v (void *result, size_t out_len, if (d > 0) { if (t > 0) - memcpy (plain, result - k, k); - memset (plain + k + ctx_len, i + 1, 1); + { + memcpy (plain, result - k, k); + i++; + } + memset (plain + k + ctx_len, i, 1); gcry_md_reset (prf); #if DEBUG_HKDF dump("K(t):d", plain, plain_len); @@ -262,8 +286,6 @@ hkdf_ok: * @param xts_len length of xts * @param skm source key material * @param skm_len length of skm - * @param ctx context info - * @param ctx_len length of ctx * @return GNUNET_YES on success */ int