aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/hazmat/backends/openssl/backend.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-02-09 05:55:34 +0800
committerAlex Gaynor <alex.gaynor@gmail.com>2017-02-08 16:55:34 -0500
commit7a13085afce1415c0524a5dc5b94c98e3d6d7b7d (patch)
treeb13d9298a91fa673e54d18315351d431a78c86dd /src/cryptography/hazmat/backends/openssl/backend.py
parent0e6a129724b707ebf79149376251e85fad550414 (diff)
downloadcryptography-7a13085afce1415c0524a5dc5b94c98e3d6d7b7d.tar.gz
cryptography-7a13085afce1415c0524a5dc5b94c98e3d6d7b7d.tar.bz2
cryptography-7a13085afce1415c0524a5dc5b94c98e3d6d7b7d.zip
enforce password must be bytes when loading PEM/DER asymmetric keys (#3383)
* enforce password must be bytes when loading PEM/DER asymmetric keys Previously we were using an ffi.buffer on the Python string, which was allowing text implicitly, but our documentation explicitly requires bytes. * add changelog entry
Diffstat (limited to 'src/cryptography/hazmat/backends/openssl/backend.py')
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index e460ab51..e5144951 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -66,6 +66,8 @@ _MemoryBIO = collections.namedtuple("_MemoryBIO", ["bio", "char_ptr"])
class _PasswordUserdata(object):
def __init__(self, password):
+ if password is not None and not isinstance(password, bytes):
+ raise TypeError("Password must be bytes")
self.password = password
self.called = 0
self.exception = None