diff --git a/pgpy/errors.py b/pgpy/errors.py index 6af0612..8c94c05 100644 --- a/pgpy/errors.py +++ b/pgpy/errors.py @@ -4,6 +4,7 @@ __all__ = ('PGPError', 'PGPEncryptionError', 'PGPDecryptionError', + 'PGPIncompatibleECPointFormat', 'PGPOpenSSLCipherNotSupported', 'PGPInsecureCipher', 'WontImplementError',) @@ -24,6 +25,11 @@ class PGPDecryptionError(Exception): pass +class PGPIncompatibleECPointFormat(Exception): + """Raised when the point format is incompatible with the elliptic curve""" + pass + + class PGPOpenSSLCipherNotSupported(Exception): """Raised when OpenSSL does not support the requested cipher""" pass diff --git a/pgpy/packet/fields.py b/pgpy/packet/fields.py index 8e74805..cc5c8cb 100644 --- a/pgpy/packet/fields.py +++ b/pgpy/packet/fields.py @@ -55,6 +55,7 @@ from ..errors import PGPDecryptionError from ..errors import PGPError +from ..errors import PGPIncompatibleECPointFormat from ..symenc import _decrypt from ..symenc import _encrypt @@ -565,8 +566,7 @@ def parse(self, packet): self.p = ECPoint(packet) if self.p.format != ECPointFormat.Standard: - raise NotImplementedError("Expected: standard Elliptic curve point format (0x40). Got: 0x{:02X}".format(self.p.format)) - + raise PGPIncompatibleECPointFormat("Only Standard format is valid for ECDSA") class ECDHPub(PubKey): @@ -637,7 +637,7 @@ def parse(self, packet): self.p = ECPoint(packet) if self.p.format != ECPointFormat.Standard: - raise NotImplementedError("Expected: standard Elliptic curve point format (0x40). Got: 0x{:02X}".format(self.p.format)) + raise PGPIncompatibleECPointFormat("Only curves using Standard format are currently supported for ECDH") self.kdf.parse(packet)