| 1 |
from enum import Enum |
| 2 |
|
| 3 |
|
| 4 |
class COSEAlgorithmIdentifier(int, Enum): |
| 5 |
"""Various registered values indicating cryptographic algorithms that may be used in credential responses |
| 6 |
|
| 7 |
Members: |
| 8 |
`ECDSA_SHA_256` |
| 9 |
`EDDSA` |
| 10 |
`ECDSA_SHA_512` |
| 11 |
`RSASSA_PSS_SHA_256` |
| 12 |
`RSASSA_PSS_SHA_384` |
| 13 |
`RSASSA_PSS_SHA_512` |
| 14 |
`RSASSA_PKCS1_v1_5_SHA_256` |
| 15 |
`RSASSA_PKCS1_v1_5_SHA_384` |
| 16 |
`RSASSA_PKCS1_v1_5_SHA_512` |
| 17 |
`RSASSA_PKCS1_v1_5_SHA_1` |
| 18 |
|
| 19 |
https://www.w3.org/TR/webauthn-2/#sctn-alg-identifier |
| 20 |
https://www.iana.org/assignments/cose/cose.xhtml#algorithms |
| 21 |
""" |
| 22 |
|
| 23 |
ECDSA_SHA_256 = -7 |
| 24 |
EDDSA = -8 |
| 25 |
ECDSA_SHA_512 = -36 |
| 26 |
RSASSA_PSS_SHA_256 = -37 |
| 27 |
RSASSA_PSS_SHA_384 = -38 |
| 28 |
RSASSA_PSS_SHA_512 = -39 |
| 29 |
RSASSA_PKCS1_v1_5_SHA_256 = -257 |
| 30 |
RSASSA_PKCS1_v1_5_SHA_384 = -258 |
| 31 |
RSASSA_PKCS1_v1_5_SHA_512 = -259 |
| 32 |
RSASSA_PKCS1_v1_5_SHA_1 = -65535 # Deprecated; here for legacy support |
| 33 |
|
| 34 |
|
| 35 |
class COSEKTY(int, Enum): |
| 36 |
""" |
| 37 |
Possible values for COSEKey.KTY representing a public key's key type |
| 38 |
|
| 39 |
https://tools.ietf.org/html/rfc8152#section-13 |
| 40 |
https://www.iana.org/assignments/cose/cose.xhtml#table-key-type |
| 41 |
""" |
| 42 |
|
| 43 |
OKP = 1 |
| 44 |
EC2 = 2 |
| 45 |
RSA = 3 |
| 46 |
|
| 47 |
|
| 48 |
class COSECRV(int, Enum): |
| 49 |
"""Possible values for COSEKey.CRV representing an EC2 public key's curve |
| 50 |
|
| 51 |
https://tools.ietf.org/html/rfc8152#section-13.1 |
| 52 |
https://www.iana.org/assignments/cose/cose.xhtml#table-elliptic-curves |
| 53 |
""" |
| 54 |
|
| 55 |
P256 = 1 # EC2, NIST P-256 also known as secp256r1 |
| 56 |
P384 = 2 # EC2, NIST P-384 also known as secp384r1 |
| 57 |
P521 = 3 # EC2, NIST P-521 also known as secp521r1 |
| 58 |
ED25519 = 6 # OKP, Ed25519 for use w/ EdDSA only |
| 59 |
|
| 60 |
|
| 61 |
class COSEKey(int, Enum): |
| 62 |
""" |
| 63 |
COSE keys for public keys |
| 64 |
|
| 65 |
https://tools.ietf.org/html/rfc8152 |
| 66 |
https://www.iana.org/assignments/cose/cose.xhtml#table-key-common-parameters |
| 67 |
https://www.iana.org/assignments/cose/cose.xhtml#table-key-type-parameters |
| 68 |
""" |
| 69 |
|
| 70 |
KTY = 1 |
| 71 |
ALG = 3 |
| 72 |
# EC2, OKP |
| 73 |
CRV = -1 |
| 74 |
X = -2 |
| 75 |
# EC2 |
| 76 |
Y = -3 |
| 77 |
# RSA |
| 78 |
N = -1 |
| 79 |
E = -2 |