- Support signature verification with SubjectPublicKeyInfo formatted keys

since, although rare, they are RFC 6376 specified (LP: #1851862)
This commit is contained in:
Scott Kitterman
2019-11-08 23:12:31 -05:00
parent 5893862e31
commit 4d2f425ae3
2 changed files with 7 additions and 2 deletions
+2
View File
@@ -3,6 +3,8 @@ Version 1.0.0
- Add new timeout parameter to enable DNS lookup timeouts to be adjusted
- Add new DKIM.present function to allow applications to test if a DKIM
signature is present without doing validation (LP: #1851141)
- Support signature verification with SubjectPublicKeyInfo formatted keys
since, although rare, they are RFC 6376 specified (LP: #1851862)
- Drop usage of pymilter Milter.dns in dnsplug since it doesn't support
havine a timeout passed to it
+5 -2
View File
@@ -118,8 +118,11 @@ def parse_public_key(data):
# Not sure why the [1:] is necessary to skip a byte.
x = asn1_parse(ASN1_Object, data)
pkd = asn1_parse(ASN1_RSAPublicKey, x[0][1][1:])
except ASN1FormatError as e:
raise UnparsableKeyError('Unparsable public key: ' + str(e))
except ASN1FormatError as e_spki:
try:
pkd = asn1_parse(ASN1_RSAPublicKey, data)
except ASN1FormatError as e_rsa:
raise UnparsableKeyError('Unparsable public key; SubjectPublicKeyInfo: ' + str(e_spki) + '; RSAPublicKey: ' + str(e_rsa))
pk = {
'modulus': pkd[0][0],
'publicExponent': pkd[0][1],