[U-Boot] [PATCH 4/4] pytest: aes: add test for aes192 and aes256

Philippe Reynes philippe.reynes at softathome.com
Mon Sep 23 16:48:12 UTC 2019


Signed-off-by: Philippe Reynes <philippe.reynes at softathome.com>
---
 test/py/tests/aes/key192.bin |  1 +
 test/py/tests/aes/key256.bin |  1 +
 test/py/tests/test_aes.py    | 54 +++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 55 insertions(+), 1 deletion(-)
 create mode 100644 test/py/tests/aes/key192.bin
 create mode 100644 test/py/tests/aes/key256.bin

diff --git a/test/py/tests/aes/key192.bin b/test/py/tests/aes/key192.bin
new file mode 100644
index 0000000..9165c3f
--- /dev/null
+++ b/test/py/tests/aes/key192.bin
@@ -0,0 +1 @@
+TŠ¬aŽ3ˆÑç2D8ÄaLî¸Ñ'(
\ No newline at end of file
diff --git a/test/py/tests/aes/key256.bin b/test/py/tests/aes/key256.bin
new file mode 100644
index 0000000..4d9c6ab
--- /dev/null
+++ b/test/py/tests/aes/key256.bin
@@ -0,0 +1 @@
+ÏxÃýQCÖ¤oŒšÚˆn¨©h!Êa/噧8ŸU
\ No newline at end of file
diff --git a/test/py/tests/test_aes.py b/test/py/tests/test_aes.py
index 408bd77..baf410e 100644
--- a/test/py/tests/test_aes.py
+++ b/test/py/tests/test_aes.py
@@ -21,7 +21,7 @@ def test_aes(u_boot_console):
 
     # Send a command with no argument ...
     output = cons.run_command('aes')
-    assert('AES 128 CBC encryption' in ''.join(output))
+    assert('AES 128/192/256 CBC encryption' in ''.join(output))
 
     # Load file from host
     output = cons.run_command('host load hostfs - 1000 %skey128.bin' % datadir)
@@ -46,3 +46,55 @@ def test_aes(u_boot_console):
 
     output = cons.run_command('cmp.b 3000 5000 0x20')
     assert('Total of 32 byte(s) were the same' in ''.join(output))
+
+    #
+    # Load file from host
+    #
+    output = cons.run_command('host load hostfs - 1000 %skey192.bin' % datadir)
+    assert('24 bytes read' in ''.join(output))
+    output = cons.run_command('host load hostfs - 2000 %siv128.bin' % datadir)
+    assert('16 bytes read' in ''.join(output))
+    output = cons.run_command('host load hostfs - 3000 %splaintext.bin' % datadir)
+    assert('32 bytes read' in ''.join(output))
+
+    output = cons.run_command('md.b 3000 0x20')
+
+    output = cons.run_command('aes.192 enc 1000 2000 3000 4000 0x20')
+
+    output = cons.run_command('cmp.b 3000 4000 0x20')
+    assert('Total of 0 byte(s) were the same' in ''.join(output))
+
+    output = cons.run_command('md.b 4000 0x20')
+
+    output = cons.run_command('aes.192 dec 1000 2000 4000 5000 0x20')
+
+    output = cons.run_command('md.b 5000 0x20')
+
+    output = cons.run_command('cmp.b 3000 5000 0x20')
+    assert('Total of 32 byte(s) were the same' in ''.join(output))
+
+    #
+    # Load file from host
+    #
+    output = cons.run_command('host load hostfs - 1000 %skey256.bin' % datadir)
+    assert('32 bytes read' in ''.join(output))
+    output = cons.run_command('host load hostfs - 2000 %siv128.bin' % datadir)
+    assert('16 bytes read' in ''.join(output))
+    output = cons.run_command('host load hostfs - 3000 %splaintext.bin' % datadir)
+    assert('32 bytes read' in ''.join(output))
+
+    output = cons.run_command('md.b 3000 0x20')
+
+    output = cons.run_command('aes.256 enc 1000 2000 3000 4000 0x20')
+
+    output = cons.run_command('cmp.b 3000 4000 0x20')
+    assert('Total of 0 byte(s) were the same' in ''.join(output))
+
+    output = cons.run_command('md.b 4000 0x20')
+
+    output = cons.run_command('aes.256 dec 1000 2000 4000 5000 0x20')
+
+    output = cons.run_command('md.b 5000 0x20')
+
+    output = cons.run_command('cmp.b 3000 5000 0x20')
+    assert('Total of 32 byte(s) were the same' in ''.join(output))
-- 
2.7.4



More information about the U-Boot mailing list