diff options
author | Legrandin <helderijs@gmail.com> | 2014-03-04 22:04:34 +0100 |
---|---|---|
committer | Dwayne Litzenberger <dlitz@dlitz.net> | 2014-06-22 20:42:00 -0700 |
commit | 629c26c21857f205b08211d7b1333eb5580c525d (patch) | |
tree | 5e187804055203acce77ce6eb452031cdb88aaa3 /lib/Crypto/PublicKey | |
parent | 7d6db864ea3f1d6e29cb5214cbfcc894d6091512 (diff) | |
download | pycrypto-629c26c21857f205b08211d7b1333eb5580c525d.tar.gz |
Remove a few custom exception types.
The following custom exceptions are replaced with ValueError:
* Crypto.Util.PaddingError
* Crypto.PublicKey.KeyFormatError
The custom Crypto.Util.asn1.NoDerElementError is now private to the
module.
Some white spaces have been removed.
Diffstat (limited to 'lib/Crypto/PublicKey')
-rw-r--r-- | lib/Crypto/PublicKey/DSA.py | 10 | ||||
-rw-r--r-- | lib/Crypto/PublicKey/__init__.py | 3 |
2 files changed, 5 insertions, 8 deletions
diff --git a/lib/Crypto/PublicKey/DSA.py b/lib/Crypto/PublicKey/DSA.py index 1818def..69f7f04 100644 --- a/lib/Crypto/PublicKey/DSA.py +++ b/lib/Crypto/PublicKey/DSA.py @@ -99,7 +99,7 @@ from Crypto.Util.py3compat import * from Crypto import Random from Crypto.IO import PKCS8, PEM from Crypto.Util.number import bytes_to_long, long_to_bytes -from Crypto.PublicKey import _DSA, _slowmath, pubkey, KeyFormatError +from Crypto.PublicKey import _DSA, _slowmath, pubkey from Crypto.Util.asn1 import DerObject, DerSequence,\ DerInteger, DerObjectId, DerBitString, newDerSequence, newDerBitString @@ -496,7 +496,7 @@ class DSAImplementation(object): :Raise ValueError: When **bits** is too little, too big, or not a multiple of 64. """ - + # Check against FIPS 186-2, which says that the size of the prime p # must be a multiple of 64 bits between 512 and 1024 for i in (0, 1, 2, 3, 4, 5, 6, 7, 8): @@ -596,7 +596,7 @@ class DSAImplementation(object): except (ValueError, EOFError): pass - raise KeyFormatError("DSA key format is not supported") + raise ValueError("DSA key format is not supported") def importKey(self, extern_key, passphrase=None): """Import a DSA key (public or private). @@ -626,7 +626,7 @@ class DSAImplementation(object): from which the decryption key is derived. :Return: A DSA key object (`_DSAobj`). - :Raise KeyFormatError: + :Raise ValueError: When the given key cannot be parsed (possibly because the pass phrase is wrong). @@ -663,7 +663,7 @@ class DSAImplementation(object): # This is probably a DER encoded key return self._importKeyDER(extern_key, passphrase) - raise KeyFormatError("DSA key format is not supported") + raise ValueError("DSA key format is not supported") #: `Object ID`_ for a DSA key. #: diff --git a/lib/Crypto/PublicKey/__init__.py b/lib/Crypto/PublicKey/__init__.py index df60c25..503809f 100644 --- a/lib/Crypto/PublicKey/__init__.py +++ b/lib/Crypto/PublicKey/__init__.py @@ -36,9 +36,6 @@ Crypto.PublicKey.RSA (Signing, encryption, and blinding) :undocumented: _DSA, _RSA, _fastmath, _slowmath, pubkey """ -class KeyFormatError(ValueError): - pass - __all__ = ['RSA', 'DSA', 'ElGamal'] __revision__ = "$Id$" |