aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAlex Stapleton <alex@ly.st>2014-05-27 12:14:09 +0100
committerAlex Stapleton <alexs@prol.etari.at>2014-05-27 21:50:31 +0100
commit70ada5893662cae303f716c2e3cac03989c5e2d9 (patch)
tree16546fdedeeb61b0933ea2ddff3bd25b7f738c99 /cryptography
parenteefc3920d548c7fcee01b898cb9b0705b02e9537 (diff)
downloadcryptography-70ada5893662cae303f716c2e3cac03989c5e2d9.tar.gz
cryptography-70ada5893662cae303f716c2e3cac03989c5e2d9.tar.bz2
cryptography-70ada5893662cae303f716c2e3cac03989c5e2d9.zip
Add unknown cipher test for PKCS8
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py
index d25ac0d1..5529f10c 100644
--- a/cryptography/hazmat/backends/openssl/backend.py
+++ b/cryptography/hazmat/backends/openssl/backend.py
@@ -827,20 +827,33 @@ class Backend(object):
"Bad decrypt. Incorrect password?"
)
- elif errors[0][1:] == (
- self._lib.ERR_LIB_PEM,
- self._lib.PEM_F_PEM_GET_EVP_CIPHER_INFO,
- self._lib.PEM_R_UNSUPPORTED_ENCRYPTION
+ elif errors[0][1:] in (
+ (
+ self._lib.ERR_LIB_PEM,
+ self._lib.PEM_F_PEM_GET_EVP_CIPHER_INFO,
+ self._lib.PEM_R_UNSUPPORTED_ENCRYPTION
+ ),
+
+ (
+ self._lib.ERR_LIB_EVP,
+ self._lib.EVP_F_EVP_PBE_CIPHERINIT,
+ self._lib.EVP_R_UNKNOWN_PBE_ALGORITHM
+ )
):
raise UnsupportedAlgorithm(
- "PEM data is encrypted with an unsupported cipher")
+ "PEM data is encrypted with an unsupported cipher",
+ _Reasons.UNSUPPORTED_CIPHER
+ )
elif errors[0][1:] == (
self._lib.ERR_LIB_EVP,
self._lib.EVP_F_EVP_PKCS82PKEY,
self._lib.EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM
):
- raise ValueError("Unsupported private key algorithm.")
+ raise UnsupportedAlgorithm(
+ "Unsupported public key algorithm.",
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ )
else:
assert errors[0][1] in (