Provide specialized error message when signing or verifying ed25519

signatures and pynacl is not installed (LP: #1854475)
This commit is contained in:
Scott Kitterman
2019-12-15 01:12:02 -05:00
parent 6c5f701131
commit 5a0824108d
3 changed files with 15 additions and 3 deletions
+2
View File
@@ -1,6 +1,8 @@
Version 1.0.1
- Follow CNAMES when looking up key records when using DNS (pydns)
(LP: #1856421)
- Provide specialized error message when signing or verifying ed25519
signatures and pynacl is not installed (LP: #1854475)
2019-12-09 Version 1.0.0
- Add support for RFC 8460 tlsrpt DKIM signature processing (LP: #1847020)
+5
View File
@@ -139,6 +139,11 @@ need not be considered experimental. The dkimpy implementation has
successfully interoperated with three other implementations and the technical
parameters for ed25519-sha256 are defined and stable.
To install from pypi with the required optional depenencies, use the ed25519
option:
```pip install -e '.[ed25519]'```
## DKIM SCRIPTS
Three helper programs are also supplied: dknewkey, dkimsign and
+6 -1
View File
@@ -184,7 +184,6 @@ class NaClNotFoundError(DKIMException):
""" Nacl package not installed, needed for ed25119 signatures """
pass
class UnknownKeyTypeError(DKIMException):
""" Key type (k tag) is not known (rsa/ed25519) """
@@ -443,7 +442,10 @@ def evaluate_pk(name, s):
pass
try:
if pub[b'k'] == b'ed25519':
try:
pk = nacl.signing.VerifyKey(pub[b'p'], encoder=nacl.encoding.Base64Encoder)
except NameError:
raise NaClNotFoundError('pynacl module required for ed25519 signing, see README.md')
keysize = 256
ktag = b'ed25519'
except KeyError:
@@ -826,7 +828,10 @@ class DKIM(DomainSigner):
except UnparsableKeyError as e:
raise KeyFormatError(str(e))
elif self.signature_algorithm == b'ed25519-sha256':
try:
pk = nacl.signing.SigningKey(privkey, encoder=nacl.encoding.Base64Encoder)
except NameError:
raise NaClNotFoundError('pynacl module required for ed25519 signing, see README.md')
if identity is not None and not identity.endswith(domain):
raise ParameterError("identity must end with domain")