Skip to content

Commit

Permalink
chunking didn't actually work (#5499)
Browse files Browse the repository at this point in the history
  • Loading branch information
reaperhulk authored Oct 25, 2020
1 parent 085d1e4 commit 836a92a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cryptography/hazmat/backends/openssl/ciphers.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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)

0 comments on commit 836a92a

Please sign in to comment.