Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chunking didn't actually work #5499

Merged
merged 1 commit into from Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cryptography/hazmat/backends/openssl/ciphers.py
Expand Up @@ -17,7 +17,7 @@
class _CipherContext(object):
_ENCRYPT = 1
_DECRYPT = 0
_MAX_CHUNK_SIZE = 2 ** 31
_MAX_CHUNK_SIZE = 2 ** 31 - 1

def __init__(self, backend, cipher, mode, operation):
self._backend = backend
Expand Down
9 changes: 9 additions & 0 deletions tests/hazmat/primitives/test_ciphers.py
Expand Up @@ -333,3 +333,12 @@ def test_update_into_auto_chunking(self, backend, monkeypatch):
decbuf = bytearray(527)
decprocessed = decryptor.update_into(buf[:processed], decbuf)
assert decbuf[:decprocessed] == pt

def test_max_chunk_size_fits_in_int32(self, backend):
# max chunk must fit in signed int32 or else a call large enough to
# cause chunking will result in the very OverflowError we want to
# avoid with chunking.
key = b"\x00" * 16
c = ciphers.Cipher(AES(key), modes.ECB(), backend)
encryptor = c.encryptor()
backend._ffi.new("int *", encryptor._ctx._MAX_CHUNK_SIZE)