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 #ifndef SUITES_H
12 #define SUITES_H
13 
14 #include <stdint.h>
15 
16 #include "common/oscore_edhoc_error.h"
17 
18 /*see https://www.iana.org/assignments/cose/cose.xhtml#algorithms for algorithm number reference*/
19 
20 enum suite_label {
21 	SUITE_0 = 0,
22 	SUITE_1 = 1,
23 	SUITE_2 = 2,
24 	SUITE_3 = 3,
25 };
26 
27 enum aead_alg {
28 	AES_CCM_16_64_128 = 10,
29 	AES_CCM_16_128_128 = 30,
30 };
31 
32 enum hash_alg { SHA_256 = -16 };
33 
34 enum ecdh_alg {
35 	P256 = 1,
36 	X25519 = 4,
37 };
38 
39 enum sign_alg {
40 	ES256 = -7,
41 	EdDSA = -8,
42 };
43 
44 enum mac_len {
45 	MAC8 = 8,
46 	MAC16 = 16,
47 };
48 
49 struct suite {
50 	enum suite_label suite_label;
51 	enum aead_alg edhoc_aead;
52 	enum hash_alg edhoc_hash;
53 	enum mac_len edhoc_mac_len_static_dh;
54 	enum ecdh_alg edhoc_ecdh;
55 	enum sign_alg edhoc_sign;
56 	enum aead_alg app_aead;
57 	enum hash_alg app_hash;
58 };
59 
60 /**
61  * @brief   retrieves the algorithms coresponding to a given suite label
62  * @param   label the suite label
63  * @param   suite the algorithms coresponding to label
64  */
65 enum err get_suite(enum suite_label label, struct suite *suite);
66 
67 /**
68  *
69  *
70  */
71 uint32_t get_hash_len(enum hash_alg alg);
72 
73 /**
74  *
75  *
76  */
77 uint32_t get_aead_mac_len(enum aead_alg alg);
78 uint32_t get_aead_key_len(enum aead_alg alg);
79 uint32_t get_aead_iv_len(enum aead_alg alg);
80 uint32_t get_signature_len(enum sign_alg alg);
81 uint32_t get_ecdh_pk_len(enum ecdh_alg alg);
82 #endif
83