CryptoDataHub 0.12.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CryptoDataHub-0.12.6.dist-info/LICENSE.txt +373 -0
- CryptoDataHub-0.12.6.dist-info/METADATA +119 -0
- CryptoDataHub-0.12.6.dist-info/RECORD +70 -0
- CryptoDataHub-0.12.6.dist-info/WHEEL +5 -0
- CryptoDataHub-0.12.6.dist-info/top_level.txt +1 -0
- cryptodatahub/__init__.py +0 -0
- cryptodatahub/__setup__.py +10 -0
- cryptodatahub/common/__init__.py +0 -0
- cryptodatahub/common/algorithm.py +164 -0
- cryptodatahub/common/attack-named.json +74 -0
- cryptodatahub/common/attack-type.json +58 -0
- cryptodatahub/common/authentication.json +113 -0
- cryptodatahub/common/block-cipher-mode.json +75 -0
- cryptodatahub/common/block-cipher.json +474 -0
- cryptodatahub/common/certificate-transparency-log.json +2394 -0
- cryptodatahub/common/client.json +20 -0
- cryptodatahub/common/dhparam-well-known.json +1975 -0
- cryptodatahub/common/ecparam-well-known.json +1868 -0
- cryptodatahub/common/entity.json +269 -0
- cryptodatahub/common/entity.py +110 -0
- cryptodatahub/common/exception.py +28 -0
- cryptodatahub/common/grade.py +200 -0
- cryptodatahub/common/hash.json +273 -0
- cryptodatahub/common/key-exchange.json +140 -0
- cryptodatahub/common/key.py +571 -0
- cryptodatahub/common/mac.json +404 -0
- cryptodatahub/common/named-group.json +902 -0
- cryptodatahub/common/parameter.py +149 -0
- cryptodatahub/common/root-certificate.json +19240 -0
- cryptodatahub/common/server.json +56 -0
- cryptodatahub/common/signature.json +233 -0
- cryptodatahub/common/standard.json +57 -0
- cryptodatahub/common/stores.py +323 -0
- cryptodatahub/common/types.py +524 -0
- cryptodatahub/common/utils.py +112 -0
- cryptodatahub/common/vulnerability.json +2 -0
- cryptodatahub/dnsrec/__init__.py +0 -0
- cryptodatahub/dnsrec/algorithm.json +114 -0
- cryptodatahub/dnsrec/algorithm.py +87 -0
- cryptodatahub/dnsrec/digest-type.json +26 -0
- cryptodatahub/dnsrec/rr-type.json +805 -0
- cryptodatahub/ssh/__init__.py +0 -0
- cryptodatahub/ssh/algorithm.py +194 -0
- cryptodatahub/ssh/compression-algorithm.json +24 -0
- cryptodatahub/ssh/elliptic-curve-identifier.json +50 -0
- cryptodatahub/ssh/encryption-algorithm.json +587 -0
- cryptodatahub/ssh/host-key-algorithm.json +482 -0
- cryptodatahub/ssh/kex-algorithm.json +709 -0
- cryptodatahub/ssh/mac-algorithm.json +566 -0
- cryptodatahub/tls/__init__.py +0 -0
- cryptodatahub/tls/algorithm.py +324 -0
- cryptodatahub/tls/certificate-compression-algorithm.json +14 -0
- cryptodatahub/tls/cipher-kind.json +171 -0
- cryptodatahub/tls/cipher-suite-extension.json +10 -0
- cryptodatahub/tls/cipher-suite.json +5098 -0
- cryptodatahub/tls/client.json +4757 -0
- cryptodatahub/tls/client.py +220 -0
- cryptodatahub/tls/compression-method.json +20 -0
- cryptodatahub/tls/ec-point-format.json +20 -0
- cryptodatahub/tls/extension-type.json +282 -0
- cryptodatahub/tls/grease-one-byte.json +34 -0
- cryptodatahub/tls/grease-two-byte.json +66 -0
- cryptodatahub/tls/hash-and-signature-algorithm.json +266 -0
- cryptodatahub/tls/named-curve.json +292 -0
- cryptodatahub/tls/next-protocol-name.json +20 -0
- cryptodatahub/tls/protocol-name.json +71 -0
- cryptodatahub/tls/psk-key-exchange-mode.json +10 -0
- cryptodatahub/tls/token-binding-paramater.json +14 -0
- cryptodatahub/tls/version.json +154 -0
- cryptodatahub/tls/version.py +17 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"APACHE_HTTP_SERVER": {
|
|
3
|
+
"name": "Apache",
|
|
4
|
+
"long_name": "Apache HTTP Server",
|
|
5
|
+
"types": [
|
|
6
|
+
"WEB_SERVER"
|
|
7
|
+
],
|
|
8
|
+
"developers": [
|
|
9
|
+
"ASF"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"HAPROXY": {
|
|
13
|
+
"name": "HAProxy",
|
|
14
|
+
"long_name": null,
|
|
15
|
+
"types": [
|
|
16
|
+
"WEB_SERVER"
|
|
17
|
+
],
|
|
18
|
+
"developers": []
|
|
19
|
+
},
|
|
20
|
+
"NGINX": {
|
|
21
|
+
"name": "NGINX",
|
|
22
|
+
"long_name": null,
|
|
23
|
+
"types": [
|
|
24
|
+
"WEB_SERVER"
|
|
25
|
+
],
|
|
26
|
+
"developers": [
|
|
27
|
+
"F5"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"POSTFIX": {
|
|
31
|
+
"name": "Postfix",
|
|
32
|
+
"long_name": null,
|
|
33
|
+
"types": [
|
|
34
|
+
"MAIL_SERVER"
|
|
35
|
+
],
|
|
36
|
+
"developers": [
|
|
37
|
+
"WIETSE_VENEMA"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"PROFTPD": {
|
|
41
|
+
"name": "ProFTPD",
|
|
42
|
+
"long_name": "Pro FTP Daemon",
|
|
43
|
+
"types": [
|
|
44
|
+
"FTP_SERVER"
|
|
45
|
+
],
|
|
46
|
+
"developers": []
|
|
47
|
+
},
|
|
48
|
+
"SOCAT": {
|
|
49
|
+
"name": "socat",
|
|
50
|
+
"long_name": "Socket CAT",
|
|
51
|
+
"types": [
|
|
52
|
+
"TCP_SERVER"
|
|
53
|
+
],
|
|
54
|
+
"developers": []
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
{
|
|
2
|
+
"RSA_WITH_MD2": {
|
|
3
|
+
"name": "MD2 with RSA Encryption",
|
|
4
|
+
"long_name": null,
|
|
5
|
+
"oid": "1.2.840.113549.1.1.2",
|
|
6
|
+
"key_type": "RSA",
|
|
7
|
+
"hash_algorithm": "MD2"
|
|
8
|
+
},
|
|
9
|
+
"RSA_WITH_MD4": {
|
|
10
|
+
"name": "MD4 with RSA Encryption",
|
|
11
|
+
"long_name": null,
|
|
12
|
+
"oid": "1.2.840.113549.1.1.3",
|
|
13
|
+
"key_type": "RSA",
|
|
14
|
+
"hash_algorithm": "MD4"
|
|
15
|
+
},
|
|
16
|
+
"RSA_WITH_MD5": {
|
|
17
|
+
"name": "MD5 with RSA Encryption",
|
|
18
|
+
"long_name": null,
|
|
19
|
+
"oid": "1.2.840.113549.1.1.4",
|
|
20
|
+
"key_type": "RSA",
|
|
21
|
+
"hash_algorithm": "MD5"
|
|
22
|
+
},
|
|
23
|
+
"RSA_WITH_SHA1": {
|
|
24
|
+
"name": "SHA-1 with RSA Encryption",
|
|
25
|
+
"long_name": null,
|
|
26
|
+
"oid": "1.2.840.113549.1.1.5",
|
|
27
|
+
"key_type": "RSA",
|
|
28
|
+
"hash_algorithm": "SHA1"
|
|
29
|
+
},
|
|
30
|
+
"RSA_WITH_SHA2_224": {
|
|
31
|
+
"name": "SHA-224 with RSA Encryption",
|
|
32
|
+
"long_name": null,
|
|
33
|
+
"oid": "1.2.840.113549.1.1.14",
|
|
34
|
+
"key_type": "RSA",
|
|
35
|
+
"hash_algorithm": "SHA2_224"
|
|
36
|
+
},
|
|
37
|
+
"RSA_WITH_SHA2_256": {
|
|
38
|
+
"name": "SHA-256 with RSA Encryption",
|
|
39
|
+
"long_name": null,
|
|
40
|
+
"oid": "1.2.840.113549.1.1.11",
|
|
41
|
+
"key_type": "RSA",
|
|
42
|
+
"hash_algorithm": "SHA2_256"
|
|
43
|
+
},
|
|
44
|
+
"RSA_WITH_SHA2_384": {
|
|
45
|
+
"name": "SHA-384 with RSA Encryption",
|
|
46
|
+
"long_name": null,
|
|
47
|
+
"oid": "1.2.840.113549.1.1.12",
|
|
48
|
+
"key_type": "RSA",
|
|
49
|
+
"hash_algorithm": "SHA2_384"
|
|
50
|
+
},
|
|
51
|
+
"RSA_WITH_SHA2_512": {
|
|
52
|
+
"name": "SHA-512 with RSA Encryption",
|
|
53
|
+
"long_name": null,
|
|
54
|
+
"oid": "1.2.840.113549.1.1.13",
|
|
55
|
+
"key_type": "RSA",
|
|
56
|
+
"hash_algorithm": "SHA2_512"
|
|
57
|
+
},
|
|
58
|
+
"DSA_WITH_SHA1": {
|
|
59
|
+
"name": "DSA with SHA-1",
|
|
60
|
+
"long_name": null,
|
|
61
|
+
"oid": "1.2.840.10040.4.3",
|
|
62
|
+
"key_type": "DSS",
|
|
63
|
+
"hash_algorithm": "SHA1"
|
|
64
|
+
},
|
|
65
|
+
"DSA_WITH_SHA2_224": {
|
|
66
|
+
"name": "DSA with SHA-224",
|
|
67
|
+
"long_name": null,
|
|
68
|
+
"oid": "2.16.840.1.101.3.4.3.1",
|
|
69
|
+
"key_type": "DSS",
|
|
70
|
+
"hash_algorithm": "SHA2_224"
|
|
71
|
+
},
|
|
72
|
+
"DSA_WITH_SHA2_256": {
|
|
73
|
+
"name": "DSA with SHA-256",
|
|
74
|
+
"long_name": null,
|
|
75
|
+
"oid": "2.16.840.1.101.3.4.3.2",
|
|
76
|
+
"key_type": "DSS",
|
|
77
|
+
"hash_algorithm": "SHA2_256"
|
|
78
|
+
},
|
|
79
|
+
"DSA_WITH_SHA2_384": {
|
|
80
|
+
"name": "DSA with SHA-384",
|
|
81
|
+
"long_name": null,
|
|
82
|
+
"oid": "2.16.840.1.101.3.4.3.3",
|
|
83
|
+
"key_type": "DSS",
|
|
84
|
+
"hash_algorithm": "SHA2_384"
|
|
85
|
+
},
|
|
86
|
+
"DSA_WITH_SHA2_512": {
|
|
87
|
+
"name": "DSA with SHA-512",
|
|
88
|
+
"long_name": null,
|
|
89
|
+
"oid": "2.16.840.1.101.3.4.3.4",
|
|
90
|
+
"key_type": "DSS",
|
|
91
|
+
"hash_algorithm": "SHA2_512"
|
|
92
|
+
},
|
|
93
|
+
"ECDSA_WITH_SHA1": {
|
|
94
|
+
"name": "ECDSA with SHA-1",
|
|
95
|
+
"long_name": null,
|
|
96
|
+
"oid": "1.2.840.10045.4.1",
|
|
97
|
+
"key_type": "ECDSA",
|
|
98
|
+
"hash_algorithm": "SHA1"
|
|
99
|
+
},
|
|
100
|
+
"ECDSA_WITH_SHA2_224": {
|
|
101
|
+
"name": "ECDSA with SHA-224",
|
|
102
|
+
"long_name": null,
|
|
103
|
+
"oid": "1.2.840.10045.4.3.1",
|
|
104
|
+
"key_type": "ECDSA",
|
|
105
|
+
"hash_algorithm": "SHA2_224"
|
|
106
|
+
},
|
|
107
|
+
"ECDSA_WITH_SHA2_256": {
|
|
108
|
+
"name": "ECDSA with SHA-256",
|
|
109
|
+
"long_name": null,
|
|
110
|
+
"oid": "1.2.840.10045.4.3.2",
|
|
111
|
+
"key_type": "ECDSA",
|
|
112
|
+
"hash_algorithm": "SHA2_256"
|
|
113
|
+
},
|
|
114
|
+
"ECDSA_WITH_SHA2_384": {
|
|
115
|
+
"name": "ECDSA with SHA-384",
|
|
116
|
+
"long_name": null,
|
|
117
|
+
"oid": "1.2.840.10045.4.3.3",
|
|
118
|
+
"key_type": "ECDSA",
|
|
119
|
+
"hash_algorithm": "SHA2_384"
|
|
120
|
+
},
|
|
121
|
+
"ECDSA_WITH_SHA2_512": {
|
|
122
|
+
"name": "ECDSA with SHA-512",
|
|
123
|
+
"long_name": null,
|
|
124
|
+
"oid": "1.2.840.10045.4.3.4",
|
|
125
|
+
"key_type": "ECDSA",
|
|
126
|
+
"hash_algorithm": "SHA2_512"
|
|
127
|
+
},
|
|
128
|
+
"ECDSA_WITH_SHA3_224": {
|
|
129
|
+
"name": "ECDSA with SHA3-224",
|
|
130
|
+
"long_name": null,
|
|
131
|
+
"oid": "2.16.840.1.101.3.4.3.9",
|
|
132
|
+
"key_type": "ECDSA",
|
|
133
|
+
"hash_algorithm": "SHA3_224"
|
|
134
|
+
},
|
|
135
|
+
"ECDSA_WITH_SHA3_256": {
|
|
136
|
+
"name": "ECDSA with SHA3-256",
|
|
137
|
+
"long_name": null,
|
|
138
|
+
"oid": "2.16.840.1.101.3.4.3.10",
|
|
139
|
+
"key_type": "ECDSA",
|
|
140
|
+
"hash_algorithm": "SHA3_256"
|
|
141
|
+
},
|
|
142
|
+
"ECDSA_WITH_SHA3_384": {
|
|
143
|
+
"name": "ECDSA with SHA3-384",
|
|
144
|
+
"long_name": null,
|
|
145
|
+
"oid": "2.16.840.1.101.3.4.3.11",
|
|
146
|
+
"key_type": "ECDSA",
|
|
147
|
+
"hash_algorithm": "SHA3_384"
|
|
148
|
+
},
|
|
149
|
+
"ECDSA_WITH_SHA3_512": {
|
|
150
|
+
"name": "ECDSA with SHA3-512",
|
|
151
|
+
"long_name": null,
|
|
152
|
+
"oid": "2.16.840.1.101.3.4.3.12",
|
|
153
|
+
"key_type": "ECDSA",
|
|
154
|
+
"hash_algorithm": "SHA3_512"
|
|
155
|
+
},
|
|
156
|
+
"GOST_R3410_01": {
|
|
157
|
+
"name": "GOST R 34.10-2001 with GOST R 34.11-94",
|
|
158
|
+
"long_name": null,
|
|
159
|
+
"oid": "1.2.643.2.2.3",
|
|
160
|
+
"key_type": "GOST_R3410_01",
|
|
161
|
+
"hash_algorithm": "GOST_R3411_94"
|
|
162
|
+
},
|
|
163
|
+
"GOST_R3410_12_94_R3410": {
|
|
164
|
+
"name": "GOST R 34.10-2012 with GOST R 34.11-2012 (94)",
|
|
165
|
+
"long_name": null,
|
|
166
|
+
"oid": "1.2.643.7.1.1.3.1",
|
|
167
|
+
"key_type": "GOST_R3410_12_256",
|
|
168
|
+
"hash_algorithm": "GOST_R3411_12_256"
|
|
169
|
+
},
|
|
170
|
+
"GOST_R3411_12_256_R3410": {
|
|
171
|
+
"name": "GOST R 34.10-2012 with GOST R 34.11-2012 (256)",
|
|
172
|
+
"long_name": null,
|
|
173
|
+
"oid": "1.2.643.7.1.1.3.2",
|
|
174
|
+
"key_type": "GOST_R3410_12_256",
|
|
175
|
+
"hash_algorithm": "GOST_R3411_12_256"
|
|
176
|
+
},
|
|
177
|
+
"GOST_R3411_12_512_R3410": {
|
|
178
|
+
"name": "GOST R 34.10-2012 with GOST R 34.11-2012 (512)",
|
|
179
|
+
"long_name": null,
|
|
180
|
+
"oid": "1.2.643.7.1.1.3.3",
|
|
181
|
+
"key_type": "GOST_R3410_12_512",
|
|
182
|
+
"hash_algorithm": "GOST_R3411_12_512"
|
|
183
|
+
},
|
|
184
|
+
"ED25519": {
|
|
185
|
+
"name": "Ed25519",
|
|
186
|
+
"long_name": "Edwards-curve Digital Signature Algorithm Ed25519",
|
|
187
|
+
"oid": "1.3.101.112",
|
|
188
|
+
"key_type": "EDDSA",
|
|
189
|
+
"hash_algorithm": "SHA2_512"
|
|
190
|
+
},
|
|
191
|
+
"ED25519PH": {
|
|
192
|
+
"name": "Ed25519ph",
|
|
193
|
+
"long_name": "Edwards-curve Digital Signature Algorithm Ed25519 with pre-hashing",
|
|
194
|
+
"oid": "1.3.101.114",
|
|
195
|
+
"key_type": "EDDSA",
|
|
196
|
+
"hash_algorithm": "SHA2_512"
|
|
197
|
+
},
|
|
198
|
+
"ED448": {
|
|
199
|
+
"name": "Ed448",
|
|
200
|
+
"long_name": "Edwards-curve Digital Signature Algorithm Ed448",
|
|
201
|
+
"oid": "1.3.101.113",
|
|
202
|
+
"key_type": "EDDSA",
|
|
203
|
+
"hash_algorithm": "SHAKE_256"
|
|
204
|
+
},
|
|
205
|
+
"ED448PH": {
|
|
206
|
+
"name": "Ed448ph",
|
|
207
|
+
"long_name": "Edwards-curve Digital Signature Algorithm Ed448 with pre-hashing",
|
|
208
|
+
"oid": "1.3.101.115",
|
|
209
|
+
"key_type": "EDDSA",
|
|
210
|
+
"hash_algorithm": "SHAKE_256"
|
|
211
|
+
},
|
|
212
|
+
"E382": {
|
|
213
|
+
"name": "E382",
|
|
214
|
+
"long_name": null,
|
|
215
|
+
"oid": null,
|
|
216
|
+
"key_type": "EDDSA",
|
|
217
|
+
"hash_algorithm": "SHAKE_256"
|
|
218
|
+
},
|
|
219
|
+
"E521": {
|
|
220
|
+
"name": "E521",
|
|
221
|
+
"long_name": null,
|
|
222
|
+
"oid": null,
|
|
223
|
+
"key_type": "EDDSA",
|
|
224
|
+
"hash_algorithm": "SHAKE_256"
|
|
225
|
+
},
|
|
226
|
+
"XMSS": {
|
|
227
|
+
"name": "XMSS",
|
|
228
|
+
"long_name": null,
|
|
229
|
+
"oid": null,
|
|
230
|
+
"key_type": "XMSS",
|
|
231
|
+
"hash_algorithm": "SHA2_256"
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"RFC_2409": {
|
|
3
|
+
"name": "RFC 2409",
|
|
4
|
+
"long_name": "The Internet Key Exchange (IKE)",
|
|
5
|
+
"publisher": "IETF"
|
|
6
|
+
},
|
|
7
|
+
"RFC_2539": {
|
|
8
|
+
"name": "RFC 2539",
|
|
9
|
+
"long_name": "Storage of Diffie-Hellman Keys in the Domain Name System (DNS)",
|
|
10
|
+
"publisher": "IETF"
|
|
11
|
+
},
|
|
12
|
+
"RFC_3526": {
|
|
13
|
+
"name": "RFC 3526",
|
|
14
|
+
"long_name": "More Modular Exponential (MODP) Diffie-Hellman groups for Internet Key Exchange (IKE)",
|
|
15
|
+
"publisher": "IETF"
|
|
16
|
+
},
|
|
17
|
+
"RFC_5114": {
|
|
18
|
+
"name": "RFC 5114",
|
|
19
|
+
"long_name": "Additional Diffie-Hellman Groups for Use with IETF Standards",
|
|
20
|
+
"publisher": "IETF"
|
|
21
|
+
},
|
|
22
|
+
"RFC_5639": {
|
|
23
|
+
"name": "RFC 5639",
|
|
24
|
+
"long_name": "Elliptic Curve Cryptography (ECC) Brainpool Standard Curves and Curve Generation",
|
|
25
|
+
"publisher": "IETF"
|
|
26
|
+
},
|
|
27
|
+
"RFC_7919": {
|
|
28
|
+
"name": "RFC 7919",
|
|
29
|
+
"long_name": "Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for Transport Layer Security (TLS)",
|
|
30
|
+
"publisher": "IETF"
|
|
31
|
+
},
|
|
32
|
+
"SEC_2": {
|
|
33
|
+
"name": "SEC2",
|
|
34
|
+
"long_name": "SEC 2: Recommended Elliptic Curve Domain Parameters",
|
|
35
|
+
"publisher": "CERTICOM"
|
|
36
|
+
},
|
|
37
|
+
"SP_800_186": {
|
|
38
|
+
"name": "NIST SP 800-186",
|
|
39
|
+
"long_name": "NIST Special Publication NIST SP 800-186 Recommendations for Discrete Logarithm-based Cryptography: Elliptic Curve Domain Parameters",
|
|
40
|
+
"publisher": "NIST"
|
|
41
|
+
},
|
|
42
|
+
"WTLS": {
|
|
43
|
+
"name": "WTLS",
|
|
44
|
+
"long_name": "Wireless Application Protocol Wireless Transport Layer Security Specification",
|
|
45
|
+
"publisher": "WAP_FORUM"
|
|
46
|
+
},
|
|
47
|
+
"X9_62": {
|
|
48
|
+
"name": "X9.62",
|
|
49
|
+
"long_name": "Public Key Cryptography For The Financial Services Industry: The Elliptic Curve Digital Signature Algorithm (ECDSA)",
|
|
50
|
+
"publisher": "ANSI"
|
|
51
|
+
},
|
|
52
|
+
"X9_63": {
|
|
53
|
+
"name": "X9.63",
|
|
54
|
+
"long_name": "Public Key Cryptography For The Financial Services Industry - Key Agreement And Key Transport Using Elliptic Curve Cryptography",
|
|
55
|
+
"publisher": "ANSI"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
import collections
|
|
4
|
+
import datetime
|
|
5
|
+
import enum
|
|
6
|
+
import re
|
|
7
|
+
import six
|
|
8
|
+
|
|
9
|
+
import attr
|
|
10
|
+
|
|
11
|
+
from cryptodatahub.common.algorithm import Hash
|
|
12
|
+
from cryptodatahub.common.entity import Entity, EntityRole
|
|
13
|
+
from cryptodatahub.common.exception import InvalidValue
|
|
14
|
+
from cryptodatahub.common.key import PublicKeyX509Base
|
|
15
|
+
from cryptodatahub.common.types import (
|
|
16
|
+
Base64Data,
|
|
17
|
+
CryptoDataEnumBase,
|
|
18
|
+
CryptoDataParamsBase,
|
|
19
|
+
CryptoDataParamsFetchedBase,
|
|
20
|
+
convert_base64_data,
|
|
21
|
+
convert_datetime,
|
|
22
|
+
convert_dict_to_object,
|
|
23
|
+
convert_enum,
|
|
24
|
+
convert_iterable,
|
|
25
|
+
)
|
|
26
|
+
from cryptodatahub.common.utils import bytes_to_hex_string, name_to_enum_item_name
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@attr.s(frozen=True)
|
|
30
|
+
class CertificateTransparencyOperator(CryptoDataParamsBase):
|
|
31
|
+
name = attr.ib(validator=attr.validators.instance_of(six.string_types))
|
|
32
|
+
email = attr.ib(
|
|
33
|
+
default=(),
|
|
34
|
+
validator=attr.validators.deep_iterable(attr.validators.instance_of(six.string_types))
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
CertificateTransparencyLogType = enum.Enum('CertificateTransparencyLogType', 'TEST PROD')
|
|
39
|
+
CertificateTransparencyLogStateType = enum.Enum(
|
|
40
|
+
'CertificateTransparencyLogStateType', 'PENDING QUALIFIED USABLE READONLY RETIRED REJECTED'
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class CertificateTransparencyLogDateTimeBase(CryptoDataParamsBase):
|
|
45
|
+
def _asdict_serializer(self, _, __, value):
|
|
46
|
+
if isinstance(value, datetime.datetime):
|
|
47
|
+
return value.strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
48
|
+
|
|
49
|
+
return super(CertificateTransparencyLogDateTimeBase, self)._asdict_serializer(_, __, value)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@attr.s(frozen=True)
|
|
53
|
+
class CertificateTransparencyLogState(CertificateTransparencyLogDateTimeBase):
|
|
54
|
+
state_type = attr.ib(
|
|
55
|
+
converter=convert_enum(CertificateTransparencyLogStateType),
|
|
56
|
+
validator=attr.validators.optional(attr.validators.instance_of(CertificateTransparencyLogStateType))
|
|
57
|
+
)
|
|
58
|
+
timestamp = attr.ib(
|
|
59
|
+
converter=convert_datetime(),
|
|
60
|
+
validator=attr.validators.instance_of(datetime.datetime),
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@attr.s(frozen=True)
|
|
65
|
+
class CertificateTransparencyLogTemporalInterval(CertificateTransparencyLogDateTimeBase):
|
|
66
|
+
start_inclusive = attr.ib(
|
|
67
|
+
converter=convert_datetime(),
|
|
68
|
+
validator=attr.validators.instance_of(datetime.datetime),
|
|
69
|
+
)
|
|
70
|
+
end_exclusive = attr.ib(
|
|
71
|
+
converter=convert_datetime(),
|
|
72
|
+
validator=attr.validators.instance_of(datetime.datetime),
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@attr.s(frozen=True)
|
|
77
|
+
class CertificateTransparencyLogParamsBase(CryptoDataParamsBase):
|
|
78
|
+
log_id = attr.ib(
|
|
79
|
+
converter=convert_base64_data(),
|
|
80
|
+
validator=attr.validators.instance_of(Base64Data),
|
|
81
|
+
metadata={'human_readable_name': 'ID'},
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class CertificateTransparencyLogUnknown(CertificateTransparencyLogParamsBase):
|
|
86
|
+
def __str__(self):
|
|
87
|
+
return str(self.log_id)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
@attr.s(frozen=True)
|
|
91
|
+
class CertificateTransparencyLogParams( # pylint: disable=too-many-instance-attributes
|
|
92
|
+
CertificateTransparencyLogParamsBase
|
|
93
|
+
):
|
|
94
|
+
operator = attr.ib(
|
|
95
|
+
converter=convert_enum(Entity),
|
|
96
|
+
validator=attr.validators.instance_of(Entity),
|
|
97
|
+
metadata={'human_friendly': False},
|
|
98
|
+
)
|
|
99
|
+
key = attr.ib(
|
|
100
|
+
converter=convert_base64_data(),
|
|
101
|
+
validator=attr.validators.instance_of(Base64Data),
|
|
102
|
+
metadata={'human_friendly': False},
|
|
103
|
+
)
|
|
104
|
+
url = attr.ib(
|
|
105
|
+
validator=attr.validators.instance_of(six.string_types),
|
|
106
|
+
metadata={'human_readable_name': 'URL', 'human_friendly': False},
|
|
107
|
+
)
|
|
108
|
+
mmd = attr.ib(
|
|
109
|
+
validator=attr.validators.instance_of(int),
|
|
110
|
+
metadata={'human_readable_name': 'Maximum Merge Delay', 'human_friendly': False},
|
|
111
|
+
)
|
|
112
|
+
description = attr.ib(
|
|
113
|
+
default=None,
|
|
114
|
+
validator=attr.validators.optional(attr.validators.instance_of(six.string_types)),
|
|
115
|
+
)
|
|
116
|
+
dns = attr.ib(
|
|
117
|
+
default=None,
|
|
118
|
+
validator=attr.validators.optional(attr.validators.instance_of(six.string_types)),
|
|
119
|
+
metadata={'human_friendly': False},
|
|
120
|
+
)
|
|
121
|
+
temporal_interval = attr.ib(
|
|
122
|
+
default=None,
|
|
123
|
+
converter=convert_dict_to_object(CertificateTransparencyLogTemporalInterval),
|
|
124
|
+
validator=attr.validators.optional(attr.validators.instance_of(CertificateTransparencyLogTemporalInterval)),
|
|
125
|
+
metadata={'human_readable_name': 'DNS', 'human_friendly': False},
|
|
126
|
+
)
|
|
127
|
+
log_type = attr.ib(
|
|
128
|
+
default=None,
|
|
129
|
+
converter=convert_enum(CertificateTransparencyLogType),
|
|
130
|
+
validator=attr.validators.optional(attr.validators.instance_of(CertificateTransparencyLogType)),
|
|
131
|
+
metadata={'human_friendly': False},
|
|
132
|
+
)
|
|
133
|
+
log_state = attr.ib(
|
|
134
|
+
default=None,
|
|
135
|
+
converter=convert_dict_to_object(CertificateTransparencyLogState),
|
|
136
|
+
validator=attr.validators.optional(attr.validators.instance_of(CertificateTransparencyLogState))
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
def __attrs_post_init__(self):
|
|
140
|
+
if self.mmd < 1:
|
|
141
|
+
raise ValueError(self.mmd)
|
|
142
|
+
|
|
143
|
+
def __str__(self):
|
|
144
|
+
return '{} ({})'.format(
|
|
145
|
+
self.description, self.log_id
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
@classmethod
|
|
149
|
+
def description_to_enum_item_name(cls, description):
|
|
150
|
+
name = name_to_enum_item_name(description)
|
|
151
|
+
|
|
152
|
+
name = re.sub('([^_])(20[12][0-9][_0-9]*)(H[1-2])?(_LOG)?$', '\\1_\\2\\3\\4', name)
|
|
153
|
+
|
|
154
|
+
return name
|
|
155
|
+
|
|
156
|
+
@property
|
|
157
|
+
def identifier(self):
|
|
158
|
+
return self.description_to_enum_item_name(self.description)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class CertificateTransparencyLogBase(CryptoDataEnumBase):
|
|
162
|
+
@classmethod
|
|
163
|
+
def from_log_id(cls, log_id):
|
|
164
|
+
log_id = convert_base64_data()(log_id)
|
|
165
|
+
try:
|
|
166
|
+
log = cls._from_attr('log_id', log_id).value
|
|
167
|
+
except InvalidValue:
|
|
168
|
+
log = CertificateTransparencyLogUnknown(log_id)
|
|
169
|
+
|
|
170
|
+
return log
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
CertificateTransparencyLog = CertificateTransparencyLogBase(
|
|
174
|
+
'CertificateTransparencyLog', CryptoDataEnumBase.get_json_records(CertificateTransparencyLogParams)
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
RootCertificateTrustConstraintAction = enum.Enum('RootCertificateTrustConstraintAction', 'DISTRUST DISTURB')
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@attr.s(frozen=True)
|
|
182
|
+
class CertificateTrustConstraint(object):
|
|
183
|
+
action = attr.ib(
|
|
184
|
+
converter=convert_enum(RootCertificateTrustConstraintAction),
|
|
185
|
+
validator=attr.validators.instance_of(RootCertificateTrustConstraintAction),
|
|
186
|
+
)
|
|
187
|
+
domains = attr.ib(
|
|
188
|
+
default=(),
|
|
189
|
+
validator=attr.validators.deep_iterable(attr.validators.instance_of(six.string_types))
|
|
190
|
+
)
|
|
191
|
+
date = attr.ib(
|
|
192
|
+
default=None,
|
|
193
|
+
converter=convert_datetime('%Y-%m-%dT%H:%M:%S'),
|
|
194
|
+
validator=attr.validators.optional(attr.validators.instance_of(datetime.datetime))
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@attr.s(repr=False, slots=True, hash=True)
|
|
199
|
+
class _RootCertificateParamCertificateConverter(object):
|
|
200
|
+
def __call__(self, value):
|
|
201
|
+
if value is None:
|
|
202
|
+
return None
|
|
203
|
+
|
|
204
|
+
if isinstance(value, PublicKeyX509Base):
|
|
205
|
+
return value
|
|
206
|
+
|
|
207
|
+
if not isinstance(value, (list, tuple)):
|
|
208
|
+
return value
|
|
209
|
+
|
|
210
|
+
try:
|
|
211
|
+
return PublicKeyX509Base.from_pem_lines(value)
|
|
212
|
+
except ValueError:
|
|
213
|
+
pass
|
|
214
|
+
|
|
215
|
+
return value
|
|
216
|
+
|
|
217
|
+
def __repr__(self):
|
|
218
|
+
return '<root certificate parameter converter>'
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def convert_root_certificate_params():
|
|
222
|
+
return _RootCertificateParamCertificateConverter()
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
@attr.s(frozen=True)
|
|
226
|
+
class RootCertificateTrustStoreConstraint(CryptoDataParamsBase):
|
|
227
|
+
owner = attr.ib(
|
|
228
|
+
converter=convert_enum(Entity),
|
|
229
|
+
validator=attr.validators.instance_of(Entity)
|
|
230
|
+
)
|
|
231
|
+
constraints = attr.ib(
|
|
232
|
+
default=(),
|
|
233
|
+
converter=convert_iterable(convert_dict_to_object(CertificateTrustConstraint)),
|
|
234
|
+
validator=attr.validators.deep_iterable(attr.validators.instance_of(CertificateTrustConstraint))
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
@attr.s(frozen=True)
|
|
239
|
+
class RootCertificateParams(CryptoDataParamsFetchedBase):
|
|
240
|
+
certificate = attr.ib(
|
|
241
|
+
converter=convert_root_certificate_params(),
|
|
242
|
+
validator=attr.validators.instance_of(PublicKeyX509Base)
|
|
243
|
+
)
|
|
244
|
+
trust_stores = attr.ib(
|
|
245
|
+
default=(),
|
|
246
|
+
converter=convert_iterable(convert_dict_to_object(RootCertificateTrustStoreConstraint)),
|
|
247
|
+
validator=attr.validators.deep_iterable(attr.validators.instance_of(RootCertificateTrustStoreConstraint))
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
@classmethod
|
|
251
|
+
def subject_to_enum_item_name(cls, subject, serial_number):
|
|
252
|
+
if 'common_name' in subject:
|
|
253
|
+
name = subject['common_name']
|
|
254
|
+
elif 'organizational_unit_name' in subject:
|
|
255
|
+
name = subject['organizational_unit_name']
|
|
256
|
+
else:
|
|
257
|
+
name = subject['organization_name']
|
|
258
|
+
|
|
259
|
+
if not isinstance(name, six.string_types):
|
|
260
|
+
name = ' '.join(name)
|
|
261
|
+
|
|
262
|
+
return '{}_{}'.format(name_to_enum_item_name(name), serial_number)
|
|
263
|
+
|
|
264
|
+
@property
|
|
265
|
+
def identifier(self):
|
|
266
|
+
return self.subject_to_enum_item_name(self.certificate.subject, self.certificate.serial_number)
|
|
267
|
+
|
|
268
|
+
def _asdict(self):
|
|
269
|
+
dict_value = super(RootCertificateParams, self)._asdict()
|
|
270
|
+
dict_value['certificate'] = self.certificate.pem.splitlines()
|
|
271
|
+
meta = collections.OrderedDict([
|
|
272
|
+
('_subject', self.certificate.subject),
|
|
273
|
+
('_fingerprints', collections.OrderedDict([
|
|
274
|
+
(hash_algorithm.name, fingerprint)
|
|
275
|
+
for hash_algorithm, fingerprint in self.certificate.fingerprints.items()
|
|
276
|
+
])),
|
|
277
|
+
])
|
|
278
|
+
|
|
279
|
+
return collections.OrderedDict([('_meta', meta)] + list(dict_value.items()))
|
|
280
|
+
|
|
281
|
+
def get_constraints_by_owner(self, owner):
|
|
282
|
+
for trust_store_constraint in self.trust_stores:
|
|
283
|
+
if trust_store_constraint.owner == owner:
|
|
284
|
+
return trust_store_constraint.constraints
|
|
285
|
+
|
|
286
|
+
raise KeyError(owner)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
class RootCertificateBase(CryptoDataEnumBase):
|
|
290
|
+
@classmethod
|
|
291
|
+
def get_json_encoding(cls):
|
|
292
|
+
return 'utf-8'
|
|
293
|
+
|
|
294
|
+
@classmethod
|
|
295
|
+
def get_item_by_sha2_256_fingerprint(cls, fingerprint_value):
|
|
296
|
+
if not hasattr(cls, '_ITEMS_BY_SHA2_256_HASH'):
|
|
297
|
+
cls._ITEMS_BY_SHA2_256_HASH = {
|
|
298
|
+
bytes_to_hex_string(item.value.certificate.get_digest(Hash.SHA2_256)): item
|
|
299
|
+
for item in cls
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return cls._ITEMS_BY_SHA2_256_HASH[fingerprint_value.upper().replace(':', '')]
|
|
303
|
+
|
|
304
|
+
@classmethod
|
|
305
|
+
def get_items_by_trust_owner(cls, trust_owner):
|
|
306
|
+
if not hasattr(cls, '_ITEMS_BY_TRUST_OWNER'):
|
|
307
|
+
cls._ITEMS_BY_TRUST_OWNER = {
|
|
308
|
+
_trust_owner: []
|
|
309
|
+
for _trust_owner in Entity.get_items_by_role(EntityRole.CA_TRUST_STORE_OWNER)
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
for root_certificate in cls:
|
|
313
|
+
for _trust_owner in map(lambda trust_store: trust_store.owner, root_certificate.value.trust_stores):
|
|
314
|
+
cls._ITEMS_BY_TRUST_OWNER[_trust_owner].append(root_certificate)
|
|
315
|
+
|
|
316
|
+
cls._ITEMS_BY_TRUST_OWNER = cls._ITEMS_BY_TRUST_OWNER
|
|
317
|
+
|
|
318
|
+
return cls._ITEMS_BY_TRUST_OWNER[trust_owner]
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
RootCertificate = RootCertificateBase(
|
|
322
|
+
'RootCertificate', RootCertificateBase.get_json_records(RootCertificateParams)
|
|
323
|
+
)
|