[U-Boot] [PATCH 4/4] pytest: add a new test for aes
Philippe Reynes
philippe.reynes at softathome.com
Thu Sep 19 13:39:45 UTC 2019
This commit add a simple test to check that
a text may be ciphered and unciphered. Each
step are checked with the known result.
Signed-off-by: Philippe Reynes <philippe.reynes at softathome.com>
---
test/py/tests/test_aes.py | 48 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
create mode 100644 test/py/tests/test_aes.py
diff --git a/test/py/tests/test_aes.py b/test/py/tests/test_aes.py
new file mode 100644
index 0000000..408bd77
--- /dev/null
+++ b/test/py/tests/test_aes.py
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019, Softathome
+
+# Test U-Boot's "aes" command.
+
+import pytest
+
+def test_aes(u_boot_console):
+ """
+ Test the aes command, and validate that it can
+ cipher and uncipher a simple text
+ """
+
+ cons = u_boot_console
+ tmpdir = cons.config.result_dir + '/'
+ datadir = cons.config.source_dir + '/test/py/tests/aes/'
+
+ # Check that the option cmd_aes is enabled in the config
+ if cons.config.buildconfig.get('config_cmd_aes', 'n') != 'y':
+ pytest.skip('aes command not supported')
+
+ # Send a command with no argument ...
+ output = cons.run_command('aes')
+ assert('AES 128 CBC encryption' in ''.join(output))
+
+ # Load file from host
+ output = cons.run_command('host load hostfs - 1000 %skey128.bin' % datadir)
+ assert('16 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 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 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