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 #ifndef COSE_H
13 #define COSE_H
14 
15 #include "common/oscore_edhoc_error.h"
16 
17 enum cose_context {
18 	Encrypt0,
19 	Signature1,
20 };
21 
22 /**
23  * @brief	Encodes a cose encrypt structure
24  * @param	context field in the cose encrypt structure
25  * @param	contex_len length of context
26  * @param	protected field in the cose encrypt structure
27  * @param	protected_len length of protected
28  * @param	external_aad field in the cose encrypt structure
29  * @param	external_aad_len length of external_aad
30  * @param	out the encoded structure
31  * @param	out_len length of the encoded structure
32  * @retval	err error code
33  */
34 enum err cose_enc_structure_encode(const uint8_t *context, uint32_t context_len,
35 				   const uint8_t *protected,
36 				   uint32_t protected_len,
37 				   const uint8_t *external_aad,
38 				   uint32_t external_aad_len, uint8_t *out,
39 				   uint32_t *out_len);
40 
41 /**
42  * @brief	Encodes a cose signature structure
43  * @param	context field in the cose signature structure
44  * @param	contex_len length of context
45  * @param	protected field in the cose signature structure
46  * @param	protected_len length of protected
47  * @param	external_aad field in the cose signature structure
48  * @param	external_aad_len length of external_aad
49  * @param	payload field in the cose signature structure
50  * @param	payload_len length of payload
51  * @param	out the encoded structure
52  * @param	out_len length of the encoded structure
53  * @retval	err error code
54  */
55 enum err cose_sig_structure_encode(const uint8_t *context, uint32_t context_len,
56 				   const uint8_t *protected,
57 				   uint32_t protected_len,
58 				   const uint8_t *external_aad,
59 				   uint32_t external_aad_len,
60 				   const uint8_t *payload, uint32_t payload_len,
61 				   uint8_t *out, uint32_t *out_len);
62 
63 #endif
64