1 /*
2    Copyright (c) 2021 Fraunhofer AISEC. See the COPYRIGHT
3    file at the top-level directory of this distribution.
4 
5    Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6    http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7    <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8    option. This file may not be copied, modified, or distributed
9    except according to those terms.
10 */
11 
12 #include "edhoc/buffer_sizes.h"
13 
14 #include "edhoc/hkdf_info.h"
15 #include "edhoc/okm.h"
16 
17 #include "common/crypto_wrapper.h"
18 #include "common/oscore_edhoc_error.h"
19 
20 #include "common/print_util.h"
21 
edhoc_kdf(enum hash_alg hash_alg,const struct byte_array * prk,uint8_t label,struct byte_array * context,struct byte_array * okm)22 enum err edhoc_kdf(enum hash_alg hash_alg, const struct byte_array *prk,
23 		   uint8_t label, struct byte_array *context,
24 		   struct byte_array *okm)
25 {
26 	PRINTF("INFO_MAX_SIZE: %d\n", INFO_MAX_SIZE);
27 	PRINTF("context->len: %d\n", context->len);
28 	BYTE_ARRAY_NEW(info, INFO_MAX_SIZE, context->len + ENCODING_OVERHEAD);
29 
30 	TRY(create_hkdf_info(label, context, okm->len, &info));
31 
32 	PRINT_ARRAY("info", info.ptr, info.len);
33 	return hkdf_expand(hash_alg, prk, &info, okm);
34 }
35