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 <stdint.h>
13 
14 #include "edhoc.h"
15 
16 #include "edhoc/hkdf_info.h"
17 #include "edhoc/okm.h"
18 #include "edhoc/suites.h"
19 
20 #include "common/crypto_wrapper.h"
21 #include "common/oscore_edhoc_error.h"
22 
prk_out2exporter(enum hash_alg app_hash_alg,struct byte_array * prk_out,struct byte_array * prk_exporter)23 enum err prk_out2exporter(enum hash_alg app_hash_alg,
24 			  struct byte_array *prk_out,
25 			  struct byte_array *prk_exporter)
26 {
27 	return edhoc_kdf(app_hash_alg, prk_out, PRK_exporter, &NULL_ARRAY,
28 			 prk_exporter);
29 }
30 
prk_out_update(enum hash_alg app_hash_alg,struct byte_array * prk_out,struct byte_array * context,struct byte_array * prk_out_new)31 enum err prk_out_update(enum hash_alg app_hash_alg, struct byte_array *prk_out,
32 			struct byte_array *context,
33 			struct byte_array *prk_out_new)
34 {
35 	return edhoc_kdf(app_hash_alg, prk_out, PRK_out_update, context,
36 			 prk_out_new);
37 }
38 
edhoc_exporter(enum hash_alg app_hash_alg,enum export_label label,struct byte_array * prk_exporter,struct byte_array * out)39 enum err edhoc_exporter(enum hash_alg app_hash_alg, enum export_label label,
40 			struct byte_array *prk_exporter, struct byte_array *out)
41 {
42 	return edhoc_kdf(app_hash_alg, prk_exporter, label, &NULL_ARRAY, out);
43 }