aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2019-04-21 10:36:03 -0400
committerJack Lloyd <[email protected]>2019-04-21 10:36:03 -0400
commite37bd06ea487a4d7b59b2e3f7e21fb955651daf9 (patch)
treefa674ed6d4b256f80c08cd0b52846bbe67a2dd1b /src/scripts
parent14cf876e4f245829b1ca1b361ff65df16bc05ca3 (diff)
Add raw block cipher interface for Python
Diffstat (limited to 'src/scripts')
-rw-r--r--src/scripts/test_python.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/scripts/test_python.py b/src/scripts/test_python.py
index 307d74269..94da4dc24 100644
--- a/src/scripts/test_python.py
+++ b/src/scripts/test_python.py
@@ -25,6 +25,22 @@ class BotanPythonTests(unittest.TestCase):
self.assertEqual(botan2.version_major(), 2)
self.assertTrue(botan2.version_minor() >= 8)
+ def test_block_cipher(self):
+ aes = botan2.BlockCipher("AES-128")
+ self.assertEqual(aes.algo_name(), "AES-128")
+ self.assertEqual(aes.block_size(), 16)
+ self.assertEqual(aes.minimum_keylength(), 16)
+ self.assertEqual(aes.maximum_keylength(), 16)
+
+ aes.set_key(hex_decode("000102030405060708090a0b0c0d0e0f"))
+ ct = aes.encrypt(hex_decode("00112233445566778899aabbccddeeff"))
+
+ self.assertEqual(hex_encode(ct), "69c4e0d86a7b0430d8cdb78070b4c55a")
+
+ pt = aes.decrypt(ct)
+
+ self.assertEqual(hex_encode(pt), "00112233445566778899aabbccddeeff")
+
def test_kdf(self):
secret = hex_decode('6FD4C3C0F38E5C7A6F83E99CD9BD')