diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-15 21:32:42 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-15 21:32:42 +0300 |
commit | 3f5df3abf1386ce9071046bb00e5eae27a10e2ef (patch) | |
tree | c37bdb612d3c0e0175d5092c9d6be8a7b90335f5 /utils | |
parent | code style (diff) | |
download | aes-tools-3f5df3abf1386ce9071046bb00e5eae27a10e2ef.tar.gz aes-tools-3f5df3abf1386ce9071046bb00e5eae27a10e2ef.zip |
handle block parsing errors the standard way
Diffstat (limited to '')
-rw-r--r-- | utils/aes128ecb_decrypt_file.cpp | 10 | ||||
-rw-r--r-- | utils/aes128ecb_encrypt_file.cpp | 8 | ||||
-rw-r--r-- | utils/cxx/include/aesnixx/error.hpp | 2 |
3 files changed, 6 insertions, 14 deletions
diff --git a/utils/aes128ecb_decrypt_file.cpp b/utils/aes128ecb_decrypt_file.cpp index f0811ce..5d9afd2 100644 --- a/utils/aes128ecb_decrypt_file.cpp +++ b/utils/aes128ecb_decrypt_file.cpp @@ -5,7 +5,7 @@ * \copyright This file is licensed under the terms of the MIT License. * See LICENSE.txt for details. */ - + #include <aesni/all.h> #include <aesnixx/all.hpp> @@ -42,14 +42,10 @@ int main(int argc, char** argv) if (argc != 4) exit_with_usage(); - if (aesni_parse_block128(&key, argv[1]) != 0) - { - std::cerr << "Invalid 128-bit AES block '" << argv[1] << "'\n"; - exit_with_usage(); - } - try { + aesni_parse_block128(&key, argv[1], aesni::ErrorDetailsThrowsInDestructor()); + const std::string src_path(argv[2]); const std::string dest_path(argv[3]); diff --git a/utils/aes128ecb_encrypt_file.cpp b/utils/aes128ecb_encrypt_file.cpp index 694d8fe..a2d13c6 100644 --- a/utils/aes128ecb_encrypt_file.cpp +++ b/utils/aes128ecb_encrypt_file.cpp @@ -42,14 +42,10 @@ int main(int argc, char** argv) if (argc != 4) exit_with_usage(); - if (aesni_parse_block128(&key, argv[1]) != 0) - { - std::cerr << "Invalid 128-bit AES block '" << argv[1] << "'\n"; - exit_with_usage(); - } - try { + aesni_parse_block128(&key, argv[1], aesni::ErrorDetailsThrowsInDestructor()); + const std::string src_path(argv[2]); const std::string dest_path(argv[3]); diff --git a/utils/cxx/include/aesnixx/error.hpp b/utils/cxx/include/aesnixx/error.hpp index 81e63c6..dd908c5 100644 --- a/utils/cxx/include/aesnixx/error.hpp +++ b/utils/cxx/include/aesnixx/error.hpp @@ -23,7 +23,7 @@ namespace aesni public: ErrorDetailsThrowsInDestructor() { - aesni_make_error_success(get()); + aesni_initialize_error_details(get()); } ~ErrorDetailsThrowsInDestructor() |