// Copyright (c) 2015 Egor Tensin // This file is part of the "AES tools" project. // For details, see https://github.com/egor-tensin/aes-tools. // Distributed under the MIT License. #pragma once #include #include #include #include template void dump_block( const char* header, const typename aes::Types::Block& block) { std::cout << header << ": " << aes::to_string(block) << "\n"; std::cout << aes::to_matrix_string(block) << "\n"; } template void dump_plaintext(const typename aes::Types::Block& block) { dump_block("Plaintext", block); } template void dump_key(const typename aes::Types::Key& key) { std::cout << "Key: " << aes::to_string(key) << "\n\n"; } template void dump_ciphertext(const typename aes::Types::Block& ciphertext) { dump_block("Ciphertext", ciphertext); } template void dump_iv(const typename aes::Types::Block& iv) { dump_block("Initialization vector", iv); } template void dump_round_keys(const char* header, const typename aes::Types::RoundKeys& round_keys) { std::cout << header << ":\n"; for (std::size_t i = 0; i < aes::get_number_of_rounds(); ++i) std::cout << "\t[" << i << "]: " << aes::to_string(round_keys.keys[i]) << "\n"; std::cout << "\n"; } template void dump_encryption_keys(const typename aes::Types::RoundKeys& round_keys) { dump_round_keys("Encryption round keys", round_keys); } template void dump_decryption_keys(const typename aes::Types::RoundKeys& round_keys) { dump_round_keys("Decryption round keys", round_keys); } template void dump_wrapper(const aes::EncryptWrapper& wrapper) { dump_encryption_keys(wrapper.encryption_keys); } template void dump_wrapper(const aes::DecryptWrapper& wrapper) { dump_decryption_keys(wrapper.decryption_keys); } template ::value>::type* = nullptr> void dump_next_iv(const aes::EncryptWrapper& wrapper) { dump_block("Next initialization vector", wrapper.iv); } template ::value>::type* = nullptr> void dump_next_iv(const aes::EncryptWrapper&) { } template ::value>::type* = nullptr> void dump_next_iv(const aes::DecryptWrapper& wrapper) { dump_block("Next initialization vector", wrapper.iv); } template ::value>::type* = nullptr> void dump_next_iv(const aes::DecryptWrapper&) { }