From 32f8a474fdfe5ed1a5a9dfc34fa2dd41e1a6d9c1 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 1 Sep 2015 02:53:39 +0300 Subject: refactoring --- utils/decrypt_block.cpp | 18 +++++++++--------- utils/decrypt_bmp.cpp | 18 +++++++++--------- utils/decrypt_file.cpp | 18 +++++++++--------- utils/encrypt_block.cpp | 18 +++++++++--------- utils/encrypt_bmp.cpp | 18 +++++++++--------- utils/encrypt_file.cpp | 18 +++++++++--------- 6 files changed, 54 insertions(+), 54 deletions(-) (limited to 'utils') diff --git a/utils/decrypt_block.cpp b/utils/decrypt_block.cpp index 6159eb5..7c8e773 100644 --- a/utils/decrypt_block.cpp +++ b/utils/decrypt_block.cpp @@ -131,7 +131,7 @@ namespace template bool decrypt_using_boxes_with_algorithm( - const AesNI_BoxAlgorithmParams& algorithm_params, + const AesNI_BoxKey& box_key, aesni::Mode mode, const std::string& key, std::deque ciphertexts) @@ -153,7 +153,7 @@ namespace aesni_box_init( &box, algorithm, - &algorithm_params, + &box_key, mode, iv_ptr, aesni::ErrorDetailsThrowsInDestructor()); @@ -183,27 +183,27 @@ namespace const std::string& key, std::deque ciphertexts) { - AesNI_BoxAlgorithmParams algorithm_params; + AesNI_BoxKey box_key; switch (algorithm) { case AESNI_AES128: aesni::from_string( - algorithm_params.aes128_key, key); + box_key.aes128_key, key); return decrypt_using_boxes_with_algorithm( - algorithm_params, mode, key, ciphertexts); + box_key, mode, key, ciphertexts); case AESNI_AES192: aesni::from_string( - algorithm_params.aes192_key, key); + box_key.aes192_key, key); return decrypt_using_boxes_with_algorithm( - algorithm_params, mode, key, ciphertexts); + box_key, mode, key, ciphertexts); case AESNI_AES256: aesni::from_string( - algorithm_params.aes256_key, key); + box_key.aes256_key, key); return decrypt_using_boxes_with_algorithm( - algorithm_params, mode, key, ciphertexts); + box_key, mode, key, ciphertexts); default: return false; diff --git a/utils/decrypt_bmp.cpp b/utils/decrypt_bmp.cpp index aafde38..802283d 100644 --- a/utils/decrypt_bmp.cpp +++ b/utils/decrypt_bmp.cpp @@ -62,7 +62,7 @@ namespace template bool decrypt_bmp_with_algorithm( - const AesNI_BoxAlgorithmParams& algorithm_params, + const AesNI_BoxKey& box_key, aesni::Mode mode, std::deque& args) { @@ -98,7 +98,7 @@ namespace aesni_box_init( &box, algorithm, - &algorithm_params, + &box_key, mode, iv_ptr, aesni::ErrorDetailsThrowsInDestructor()); @@ -139,30 +139,30 @@ namespace if (args.empty()) return false; - AesNI_BoxAlgorithmParams algorithm_params; + AesNI_BoxKey box_key; switch (algorithm) { case AESNI_AES128: aesni::from_string( - algorithm_params.aes128_key, args.front()); + box_key.aes128_key, args.front()); args.pop_front(); return decrypt_bmp_with_algorithm( - algorithm_params, mode, args); + box_key, mode, args); case AESNI_AES192: aesni::from_string( - algorithm_params.aes192_key, args.front()); + box_key.aes192_key, args.front()); args.pop_front(); return decrypt_bmp_with_algorithm( - algorithm_params, mode, args); + box_key, mode, args); case AESNI_AES256: aesni::from_string( - algorithm_params.aes256_key, args.front()); + box_key.aes256_key, args.front()); args.pop_front(); return decrypt_bmp_with_algorithm( - algorithm_params, mode, args); + box_key, mode, args); default: return false; diff --git a/utils/decrypt_file.cpp b/utils/decrypt_file.cpp index 2e4da3b..d8c42c4 100644 --- a/utils/decrypt_file.cpp +++ b/utils/decrypt_file.cpp @@ -59,7 +59,7 @@ namespace template bool decrypt_file_with_algorithm( - const AesNI_BoxAlgorithmParams& algorithm_params, + const AesNI_BoxKey& box_key, aesni::Mode mode, std::deque& args) { @@ -89,7 +89,7 @@ namespace aesni_box_init( &box, algorithm, - &algorithm_params, + &box_key, mode, iv_ptr, aesni::ErrorDetailsThrowsInDestructor()); @@ -129,30 +129,30 @@ namespace if (args.empty()) return false; - AesNI_BoxAlgorithmParams algorithm_params; + AesNI_BoxKey box_key; switch (algorithm) { case AESNI_AES128: aesni::from_string( - algorithm_params.aes128_key, args.front()); + box_key.aes128_key, args.front()); args.pop_front(); return decrypt_file_with_algorithm( - algorithm_params, mode, args); + box_key, mode, args); case AESNI_AES192: aesni::from_string( - algorithm_params.aes192_key, args.front()); + box_key.aes192_key, args.front()); args.pop_front(); return decrypt_file_with_algorithm( - algorithm_params, mode, args); + box_key, mode, args); case AESNI_AES256: aesni::from_string( - algorithm_params.aes256_key, args.front()); + box_key.aes256_key, args.front()); args.pop_front(); return decrypt_file_with_algorithm( - algorithm_params, mode, args); + box_key, mode, args); default: return false; diff --git a/utils/encrypt_block.cpp b/utils/encrypt_block.cpp index c8313a6..1a62bda 100644 --- a/utils/encrypt_block.cpp +++ b/utils/encrypt_block.cpp @@ -130,7 +130,7 @@ namespace template bool encrypt_using_boxes_with_algorithm( - const AesNI_BoxAlgorithmParams& algorithm_params, + const AesNI_BoxKey& box_key, aesni::Mode mode, const std::string& key, std::deque plaintexts) @@ -152,7 +152,7 @@ namespace aesni_box_init( &box, algorithm, - &algorithm_params, + &box_key, mode, iv_ptr, aesni::ErrorDetailsThrowsInDestructor()); @@ -182,27 +182,27 @@ namespace const std::string& key, std::deque plaintexts) { - AesNI_BoxAlgorithmParams algorithm_params; + AesNI_BoxKey box_key; switch (algorithm) { case AESNI_AES128: aesni::from_string( - algorithm_params.aes128_key, key); + box_key.aes128_key, key); return encrypt_using_boxes_with_algorithm( - algorithm_params, mode, key, plaintexts); + box_key, mode, key, plaintexts); case AESNI_AES192: aesni::from_string( - algorithm_params.aes192_key, key); + box_key.aes192_key, key); return encrypt_using_boxes_with_algorithm( - algorithm_params, mode, key, plaintexts); + box_key, mode, key, plaintexts); case AESNI_AES256: aesni::from_string( - algorithm_params.aes256_key, key); + box_key.aes256_key, key); return encrypt_using_boxes_with_algorithm( - algorithm_params, mode, key, plaintexts); + box_key, mode, key, plaintexts); default: return false; diff --git a/utils/encrypt_bmp.cpp b/utils/encrypt_bmp.cpp index 4eaa767..7e2ad21 100644 --- a/utils/encrypt_bmp.cpp +++ b/utils/encrypt_bmp.cpp @@ -62,7 +62,7 @@ namespace template bool encrypt_bmp_with_algorithm( - const AesNI_BoxAlgorithmParams& algorithm_params, + const AesNI_BoxKey& box_key, aesni::Mode mode, std::deque& args) { @@ -98,7 +98,7 @@ namespace aesni_box_init( &box, algorithm, - &algorithm_params, + &box_key, mode, iv_ptr, aesni::ErrorDetailsThrowsInDestructor()); @@ -138,30 +138,30 @@ namespace if (args.empty()) return false; - AesNI_BoxAlgorithmParams algorithm_params; + AesNI_BoxKey box_key; switch (algorithm) { case AESNI_AES128: aesni::from_string( - algorithm_params.aes128_key, args.front()); + box_key.aes128_key, args.front()); args.pop_front(); return encrypt_bmp_with_algorithm( - algorithm_params, mode, args); + box_key, mode, args); case AESNI_AES192: aesni::from_string( - algorithm_params.aes192_key, args.front()); + box_key.aes192_key, args.front()); args.pop_front(); return encrypt_bmp_with_algorithm( - algorithm_params, mode, args); + box_key, mode, args); case AESNI_AES256: aesni::from_string( - algorithm_params.aes256_key, args.front()); + box_key.aes256_key, args.front()); args.pop_front(); return encrypt_bmp_with_algorithm( - algorithm_params, mode, args); + box_key, mode, args); default: return false; diff --git a/utils/encrypt_file.cpp b/utils/encrypt_file.cpp index 0619568..13f2ce1 100644 --- a/utils/encrypt_file.cpp +++ b/utils/encrypt_file.cpp @@ -59,7 +59,7 @@ namespace template bool encrypt_file_with_algorithm( - const AesNI_BoxAlgorithmParams& algorithm_params, + const AesNI_BoxKey& box_key, aesni::Mode mode, std::deque& args) { @@ -89,7 +89,7 @@ namespace aesni_box_init( &box, algorithm, - &algorithm_params, + &box_key, mode, iv_ptr, aesni::ErrorDetailsThrowsInDestructor()); @@ -129,30 +129,30 @@ namespace if (args.empty()) return false; - AesNI_BoxAlgorithmParams algorithm_params; + AesNI_BoxKey box_key; switch (algorithm) { case AESNI_AES128: aesni::from_string( - algorithm_params.aes128_key, args.front()); + box_key.aes128_key, args.front()); args.pop_front(); return encrypt_file_with_algorithm( - algorithm_params, mode, args); + box_key, mode, args); case AESNI_AES192: aesni::from_string( - algorithm_params.aes192_key, args.front()); + box_key.aes192_key, args.front()); args.pop_front(); return encrypt_file_with_algorithm( - algorithm_params, mode, args); + box_key, mode, args); case AESNI_AES256: aesni::from_string( - algorithm_params.aes256_key, args.front()); + box_key.aes256_key, args.front()); args.pop_front(); return encrypt_file_with_algorithm( - algorithm_params, mode, args); + box_key, mode, args); default: return false; -- cgit v1.2.3