diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cryptography/hazmat/backends/openssl/aead.py | 6 | ||||
| -rw-r--r-- | src/cryptography/hazmat/primitives/ciphers/aead.py | 12 | 
2 files changed, 10 insertions, 8 deletions
| diff --git a/src/cryptography/hazmat/backends/openssl/aead.py b/src/cryptography/hazmat/backends/openssl/aead.py index 9cec3e23..73195ff3 100644 --- a/src/cryptography/hazmat/backends/openssl/aead.py +++ b/src/cryptography/hazmat/backends/openssl/aead.py @@ -54,12 +54,14 @@ def _aead_setup(backend, cipher_name, key, nonce, tag, tag_len, operation):              ctx, backend._lib.EVP_CTRL_AEAD_SET_TAG, tag_len, backend._ffi.NULL          ) +    nonce_ptr = backend._ffi.from_buffer(nonce) +    key_ptr = backend._ffi.from_buffer(key)      res = backend._lib.EVP_CipherInit_ex(          ctx,          backend._ffi.NULL,          backend._ffi.NULL, -        key, -        nonce, +        key_ptr, +        nonce_ptr,          int(operation == _ENCRYPT)      )      backend.openssl_assert(res != 0) diff --git a/src/cryptography/hazmat/primitives/ciphers/aead.py b/src/cryptography/hazmat/primitives/ciphers/aead.py index 16899d00..42e19adb 100644 --- a/src/cryptography/hazmat/primitives/ciphers/aead.py +++ b/src/cryptography/hazmat/primitives/ciphers/aead.py @@ -20,7 +20,7 @@ class ChaCha20Poly1305(object):                  "ChaCha20Poly1305 is not supported by this version of OpenSSL",                  exceptions._Reasons.UNSUPPORTED_CIPHER              ) -        utils._check_bytes("key", key) +        utils._check_byteslike("key", key)          if len(key) != 32:              raise ValueError("ChaCha20Poly1305 key must be 32 bytes.") @@ -56,7 +56,7 @@ class ChaCha20Poly1305(object):          )      def _check_params(self, nonce, data, associated_data): -        utils._check_bytes("nonce", nonce) +        utils._check_byteslike("nonce", nonce)          utils._check_bytes("data", data)          utils._check_bytes("associated_data", associated_data)          if len(nonce) != 12: @@ -67,7 +67,7 @@ class AESCCM(object):      _MAX_SIZE = 2 ** 32      def __init__(self, key, tag_length=16): -        utils._check_bytes("key", key) +        utils._check_byteslike("key", key)          if len(key) not in (16, 24, 32):              raise ValueError("AESCCM key must be 128, 192, or 256 bits.") @@ -129,7 +129,7 @@ class AESCCM(object):              raise ValueError("Nonce too long for data")      def _check_params(self, nonce, data, associated_data): -        utils._check_bytes("nonce", nonce) +        utils._check_byteslike("nonce", nonce)          utils._check_bytes("data", data)          utils._check_bytes("associated_data", associated_data)          if not 7 <= len(nonce) <= 13: @@ -140,7 +140,7 @@ class AESGCM(object):      _MAX_SIZE = 2 ** 32      def __init__(self, key): -        utils._check_bytes("key", key) +        utils._check_byteslike("key", key)          if len(key) not in (16, 24, 32):              raise ValueError("AESGCM key must be 128, 192, or 256 bits.") @@ -181,7 +181,7 @@ class AESGCM(object):          )      def _check_params(self, nonce, data, associated_data): -        utils._check_bytes("nonce", nonce) +        utils._check_byteslike("nonce", nonce)          utils._check_bytes("data", data)          utils._check_bytes("associated_data", associated_data)          if len(nonce) == 0: | 
