#[cfg(test)]
mod tests;
pub trait EnumI64: Sized + Eq {
fn from_i64(i: i64) -> Option<Self>;
fn to_i64(&self) -> i64;
}
pub trait WithPrivateRange {
fn is_private(i: i64) -> bool;
}
macro_rules! iana_registry {
( $(#[$attr:meta])* $enum_name:ident {$($(#[$fattr:meta])* $name:ident: $val:expr,)* } ) => {
#[allow(non_camel_case_types)]
$(#[$attr])*
#[non_exhaustive]
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum $enum_name {
$($(#[$fattr])* $name = $val,)*
}
impl EnumI64 for $enum_name {
fn from_i64(i: i64) -> Option<Self> {
match i {
$(x if x == Self::$name as i64 => Some(Self::$name),)*
_ => None,
}
}
#[inline]
fn to_i64(&self) -> i64 {
*self as i64
}
}
}
}
iana_registry! {
HeaderParameter {
Reserved: 0,
Alg: 1,
Crit: 2,
ContentType: 3,
Kid: 4,
Iv: 5,
PartialIv: 6,
CounterSignature: 7,
CounterSignature0: 9,
KidContext: 10,
CounterSignatureV2: 11,
CounterSignature0V2: 12,
KeyCwt: 13,
KeyCwtClaimsSet: 14,
CwtClaims: 15,
ObjectContentType: 16,
X5Bag: 32,
X5Chain: 33,
X5T: 34,
X5U: 35,
CuphNonce: 256,
CuphOwnerPubKey: 257,
}
}
pub const HEADER_PARAMETER_PRIVATE_USE_MAX: i64 = -65536;
impl WithPrivateRange for HeaderParameter {
fn is_private(i: i64) -> bool {
i < HEADER_PARAMETER_PRIVATE_USE_MAX
}
}
iana_registry! {
HeaderAlgorithmParameter {
X5ChainSender: -29,
X5USender: -28,
X5TSender: -27,
PartyVOther: -26,
PartyVNonce: -25,
PartyVIdentity: -24,
PartyUOther: -23,
PartyUNonce: -22,
PartyUIdentity: -21,
Salt: -20,
StaticKeyId: -3,
StaticKey: -2,
EphemeralKey: -1,
}
}
iana_registry! {
Algorithm {
RS1: -65535,
AesCtr128: -65534,
AesCtr192: -65533,
AesCtr256: -65532,
AesCbc128: -65531,
AesCbc192: -65530,
AesCbc256: -65529,
ESB512: -268,
ESB384: -267,
ESB320: -266,
ESB256: -265,
WalnutDSA: -260,
RS512: -259,
RS384: -258,
RS256: -257,
Ed448: -53,
ESP512: -52,
ESP384: -51,
ML_DSA_87: -50,
ML_DSA_65: -49,
ML_DSA_44: -48,
ES256K: -47,
HSS_LMS: -46,
SHAKE256: -45,
SHA_512: -44,
SHA_384: -43,
RSAES_OAEP_SHA_512: -42,
RSAES_OAEP_SHA_256: -41,
RSAES_OAEP_RFC_8017_default: -40,
PS512: -39,
PS384: -38,
PS256: -37,
ES512: -36,
ES384: -35,
ECDH_SS_A256KW: -34,
ECDH_SS_A192KW: -33,
ECDH_SS_A128KW: -32,
ECDH_ES_A256KW: -31,
ECDH_ES_A192KW: -30,
ECDH_ES_A128KW: -29,
ECDH_SS_HKDF_512: -28,
ECDH_SS_HKDF_256: -27,
ECDH_ES_HKDF_512: -26,
ECDH_ES_HKDF_256: -25,
Ed25519: -19,
SHAKE128: -18,
SHA_512_256: -17,
SHA_256: -16,
SHA_256_64: -15,
SHA_1: -14,
Direct_HKDF_AES_256: -13,
Direct_HKDF_AES_128: -12,
Direct_HKDF_SHA_512: -11,
Direct_HKDF_SHA_256: -10,
ESP256: -9,
EdDSA: -8,
ES256: -7,
Direct: -6,
A256KW: -5,
A192KW: -4,
A128KW: -3,
Reserved: 0,
A128GCM: 1,
A192GCM: 2,
A256GCM: 3,
HMAC_256_64: 4,
HMAC_256_256: 5,
HMAC_384_384: 6,
HMAC_512_512: 7,
AES_CCM_16_64_128: 10,
AES_CCM_16_64_256: 11,
AES_CCM_64_64_128: 12,
AES_CCM_64_64_256: 13,
AES_MAC_128_64: 14,
AES_MAC_256_64: 15,
ChaCha20Poly1305: 24,
AES_MAC_128_128: 25,
AES_MAC_256_128: 26,
AES_CCM_16_128_128: 30,
AES_CCM_16_128_256: 31,
AES_CCM_64_128_128: 32,
AES_CCM_64_128_256: 33,
IV_GENERATION: 34,
}
}
pub const ALGORITHM_PRIVATE_USE_MAX: i64 = -65536;
impl WithPrivateRange for Algorithm {
fn is_private(i: i64) -> bool {
i < ALGORITHM_PRIVATE_USE_MAX
}
}
iana_registry! {
KeyParameter {
Reserved: 0,
Kty: 1,
Kid: 2,
Alg: 3,
KeyOps: 4,
BaseIv: 5,
}
}
iana_registry! {
OkpKeyParameter {
Crv: -1,
X: -2,
D: -4,
}
}
iana_registry! {
Ec2KeyParameter {
Crv: -1,
X: -2,
Y: -3,
D: -4,
}
}
iana_registry! {
RsaKeyParameter {
N: -1,
E: -2,
D: -3,
P: -4,
Q: -5,
DP: -6,
DQ: -7,
QInv: -8,
Other: -9,
RI: -10,
DI: -11,
TI: -12,
}
}
iana_registry! {
SymmetricKeyParameter {
K: -1,
}
}
iana_registry! {
HssLmsKeyParameter {
Pub: -1,
}
}
iana_registry! {
WalnutDsaKeyParameter {
N: -1,
Q: -2,
TValues: -3,
Matrix1: -4,
Permutation1: -5,
Matrix2: -6,
}
}
iana_registry! {
AkpKeyParameter {
Pub: -1,
Priv: -2,
}
}
iana_registry! {
KeyType {
Reserved: 0,
OKP: 1,
EC2: 2,
RSA: 3,
Symmetric: 4,
HSS_LMS: 5,
WalnutDSA: 6,
AKP: 7,
}
}
iana_registry! {
EllipticCurve {
Reserved: 0,
P_256: 1,
P_384: 2,
P_521: 3,
X25519: 4,
X448: 5,
Ed25519: 6,
Ed448: 7,
Secp256k1: 8,
BrainpoolP256R1: 256,
BrainpoolP320R1: 257,
BrainpoolP384R1: 258,
BrainpoolP512R1: 259,
}
}
pub const ELLIPTIC_CURVE_PRIVATE_USE_MAX: i64 = -65536;
impl WithPrivateRange for EllipticCurve {
fn is_private(i: i64) -> bool {
i < ELLIPTIC_CURVE_PRIVATE_USE_MAX
}
}
iana_registry! {
KeyOperation {
Sign: 1,
Verify: 2,
Encrypt: 3,
Decrypt: 4,
WrapKey: 5,
UnwrapKey: 6,
DeriveKey: 7,
DeriveBits: 8,
MacCreate: 9,
MacVerify: 10,
}
}
iana_registry! {
CborTag {
CoseEncrypt0: 16,
CoseMac0: 17,
CoseSign1: 18,
CoseCountersignature: 19,
Cwt: 61,
CoseEncrypt: 96,
CoseMac: 97,
CoseSign: 98,
}
}
iana_registry! {
CoapContentFormat {
TextPlainUtf8: 0,
CoseEncrypt0: 16,
CoseMac0: 17,
CoseSign1: 18,
AceCbor: 19,
ImageGif: 21,
ImageJpeg: 22,
ImagePng: 23,
LinkFormat: 40,
Xml: 41,
OctetStream: 42,
Exi: 47,
Json: 50,
JsonPatchJson: 51,
MergePatchJson: 52,
Cbor: 60,
Cwt: 61,
MultipartCore: 62,
CborSeq: 63,
EdhocCborSeq: 64,
CidEdhocCborSeq: 65,
CoseEncrypt: 96,
CoseMac: 97,
CoseSign: 98,
CoseKey: 101,
CoseKeySet: 102,
SenmlJson: 110,
SensmlJson: 111,
SenmlCbor: 112,
SensmlCbor: 113,
SenmlExi: 114,
SensmlExi: 115,
YangData: 140,
CoapGroupJson: 256,
ConciseProblemDetailsCbor: 257,
SwidCbor:258,
PkixCmp: 259,
YangSidJson: 260,
AceGroupcommCbor: 261,
AceTrlCbor: 262,
EatCwt: 263,
EatJwt: 264,
EatBunCbor: 265,
EatBunJson: 266,
EatUcsCbor: 267,
EatUcsJson: 268,
DotsCbor: 271,
MissingBlocksCborSeq: 272,
Pkcs7MimeSmimeTypeServerGeneratedKey: 280,
Pkcs7MimeSmimeTypeCertsOnly: 281,
Pkcs7MimeSmimeTypeCmcRequest: 282,
Pkcs7MimeSmimeTypeCmcResponse: 283,
Pkcs8: 284,
Csrattrs: 285,
Pkcs10: 286,
PkixCert: 287,
AifCbor: 290,
AifJson: 291,
SenmlXml: 310,
SensmlXml: 311,
SenmlEtchJson: 320,
SenmlEtchCbor: 322,
YangDataCbor: 340,
YangDataCborName: 341,
TdJson: 432,
TmJson: 433,
UccsCbor: 601,
VndOcfCbor: 10000,
Oscore: 10001,
Javascript: 10002,
EatCwtTfm: 10003,
EatCwtLegacy: 10004,
JsonDeflate: 11050,
CborDeflate: 11060,
VndOmaLwm2mTlv: 11542,
VndOmaLwm2mJson: 11543,
VndOmaLwm2mCbor: 11544,
TextCss: 20000,
ImageSvgXml: 30000,
}
}
iana_registry! {
CwtClaimName {
GlobalPlatformComponents: -261,
Hcert: -260,
EuphNonce: -259,
EatMaroePrefix: -258,
EatFido: -257,
Reserved: 0,
Iss: 1,
Sub: 2,
Aud: 3,
Exp: 4,
Nbf: 5,
Iat: 6,
Cti: 7,
Cnf: 8,
Scope: 9,
Nonce: 10,
AceProfile: 38,
CNonce: 39,
Exi: 40,
UEID: 256,
SUEIDs: 257,
HardwareOemid: 258,
HardwareModel: 259,
HardwareVersion: 260,
Uptime: 261,
OemAuthorizedBoot: 262,
DebugStatus: 263,
Location: 264,
EatProfile: 265,
SubmodulesSection: 266,
BootCount: 267,
BootSeed: 268,
DLoAs: 269,
SoftwareName: 270,
SoftwareVersion: 271,
SoftwareManifests: 272,
Measurements: 273,
SoftwareMeasurementResults: 274,
IntendedUse: 275,
Geohash: 282,
WmVersion: 300,
WmVendor: 301,
WmPatternLen: 302,
WmSegmentDuration: 303,
WmPattern: 304,
WmId: 305,
WmOpId: 306,
WmKeyVer: 307,
CatReplay: 308,
CatPor: 309,
CatVersion: 310,
CatNetworkIp: 311,
CatUri: 312,
CatMethod: 313,
CatAlpn: 314,
CatHeader: 315,
CatGeoIso3166: 316,
CatGeoCoord: 317,
CatGeoAlt: 318,
CatTlsPublicKey: 319,
CatIfData: 320,
CatDPoP: 321,
CatIf: 322,
CatRenewal: 323,
PsaClientId: 2394,
PsaSecurityLifecycle: 2395,
PsaImplementationId: 2396,
PsaCertificationReference: 2398,
PsaSoftwareComponents: 2399,
PsaVerificationServiceIndicator: 2400,
}
}
pub const CWT_CLAIM_PRIVATE_USE_MAX: i64 = -65536;
impl WithPrivateRange for CwtClaimName {
fn is_private(i: i64) -> bool {
i < CWT_CLAIM_PRIVATE_USE_MAX
}
}