Skip to content

Commit 927e3a8

Browse files
committed
Added test
Added a test for the encryption mode
1 parent 5c8581d commit 927e3a8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_padding_oracle.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from cryptography.hazmat.primitives import padding
12
from padding_oracle import padding_oracle
23
from .cryptor import VulnerableCryptor
34

@@ -14,6 +15,21 @@ def test_padding_oracle_basic():
1415

1516
assert decrypted == plaintext
1617

18+
def test_padding_oracle_encryption():
19+
cryptor = VulnerableCryptor()
20+
21+
plaintext = b'the quick brown fox jumps over the lazy dog'
22+
ciphertext = cryptor.encrypt(plaintext)
23+
24+
padder = padding.PKCS7(128).padder()
25+
payload = padder.update(plaintext) + padder.finalize()
26+
27+
encrypted = padding_oracle(payload, cryptor.block_size,
28+
cryptor.oracle, 4, null_byte=b'?', mode='encrypt')
29+
print(encrypted)
30+
31+
assert encrypted == ciphertext
1732

1833
if __name__ == '__main__':
1934
test_padding_oracle_basic()
35+
test_padding_oracle_encryption()

0 commit comments

Comments
 (0)