diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2017-05-04 04:08:15 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2017-05-04 04:08:15 +0300 |
commit | 188460a91bd37ca6f18fb89e448819b642953be7 (patch) | |
tree | 12fa7b29fa207240fe8ddf19d70f5a5333bf1233 /utils/block_dumper.hpp | |
parent | refactoring (diff) | |
download | aes-tools-188460a91bd37ca6f18fb89e448819b642953be7.tar.gz aes-tools-188460a91bd37ca6f18fb89e448819b642953be7.zip |
code style & refactoring
Diffstat (limited to 'utils/block_dumper.hpp')
-rw-r--r-- | utils/block_dumper.hpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/utils/block_dumper.hpp b/utils/block_dumper.hpp index df5b818..ff28c75 100644 --- a/utils/block_dumper.hpp +++ b/utils/block_dumper.hpp @@ -15,9 +15,12 @@ namespace { template <aes::Algorithm algorithm> - void dump_block(const char* name, const typename aes::Types<algorithm>::Block& block) + void dump_block( + const char* header, + const typename aes::Types<algorithm>::Block& block) { - std::cout << name << ": " << aes::to_string<algorithm>(block) << "\n" << aes::to_matrix_string<algorithm>(block) << "\n"; + std::cout << header << ": " << aes::to_string<algorithm>(block) << "\n"; + std::cout << aes::to_matrix_string<algorithm>(block) << "\n"; } template <aes::Algorithm algorithm> @@ -45,9 +48,9 @@ namespace } template <aes::Algorithm algorithm> - void dump_round_keys(const char* name, const typename aes::Types<algorithm>::RoundKeys& round_keys) + void dump_round_keys(const char* header, const typename aes::Types<algorithm>::RoundKeys& round_keys) { - std::cout << name << ":\n"; + 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"; @@ -66,40 +69,34 @@ namespace } template <aes::Algorithm algorithm, aes::Mode mode> - void dump_wrapper( - const aes::EncryptWrapper<algorithm, mode>& wrapper) + 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) + 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) + 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>&) + 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) + 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>&) + void dump_next_iv(const aes::DecryptWrapper<algorithm, mode>&) { } } |