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
+5
View File
@@ -384,6 +384,11 @@ def load_pk_from_dns(name, dnsfunc=get_txt):
pub = parse_tag_value(s)
except InvalidTagValueList as 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:
if pub[b'k'] == b'ed25519':
pk = nacl.signing.VerifyKey(pub[b'p'], encoder=nacl.encoding.Base64Encoder)