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 --------------------------------------- 31 files changed, 877 insertions(+), 876 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 (limited to 'examples') 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; -} -- cgit v1.2.3