* [U-Boot] [PATCH 1/4] sandbox: enable command aes
2019-09-19 13:39 [U-Boot] [PATCH 0/4] pytest: add a simple test to check the command aes Philippe Reynes
@ 2019-09-19 13:39 ` Philippe Reynes
2019-10-21 15:25 ` Simon Glass
2019-09-19 13:39 ` [U-Boot] [PATCH 2/4] sandbox64: " Philippe Reynes
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Philippe Reynes @ 2019-09-19 13:39 UTC (permalink / raw)
To: u-boot
This commit enable the command aes on sandbox.
Then, it may be used on pytest.
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
configs/sandbox_defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index 968ffda..d5872dd 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -67,6 +67,7 @@ CONFIG_CMD_QFW=y
CONFIG_CMD_BOOTSTAGE=y
CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
+CONFIG_CMD_AES=y
CONFIG_CMD_TPM=y
CONFIG_CMD_TPM_TEST=y
CONFIG_CMD_BTRFS=y
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 2/4] sandbox64: enable command aes
2019-09-19 13:39 [U-Boot] [PATCH 0/4] pytest: add a simple test to check the command aes Philippe Reynes
2019-09-19 13:39 ` [U-Boot] [PATCH 1/4] sandbox: enable " Philippe Reynes
@ 2019-09-19 13:39 ` Philippe Reynes
2019-09-19 13:39 ` [U-Boot] [PATCH 3/4] cmd: aes: use map_sysmem when accessing memory Philippe Reynes
2019-09-19 13:39 ` [U-Boot] [PATCH 4/4] pytest: add a new test for aes Philippe Reynes
3 siblings, 0 replies; 6+ messages in thread
From: Philippe Reynes @ 2019-09-19 13:39 UTC (permalink / raw)
To: u-boot
This commit add the support of command aes.
Then, it may be used on pytest.
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
configs/sandbox64_defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index c177ff8..9332e34 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -59,6 +59,7 @@ CONFIG_CMD_QFW=y
CONFIG_CMD_BOOTSTAGE=y
CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
+CONFIG_CMD_AES=y
CONFIG_CMD_TPM=y
CONFIG_CMD_TPM_TEST=y
CONFIG_CMD_BTRFS=y
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 3/4] cmd: aes: use map_sysmem when accessing memory
2019-09-19 13:39 [U-Boot] [PATCH 0/4] pytest: add a simple test to check the command aes Philippe Reynes
2019-09-19 13:39 ` [U-Boot] [PATCH 1/4] sandbox: enable " Philippe Reynes
2019-09-19 13:39 ` [U-Boot] [PATCH 2/4] sandbox64: " Philippe Reynes
@ 2019-09-19 13:39 ` Philippe Reynes
2019-09-19 13:39 ` [U-Boot] [PATCH 4/4] pytest: add a new test for aes Philippe Reynes
3 siblings, 0 replies; 6+ messages in thread
From: Philippe Reynes @ 2019-09-19 13:39 UTC (permalink / raw)
To: u-boot
The aes command used to segfault when accessing memory in sandbox.
The pointer accesses should be mapped.
Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
---
cmd/aes.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/cmd/aes.c b/cmd/aes.c
index 7ff4a71..3db110c 100644
--- a/cmd/aes.c
+++ b/cmd/aes.c
@@ -11,6 +11,7 @@
#include <malloc.h>
#include <asm/byteorder.h>
#include <linux/compiler.h>
+#include <mapmem.h>
/**
* do_aes() - Handle the "aes" command-line command
@@ -46,10 +47,10 @@ static int do_aes(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
dst_addr = simple_strtoul(argv[5], NULL, 16);
len = simple_strtoul(argv[6], NULL, 16);
- key_ptr = (uint8_t *)key_addr;
- iv_ptr = (uint8_t *)iv_addr;
- src_ptr = (uint8_t *)src_addr;
- dst_ptr = (uint8_t *)dst_addr;
+ key_ptr = (uint8_t *)map_sysmem(key_addr, 128 / 8);
+ iv_ptr = (uint8_t *)map_sysmem(iv_addr, 128 / 8);
+ src_ptr = (uint8_t *)map_sysmem(src_addr, len);
+ dst_ptr = (uint8_t *)map_sysmem(dst_addr, len);
/* First we expand the key. */
aes_expand_key(key_ptr, key_exp);
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH 4/4] pytest: add a new test for aes
2019-09-19 13:39 [U-Boot] [PATCH 0/4] pytest: add a simple test to check the command aes Philippe Reynes
` (2 preceding siblings ...)
2019-09-19 13:39 ` [U-Boot] [PATCH 3/4] cmd: aes: use map_sysmem when accessing memory Philippe Reynes
@ 2019-09-19 13:39 ` Philippe Reynes
3 siblings, 0 replies; 6+ messages in thread
From: Philippe Reynes @ 2019-09-19 13:39 UTC (permalink / raw)
To: u-boot
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@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
^ permalink raw reply related [flat|nested] 6+ messages in thread