Skip to content

Commit 1fb0d8a

Browse files
authored
Added a test for update_into with an empty out buf (#9863)
refs #9859
1 parent 1e7136b commit 1fb0d8a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tests/hazmat/primitives/test_aes_gcm.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,24 @@ def test_gcm_tag_decrypt_finalize_tag_length(self, tag, backend):
206206

207207
def test_buffer_protocol(self, backend):
208208
data = bytearray(b"helloworld")
209-
enc = base.Cipher(
209+
c = base.Cipher(
210210
algorithms.AES(bytearray(b"\x00" * 16)),
211211
modes.GCM(bytearray(b"\x00" * 12)),
212212
backend,
213-
).encryptor()
213+
)
214+
enc = c.encryptor()
214215
enc.authenticate_additional_data(bytearray(b"foo"))
215216
ct = enc.update(data) + enc.finalize()
216-
dec = base.Cipher(
217-
algorithms.AES(bytearray(b"\x00" * 16)),
218-
modes.GCM(bytearray(b"\x00" * 12), enc.tag),
219-
backend,
220-
).decryptor()
217+
218+
dec = c.decryptor()
221219
dec.authenticate_additional_data(bytearray(b"foo"))
222-
pt = dec.update(ct) + dec.finalize()
220+
pt = dec.update(ct) + dec.finalize_with_tag(enc.tag)
223221
assert pt == data
224222

223+
enc = c.encryptor()
224+
with pytest.raises(ValueError):
225+
enc.update_into(b"abc123", bytearray(0))
226+
225227
@pytest.mark.parametrize("size", [8, 128])
226228
def test_gcm_min_max_iv(self, size, backend):
227229
if backend._fips_enabled:

0 commit comments

Comments
 (0)