blob: 79d65a0f41416719b99bcd433943f19360e5b377 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import binascii
import pytest
from cryptography.primitives.block import BlockCipher, ciphers, modes, padding
class TestBlockCipher(object):
def test_use_after_finalize(self):
cipher = BlockCipher(
ciphers.AES(binascii.unhexlify(b"0" * 32)),
modes.CBC(binascii.unhexlify(b"0" * 32), padding.NoPadding())
)
cipher.encrypt(b"a" * 16)
cipher.finalize()
with pytest.raises(ValueError):
cipher.encrypt(b"b" * 16)
with pytest.raises(ValueError):
cipher.finalize()
|