summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-07-22 22:03:41 +0200
committerEgor Tensin <egor@tensin.name>2026-07-22 22:50:00 +0200
commit3fceda79fbfd2fe11937bf19fce6a14a00619b52 (patch)
tree92b0418b2158ba181a7eed29640f39ea2be77bb6
parentrewrite: aes: sort out error handling in most spots (diff)
downloadaes-tools-3fceda79fbfd2fe11937bf19fce6a14a00619b52.tar.gz
aes-tools-3fceda79fbfd2fe11937bf19fce6a14a00619b52.zip
aesxx/utils: add tests for invalid inputs
-rw-r--r--aesxx/utils/test/basic.cmake32
1 files changed, 32 insertions, 0 deletions
diff --git a/aesxx/utils/test/basic.cmake b/aesxx/utils/test/basic.cmake
index 9e9bcc3..df4150b 100644
--- a/aesxx/utils/test/basic.cmake
+++ b/aesxx/utils/test/basic.cmake
@@ -63,4 +63,36 @@ foreach(action encrypt decrypt)
--
"$<TARGET_FILE:${tgt}>" -a aes192 -m cbc 000102030405060708090a0b0c0d0e0f1011121314151617
)
+ add_test(NAME "${tgt}_invalid_key1" COMMAND Python3::Interpreter
+ "${CMAKE_SOURCE_DIR}/cmake/tools/ctest-driver.py"
+ run
+ --exit-code 1
+ --pass-regex [=[AES error: Couldn't parse '0001020304050607' \(possibly not complete input\) as a 256-bit block]=]
+ --
+ "$<TARGET_FILE:${tgt}>" -a aes256 -m ecb 0001020304050607
+ )
+ add_test(NAME "${tgt}_invalid_key2" COMMAND Python3::Interpreter
+ "${CMAKE_SOURCE_DIR}/cmake/tools/ctest-driver.py"
+ run
+ --exit-code 1
+ --pass-regex [=[AES error: Couldn't parse 'foobar' \(possibly not complete input\) as a 256-bit block]=]
+ --
+ "$<TARGET_FILE:${tgt}>" -a aes256 -m ecb foobar
+ )
+ add_test(NAME "${tgt}_invalid_iv" COMMAND Python3::Interpreter
+ "${CMAKE_SOURCE_DIR}/cmake/tools/ctest-driver.py"
+ run
+ --exit-code 1
+ --pass-regex [=[AES error: Couldn't parse '2222222222222222222222222222222' \(possibly not complete input\) as a 128-bit block]=]
+ --
+ "$<TARGET_FILE:${tgt}>" -a aes128 -m cbc 11111111111111111111111111111111 2222222222222222222222222222222
+ )
+ add_test(NAME "${tgt}_invalid_block" COMMAND Python3::Interpreter
+ "${CMAKE_SOURCE_DIR}/cmake/tools/ctest-driver.py"
+ run
+ --exit-code 1
+ --pass-regex [=[AES error: Couldn't parse '0' \(possibly not complete input\) as a 128-bit block]=]
+ --
+ "$<TARGET_FILE:${tgt}>" -a aes128 -m cbc 11111111111111111111111111111111 2222222222222222222222222222222 0
+ )
endforeach()