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 --- examples/CMakeLists.txt | 5 ++-- examples/aes128cbc.c | 66 +++++++++++++++++++++++++++++++++++++++++ examples/aes128cbc_example.c | 66 ----------------------------------------- examples/aes128cfb.c | 59 +++++++++++++++++++++++++++++++++++++ examples/aes128cfb_example.c | 59 ------------------------------------- examples/aes128ctr.c | 51 ++++++++++++++++++++++++++++++++ examples/aes128ctr_example.c | 51 -------------------------------- examples/aes128ecb.c | 53 +++++++++++++++++++++++++++++++++ examples/aes128ecb_example.c | 53 --------------------------------- examples/aes128ofb.c | 59 +++++++++++++++++++++++++++++++++++++ examples/aes128ofb_example.c | 59 ------------------------------------- examples/aes192cbc.c | 67 ++++++++++++++++++++++++++++++++++++++++++ examples/aes192cbc_example.c | 67 ------------------------------------------ examples/aes192cfb.c | 60 +++++++++++++++++++++++++++++++++++++ examples/aes192cfb_example.c | 60 ------------------------------------- examples/aes192ctr.c | 52 ++++++++++++++++++++++++++++++++ examples/aes192ctr_example.c | 52 -------------------------------- examples/aes192ecb.c | 54 ++++++++++++++++++++++++++++++++++ examples/aes192ecb_example.c | 54 ---------------------------------- examples/aes192ofb.c | 60 +++++++++++++++++++++++++++++++++++++ examples/aes192ofb_example.c | 60 ------------------------------------- examples/aes256cbc.c | 67 ++++++++++++++++++++++++++++++++++++++++++ examples/aes256cbc_example.c | 67 ------------------------------------------ examples/aes256cfb.c | 60 +++++++++++++++++++++++++++++++++++++ examples/aes256cfb_example.c | 60 ------------------------------------- examples/aes256ctr.c | 52 ++++++++++++++++++++++++++++++++ examples/aes256ctr_example.c | 52 -------------------------------- examples/aes256ecb.c | 54 ++++++++++++++++++++++++++++++++++ examples/aes256ecb_example.c | 54 ---------------------------------- examples/aes256ofb.c | 60 +++++++++++++++++++++++++++++++++++++ examples/aes256ofb_example.c | 60 ------------------------------------- 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 ---------------------------------- 92 files changed, 2493 insertions(+), 2490 deletions(-) create mode 100644 examples/aes128cbc.c delete mode 100644 examples/aes128cbc_example.c create mode 100644 examples/aes128cfb.c delete mode 100644 examples/aes128cfb_example.c create mode 100644 examples/aes128ctr.c delete mode 100644 examples/aes128ctr_example.c create mode 100644 examples/aes128ecb.c delete mode 100644 examples/aes128ecb_example.c create mode 100644 examples/aes128ofb.c delete mode 100644 examples/aes128ofb_example.c create mode 100644 examples/aes192cbc.c delete mode 100644 examples/aes192cbc_example.c create mode 100644 examples/aes192cfb.c delete mode 100644 examples/aes192cfb_example.c create mode 100644 examples/aes192ctr.c delete mode 100644 examples/aes192ctr_example.c create mode 100644 examples/aes192ecb.c delete mode 100644 examples/aes192ecb_example.c create mode 100644 examples/aes192ofb.c delete mode 100644 examples/aes192ofb_example.c create mode 100644 examples/aes256cbc.c delete mode 100644 examples/aes256cbc_example.c create mode 100644 examples/aes256cfb.c delete mode 100644 examples/aes256cfb_example.c create mode 100644 examples/aes256ctr.c delete mode 100644 examples/aes256ctr_example.c create mode 100644 examples/aes256ecb.c delete mode 100644 examples/aes256ecb_example.c create mode 100644 examples/aes256ofb.c delete mode 100644 examples/aes256ofb_example.c 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 diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index db2b2c4..8cf4d6a 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,8 +1,9 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") macro(example prefix) - add_executable(${prefix}_example ${prefix}_example.c) - target_link_libraries(${prefix}_example libaesni) + add_executable(example_${prefix} ${prefix}.c) + target_link_libraries(example_${prefix} libaesni) + set_target_properties(example_${prefix} PROPERTIES OUTPUT_NAME ${prefix}) endmacro() example(aes128ecb) diff --git a/examples/aes128cbc.c b/examples/aes128cbc.c new file mode 100644 index 0000000..bf2c601 --- /dev/null +++ b/examples/aes128cbc.c @@ -0,0 +1,66 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, decrypted, iv, next_iv; + __declspec(align(16)) Aes128KeySchedule key_schedule, inverted_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block128(&key).str); + print_aes_block128_fips_matrix_style(&key); + + printf("\n"); + printf("Initialization vector: %s\n", format_aes_block128(&iv).str); + print_aes_block128_fips_matrix_style(&iv); + + aes128_expand_key_schedule(key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 11; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes128cbc_encrypt(plain, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + aes128_invert_key_schedule(&key_schedule, &inverted_schedule); + + printf("\n"); + printf("Inverted key schedule:\n"); + for (int i = 0; i < 11; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str); + + decrypted = aes128cbc_decrypt(cipher, &inverted_schedule, iv, &next_iv); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + return 0; +} diff --git a/examples/aes128cbc_example.c b/examples/aes128cbc_example.c deleted file mode 100644 index bf2c601..0000000 --- a/examples/aes128cbc_example.c +++ /dev/null @@ -1,66 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, decrypted, iv, next_iv; - __declspec(align(16)) Aes128KeySchedule key_schedule, inverted_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block128(&key).str); - print_aes_block128_fips_matrix_style(&key); - - printf("\n"); - printf("Initialization vector: %s\n", format_aes_block128(&iv).str); - print_aes_block128_fips_matrix_style(&iv); - - aes128_expand_key_schedule(key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 11; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes128cbc_encrypt(plain, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - aes128_invert_key_schedule(&key_schedule, &inverted_schedule); - - printf("\n"); - printf("Inverted key schedule:\n"); - for (int i = 0; i < 11; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str); - - decrypted = aes128cbc_decrypt(cipher, &inverted_schedule, iv, &next_iv); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - return 0; -} diff --git a/examples/aes128cfb.c b/examples/aes128cfb.c new file mode 100644 index 0000000..c3b7cd2 --- /dev/null +++ b/examples/aes128cfb.c @@ -0,0 +1,59 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, decrypted, iv, next_iv; + __declspec(align(16)) Aes128KeySchedule key_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block128(&key).str); + print_aes_block128_fips_matrix_style(&key); + + printf("\n"); + printf("Initialization vector: %s\n", format_aes_block128(&iv).str); + print_aes_block128_fips_matrix_style(&iv); + + aes128_expand_key_schedule(key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 11; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes128cfb_encrypt(plain, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + decrypted = aes128cfb_decrypt(cipher, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + return 0; +} diff --git a/examples/aes128cfb_example.c b/examples/aes128cfb_example.c deleted file mode 100644 index c3b7cd2..0000000 --- a/examples/aes128cfb_example.c +++ /dev/null @@ -1,59 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, decrypted, iv, next_iv; - __declspec(align(16)) Aes128KeySchedule key_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block128(&key).str); - print_aes_block128_fips_matrix_style(&key); - - printf("\n"); - printf("Initialization vector: %s\n", format_aes_block128(&iv).str); - print_aes_block128_fips_matrix_style(&iv); - - aes128_expand_key_schedule(key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 11; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes128cfb_encrypt(plain, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - decrypted = aes128cfb_decrypt(cipher, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - return 0; -} diff --git a/examples/aes128ctr.c b/examples/aes128ctr.c new file mode 100644 index 0000000..46251e8 --- /dev/null +++ b/examples/aes128ctr.c @@ -0,0 +1,51 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, decrypted, iv; + __declspec(align(16)) Aes128KeySchedule key_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block128(&key).str); + print_aes_block128_fips_matrix_style(&key); + + printf("\n"); + printf("Initialization vector: %s\n", format_aes_block128(&iv).str); + print_aes_block128_fips_matrix_style(&iv); + + aes128_expand_key_schedule(key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 11; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes128ctr_encrypt(plain, &key_schedule, iv, 0); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + decrypted = aes128ctr_decrypt(cipher, &key_schedule, iv, 0); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + return 0; +} diff --git a/examples/aes128ctr_example.c b/examples/aes128ctr_example.c deleted file mode 100644 index 46251e8..0000000 --- a/examples/aes128ctr_example.c +++ /dev/null @@ -1,51 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, decrypted, iv; - __declspec(align(16)) Aes128KeySchedule key_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block128(&key).str); - print_aes_block128_fips_matrix_style(&key); - - printf("\n"); - printf("Initialization vector: %s\n", format_aes_block128(&iv).str); - print_aes_block128_fips_matrix_style(&iv); - - aes128_expand_key_schedule(key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 11; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes128ctr_encrypt(plain, &key_schedule, iv, 0); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - decrypted = aes128ctr_decrypt(cipher, &key_schedule, iv, 0); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - return 0; -} diff --git a/examples/aes128ecb.c b/examples/aes128ecb.c new file mode 100644 index 0000000..1d8e7ae --- /dev/null +++ b/examples/aes128ecb.c @@ -0,0 +1,53 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, decrypted; + __declspec(align(16)) Aes128KeySchedule key_schedule, inverted_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block128(&key).str); + print_aes_block128_fips_matrix_style(&key); + + aes128_expand_key_schedule(key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 11; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes128ecb_encrypt(plain, &key_schedule); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + aes128_invert_key_schedule(&key_schedule, &inverted_schedule); + + printf("\n"); + printf("Inverted key schedule:\n"); + for (int i = 0; i < 11; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str); + + decrypted = aes128ecb_decrypt(cipher, &inverted_schedule); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + return 0; +} diff --git a/examples/aes128ecb_example.c b/examples/aes128ecb_example.c deleted file mode 100644 index 1d8e7ae..0000000 --- a/examples/aes128ecb_example.c +++ /dev/null @@ -1,53 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, decrypted; - __declspec(align(16)) Aes128KeySchedule key_schedule, inverted_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block128(&key).str); - print_aes_block128_fips_matrix_style(&key); - - aes128_expand_key_schedule(key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 11; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes128ecb_encrypt(plain, &key_schedule); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - aes128_invert_key_schedule(&key_schedule, &inverted_schedule); - - printf("\n"); - printf("Inverted key schedule:\n"); - for (int i = 0; i < 11; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str); - - decrypted = aes128ecb_decrypt(cipher, &inverted_schedule); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - return 0; -} diff --git a/examples/aes128ofb.c b/examples/aes128ofb.c new file mode 100644 index 0000000..51f0a8d --- /dev/null +++ b/examples/aes128ofb.c @@ -0,0 +1,59 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, key, cipher, decrypted, iv, next_iv; + __declspec(align(16)) Aes128KeySchedule key_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block128(&key).str); + print_aes_block128_fips_matrix_style(&key); + + printf("\n"); + printf("Initialization vector: %s\n", format_aes_block128(&iv).str); + print_aes_block128_fips_matrix_style(&iv); + + aes128_expand_key_schedule(key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 11; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes128ofb_encrypt(plain, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + decrypted = aes128ofb_decrypt(cipher, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + return 0; +} diff --git a/examples/aes128ofb_example.c b/examples/aes128ofb_example.c deleted file mode 100644 index 51f0a8d..0000000 --- a/examples/aes128ofb_example.c +++ /dev/null @@ -1,59 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, key, cipher, decrypted, iv, next_iv; - __declspec(align(16)) Aes128KeySchedule key_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block128(0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block128(&key).str); - print_aes_block128_fips_matrix_style(&key); - - printf("\n"); - printf("Initialization vector: %s\n", format_aes_block128(&iv).str); - print_aes_block128_fips_matrix_style(&iv); - - aes128_expand_key_schedule(key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 11; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes128ofb_encrypt(plain, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - decrypted = aes128ofb_decrypt(cipher, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - return 0; -} diff --git a/examples/aes192cbc.c b/examples/aes192cbc.c new file mode 100644 index 0000000..522cc09 --- /dev/null +++ b/examples/aes192cbc.c @@ -0,0 +1,67 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv, next_iv; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule, inverted_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block192(&key).str); + print_aes_block192_fips_matrix_style(&key); + + printf("\n"); + printf("Initialization vector: %s\n", format_aes_block128(&iv).str); + print_aes_block128_fips_matrix_style(&iv); + + aes192_expand_key_schedule(&key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 13; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes192cbc_encrypt(plain, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + aes192_invert_key_schedule(&key_schedule, &inverted_schedule); + + printf("\n"); + printf("Inverted key schedule:\n"); + for (int i = 0; i < 13; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str); + + decrypted = aes192cbc_decrypt(cipher, &inverted_schedule, iv, &next_iv); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + return 0; +} diff --git a/examples/aes192cbc_example.c b/examples/aes192cbc_example.c deleted file mode 100644 index 522cc09..0000000 --- a/examples/aes192cbc_example.c +++ /dev/null @@ -1,67 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv, next_iv; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule, inverted_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block192(&key).str); - print_aes_block192_fips_matrix_style(&key); - - printf("\n"); - printf("Initialization vector: %s\n", format_aes_block128(&iv).str); - print_aes_block128_fips_matrix_style(&iv); - - aes192_expand_key_schedule(&key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 13; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes192cbc_encrypt(plain, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - aes192_invert_key_schedule(&key_schedule, &inverted_schedule); - - printf("\n"); - printf("Inverted key schedule:\n"); - for (int i = 0; i < 13; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str); - - decrypted = aes192cbc_decrypt(cipher, &inverted_schedule, iv, &next_iv); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - return 0; -} diff --git a/examples/aes192cfb.c b/examples/aes192cfb.c new file mode 100644 index 0000000..598516a --- /dev/null +++ b/examples/aes192cfb.c @@ -0,0 +1,60 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv, next_iv; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block192(&key).str); + print_aes_block192_fips_matrix_style(&key); + + printf("\n"); + printf("Initialization vector: %s\n", format_aes_block128(&iv).str); + print_aes_block128_fips_matrix_style(&iv); + + aes192_expand_key_schedule(&key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 13; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes192cfb_encrypt(plain, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + decrypted = aes192cfb_decrypt(cipher, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + return 0; +} diff --git a/examples/aes192cfb_example.c b/examples/aes192cfb_example.c deleted file mode 100644 index 598516a..0000000 --- a/examples/aes192cfb_example.c +++ /dev/null @@ -1,60 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv, next_iv; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block192(&key).str); - print_aes_block192_fips_matrix_style(&key); - - printf("\n"); - printf("Initialization vector: %s\n", format_aes_block128(&iv).str); - print_aes_block128_fips_matrix_style(&iv); - - aes192_expand_key_schedule(&key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 13; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes192cfb_encrypt(plain, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - decrypted = aes192cfb_decrypt(cipher, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - return 0; -} diff --git a/examples/aes192ctr.c b/examples/aes192ctr.c new file mode 100644 index 0000000..6ba8430 --- /dev/null +++ b/examples/aes192ctr.c @@ -0,0 +1,52 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block192(&key).str); + print_aes_block192_fips_matrix_style(&key); + + printf("\n"); + printf("Initialization vector: %s\n", format_aes_block128(&iv).str); + print_aes_block128_fips_matrix_style(&iv); + + aes192_expand_key_schedule(&key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 13; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes192ctr_encrypt(plain, &key_schedule, iv, 0); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + decrypted = aes192ctr_decrypt(cipher, &key_schedule, iv, 0); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + return 0; +} diff --git a/examples/aes192ctr_example.c b/examples/aes192ctr_example.c deleted file mode 100644 index 6ba8430..0000000 --- a/examples/aes192ctr_example.c +++ /dev/null @@ -1,52 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block192(&key).str); - print_aes_block192_fips_matrix_style(&key); - - printf("\n"); - printf("Initialization vector: %s\n", format_aes_block128(&iv).str); - print_aes_block128_fips_matrix_style(&iv); - - aes192_expand_key_schedule(&key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 13; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes192ctr_encrypt(plain, &key_schedule, iv, 0); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - decrypted = aes192ctr_decrypt(cipher, &key_schedule, iv, 0); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - return 0; -} diff --git a/examples/aes192ecb.c b/examples/aes192ecb.c new file mode 100644 index 0000000..5aae0bc --- /dev/null +++ b/examples/aes192ecb.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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, cipher, decrypted; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule, inverted_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block192(&key).str); + print_aes_block192_fips_matrix_style(&key); + + aes192_expand_key_schedule(&key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 13; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes192ecb_encrypt(plain, &key_schedule); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + aes192_invert_key_schedule(&key_schedule, &inverted_schedule); + + printf("\n"); + printf("Inverted key schedule:\n"); + for (int i = 0; i < 13; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str); + + decrypted = aes192ecb_decrypt(cipher, &inverted_schedule); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + return 0; +} diff --git a/examples/aes192ecb_example.c b/examples/aes192ecb_example.c deleted file mode 100644 index 5aae0bc..0000000 --- a/examples/aes192ecb_example.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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, cipher, decrypted; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule, inverted_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block192(&key).str); - print_aes_block192_fips_matrix_style(&key); - - aes192_expand_key_schedule(&key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 13; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes192ecb_encrypt(plain, &key_schedule); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - aes192_invert_key_schedule(&key_schedule, &inverted_schedule); - - printf("\n"); - printf("Inverted key schedule:\n"); - for (int i = 0; i < 13; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str); - - decrypted = aes192ecb_decrypt(cipher, &inverted_schedule); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - return 0; -} diff --git a/examples/aes192ofb.c b/examples/aes192ofb.c new file mode 100644 index 0000000..1e561cb --- /dev/null +++ b/examples/aes192ofb.c @@ -0,0 +1,60 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv, next_iv; + __declspec(align(16)) AesBlock192 key; + __declspec(align(16)) Aes192KeySchedule key_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block192(&key).str); + print_aes_block192_fips_matrix_style(&key); + + printf("\n"); + printf("Initialization vector: %s\n", format_aes_block128(&iv).str); + print_aes_block128_fips_matrix_style(&iv); + + aes192_expand_key_schedule(&key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 13; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes192ofb_encrypt(plain, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + decrypted = aes192ofb_decrypt(cipher, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + return 0; +} diff --git a/examples/aes192ofb_example.c b/examples/aes192ofb_example.c deleted file mode 100644 index 1e561cb..0000000 --- a/examples/aes192ofb_example.c +++ /dev/null @@ -1,60 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv, next_iv; - __declspec(align(16)) AesBlock192 key; - __declspec(align(16)) Aes192KeySchedule key_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block192(0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block192(&key).str); - print_aes_block192_fips_matrix_style(&key); - - printf("\n"); - printf("Initialization vector: %s\n", format_aes_block128(&iv).str); - print_aes_block128_fips_matrix_style(&iv); - - aes192_expand_key_schedule(&key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 13; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes192ofb_encrypt(plain, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - decrypted = aes192ofb_decrypt(cipher, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - return 0; -} diff --git a/examples/aes256cbc.c b/examples/aes256cbc.c new file mode 100644 index 0000000..b727bec --- /dev/null +++ b/examples/aes256cbc.c @@ -0,0 +1,67 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv, next_iv; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule, inverted_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block256(&key).str); + print_aes_block256_fips_matrix_style(&key); + + printf("\n"); + printf("Initialization vector: %s\n", format_aes_block128(&iv).str); + print_aes_block128_fips_matrix_style(&iv); + + aes256_expand_key_schedule(&key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 15; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes256cbc_encrypt(plain, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + aes256_invert_key_schedule(&key_schedule, &inverted_schedule); + + printf("\n"); + printf("Inverted key schedule:\n"); + for (int i = 0; i < 15; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str); + + decrypted = aes256cbc_decrypt(cipher, &inverted_schedule, iv, &next_iv); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + return 0; +} diff --git a/examples/aes256cbc_example.c b/examples/aes256cbc_example.c deleted file mode 100644 index b727bec..0000000 --- a/examples/aes256cbc_example.c +++ /dev/null @@ -1,67 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv, next_iv; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule, inverted_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block256(&key).str); - print_aes_block256_fips_matrix_style(&key); - - printf("\n"); - printf("Initialization vector: %s\n", format_aes_block128(&iv).str); - print_aes_block128_fips_matrix_style(&iv); - - aes256_expand_key_schedule(&key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 15; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes256cbc_encrypt(plain, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - aes256_invert_key_schedule(&key_schedule, &inverted_schedule); - - printf("\n"); - printf("Inverted key schedule:\n"); - for (int i = 0; i < 15; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str); - - decrypted = aes256cbc_decrypt(cipher, &inverted_schedule, iv, &next_iv); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - return 0; -} diff --git a/examples/aes256cfb.c b/examples/aes256cfb.c new file mode 100644 index 0000000..9541ddd --- /dev/null +++ b/examples/aes256cfb.c @@ -0,0 +1,60 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv, next_iv; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block256(&key).str); + print_aes_block256_fips_matrix_style(&key); + + printf("\n"); + printf("Initialization vector: %s\n", format_aes_block128(&iv).str); + print_aes_block128_fips_matrix_style(&iv); + + aes256_expand_key_schedule(&key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 15; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes256cfb_encrypt(plain, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + decrypted = aes256cfb_decrypt(cipher, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + return 0; +} diff --git a/examples/aes256cfb_example.c b/examples/aes256cfb_example.c deleted file mode 100644 index 9541ddd..0000000 --- a/examples/aes256cfb_example.c +++ /dev/null @@ -1,60 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv, next_iv; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block256(&key).str); - print_aes_block256_fips_matrix_style(&key); - - printf("\n"); - printf("Initialization vector: %s\n", format_aes_block128(&iv).str); - print_aes_block128_fips_matrix_style(&iv); - - aes256_expand_key_schedule(&key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 15; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes256cfb_encrypt(plain, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - decrypted = aes256cfb_decrypt(cipher, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - return 0; -} diff --git a/examples/aes256ctr.c b/examples/aes256ctr.c new file mode 100644 index 0000000..647d668 --- /dev/null +++ b/examples/aes256ctr.c @@ -0,0 +1,52 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block256(&key).str); + print_aes_block256_fips_matrix_style(&key); + + printf("\n"); + printf("Initialization vector: %s\n", format_aes_block128(&iv).str); + print_aes_block128_fips_matrix_style(&iv); + + aes256_expand_key_schedule(&key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 15; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes256ctr_encrypt(plain, &key_schedule, iv, 0); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + decrypted = aes256ctr_decrypt(cipher, &key_schedule, iv, 0); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + return 0; +} diff --git a/examples/aes256ctr_example.c b/examples/aes256ctr_example.c deleted file mode 100644 index 647d668..0000000 --- a/examples/aes256ctr_example.c +++ /dev/null @@ -1,52 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block256(&key).str); - print_aes_block256_fips_matrix_style(&key); - - printf("\n"); - printf("Initialization vector: %s\n", format_aes_block128(&iv).str); - print_aes_block128_fips_matrix_style(&iv); - - aes256_expand_key_schedule(&key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 15; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes256ctr_encrypt(plain, &key_schedule, iv, 0); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - decrypted = aes256ctr_decrypt(cipher, &key_schedule, iv, 0); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - return 0; -} diff --git a/examples/aes256ecb.c b/examples/aes256ecb.c new file mode 100644 index 0000000..31d05d7 --- /dev/null +++ b/examples/aes256ecb.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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, cipher, decrypted; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule, inverted_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block256(&key).str); + print_aes_block256_fips_matrix_style(&key); + + aes256_expand_key_schedule(&key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 15; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes256ecb_encrypt(plain, &key_schedule); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + aes256_invert_key_schedule(&key_schedule, &inverted_schedule); + + printf("\n"); + printf("Inverted key schedule:\n"); + for (int i = 0; i < 15; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str); + + decrypted = aes256ecb_decrypt(cipher, &inverted_schedule); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + return 0; +} diff --git a/examples/aes256ecb_example.c b/examples/aes256ecb_example.c deleted file mode 100644 index 31d05d7..0000000 --- a/examples/aes256ecb_example.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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, cipher, decrypted; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule, inverted_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block256(&key).str); - print_aes_block256_fips_matrix_style(&key); - - aes256_expand_key_schedule(&key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 15; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes256ecb_encrypt(plain, &key_schedule); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - aes256_invert_key_schedule(&key_schedule, &inverted_schedule); - - printf("\n"); - printf("Inverted key schedule:\n"); - for (int i = 0; i < 15; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&inverted_schedule.keys[i]).str); - - decrypted = aes256ecb_decrypt(cipher, &inverted_schedule); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - return 0; -} diff --git a/examples/aes256ofb.c b/examples/aes256ofb.c new file mode 100644 index 0000000..4b2248a --- /dev/null +++ b/examples/aes256ofb.c @@ -0,0 +1,60 @@ +/** + * \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 + +int main() +{ + __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv, next_iv; + __declspec(align(16)) AesBlock256 key; + __declspec(align(16)) Aes256KeySchedule key_schedule; + + plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); + key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); + iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); + + printf("Plain: %s\n", format_aes_block128(&plain).str); + print_aes_block128_fips_matrix_style(&plain); + + printf("\n"); + printf("Key: %s\n", format_aes_block256(&key).str); + print_aes_block256_fips_matrix_style(&key); + + printf("\n"); + printf("Initialization vector: %s\n", format_aes_block128(&iv).str); + print_aes_block128_fips_matrix_style(&iv); + + aes256_expand_key_schedule(&key, &key_schedule); + + printf("\n"); + printf("Key schedule:\n"); + for (int i = 0; i < 15; ++i) + printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); + + cipher = aes256ofb_encrypt(plain, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Cypher: %s\n", format_aes_block128(&cipher).str); + print_aes_block128_fips_matrix_style(&cipher); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + decrypted = aes256ofb_decrypt(cipher, &key_schedule, iv, &next_iv); + printf("\n"); + printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); + print_aes_block128_fips_matrix_style(&decrypted); + + printf("\n"); + printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); + print_aes_block128_fips_matrix_style(&next_iv); + + return 0; +} diff --git a/examples/aes256ofb_example.c b/examples/aes256ofb_example.c deleted file mode 100644 index 4b2248a..0000000 --- a/examples/aes256ofb_example.c +++ /dev/null @@ -1,60 +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 - -int main() -{ - __declspec(align(16)) AesBlock128 plain, cipher, decrypted, iv, next_iv; - __declspec(align(16)) AesBlock256 key; - __declspec(align(16)) Aes256KeySchedule key_schedule; - - plain = make_aes_block128(0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100); - key = make_aes_block256(0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100); - iv = make_aes_block128(0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210); - - printf("Plain: %s\n", format_aes_block128(&plain).str); - print_aes_block128_fips_matrix_style(&plain); - - printf("\n"); - printf("Key: %s\n", format_aes_block256(&key).str); - print_aes_block256_fips_matrix_style(&key); - - printf("\n"); - printf("Initialization vector: %s\n", format_aes_block128(&iv).str); - print_aes_block128_fips_matrix_style(&iv); - - aes256_expand_key_schedule(&key, &key_schedule); - - printf("\n"); - printf("Key schedule:\n"); - for (int i = 0; i < 15; ++i) - printf("\t[%d]: %s\n", i, format_aes_block128(&key_schedule.keys[i]).str); - - cipher = aes256ofb_encrypt(plain, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Cypher: %s\n", format_aes_block128(&cipher).str); - print_aes_block128_fips_matrix_style(&cipher); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - decrypted = aes256ofb_decrypt(cipher, &key_schedule, iv, &next_iv); - printf("\n"); - printf("Decrypted: %s\n", format_aes_block128(&decrypted).str); - print_aes_block128_fips_matrix_style(&decrypted); - - printf("\n"); - printf("Next initialization vector: %s\n", format_aes_block128(&next_iv).str); - print_aes_block128_fips_matrix_style(&next_iv); - - return 0; -} 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