aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/examples/common.hpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-07-26 00:44:16 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-07-26 00:44:16 +0300
commit6b31d793706f8422e06b5148e366644074a48b5d (patch)
tree4fffdc6e31d4edbce132443aeabc0d4c3ddc2d53 /examples/common.hpp
parentcxx: disable DbgHelp.h warnings (diff)
downloadaes-tools-6b31d793706f8422e06b5148e366644074a48b5d.tar.gz
aes-tools-6b31d793706f8422e06b5148e366644074a48b5d.zip
examples: merge to block utils
Diffstat (limited to '')
-rw-r--r--examples/common.hpp105
1 files changed, 0 insertions, 105 deletions
diff --git a/examples/common.hpp b/examples/common.hpp
deleted file mode 100644
index 019a8da..0000000
--- a/examples/common.hpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/**
- * \file
- * \author Egor Tensin <Egor.Tensin@gmail.com>
- * \date 2015
- * \copyright This file is licensed under the terms of the MIT License.
- * See LICENSE.txt for details.
- */
-
-#pragma once
-
-#include <aesnixx/all.hpp>
-
-#include <cstdlib>
-
-#include <iostream>
-
-namespace
-{
- void dump_block(const char* name, const aesni::aes::Block& block)
- {
- std::cout << name << ": " << aesni::aes::to_string(block) << "\n" << aesni::aes::to_matrix_string(block) << "\n";
- }
-
- void dump_plaintext(const aesni::aes::Block& block)
- {
- dump_block("Plaintext", block);
- }
-
- template <typename KeyT>
- void dump_key(const KeyT& key)
- {
- std::cout << "Key: " << aesni::aes::to_string(key) << "\n\n";
- }
-
- void dump_ciphertext(const aesni::aes::Block& ciphertext)
- {
- dump_block("Ciphertext", ciphertext);
- }
-
- void dump_iv(const aesni::aes::Block& iv)
- {
- dump_block("Initialization vector", iv);
- }
-
- void dump_next_iv(const aesni::aes::Block& next_iv)
- {
- dump_block("Next initialization vector", next_iv);
- }
-
- void dump_decrypted(const aesni::aes::Block& decrypted)
- {
- dump_block("Decrypted", decrypted);
- }
-
- void make_default_plaintext(aesni::aes::Block& plaintext)
- {
- aesni::make_block(plaintext, 0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100);
- dump_plaintext(plaintext);
- }
-
- void make_default_key(aesni::aes::Key128& key)
- {
- aesni::aes::make_key(key, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- dump_key(key);
- }
-
- void make_default_key(aesni::aes::Key192& key)
- {
- aesni::aes::make_key(key, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- dump_key(key);
- }
-
- void make_default_key(aesni::aes::Key256& key)
- {
- aesni::aes::make_key(key, 0x1f1e1d1c, 0x1b1a1918, 0x17161514, 0x13121110, 0x0f0e0d0c, 0x0b0a0908, 0x07060504, 0x03020100);
- dump_key(key);
- }
-
- void make_default_iv(aesni::aes::Block& iv)
- {
- aesni::make_block(iv, 0xfedcba98, 0x76543210, 0xfedcba98, 0x76543210);
- dump_iv(iv);
- }
-
- template <typename RoundKeysT>
- void dump_round_keys(const char* name, const RoundKeysT& round_keys)
- {
- std::cout << name << ":\n";
- for (std::size_t i = 0; i < aesni::aes::get_number_of_rounds(round_keys); ++i)
- std::cout << "\t[" << i << "]: " << aesni::aes::to_string(round_keys.keys[i]) << "\n";
- std::cout << "\n";
- }
-
- template <typename RoundKeysT>
- void dump_encryption_keys(const RoundKeysT& round_keys)
- {
- dump_round_keys("Encryption round keys", round_keys);
- }
-
- template <typename RoundKeysT>
- void dump_decryption_keys(const RoundKeysT& round_keys)
- {
- dump_round_keys("Decryption round keys", round_keys);
- }
-}