From 09c2543e905ddd2915e628b0e2c0c7e9c596f2bb Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 4 Jun 2015 06:14:35 +0300 Subject: remove redundant file suffixes --- test/CMakeLists.txt | 10 +++++--- test/aes128cbc_decrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes128cbc_decrypt_block.c | 55 ----------------------------------------- test/aes128cbc_encrypt.c | 54 ++++++++++++++++++++++++++++++++++++++++ test/aes128cbc_encrypt_block.c | 54 ---------------------------------------- test/aes128cfb_decrypt.c | 54 ++++++++++++++++++++++++++++++++++++++++ test/aes128cfb_decrypt_block.c | 54 ---------------------------------------- test/aes128cfb_encrypt.c | 54 ++++++++++++++++++++++++++++++++++++++++ test/aes128cfb_encrypt_block.c | 54 ---------------------------------------- test/aes128ctr_decrypt.c | 54 ++++++++++++++++++++++++++++++++++++++++ test/aes128ctr_decrypt_block.c | 54 ---------------------------------------- test/aes128ctr_encrypt.c | 54 ++++++++++++++++++++++++++++++++++++++++ test/aes128ctr_encrypt_block.c | 54 ---------------------------------------- test/aes128ecb_decrypt.c | 49 ++++++++++++++++++++++++++++++++++++ test/aes128ecb_decrypt_block.c | 49 ------------------------------------ test/aes128ecb_encrypt.c | 48 ++++++++++++++++++++++++++++++++++++ test/aes128ecb_encrypt_block.c | 48 ------------------------------------ test/aes128ofb_decrypt.c | 54 ++++++++++++++++++++++++++++++++++++++++ test/aes128ofb_decrypt_block.c | 54 ---------------------------------------- test/aes128ofb_encrypt.c | 54 ++++++++++++++++++++++++++++++++++++++++ test/aes128ofb_encrypt_block.c | 54 ---------------------------------------- test/aes192cbc_decrypt.c | 56 ++++++++++++++++++++++++++++++++++++++++++ test/aes192cbc_decrypt_block.c | 56 ------------------------------------------ test/aes192cbc_encrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes192cbc_encrypt_block.c | 55 ----------------------------------------- test/aes192cfb_decrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes192cfb_decrypt_block.c | 55 ----------------------------------------- test/aes192cfb_encrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes192cfb_encrypt_block.c | 55 ----------------------------------------- test/aes192ctr_decrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes192ctr_decrypt_block.c | 55 ----------------------------------------- test/aes192ctr_encrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes192ctr_encrypt_block.c | 55 ----------------------------------------- test/aes192ecb_decrypt.c | 50 +++++++++++++++++++++++++++++++++++++ test/aes192ecb_decrypt_block.c | 50 ------------------------------------- test/aes192ecb_encrypt.c | 49 ++++++++++++++++++++++++++++++++++++ test/aes192ecb_encrypt_block.c | 49 ------------------------------------ test/aes192ofb_decrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes192ofb_decrypt_block.c | 55 ----------------------------------------- test/aes192ofb_encrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes192ofb_encrypt_block.c | 55 ----------------------------------------- test/aes256cbc_decrypt.c | 56 ++++++++++++++++++++++++++++++++++++++++++ test/aes256cbc_decrypt_block.c | 56 ------------------------------------------ test/aes256cbc_encrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes256cbc_encrypt_block.c | 55 ----------------------------------------- test/aes256cfb_decrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes256cfb_decrypt_block.c | 55 ----------------------------------------- test/aes256cfb_encrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes256cfb_encrypt_block.c | 55 ----------------------------------------- test/aes256ctr_decrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes256ctr_decrypt_block.c | 55 ----------------------------------------- test/aes256ctr_encrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes256ctr_encrypt_block.c | 55 ----------------------------------------- test/aes256ecb_decrypt.c | 50 +++++++++++++++++++++++++++++++++++++ test/aes256ecb_decrypt_block.c | 50 ------------------------------------- test/aes256ecb_encrypt.c | 49 ++++++++++++++++++++++++++++++++++++ test/aes256ecb_encrypt_block.c | 49 ------------------------------------ test/aes256ofb_decrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes256ofb_decrypt_block.c | 55 ----------------------------------------- test/aes256ofb_encrypt.c | 55 +++++++++++++++++++++++++++++++++++++++++ test/aes256ofb_encrypt_block.c | 55 ----------------------------------------- 61 files changed, 1616 insertions(+), 1614 deletions(-) create mode 100644 test/aes128cbc_decrypt.c delete mode 100644 test/aes128cbc_decrypt_block.c create mode 100644 test/aes128cbc_encrypt.c delete mode 100644 test/aes128cbc_encrypt_block.c create mode 100644 test/aes128cfb_decrypt.c delete mode 100644 test/aes128cfb_decrypt_block.c create mode 100644 test/aes128cfb_encrypt.c delete mode 100644 test/aes128cfb_encrypt_block.c create mode 100644 test/aes128ctr_decrypt.c delete mode 100644 test/aes128ctr_decrypt_block.c create mode 100644 test/aes128ctr_encrypt.c delete mode 100644 test/aes128ctr_encrypt_block.c create mode 100644 test/aes128ecb_decrypt.c delete mode 100644 test/aes128ecb_decrypt_block.c create mode 100644 test/aes128ecb_encrypt.c delete mode 100644 test/aes128ecb_encrypt_block.c create mode 100644 test/aes128ofb_decrypt.c delete mode 100644 test/aes128ofb_decrypt_block.c create mode 100644 test/aes128ofb_encrypt.c delete mode 100644 test/aes128ofb_encrypt_block.c create mode 100644 test/aes192cbc_decrypt.c delete mode 100644 test/aes192cbc_decrypt_block.c create mode 100644 test/aes192cbc_encrypt.c delete mode 100644 test/aes192cbc_encrypt_block.c create mode 100644 test/aes192cfb_decrypt.c delete mode 100644 test/aes192cfb_decrypt_block.c create mode 100644 test/aes192cfb_encrypt.c delete mode 100644 test/aes192cfb_encrypt_block.c create mode 100644 test/aes192ctr_decrypt.c delete mode 100644 test/aes192ctr_decrypt_block.c create mode 100644 test/aes192ctr_encrypt.c delete mode 100644 test/aes192ctr_encrypt_block.c create mode 100644 test/aes192ecb_decrypt.c delete mode 100644 test/aes192ecb_decrypt_block.c create mode 100644 test/aes192ecb_encrypt.c delete mode 100644 test/aes192ecb_encrypt_block.c create mode 100644 test/aes192ofb_decrypt.c delete mode 100644 test/aes192ofb_decrypt_block.c create mode 100644 test/aes192ofb_encrypt.c delete mode 100644 test/aes192ofb_encrypt_block.c create mode 100644 test/aes256cbc_decrypt.c delete mode 100644 test/aes256cbc_decrypt_block.c create mode 100644 test/aes256cbc_encrypt.c delete mode 100644 test/aes256cbc_encrypt_block.c create mode 100644 test/aes256cfb_decrypt.c delete mode 100644 test/aes256cfb_decrypt_block.c create mode 100644 test/aes256cfb_encrypt.c delete mode 100644 test/aes256cfb_encrypt_block.c create mode 100644 test/aes256ctr_decrypt.c delete mode 100644 test/aes256ctr_decrypt_block.c create mode 100644 test/aes256ctr_encrypt.c delete mode 100644 test/aes256ctr_encrypt_block.c create mode 100644 test/aes256ecb_decrypt.c delete mode 100644 test/aes256ecb_decrypt_block.c create mode 100644 test/aes256ecb_encrypt.c delete mode 100644 test/aes256ecb_encrypt_block.c create mode 100644 test/aes256ofb_decrypt.c delete mode 100644 test/aes256ofb_decrypt_block.c create mode 100644 test/aes256ofb_encrypt.c delete mode 100644 test/aes256ofb_encrypt_block.c (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f4460f0..a024d40 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,11 +1,13 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") macro(test prefix) - add_executable(${prefix}_encrypt_block ${prefix}_encrypt_block.c) - target_link_libraries(${prefix}_encrypt_block libaesni) + add_executable(test_${prefix}_encrypt ${prefix}_encrypt.c) + target_link_libraries(test_${prefix}_encrypt libaesni) + set_target_properties(test_${prefix}_encrypt PROPERTIES OUTPUT_NAME ${prefix}_encrypt) - add_executable(${prefix}_decrypt_block ${prefix}_decrypt_block.c) - target_link_libraries(${prefix}_decrypt_block libaesni) + add_executable(test_${prefix}_decrypt ${prefix}_decrypt.c) + target_link_libraries(test_${prefix}_decrypt libaesni) + set_target_properties(test_${prefix}_decrypt PROPERTIES OUTPUT_NAME ${prefix}_decrypt) endmacro() test(aes128ecb) diff --git a/test/aes128cbc_decrypt.c b/test/aes128cbc_decrypt.c new file mode 100644 index 0000000..791110a --- /dev/null +++ b/test/aes128cbc_decrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, iv; + __declspec(align(16)) Aes128KeySchedule key_schedule, inverted_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block128(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes128_expand_key_schedule(key, &key_schedule); + aes128_invert_key_schedule(&key_schedule, &inverted_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes128cbc_decrypt(cipher, &inverted_schedule, iv, &iv); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes128cbc_decrypt_block.c b/test/aes128cbc_decrypt_block.c deleted file mode 100644 index 791110a..0000000 --- a/test/aes128cbc_decrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, iv; - __declspec(align(16)) Aes128KeySchedule key_schedule, inverted_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block128(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes128_expand_key_schedule(key, &key_schedule); - aes128_invert_key_schedule(&key_schedule, &inverted_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes128cbc_decrypt(cipher, &inverted_schedule, iv, &iv); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes128cbc_encrypt.c b/test/aes128cbc_encrypt.c new file mode 100644 index 0000000..a4a1675 --- /dev/null +++ b/test/aes128cbc_encrypt.c @@ -0,0 +1,54 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, iv; + __declspec(align(16)) Aes128KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block128(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes128_expand_key_schedule(key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes128cbc_encrypt(plain, &key_schedule, iv, &iv); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes128cbc_encrypt_block.c b/test/aes128cbc_encrypt_block.c deleted file mode 100644 index a4a1675..0000000 --- a/test/aes128cbc_encrypt_block.c +++ /dev/null @@ -1,54 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, iv; - __declspec(align(16)) Aes128KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block128(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes128_expand_key_schedule(key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes128cbc_encrypt(plain, &key_schedule, iv, &iv); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes128cfb_decrypt.c b/test/aes128cfb_decrypt.c new file mode 100644 index 0000000..bfc7ea7 --- /dev/null +++ b/test/aes128cfb_decrypt.c @@ -0,0 +1,54 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, iv; + __declspec(align(16)) Aes128KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block128(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes128_expand_key_schedule(key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes128cfb_decrypt(cipher, &key_schedule, iv, &iv); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes128cfb_decrypt_block.c b/test/aes128cfb_decrypt_block.c deleted file mode 100644 index bfc7ea7..0000000 --- a/test/aes128cfb_decrypt_block.c +++ /dev/null @@ -1,54 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, iv; - __declspec(align(16)) Aes128KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block128(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes128_expand_key_schedule(key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes128cfb_decrypt(cipher, &key_schedule, iv, &iv); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes128cfb_encrypt.c b/test/aes128cfb_encrypt.c new file mode 100644 index 0000000..b4e2885 --- /dev/null +++ b/test/aes128cfb_encrypt.c @@ -0,0 +1,54 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, iv; + __declspec(align(16)) Aes128KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block128(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes128_expand_key_schedule(key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes128cfb_encrypt(plain, &key_schedule, iv, &iv); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes128cfb_encrypt_block.c b/test/aes128cfb_encrypt_block.c deleted file mode 100644 index b4e2885..0000000 --- a/test/aes128cfb_encrypt_block.c +++ /dev/null @@ -1,54 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, iv; - __declspec(align(16)) Aes128KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block128(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes128_expand_key_schedule(key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes128cfb_encrypt(plain, &key_schedule, iv, &iv); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes128ctr_decrypt.c b/test/aes128ctr_decrypt.c new file mode 100644 index 0000000..313e5d9 --- /dev/null +++ b/test/aes128ctr_decrypt.c @@ -0,0 +1,54 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, iv; + __declspec(align(16)) Aes128KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block128(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes128_expand_key_schedule(key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes128ctr_decrypt(cipher, &key_schedule, iv, i - 3); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes128ctr_decrypt_block.c b/test/aes128ctr_decrypt_block.c deleted file mode 100644 index 313e5d9..0000000 --- a/test/aes128ctr_decrypt_block.c +++ /dev/null @@ -1,54 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, iv; - __declspec(align(16)) Aes128KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block128(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes128_expand_key_schedule(key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes128ctr_decrypt(cipher, &key_schedule, iv, i - 3); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes128ctr_encrypt.c b/test/aes128ctr_encrypt.c new file mode 100644 index 0000000..e5372c2 --- /dev/null +++ b/test/aes128ctr_encrypt.c @@ -0,0 +1,54 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, iv; + __declspec(align(16)) Aes128KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block128(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes128_expand_key_schedule(key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes128ctr_encrypt(plain, &key_schedule, iv, i - 3); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes128ctr_encrypt_block.c b/test/aes128ctr_encrypt_block.c deleted file mode 100644 index e5372c2..0000000 --- a/test/aes128ctr_encrypt_block.c +++ /dev/null @@ -1,54 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, iv; - __declspec(align(16)) Aes128KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block128(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes128_expand_key_schedule(key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes128ctr_encrypt(plain, &key_schedule, iv, i - 3); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes128ecb_decrypt.c b/test/aes128ecb_decrypt.c new file mode 100644 index 0000000..70c7285 --- /dev/null +++ b/test/aes128ecb_decrypt.c @@ -0,0 +1,49 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, key, cipher; + __declspec(align(16)) Aes128KeySchedule key_schedule, inverted_schedule; + + if (argc < 2) + exit_with_usage(argv[0]); + + if (parse_aes_block128(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + aes128_expand_key_schedule(key, &key_schedule); + aes128_invert_key_schedule(&key_schedule, &inverted_schedule); + + for (int i = 2; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes128ecb_decrypt(cipher, &inverted_schedule); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes128ecb_decrypt_block.c b/test/aes128ecb_decrypt_block.c deleted file mode 100644 index 70c7285..0000000 --- a/test/aes128ecb_decrypt_block.c +++ /dev/null @@ -1,49 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, key, cipher; - __declspec(align(16)) Aes128KeySchedule key_schedule, inverted_schedule; - - if (argc < 2) - exit_with_usage(argv[0]); - - if (parse_aes_block128(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - aes128_expand_key_schedule(key, &key_schedule); - aes128_invert_key_schedule(&key_schedule, &inverted_schedule); - - for (int i = 2; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes128ecb_decrypt(cipher, &inverted_schedule); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes128ecb_encrypt.c b/test/aes128ecb_encrypt.c new file mode 100644 index 0000000..8f0bf0a --- /dev/null +++ b/test/aes128ecb_encrypt.c @@ -0,0 +1,48 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, key, cipher; + __declspec(align(16)) Aes128KeySchedule key_schedule; + + if (argc < 2) + exit_with_usage(argv[0]); + + if (parse_aes_block128(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + aes128_expand_key_schedule(key, &key_schedule); + + for (int i = 2; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes128ecb_encrypt(plain, &key_schedule); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes128ecb_encrypt_block.c b/test/aes128ecb_encrypt_block.c deleted file mode 100644 index 8f0bf0a..0000000 --- a/test/aes128ecb_encrypt_block.c +++ /dev/null @@ -1,48 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, key, cipher; - __declspec(align(16)) Aes128KeySchedule key_schedule; - - if (argc < 2) - exit_with_usage(argv[0]); - - if (parse_aes_block128(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - aes128_expand_key_schedule(key, &key_schedule); - - for (int i = 2; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes128ecb_encrypt(plain, &key_schedule); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes128ofb_decrypt.c b/test/aes128ofb_decrypt.c new file mode 100644 index 0000000..74fb314 --- /dev/null +++ b/test/aes128ofb_decrypt.c @@ -0,0 +1,54 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, iv; + __declspec(align(16)) Aes128KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block128(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes128_expand_key_schedule(key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes128ofb_decrypt(cipher, &key_schedule, iv, &iv); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes128ofb_decrypt_block.c b/test/aes128ofb_decrypt_block.c deleted file mode 100644 index 74fb314..0000000 --- a/test/aes128ofb_decrypt_block.c +++ /dev/null @@ -1,54 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, iv; - __declspec(align(16)) Aes128KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block128(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes128_expand_key_schedule(key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes128ofb_decrypt(cipher, &key_schedule, iv, &iv); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes128ofb_encrypt.c b/test/aes128ofb_encrypt.c new file mode 100644 index 0000000..df30777 --- /dev/null +++ b/test/aes128ofb_encrypt.c @@ -0,0 +1,54 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, iv; + __declspec(align(16)) Aes128KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block128(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes128_expand_key_schedule(key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes128ofb_encrypt(plain, &key_schedule, iv, &iv); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes128ofb_encrypt_block.c b/test/aes128ofb_encrypt_block.c deleted file mode 100644 index df30777..0000000 --- a/test/aes128ofb_encrypt_block.c +++ /dev/null @@ -1,54 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, iv; - __declspec(align(16)) Aes128KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block128(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes128_expand_key_schedule(key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes128ofb_encrypt(plain, &key_schedule, iv, &iv); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes192cbc_decrypt.c b/test/aes192cbc_decrypt.c new file mode 100644 index 0000000..6a953ad --- /dev/null +++ b/test/aes192cbc_decrypt.c @@ -0,0 +1,56 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule, inverted_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block192(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes192_expand_key_schedule(&key, &key_schedule); + aes192_invert_key_schedule(&key_schedule, &inverted_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes192cbc_decrypt(cipher, &inverted_schedule, iv, &iv); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes192cbc_decrypt_block.c b/test/aes192cbc_decrypt_block.c deleted file mode 100644 index 6a953ad..0000000 --- a/test/aes192cbc_decrypt_block.c +++ /dev/null @@ -1,56 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule, inverted_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block192(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes192_expand_key_schedule(&key, &key_schedule); - aes192_invert_key_schedule(&key_schedule, &inverted_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes192cbc_decrypt(cipher, &inverted_schedule, iv, &iv); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes192cbc_encrypt.c b/test/aes192cbc_encrypt.c new file mode 100644 index 0000000..a1269b4 --- /dev/null +++ b/test/aes192cbc_encrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block192(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes192_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes192cbc_encrypt(plain, &key_schedule, iv, &iv); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes192cbc_encrypt_block.c b/test/aes192cbc_encrypt_block.c deleted file mode 100644 index a1269b4..0000000 --- a/test/aes192cbc_encrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block192(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes192_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes192cbc_encrypt(plain, &key_schedule, iv, &iv); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes192cfb_decrypt.c b/test/aes192cfb_decrypt.c new file mode 100644 index 0000000..906ecf9 --- /dev/null +++ b/test/aes192cfb_decrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block192(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes192_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes192cfb_decrypt(cipher, &key_schedule, iv, &iv); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes192cfb_decrypt_block.c b/test/aes192cfb_decrypt_block.c deleted file mode 100644 index 906ecf9..0000000 --- a/test/aes192cfb_decrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block192(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes192_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes192cfb_decrypt(cipher, &key_schedule, iv, &iv); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes192cfb_encrypt.c b/test/aes192cfb_encrypt.c new file mode 100644 index 0000000..3261a03 --- /dev/null +++ b/test/aes192cfb_encrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block192(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes192_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes192cfb_encrypt(plain, &key_schedule, iv, &iv); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes192cfb_encrypt_block.c b/test/aes192cfb_encrypt_block.c deleted file mode 100644 index 3261a03..0000000 --- a/test/aes192cfb_encrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block192(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes192_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes192cfb_encrypt(plain, &key_schedule, iv, &iv); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes192ctr_decrypt.c b/test/aes192ctr_decrypt.c new file mode 100644 index 0000000..01258ea --- /dev/null +++ b/test/aes192ctr_decrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block192(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes192_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes192ctr_decrypt(cipher, &key_schedule, iv, i - 3); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes192ctr_decrypt_block.c b/test/aes192ctr_decrypt_block.c deleted file mode 100644 index 01258ea..0000000 --- a/test/aes192ctr_decrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block192(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes192_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes192ctr_decrypt(cipher, &key_schedule, iv, i - 3); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes192ctr_encrypt.c b/test/aes192ctr_encrypt.c new file mode 100644 index 0000000..9a29005 --- /dev/null +++ b/test/aes192ctr_encrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block192(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes192_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes192ctr_encrypt(plain, &key_schedule, iv, i - 3); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes192ctr_encrypt_block.c b/test/aes192ctr_encrypt_block.c deleted file mode 100644 index 9a29005..0000000 --- a/test/aes192ctr_encrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block192(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes192_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes192ctr_encrypt(plain, &key_schedule, iv, i - 3); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes192ecb_decrypt.c b/test/aes192ecb_decrypt.c new file mode 100644 index 0000000..e6e749a --- /dev/null +++ b/test/aes192ecb_decrypt.c @@ -0,0 +1,50 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule, inverted_schedule; + + if (argc < 2) + exit_with_usage(argv[0]); + + if (parse_aes_block192(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + aes192_expand_key_schedule(&key, &key_schedule); + aes192_invert_key_schedule(&key_schedule, &inverted_schedule); + + for (int i = 2; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes192ecb_decrypt(cipher, &inverted_schedule); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes192ecb_decrypt_block.c b/test/aes192ecb_decrypt_block.c deleted file mode 100644 index e6e749a..0000000 --- a/test/aes192ecb_decrypt_block.c +++ /dev/null @@ -1,50 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule, inverted_schedule; - - if (argc < 2) - exit_with_usage(argv[0]); - - if (parse_aes_block192(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - aes192_expand_key_schedule(&key, &key_schedule); - aes192_invert_key_schedule(&key_schedule, &inverted_schedule); - - for (int i = 2; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes192ecb_decrypt(cipher, &inverted_schedule); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes192ecb_encrypt.c b/test/aes192ecb_encrypt.c new file mode 100644 index 0000000..2b4f688 --- /dev/null +++ b/test/aes192ecb_encrypt.c @@ -0,0 +1,49 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule; + + if (argc < 2) + exit_with_usage(argv[0]); + + if (parse_aes_block192(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + aes192_expand_key_schedule(&key, &key_schedule); + + for (int i = 2; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes192ecb_encrypt(plain, &key_schedule); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes192ecb_encrypt_block.c b/test/aes192ecb_encrypt_block.c deleted file mode 100644 index 2b4f688..0000000 --- a/test/aes192ecb_encrypt_block.c +++ /dev/null @@ -1,49 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule; - - if (argc < 2) - exit_with_usage(argv[0]); - - if (parse_aes_block192(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - aes192_expand_key_schedule(&key, &key_schedule); - - for (int i = 2; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes192ecb_encrypt(plain, &key_schedule); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes192ofb_decrypt.c b/test/aes192ofb_decrypt.c new file mode 100644 index 0000000..268b00c --- /dev/null +++ b/test/aes192ofb_decrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block192(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes192_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes192ofb_decrypt(cipher, &key_schedule, iv, &iv); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes192ofb_decrypt_block.c b/test/aes192ofb_decrypt_block.c deleted file mode 100644 index 268b00c..0000000 --- a/test/aes192ofb_decrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block192(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes192_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes192ofb_decrypt(cipher, &key_schedule, iv, &iv); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes192ofb_encrypt.c b/test/aes192ofb_encrypt.c new file mode 100644 index 0000000..8c866c3 --- /dev/null +++ b/test/aes192ofb_encrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block192(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes192_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes192ofb_encrypt(plain, &key_schedule, iv, &iv); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes192ofb_encrypt_block.c b/test/aes192ofb_encrypt_block.c deleted file mode 100644 index 8c866c3..0000000 --- a/test/aes192ofb_encrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block192(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 192-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes192_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes192ofb_encrypt(plain, &key_schedule, iv, &iv); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes256cbc_decrypt.c b/test/aes256cbc_decrypt.c new file mode 100644 index 0000000..52abaff --- /dev/null +++ b/test/aes256cbc_decrypt.c @@ -0,0 +1,56 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule, inverted_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block256(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes256_expand_key_schedule(&key, &key_schedule); + aes256_invert_key_schedule(&key_schedule, &inverted_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes256cbc_decrypt(cipher, &inverted_schedule, iv, &iv); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes256cbc_decrypt_block.c b/test/aes256cbc_decrypt_block.c deleted file mode 100644 index 52abaff..0000000 --- a/test/aes256cbc_decrypt_block.c +++ /dev/null @@ -1,56 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule, inverted_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block256(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes256_expand_key_schedule(&key, &key_schedule); - aes256_invert_key_schedule(&key_schedule, &inverted_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes256cbc_decrypt(cipher, &inverted_schedule, iv, &iv); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes256cbc_encrypt.c b/test/aes256cbc_encrypt.c new file mode 100644 index 0000000..0b10f54 --- /dev/null +++ b/test/aes256cbc_encrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block256(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes256_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes256cbc_encrypt(plain, &key_schedule, iv, &iv); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes256cbc_encrypt_block.c b/test/aes256cbc_encrypt_block.c deleted file mode 100644 index 0b10f54..0000000 --- a/test/aes256cbc_encrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block256(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes256_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes256cbc_encrypt(plain, &key_schedule, iv, &iv); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes256cfb_decrypt.c b/test/aes256cfb_decrypt.c new file mode 100644 index 0000000..d3f6075 --- /dev/null +++ b/test/aes256cfb_decrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block256(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes256_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes256cfb_decrypt(cipher, &key_schedule, iv, &iv); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes256cfb_decrypt_block.c b/test/aes256cfb_decrypt_block.c deleted file mode 100644 index d3f6075..0000000 --- a/test/aes256cfb_decrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block256(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes256_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes256cfb_decrypt(cipher, &key_schedule, iv, &iv); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes256cfb_encrypt.c b/test/aes256cfb_encrypt.c new file mode 100644 index 0000000..c14e931 --- /dev/null +++ b/test/aes256cfb_encrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block256(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes256_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes256cfb_encrypt(plain, &key_schedule, iv, &iv); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes256cfb_encrypt_block.c b/test/aes256cfb_encrypt_block.c deleted file mode 100644 index c14e931..0000000 --- a/test/aes256cfb_encrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block256(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes256_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes256cfb_encrypt(plain, &key_schedule, iv, &iv); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes256ctr_decrypt.c b/test/aes256ctr_decrypt.c new file mode 100644 index 0000000..db7ae5c --- /dev/null +++ b/test/aes256ctr_decrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block256(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes256_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes256ctr_decrypt(cipher, &key_schedule, iv, i - 3); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes256ctr_decrypt_block.c b/test/aes256ctr_decrypt_block.c deleted file mode 100644 index db7ae5c..0000000 --- a/test/aes256ctr_decrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block256(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes256_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes256ctr_decrypt(cipher, &key_schedule, iv, i - 3); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes256ctr_encrypt.c b/test/aes256ctr_encrypt.c new file mode 100644 index 0000000..d812a86 --- /dev/null +++ b/test/aes256ctr_encrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block256(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes256_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes256ctr_encrypt(plain, &key_schedule, iv, i - 3); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes256ctr_encrypt_block.c b/test/aes256ctr_encrypt_block.c deleted file mode 100644 index d812a86..0000000 --- a/test/aes256ctr_encrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block256(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes256_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes256ctr_encrypt(plain, &key_schedule, iv, i - 3); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes256ecb_decrypt.c b/test/aes256ecb_decrypt.c new file mode 100644 index 0000000..a290eed --- /dev/null +++ b/test/aes256ecb_decrypt.c @@ -0,0 +1,50 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule, inverted_schedule; + + if (argc < 2) + exit_with_usage(argv[0]); + + if (parse_aes_block256(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + aes256_expand_key_schedule(&key, &key_schedule); + aes256_invert_key_schedule(&key_schedule, &inverted_schedule); + + for (int i = 2; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes256ecb_decrypt(cipher, &inverted_schedule); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes256ecb_decrypt_block.c b/test/aes256ecb_decrypt_block.c deleted file mode 100644 index a290eed..0000000 --- a/test/aes256ecb_decrypt_block.c +++ /dev/null @@ -1,50 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule, inverted_schedule; - - if (argc < 2) - exit_with_usage(argv[0]); - - if (parse_aes_block256(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - aes256_expand_key_schedule(&key, &key_schedule); - aes256_invert_key_schedule(&key_schedule, &inverted_schedule); - - for (int i = 2; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes256ecb_decrypt(cipher, &inverted_schedule); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes256ecb_encrypt.c b/test/aes256ecb_encrypt.c new file mode 100644 index 0000000..2a4899e --- /dev/null +++ b/test/aes256ecb_encrypt.c @@ -0,0 +1,49 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule; + + if (argc < 2) + exit_with_usage(argv[0]); + + if (parse_aes_block256(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + aes256_expand_key_schedule(&key, &key_schedule); + + for (int i = 2; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes256ecb_encrypt(plain, &key_schedule); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes256ecb_encrypt_block.c b/test/aes256ecb_encrypt_block.c deleted file mode 100644 index 2a4899e..0000000 --- a/test/aes256ecb_encrypt_block.c +++ /dev/null @@ -1,49 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule; - - if (argc < 2) - exit_with_usage(argv[0]); - - if (parse_aes_block256(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - aes256_expand_key_schedule(&key, &key_schedule); - - for (int i = 2; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes256ecb_encrypt(plain, &key_schedule); - print_aes_block128(&cipher); - } - - return 0; -} diff --git a/test/aes256ofb_decrypt.c b/test/aes256ofb_decrypt.c new file mode 100644 index 0000000..282dc6a --- /dev/null +++ b/test/aes256ofb_decrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block256(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes256_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&cipher, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + plain = aes256ofb_decrypt(cipher, &key_schedule, iv, &iv); + print_aes_block128(&plain); + } + + return 0; +} diff --git a/test/aes256ofb_decrypt_block.c b/test/aes256ofb_decrypt_block.c deleted file mode 100644 index 282dc6a..0000000 --- a/test/aes256ofb_decrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [CIPHER...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block256(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes256_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&cipher, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - plain = aes256ofb_decrypt(cipher, &key_schedule, iv, &iv); - print_aes_block128(&plain); - } - - return 0; -} diff --git a/test/aes256ofb_encrypt.c b/test/aes256ofb_encrypt.c new file mode 100644 index 0000000..b74f29f --- /dev/null +++ b/test/aes256ofb_encrypt.c @@ -0,0 +1,55 @@ +/** + * \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 + +static void exit_with_usage(const char* argv0) +{ + printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); + exit(EXIT_FAILURE); +} + +int main(int argc, char** argv) +{ + __declspec(align(16)) AesBlock128 plain, cipher, iv; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule; + + if (argc < 3) + exit_with_usage(argv[0]); + + if (parse_aes_block256(&key, argv[1]) != 0) + { + fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); + exit_with_usage(argv[0]); + } + + if (parse_aes_block128(&iv, argv[2]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); + exit_with_usage(argv[0]); + } + + aes256_expand_key_schedule(&key, &key_schedule); + + for (int i = 3; i < argc; ++i) + { + if (parse_aes_block128(&plain, argv[i]) != 0) + { + fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); + continue; + } + cipher = aes256ofb_encrypt(plain, &key_schedule, iv, &iv); + print_aes_block128(&cipher); + } + + return 0; +} diff --git a/test/aes256ofb_encrypt_block.c b/test/aes256ofb_encrypt_block.c deleted file mode 100644 index b74f29f..0000000 --- a/test/aes256ofb_encrypt_block.c +++ /dev/null @@ -1,55 +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 - -static void exit_with_usage(const char* argv0) -{ - printf("Usage: %s KEY INIT_VECTOR [PLAIN...]\n", argv0); - exit(EXIT_FAILURE); -} - -int main(int argc, char** argv) -{ - __declspec(align(16)) AesBlock128 plain, cipher, iv; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule; - - if (argc < 3) - exit_with_usage(argv[0]); - - if (parse_aes_block256(&key, argv[1]) != 0) - { - fprintf(stderr, "Invalid 256-bit AES block '%s'\n", argv[1]); - exit_with_usage(argv[0]); - } - - if (parse_aes_block128(&iv, argv[2]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[2]); - exit_with_usage(argv[0]); - } - - aes256_expand_key_schedule(&key, &key_schedule); - - for (int i = 3; i < argc; ++i) - { - if (parse_aes_block128(&plain, argv[i]) != 0) - { - fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[i]); - continue; - } - cipher = aes256ofb_encrypt(plain, &key_schedule, iv, &iv); - print_aes_block128(&cipher); - } - - return 0; -} -- cgit v1.2.3