CryptoDataHub 0.11.1__tar.gz → 0.12.1__tar.gz
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.
Potentially problematic release.
This version of CryptoDataHub might be problematic. Click here for more details.
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/CHANGELOG.rst +36 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/CryptoDataHub.egg-info/PKG-INFO +1 -1
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/PKG-INFO +1 -1
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/__setup__.py +1 -1
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/algorithm.py +1 -1
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/authentication.json +7 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/block-cipher-mode.json +1 -7
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/block-cipher.json +16 -2
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/hash.json +42 -4
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/key-exchange.json +1 -1
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/key.py +16 -27
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/mac.json +56 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/parameter.py +1 -1
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/signature.json +7 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/stores.py +13 -9
- CryptoDataHub-0.12.1/cryptodatahub/common/utils.py +110 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/ssh/algorithm.py +17 -15
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/ssh/compression-algorithm.json +4 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/ssh/encryption-algorithm.json +215 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/ssh/host-key-algorithm.json +157 -7
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/ssh/kex-algorithm.json +326 -18
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/ssh/mac-algorithm.json +169 -31
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/algorithm.py +23 -27
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/cipher-kind.json +1 -1
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/client.py +5 -5
- CryptoDataHub-0.11.1/cryptodatahub/common/utils.py +0 -37
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/CryptoDataHub.egg-info/SOURCES.txt +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/CryptoDataHub.egg-info/dependency_links.txt +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/CryptoDataHub.egg-info/requires.txt +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/CryptoDataHub.egg-info/top_level.txt +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/LICENSE.txt +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/MANIFEST.in +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/README.rst +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/__init__.py +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/__init__.py +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/attack-named.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/attack-type.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/certificate-transparency-log.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/client.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/dhparam-well-known.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/entity.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/entity.py +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/exception.py +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/grade.py +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/named-group.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/root-certificate.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/server.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/standard.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/types.py +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/common/vulnerability.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/dnsrec/__init__.py +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/dnsrec/algorithm.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/dnsrec/algorithm.py +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/dnsrec/digest-type.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/dnsrec/rr-type.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/ssh/__init__.py +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/ssh/elliptic-curve-identifier.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/__init__.py +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/certificate-compression-algorithm.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/cipher-suite-extension.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/cipher-suite.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/client.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/compression-method.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/ec-point-format.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/extension-type.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/grease-one-byte.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/grease-two-byte.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/hash-and-signature-algorithm.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/named-curve.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/next-protocol-name.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/protocol-name.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/psk-key-exchange-mode.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/token-binding-paramater.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/version.json +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/cryptodatahub/tls/version.py +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/requirements.txt +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/setup.cfg +0 -0
- {CryptoDataHub-0.11.1 → CryptoDataHub-0.12.1}/setup.py +0 -0
|
@@ -2,6 +2,42 @@
|
|
|
2
2
|
Changelog
|
|
3
3
|
=========
|
|
4
4
|
|
|
5
|
+
-------------------
|
|
6
|
+
0.12.1 - 2023-12-13
|
|
7
|
+
-------------------
|
|
8
|
+
|
|
9
|
+
Improvements
|
|
10
|
+
============
|
|
11
|
+
|
|
12
|
+
- SSH
|
|
13
|
+
|
|
14
|
+
- add missing compression algorithms (#16)
|
|
15
|
+
- add missing encryption algorithms (#16)
|
|
16
|
+
- add missing host key algorithms (#16)
|
|
17
|
+
- add missing KEX algorithms (#16)
|
|
18
|
+
|
|
19
|
+
- TLS
|
|
20
|
+
|
|
21
|
+
- add grade for SSL cipher kinds (#18)
|
|
22
|
+
|
|
23
|
+
-------------------
|
|
24
|
+
0.11.2 - 2023-11-13
|
|
25
|
+
-------------------
|
|
26
|
+
|
|
27
|
+
Notable fixes
|
|
28
|
+
=============
|
|
29
|
+
|
|
30
|
+
- Generic
|
|
31
|
+
|
|
32
|
+
- add missing garde for PQC algorithms
|
|
33
|
+
|
|
34
|
+
Refactor
|
|
35
|
+
========
|
|
36
|
+
|
|
37
|
+
- Generic
|
|
38
|
+
|
|
39
|
+
- move HTTP fetcher and digest generation to common utils
|
|
40
|
+
|
|
5
41
|
-------------------
|
|
6
42
|
0.11.1 - 2023-11-06
|
|
7
43
|
-------------------
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
__title__ = 'CryptoDataHub'
|
|
4
4
|
__technical_name__ = __title__.lower()
|
|
5
|
-
__version__ = '0.
|
|
5
|
+
__version__ = '0.12.1'
|
|
6
6
|
__description__ = 'Repository of cryptography-related data'
|
|
7
7
|
__author__ = 'Szilárd Pfeiffer'
|
|
8
8
|
__author_email__ = 'coroner@pfeifferszilard.hu'
|
|
@@ -115,7 +115,7 @@ class MACParams(CryptoDataParamsOIDOptional, GradeableVulnerabilities):
|
|
|
115
115
|
MAC = CryptoDataEnumOIDBase('MAC', CryptoDataEnumOIDBase.get_json_records(MACParams))
|
|
116
116
|
|
|
117
117
|
|
|
118
|
-
@attr.s
|
|
118
|
+
@attr.s(frozen=True)
|
|
119
119
|
class MACModeParams(CryptoDataParamsEnumString, GradeableVulnerabilities):
|
|
120
120
|
name = attr.ib(validator=attr.validators.instance_of(six.string_types))
|
|
121
121
|
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
}
|
|
86
86
|
],
|
|
87
87
|
"key_size": 192,
|
|
88
|
-
"block_size":
|
|
88
|
+
"block_size": 128
|
|
89
89
|
},
|
|
90
90
|
"TWOFISH256": {
|
|
91
91
|
"name": "Twofish-256",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
}
|
|
99
99
|
],
|
|
100
100
|
"key_size": 256,
|
|
101
|
-
"block_size":
|
|
101
|
+
"block_size": 128
|
|
102
102
|
},
|
|
103
103
|
"CAMELLIA_128": {
|
|
104
104
|
"name": "Camellia-128",
|
|
@@ -107,6 +107,13 @@
|
|
|
107
107
|
"key_size": 128,
|
|
108
108
|
"block_size": 128
|
|
109
109
|
},
|
|
110
|
+
"CAMELLIA_192": {
|
|
111
|
+
"name": "Camellia-192",
|
|
112
|
+
"long_name": null,
|
|
113
|
+
"vulnerabilities": null,
|
|
114
|
+
"key_size": 192,
|
|
115
|
+
"block_size": 128
|
|
116
|
+
},
|
|
110
117
|
"CAMELLIA_256": {
|
|
111
118
|
"name": "Camellia-256",
|
|
112
119
|
"long_name": null,
|
|
@@ -431,6 +438,13 @@
|
|
|
431
438
|
"key_size": 256,
|
|
432
439
|
"block_size": 128
|
|
433
440
|
},
|
|
441
|
+
"SM4": {
|
|
442
|
+
"name": "SM4",
|
|
443
|
+
"long_name": "ShangMi 4",
|
|
444
|
+
"vulnerabilities": [],
|
|
445
|
+
"key_size": 128,
|
|
446
|
+
"block_size": 128
|
|
447
|
+
},
|
|
434
448
|
"TRIPLE_DES": {
|
|
435
449
|
"name": "3DES",
|
|
436
450
|
"long_name": "Triple DES",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"named": null
|
|
46
46
|
}
|
|
47
47
|
],
|
|
48
|
-
"digest_size":
|
|
48
|
+
"digest_size": 128
|
|
49
49
|
},
|
|
50
50
|
"RIPEMD128": {
|
|
51
51
|
"name": "RIPEMD-128",
|
|
@@ -99,6 +99,19 @@
|
|
|
99
99
|
],
|
|
100
100
|
"digest_size": 160
|
|
101
101
|
},
|
|
102
|
+
"SHA1_96": {
|
|
103
|
+
"name": "SHA-1/96",
|
|
104
|
+
"long_name": "Secure Hash Algorithm 1 (96)",
|
|
105
|
+
"oid": null,
|
|
106
|
+
"vulnerabilities": [
|
|
107
|
+
{
|
|
108
|
+
"attack_type": "COLLISION",
|
|
109
|
+
"grade": "WEAK",
|
|
110
|
+
"named": null
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
"digest_size": 96
|
|
114
|
+
},
|
|
102
115
|
"SHA2_224": {
|
|
103
116
|
"name": "SHA-224",
|
|
104
117
|
"long_name": "Secure Hash Algorithm 2 (224)",
|
|
@@ -183,6 +196,13 @@
|
|
|
183
196
|
"vulnerabilities": null,
|
|
184
197
|
"digest_size": 256
|
|
185
198
|
},
|
|
199
|
+
"SM3": {
|
|
200
|
+
"name": "SM3",
|
|
201
|
+
"long_name": "ShangMi 3",
|
|
202
|
+
"oid": "1.2.156.10197.1.401",
|
|
203
|
+
"vulnerabilities": null,
|
|
204
|
+
"digest_size": 256
|
|
205
|
+
},
|
|
186
206
|
"TIGER_128": {
|
|
187
207
|
"name": "Tiger/128",
|
|
188
208
|
"long_name": null,
|
|
@@ -194,7 +214,13 @@
|
|
|
194
214
|
"name": "Tiger/128(96)",
|
|
195
215
|
"long_name": null,
|
|
196
216
|
"oid": null,
|
|
197
|
-
"vulnerabilities":
|
|
217
|
+
"vulnerabilities": [
|
|
218
|
+
{
|
|
219
|
+
"attack_type": "COLLISION",
|
|
220
|
+
"grade": "WEAK",
|
|
221
|
+
"named": null
|
|
222
|
+
}
|
|
223
|
+
],
|
|
198
224
|
"digest_size": 96
|
|
199
225
|
},
|
|
200
226
|
"TIGER_160": {
|
|
@@ -208,7 +234,13 @@
|
|
|
208
234
|
"name": "Tiger/160(96)",
|
|
209
235
|
"long_name": null,
|
|
210
236
|
"oid": null,
|
|
211
|
-
"vulnerabilities":
|
|
237
|
+
"vulnerabilities": [
|
|
238
|
+
{
|
|
239
|
+
"attack_type": "COLLISION",
|
|
240
|
+
"grade": "WEAK",
|
|
241
|
+
"named": null
|
|
242
|
+
}
|
|
243
|
+
],
|
|
212
244
|
"digest_size": 96
|
|
213
245
|
},
|
|
214
246
|
"TIGER_192": {
|
|
@@ -222,7 +254,13 @@
|
|
|
222
254
|
"name": "Tiger/192(96)",
|
|
223
255
|
"long_name": null,
|
|
224
256
|
"oid": null,
|
|
225
|
-
"vulnerabilities":
|
|
257
|
+
"vulnerabilities": [
|
|
258
|
+
{
|
|
259
|
+
"attack_type": "COLLISION",
|
|
260
|
+
"grade": "WEAK",
|
|
261
|
+
"named": null
|
|
262
|
+
}
|
|
263
|
+
],
|
|
226
264
|
"digest_size": 96
|
|
227
265
|
},
|
|
228
266
|
"WHIRLPOOL": {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
|
|
3
3
|
import abc
|
|
4
|
-
import hashlib
|
|
5
4
|
import base64
|
|
6
5
|
import collections
|
|
7
6
|
import datetime
|
|
@@ -26,7 +25,7 @@ from cryptodatahub.common.grade import (
|
|
|
26
25
|
Vulnerability,
|
|
27
26
|
)
|
|
28
27
|
from cryptodatahub.common.types import _ConverterBase
|
|
29
|
-
from cryptodatahub.common.utils import bytes_to_hex_string
|
|
28
|
+
from cryptodatahub.common.utils import bytes_to_hex_string, hash_bytes
|
|
30
29
|
|
|
31
30
|
from cryptodatahub.tls.algorithm import TlsExtensionType
|
|
32
31
|
|
|
@@ -38,7 +37,7 @@ class _PublicKeySizeGradeable(GradeableVulnerabilities):
|
|
|
38
37
|
return 'public key size'
|
|
39
38
|
|
|
40
39
|
|
|
41
|
-
@attr.s
|
|
40
|
+
@attr.s(frozen=True)
|
|
42
41
|
class PublicKeySize(GradeableComplex):
|
|
43
42
|
_FINITE_FIELD_TYPES = [Authentication.RSA, Authentication.DSS, KeyExchange.ADH, KeyExchange.DH, KeyExchange.DHE]
|
|
44
43
|
_ELLIPTIC_CURVE_TYPES = [Authentication.ECDSA, Authentication.EDDSA, KeyExchange.ECDH, KeyExchange.ECDHE]
|
|
@@ -79,6 +78,8 @@ class PublicKeySize(GradeableComplex):
|
|
|
79
78
|
Vulnerability(attack_type=AttackType.DOS_ATTACK, grade=Grade.WEAK, named=AttackNamed.DHEAT_ATTACK)
|
|
80
79
|
)
|
|
81
80
|
gradeables = [_PublicKeySizeGradeable(gradeables)]
|
|
81
|
+
elif self.key_type == KeyExchange.HYBRID_PQS:
|
|
82
|
+
gradeables = []
|
|
82
83
|
else:
|
|
83
84
|
gradeables = None
|
|
84
85
|
|
|
@@ -109,12 +110,12 @@ def convert_public_key_size(key_exchange):
|
|
|
109
110
|
return _PublicKeySizeConverter(key_exchange)
|
|
110
111
|
|
|
111
112
|
|
|
112
|
-
@attr.s
|
|
113
|
+
@attr.s(frozen=True)
|
|
113
114
|
class PublicKeyParamBase(object):
|
|
114
115
|
pass
|
|
115
116
|
|
|
116
117
|
|
|
117
|
-
@attr.s
|
|
118
|
+
@attr.s(frozen=True)
|
|
118
119
|
class PublicKeyParamsDsa(PublicKeyParamBase):
|
|
119
120
|
prime = attr.ib(validator=attr.validators.instance_of(six.integer_types))
|
|
120
121
|
generator = attr.ib(validator=attr.validators.instance_of(six.integer_types))
|
|
@@ -122,7 +123,7 @@ class PublicKeyParamsDsa(PublicKeyParamBase):
|
|
|
122
123
|
public_key_value = attr.ib(validator=attr.validators.instance_of(six.integer_types))
|
|
123
124
|
|
|
124
125
|
|
|
125
|
-
@attr.s
|
|
126
|
+
@attr.s(frozen=True)
|
|
126
127
|
class PublicKeyParamsEcdsa(PublicKeyParamBase):
|
|
127
128
|
named_group = attr.ib(validator=attr.validators.instance_of(NamedGroup))
|
|
128
129
|
point_x = attr.ib(validator=attr.validators.instance_of(six.integer_types))
|
|
@@ -142,26 +143,20 @@ class PublicKeyParamsEcdsa(PublicKeyParamBase):
|
|
|
142
143
|
return bytes(asn1crypto.keys.ECPointBitString.from_coords(self.point_x, self.point_y))
|
|
143
144
|
|
|
144
145
|
|
|
145
|
-
@attr.s
|
|
146
|
+
@attr.s(frozen=True)
|
|
146
147
|
class PublicKeyParamsEddsa(PublicKeyParamBase):
|
|
147
148
|
curve_type = attr.ib(validator=attr.validators.instance_of(NamedGroup))
|
|
148
149
|
key_data = attr.ib(validator=attr.validators.instance_of((bytes, bytearray)))
|
|
149
150
|
|
|
150
151
|
|
|
151
|
-
@attr.s
|
|
152
|
+
@attr.s(frozen=True)
|
|
152
153
|
class PublicKeyParamsRsa(PublicKeyParamBase):
|
|
153
154
|
modulus = attr.ib(validator=attr.validators.instance_of(six.integer_types))
|
|
154
155
|
public_exponent = attr.ib(validator=attr.validators.instance_of(six.integer_types))
|
|
155
156
|
|
|
156
157
|
|
|
157
|
-
@attr.s(eq=False)
|
|
158
|
+
@attr.s(eq=False, frozen=True)
|
|
158
159
|
class PublicKey(object):
|
|
159
|
-
_HASHLIB_FUNCS = {
|
|
160
|
-
Hash.MD5: hashlib.md5,
|
|
161
|
-
Hash.SHA1: hashlib.sha1,
|
|
162
|
-
Hash.SHA2_256: hashlib.sha256
|
|
163
|
-
}
|
|
164
|
-
|
|
165
160
|
_public_key = attr.ib(validator=attr.validators.instance_of(asn1crypto.keys.PublicKeyInfo))
|
|
166
161
|
|
|
167
162
|
@classmethod
|
|
@@ -317,17 +312,11 @@ class PublicKey(object):
|
|
|
317
312
|
def key_bytes(self):
|
|
318
313
|
return PublicKey.der.fget(self)
|
|
319
314
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
try:
|
|
323
|
-
hashlib_funcs = cls._HASHLIB_FUNCS[hash_type]
|
|
324
|
-
except KeyError as e:
|
|
325
|
-
six.raise_from(NotImplementedError(hash_type), e)
|
|
326
|
-
|
|
327
|
-
return hashlib_funcs(key_bytes).digest()
|
|
315
|
+
def get_digest(self, hash_type):
|
|
316
|
+
return hash_bytes(hash_type, self.der)
|
|
328
317
|
|
|
329
318
|
def fingerprint(self, hash_type):
|
|
330
|
-
return bytes_to_hex_string(self.get_digest(hash_type
|
|
319
|
+
return bytes_to_hex_string(self.get_digest(hash_type), ':')
|
|
331
320
|
|
|
332
321
|
@property
|
|
333
322
|
def fingerprints(self):
|
|
@@ -374,7 +363,7 @@ class PublicKeySigned(PublicKey):
|
|
|
374
363
|
raise NotImplementedError()
|
|
375
364
|
|
|
376
365
|
|
|
377
|
-
@attr.s(eq=False, init=False)
|
|
366
|
+
@attr.s(eq=False, init=False, frozen=True)
|
|
378
367
|
class PublicKeyX509Base(PublicKeySigned): # pylint: disable=too-many-public-methods
|
|
379
368
|
_EV_OIDS_BY_CA = {
|
|
380
369
|
'A-Trust': ('1.2.40.0.17.1.22', ),
|
|
@@ -435,7 +424,7 @@ class PublicKeyX509Base(PublicKeySigned): # pylint: disable=too-many-public-met
|
|
|
435
424
|
def __init__(self, certificate):
|
|
436
425
|
super(PublicKeySigned, self).__init__(certificate.public_key)
|
|
437
426
|
|
|
438
|
-
self
|
|
427
|
+
object.__setattr__(self, '_certificate', certificate)
|
|
439
428
|
|
|
440
429
|
@classmethod
|
|
441
430
|
def _get_type_name(cls):
|
|
@@ -472,7 +461,7 @@ class PublicKeyX509Base(PublicKeySigned): # pylint: disable=too-many-public-met
|
|
|
472
461
|
|
|
473
462
|
@property
|
|
474
463
|
def public_key_pin(self):
|
|
475
|
-
return base64.b64encode(
|
|
464
|
+
return base64.b64encode(hash_bytes(Hash.SHA2_256, self.key_bytes)).decode('ascii')
|
|
476
465
|
|
|
477
466
|
def _has_any_policy_value(self, oid_values):
|
|
478
467
|
if self._certificate.certificate_policies_value is None:
|
|
@@ -31,6 +31,54 @@
|
|
|
31
31
|
"digest_size": 256,
|
|
32
32
|
"hash_algorithm": null
|
|
33
33
|
},
|
|
34
|
+
"CBCMAC_3DES": {
|
|
35
|
+
"name": "CBC-MAC 3DES",
|
|
36
|
+
"long_name": null,
|
|
37
|
+
"oid": null,
|
|
38
|
+
"vulnerabilities": null,
|
|
39
|
+
"digest_size": 64,
|
|
40
|
+
"hash_algorithm": null
|
|
41
|
+
},
|
|
42
|
+
"CBCMAC_AES": {
|
|
43
|
+
"name": "CBC-MAC AES",
|
|
44
|
+
"long_name": null,
|
|
45
|
+
"oid": null,
|
|
46
|
+
"vulnerabilities": null,
|
|
47
|
+
"digest_size": 128,
|
|
48
|
+
"hash_algorithm": null
|
|
49
|
+
},
|
|
50
|
+
"CBCMAC_BLOWFISH": {
|
|
51
|
+
"name": "CBC-MAC Blowfish",
|
|
52
|
+
"long_name": null,
|
|
53
|
+
"oid": null,
|
|
54
|
+
"vulnerabilities": null,
|
|
55
|
+
"digest_size": 64,
|
|
56
|
+
"hash_algorithm": null
|
|
57
|
+
},
|
|
58
|
+
"CBCMAC_DES": {
|
|
59
|
+
"name": "CBC-MAC DES",
|
|
60
|
+
"long_name": null,
|
|
61
|
+
"oid": null,
|
|
62
|
+
"vulnerabilities": null,
|
|
63
|
+
"digest_size": 64,
|
|
64
|
+
"hash_algorithm": null
|
|
65
|
+
},
|
|
66
|
+
"CBCMAC_RIJNDAEL": {
|
|
67
|
+
"name": "CBC-MAC Rijndael",
|
|
68
|
+
"long_name": null,
|
|
69
|
+
"oid": null,
|
|
70
|
+
"vulnerabilities": null,
|
|
71
|
+
"digest_size": 128,
|
|
72
|
+
"hash_algorithm": null
|
|
73
|
+
},
|
|
74
|
+
"CBCMAC_TWOFISH": {
|
|
75
|
+
"name": "CBC-MAC Twofish",
|
|
76
|
+
"long_name": null,
|
|
77
|
+
"oid": null,
|
|
78
|
+
"vulnerabilities": null,
|
|
79
|
+
"digest_size": 128,
|
|
80
|
+
"hash_algorithm": null
|
|
81
|
+
},
|
|
34
82
|
"CRYPTICORE": {
|
|
35
83
|
"name": "CryptiCore",
|
|
36
84
|
"long_name": "CryptiCore (Badger)",
|
|
@@ -239,6 +287,14 @@
|
|
|
239
287
|
"digest_size": null,
|
|
240
288
|
"hash_algorithm": "SHA3_512"
|
|
241
289
|
},
|
|
290
|
+
"SM3": {
|
|
291
|
+
"name": "SM3",
|
|
292
|
+
"long_name": "ShangMi 3",
|
|
293
|
+
"oid": "1.2.156.10197.1.401.2",
|
|
294
|
+
"vulnerabilities": [],
|
|
295
|
+
"digest_size": null,
|
|
296
|
+
"hash_algorithm": "SM3"
|
|
297
|
+
},
|
|
242
298
|
"TIGER_128": {
|
|
243
299
|
"name": "Tiger/128",
|
|
244
300
|
"long_name": null,
|
|
@@ -48,7 +48,7 @@ class DHParameterNumbers(object):
|
|
|
48
48
|
return self.p == other.p and self.g == other.g and (self.q is None or self.q == other.q)
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
@attr.s(eq=False)
|
|
51
|
+
@attr.s(eq=False, frozen=True)
|
|
52
52
|
class DHParamWellKnownParams(CryptoDataParamsBase, GradeableVulnerabilities):
|
|
53
53
|
parameter_numbers = attr.ib(
|
|
54
54
|
converter=convert_dict_to_object(DHParameterNumbers),
|
|
@@ -41,7 +41,7 @@ CertificateTransparencyLogStateType = enum.Enum(
|
|
|
41
41
|
)
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
@attr.s
|
|
44
|
+
@attr.s(frozen=True)
|
|
45
45
|
class CertificateTransparencyLogState(CryptoDataParamsBase):
|
|
46
46
|
state_type = attr.ib(
|
|
47
47
|
converter=convert_enum(CertificateTransparencyLogStateType),
|
|
@@ -53,7 +53,7 @@ class CertificateTransparencyLogState(CryptoDataParamsBase):
|
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
@attr.s
|
|
56
|
+
@attr.s(frozen=True)
|
|
57
57
|
class CertificateTransparencyLogTemporalInterval(CryptoDataParamsBase):
|
|
58
58
|
start_inclusive = attr.ib(
|
|
59
59
|
converter=convert_datetime(),
|
|
@@ -65,7 +65,7 @@ class CertificateTransparencyLogTemporalInterval(CryptoDataParamsBase):
|
|
|
65
65
|
)
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
@attr.s
|
|
68
|
+
@attr.s(frozen=True)
|
|
69
69
|
class CertificateTransparencyLogParamsBase(CryptoDataParamsBase):
|
|
70
70
|
log_id = attr.ib(
|
|
71
71
|
converter=convert_base64_data(),
|
|
@@ -75,7 +75,8 @@ class CertificateTransparencyLogParamsBase(CryptoDataParamsBase):
|
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
class CertificateTransparencyLogUnknown(CertificateTransparencyLogParamsBase):
|
|
78
|
-
|
|
78
|
+
def __str__(self):
|
|
79
|
+
return str(self.log_id)
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
@attr.s(frozen=True)
|
|
@@ -131,6 +132,11 @@ class CertificateTransparencyLogParams( # pylint: disable=too-many-instance-att
|
|
|
131
132
|
if self.mmd < 1:
|
|
132
133
|
raise ValueError(self.mmd)
|
|
133
134
|
|
|
135
|
+
def __str__(self):
|
|
136
|
+
return '{} ({})'.format(
|
|
137
|
+
self.description, self.log_id
|
|
138
|
+
)
|
|
139
|
+
|
|
134
140
|
@classmethod
|
|
135
141
|
def description_to_enum_item_name(cls, description):
|
|
136
142
|
name = name_to_enum_item_name(description)
|
|
@@ -208,7 +214,7 @@ def convert_root_certificate_params():
|
|
|
208
214
|
return _RootCertificateParamCertificateConverter()
|
|
209
215
|
|
|
210
216
|
|
|
211
|
-
@attr.s
|
|
217
|
+
@attr.s(frozen=True)
|
|
212
218
|
class RootCertificateTrustStoreConstraint(CryptoDataParamsBase):
|
|
213
219
|
owner = attr.ib(
|
|
214
220
|
converter=convert_enum(Entity),
|
|
@@ -221,7 +227,7 @@ class RootCertificateTrustStoreConstraint(CryptoDataParamsBase):
|
|
|
221
227
|
)
|
|
222
228
|
|
|
223
229
|
|
|
224
|
-
@attr.s
|
|
230
|
+
@attr.s(frozen=True)
|
|
225
231
|
class RootCertificateParams(CryptoDataParamsFetchedBase):
|
|
226
232
|
certificate = attr.ib(
|
|
227
233
|
converter=convert_root_certificate_params(),
|
|
@@ -281,9 +287,7 @@ class RootCertificateBase(CryptoDataEnumBase):
|
|
|
281
287
|
def get_item_by_sha2_256_fingerprint(cls, fingerprint_value):
|
|
282
288
|
if not hasattr(cls, '_ITEMS_BY_SHA2_256_HASH'):
|
|
283
289
|
cls._ITEMS_BY_SHA2_256_HASH = {
|
|
284
|
-
bytes_to_hex_string(
|
|
285
|
-
item.value.certificate.get_digest(Hash.SHA2_256, item.value.certificate.der)
|
|
286
|
-
): item
|
|
290
|
+
bytes_to_hex_string(item.value.certificate.get_digest(Hash.SHA2_256)): item
|
|
287
291
|
for item in cls
|
|
288
292
|
}
|
|
289
293
|
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
import binascii
|
|
4
|
+
import hashlib
|
|
5
|
+
|
|
6
|
+
import attr
|
|
7
|
+
import six
|
|
8
|
+
import urllib3
|
|
9
|
+
|
|
10
|
+
from cryptodatahub.common.algorithm import Hash
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def bytes_to_hex_string(byte_array, separator='', lowercase=False):
|
|
14
|
+
if lowercase:
|
|
15
|
+
format_str = '{:02x}'
|
|
16
|
+
else:
|
|
17
|
+
format_str = '{:02X}'
|
|
18
|
+
|
|
19
|
+
return separator.join([format_str.format(x) for x in six.iterbytes(bytes(byte_array))])
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def bytes_from_hex_string(hex_string, separator=''):
|
|
23
|
+
if separator:
|
|
24
|
+
hex_string = ''.join(hex_string.split(separator))
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
binary_data = binascii.a2b_hex(hex_string)
|
|
28
|
+
except (TypeError, ValueError) as e:
|
|
29
|
+
six.raise_from(ValueError(*e.args), e)
|
|
30
|
+
|
|
31
|
+
return binary_data
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def name_to_enum_item_name(name):
|
|
35
|
+
converted_name = ''
|
|
36
|
+
for char in name:
|
|
37
|
+
if char.isalnum():
|
|
38
|
+
converted_name += char
|
|
39
|
+
elif converted_name and converted_name[-1] != '_':
|
|
40
|
+
converted_name += '_'
|
|
41
|
+
|
|
42
|
+
return converted_name.rstrip('_').upper()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
_HASHLIB_FUNCS = {
|
|
46
|
+
Hash.MD5: hashlib.md5,
|
|
47
|
+
Hash.SHA1: hashlib.sha1,
|
|
48
|
+
Hash.SHA2_224: hashlib.sha224,
|
|
49
|
+
Hash.SHA2_256: hashlib.sha256,
|
|
50
|
+
Hash.SHA2_384: hashlib.sha384,
|
|
51
|
+
Hash.SHA2_512: hashlib.sha512,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def hash_bytes(hash_algorithm, hashable_value):
|
|
56
|
+
try:
|
|
57
|
+
hashlib_funcs = _HASHLIB_FUNCS[hash_algorithm]
|
|
58
|
+
except KeyError as e:
|
|
59
|
+
six.raise_from(NotImplementedError(hash_algorithm), e)
|
|
60
|
+
|
|
61
|
+
return hashlib_funcs(hashable_value).digest()
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@attr.s
|
|
65
|
+
class HttpFetcher(object):
|
|
66
|
+
connect_timeout = attr.ib(default=2, validator=attr.validators.instance_of((int, float)))
|
|
67
|
+
read_timeout = attr.ib(default=1, validator=attr.validators.instance_of((int, float)))
|
|
68
|
+
retry = attr.ib(default=1, validator=attr.validators.instance_of(int))
|
|
69
|
+
_request_params = attr.ib(default=None, init=False)
|
|
70
|
+
_response = attr.ib(default=None, init=False)
|
|
71
|
+
|
|
72
|
+
def __attrs_post_init__(self):
|
|
73
|
+
request_params = {
|
|
74
|
+
'preload_content': False,
|
|
75
|
+
'timeout': urllib3.Timeout(connect=self.connect_timeout, read=self.read_timeout),
|
|
76
|
+
'retries': urllib3.Retry(
|
|
77
|
+
self.retry, status_forcelist=urllib3.Retry.RETRY_AFTER_STATUS_CODES | frozenset([502])
|
|
78
|
+
),
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
object.__setattr__(self, '_request_params', request_params)
|
|
82
|
+
|
|
83
|
+
def get_response_header(self, header_name):
|
|
84
|
+
if self._response is None:
|
|
85
|
+
raise AttributeError()
|
|
86
|
+
|
|
87
|
+
return self._response.headers.get(header_name, None)
|
|
88
|
+
|
|
89
|
+
@property
|
|
90
|
+
def response_data(self):
|
|
91
|
+
if self._response is None:
|
|
92
|
+
raise AttributeError()
|
|
93
|
+
|
|
94
|
+
return self._response.data
|
|
95
|
+
|
|
96
|
+
def fetch(self, url):
|
|
97
|
+
pool_manager = urllib3.PoolManager()
|
|
98
|
+
|
|
99
|
+
try:
|
|
100
|
+
self._response = pool_manager.request('GET', str(url), **self._request_params)
|
|
101
|
+
except BaseException as e: # pylint: disable=broad-except
|
|
102
|
+
if e.__class__.__name__ != 'TimeoutError' and not isinstance(e, urllib3.exceptions.HTTPError):
|
|
103
|
+
raise e
|
|
104
|
+
|
|
105
|
+
pool_manager.clear()
|
|
106
|
+
|
|
107
|
+
def __call__(self, url):
|
|
108
|
+
self.fetch(url)
|
|
109
|
+
|
|
110
|
+
return self.response_data
|