Mistake on this page?
Report an issue in GitHub or email us
t_cose_defines.h
Go to the documentation of this file.
1 /*
2  * t_cose_defines.h
3  *
4  * Copyright (c) 2018-2019, Laurence Lundblade. All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * See BSD-3-Clause license in README.md
9  */
10 
11 #ifndef __T_COSE_DEFINES_H__
12 #define __T_COSE_DEFINES_H__
13 
14 /**
15  * \file t_cose_defines.h
16  *
17  * \brief Constants from COSE standard and IANA registry.
18  *
19  * This file contains constants identifiers defined in [COSE (RFC
20  * 8152)] (https://tools.ietf.org/html/rfc8152) and [IANA COSE
21  * Registry] (https://www.iana.org/assignments/cose/cose.xhtml). They
22  * include algorithm IDs and other constants.
23  *
24  * Many constants in the IANA registry are not included here yet as
25  * they are not needed by t_cose. They can be added if they become
26  * needed.
27  */
28 
29 
30 
31 
32 /* --------------- COSE Header parameters -----------
33  * https://www.iana.org/assignments/cose/cose.xhtml#header-parameters
34  */
35 
36 /**
37  * \def COSE_HEADER_PARAM_ALG
38  *
39  * \brief Label of COSE header that indicates an algorithm.
40  */
41 #define COSE_HEADER_PARAM_ALG 1
42 
43 /**
44  * \def COSE_HEADER_PARAM_KID
45  *
46  * \brief Label of COSE header that contains a key ID.
47  */
48 #define COSE_HEADER_PARAM_KID 4
49 
50 
51 
52 
53 /* ------------ COSE Header Algorithm Parameters --------------
54  * https://www.iana.org/assignments/cose/cose.xhtml#header-algorithm-parameters
55  *
56  * None of these are defined here yet, as they are not needed by t_cose yet.
57  */
58 
59 
60 
61 
62 /* ------------- COSE Algorithms ----------------------------
63  * https://www.iana.org/assignments/cose/cose.xhtml#algorithms
64  */
65 
66 /**
67  * \def COSE_ALGORITHM_ES256
68  *
69  * \brief Indicates ECDSA with SHA-256.
70  *
71  * Value for \ref COSE_HEADER_PARAM_ALG to indicate ECDSA. w/SHA-256
72  */
73 #define COSE_ALGORITHM_ES256 -7
74 
75 /**
76  * \def COSE_ALGORITHM_ES384
77  *
78  * \brief Indicates ECDSA with SHA-384.
79  *
80  * Value for \ref COSE_HEADER_PARAM_ALG to indicate ECDSA. w/SHA-384
81  */
82 #define COSE_ALGORITHM_ES384 -35
83 
84 /**
85  * \def COSE_ALGORITHM_ES512
86  *
87  * \brief Indicates ECDSA with SHA-384.
88  *
89  * Value for \ref COSE_HEADER_PARAM_ALG to indicate ECDSA. w/SHA-512
90  */
91 #define COSE_ALGORITHM_ES512 -36
92 
93 
94 /**
95  * \def COSE_ALG_SHA256_PROPRIETARY
96  *
97  * \brief COSE-style algorithm ID for SHA256. The official COSE
98  * algorithm registry doesn't yet define an ID for a pure hash
99  * function. One is needed for internal use, so this is defined.
100  *
101  * This is only used internally in the implementation and doesn't
102  * appear in any protocol messages so there are no interoperability
103  * issues. When this gets defined in the IANA registry, that value can
104  * be substituted here and all will work fine.
105  */
106 #define COSE_ALG_SHA256_PROPRIETARY -72000
107 
108 
109 
110 
111 /* ---------- COSE Key Common Parameters --------------
112  * https://www.iana.org/assignments/cose/cose.xhtml#key-common-parameters
113  */
114 
115 /**
116  * \def COSE_KEY_COMMON_KTY
117  *
118  * \brief Label for data item containing the key type.
119  *
120  * In a \c COSE_Key, label that indicates the data item containing the
121  * key type.
122  */
123 #define COSE_KEY_COMMON_KTY 1
124 
125 /**
126  * \def COSE_KEY_COMMON_KID
127  *
128  * \brief Label for data item containing the key's kid.
129  *
130  * In a \c COSE_Key, label that indicates the data item containing the
131  * kid of this key.
132  */
133 #define COSE_KEY_COMMON_KID 2
134 
135 
136 
137 
138 /* ---------- COSE Key Type Parameters --------------------
139  * https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters
140  */
141 
142 /**
143  * \def COSE_KEY_PARAM_CRV
144  *
145  * \brief Label for data item indicating EC curve.
146  *
147  * In a \c COSE_Key that holds an EC key of either type \ref
148  * COSE_KEY_TYPE_EC2 or \ref COSE_KEY_TYPE_OKP this labels the data
149  * item with the EC curve for the key.
150  */
151 #define COSE_KEY_PARAM_CRV -1
152 
153 /**
154  * \def COSE_KEY_PARAM_X_COORDINATE
155  *
156  * \brief Label for data item that is an X coordinate of an EC key.
157  *
158  * In a \c COSE_Key that holds an EC key, this is label that indicates
159  * the data item containing the X coordinate.
160  *
161  * This is used for both key types \ref COSE_KEY_TYPE_EC2 and \ref
162  * COSE_KEY_TYPE_OKP.
163  */
164 #define COSE_KEY_PARAM_X_COORDINATE -2
165 
166 /**
167  * \def COSE_KEY_PARAM_Y_COORDINATE
168  *
169  * \brief Label for data item that is a y coordinate of an EC key.
170  *
171  * In a COSE_Key that holds an EC key, this is label that indicates
172  * the data item containing the Y coordinate.
173  *
174  * This is used only for key type \ref COSE_KEY_TYPE_EC2.
175  */
176 #define COSE_KEY_PARAM_Y_COORDINATE -3
177 
178 /**
179  * \def COSE_KEY_PARAM_PRIVATE_D
180  *
181  * \brief Label for data item that is d, the private part of EC key.
182  *
183  * In a \c COSE_Key that holds an EC key, this is label that indicates
184  * the data item containing the Y coordinate.
185  *
186  * This is used for both key types \ref COSE_KEY_TYPE_EC2 and \ref
187  * COSE_KEY_TYPE_OKP.
188  */
189 #define COSE_KEY_PARAM_PRIVATE_D -4
190 
191 
192 
193 
194 /* ---------- COSE Key Types --------------------------------
195  * https://www.iana.org/assignments/cose/cose.xhtml#key-type
196  */
197 
198 /**
199  * \def COSE_KEY_TYPE_OKP
200  *
201  * \brief Key type is Octet Key Pair
202  *
203  * In a \c COSE_Key, this is a value of the data item labeled \ref
204  * COSE_KEY_COMMON_KTY that indicates the \c COSE_Key is some sort of
205  * key pair represented by some octets. It may or may not be an EC
206  * key.
207  */
208 #define COSE_KEY_TYPE_OKP 1
209 
210 /**
211  * \def COSE_KEY_TYPE_EC2
212  *
213  * \brief Key is a 2-parameter EC key.
214  *
215  * In a \c COSE_Key, this is a value of the data item labeled \ref
216  * COSE_KEY_COMMON_KTY that indicates the \c COSE_Key is an EC key
217  * specified with two coordinates, X and Y.
218  */
219 #define COSE_KEY_TYPE_EC2 2
220 
221 /**
222  * \def COSE_KEY_TYPE_SYMMETRIC
223  *
224  * \brief Key is a symmetric key.
225  *
226  * In a \c COSE_Key, this is a value of the data item labeled \ref
227  * COSE_KEY_COMMON_KTY that indicates the \c COSE_Key is a symmetric
228  * key.
229  */
230 #define COSE_KEY_TYPE_SYMMETRIC 4
231 
232 
233 
234 
235 /* ----------- COSE Elliptic Curves ---------------------
236  * https://www.iana.org/assignments/cose/cose.xhtml#elliptic-curves
237  */
238 
239 /**
240  * \def COSE_ELLIPTIC_CURVE_P_256
241  *
242  * \brief Key type for NIST P-256 key
243  *
244  * In a \c COSE_Key, this is a value of the data item labeled \ref
245  * COSE_KEY_PARAM_CRV to indicate the NIST P-256 curve, also known as
246  * secp256r1.
247  *
248  * This key type is always \ref COSE_KEY_TYPE_EC2.
249  */
250 #define COSE_ELLIPTIC_CURVE_P_256 1
251 
252 /**
253  * \def COSE_ELLIPTIC_CURVE_P_384
254  *
255  * \brief Key type for NIST P-384 key
256  *
257  * In a \c COSE_Key, this is a value of the data item labeled \ref
258  * COSE_KEY_PARAM_CRV to indicate the NIST P-384 curve, also known as
259  * secp384r1.
260  *
261  * This key type is always \ref COSE_KEY_TYPE_EC2.
262  */
263 #define COSE_ELLIPTIC_CURVE_P_384 2
264 
265 /**
266  * \def COSE_ELLIPTIC_CURVE_P_521
267  *
268  * \brief Key type for NIST P-521 key
269  *
270  * In a \c COSE_Key, this is a value of the data item labeled \ref
271  * COSE_KEY_PARAM_CRV to indicate the NIST P-521 curve, also known as
272  * secp521r1.
273  */
274 #define COSE_ELLIPTIC_CURVE_P_521 3
275 
276 
277 
278 
279 /* ------- Constants from RFC 8152 ---------
280  */
281 
282 /**
283  * \def COSE_SIG_CONTEXT_STRING_SIGNATURE1
284  *
285  * \brief This is a string constant used by COSE to label \c COSE_Sign1
286  * structures. See RFC 8152, section 4.4.
287  */
288 #define COSE_SIG_CONTEXT_STRING_SIGNATURE1 "Signature1"
289 
290 
291 #endif /* __T_COSE_DEFINES_H__ */
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.