aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils/block_dumper.hpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2017-06-25 19:56:14 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2017-06-25 19:56:14 +0300
commita151a774f4ce6c4b13c819502efcfe919bbf050b (patch)
tree5cbed50713e2ea176c04327560b51df65bcd8b54 /utils/block_dumper.hpp
parentutils: code style (diff)
downloadaes-tools-a151a774f4ce6c4b13c819502efcfe919bbf050b.tar.gz
aes-tools-a151a774f4ce6c4b13c819502efcfe919bbf050b.zip
code style
Diffstat (limited to '')
-rw-r--r--utils/block_dumper.hpp169
1 files changed, 83 insertions, 86 deletions
diff --git a/utils/block_dumper.hpp b/utils/block_dumper.hpp
index ff28c75..00f75f1 100644
--- a/utils/block_dumper.hpp
+++ b/utils/block_dumper.hpp
@@ -12,91 +12,88 @@
#include <iostream>
#include <type_traits>
-namespace
+template <aes::Algorithm algorithm>
+void dump_block(
+ const char* header,
+ const typename aes::Types<algorithm>::Block& block)
{
- template <aes::Algorithm algorithm>
- void dump_block(
- const char* header,
- const typename aes::Types<algorithm>::Block& block)
- {
- std::cout << header << ": " << aes::to_string<algorithm>(block) << "\n";
- std::cout << aes::to_matrix_string<algorithm>(block) << "\n";
- }
-
- template <aes::Algorithm algorithm>
- void dump_plaintext(const typename aes::Types<algorithm>::Block& block)
- {
- dump_block<algorithm>("Plaintext", block);
- }
-
- template <aes::Algorithm algorithm>
- void dump_key(const typename aes::Types<algorithm>::Key& key)
- {
- std::cout << "Key: " << aes::to_string<algorithm>(key) << "\n\n";
- }
-
- template <aes::Algorithm algorithm>
- void dump_ciphertext(const typename aes::Types<algorithm>::Block& ciphertext)
- {
- dump_block<algorithm>("Ciphertext", ciphertext);
- }
-
- template <aes::Algorithm algorithm>
- void dump_iv(const typename aes::Types<algorithm>::Block& iv)
- {
- dump_block<algorithm>("Initialization vector", iv);
- }
-
- template <aes::Algorithm algorithm>
- void dump_round_keys(const char* header, const typename aes::Types<algorithm>::RoundKeys& round_keys)
- {
- std::cout << header << ":\n";
- for (std::size_t i = 0; i < aes::get_number_of_rounds<algorithm>(); ++i)
- std::cout << "\t[" << i << "]: " << aes::to_string<algorithm>(round_keys.keys[i]) << "\n";
- std::cout << "\n";
- }
-
- template <aes::Algorithm algorithm>
- void dump_encryption_keys(const typename aes::Types<algorithm>::RoundKeys& round_keys)
- {
- dump_round_keys<algorithm>("Encryption round keys", round_keys);
- }
-
- template <aes::Algorithm algorithm>
- void dump_decryption_keys(const typename aes::Types<algorithm>::RoundKeys& round_keys)
- {
- dump_round_keys<algorithm>("Decryption round keys", round_keys);
- }
-
- template <aes::Algorithm algorithm, aes::Mode mode>
- void dump_wrapper(const aes::EncryptWrapper<algorithm, mode>& wrapper)
- {
- dump_encryption_keys<algorithm>(wrapper.encryption_keys);
- }
-
- template <aes::Algorithm algorithm, aes::Mode mode>
- void dump_wrapper(const aes::DecryptWrapper<algorithm, mode>& wrapper)
- {
- dump_decryption_keys<algorithm>(wrapper.decryption_keys);
- }
-
- template <aes::Algorithm algorithm, aes::Mode mode, typename std::enable_if<aes::ModeRequiresInitVector<mode>::value>::type* = nullptr>
- void dump_next_iv(const aes::EncryptWrapper<algorithm, mode>& wrapper)
- {
- dump_block<algorithm>("Next initialization vector", wrapper.iv);
- }
-
- template <aes::Algorithm algorithm, aes::Mode mode, typename std::enable_if<!aes::ModeRequiresInitVector<mode>::value>::type* = nullptr>
- void dump_next_iv(const aes::EncryptWrapper<algorithm, mode>&)
- { }
-
- template <aes::Algorithm algorithm, aes::Mode mode, typename std::enable_if<aes::ModeRequiresInitVector<mode>::value>::type* = nullptr>
- void dump_next_iv(const aes::DecryptWrapper<algorithm, mode>& wrapper)
- {
- dump_block<algorithm>("Next initialization vector", wrapper.iv);
- }
-
- template <aes::Algorithm algorithm, aes::Mode mode, typename std::enable_if<!aes::ModeRequiresInitVector<mode>::value>::type* = nullptr>
- void dump_next_iv(const aes::DecryptWrapper<algorithm, mode>&)
- { }
+ std::cout << header << ": " << aes::to_string<algorithm>(block) << "\n";
+ std::cout << aes::to_matrix_string<algorithm>(block) << "\n";
}
+
+template <aes::Algorithm algorithm>
+void dump_plaintext(const typename aes::Types<algorithm>::Block& block)
+{
+ dump_block<algorithm>("Plaintext", block);
+}
+
+template <aes::Algorithm algorithm>
+void dump_key(const typename aes::Types<algorithm>::Key& key)
+{
+ std::cout << "Key: " << aes::to_string<algorithm>(key) << "\n\n";
+}
+
+template <aes::Algorithm algorithm>
+void dump_ciphertext(const typename aes::Types<algorithm>::Block& ciphertext)
+{
+ dump_block<algorithm>("Ciphertext", ciphertext);
+}
+
+template <aes::Algorithm algorithm>
+void dump_iv(const typename aes::Types<algorithm>::Block& iv)
+{
+ dump_block<algorithm>("Initialization vector", iv);
+}
+
+template <aes::Algorithm algorithm>
+void dump_round_keys(const char* header, const typename aes::Types<algorithm>::RoundKeys& round_keys)
+{
+ std::cout << header << ":\n";
+ for (std::size_t i = 0; i < aes::get_number_of_rounds<algorithm>(); ++i)
+ std::cout << "\t[" << i << "]: " << aes::to_string<algorithm>(round_keys.keys[i]) << "\n";
+ std::cout << "\n";
+}
+
+template <aes::Algorithm algorithm>
+void dump_encryption_keys(const typename aes::Types<algorithm>::RoundKeys& round_keys)
+{
+ dump_round_keys<algorithm>("Encryption round keys", round_keys);
+}
+
+template <aes::Algorithm algorithm>
+void dump_decryption_keys(const typename aes::Types<algorithm>::RoundKeys& round_keys)
+{
+ dump_round_keys<algorithm>("Decryption round keys", round_keys);
+}
+
+template <aes::Algorithm algorithm, aes::Mode mode>
+void dump_wrapper(const aes::EncryptWrapper<algorithm, mode>& wrapper)
+{
+ dump_encryption_keys<algorithm>(wrapper.encryption_keys);
+}
+
+template <aes::Algorithm algorithm, aes::Mode mode>
+void dump_wrapper(const aes::DecryptWrapper<algorithm, mode>& wrapper)
+{
+ dump_decryption_keys<algorithm>(wrapper.decryption_keys);
+}
+
+template <aes::Algorithm algorithm, aes::Mode mode, typename std::enable_if<aes::ModeRequiresInitVector<mode>::value>::type* = nullptr>
+void dump_next_iv(const aes::EncryptWrapper<algorithm, mode>& wrapper)
+{
+ dump_block<algorithm>("Next initialization vector", wrapper.iv);
+}
+
+template <aes::Algorithm algorithm, aes::Mode mode, typename std::enable_if<!aes::ModeRequiresInitVector<mode>::value>::type* = nullptr>
+void dump_next_iv(const aes::EncryptWrapper<algorithm, mode>&)
+{ }
+
+template <aes::Algorithm algorithm, aes::Mode mode, typename std::enable_if<aes::ModeRequiresInitVector<mode>::value>::type* = nullptr>
+void dump_next_iv(const aes::DecryptWrapper<algorithm, mode>& wrapper)
+{
+ dump_block<algorithm>("Next initialization vector", wrapper.iv);
+}
+
+template <aes::Algorithm algorithm, aes::Mode mode, typename std::enable_if<!aes::ModeRequiresInitVector<mode>::value>::type* = nullptr>
+void dump_next_iv(const aes::DecryptWrapper<algorithm, mode>&)
+{ }