1 // Copyright 2021 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 ////////////////////////////////////////////////////////////////////////////////
16 
17 //! Enumerations for IANA-managed values.
18 //!
19 //! Sources:
20 //! - <https://www.iana.org/assignments/cose/cose.xhtml>
21 //! - <https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml>
22 //! - <https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#content-formats>
23 //! - <https://www.iana.org/assignments/cwt/cwt.xhtml>
24 
25 #[cfg(test)]
26 mod tests;
27 
28 /// Trait indicating an enum that can be constructed from `i64` values.
29 pub trait EnumI64: Sized + Eq {
from_i64(i: i64) -> Option<Self>30     fn from_i64(i: i64) -> Option<Self>;
to_i64(&self) -> i6431     fn to_i64(&self) -> i64;
32 }
33 
34 /// Trait indicating an enum with a range of private values.
35 pub trait WithPrivateRange {
is_private(i: i64) -> bool36     fn is_private(i: i64) -> bool;
37 }
38 
39 /// Generate an enum with associated values, plus a `from_i64` method.
40 macro_rules! iana_registry {
41     ( $(#[$attr:meta])* $enum_name:ident {$($(#[$fattr:meta])* $name:ident: $val:expr,)* } ) => {
42         #[allow(non_camel_case_types)]
43         $(#[$attr])*
44         #[non_exhaustive]
45         #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
46         pub enum $enum_name {
47             $($(#[$fattr])* $name = $val,)*
48         }
49         impl EnumI64 for $enum_name {
50             fn from_i64(i: i64) -> Option<Self> {
51                 match i {
52                     $(x if x == Self::$name as i64 => Some(Self::$name),)*
53                     _ => None,
54                 }
55             }
56             #[inline]
57             fn to_i64(&self) -> i64 {
58                 *self as i64
59             }
60         }
61     }
62 }
63 
64 iana_registry! {
65     /// IANA-registered COSE header parameters.
66     ///
67     /// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#header-parameters>
68     /// as of 2021-03-19.
69     HeaderParameter {
70         /// Reserved
71         Reserved: 0,
72         /// Cryptographic algorithm to use
73         ///
74         /// Associated value of type int / tstr
75         Alg: 1,
76         /// Critical headers to be understood
77         ///
78         /// Associated value of type [+ label]
79         Crit: 2,
80         /// Content type of the payload
81         ///
82         /// Associated value of type tstr / uint
83         ContentType: 3,
84         /// Key identifier
85         ///
86         /// Associated value of type bstr
87         Kid: 4,
88         /// Full Initialization Vector
89         ///
90         /// Associated value of type bstr
91         Iv: 5,
92         /// Partial Initialization Vector
93         ///
94         /// Associated value of type bstr
95         PartialIv: 6,
96         /// CBOR-encoded signature structure
97         ///
98         /// Associated value of type COSE_Signature / [+ COSE_Signature ]
99         CounterSignature: 7,
100         /// Counter signature with implied signer and headers
101         ///
102         /// Associated value of type bstr
103         CounterSignature0: 9,
104         /// Identifies the context for the key identifier
105         ///
106         /// Associated value of type bstr
107         KidContext: 10,
108         /// An unordered bag of X.509 certificates
109         ///
110         /// Associated value of type COSE_X509
111         X5Bag: 32,
112         /// An ordered chain of X.509 certificates
113         ///
114         /// Associated value of type COSE_X509
115         X5Chain: 33,
116         /// Hash of an X.509 certificate
117         ///
118         /// Associated value of type COSE_CertHash
119         X5T: 34,
120         /// URI pointing to an X.509 certificate
121         ///
122         /// Associated value of type uri
123         X5U: 35,
124         /// Challenge Nonce
125         ///
126         /// Associated value of type bstr
127         CuphNonce: 256,
128         /// Public Key
129         ///
130         /// Associated value of type array
131         CuphOwnerPubKey: 257,
132     }
133 }
134 
135 /// Integer values for COSE header parameters below this value are reserved for private use.
136 pub const HEADER_PARAMETER_PRIVATE_USE_MAX: i64 = -65536;
137 
138 impl WithPrivateRange for HeaderParameter {
is_private(i: i64) -> bool139     fn is_private(i: i64) -> bool {
140         i < HEADER_PARAMETER_PRIVATE_USE_MAX
141     }
142 }
143 
144 iana_registry! {
145     /// IANA-registered COSE header algorithm parameters.
146     ///
147     /// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#header-algorithm-parameters>
148     /// as of 2021-03-19.
149     HeaderAlgorithmParameter {
150         /// Party V other provided information
151         ///
152         /// Associated value of type bstr
153         PartyVOther: -26,
154         /// Party V provided nonce
155         ///
156         /// Associated value of type bstr / int
157         PartyVNonce: -25,
158         /// Party V identity information
159         ///
160         /// Associated value of type bstr
161         PartyVIdentity: -24,
162         /// Party U other provided information
163         ///
164         /// Associated value of type bstr
165         PartyUOther: -23,
166         /// Party U provided nonce
167         ///
168         /// Associated value of type bstr / int
169         PartyUNonce: -22,
170         /// Party U identity information
171         ///
172         /// Associated value of type bstr
173         PartyUIdentity: -21,
174         /// Random salt
175         ///
176         /// Associated value of type bstr
177         Salt: -20,
178         /// Static public key identifier for the sender
179         ///
180         /// Associated value of type bstr
181         StaticKeyId: -3,
182         /// Static public key for the sender
183         ///
184         /// Associated value of type COSE_Key
185         StaticKey: -2,
186         /// Ephemeral public key for the sender
187         ///
188         /// Associated value of type COSE_Key
189         EphemeralKey: -1,
190     }
191 }
192 
193 iana_registry! {
194     /// IANA-registered COSE algorithms.
195     ///
196     /// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#algorithms>
197     /// as of 2021-03-19.
198     Algorithm {
199         /// RSASSA-PKCS1-v1_5 using SHA-1
200         RS1: -65535,
201         /// WalnutDSA signature
202         WalnutDSA: -260,
203         /// RSASSA-PKCS1-v1_5 using SHA-512
204         RS512: -259,
205         /// RSASSA-PKCS1-v1_5 using SHA-384
206         RS384: -258,
207         /// RSASSA-PKCS1-v1_5 using SHA-256
208         RS256: -257,
209         /// ECDSA using secp256k1 curve and SHA-256
210         ES256K: -47,
211         /// HSS/LMS hash-based digital signature
212         HSS_LMS: -46,
213         /// SHAKE-256 512-bit Hash Value
214         SHAKE256: -45,
215         /// SHA-2 512-bit Hash
216         SHA_512: -44,
217         /// SHA-2 384-bit Hash
218         SHA_384: -43,
219         /// RSAES-OAEP w/ SHA-512
220         RSAES_OAEP_SHA_512: -42,
221         /// RSAES-OAEP w/ SHA-256
222         RSAES_OAEP_SHA_256: -41,
223         /// RSAES-OAEP w/ SHA-1
224         RSAES_OAEP_RFC_8017_default: -40,
225         /// RSASSA-PSS w/ SHA-512
226         PS512: -39,
227         /// RSASSA-PSS_SHA-384
228         PS384: -38,
229         /// RSASSA-PSS w/ SHA-256
230         PS256: -37,
231         /// ECDSA w/ SHA-512
232         ES512: -36,
233         /// ECDSA w/ SHA-384
234         ES384: -35,
235         /// ECDH SS w/ Concat KDF and AES Key Wrap w/ 256-bit key
236         ECDH_SS_A256KW: -34,
237         /// ECDH SS w/ Concat KDF and AES Key Wrap w/ 192-bit key
238         ECDH_SS_A192KW: -33,
239         /// ECDH SS w/ Concat KDF and AES Key Wrap w/ 128-bit key
240         ECDH_SS_A128KW: -32,
241         /// ECDH ES w/ Concat KDF and AES Key Wrap w/ 256-bit key
242         ECDH_ES_A256KW: -31,
243         /// ECDH ES w/ Concat KDF and AES Key Wrap w/ 192-bit key
244         ECDH_ES_A192KW: -30,
245         /// ECDH ES w/ Concat KDF and AES Key Wrap w/ 128-bit key
246         ECDH_ES_A128KW: -29,
247         /// ECDH SS w/ HKDF - generate key directly
248         ECDH_SS_HKDF_512: -28,
249         /// ECDH SS w/ HKDF - generate key directly
250         ECDH_SS_HKDF_256: -27,
251         /// ECDH ES w/ HKDF - generate key directly
252         ECDH_ES_HKDF_512: -26,
253         /// ECDH ES w/ HKDF - generate key directly
254         ECDH_ES_HKDF_256: -25,
255         /// SHAKE-128 256-bit Hash Value
256         SHAKE128: -18,
257         /// SHA-2 512-bit Hash truncated to 256-bits
258         SHA_512_256: -17,
259         /// SHA-2 256-bit Hash
260         SHA_256: -16,
261         /// SHA-2 256-bit Hash truncated to 64-bits
262         SHA_256_64: -15,
263         /// SHA-1 Hash
264         SHA_1: -14,
265         /// Shared secret w/ AES-MAC 256-bit key
266         Direct_HKDF_AES_256: -13,
267         /// Shared secret w/ AES-MAC 128-bit key
268         Direct_HKDF_AES_128: -12,
269         /// Shared secret w/ HKDF and SHA-512
270         Direct_HKDF_SHA_512: -11,
271         /// Shared secret w/ HKDF and SHA-256
272         Direct_HKDF_SHA_256: -10,
273         /// EdDSA
274         EdDSA: -8,
275         /// ECDSA w/ SHA-256
276         ES256: -7,
277         /// Direct use of CEK
278         Direct: -6,
279         /// AES Key Wrap w/ 256-bit key
280         A256KW: -5,
281         /// AES Key Wrap w/ 192-bit key
282         A192KW: -4,
283         /// AES Key Wrap w/ 128-bit key
284         A128KW: -3,
285         /// Reserved
286         Reserved: 0,
287         /// AES-GCM mode w/ 128-bit key, 128-bit tag
288         A128GCM: 1,
289         /// AES-GCM mode w/ 192-bit key, 128-bit tag
290         A192GCM: 2,
291         /// AES-GCM mode w/ 256-bit key, 128-bit tag
292         A256GCM: 3,
293         /// HMAC w/ SHA-256 truncated to 64 bits
294         HMAC_256_64: 4,
295         /// HMAC w/ SHA-256
296         HMAC_256_256: 5,
297         /// HMAC w/ SHA-384
298         HMAC_384_384: 6,
299         /// HMAC w/ SHA-512
300         HMAC_512_512: 7,
301         /// AES-CCM mode 128-bit key, 64-bit tag, 13-byte nonce
302         AES_CCM_16_64_128: 10,
303         /// AES-CCM mode 256-bit key, 64-bit tag, 13-byte nonce
304         AES_CCM_16_64_256: 11,
305         /// AES-CCM mode 128-bit key, 64-bit tag, 7-byte nonce
306         AES_CCM_64_64_128: 12,
307         /// AES-CCM mode 256-bit key, 64-bit tag, 7-byte nonce
308         AES_CCM_64_64_256: 13,
309         /// AES-MAC 128-bit key, 64-bit tag
310         AES_MAC_128_64: 14,
311         /// AES-MAC 256-bit key, 64-bit tag
312         AES_MAC_256_64: 15,
313         /// ChaCha20/Poly1305 w/ 256-bit key, 128-bit tag
314         ChaCha20Poly1305: 24,
315         /// AES-MAC 128-bit key, 128-bit tag
316         AES_MAC_128_128: 25,
317         /// AES-MAC 256-bit key, 128-bit tag
318         AES_MAC_256_128: 26,
319         /// AES-CCM mode 128-bit key, 128-bit tag, 13-byte nonce
320         AES_CCM_16_128_128: 30,
321         /// AES-CCM mode 256-bit key, 128-bit tag, 13-byte nonce
322         AES_CCM_16_128_256: 31,
323         /// AES-CCM mode 128-bit key, 128-bit tag, 7-byte nonce
324         AES_CCM_64_128_128: 32,
325         /// AES-CCM mode 256-bit key, 128-bit tag, 7-byte nonce
326         AES_CCM_64_128_256: 33,
327         /// For doing IV generation for symmetric algorithms.
328         IV_GENERATION: 34,
329     }
330 }
331 
332 /// Integer values for COSE algorithms below this value are reserved for private use.
333 pub const ALGORITHM_PRIVATE_USE_MAX: i64 = -65536;
334 
335 impl WithPrivateRange for Algorithm {
is_private(i: i64) -> bool336     fn is_private(i: i64) -> bool {
337         i < ALGORITHM_PRIVATE_USE_MAX
338     }
339 }
340 
341 iana_registry! {
342     /// IANA-registered COSE common key parameters.
343     ///
344     /// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#key-common-parameters>
345     /// as of 2021-03-19.
346     KeyParameter {
347         /// Reserved value.
348         Reserved: 0,
349         /// Identification of the key type
350         ///
351         /// Associated value of type tstr / int
352         Kty: 1,
353         /// Key identification value - match to kid in message
354         ///
355         /// Associated value of type bstr
356         Kid: 2,
357         /// Key usage restriction to this algorithm
358         ///
359         /// Associated value of type tstr / int
360         Alg: 3,
361         /// Restrict set of permissible operations
362         ///
363         /// Associated value of type [+ (tstr / int)]
364         KeyOps: 4,
365         /// Base IV to be XORed with Partial IVs
366         ///
367         /// Associated value of type bstr
368         BaseIv: 5,
369     }
370 }
371 
372 iana_registry! {
373     /// IANA-registered COSE key parameters for keys of type [`KeyType::OKP`].
374     ///
375     /// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters>
376     /// as of 2021-03-19.
377     OkpKeyParameter {
378         /// EC identifier - Taken from the "COSE Elliptic Curves" registry
379         ///
380         /// Associated value of type tstr / int
381         Crv: -1,
382         /// x-coordinate
383         ///
384         /// Associated value of type bstr
385         X: -2,
386         /// Private key
387         ///
388         /// Associated value of type bstr
389         D: -4,
390     }
391 }
392 
393 iana_registry! {
394     /// IANA-registered COSE key parameters for keys of type [`KeyType::EC2`].
395     ///
396     /// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters>
397     /// as of 2021-03-19.
398     Ec2KeyParameter {
399         /// EC identifier - Taken from the "COSE Elliptic Curves" registry
400         ///
401         /// Associated value of type tstr / int
402         Crv: -1,
403         /// Public Key
404         ///
405         /// Associated value of type bstr
406         X: -2,
407         /// y-coordinate
408         ///
409         /// Associated value of type bstr / bool
410         Y: -3,
411         /// Private key
412         ///
413         /// Associated value of type bstr
414         D: -4,
415     }
416 }
417 
418 iana_registry! {
419     /// IANA-registered COSE key parameters for keys of type [`KeyType::RSA`].
420     ///
421     /// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters>
422     /// as of 2021-03-19.
423     RsaKeyParameter {
424         /// The RSA modulus n
425         ///
426         /// Associated value of type bstr
427         N: -1,
428         /// The RSA public exponent e
429         ///
430         /// Associated value of type bstr
431         E: -2,
432         /// The RSA private exponent d
433         ///
434         /// Associated value of type bstr
435         D: -3,
436         /// The prime factor p of n
437         ///
438         /// Associated value of type bstr
439         P: -4,
440         /// The prime factor q of n
441         ///
442         /// Associated value of type bstr
443         Q: -5,
444         /// dP is d mod (p - 1)
445         ///
446         /// Associated value of type bstr
447         DP: -6,
448         /// dQ is d mod (q - 1)
449         ///
450         /// Associated value of type bstr
451         DQ: -7,
452         /// qInv is the CRT coefficient q^(-1) mod p
453         ///
454         /// Associated value of type bstr
455         QInv: -8,
456         /// Other prime infos, an array
457         ///
458         /// Associated value of type array
459         Other: -9,
460         /// a prime factor r_i of n, where i >= 3
461         ///
462         /// Associated value of type bstr
463         RI: -10,
464         /// d_i = d mod (r_i - 1)
465         ///
466         /// Associated value of type bstr
467         DI: -11,
468         /// The CRT coefficient t_i = (r_1 * r_2 * ... * r_(i-1))^(-1) mod r_i
469         ///
470         /// Associated value of type bstr
471         TI: -12,
472     }
473 }
474 
475 iana_registry! {
476     /// IANA-registered COSE key parameters for keys of type [`KeyType::Symmetric`].
477     ///
478     /// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters>
479     /// as of 2021-03-19.
480     SymmetricKeyParameter {
481         /// Key Value
482         ///
483         /// Associated value of type bstr
484         K: -1,
485     }
486 }
487 
488 iana_registry! {
489     /// IANA-registered COSE key parameters for keys of type [`KeyType::HSS_LMS`].
490     ///
491     /// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters>
492     /// as of 2021-03-19.
493     HssLmsKeyParameter {
494         /// Public key for HSS/LMS hash-based digital signature
495         ///
496         /// Associated value of type bstr
497         Pub: -1,
498     }
499 }
500 
501 iana_registry! {
502     /// IANA-registered COSE key parameters for keys of type [`KeyType::WalnutDSA`].
503     ///
504     /// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters>
505     /// as of 2021-03-19.
506     WalnutDsaKeyParameter {
507         /// Group and Matrix (NxN) size
508         ///
509         /// Associated value of type uint
510         N: -1,
511         /// Finite field F_q
512         ///
513         /// Associated value of type uint
514         Q: -2,
515         /// List of T-values, enties in F_q
516         ///
517         /// Associated value of type array of uint
518         TValues: -3,
519         /// NxN Matrix of enties in F_q in column-major form
520         ///
521         /// Associated value of type array of array of uint
522         Matrix1: -4,
523         /// Permutation associated with matrix 1
524         ///
525         /// Associated value of type array of uint
526         Permutation1: -5,
527         /// NxN Matrix of enties in F_q in column-major form
528         ///
529         /// Associated value of type array of array of uint
530         Matrix2: -6,
531     }
532 }
533 
534 iana_registry! {
535     /// IANA-registered COSE key types.
536     ///
537     /// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#key-type>
538     /// as of 2021-03-19.
539     KeyType {
540         /// This value is reserved
541         Reserved: 0,
542         /// Octet Key Pair
543         OKP: 1,
544         /// Elliptic Curve Keys w/ x- and y-coordinate pair
545         EC2: 2,
546         /// RSA Key
547         RSA: 3,
548         /// Symmetric Keys
549         Symmetric: 4,
550         /// Public key for HSS/LMS hash-based digital signature
551         HSS_LMS: 5,
552         /// WalnutDSA public key
553         WalnutDSA: 6,
554     }
555 }
556 
557 iana_registry! {
558     /// IANA-registered COSE elliptic curves.
559     ///
560     /// From IANA registry <https://www.iana.org/assignments/cose/cose.xhtml#elliptic-curves>
561     /// as of 2021-03-19.
562     EllipticCurve {
563         Reserved: 0,
564         /// EC2: NIST P-256 also known as secp256r1
565         P_256: 1,
566         /// EC2: NIST P-384 also known as secp384r1
567         P_384: 2,
568         /// EC2: NIST P-521 also known as secp521r1
569         P_521: 3,
570         /// OKP: X25519 for use w/ ECDH only
571         X25519: 4,
572         /// OKP: X448 for use w/ ECDH only
573         X448: 5,
574         /// OKP: Ed25519 for use w/ EdDSA only
575         Ed25519: 6,
576         /// OKP: Ed448 for use w/ EdDSA only
577         Ed448: 7,
578         /// EC2: SECG secp256k1 curve
579         Secp256k1: 8,
580     }
581 }
582 
583 /// Integer values for COSE elliptic curves below this value are reserved for private use.
584 pub const ELLIPTIC_CURVE_PRIVATE_USE_MAX: i64 = -65536;
585 
586 impl WithPrivateRange for EllipticCurve {
is_private(i: i64) -> bool587     fn is_private(i: i64) -> bool {
588         i < ELLIPTIC_CURVE_PRIVATE_USE_MAX
589     }
590 }
591 
592 iana_registry! {
593     /// Key operation values.
594     ///
595     /// See RFC 8152 section 7.1 table 4.
596     KeyOperation {
597         /// Key is used to create signatures. Requires private key fields.
598         Sign: 1,
599         /// Key is used for verification of signatures.
600         Verify: 2,
601         /// Key is used for key transport encryption.
602         Encrypt: 3,
603         /// Key is used for key transport decryption. Requires private key fields.
604         Decrypt: 4,
605         /// Key is used for key wrap encryption.
606         WrapKey: 5,
607         /// Key is used for key wrap decryption.  Requires private key fields.
608         UnwrapKey: 6,
609         /// Key is used for deriving keys.  Requires private key fields.
610         DeriveKey: 7,
611         /// Key is used for deriving bits not to be used as a key.  Requires private key fields.
612         DeriveBits: 8,
613         /// Key is used for creating MACs.
614         MacCreate: 9,
615         /// Key is used for validating MACs.
616         MacVerify: 10,
617     }
618 }
619 
620 iana_registry! {
621     /// CBOR tag values for COSE structures.
622     ///
623     /// From IANA registry <https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml>
624     /// as of 2021-03-19.
625     CborTag {
626         /// COSE Single Recipient Encrypted Data Object
627         CoseEncrypt0: 16,
628         /// COSE Mac w/o Recipients Object
629         CoseMac0: 17,
630         /// COSE Single Signer Data Object
631         CoseSign1: 18,
632         /// CBOR Web Token (CWT)
633         Cwt: 61,
634         /// COSE Encrypted Data Object
635         CoseEncrypt: 96,
636         /// COSE MACed Data Object
637         CoseMac: 97,
638         /// COSE Signed Data Object
639         CoseSign: 98,
640     }
641 }
642 
643 iana_registry! {
644     /// CoAP Content Formats
645     ///
646     /// From IANA registry <https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#content-formats>
647     /// as of 2021-03-19.
648     CoapContentFormat {
649         /// text/plain; charset=utf-8
650         TextPlainUtf8: 0,
651         /// application/cose; cose-type="cose-encrypt0"
652         CoseEncrypt0: 16,
653         /// application/cose; cose-type="cose-mac0"
654         CoseMac0: 17,
655         /// application/cose; cose-type="cose-sign1"
656         CoseSign1: 18,
657         /// application/link-format
658         LinkFormat: 40,
659         /// application/xml
660         Xml: 41,
661         /// application/octet-stream
662         OctetStream: 42,
663         /// application/exi
664         Exi: 47,
665         /// application/json
666         Json: 50,
667         /// application/json-patch+json
668         JsonPatchJson: 51,
669         /// application/merge-patch+json
670         MergePatchJson: 52,
671         /// application/cbor
672         Cbor: 60,
673         /// application/cwt
674         Cwt: 61,
675         /// application/multipart-core
676         MultipartCore: 62,
677         /// application/cbor-seq
678         CborSeq: 63,
679         /// application/cose; cose-type="cose-encrypt"
680         CoseEncrypt: 96,
681         /// application/cose; cose-type="cose-mac"
682         CoseMac: 97,
683         /// application/cose; cose-type="cose-sign"
684         CoseSign: 98,
685         /// application/cose-key
686         CoseKey: 101,
687         /// application/cose-key-set
688         CoseKeySet: 102,
689         /// application/senml+json
690         SenmlJson: 110,
691         /// application/sensml+json
692         SensmlJson: 111,
693         /// application/senml+cbor
694         SenmlCbor: 112,
695         /// application/sensml+cbor
696         SensmlCbor: 113,
697         /// application/senml-exi
698         SenmlExi: 114,
699         /// application/sensml-exi
700         SensmlExi: 115,
701         /// application/coap-group+json
702         CoapGroupJson: 256,
703         /// application/dots+cbor
704         DotsCbor: 271,
705         /// application/pkcs7-mime; smime-type=server-generated-key
706         Pkcs7MimeSmimeTypeServerGeneratedKey: 280,
707         /// application/pkcs7-mime; smime-type=certs-only
708         Pkcs7MimeSmimeTypeCertsOnly: 281,
709         /// application/pkcs7-mime; smime-type=CMC-Request
710         Pkcs7MimeSmimeTypeCmcRequest: 282,
711         /// application/pkcs7-mime; smime-type=CMC-Response
712         Pkcs7MimeSmimeTypeCmcResponse: 283,
713         /// application/pkcs8
714         Pkcs8: 284,
715         /// application/csrattrs
716         Csrattrs: 285,
717         /// application/pkcs10
718         Pkcs10: 286,
719         /// application/pkix-cert
720         PkixCert: 287,
721         /// application/senml+xml
722         SenmlXml: 310,
723         /// application/sensml+xml
724         SensmlXml: 311,
725         /// application/senml-etch+json
726         SenmlEtchJson: 320,
727         /// application/senml-etch+cbor
728         SenmlEtchCbor: 322,
729         /// application/td+json
730         TdJson: 432,
731         /// application/vnd.ocf+cbor
732         VndOcfCbor: 10000,
733         /// application/oscore
734         Oscore: 10001,
735         // application/json deflate
736         JsonDeflate: 11050,
737         // application/cbor deflate
738         CborDeflate: 11060,
739         /// application/vnd.oma.lwm2m+tlv
740         VndOmaLwm2mTlv: 11542,
741         /// application/vnd.oma.lwm2m+json
742         VndOmaLwm2mJson: 11543,
743         /// application/vnd.oma.lwm2m+cbor
744         VndOmaLwm2mCbor: 11544,
745     }
746 }
747 
748 iana_registry! {
749     /// CBOR Web Token (CWT) Claims
750     /// From IANA registry <https://www.iana.org/assignments/cwt/cwt.xhtml>
751     /// as of 2021-10-21.
752     CwtClaimName {
753         /// Health certificate ("hcert": map).
754         Hcert: -260,
755         /// Challenge nonce ("EUPHNonce": bstr).
756         EuphNonce: -259,
757         /// Signing prefix for multi-app restricted operating environment ("EATMAROEPrefix": bstr).
758         EatMaroePrefix: -258,
759         /// FIDO Device Onboarding EAT ("EAT-FDO": array).
760         EatFido: -257,
761         /// Reserved value.
762         Reserved: 0,
763         /// Issuer ("iss": tstr).
764         Iss: 1,
765         /// Subject ("sub": tstr)
766         Sub: 2,
767         /// Audience ("aud": tstr)
768         Aud: 3,
769         /// Expiration Time, as seconds since UNIX epoch ("exp": int/float)
770         Exp: 4,
771         /// Not Before, as seconds since UNIX epoch ("nbf": int/float)
772         Nbf: 5,
773         /// Issued at, as seconds since UNIX epoch ("iat": int/float)
774         Iat: 6,
775         /// CWT ID ("cti": bstr)
776         Cti: 7,
777         /// Confirmation ("cnf": map)
778         Cnf: 8,
779         /// Scope of an access token ("scope": bstr/tstr)
780         Scope: 9,
781         /// The ACE profile a token is supposed to be used with ("ace_profile": int)
782         AceProfile: 38,
783         /// The client-nonce sent to the AS by the RS via the client ("cnonce": bstr)
784         CNonce: 39,
785         /// The expiration time of a token measured from when it was received at the RS in seconds ("exi": int)
786         Exi: 40,
787     }
788 }
789 
790 /// Integer values for CWT claims below this value are reserved for private use.
791 pub const CWT_CLAIM_PRIVATE_USE_MAX: i64 = -65536;
792 
793 impl WithPrivateRange for CwtClaimName {
is_private(i: i64) -> bool794     fn is_private(i: i64) -> bool {
795         i < CWT_CLAIM_PRIVATE_USE_MAX
796     }
797 }
798