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 RETRIEVE_CRED_H
12 #define RETRIEVE_CRED_H
13 
14 #include <stdbool.h>
15 #include <stdint.h>
16 
17 #include "edhoc.h"
18 
19 #include "common/oscore_edhoc_error.h"
20 
21 enum id_cred_x_label {
22 	/*ID_CRED_x contains a key ID used to identify a pre established RPK*/
23 	kid = 4,
24 
25 	/* ID_CRED_x contains an unordered bag of X.509 certificates*/
26 	x5bag = 32,
27 	/* ID_CRED_x contains an certificate chain*/
28 	x5chain = 33,
29 	/*ID_CRED_x contains a hash used to identify a pre established cert*/
30 	x5t = 34,
31 	/*ID_CRED_x contains an uri used to identify a pre established cert*/
32 	x5u = 35,
33 
34 	/* ID_CRED_x contains an unordered bag of C509 certificates*/
35 	c5b = 52,
36 	/* ID_CRED_x contains an certificate chain of C509 certificates*/
37 	c5c = 53,
38 	/*ID_CRED_x contains a hash used to identify a pre established C509 cert*/
39 	c5t = 54,
40 	/*ID_CRED_x contains an uri used to identify a pre established C509 cert*/
41 	c5u = 55,
42 };
43 
44 /**
45  * @brief   retrives the credential of the other party and its static DH key
46  *          and when static DH authentication is used or public signature key
47  *          when digital signatures are used
48  * @param   static_dh_auth true if static DH authentication is used
49  * @param   cred_array an array containing credentials
50  * @param   cred_num number of elements in cred_array
51  * @param   id_cred ID_CRED_x
52  * @param   id_cred_len length of id_cred
53  * @param   cred CRED_x
54  * @param   cred_len length of cred
55  * @param   pk public key
56  * @param   pk_len length of pk
57  * @param   g static DH public key
58  * @param   g_len length of g
59  */
60 enum err retrieve_cred(bool static_dh_auth, struct other_party_cred *cred_array,
61 		       uint16_t cred_num, uint8_t *id_cred,
62 		       uint32_t id_cred_len, uint8_t *cred, uint32_t *cred_len,
63 		       uint8_t *pk, uint32_t *pk_len, uint8_t *g,
64 		       uint32_t *g_len);
65 
66 #endif
67