diff options
Diffstat (limited to '')
-rw-r--r-- | examples/CMakeLists.txt | 21 | ||||
-rw-r--r-- | examples/aes128cbc.cpp | 60 | ||||
-rw-r--r-- | examples/aes128cfb.cpp | 56 | ||||
-rw-r--r-- | examples/aes128ctr.cpp | 56 | ||||
-rw-r--r-- | examples/aes128ecb.cpp | 54 | ||||
-rw-r--r-- | examples/aes128ofb.cpp | 56 | ||||
-rw-r--r-- | examples/aes192cbc.cpp | 60 | ||||
-rw-r--r-- | examples/aes192cfb.cpp | 56 | ||||
-rw-r--r-- | examples/aes192ctr.cpp | 56 | ||||
-rw-r--r-- | examples/aes192ecb.cpp | 54 | ||||
-rw-r--r-- | examples/aes192ofb.cpp | 56 | ||||
-rw-r--r-- | examples/aes256cbc.cpp | 60 | ||||
-rw-r--r-- | examples/aes256cfb.cpp | 56 | ||||
-rw-r--r-- | examples/aes256ctr.cpp | 56 | ||||
-rw-r--r-- | examples/aes256ecb.cpp | 54 | ||||
-rw-r--r-- | examples/aes256ofb.cpp | 56 | ||||
-rw-r--r-- | examples/common.hpp | 105 |
17 files changed, 0 insertions, 972 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt deleted file mode 100644 index cb82577..0000000 --- a/examples/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -macro(example prefix) - add_executable(example_${prefix} ${prefix}.cpp) - target_link_libraries(example_${prefix} libaesni libaesnixx) - set_target_properties(example_${prefix} PROPERTIES OUTPUT_NAME ${prefix}) -endmacro() - -example(aes128ecb) -example(aes128cbc) -example(aes128cfb) -example(aes128ofb) -example(aes128ctr) -example(aes192ecb) -example(aes192cbc) -example(aes192cfb) -example(aes192ofb) -example(aes192ctr) -example(aes256ecb) -example(aes256cbc) -example(aes256cfb) -example(aes256ofb) -example(aes256ctr) diff --git a/examples/aes128cbc.cpp b/examples/aes128cbc.cpp deleted file mode 100644 index cf61604..0000000 --- a/examples/aes128cbc.cpp +++ /dev/null @@ -1,60 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key128 key; - make_default_key(key); - - aesni::aes::Block iv; - make_default_iv(iv); - - aesni::aes::RoundKeys128 encryption_keys; - aesni_aes128_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - aesni::aes::Block next_iv; - const auto ciphertext = aesni_aes128_encrypt_block_cbc(plaintext, &encryption_keys, iv, &next_iv); - dump_ciphertext(ciphertext); - dump_next_iv(next_iv); - - aesni::aes::RoundKeys128 decryption_keys; - aesni_aes128_derive_decryption_keys(&encryption_keys, &decryption_keys); - dump_decryption_keys(decryption_keys); - - aesni::aes::Block decrypted = aesni_aes128_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &next_iv); - dump_decrypted(decrypted); - dump_next_iv(next_iv); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/examples/aes128cfb.cpp b/examples/aes128cfb.cpp deleted file mode 100644 index c8f7230..0000000 --- a/examples/aes128cfb.cpp +++ /dev/null @@ -1,56 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key128 key; - make_default_key(key); - - aesni::aes::Block iv; - make_default_iv(iv); - - aesni::aes::RoundKeys128 encryption_keys; - aesni_aes128_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - aesni::aes::Block next_iv; - const auto ciphertext = aesni_aes128_encrypt_block_cfb(plaintext, &encryption_keys, iv, &next_iv); - dump_ciphertext(ciphertext); - dump_next_iv(next_iv); - - const auto decrypted = aesni_aes128_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &next_iv); - dump_decrypted(decrypted); - dump_next_iv(next_iv); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/examples/aes128ctr.cpp b/examples/aes128ctr.cpp deleted file mode 100644 index 5419ce2..0000000 --- a/examples/aes128ctr.cpp +++ /dev/null @@ -1,56 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key128 key; - make_default_key(key); - - aesni::aes::Block iv; - make_default_iv(iv); - - aesni::aes::RoundKeys128 encryption_keys; - aesni_aes128_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - aesni::aes::Block next_iv; - const auto ciphertext = aesni_aes128_encrypt_block_ctr(plaintext, &encryption_keys, iv, &next_iv); - dump_ciphertext(ciphertext); - dump_next_iv(next_iv); - - const auto decrypted = aesni_aes128_decrypt_block_ctr(ciphertext, &encryption_keys, iv, &next_iv); - dump_decrypted(decrypted); - dump_next_iv(next_iv); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/examples/aes128ecb.cpp b/examples/aes128ecb.cpp deleted file mode 100644 index d999f81..0000000 --- a/examples/aes128ecb.cpp +++ /dev/null @@ -1,54 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key128 key; - make_default_key(key); - - aesni::aes::RoundKeys128 encryption_keys; - aesni_aes128_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - const auto ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, &encryption_keys); - dump_ciphertext(ciphertext); - - aesni::aes::RoundKeys128 decryption_keys; - aesni_aes128_derive_decryption_keys(&encryption_keys, &decryption_keys); - dump_decryption_keys(decryption_keys); - - const auto decrypted = aesni_aes128_decrypt_block_ecb(ciphertext, &decryption_keys); - dump_decrypted(decrypted); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/examples/aes128ofb.cpp b/examples/aes128ofb.cpp deleted file mode 100644 index f5f93d0..0000000 --- a/examples/aes128ofb.cpp +++ /dev/null @@ -1,56 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key128 key; - make_default_key(key); - - aesni::aes::Block iv; - make_default_iv(iv); - - aesni::aes::RoundKeys128 encryption_keys; - aesni_aes128_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - aesni::aes::Block next_iv; - const auto ciphertext = aesni_aes128_encrypt_block_ofb(plaintext, &encryption_keys, iv, &next_iv); - dump_ciphertext(ciphertext); - dump_next_iv(next_iv); - - const auto decrypted = aesni_aes128_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &next_iv); - dump_decrypted(decrypted); - dump_next_iv(next_iv); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/examples/aes192cbc.cpp b/examples/aes192cbc.cpp deleted file mode 100644 index b2adabd..0000000 --- a/examples/aes192cbc.cpp +++ /dev/null @@ -1,60 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key192 key; - make_default_key(key); - - aesni::aes::Block iv; - make_default_iv(iv); - - aesni::aes::RoundKeys192 encryption_keys; - aesni_aes192_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - aesni::aes::Block next_iv; - const auto ciphertext = aesni_aes192_encrypt_block_cbc(plaintext, &encryption_keys, iv, &next_iv); - dump_ciphertext(ciphertext); - dump_next_iv(next_iv); - - aesni::aes::RoundKeys192 decryption_keys; - aesni_aes192_derive_decryption_keys(&encryption_keys, &decryption_keys); - dump_decryption_keys(decryption_keys); - - const auto decrypted = aesni_aes192_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &next_iv); - dump_decrypted(decrypted); - dump_next_iv(next_iv); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/examples/aes192cfb.cpp b/examples/aes192cfb.cpp deleted file mode 100644 index d7fd9b5..0000000 --- a/examples/aes192cfb.cpp +++ /dev/null @@ -1,56 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key192 key; - make_default_key(key); - - aesni::aes::Block iv; - make_default_iv(iv); - - aesni::aes::RoundKeys192 encryption_keys; - aesni_aes192_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - aesni::aes::Block next_iv; - const auto ciphertext = aesni_aes192_encrypt_block_cfb(plaintext, &encryption_keys, iv, &next_iv); - dump_ciphertext(ciphertext); - dump_next_iv(next_iv); - - const auto decrypted = aesni_aes192_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &next_iv); - dump_decrypted(decrypted); - dump_next_iv(next_iv); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/examples/aes192ctr.cpp b/examples/aes192ctr.cpp deleted file mode 100644 index 9cad355..0000000 --- a/examples/aes192ctr.cpp +++ /dev/null @@ -1,56 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key192 key; - make_default_key(key); - - aesni::aes::Block iv; - make_default_iv(iv); - - aesni::aes::RoundKeys192 encryption_keys; - aesni_aes192_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - aesni::aes::Block next_iv; - const auto ciphertext = aesni_aes192_encrypt_block_ctr(plaintext, &encryption_keys, iv, &next_iv); - dump_ciphertext(ciphertext); - dump_next_iv(next_iv); - - const auto decrypted = aesni_aes192_decrypt_block_ctr(ciphertext, &encryption_keys, iv, &next_iv); - dump_decrypted(decrypted); - dump_next_iv(next_iv); - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } - - return 0; -} diff --git a/examples/aes192ecb.cpp b/examples/aes192ecb.cpp deleted file mode 100644 index 313f084..0000000 --- a/examples/aes192ecb.cpp +++ /dev/null @@ -1,54 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key192 key; - make_default_key(key); - - aesni::aes::RoundKeys192 encryption_keys; - aesni_aes192_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - const auto ciphertext = aesni_aes192_encrypt_block_ecb(plaintext, &encryption_keys); - dump_ciphertext(ciphertext); - - aesni::aes::RoundKeys192 decryption_keys; - aesni_aes192_derive_decryption_keys(&encryption_keys, &decryption_keys); - dump_decryption_keys(decryption_keys); - - const auto decrypted = aesni_aes192_decrypt_block_ecb(ciphertext, &decryption_keys); - dump_decrypted(decrypted); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/examples/aes192ofb.cpp b/examples/aes192ofb.cpp deleted file mode 100644 index e2d96c4..0000000 --- a/examples/aes192ofb.cpp +++ /dev/null @@ -1,56 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key192 key; - make_default_key(key); - - aesni::aes::Block iv; - make_default_iv(iv); - - aesni::aes::RoundKeys192 encryption_keys; - aesni_aes192_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - aesni::aes::Block next_iv; - const auto ciphertext = aesni_aes192_encrypt_block_ofb(plaintext, &encryption_keys, iv, &next_iv); - dump_ciphertext(ciphertext); - dump_next_iv(next_iv); - - const auto decrypted = aesni_aes192_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &next_iv); - dump_decrypted(decrypted); - dump_next_iv(next_iv); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/examples/aes256cbc.cpp b/examples/aes256cbc.cpp deleted file mode 100644 index c5ab427..0000000 --- a/examples/aes256cbc.cpp +++ /dev/null @@ -1,60 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key256 key; - make_default_key(key); - - aesni::aes::Block iv; - make_default_iv(iv); - - aesni::aes::RoundKeys256 encryption_keys; - aesni_aes256_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - aesni::aes::Block next_iv; - const auto ciphertext = aesni_aes256_encrypt_block_cbc(plaintext, &encryption_keys, iv, &next_iv); - dump_ciphertext(ciphertext); - dump_next_iv(next_iv); - - aesni::aes::RoundKeys256 decryption_keys; - aesni_aes256_derive_decryption_keys(&encryption_keys, &decryption_keys); - dump_decryption_keys(decryption_keys); - - const auto decrypted = aesni_aes256_decrypt_block_cbc(ciphertext, &decryption_keys, iv, &next_iv); - dump_decrypted(decrypted); - dump_next_iv(next_iv); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/examples/aes256cfb.cpp b/examples/aes256cfb.cpp deleted file mode 100644 index fb43d3a..0000000 --- a/examples/aes256cfb.cpp +++ /dev/null @@ -1,56 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key256 key; - make_default_key(key); - - aesni::aes::Block iv; - make_default_iv(iv); - - aesni::aes::RoundKeys256 encryption_keys; - aesni_aes256_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - aesni::aes::Block next_iv; - const auto ciphertext = aesni_aes256_encrypt_block_cfb(plaintext, &encryption_keys, iv, &next_iv); - dump_ciphertext(ciphertext); - dump_next_iv(next_iv); - - const auto decrypted = aesni_aes256_decrypt_block_cfb(ciphertext, &encryption_keys, iv, &next_iv); - dump_decrypted(decrypted); - dump_next_iv(next_iv); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/examples/aes256ctr.cpp b/examples/aes256ctr.cpp deleted file mode 100644 index 9827e79..0000000 --- a/examples/aes256ctr.cpp +++ /dev/null @@ -1,56 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key256 key; - make_default_key(key); - - aesni::aes::Block iv; - make_default_iv(iv); - - aesni::aes::RoundKeys256 encryption_keys; - aesni_aes256_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - aesni::aes::Block next_iv; - const auto ciphertext = aesni_aes256_encrypt_block_ctr(plaintext, &encryption_keys, iv, &next_iv); - dump_ciphertext(ciphertext); - dump_next_iv(next_iv); - - const auto decrypted = aesni_aes256_decrypt_block_ctr(ciphertext, &encryption_keys, iv, &next_iv); - dump_decrypted(decrypted); - dump_next_iv(next_iv); - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } - - return 0; -} diff --git a/examples/aes256ecb.cpp b/examples/aes256ecb.cpp deleted file mode 100644 index e8777e2..0000000 --- a/examples/aes256ecb.cpp +++ /dev/null @@ -1,54 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key256 key; - make_default_key(key); - - aesni::aes::RoundKeys256 encryption_keys; - aesni_aes256_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - const auto ciphertext = aesni_aes256_encrypt_block_ecb(plaintext, &encryption_keys); - dump_ciphertext(ciphertext); - - aesni::aes::RoundKeys256 decryption_keys; - aesni_aes256_derive_decryption_keys(&encryption_keys, &decryption_keys); - dump_decryption_keys(decryption_keys); - - const auto decrypted = aesni_aes256_decrypt_block_ecb(ciphertext, &decryption_keys); - dump_decrypted(decrypted); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} diff --git a/examples/aes256ofb.cpp b/examples/aes256ofb.cpp deleted file mode 100644 index 1d806aa..0000000 --- a/examples/aes256ofb.cpp +++ /dev/null @@ -1,56 +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. - */ - -#include "common.hpp" - -#include <aesni/all.h> - -#include <aesnixx/all.hpp> - -#include <exception> -#include <iostream> - -int main() -{ - try - { - aesni::aes::Block plaintext; - make_default_plaintext(plaintext); - - aesni::aes::Key256 key; - make_default_key(key); - - aesni::aes::Block iv; - make_default_iv(iv); - - aesni::aes::RoundKeys256 encryption_keys; - aesni_aes256_expand_key(&key, &encryption_keys); - dump_encryption_keys(encryption_keys); - - aesni::aes::Block next_iv; - const auto ciphertext = aesni_aes256_encrypt_block_ofb(plaintext, &encryption_keys, iv, &next_iv); - dump_ciphertext(ciphertext); - dump_next_iv(next_iv); - - const auto decrypted = aesni_aes256_decrypt_block_ofb(ciphertext, &encryption_keys, iv, &next_iv); - dump_decrypted(decrypted); - dump_next_iv(next_iv); - - return 0; - } - catch (const aesni::Error& e) - { - std::cerr << e; - return 1; - } - catch (const std::exception& e) - { - std::cerr << e.what() << "\n"; - return 1; - } -} 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); - } -} |