Skip to content

Commit

Permalink
Added a test for update_into with an empty out buf (#9863)
Browse files Browse the repository at this point in the history
refs #9859
  • Loading branch information
alex authored Nov 11, 2023
1 parent 1e7136b commit 1fb0d8a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/hazmat/primitives/test_aes_gcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,22 +206,24 @@ def test_gcm_tag_decrypt_finalize_tag_length(self, tag, backend):

def test_buffer_protocol(self, backend):
data = bytearray(b"helloworld")
enc = base.Cipher(
c = base.Cipher(
algorithms.AES(bytearray(b"\x00" * 16)),
modes.GCM(bytearray(b"\x00" * 12)),
backend,
).encryptor()
)
enc = c.encryptor()
enc.authenticate_additional_data(bytearray(b"foo"))
ct = enc.update(data) + enc.finalize()
dec = base.Cipher(
algorithms.AES(bytearray(b"\x00" * 16)),
modes.GCM(bytearray(b"\x00" * 12), enc.tag),
backend,
).decryptor()

dec = c.decryptor()
dec.authenticate_additional_data(bytearray(b"foo"))
pt = dec.update(ct) + dec.finalize()
pt = dec.update(ct) + dec.finalize_with_tag(enc.tag)
assert pt == data

enc = c.encryptor()
with pytest.raises(ValueError):
enc.update_into(b"abc123", bytearray(0))

@pytest.mark.parametrize("size", [8, 128])
def test_gcm_min_max_iv(self, size, backend):
if backend._fips_enabled:
Expand Down

0 comments on commit 1fb0d8a

Please sign in to comment.