Detect incorrect version in DKIM public key record (LP: #1763815)

This commit is contained in:
Scott Kitterman
2018-05-18 18:17:30 -04:00
parent 261eb5f5eb
commit bec6869c78
2 changed files with 6 additions and 0 deletions
+1
View File
@@ -5,6 +5,7 @@ Unreleased Version 0.8.0
dependencies for dkimpy (LP: #1227526) dependencies for dkimpy (LP: #1227526)
- Fix typo in dknewky(1) for k= tag (Thanks to Andreas Schulze for - Fix typo in dknewky(1) for k= tag (Thanks to Andreas Schulze for
reporting) reporting)
- Detect incorrect version in DKIM public key record (LP: #1763815)
- Indicate that ed25519-sha256 is no longer experimental - Indicate that ed25519-sha256 is no longer experimental
2018-02-17 Version 0.7.1 2018-02-17 Version 0.7.1
+5
View File
@@ -384,6 +384,11 @@ def load_pk_from_dns(name, dnsfunc=get_txt):
pub = parse_tag_value(s) pub = parse_tag_value(s)
except InvalidTagValueList as e: except InvalidTagValueList as e:
raise KeyFormatError(e) raise KeyFormatError(e)
try:
if pub[b'v'] != b'DKIM1':
raise KeyFormatError("Unknown DKIM version in public key record: '{0}'".format(pub[b'v']))
except KeyError as e:
pass
try: try:
if pub[b'k'] == b'ed25519': if pub[b'k'] == b'ed25519':
pk = nacl.signing.VerifyKey(pub[b'p'], encoder=nacl.encoding.Base64Encoder) pk = nacl.signing.VerifyKey(pub[b'p'], encoder=nacl.encoding.Base64Encoder)