/
cose_configure.h
177 lines (152 loc) · 3.95 KB
/
cose_configure.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//
// Determine which cryptographic library we are going to be using
//
#pragma once
#if defined(USE_MBED_TLS)
#if defined(USE_OPEN_SSL) || defined(USE_BCRYPT)
#error Only Define One Crypto Package
#endif
#elif defined(USE_BCRYPT)
#if defined(USE_OPENSSL)
#error Only Define One Crypto Package
#endif
#elif !defined(USE_OPEN_SSL)
#include <openssl/opensslv.h>
#define USE_OPEN_SSL
#endif
//
// Define which AES GCM algorithms are being used
//
#define USE_AES_GCM_128
#define USE_AES_GCM_192
#define USE_AES_GCM_256
#if defined(USE_AES_GCM_128) || defined(USE_AES_GCM_192) || \
defined(USE_AES_GCM_256)
#define USE_AES_GCM
#endif
//
// Define which AES CCM algorithms are being used
//
#define USE_AES_CCM_16_64_128
#define USE_AES_CCM_16_64_256
#define USE_AES_CCM_64_64_128
#define USE_AES_CCM_64_64_256
#define USE_AES_CCM_16_128_128
#define USE_AES_CCM_16_128_256
#define USE_AES_CCM_64_128_128
#define USE_AES_CCM_64_128_256
#define INCLUDE_AES_CCM
//
// Define which HMAC-SHA algorithms are being used
//
#define USE_HMAC_256_64
#define USE_HMAC_256_256
#define USE_HMAC_384_384
#define USE_HMAC_512_512
#if defined(USE_HMAC_256_64) || defined(USE_HMAC_256_256) || \
defined(USE_HMAC_384_384) || defined(USE_HMAC_512_512)
#define USE_HMAC
#endif
//
// Define which AES CBC-MAC algorithms are to be used
//
#if !defined(USE_MBED_TLS)
#define USE_AES_CBC_MAC_128_64
#define USE_AES_CBC_MAC_128_128
#define USE_AES_CBC_MAC_256_64
#define USE_AES_CBC_MAC_256_128
#endif // !defined(USE_MBED_TLS)
//
// Define which ECDH algorithms are to be used
//
#if !defined(USE_MBED_TLS)
#define USE_ECDH_ES_HKDF_256
#define USE_ECDH_ES_HKDF_512
#define USE_ECDH_SS_HKDF_256
#define USE_ECDH_SS_HKDF_512
#if defined(USE_ECDH_ES_HKDF_256) || defined(USE_ECDH_ES_HKDF_512) || \
defined(USE_ECDH_SS_HKDF_256) || defined(USE_ECDH_SS_HKDF_512)
#define USE_ECDH 1
#define USE_HKDF_SHA2 1
#endif
#endif // !defined(USE_MBED_TLS)
#if !defined(USE_MBED_TLS)
#define USE_ECDH_ES_A128KW
#define USE_ECDH_ES_A192KW
#define USE_ECDH_ES_A256KW
#define USE_ECDH_SS_A128KW
#define USE_ECDH_SS_A192KW
#define USE_ECDH_SS_A256KW
#if defined(USE_ECDH_ES_A128KW) || defined(USE_ECDH_ES_A192KW) || \
defined(USE_ECDH_ES_A256KW) || defined(USE_ECDH_SS_A128KW) || \
defined(USE_ECDH_SS_A192KW) || defined(USE_ECDH_SS_A256KW)
#define USE_ECDH 1
#define USE_HKDF_AES 1
#endif
#endif // !defined(USE_MBED_TLS)
//
// Define which Key Wrap functions are to be used
//
#if !defined(USE_MBED_TLS)
#define USE_AES_KW_128
#define USE_AES_KW_192
#define USE_AES_KW_256
#endif // !defined(USE_MBED_TLS)
//
// Define which of the DIRECT + KDF algorithms are to be used
//
#if !defined(USE_MBED_TLS)
#define USE_Direct_HKDF_HMAC_SHA_256
#define USE_Direct_HKDF_HMAC_SHA_512
#define USE_Direct_HKDF_AES_128
#define USE_Direct_HKDF_AES_256
#if defined(USE_Direct_HKDF_HMAC_SHA_256) || \
defined(USE_Direct_HKDF_HMAC_SHA_512)
#define USE_HKDF_SHA2 1
#endif
#if defined(USE_Direct_HKDF_AES_128) || defined(USE_Direct_KDF_AES_256)
#define USE_HKDF_AES 1
#endif
#endif // !defined(USE_MBED_TLS)
//
// Define which of the signature algorithms are to be used
//
#define USE_ECDSA_SHA_256
#define USE_ECDSA_SHA_384
#define USE_ECDSA_SHA_512
#if !defined(USE_MBED_TLS)
// MBEDTLS currently supports ECDH for X25519 but not EdDSA
#if OPENSSL_VERSION_NUMBER > 0x10100000L
// Requires OPEN SSL 1.1.1 to build
#define USE_EDDSA
#else
#pragma message("OPENSSL VERSION IS " #OPENSSL_VERISON_NUMBER)
#endif
#endif // !defined (USE_MBED_TLS)
//
// Define which COSE objects are included
//
#ifndef INCLUDE_ENCRYPT
#define INCLUDE_ENCRYPT 1
#endif
#ifndef INCLUDE_ENCRYPT0
#define INCLUDE_ENCRYPT0 1
#endif
#ifndef INCLUDE_MAC
#define INCLUDE_MAC 1
#endif
#ifndef INCLUDE_MAC0
#define INCLUDE_MAC0 1
#endif
#ifndef INCLUDE_SIGN
#define INCLUDE_SIGN 1
#endif
#ifndef INCLUDE_SIGN1
#define INCLUDE_SIGN1 1
#endif
#ifndef INCLUDE_COUNTERSIGNATURE
#define INCLUDE_COUNTERSIGNATURE 1
#endif
#ifndef INCLUDE_COUNTERSIGNATURE1
#define INCLUDE_COUNTERSIGNATURE1 0
#endif