From 225ef13cc7f58b69ef4c4db6308a225c726359f7 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Wed, 24 Jun 2015 05:59:11 +0300 Subject: move executables from test/ to utils/ --- test/CMakeLists.txt | 37 ------------ test/README.md | 4 +- test/aes128cbc_decrypt_block.c | 76 ----------------------- test/aes128cbc_encrypt_block.c | 75 ----------------------- test/aes128cfb_decrypt_block.c | 75 ----------------------- test/aes128cfb_encrypt_block.c | 75 ----------------------- test/aes128ctr_decrypt_block.c | 75 ----------------------- test/aes128ctr_encrypt_block.c | 75 ----------------------- test/aes128ecb_decrypt_block.c | 70 --------------------- test/aes128ecb_encrypt_block.c | 69 --------------------- test/aes128ofb_decrypt_block.c | 75 ----------------------- test/aes128ofb_encrypt_block.c | 75 ----------------------- test/aes192cbc_decrypt_block.c | 76 ----------------------- test/aes192cbc_encrypt_block.c | 75 ----------------------- test/aes192cfb_decrypt_block.c | 75 ----------------------- test/aes192cfb_encrypt_block.c | 75 ----------------------- test/aes192ctr_decrypt_block.c | 75 ----------------------- test/aes192ctr_encrypt_block.c | 75 ----------------------- test/aes192ecb_decrypt_block.c | 70 --------------------- test/aes192ecb_encrypt_block.c | 69 --------------------- test/aes192ofb_decrypt_block.c | 75 ----------------------- test/aes192ofb_encrypt_block.c | 75 ----------------------- test/aes256cbc_decrypt_block.c | 76 ----------------------- test/aes256cbc_encrypt_block.c | 75 ----------------------- test/aes256cfb_decrypt_block.c | 75 ----------------------- test/aes256cfb_encrypt_block.c | 75 ----------------------- test/aes256ctr_decrypt_block.c | 75 ----------------------- test/aes256ctr_encrypt_block.c | 75 ----------------------- test/aes256ecb_decrypt_block.c | 70 --------------------- test/aes256ecb_encrypt_block.c | 69 --------------------- test/aes256ofb_decrypt_block.c | 75 ----------------------- test/aes256ofb_encrypt_block.c | 75 ----------------------- test/aes_common.hpp | 134 ----------------------------------------- test/aes_decrypt_block.cpp | 122 ------------------------------------- test/aes_encrypt_block.cpp | 122 ------------------------------------- 35 files changed, 2 insertions(+), 2637 deletions(-) delete mode 100644 test/CMakeLists.txt delete mode 100644 test/aes128cbc_decrypt_block.c delete mode 100644 test/aes128cbc_encrypt_block.c delete mode 100644 test/aes128cfb_decrypt_block.c delete mode 100644 test/aes128cfb_encrypt_block.c delete mode 100644 test/aes128ctr_decrypt_block.c delete mode 100644 test/aes128ctr_encrypt_block.c delete mode 100644 test/aes128ecb_decrypt_block.c delete mode 100644 test/aes128ecb_encrypt_block.c delete mode 100644 test/aes128ofb_decrypt_block.c delete mode 100644 test/aes128ofb_encrypt_block.c delete mode 100644 test/aes192cbc_decrypt_block.c delete mode 100644 test/aes192cbc_encrypt_block.c delete mode 100644 test/aes192cfb_decrypt_block.c delete mode 100644 test/aes192cfb_encrypt_block.c delete mode 100644 test/aes192ctr_decrypt_block.c delete mode 100644 test/aes192ctr_encrypt_block.c delete mode 100644 test/aes192ecb_decrypt_block.c delete mode 100644 test/aes192ecb_encrypt_block.c delete mode 100644 test/aes192ofb_decrypt_block.c delete mode 100644 test/aes192ofb_encrypt_block.c delete mode 100644 test/aes256cbc_decrypt_block.c delete mode 100644 test/aes256cbc_encrypt_block.c delete mode 100644 test/aes256cfb_decrypt_block.c delete mode 100644 test/aes256cfb_encrypt_block.c delete mode 100644 test/aes256ctr_decrypt_block.c delete mode 100644 test/aes256ctr_encrypt_block.c delete mode 100644 test/aes256ecb_decrypt_block.c delete mode 100644 test/aes256ecb_encrypt_block.c delete mode 100644 test/aes256ofb_decrypt_block.c delete mode 100644 test/aes256ofb_encrypt_block.c delete mode 100644 test/aes_common.hpp delete mode 100644 test/aes_decrypt_block.cpp delete mode 100644 test/aes_encrypt_block.cpp (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 2d58160..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -macro(test prefix) - add_executable(test_${prefix}_encrypt_block ${prefix}_encrypt_block.c) - target_link_libraries(test_${prefix}_encrypt_block libaesni) - set_target_properties(test_${prefix}_encrypt_block PROPERTIES OUTPUT_NAME ${prefix}_encrypt_block) - - add_executable(test_${prefix}_decrypt_block ${prefix}_decrypt_block.c) - target_link_libraries(test_${prefix}_decrypt_block libaesni) - set_target_properties(test_${prefix}_decrypt_block PROPERTIES OUTPUT_NAME ${prefix}_decrypt_block) -endmacro() - -test(aes128ecb) -test(aes128cbc) -test(aes128cfb) -test(aes128ofb) -test(aes128ctr) -test(aes192ecb) -test(aes192cbc) -test(aes192cfb) -test(aes192ofb) -test(aes192ctr) -test(aes256ecb) -test(aes256cbc) -test(aes256cfb) -test(aes256ofb) -test(aes256ctr) - -find_package(Boost REQUIRED COMPONENTS program_options) - -add_executable(test_aes_encrypt_block aes_encrypt_block.cpp aes_common.hpp) -target_include_directories(test_aes_encrypt_block PRIVATE ${Boost_INCLUDE_DIRS}) -target_link_libraries(test_aes_encrypt_block libaesni libaesnixx ${Boost_LIBRARIES}) -set_target_properties(test_aes_encrypt_block PROPERTIES OUTPUT_NAME aes_encrypt_block) - -add_executable(test_aes_decrypt_block aes_decrypt_block.cpp aes_common.hpp) -target_include_directories(test_aes_decrypt_block PRIVATE ${Boost_INCLUDE_DIRS}) -target_link_libraries(test_aes_decrypt_block libaesni libaesnixx ${Boost_LIBRARIES}) -set_target_properties(test_aes_decrypt_block PROPERTIES OUTPUT_NAME aes_decrypt_block) diff --git a/test/README.md b/test/README.md index e05b840..7b3b128 100644 --- a/test/README.md +++ b/test/README.md @@ -41,11 +41,11 @@ Use `--help` to see the script's usage details. To test the implementation against the vectors from [NIST SP 800-38A](http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf) using `nist-sp-800-32a.py`. - python nist-sp-800-38a.py -p C:\build\test\Debug + python nist-sp-800-38a.py -p C:\build\utils\block\cxx\Debug ### Cryptographic Algorithm Validation Program To test the implementation against the vectors from [CAVP](http://csrc.nist.gov/groups/STM/cavp/) using `cavp.py`. The AES Known Answer Test (KAT) Vectors are used and read from `KAT_AES.zip`. - python cavp.py -p C:\build\test\Debug + python cavp.py -p C:\build\utils\block\cxx\Debug diff --git a/test/aes128cbc_decrypt_block.c b/test/aes128cbc_decrypt_block.c deleted file mode 100644 index 95120e7..0000000 --- a/test/aes128cbc_decrypt_block.c +++ /dev/null @@ -1,76 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes128cbc_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes128_Key key; - AesNI_Aes128_RoundKeys encryption_keys, decryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes128_expand_key(&key, &encryption_keys); - aesni_aes128_derive_decryption_keys(&encryption_keys, &decryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes128_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes128cbc_encrypt_block.c b/test/aes128cbc_encrypt_block.c deleted file mode 100644 index 68f95a3..0000000 --- a/test/aes128cbc_encrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes128cbc_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes128_Key key; - AesNI_Aes128_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes128_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes128_encrypt_block_cbc(plaintext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes128cfb_decrypt_block.c b/test/aes128cfb_decrypt_block.c deleted file mode 100644 index ef68e44..0000000 --- a/test/aes128cfb_decrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes128cfb_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes128_Key key; - AesNI_Aes128_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes128_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes128_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes128cfb_encrypt_block.c b/test/aes128cfb_encrypt_block.c deleted file mode 100644 index 6f8fb4d..0000000 --- a/test/aes128cfb_encrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes128cfb_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes128_Key key; - AesNI_Aes128_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes128_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes128_encrypt_block_cfb(plaintext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes128ctr_decrypt_block.c b/test/aes128ctr_decrypt_block.c deleted file mode 100644 index 85d07f5..0000000 --- a/test/aes128ctr_decrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes128ctr_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes128_Key key; - AesNI_Aes128_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes128_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes128_decrypt_block_ctr(ciphertext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes128ctr_encrypt_block.c b/test/aes128ctr_encrypt_block.c deleted file mode 100644 index a62f3cd..0000000 --- a/test/aes128ctr_encrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes128ctr_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes128_Key key; - AesNI_Aes128_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes128_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes128_encrypt_block_ctr(plaintext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes128ecb_decrypt_block.c b/test/aes128ecb_decrypt_block.c deleted file mode 100644 index 9fbf26d..0000000 --- a/test/aes128ecb_decrypt_block.c +++ /dev/null @@ -1,70 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes128ecb_decrypt_block.exe KEY0 [CIPHERTEXT0...] [-- KEY1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext; - AesNI_Aes128_Key key; - AesNI_Aes128_RoundKeys encryption_keys, decryption_keys; - - if (argc < 1) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes128_expand_key(&key, &encryption_keys); - aesni_aes128_derive_decryption_keys(&encryption_keys, &decryption_keys); - - for (--argc, ++argv; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes128_decrypt_block_ecb(ciphertext, &decryption_keys); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes128ecb_encrypt_block.c b/test/aes128ecb_encrypt_block.c deleted file mode 100644 index 45a1123..0000000 --- a/test/aes128ecb_encrypt_block.c +++ /dev/null @@ -1,69 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes128ecb_encrypt_block.exe KEY0 [PLAINTEXT0...] [-- KEY1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext; - AesNI_Aes128_Key key; - AesNI_Aes128_RoundKeys encryption_keys; - - if (argc < 1) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes128_expand_key(&key, &encryption_keys); - - for (--argc, ++argv; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, &encryption_keys); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes128ofb_decrypt_block.c b/test/aes128ofb_decrypt_block.c deleted file mode 100644 index e61e70f..0000000 --- a/test/aes128ofb_decrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes128ofb_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes128_Key key; - AesNI_Aes128_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes128_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes128_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes128ofb_encrypt_block.c b/test/aes128ofb_encrypt_block.c deleted file mode 100644 index 6613ca9..0000000 --- a/test/aes128ofb_encrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes128ofb_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes128_Key key; - AesNI_Aes128_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes128_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes128_encrypt_block_ofb(plaintext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes192cbc_decrypt_block.c b/test/aes192cbc_decrypt_block.c deleted file mode 100644 index 13edbe4..0000000 --- a/test/aes192cbc_decrypt_block.c +++ /dev/null @@ -1,76 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes192cbc_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes192_Key key; - AesNI_Aes192_RoundKeys encryption_keys, decryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes192_expand_key(&key, &encryption_keys); - aesni_aes192_derive_decryption_keys(&encryption_keys, &decryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes192_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes192cbc_encrypt_block.c b/test/aes192cbc_encrypt_block.c deleted file mode 100644 index d89c12d..0000000 --- a/test/aes192cbc_encrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes192cbc_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes192_Key key; - AesNI_Aes192_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes192_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes192_encrypt_block_cbc(plaintext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes192cfb_decrypt_block.c b/test/aes192cfb_decrypt_block.c deleted file mode 100644 index cedc7d0..0000000 --- a/test/aes192cfb_decrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes192cfb_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes192_Key key; - AesNI_Aes192_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes192_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes192_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes192cfb_encrypt_block.c b/test/aes192cfb_encrypt_block.c deleted file mode 100644 index 357df8d..0000000 --- a/test/aes192cfb_encrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes192cfb_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes192_Key key; - AesNI_Aes192_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes192_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes192_encrypt_block_cfb(plaintext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes192ctr_decrypt_block.c b/test/aes192ctr_decrypt_block.c deleted file mode 100644 index b094964..0000000 --- a/test/aes192ctr_decrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes192ctr_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes192_Key key; - AesNI_Aes192_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes192_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes192_decrypt_block_ctr(ciphertext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes192ctr_encrypt_block.c b/test/aes192ctr_encrypt_block.c deleted file mode 100644 index 977c7bf..0000000 --- a/test/aes192ctr_encrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes192ctr_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes192_Key key; - AesNI_Aes192_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes192_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes192_encrypt_block_ctr(plaintext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes192ecb_decrypt_block.c b/test/aes192ecb_decrypt_block.c deleted file mode 100644 index 29e7274..0000000 --- a/test/aes192ecb_decrypt_block.c +++ /dev/null @@ -1,70 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes192ecb_decrypt_block.exe KEY0 [CIPHERTEXT0...] [-- KEY1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext; - AesNI_Aes192_Key key; - AesNI_Aes192_RoundKeys encryption_keys, decryption_keys; - - if (argc < 1) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes192_expand_key(&key, &encryption_keys); - aesni_aes192_derive_decryption_keys(&encryption_keys, &decryption_keys); - - for (--argc, ++argv; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes192_decrypt_block_ecb(ciphertext, &decryption_keys); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes192ecb_encrypt_block.c b/test/aes192ecb_encrypt_block.c deleted file mode 100644 index a74759c..0000000 --- a/test/aes192ecb_encrypt_block.c +++ /dev/null @@ -1,69 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes192ecb_encrypt_block.exe KEY0 [PLAINTEXT0...] [-- KEY1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext; - AesNI_Aes192_Key key; - AesNI_Aes192_RoundKeys encryption_keys; - - if (argc < 1) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes192_expand_key(&key, &encryption_keys); - - for (--argc, ++argv; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes192_encrypt_block_ecb(plaintext, &encryption_keys); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes192ofb_decrypt_block.c b/test/aes192ofb_decrypt_block.c deleted file mode 100644 index eaa9d2a..0000000 --- a/test/aes192ofb_decrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes192ofb_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes192_Key key; - AesNI_Aes192_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes192_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes192_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes192ofb_encrypt_block.c b/test/aes192ofb_encrypt_block.c deleted file mode 100644 index fed0c5a..0000000 --- a/test/aes192ofb_encrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes192ofb_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes192_Key key; - AesNI_Aes192_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes192_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes192_encrypt_block_ofb(plaintext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes256cbc_decrypt_block.c b/test/aes256cbc_decrypt_block.c deleted file mode 100644 index 0021007..0000000 --- a/test/aes256cbc_decrypt_block.c +++ /dev/null @@ -1,76 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes256cbc_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes256_Key key; - AesNI_Aes256_RoundKeys encryption_keys, decryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes256_expand_key(&key, &encryption_keys); - aesni_aes256_derive_decryption_keys(&encryption_keys, &decryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes256_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes256cbc_encrypt_block.c b/test/aes256cbc_encrypt_block.c deleted file mode 100644 index e01ab95..0000000 --- a/test/aes256cbc_encrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes256cbc_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes256_Key key; - AesNI_Aes256_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes256_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes256_encrypt_block_cbc(plaintext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes256cfb_decrypt_block.c b/test/aes256cfb_decrypt_block.c deleted file mode 100644 index 9d320a5..0000000 --- a/test/aes256cfb_decrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes256cfb_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes256_Key key; - AesNI_Aes256_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes256_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes256_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes256cfb_encrypt_block.c b/test/aes256cfb_encrypt_block.c deleted file mode 100644 index 94e8619..0000000 --- a/test/aes256cfb_encrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes256cfb_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes256_Key key; - AesNI_Aes256_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes256_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes256_encrypt_block_cfb(plaintext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes256ctr_decrypt_block.c b/test/aes256ctr_decrypt_block.c deleted file mode 100644 index a0f9ef0..0000000 --- a/test/aes256ctr_decrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes256ctr_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes256_Key key; - AesNI_Aes256_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes256_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes256_decrypt_block_ctr(ciphertext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes256ctr_encrypt_block.c b/test/aes256ctr_encrypt_block.c deleted file mode 100644 index fbae884..0000000 --- a/test/aes256ctr_encrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes256ctr_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes256_Key key; - AesNI_Aes256_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes256_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes256_encrypt_block_ctr(plaintext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes256ecb_decrypt_block.c b/test/aes256ecb_decrypt_block.c deleted file mode 100644 index 16ffe77..0000000 --- a/test/aes256ecb_decrypt_block.c +++ /dev/null @@ -1,70 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes256ecb_decrypt_block.exe KEY0 [CIPHERTEXT0...] [-- KEY1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext; - AesNI_Aes256_Key key; - AesNI_Aes256_RoundKeys encryption_keys, decryption_keys; - - if (argc < 1) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes256_expand_key(&key, &encryption_keys); - aesni_aes256_derive_decryption_keys(&encryption_keys, &decryption_keys); - - for (--argc, ++argv; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes256_decrypt_block_ecb(ciphertext, &decryption_keys); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes256ecb_encrypt_block.c b/test/aes256ecb_encrypt_block.c deleted file mode 100644 index 01ae7ed..0000000 --- a/test/aes256ecb_encrypt_block.c +++ /dev/null @@ -1,69 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes256ecb_encrypt_block.exe KEY0 [PLAINTEXT0...] [-- KEY1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext; - AesNI_Aes256_Key key; - AesNI_Aes256_RoundKeys encryption_keys; - - if (argc < 1) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes256_expand_key(&key, &encryption_keys); - - for (--argc, ++argv; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes256_encrypt_block_ecb(plaintext, &encryption_keys); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes256ofb_decrypt_block.c b/test/aes256ofb_decrypt_block.c deleted file mode 100644 index a57c8db..0000000 --- a/test/aes256ofb_decrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes256ofb_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes256_Key key; - AesNI_Aes256_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes256_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL))) - { - print_error(status); - continue; - } - - plaintext = aesni_aes256_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes256ofb_encrypt_block.c b/test/aes256ofb_encrypt_block.c deleted file mode 100644 index 7dc01b8..0000000 --- a/test/aes256ofb_encrypt_block.c +++ /dev/null @@ -1,75 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include - -#include -#include -#include - -static void exit_with_usage() -{ - puts("Usage: aes256ofb_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]"); - exit(EXIT_FAILURE); -} - -static void print_error(AesNI_StatusCode status) -{ - fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status)); -} - -int main(int argc, char** argv) -{ - AesNI_StatusCode status = AESNI_SUCCESS; - - for (--argc, ++argv; argc > -1; --argc, ++argv) - { - AesNI_Block128 plaintext, ciphertext, iv; - AesNI_Aes256_Key key; - AesNI_Aes256_RoundKeys encryption_keys; - - if (argc < 2) - exit_with_usage(); - - if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL))) - { - print_error(status); - exit_with_usage(); - } - - if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL))) - { - print_error(status); - exit_with_usage(); - } - - aesni_aes256_expand_key(&key, &encryption_keys); - - for (argc -= 2, argv += 2; argc > 0; --argc, ++argv) - { - if (strcmp("--", *argv) == 0) - break; - - if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL))) - { - print_error(status); - continue; - } - - ciphertext = aesni_aes256_encrypt_block_ofb(plaintext, &encryption_keys, iv, &iv); - - if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL))) - { - print_error(status); - continue; - } - } - } - - return 0; -} diff --git a/test/aes_common.hpp b/test/aes_common.hpp deleted file mode 100644 index 78126e5..0000000 --- a/test/aes_common.hpp +++ /dev/null @@ -1,134 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#pragma once - -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -static std::istream& operator>>(std::istream& is, AesNI_Mode& dest) -{ - std::string src; - is >> src; - - if (boost::iequals(src, "ecb")) - dest = AESNI_ECB; - else if (boost::iequals(src, "cbc")) - dest = AESNI_CBC; - else if (boost::iequals(src, "cfb")) - dest = AESNI_CFB; - else if (boost::iequals(src, "ofb")) - dest = AESNI_OFB; - else if (boost::iequals(src, "ctr")) - dest = AESNI_CTR; - else - throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value, "mode", src); - - return is; -} - -static std::istream& operator>>(std::istream& is, AesNI_Algorithm& dest) -{ - std::string src; - is >> src; - - if (boost::iequals(src, "aes128")) - dest = AESNI_AES128; - else if (boost::iequals(src, "aes192")) - dest = AESNI_AES192; - else if (boost::iequals(src, "aes256")) - dest = AESNI_AES256; - else - throw boost::program_options::validation_error(boost::program_options::validation_error::invalid_option_value, "algorithm", src); - - return is; -} - -namespace -{ - class CommandLineParser - { - public: - CommandLineParser(const std::string& program_name) - : m_program_name(program_name) - , m_options("Options") - { } - - bool parse_options(int argc, char** argv) - { - namespace po = boost::program_options; - - m_options.add_options() - ("help,h", "show this message and exit") - ("mode,m", po::value(&m_mode)->required(), "set mode of operation") - ("algorithm,a", po::value(&m_algorithm)->required(), "set algorithm"); - - po::options_description hidden_options; - hidden_options.add_options() - ("positional", po::value>(&m_args)); - - po::options_description all_options; - all_options.add(m_options).add(hidden_options); - - po::positional_options_description positional_options; - positional_options.add("positional", -1); - - po::variables_map vm; - po::store(po::command_line_parser(argc, argv).options(all_options).positional(positional_options).run(), vm); - - if (vm.count("help")) - { - print_usage(); - return false; - } - - po::notify(vm); - return true; - } - - void print_usage() - { - std::cout << "Usage: " << m_program_name << " [OPTIONS...] [-- KEY [IV] [PLAINTEXT...]...]\n"; - std::cout << m_options << "\n"; - } - - AesNI_Mode get_mode() const - { - return m_mode; - } - - AesNI_Algorithm get_algorithm() const - { - return m_algorithm; - } - - std::deque get_args() - { - return { std::make_move_iterator(m_args.begin()), std::make_move_iterator(m_args.end()) }; - } - - private: - const std::string m_program_name; - boost::program_options::options_description m_options; - - AesNI_Mode m_mode; - AesNI_Algorithm m_algorithm; - std::vector m_args; - }; -} diff --git a/test/aes_decrypt_block.cpp b/test/aes_decrypt_block.cpp deleted file mode 100644 index 9898d4e..0000000 --- a/test/aes_decrypt_block.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include "aes_common.hpp" - -#include - -#include - -#include -#include - -int main(int argc, char** argv) -{ - try - { - CommandLineParser cmd_parser("encrypt_block_aes.exe"); - - if (!cmd_parser.parse_options(argc, argv)) - return 0; - - auto args = cmd_parser.get_args(); - - while (!args.empty()) - { - AesNI_BoxAlgorithmParams algorithm_params; - - switch (cmd_parser.get_algorithm()) - { - case AESNI_AES128: - aesni::aes::from_string(algorithm_params.aes128_key, args.front()); - break; - - case AESNI_AES192: - aesni::aes::from_string(algorithm_params.aes192_key, args.front()); - break; - - case AESNI_AES256: - aesni::aes::from_string(algorithm_params.aes256_key, args.front()); - break; - } - - args.pop_front(); - - AesNI_BoxBlock iv; - AesNI_BoxBlock* iv_ptr = nullptr; - - switch (cmd_parser.get_mode()) - { - case AESNI_ECB: - break; - - case AESNI_CBC: - case AESNI_CFB: - case AESNI_OFB: - case AESNI_CTR: - if (args.empty()) - { - cmd_parser.print_usage(); - return 1; - } - aesni::aes::from_string(iv.aes_block, args.front()); - iv_ptr = &iv; - args.pop_front(); - break; - } - - AesNI_Box box; - aesni_box_init( - &box, - cmd_parser.get_algorithm(), - &algorithm_params, - cmd_parser.get_mode(), - iv_ptr, - aesni::ErrorDetailsThrowsInDestructor()); - - while (!args.empty()) - { - if (args.front() == "--") - { - args.pop_front(); - break; - } - - AesNI_BoxBlock ciphertext; - aesni::aes::from_string(ciphertext.aes_block, args.front()); - args.pop_front(); - - AesNI_BoxBlock plaintext; - aesni_box_decrypt_block( - &box, - &ciphertext, - &plaintext, - aesni::ErrorDetailsThrowsInDestructor()); - - std::cout << aesni::aes::to_string(plaintext.aes_block) << "\n"; - } - } - - return 0; - } - catch (const boost::program_options::error& e) - { - std::cerr << "Usage error: " << e.what() << "\n"; - return 1; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/test/aes_encrypt_block.cpp b/test/aes_encrypt_block.cpp deleted file mode 100644 index 9458831..0000000 --- a/test/aes_encrypt_block.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/** - * \file - * \author Egor Tensin - * \date 2015 - * \copyright This file is licensed under the terms of the MIT License. - * See LICENSE.txt for details. - */ - -#include "aes_common.hpp" - -#include - -#include - -#include -#include - -int main(int argc, char** argv) -{ - try - { - CommandLineParser cmd_parser("encrypt_block_aes.exe"); - - if (!cmd_parser.parse_options(argc, argv)) - return 0; - - auto args = cmd_parser.get_args(); - - while (!args.empty()) - { - AesNI_BoxAlgorithmParams algorithm_params; - - switch (cmd_parser.get_algorithm()) - { - case AESNI_AES128: - aesni::aes::from_string(algorithm_params.aes128_key, args.front()); - break; - - case AESNI_AES192: - aesni::aes::from_string(algorithm_params.aes192_key, args.front()); - break; - - case AESNI_AES256: - aesni::aes::from_string(algorithm_params.aes256_key, args.front()); - break; - } - - args.pop_front(); - - AesNI_BoxBlock iv; - AesNI_BoxBlock* iv_ptr = nullptr; - - switch (cmd_parser.get_mode()) - { - case AESNI_ECB: - break; - - case AESNI_CBC: - case AESNI_CFB: - case AESNI_OFB: - case AESNI_CTR: - if (args.empty()) - { - cmd_parser.print_usage(); - return 1; - } - aesni::aes::from_string(iv.aes_block, args.front()); - iv_ptr = &iv; - args.pop_front(); - break; - } - - AesNI_Box box; - aesni_box_init( - &box, - cmd_parser.get_algorithm(), - &algorithm_params, - cmd_parser.get_mode(), - iv_ptr, - aesni::ErrorDetailsThrowsInDestructor()); - - while (!args.empty()) - { - if (args.front() == "--") - { - args.pop_front(); - break; - } - - AesNI_BoxBlock plaintext; - aesni::aes::from_string(plaintext.aes_block, args.front()); - args.pop_front(); - - AesNI_BoxBlock ciphertext; - aesni_box_encrypt_block( - &box, - &plaintext, - &ciphertext, - aesni::ErrorDetailsThrowsInDestructor()); - - std::cout << aesni::aes::to_string(ciphertext.aes_block) << "\n"; - } - } - - return 0; - } - catch (const boost::program_options::error& e) - { - std::cerr << "Usage error: " << e.what() << "\n"; - return 1; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} -- cgit v1.2.3