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			Retrieves the credential of the other party and
46  * 				its static DH key when static DH
47  * 				authentication is used or public signature key
48  *				when digital signatures are used.
49  *
50  * @param static_dh_auth 	True if static DH authentication is used.
51  * @param cred_array 		An array containing credentials.
52  * @param[in] id_cred 		ID_CRED_x.
53  * @param[out] cred 		CRED_x.
54  * @param[out] pk 		Public key.
55  * @param[out] g 		Static DH public key.
56  * @retval			Ok or error.
57  */
58 enum err retrieve_cred(bool static_dh_auth, struct cred_array *cred_array,
59 		       struct byte_array *id_cred, struct byte_array *cred,
60 		       struct byte_array *pk, struct byte_array *g);
61 
62 #endif
63