2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file src/util/crypto_kdf.c
23 * @brief Key derivation
30 #include "gnunet_crypto_lib.h"
32 #define LOG(kind,...) GNUNET_log_from (kind, "util", __VA_ARGS__)
36 * @param result buffer for the derived key, allocated by caller
37 * @param out_len desired length of the derived key
39 * @param xts_len length of xts
40 * @param skm source key material
41 * @param skm_len length of skm
42 * @param argp va_list of void * & size_t pairs for context chunks
43 * @return GNUNET_YES on success
46 GNUNET_CRYPTO_kdf_v (void *result, size_t out_len, const void *xts,
47 size_t xts_len, const void *skm, size_t skm_len,
51 * "Finally, we point out to a particularly advantageous instantiation using
52 * HMAC-SHA512 as XTR and HMAC-SHA256 in PRF* (in which case the output from SHA-512 is
53 * truncated to 256 bits). This makes sense in two ways: First, the extraction part is where we need a
54 * stronger hash function due to the unconventional demand from the hash function in the extraction
55 * setting. Second, as shown in Section 6, using HMAC with a truncated output as an extractor
56 * allows to prove the security of HKDF under considerably weaker assumptions on the underlying
59 * http://eprint.iacr.org/2010/264
62 return GNUNET_CRYPTO_hkdf_v (result, out_len, GCRY_MD_SHA512, GCRY_MD_SHA256,
63 xts, xts_len, skm, skm_len, argp);
68 * @param result buffer for the derived key, allocated by caller
69 * @param out_len desired length of the derived key
71 * @param xts_len length of xts
72 * @param skm source key material
73 * @param skm_len length of skm
74 * @param ... void * & size_t pairs for context chunks
75 * @return GNUNET_YES on success
78 GNUNET_CRYPTO_kdf (void *result, size_t out_len, const void *xts,
79 size_t xts_len, const void *skm, size_t skm_len, ...)
84 va_start (argp, skm_len);
85 ret = GNUNET_CRYPTO_kdf_v (result, out_len, xts, xts_len, skm, skm_len, argp);