pytest: add a simple test to check the command aes
v2 cover pytest: add a simple test to check the command aes
This serie fix the command aes on sandbox and add a simple pytest for aes.
The first and second patch enable the command aes on sandbox and sandbox64. Thr third patch fix the command aes on sandbox (adding map_sysmem to avoid a segfault), the forth patch add a simple pytest for the command aes.
Philippe Reynes (4):
sandbox: enable command aes
sandbox64: enable command aes
cmd: aes: use map_sysmem when accessing memory
pytest: add a new test for aes
Changelog:
v2:
- add binary file (key128.bin, iv128.bin and plaintext.bin)
cmd/aes.c | 9 ++++---- configs/sandbox64_defconfig | 1 + configs/sandbox_defconfig | 1 + test/py/tests/aes/iv128.bin | 1 + test/py/tests/aes/key128.bin | 1 + test/py/tests/aes/plaintext.bin | 1 + test/py/tests/test_aes.py | 48 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 test/py/tests/aes/iv128.bin create mode 100644 test/py/tests/aes/key128.bin create mode 100644 test/py/tests/aes/plaintext.bin create mode 100644 test/py/tests/test_aes.py
Signature · 1 line
2.7.4
PATCH v2 1/4 sandbox: enable command aes
This commit enable the command aes on sandbox.
Then, it may be used on pytest.
--- configs/sandbox_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/sandbox_defconfig +1 -0
@@ -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
Signature · 1 line
2.7.4
PATCH v2 1/4 sandbox: enable command aes
Quoted 8 lines · Philippe Reynes
This commit enable the command aes on sandbox.
Then, it may be used on pytest.Signed-off-by Philippe Reynes <[email protected]>--- configs/sandbox_defconfig | 1 + 1 file changed, 1 insertion(+)
PATCH v2 2/4 sandbox64: enable command aes
In reply to Philippe ReynesThis commit add the support of command aes.
Then, it may be used on pytest.
--- configs/sandbox64_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/sandbox64_defconfig +1 -0
@@ -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
Signature · 1 line
2.7.4
PATCH v2 3/4 cmd: aes: use map_sysmem when accessing memory
In reply to Philippe ReynesThe aes command used to segfault when accessing memory in sandbox. The pointer accesses should be mapped.
--- cmd/aes.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
cmd/aes.c +5 -4
@@ -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);
Signature · 1 line
2.7.4
PATCH v2 3/4 cmd: aes: use map_sysmem when accessing memory
Quoted 26 lines · Philippe Reynes
The aes command used to segfault when accessing memory in sandbox. The pointer accesses should be mapped.
Signed-off-by Philippe Reynes <[email protected]>--- cmd/aes.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)cmd/aes.c +1
-1@@ -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;
cmd/aes.c static int do_aes(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) · line 56
Quoted 10 lines
cmd/aes.c +4
-3- 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);
Please can you unmap_sysmem() as well?
Regards,
SImon
PATCH v2 4/4 pytest: add a new test for aes
In reply to Philippe ReynesThis commit add a simple test to check that
a text may be ciphered and unciphered. Each
step are checked with the known result.
--- test/py/tests/aes/iv128.bin | 1 + test/py/tests/aes/key128.bin | 1 + test/py/tests/aes/plaintext.bin | 1 + test/py/tests/test_aes.py | 48 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 test/py/tests/aes/iv128.bin create mode 100644 test/py/tests/aes/key128.bin create mode 100644 test/py/tests/aes/plaintext.bin create mode 100644 test/py/tests/test_aes.py
test/py/tests/aes/iv128.bin new file +1 -0
@@ -0,0 +1 @@ +�!�/���a�P���r
test/py/tests/aes/key128.bin new file +1 -0
@@ -0,0 +1 @@ +����Ć皳���6}
test/py/tests/aes/plaintext.bin new file +1 -0
@@ -0,0 +1 @@ +AES128 is working, amazing !!!!!
test/py/tests/test_aes.py new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
2.7.4