From 3fceda79fbfd2fe11937bf19fce6a14a00619b52 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 22 Jul 2026 22:03:41 +0200 Subject: aesxx/utils: add tests for invalid inputs --- aesxx/utils/test/basic.cmake | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'aesxx/utils/test/basic.cmake') 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) -- "$" -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]=] + -- + "$" -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]=] + -- + "$" -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]=] + -- + "$" -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]=] + -- + "$" -a aes128 -m cbc 11111111111111111111111111111111 2222222222222222222222222222222 0 + ) endforeach() -- cgit v1.3