aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/CMakeLists.txt26
-rw-r--r--test/aes128cbc_decrypt_block.c63
-rw-r--r--test/aes128cbc_encrypt_block.c62
-rw-r--r--test/aes128cfb_decrypt_block.c62
-rw-r--r--test/aes128cfb_encrypt_block.c62
-rw-r--r--test/aes128ctr_decrypt_block.c62
-rw-r--r--test/aes128ctr_encrypt_block.c62
-rw-r--r--test/aes128ecb_decrypt_block.c57
-rw-r--r--test/aes128ecb_encrypt_block.c56
-rw-r--r--test/aes128ofb_decrypt_block.c62
-rw-r--r--test/aes128ofb_encrypt_block.c62
-rw-r--r--test/aes192cbc_decrypt_block.c63
-rw-r--r--test/aes192cbc_encrypt_block.c62
-rw-r--r--test/aes192cfb_decrypt_block.c62
-rw-r--r--test/aes192cfb_encrypt_block.c62
-rw-r--r--test/aes192ctr_decrypt_block.c62
-rw-r--r--test/aes192ctr_encrypt_block.c62
-rw-r--r--test/aes192ecb_decrypt_block.c57
-rw-r--r--test/aes192ecb_encrypt_block.c56
-rw-r--r--test/aes192ofb_decrypt_block.c62
-rw-r--r--test/aes192ofb_encrypt_block.c62
-rw-r--r--test/aes256cbc_decrypt_block.c63
-rw-r--r--test/aes256cbc_encrypt_block.c62
-rw-r--r--test/aes256cfb_decrypt_block.c62
-rw-r--r--test/aes256cfb_encrypt_block.c62
-rw-r--r--test/aes256ctr_decrypt_block.c62
-rw-r--r--test/aes256ctr_encrypt_block.c62
-rw-r--r--test/aes256ecb_decrypt_block.c57
-rw-r--r--test/aes256ecb_encrypt_block.c56
-rw-r--r--test/aes256ofb_decrypt_block.c62
-rw-r--r--test/aes256ofb_encrypt_block.c62
31 files changed, 1856 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 199388d..0ee556f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,3 +1,29 @@
+macro(test prefix)
+ add_executable(test_${prefix}_encrypt_block ${prefix}_encrypt_block.c)
+ target_link_libraries(test_${prefix}_encrypt_block libaesni)
+ set_target_properties(test_${prefix}_encrypt_block PROPERTIES OUTPUT_NAME ${prefix}_encrypt_block)
+
+ add_executable(test_${prefix}_decrypt_block ${prefix}_decrypt_block.c)
+ target_link_libraries(test_${prefix}_decrypt_block libaesni)
+ set_target_properties(test_${prefix}_decrypt_block PROPERTIES OUTPUT_NAME ${prefix}_decrypt_block)
+endmacro()
+
+test(aes128ecb)
+test(aes128cbc)
+test(aes128cfb)
+test(aes128ofb)
+test(aes128ctr)
+test(aes192ecb)
+test(aes192cbc)
+test(aes192cfb)
+test(aes192ofb)
+test(aes192ctr)
+test(aes256ecb)
+test(aes256cbc)
+test(aes256cfb)
+test(aes256ofb)
+test(aes256ctr)
+
find_package(Boost REQUIRED COMPONENTS program_options)
add_executable(test_encrypt_block_aes encrypt_block_aes.cpp common_aes.hpp)
diff --git a/test/aes128cbc_decrypt_block.c b/test/aes128cbc_decrypt_block.c
new file mode 100644
index 0000000..763285c
--- /dev/null
+++ b/test/aes128cbc_decrypt_block.c
@@ -0,0 +1,63 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes128cbc_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes128_Key key;
+ AesNI_Aes128_RoundKeys encryption_keys, decryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes128_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes128_expand_key(&key, &encryption_keys);
+ aesni_aes128_derive_decryption_keys(&encryption_keys, &decryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes128_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &iv);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes128cbc_encrypt_block.c b/test/aes128cbc_encrypt_block.c
new file mode 100644
index 0000000..c9c719d
--- /dev/null
+++ b/test/aes128cbc_encrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes128cbc_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes128_Key key;
+ AesNI_Aes128_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes128_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes128_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes128_encrypt_block_cbc(plaintext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes128cfb_decrypt_block.c b/test/aes128cfb_decrypt_block.c
new file mode 100644
index 0000000..2a27056
--- /dev/null
+++ b/test/aes128cfb_decrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes128cfb_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes128_Key key;
+ AesNI_Aes128_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes128_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes128_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes128_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes128cfb_encrypt_block.c b/test/aes128cfb_encrypt_block.c
new file mode 100644
index 0000000..4c06f9c
--- /dev/null
+++ b/test/aes128cfb_encrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes128cfb_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes128_Key key;
+ AesNI_Aes128_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes128_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes128_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes128_encrypt_block_cfb(plaintext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes128ctr_decrypt_block.c b/test/aes128ctr_decrypt_block.c
new file mode 100644
index 0000000..e7513b5
--- /dev/null
+++ b/test/aes128ctr_decrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes128ctr_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes128_Key key;
+ AesNI_Aes128_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes128_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes128_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes128_decrypt_block_ctr(ciphertext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes128ctr_encrypt_block.c b/test/aes128ctr_encrypt_block.c
new file mode 100644
index 0000000..cbcdbe4
--- /dev/null
+++ b/test/aes128ctr_encrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes128ctr_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes128_Key key;
+ AesNI_Aes128_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes128_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes128_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes128_encrypt_block_ctr(plaintext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes128ecb_decrypt_block.c b/test/aes128ecb_decrypt_block.c
new file mode 100644
index 0000000..c545943
--- /dev/null
+++ b/test/aes128ecb_decrypt_block.c
@@ -0,0 +1,57 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes128ecb_decrypt_block.exe KEY0 [CIPHERTEXT0...] [-- KEY1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext;
+ AesNI_Aes128_Key key;
+ AesNI_Aes128_RoundKeys encryption_keys, decryption_keys;
+
+ if (argc < 1)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes128_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ aesni_aes128_expand_key(&key, &encryption_keys);
+ aesni_aes128_derive_decryption_keys(&encryption_keys, &decryption_keys);
+
+ for (--argc, ++argv; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes128_decrypt_block_ecb(ciphertext, &decryption_keys);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes128ecb_encrypt_block.c b/test/aes128ecb_encrypt_block.c
new file mode 100644
index 0000000..17bcce1
--- /dev/null
+++ b/test/aes128ecb_encrypt_block.c
@@ -0,0 +1,56 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes128ecb_encrypt_block.exe KEY0 [PLAINTEXT0...] [-- KEY1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext;
+ AesNI_Aes128_Key key;
+ AesNI_Aes128_RoundKeys encryption_keys;
+
+ if (argc < 1)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes128_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ aesni_aes128_expand_key(&key, &encryption_keys);
+
+ for (--argc, ++argv; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, &encryption_keys);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes128ofb_decrypt_block.c b/test/aes128ofb_decrypt_block.c
new file mode 100644
index 0000000..06e88a4
--- /dev/null
+++ b/test/aes128ofb_decrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes128ofb_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes128_Key key;
+ AesNI_Aes128_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes128_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes128_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes128_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes128ofb_encrypt_block.c b/test/aes128ofb_encrypt_block.c
new file mode 100644
index 0000000..e8d7759
--- /dev/null
+++ b/test/aes128ofb_encrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes128ofb_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes128_Key key;
+ AesNI_Aes128_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes128_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes128_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes128_encrypt_block_ofb(plaintext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes192cbc_decrypt_block.c b/test/aes192cbc_decrypt_block.c
new file mode 100644
index 0000000..d305a10
--- /dev/null
+++ b/test/aes192cbc_decrypt_block.c
@@ -0,0 +1,63 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes192cbc_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes192_Key key;
+ AesNI_Aes192_RoundKeys encryption_keys, decryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes192_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 192-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes192_expand_key(&key, &encryption_keys);
+ aesni_aes192_derive_decryption_keys(&encryption_keys, &decryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes192_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &iv);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes192cbc_encrypt_block.c b/test/aes192cbc_encrypt_block.c
new file mode 100644
index 0000000..41b2f2b
--- /dev/null
+++ b/test/aes192cbc_encrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes192cbc_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes192_Key key;
+ AesNI_Aes192_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes192_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 192-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes192_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes192_encrypt_block_cbc(plaintext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes192cfb_decrypt_block.c b/test/aes192cfb_decrypt_block.c
new file mode 100644
index 0000000..8e282ba
--- /dev/null
+++ b/test/aes192cfb_decrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes192cfb_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes192_Key key;
+ AesNI_Aes192_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes192_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 192-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes192_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes192_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes192cfb_encrypt_block.c b/test/aes192cfb_encrypt_block.c
new file mode 100644
index 0000000..f2d0dcc
--- /dev/null
+++ b/test/aes192cfb_encrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes192cfb_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes192_Key key;
+ AesNI_Aes192_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes192_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 192-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes192_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes192_encrypt_block_cfb(plaintext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes192ctr_decrypt_block.c b/test/aes192ctr_decrypt_block.c
new file mode 100644
index 0000000..3e4ed94
--- /dev/null
+++ b/test/aes192ctr_decrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes192ctr_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes192_Key key;
+ AesNI_Aes192_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes192_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 192-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes192_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes192_decrypt_block_ctr(ciphertext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes192ctr_encrypt_block.c b/test/aes192ctr_encrypt_block.c
new file mode 100644
index 0000000..12778ea
--- /dev/null
+++ b/test/aes192ctr_encrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes192ctr_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes192_Key key;
+ AesNI_Aes192_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes192_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 192-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes192_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes192_encrypt_block_ctr(plaintext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes192ecb_decrypt_block.c b/test/aes192ecb_decrypt_block.c
new file mode 100644
index 0000000..bbaaf47
--- /dev/null
+++ b/test/aes192ecb_decrypt_block.c
@@ -0,0 +1,57 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes192ecb_decrypt_block.exe KEY0 [CIPHERTEXT0...] [-- KEY1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext;
+ AesNI_Aes192_Key key;
+ AesNI_Aes192_RoundKeys encryption_keys, decryption_keys;
+
+ if (argc < 1)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes192_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ aesni_aes192_expand_key(&key, &encryption_keys);
+ aesni_aes192_derive_decryption_keys(&encryption_keys, &decryption_keys);
+
+ for (--argc, ++argv; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes192_decrypt_block_ecb(ciphertext, &decryption_keys);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes192ecb_encrypt_block.c b/test/aes192ecb_encrypt_block.c
new file mode 100644
index 0000000..87241df
--- /dev/null
+++ b/test/aes192ecb_encrypt_block.c
@@ -0,0 +1,56 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes192ecb_encrypt_block.exe KEY0 [PLAINTEXT0...] [-- KEY1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext;
+ AesNI_Aes192_Key key;
+ AesNI_Aes192_RoundKeys encryption_keys;
+
+ if (argc < 1)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes192_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 192-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ aesni_aes192_expand_key(&key, &encryption_keys);
+
+ for (--argc, ++argv; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes192_encrypt_block_ecb(plaintext, &encryption_keys);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes192ofb_decrypt_block.c b/test/aes192ofb_decrypt_block.c
new file mode 100644
index 0000000..b202e41
--- /dev/null
+++ b/test/aes192ofb_decrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes192ofb_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes192_Key key;
+ AesNI_Aes192_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes192_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 192-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes192_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes192_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes192ofb_encrypt_block.c b/test/aes192ofb_encrypt_block.c
new file mode 100644
index 0000000..4416be8
--- /dev/null
+++ b/test/aes192ofb_encrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes192ofb_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes192_Key key;
+ AesNI_Aes192_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes192_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 192-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes192_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes192_encrypt_block_ofb(plaintext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes256cbc_decrypt_block.c b/test/aes256cbc_decrypt_block.c
new file mode 100644
index 0000000..8a2cbe1
--- /dev/null
+++ b/test/aes256cbc_decrypt_block.c
@@ -0,0 +1,63 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes256cbc_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes256_Key key;
+ AesNI_Aes256_RoundKeys encryption_keys, decryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes256_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 256-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes256_expand_key(&key, &encryption_keys);
+ aesni_aes256_derive_decryption_keys(&encryption_keys, &decryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes256_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &iv);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes256cbc_encrypt_block.c b/test/aes256cbc_encrypt_block.c
new file mode 100644
index 0000000..d99c203
--- /dev/null
+++ b/test/aes256cbc_encrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes256cbc_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes256_Key key;
+ AesNI_Aes256_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes256_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 256-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes256_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes256_encrypt_block_cbc(plaintext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes256cfb_decrypt_block.c b/test/aes256cfb_decrypt_block.c
new file mode 100644
index 0000000..bdaf1dd
--- /dev/null
+++ b/test/aes256cfb_decrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes256cfb_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes256_Key key;
+ AesNI_Aes256_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes256_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 256-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes256_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes256_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes256cfb_encrypt_block.c b/test/aes256cfb_encrypt_block.c
new file mode 100644
index 0000000..a31effc
--- /dev/null
+++ b/test/aes256cfb_encrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes256cfb_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes256_Key key;
+ AesNI_Aes256_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes256_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 256-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes256_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes256_encrypt_block_cfb(plaintext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes256ctr_decrypt_block.c b/test/aes256ctr_decrypt_block.c
new file mode 100644
index 0000000..2a1fc8f
--- /dev/null
+++ b/test/aes256ctr_decrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes256ctr_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes256_Key key;
+ AesNI_Aes256_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes256_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 256-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes256_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes256_decrypt_block_ctr(ciphertext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes256ctr_encrypt_block.c b/test/aes256ctr_encrypt_block.c
new file mode 100644
index 0000000..6ca8e2f
--- /dev/null
+++ b/test/aes256ctr_encrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes256ctr_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes256_Key key;
+ AesNI_Aes256_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes256_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 256-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes256_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes256_encrypt_block_ctr(plaintext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes256ecb_decrypt_block.c b/test/aes256ecb_decrypt_block.c
new file mode 100644
index 0000000..8439044
--- /dev/null
+++ b/test/aes256ecb_decrypt_block.c
@@ -0,0 +1,57 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes256ecb_decrypt_block.exe KEY0 [CIPHERTEXT0...] [-- KEY1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext;
+ AesNI_Aes256_Key key;
+ AesNI_Aes256_RoundKeys encryption_keys, decryption_keys;
+
+ if (argc < 1)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes256_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 256-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ aesni_aes256_expand_key(&key, &encryption_keys);
+ aesni_aes256_derive_decryption_keys(&encryption_keys, &decryption_keys);
+
+ for (--argc, ++argv; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes256_decrypt_block_ecb(ciphertext, &decryption_keys);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes256ecb_encrypt_block.c b/test/aes256ecb_encrypt_block.c
new file mode 100644
index 0000000..a8da243
--- /dev/null
+++ b/test/aes256ecb_encrypt_block.c
@@ -0,0 +1,56 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes256ecb_encrypt_block.exe KEY0 [PLAINTEXT0...] [-- KEY1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext;
+ AesNI_Aes256_Key key;
+ AesNI_Aes256_RoundKeys encryption_keys;
+
+ if (argc < 1)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes256_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 256-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ aesni_aes256_expand_key(&key, &encryption_keys);
+
+ for (--argc, ++argv; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes256_encrypt_block_ecb(plaintext, &encryption_keys);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes256ofb_decrypt_block.c b/test/aes256ofb_decrypt_block.c
new file mode 100644
index 0000000..9d4cc36
--- /dev/null
+++ b/test/aes256ofb_decrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes256ofb_decrypt_block.exe KEY0 IV0 [CIPHERTEXT0...] [-- KEY1 IV1 [CIPHERTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes256_Key key;
+ AesNI_Aes256_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes256_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 256-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes256_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&ciphertext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ plaintext = aesni_aes256_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&plaintext, NULL);
+ }
+ }
+
+ return 0;
+}
diff --git a/test/aes256ofb_encrypt_block.c b/test/aes256ofb_encrypt_block.c
new file mode 100644
index 0000000..0018e9a
--- /dev/null
+++ b/test/aes256ofb_encrypt_block.c
@@ -0,0 +1,62 @@
+/**
+ * \file
+ * \author Egor Tensin <Egor.Tensin@gmail.com>
+ * \date 2015
+ * \copyright This file is licensed under the terms of the MIT License.
+ * See LICENSE.txt for details.
+ */
+
+#include <aesni/all.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static void exit_with_usage()
+{
+ puts("Usage: aes256ofb_encrypt_block.exe KEY0 IV0 [PLAINTEXT0...] [-- KEY1 IV1 [PLAINTEXT1...]...]");
+ exit(EXIT_FAILURE);
+}
+
+int main(int argc, char** argv)
+{
+ for (--argc, ++argv; argc > -1; --argc, ++argv)
+ {
+ AesNI_Block128 plaintext, ciphertext, iv;
+ AesNI_Aes256_Key key;
+ AesNI_Aes256_RoundKeys encryption_keys;
+
+ if (argc < 2)
+ exit_with_usage();
+
+ if (aesni_is_error(aesni_aes256_parse_key(&key, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 256-bit AES block '%s'\n", *argv);
+ exit_with_usage();
+ }
+
+ if (aesni_is_error(aesni_aes_parse_block(&iv, argv[1], NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", argv[1]);
+ exit_with_usage();
+ }
+
+ aesni_aes256_expand_key(&key, &encryption_keys);
+
+ for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
+ {
+ if (strcmp("--", *argv) == 0)
+ break;
+
+ if (aesni_is_error(aesni_aes_parse_block(&plaintext, *argv, NULL)))
+ {
+ fprintf(stderr, "Invalid 128-bit AES block '%s'\n", *argv);
+ continue;
+ }
+ ciphertext = aesni_aes256_encrypt_block_ofb(plaintext, &encryption_keys, iv, &iv);
+ aesni_aes_print_block(&ciphertext, NULL);
+ }
+ }
+
+ return 0;
+}