Debian Codegraph @

addons/auth_passkey/_vendor/webauthn/helpers/asn1/android_key.py

raw
1 from enum import Enum
2
3 from asn1crypto.core import (
4 Boolean,
5 Enumerated,
6 Integer,
7 Null,
8 OctetString,
9 Sequence,
10 SetOf,
11 )
12
13
14 class Integers(SetOf):
15 _child_spec = Integer
16
17
18 class SecurityLevel(Enumerated):
19 _map = {
20 0: "Software",
21 1: "TrustedEnvironment",
22 2: "StrongBox",
23 }
24
25
26 class VerifiedBootState(Enumerated):
27 _map = {
28 0: "Verified",
29 1: "SelfSigned",
30 2: "Unverified",
31 3: "Failed",
32 }
33
34
35 class RootOfTrust(Sequence):
36 _fields = [
37 ("verifiedBootKey", OctetString),
38 ("deviceLocked", Boolean),
39 ("verifiedBootState", VerifiedBootState),
40 ("verifiedBootHash", OctetString),
41 ]
42
43
44 class AuthorizationList(Sequence):
45 _fields = [
46 ("purpose", Integers, {"explicit": 1, "optional": True}),
47 ("algorithm", Integer, {"explicit": 2, "optional": True}),
48 ("keySize", Integer, {"explicit": 3, "optional": True}),
49 ("digest", Integers, {"explicit": 5, "optional": True}),
50 ("padding", Integers, {"explicit": 6, "optional": True}),
51 ("ecCurve", Integer, {"explicit": 10, "optional": True}),
52 ("rsaPublicExponent", Integer, {"explicit": 200, "optional": True}),
53 ("rollbackResistance", Null, {"explicit": 303, "optional": True}),
54 ("activeDateTime", Integer, {"explicit": 400, "optional": True}),
55 ("originationExpireDateTime", Integer, {"explicit": 401, "optional": True}),
56 ("usageExpireDateTime", Integer, {"explicit": 402, "optional": True}),
57 ("noAuthRequired", Null, {"explicit": 503, "optional": True}),
58 ("userAuthType", Integer, {"explicit": 504, "optional": True}),
59 ("authTimeout", Integer, {"explicit": 505, "optional": True}),
60 ("allowWhileOnBody", Null, {"explicit": 506, "optional": True}),
61 ("trustedUserPresenceRequired", Null, {"explicit": 507, "optional": True}),
62 ("trustedConfirmationRequired", Null, {"explicit": 508, "optional": True}),
63 ("unlockedDeviceRequired", Null, {"explicit": 509, "optional": True}),
64 ("allApplications", Null, {"explicit": 600, "optional": True}),
65 ("applicationId", OctetString, {"explicit": 601, "optional": True}),
66 ("creationDateTime", Integer, {"explicit": 701, "optional": True}),
67 ("origin", Integer, {"explicit": 702, "optional": True}),
68 ("rollbackResistant", Null, {"explicit": 703, "optional": True}),
69 ("rootOfTrust", RootOfTrust, {"explicit": 704, "optional": True}),
70 ("osVersion", Integer, {"explicit": 705, "optional": True}),
71 ("osPatchLevel", Integer, {"explicit": 706, "optional": True}),
72 ("attestationApplicationId", OctetString, {"explicit": 709, "optional": True}),
73 ("attestationIdBrand", OctetString, {"explicit": 710, "optional": True}),
74 ("attestationIdDevice", OctetString, {"explicit": 711, "optional": True}),
75 ("attestationIdProduct", OctetString, {"explicit": 712, "optional": True}),
76 ("attestationIdSerial", OctetString, {"explicit": 713, "optional": True}),
77 ("attestationIdImei", OctetString, {"explicit": 714, "optional": True}),
78 ("attestationIdMeid", OctetString, {"explicit": 715, "optional": True}),
79 ("attestationIdManufacturer", OctetString, {"explicit": 716, "optional": True}),
80 ("attestationIdModel", OctetString, {"explicit": 717, "optional": True}),
81 ("vendorPatchLevel", Integer, {"explicit": 718, "optional": True}),
82 ("bootPatchLevel", Integer, {"explicit": 719, "optional": True}),
83 ]
84
85
86 class KeyDescription(Sequence):
87 """Attestation extension content as ASN.1 schema (DER-encoded)
88
89 Corresponds to X.509 certificate extension with the following OID:
90
91 `1.3.6.1.4.1.11129.2.1.17`
92
93 See https://source.android.com/security/keystore/attestation#schema
94 """
95
96 _fields = [
97 ("attestationVersion", Integer),
98 ("attestationSecurityLevel", SecurityLevel),
99 ("keymasterVersion", Integer),
100 ("keymasterSecurityLevel", SecurityLevel),
101 ("attestationChallenge", OctetString),
102 ("uniqueId", OctetString),
103 ("softwareEnforced", AuthorizationList),
104 ("teeEnforced", AuthorizationList),
105 ]
106
107
108 class KeyOrigin(int, Enum):
109 """`Tag::ORIGIN`
110
111 See https://source.android.com/security/keystore/tags#origin
112 """
113
114 GENERATED = 0
115 DERIVED = 1
116 IMPORTED = 2
117 UNKNOWN = 3
118
119
120 class KeyPurpose(int, Enum):
121 """`Tag::PURPOSE`
122
123 See https://source.android.com/security/keystore/tags#purpose
124 """
125
126 ENCRYPT = 0
127 DECRYPT = 1
128 SIGN = 2
129 VERIFY = 3
130 DERIVE_KEY = 4
131 WRAP_KEY = 5