aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils/block
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-06-25 05:10:40 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-06-25 05:10:40 +0300
commit8ebebf9f27070bccd4df8949aadf4ca2860bf4b1 (patch)
tree9c1c9519dcbaf6cbaabeef3d6785b2d1b7f153ca /utils/block
parentcxx: import more stuff (diff)
downloadaes-tools-8ebebf9f27070bccd4df8949aadf4ca2860bf4b1.tar.gz
aes-tools-8ebebf9f27070bccd4df8949aadf4ca2860bf4b1.zip
merge specialized block utils into general ones
... taking advantage of the new template interface.
Diffstat (limited to 'utils/block')
-rw-r--r--utils/block/CMakeLists.txt34
-rw-r--r--utils/block/README.md (renamed from utils/block/cxx/README.md)0
-rw-r--r--utils/block/aes128cbc_decrypt_block.c76
-rw-r--r--utils/block/aes128cbc_encrypt_block.c75
-rw-r--r--utils/block/aes128cfb_decrypt_block.c75
-rw-r--r--utils/block/aes128cfb_encrypt_block.c75
-rw-r--r--utils/block/aes128ctr_decrypt_block.c75
-rw-r--r--utils/block/aes128ctr_encrypt_block.c75
-rw-r--r--utils/block/aes128ecb_decrypt_block.c70
-rw-r--r--utils/block/aes128ecb_encrypt_block.c69
-rw-r--r--utils/block/aes128ofb_decrypt_block.c75
-rw-r--r--utils/block/aes128ofb_encrypt_block.c75
-rw-r--r--utils/block/aes192cbc_decrypt_block.c76
-rw-r--r--utils/block/aes192cbc_encrypt_block.c75
-rw-r--r--utils/block/aes192cfb_decrypt_block.c75
-rw-r--r--utils/block/aes192cfb_encrypt_block.c75
-rw-r--r--utils/block/aes192ctr_decrypt_block.c75
-rw-r--r--utils/block/aes192ctr_encrypt_block.c75
-rw-r--r--utils/block/aes192ecb_decrypt_block.c70
-rw-r--r--utils/block/aes192ecb_encrypt_block.c69
-rw-r--r--utils/block/aes192ofb_decrypt_block.c75
-rw-r--r--utils/block/aes192ofb_encrypt_block.c75
-rw-r--r--utils/block/aes256cbc_decrypt_block.c76
-rw-r--r--utils/block/aes256cbc_encrypt_block.c75
-rw-r--r--utils/block/aes256cfb_decrypt_block.c75
-rw-r--r--utils/block/aes256cfb_encrypt_block.c75
-rw-r--r--utils/block/aes256ctr_decrypt_block.c75
-rw-r--r--utils/block/aes256ctr_encrypt_block.c75
-rw-r--r--utils/block/aes256ecb_decrypt_block.c70
-rw-r--r--utils/block/aes256ecb_encrypt_block.c69
-rw-r--r--utils/block/aes256ofb_decrypt_block.c75
-rw-r--r--utils/block/aes256ofb_encrypt_block.c75
-rw-r--r--utils/block/aes_common.hpp (renamed from utils/block/cxx/aes_common.hpp)8
-rw-r--r--utils/block/aes_decrypt_block.cpp234
-rw-r--r--utils/block/aes_encrypt_block.cpp234
-rw-r--r--utils/block/cxx/CMakeLists.txt11
-rw-r--r--utils/block/cxx/aes_decrypt_block.cpp122
-rw-r--r--utils/block/cxx/aes_encrypt_block.cpp122
38 files changed, 485 insertions, 2500 deletions
diff --git a/utils/block/CMakeLists.txt b/utils/block/CMakeLists.txt
index 4b232bd..8df91d0 100644
--- a/utils/block/CMakeLists.txt
+++ b/utils/block/CMakeLists.txt
@@ -1,27 +1,11 @@
-macro(util prefix)
- add_executable(util_${prefix}_encrypt_block ${prefix}_encrypt_block.c)
- target_link_libraries(util_${prefix}_encrypt_block libaesni)
- set_target_properties(util_${prefix}_encrypt_block PROPERTIES OUTPUT_NAME ${prefix}_encrypt_block)
+find_package(Boost REQUIRED COMPONENTS program_options)
- add_executable(util_${prefix}_decrypt_block ${prefix}_decrypt_block.c)
- target_link_libraries(util_${prefix}_decrypt_block libaesni)
- set_target_properties(util_${prefix}_decrypt_block PROPERTIES OUTPUT_NAME ${prefix}_decrypt_block)
-endmacro()
+add_executable(util_aes_encrypt_block aes_encrypt_block.cpp aes_common.hpp)
+target_include_directories(util_aes_encrypt_block PRIVATE ${Boost_INCLUDE_DIRS})
+target_link_libraries(util_aes_encrypt_block libaesni libaesnixx ${Boost_LIBRARIES})
+set_target_properties(util_aes_encrypt_block PROPERTIES OUTPUT_NAME aes_encrypt_block)
-util(aes128ecb)
-util(aes128cbc)
-util(aes128cfb)
-util(aes128ofb)
-util(aes128ctr)
-util(aes192ecb)
-util(aes192cbc)
-util(aes192cfb)
-util(aes192ofb)
-util(aes192ctr)
-util(aes256ecb)
-util(aes256cbc)
-util(aes256cfb)
-util(aes256ofb)
-util(aes256ctr)
-
-add_subdirectory(cxx)
+add_executable(util_aes_decrypt_block aes_decrypt_block.cpp aes_common.hpp)
+target_include_directories(util_aes_decrypt_block PRIVATE ${Boost_INCLUDE_DIRS})
+target_link_libraries(util_aes_decrypt_block libaesni libaesnixx ${Boost_LIBRARIES})
+set_target_properties(util_aes_decrypt_block PROPERTIES OUTPUT_NAME aes_decrypt_block)
diff --git a/utils/block/cxx/README.md b/utils/block/README.md
index bce2434..bce2434 100644
--- a/utils/block/cxx/README.md
+++ b/utils/block/README.md
diff --git a/utils/block/aes128cbc_decrypt_block.c b/utils/block/aes128cbc_decrypt_block.c
deleted file mode 100644
index 95120e7..0000000
--- a/utils/block/aes128cbc_decrypt_block.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes128_Key key;
- AesNI_Aes128_RoundKeys encryption_keys, decryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes128_expand_key(&key, &encryption_keys);
- aesni_aes128_derive_decryption_keys(&encryption_keys, &decryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes128_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes128cbc_encrypt_block.c b/utils/block/aes128cbc_encrypt_block.c
deleted file mode 100644
index 68f95a3..0000000
--- a/utils/block/aes128cbc_encrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes128_Key key;
- AesNI_Aes128_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes128_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes128_encrypt_block_cbc(plaintext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes128cfb_decrypt_block.c b/utils/block/aes128cfb_decrypt_block.c
deleted file mode 100644
index ef68e44..0000000
--- a/utils/block/aes128cfb_decrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes128_Key key;
- AesNI_Aes128_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes128_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes128_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes128cfb_encrypt_block.c b/utils/block/aes128cfb_encrypt_block.c
deleted file mode 100644
index 6f8fb4d..0000000
--- a/utils/block/aes128cfb_encrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes128_Key key;
- AesNI_Aes128_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes128_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes128_encrypt_block_cfb(plaintext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes128ctr_decrypt_block.c b/utils/block/aes128ctr_decrypt_block.c
deleted file mode 100644
index 85d07f5..0000000
--- a/utils/block/aes128ctr_decrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes128_Key key;
- AesNI_Aes128_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes128_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes128_decrypt_block_ctr(ciphertext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes128ctr_encrypt_block.c b/utils/block/aes128ctr_encrypt_block.c
deleted file mode 100644
index a62f3cd..0000000
--- a/utils/block/aes128ctr_encrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes128_Key key;
- AesNI_Aes128_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes128_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes128_encrypt_block_ctr(plaintext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes128ecb_decrypt_block.c b/utils/block/aes128ecb_decrypt_block.c
deleted file mode 100644
index 9fbf26d..0000000
--- a/utils/block/aes128ecb_decrypt_block.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext;
- AesNI_Aes128_Key key;
- AesNI_Aes128_RoundKeys encryption_keys, decryption_keys;
-
- if (argc < 1)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes128_expand_key(&key, &encryption_keys);
- aesni_aes128_derive_decryption_keys(&encryption_keys, &decryption_keys);
-
- for (--argc, ++argv; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes128_decrypt_block_ecb(ciphertext, &decryption_keys);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes128ecb_encrypt_block.c b/utils/block/aes128ecb_encrypt_block.c
deleted file mode 100644
index 45a1123..0000000
--- a/utils/block/aes128ecb_encrypt_block.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext;
- AesNI_Aes128_Key key;
- AesNI_Aes128_RoundKeys encryption_keys;
-
- if (argc < 1)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes128_expand_key(&key, &encryption_keys);
-
- for (--argc, ++argv; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, &encryption_keys);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes128ofb_decrypt_block.c b/utils/block/aes128ofb_decrypt_block.c
deleted file mode 100644
index e61e70f..0000000
--- a/utils/block/aes128ofb_decrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes128_Key key;
- AesNI_Aes128_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes128_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes128_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes128ofb_encrypt_block.c b/utils/block/aes128ofb_encrypt_block.c
deleted file mode 100644
index 6613ca9..0000000
--- a/utils/block/aes128ofb_encrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes128_Key key;
- AesNI_Aes128_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes128_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes128_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes128_encrypt_block_ofb(plaintext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes192cbc_decrypt_block.c b/utils/block/aes192cbc_decrypt_block.c
deleted file mode 100644
index 13edbe4..0000000
--- a/utils/block/aes192cbc_decrypt_block.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes192_Key key;
- AesNI_Aes192_RoundKeys encryption_keys, decryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes192_expand_key(&key, &encryption_keys);
- aesni_aes192_derive_decryption_keys(&encryption_keys, &decryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes192_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes192cbc_encrypt_block.c b/utils/block/aes192cbc_encrypt_block.c
deleted file mode 100644
index d89c12d..0000000
--- a/utils/block/aes192cbc_encrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes192_Key key;
- AesNI_Aes192_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes192_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes192_encrypt_block_cbc(plaintext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes192cfb_decrypt_block.c b/utils/block/aes192cfb_decrypt_block.c
deleted file mode 100644
index cedc7d0..0000000
--- a/utils/block/aes192cfb_decrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes192_Key key;
- AesNI_Aes192_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes192_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes192_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes192cfb_encrypt_block.c b/utils/block/aes192cfb_encrypt_block.c
deleted file mode 100644
index 357df8d..0000000
--- a/utils/block/aes192cfb_encrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes192_Key key;
- AesNI_Aes192_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes192_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes192_encrypt_block_cfb(plaintext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes192ctr_decrypt_block.c b/utils/block/aes192ctr_decrypt_block.c
deleted file mode 100644
index b094964..0000000
--- a/utils/block/aes192ctr_decrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes192_Key key;
- AesNI_Aes192_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes192_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes192_decrypt_block_ctr(ciphertext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes192ctr_encrypt_block.c b/utils/block/aes192ctr_encrypt_block.c
deleted file mode 100644
index 977c7bf..0000000
--- a/utils/block/aes192ctr_encrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes192_Key key;
- AesNI_Aes192_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes192_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes192_encrypt_block_ctr(plaintext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes192ecb_decrypt_block.c b/utils/block/aes192ecb_decrypt_block.c
deleted file mode 100644
index 29e7274..0000000
--- a/utils/block/aes192ecb_decrypt_block.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext;
- AesNI_Aes192_Key key;
- AesNI_Aes192_RoundKeys encryption_keys, decryption_keys;
-
- if (argc < 1)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes192_expand_key(&key, &encryption_keys);
- aesni_aes192_derive_decryption_keys(&encryption_keys, &decryption_keys);
-
- for (--argc, ++argv; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes192_decrypt_block_ecb(ciphertext, &decryption_keys);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes192ecb_encrypt_block.c b/utils/block/aes192ecb_encrypt_block.c
deleted file mode 100644
index a74759c..0000000
--- a/utils/block/aes192ecb_encrypt_block.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext;
- AesNI_Aes192_Key key;
- AesNI_Aes192_RoundKeys encryption_keys;
-
- if (argc < 1)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes192_expand_key(&key, &encryption_keys);
-
- for (--argc, ++argv; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes192_encrypt_block_ecb(plaintext, &encryption_keys);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes192ofb_decrypt_block.c b/utils/block/aes192ofb_decrypt_block.c
deleted file mode 100644
index eaa9d2a..0000000
--- a/utils/block/aes192ofb_decrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes192_Key key;
- AesNI_Aes192_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes192_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes192_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes192ofb_encrypt_block.c b/utils/block/aes192ofb_encrypt_block.c
deleted file mode 100644
index fed0c5a..0000000
--- a/utils/block/aes192ofb_encrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes192_Key key;
- AesNI_Aes192_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes192_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes192_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes192_encrypt_block_ofb(plaintext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes256cbc_decrypt_block.c b/utils/block/aes256cbc_decrypt_block.c
deleted file mode 100644
index 0021007..0000000
--- a/utils/block/aes256cbc_decrypt_block.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes256_Key key;
- AesNI_Aes256_RoundKeys encryption_keys, decryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes256_expand_key(&key, &encryption_keys);
- aesni_aes256_derive_decryption_keys(&encryption_keys, &decryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes256_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes256cbc_encrypt_block.c b/utils/block/aes256cbc_encrypt_block.c
deleted file mode 100644
index e01ab95..0000000
--- a/utils/block/aes256cbc_encrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes256_Key key;
- AesNI_Aes256_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes256_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes256_encrypt_block_cbc(plaintext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes256cfb_decrypt_block.c b/utils/block/aes256cfb_decrypt_block.c
deleted file mode 100644
index 9d320a5..0000000
--- a/utils/block/aes256cfb_decrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes256_Key key;
- AesNI_Aes256_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes256_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes256_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes256cfb_encrypt_block.c b/utils/block/aes256cfb_encrypt_block.c
deleted file mode 100644
index 94e8619..0000000
--- a/utils/block/aes256cfb_encrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes256_Key key;
- AesNI_Aes256_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes256_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes256_encrypt_block_cfb(plaintext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes256ctr_decrypt_block.c b/utils/block/aes256ctr_decrypt_block.c
deleted file mode 100644
index a0f9ef0..0000000
--- a/utils/block/aes256ctr_decrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes256_Key key;
- AesNI_Aes256_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes256_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes256_decrypt_block_ctr(ciphertext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes256ctr_encrypt_block.c b/utils/block/aes256ctr_encrypt_block.c
deleted file mode 100644
index fbae884..0000000
--- a/utils/block/aes256ctr_encrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes256_Key key;
- AesNI_Aes256_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes256_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes256_encrypt_block_ctr(plaintext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes256ecb_decrypt_block.c b/utils/block/aes256ecb_decrypt_block.c
deleted file mode 100644
index 16ffe77..0000000
--- a/utils/block/aes256ecb_decrypt_block.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext;
- AesNI_Aes256_Key key;
- AesNI_Aes256_RoundKeys encryption_keys, decryption_keys;
-
- if (argc < 1)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes256_expand_key(&key, &encryption_keys);
- aesni_aes256_derive_decryption_keys(&encryption_keys, &decryption_keys);
-
- for (--argc, ++argv; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes256_decrypt_block_ecb(ciphertext, &decryption_keys);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes256ecb_encrypt_block.c b/utils/block/aes256ecb_encrypt_block.c
deleted file mode 100644
index 01ae7ed..0000000
--- a/utils/block/aes256ecb_encrypt_block.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext;
- AesNI_Aes256_Key key;
- AesNI_Aes256_RoundKeys encryption_keys;
-
- if (argc < 1)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes256_expand_key(&key, &encryption_keys);
-
- for (--argc, ++argv; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes256_encrypt_block_ecb(plaintext, &encryption_keys);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes256ofb_decrypt_block.c b/utils/block/aes256ofb_decrypt_block.c
deleted file mode 100644
index a57c8db..0000000
--- a/utils/block/aes256ofb_decrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes256_Key key;
- AesNI_Aes256_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes256_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&ciphertext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- plaintext = aesni_aes256_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&plaintext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/aes256ofb_encrypt_block.c b/utils/block/aes256ofb_encrypt_block.c
deleted file mode 100644
index 7dc01b8..0000000
--- a/utils/block/aes256ofb_encrypt_block.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * \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);
-}
-
-static void print_error(AesNI_StatusCode status)
-{
- fprintf(stderr, "AesNI error: %s\n", aesni_strerror(status));
-}
-
-int main(int argc, char** argv)
-{
- AesNI_StatusCode status = AESNI_SUCCESS;
-
- for (--argc, ++argv; argc > -1; --argc, ++argv)
- {
- AesNI_Block128 plaintext, ciphertext, iv;
- AesNI_Aes256_Key key;
- AesNI_Aes256_RoundKeys encryption_keys;
-
- if (argc < 2)
- exit_with_usage();
-
- if (aesni_is_error(status = aesni_aes256_parse_key(&key, *argv, NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- if (aesni_is_error(status = aesni_aes_parse_block(&iv, argv[1], NULL)))
- {
- print_error(status);
- exit_with_usage();
- }
-
- aesni_aes256_expand_key(&key, &encryption_keys);
-
- for (argc -= 2, argv += 2; argc > 0; --argc, ++argv)
- {
- if (strcmp("--", *argv) == 0)
- break;
-
- if (aesni_is_error(status = aesni_aes_parse_block(&plaintext, *argv, NULL)))
- {
- print_error(status);
- continue;
- }
-
- ciphertext = aesni_aes256_encrypt_block_ofb(plaintext, &encryption_keys, iv, &iv);
-
- if (aesni_is_error(status = aesni_aes_print_block(&ciphertext, NULL)))
- {
- print_error(status);
- continue;
- }
- }
- }
-
- return 0;
-}
diff --git a/utils/block/cxx/aes_common.hpp b/utils/block/aes_common.hpp
index cd5d669..327efad 100644
--- a/utils/block/cxx/aes_common.hpp
+++ b/utils/block/aes_common.hpp
@@ -68,6 +68,7 @@ namespace
CommandLineParser(const std::string& program_name)
: m_program_name(program_name)
, m_options("Options")
+ , m_boxes(false)
{ }
bool parse_options(int argc, char** argv)
@@ -76,6 +77,7 @@ namespace
m_options.add_options()
("help,h", "show this message and exit")
+ ("box,b", po::bool_switch(&m_boxes)->default_value(false), "use the \"boxes\" interface")
("mode,m", po::value<aesni::Mode>(&m_mode)->required(), "set mode of operation")
("algorithm,a", po::value<aesni::Algorithm>(&m_algorithm)->required(), "set algorithm");
@@ -118,6 +120,11 @@ namespace
return m_algorithm;
}
+ bool use_boxes() const
+ {
+ return m_boxes;
+ }
+
std::deque<std::string> get_args()
{
return { std::make_move_iterator(m_args.begin()), std::make_move_iterator(m_args.end()) };
@@ -129,6 +136,7 @@ namespace
aesni::Mode m_mode;
aesni::Algorithm m_algorithm;
+ bool m_boxes;
std::vector<std::string> m_args;
};
}
diff --git a/utils/block/aes_decrypt_block.cpp b/utils/block/aes_decrypt_block.cpp
new file mode 100644
index 0000000..a8a39f4
--- /dev/null
+++ b/utils/block/aes_decrypt_block.cpp
@@ -0,0 +1,234 @@
+/**
+ * \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 "aes_common.hpp"
+
+#include <aesni/all.h>
+
+#include <aesnixx/all.hpp>
+
+#include <deque>
+#include <exception>
+#include <iostream>
+#include <string>
+
+namespace
+{
+ template <aesni::Algorithm algorithm, aesni::Mode mode>
+ bool decrypt_with_mode(
+ const std::string& key_str,
+ std::deque<std::string>& ciphertexts)
+ {
+ typename aesni::aes::Types<algorithm>::BlockT iv;
+
+ if (aesni::ModeRequiresInitializationVector<mode>())
+ {
+ if (ciphertexts.empty())
+ return false;
+
+ aesni::aes::from_string(iv, ciphertexts.front());
+ ciphertexts.pop_front();
+ }
+
+ typename aesni::aes::Types<algorithm>::KeyT key;
+ aesni::aes::from_string(key, key_str);
+
+ aesni::aes::Encrypt<algorithm, mode> encrypt(key, iv);
+
+ while (!ciphertexts.empty())
+ {
+ typename aesni::aes::Types<algorithm>::BlockT ciphertext;
+ aesni::aes::from_string(ciphertext, ciphertexts.front());
+ ciphertexts.pop_front();
+
+ std::cout << aesni::aes::to_string(encrypt.decrypt(ciphertext)) << "\n";
+ }
+
+ return true;
+ }
+
+ template <aesni::Algorithm algorithm>
+ bool decrypt_with_algorithm(
+ aesni::Mode mode,
+ const std::string& key_str,
+ std::deque<std::string>& ciphertexts)
+ {
+ switch (mode)
+ {
+ case AESNI_ECB:
+ return decrypt_with_mode<algorithm, AESNI_ECB>(key_str, ciphertexts);
+
+ case AESNI_CBC:
+ return decrypt_with_mode<algorithm, AESNI_CBC>(key_str, ciphertexts);
+
+ case AESNI_CFB:
+ return decrypt_with_mode<algorithm, AESNI_CFB>(key_str, ciphertexts);
+
+ case AESNI_OFB:
+ return decrypt_with_mode<algorithm, AESNI_OFB>(key_str, ciphertexts);
+
+ case AESNI_CTR:
+ return decrypt_with_mode<algorithm, AESNI_CTR>(key_str, ciphertexts);
+
+ default:
+ return false;
+ }
+ }
+
+ bool decrypt(
+ aesni::Algorithm algorithm,
+ aesni::Mode mode,
+ const std::string& key_str,
+ std::deque<std::string> ciphertexts)
+ {
+ switch (algorithm)
+ {
+ case AESNI_AES128:
+ return decrypt_with_algorithm<AESNI_AES128>(mode, key_str, ciphertexts);
+
+ case AESNI_AES192:
+ return decrypt_with_algorithm<AESNI_AES192>(mode, key_str, ciphertexts);
+
+ case AESNI_AES256:
+ return decrypt_with_algorithm<AESNI_AES256>(mode, key_str, ciphertexts);
+
+ default:
+ return false;
+ }
+ }
+
+ bool decrypt_using_boxes(
+ aesni::Algorithm algorithm,
+ aesni::Mode mode,
+ const std::string& key,
+ std::deque<std::string> ciphertexts)
+ {
+ AesNI_BoxAlgorithmParams algorithm_params;
+
+ switch (algorithm)
+ {
+ case AESNI_AES128:
+ aesni::aes::from_string(algorithm_params.aes128_key, key);
+ break;
+
+ case AESNI_AES192:
+ aesni::aes::from_string(algorithm_params.aes192_key, key);
+ break;
+
+ case AESNI_AES256:
+ aesni::aes::from_string(algorithm_params.aes256_key, key);
+ break;
+
+ default:
+ return false;
+ }
+
+ AesNI_BoxBlock iv;
+ AesNI_BoxBlock* iv_ptr = nullptr;
+
+ if (aesni::mode_requires_initialization_vector(mode))
+ {
+ if (ciphertexts.empty())
+ return false;
+
+ aesni::aes::from_string(iv.aes_block, ciphertexts.front());
+ iv_ptr = &iv;
+ ciphertexts.pop_front();
+ }
+
+ AesNI_Box box;
+ aesni_box_init(
+ &box,
+ algorithm,
+ &algorithm_params,
+ mode,
+ iv_ptr,
+ aesni::ErrorDetailsThrowsInDestructor());
+
+ while (!ciphertexts.empty())
+ {
+ AesNI_BoxBlock ciphertext;
+ aesni::aes::from_string(ciphertext.aes_block, ciphertexts.front());
+ ciphertexts.pop_front();
+
+ AesNI_BoxBlock plaintext;
+ aesni_box_decrypt_block(
+ &box,
+ &ciphertext,
+ &plaintext,
+ aesni::ErrorDetailsThrowsInDestructor());
+
+ std::cout << aesni::aes::to_string(plaintext.aes_block) << "\n";
+ }
+
+ return true;
+ }
+}
+
+int main(int argc, char** argv)
+{
+ try
+ {
+ CommandLineParser cmd_parser("aes_decrypt_block.exe");
+
+ if (!cmd_parser.parse_options(argc, argv))
+ return 0;
+
+ const auto algorithm = cmd_parser.get_algorithm();
+ const auto mode = cmd_parser.get_mode();
+
+ auto args = cmd_parser.get_args();
+
+ while (!args.empty())
+ {
+ const auto key = args.front();
+ args.pop_front();
+
+ std::deque<std::string> ciphertexts;
+
+ while (!args.empty())
+ {
+ if (args.front() == "--")
+ {
+ args.pop_front();
+ break;
+ }
+
+ ciphertexts.push_back(args.front());
+ args.pop_front();
+ }
+
+ const auto success = cmd_parser.use_boxes()
+ ? decrypt_using_boxes(algorithm, mode, key, ciphertexts)
+ : decrypt(algorithm, mode, key, ciphertexts);
+
+ if (!success)
+ {
+ cmd_parser.print_usage();
+ return 1;
+ }
+ }
+
+ return 0;
+ }
+ catch (const boost::program_options::error& e)
+ {
+ std::cerr << "Usage error: " << e.what() << "\n";
+ return 1;
+ }
+ catch (const aesni::Error& e)
+ {
+ std::cerr << e;
+ return 1;
+ }
+ catch (const std::exception& e)
+ {
+ std::cerr << e.what() << "\n";
+ return 1;
+ }
+}
diff --git a/utils/block/aes_encrypt_block.cpp b/utils/block/aes_encrypt_block.cpp
new file mode 100644
index 0000000..3b0e837
--- /dev/null
+++ b/utils/block/aes_encrypt_block.cpp
@@ -0,0 +1,234 @@
+/**
+ * \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 "aes_common.hpp"
+
+#include <aesni/all.h>
+
+#include <aesnixx/all.hpp>
+
+#include <deque>
+#include <exception>
+#include <iostream>
+#include <string>
+
+namespace
+{
+ template <aesni::Algorithm algorithm, aesni::Mode mode>
+ bool encrypt_with_mode(
+ const std::string& key_str,
+ std::deque<std::string>& plaintexts)
+ {
+ typename aesni::aes::Types<algorithm>::BlockT iv;
+
+ if (aesni::ModeRequiresInitializationVector<mode>())
+ {
+ if (plaintexts.empty())
+ return false;
+
+ aesni::aes::from_string(iv, plaintexts.front());
+ plaintexts.pop_front();
+ }
+
+ typename aesni::aes::Types<algorithm>::KeyT key;
+ aesni::aes::from_string(key, key_str);
+
+ aesni::aes::Encrypt<algorithm, mode> encrypt(key, iv);
+
+ while (!plaintexts.empty())
+ {
+ typename aesni::aes::Types<algorithm>::BlockT plaintext;
+ aesni::aes::from_string(plaintext, plaintexts.front());
+ plaintexts.pop_front();
+
+ std::cout << aesni::aes::to_string(encrypt.encrypt(plaintext)) << "\n";
+ }
+
+ return true;
+ }
+
+ template <aesni::Algorithm algorithm>
+ bool encrypt_with_algorithm(
+ aesni::Mode mode,
+ const std::string& key_str,
+ std::deque<std::string>& plaintexts)
+ {
+ switch (mode)
+ {
+ case AESNI_ECB:
+ return encrypt_with_mode<algorithm, AESNI_ECB>(key_str, plaintexts);
+
+ case AESNI_CBC:
+ return encrypt_with_mode<algorithm, AESNI_CBC>(key_str, plaintexts);
+
+ case AESNI_CFB:
+ return encrypt_with_mode<algorithm, AESNI_CFB>(key_str, plaintexts);
+
+ case AESNI_OFB:
+ return encrypt_with_mode<algorithm, AESNI_OFB>(key_str, plaintexts);
+
+ case AESNI_CTR:
+ return encrypt_with_mode<algorithm, AESNI_CTR>(key_str, plaintexts);
+
+ default:
+ return false;
+ }
+ }
+
+ bool encrypt(
+ aesni::Algorithm algorithm,
+ aesni::Mode mode,
+ const std::string& key_str,
+ std::deque<std::string> plaintexts)
+ {
+ switch (algorithm)
+ {
+ case AESNI_AES128:
+ return encrypt_with_algorithm<AESNI_AES128>(mode, key_str, plaintexts);
+
+ case AESNI_AES192:
+ return encrypt_with_algorithm<AESNI_AES192>(mode, key_str, plaintexts);
+
+ case AESNI_AES256:
+ return encrypt_with_algorithm<AESNI_AES256>(mode, key_str, plaintexts);
+
+ default:
+ return false;
+ }
+ }
+
+ bool encrypt_using_boxes(
+ aesni::Algorithm algorithm,
+ aesni::Mode mode,
+ const std::string& key,
+ std::deque<std::string> plaintexts)
+ {
+ AesNI_BoxAlgorithmParams algorithm_params;
+
+ switch (algorithm)
+ {
+ case AESNI_AES128:
+ aesni::aes::from_string(algorithm_params.aes128_key, key);
+ break;
+
+ case AESNI_AES192:
+ aesni::aes::from_string(algorithm_params.aes192_key, key);
+ break;
+
+ case AESNI_AES256:
+ aesni::aes::from_string(algorithm_params.aes256_key, key);
+ break;
+
+ default:
+ return false;
+ }
+
+ AesNI_BoxBlock iv;
+ AesNI_BoxBlock* iv_ptr = nullptr;
+
+ if (aesni::mode_requires_initialization_vector(mode))
+ {
+ if (plaintexts.empty())
+ return false;
+
+ aesni::aes::from_string(iv.aes_block, plaintexts.front());
+ iv_ptr = &iv;
+ plaintexts.pop_front();
+ }
+
+ AesNI_Box box;
+ aesni_box_init(
+ &box,
+ algorithm,
+ &algorithm_params,
+ mode,
+ iv_ptr,
+ aesni::ErrorDetailsThrowsInDestructor());
+
+ while (!plaintexts.empty())
+ {
+ AesNI_BoxBlock plaintext;
+ aesni::aes::from_string(plaintext.aes_block, plaintexts.front());
+ plaintexts.pop_front();
+
+ AesNI_BoxBlock ciphertext;
+ aesni_box_encrypt_block(
+ &box,
+ &plaintext,
+ &ciphertext,
+ aesni::ErrorDetailsThrowsInDestructor());
+
+ std::cout << aesni::aes::to_string(ciphertext.aes_block) << "\n";
+ }
+
+ return true;
+ }
+}
+
+int main(int argc, char** argv)
+{
+ try
+ {
+ CommandLineParser cmd_parser("aes_encrypt_block.exe");
+
+ if (!cmd_parser.parse_options(argc, argv))
+ return 0;
+
+ const auto algorithm = cmd_parser.get_algorithm();
+ const auto mode = cmd_parser.get_mode();
+
+ auto args = cmd_parser.get_args();
+
+ while (!args.empty())
+ {
+ const auto key = args.front();
+ args.pop_front();
+
+ std::deque<std::string> plaintexts;
+
+ while (!args.empty())
+ {
+ if (args.front() == "--")
+ {
+ args.pop_front();
+ break;
+ }
+
+ plaintexts.push_back(args.front());
+ args.pop_front();
+ }
+
+ const auto success = cmd_parser.use_boxes()
+ ? encrypt_using_boxes(algorithm, mode, key, plaintexts)
+ : encrypt(algorithm, mode, key, plaintexts);
+
+ if (!success)
+ {
+ cmd_parser.print_usage();
+ return 1;
+ }
+ }
+
+ return 0;
+ }
+ catch (const boost::program_options::error& e)
+ {
+ std::cerr << "Usage error: " << e.what() << "\n";
+ return 1;
+ }
+ catch (const aesni::Error& e)
+ {
+ std::cerr << e;
+ return 1;
+ }
+ catch (const std::exception& e)
+ {
+ std::cerr << e.what() << "\n";
+ return 1;
+ }
+}
diff --git a/utils/block/cxx/CMakeLists.txt b/utils/block/cxx/CMakeLists.txt
deleted file mode 100644
index 8df91d0..0000000
--- a/utils/block/cxx/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-find_package(Boost REQUIRED COMPONENTS program_options)
-
-add_executable(util_aes_encrypt_block aes_encrypt_block.cpp aes_common.hpp)
-target_include_directories(util_aes_encrypt_block PRIVATE ${Boost_INCLUDE_DIRS})
-target_link_libraries(util_aes_encrypt_block libaesni libaesnixx ${Boost_LIBRARIES})
-set_target_properties(util_aes_encrypt_block PROPERTIES OUTPUT_NAME aes_encrypt_block)
-
-add_executable(util_aes_decrypt_block aes_decrypt_block.cpp aes_common.hpp)
-target_include_directories(util_aes_decrypt_block PRIVATE ${Boost_INCLUDE_DIRS})
-target_link_libraries(util_aes_decrypt_block libaesni libaesnixx ${Boost_LIBRARIES})
-set_target_properties(util_aes_decrypt_block PROPERTIES OUTPUT_NAME aes_decrypt_block)
diff --git a/utils/block/cxx/aes_decrypt_block.cpp b/utils/block/cxx/aes_decrypt_block.cpp
deleted file mode 100644
index 835d945..0000000
--- a/utils/block/cxx/aes_decrypt_block.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * \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 "aes_common.hpp"
-
-#include <aesni/all.h>
-
-#include <aesnixx/all.hpp>
-
-#include <exception>
-#include <iostream>
-
-int main(int argc, char** argv)
-{
- try
- {
- CommandLineParser cmd_parser("aes_encrypt_block.exe");
-
- if (!cmd_parser.parse_options(argc, argv))
- return 0;
-
- auto args = cmd_parser.get_args();
-
- while (!args.empty())
- {
- AesNI_BoxAlgorithmParams algorithm_params;
-
- switch (cmd_parser.get_algorithm())
- {
- case AESNI_AES128:
- aesni::aes::from_string(algorithm_params.aes128_key, args.front());
- break;
-
- case AESNI_AES192:
- aesni::aes::from_string(algorithm_params.aes192_key, args.front());
- break;
-
- case AESNI_AES256:
- aesni::aes::from_string(algorithm_params.aes256_key, args.front());
- break;
- }
-
- args.pop_front();
-
- AesNI_BoxBlock iv;
- AesNI_BoxBlock* iv_ptr = nullptr;
-
- switch (cmd_parser.get_mode())
- {
- case AESNI_ECB:
- break;
-
- case AESNI_CBC:
- case AESNI_CFB:
- case AESNI_OFB:
- case AESNI_CTR:
- if (args.empty())
- {
- cmd_parser.print_usage();
- return 1;
- }
- aesni::aes::from_string(iv.aes_block, args.front());
- iv_ptr = &iv;
- args.pop_front();
- break;
- }
-
- AesNI_Box box;
- aesni_box_init(
- &box,
- cmd_parser.get_algorithm(),
- &algorithm_params,
- cmd_parser.get_mode(),
- iv_ptr,
- aesni::ErrorDetailsThrowsInDestructor());
-
- while (!args.empty())
- {
- if (args.front() == "--")
- {
- args.pop_front();
- break;
- }
-
- AesNI_BoxBlock ciphertext;
- aesni::aes::from_string(ciphertext.aes_block, args.front());
- args.pop_front();
-
- AesNI_BoxBlock plaintext;
- aesni_box_decrypt_block(
- &box,
- &ciphertext,
- &plaintext,
- aesni::ErrorDetailsThrowsInDestructor());
-
- std::cout << aesni::aes::to_string(plaintext.aes_block) << "\n";
- }
- }
-
- return 0;
- }
- catch (const boost::program_options::error& e)
- {
- std::cerr << "Usage error: " << e.what() << "\n";
- return 1;
- }
- catch (const aesni::Error& e)
- {
- std::cerr << e;
- return 1;
- }
- catch (const std::exception& e)
- {
- std::cerr << e.what() << "\n";
- return 1;
- }
-}
diff --git a/utils/block/cxx/aes_encrypt_block.cpp b/utils/block/cxx/aes_encrypt_block.cpp
deleted file mode 100644
index cd92fa3..0000000
--- a/utils/block/cxx/aes_encrypt_block.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * \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 "aes_common.hpp"
-
-#include <aesni/all.h>
-
-#include <aesnixx/all.hpp>
-
-#include <exception>
-#include <iostream>
-
-int main(int argc, char** argv)
-{
- try
- {
- CommandLineParser cmd_parser("aes_encrypt_block.exe");
-
- if (!cmd_parser.parse_options(argc, argv))
- return 0;
-
- auto args = cmd_parser.get_args();
-
- while (!args.empty())
- {
- AesNI_BoxAlgorithmParams algorithm_params;
-
- switch (cmd_parser.get_algorithm())
- {
- case AESNI_AES128:
- aesni::aes::from_string(algorithm_params.aes128_key, args.front());
- break;
-
- case AESNI_AES192:
- aesni::aes::from_string(algorithm_params.aes192_key, args.front());
- break;
-
- case AESNI_AES256:
- aesni::aes::from_string(algorithm_params.aes256_key, args.front());
- break;
- }
-
- args.pop_front();
-
- AesNI_BoxBlock iv;
- AesNI_BoxBlock* iv_ptr = nullptr;
-
- switch (cmd_parser.get_mode())
- {
- case AESNI_ECB:
- break;
-
- case AESNI_CBC:
- case AESNI_CFB:
- case AESNI_OFB:
- case AESNI_CTR:
- if (args.empty())
- {
- cmd_parser.print_usage();
- return 1;
- }
- aesni::aes::from_string(iv.aes_block, args.front());
- iv_ptr = &iv;
- args.pop_front();
- break;
- }
-
- AesNI_Box box;
- aesni_box_init(
- &box,
- cmd_parser.get_algorithm(),
- &algorithm_params,
- cmd_parser.get_mode(),
- iv_ptr,
- aesni::ErrorDetailsThrowsInDestructor());
-
- while (!args.empty())
- {
- if (args.front() == "--")
- {
- args.pop_front();
- break;
- }
-
- AesNI_BoxBlock plaintext;
- aesni::aes::from_string(plaintext.aes_block, args.front());
- args.pop_front();
-
- AesNI_BoxBlock ciphertext;
- aesni_box_encrypt_block(
- &box,
- &plaintext,
- &ciphertext,
- aesni::ErrorDetailsThrowsInDestructor());
-
- std::cout << aesni::aes::to_string(ciphertext.aes_block) << "\n";
- }
- }
-
- return 0;
- }
- catch (const boost::program_options::error& e)
- {
- std::cerr << "Usage error: " << e.what() << "\n";
- return 1;
- }
- catch (const aesni::Error& e)
- {
- std::cerr << e;
- return 1;
- }
- catch (const std::exception& e)
- {
- std::cerr << e.what() << "\n";
- return 1;
- }
-}