aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--cxx/include/aesxx/api.hpp22
-rw-r--r--cxx/include/aesxx/box.hpp14
-rw-r--r--utils/block_dumper.hpp16
-rw-r--r--utils/decrypt_block.cpp2
-rw-r--r--utils/decrypt_file.cpp3
-rw-r--r--utils/encrypt_block.cpp2
-rw-r--r--utils/encrypt_file.cpp3
7 files changed, 37 insertions, 25 deletions
diff --git a/cxx/include/aesxx/api.hpp b/cxx/include/aesxx/api.hpp
index 789320f..68112bf 100644
--- a/cxx/include/aesxx/api.hpp
+++ b/cxx/include/aesxx/api.hpp
@@ -66,20 +66,23 @@ namespace aes
const typename Types<algorithm>::RoundKeys& encryption_keys,
typename Types<algorithm>::RoundKeys& decryption_keys);
- template <Algorithm algorithm, Mode mode, typename std::enable_if<ModeRequiresInitVector<mode>::value>::type* = nullptr>
+ template <Algorithm algorithm, Mode mode,
+ typename std::enable_if<ModeRequiresInitVector<mode>::value>::type* = nullptr>
void encrypt_block(
const typename Types<algorithm>::Block& plaintext,
const typename Types<algorithm>::RoundKeys& round_keys,
typename Types<algorithm>::Block& iv,
typename Types<algorithm>::Block& ciphertext);
- template <Algorithm algorithm, Mode mode, typename std::enable_if<!ModeRequiresInitVector<mode>::value>::type* = nullptr>
+ template <Algorithm algorithm, Mode mode,
+ typename std::enable_if<!ModeRequiresInitVector<mode>::value>::type* = nullptr>
void encrypt_block(
const typename Types<algorithm>::Block& plaintext,
const typename Types<algorithm>::RoundKeys& round_keys,
typename Types<algorithm>::Block& ciphertext);
- template <Algorithm algorithm, Mode mode, typename std::enable_if<!ModeRequiresInitVector<mode>::value>::type* = nullptr>
+ template <Algorithm algorithm, Mode mode,
+ typename std::enable_if<!ModeRequiresInitVector<mode>::value>::type* = nullptr>
void encrypt_block(
const typename Types<algorithm>::Block& plaintext,
const typename Types<algorithm>::RoundKeys& round_keys,
@@ -89,20 +92,23 @@ namespace aes
encrypt_block<algorithm, mode>(plaintext, round_keys, ciphertext);
}
- template <Algorithm algorithm, Mode mode, typename std::enable_if<ModeRequiresInitVector<mode>::value>::type* = nullptr>
+ template <Algorithm algorithm, Mode mode,
+ typename std::enable_if<ModeRequiresInitVector<mode>::value>::type* = nullptr>
void decrypt_block(
const typename Types<algorithm>::Block& ciphertext,
const typename Types<algorithm>::RoundKeys& round_keys,
typename Types<algorithm>::Block& iv,
typename Types<algorithm>::Block& plaintext);
- template <Algorithm algorithm, Mode mode, typename std::enable_if<!ModeRequiresInitVector<mode>::value>::type* = nullptr>
+ template <Algorithm algorithm, Mode mode,
+ typename std::enable_if<!ModeRequiresInitVector<mode>::value>::type* = nullptr>
void decrypt_block(
const typename Types<algorithm>::Block& ciphertext,
const typename Types<algorithm>::RoundKeys& round_keys,
typename Types<algorithm>::Block& plaintext);
- template <Algorithm algorithm, Mode mode, typename std::enable_if<!ModeRequiresInitVector<mode>::value>::type* = nullptr>
+ template <Algorithm algorithm, Mode mode,
+ typename std::enable_if<!ModeRequiresInitVector<mode>::value>::type* = nullptr>
void decrypt_block(
const typename Types<algorithm>::Block& ciphertext,
const typename Types<algorithm>::RoundKeys& round_keys,
@@ -117,7 +123,7 @@ namespace aes
{
EncryptWrapper(
const typename Types<algorithm>::Key& key,
- const typename Types<algorithm>::Block& iv) : iv(iv)
+ const typename Types<algorithm>::Block& iv) : iv{iv}
{
expand_key<algorithm>(key, encryption_keys);
}
@@ -139,7 +145,7 @@ namespace aes
{
DecryptWrapper(
const typename Types<algorithm>::Key& key,
- const typename Types<algorithm>::Block& iv) : iv(iv)
+ const typename Types<algorithm>::Block& iv) : iv{iv}
{
typename Types<algorithm>::RoundKeys encryption_keys;
expand_key<algorithm>(key, encryption_keys);
diff --git a/cxx/include/aesxx/box.hpp b/cxx/include/aesxx/box.hpp
index 3d9529b..076407c 100644
--- a/cxx/include/aesxx/box.hpp
+++ b/cxx/include/aesxx/box.hpp
@@ -11,10 +11,8 @@
#include <aes/all.h>
-#include <cassert>
#include <cstddef>
-#include <iostream>
#include <string>
#include <vector>
@@ -77,16 +75,16 @@ namespace aes
}
Box(Algorithm algorithm, const Key& key)
- : algorithm(algorithm)
- , mode(AES_ECB)
+ : algorithm{algorithm}
+ , mode{AES_ECB}
{
aes_box_init(&impl, algorithm, &key, mode, nullptr,
ErrorDetailsThrowsInDestructor{});
}
Box(Algorithm algorithm, const Key& key, Mode mode, const Block& iv)
- : algorithm(algorithm)
- , mode(mode)
+ : algorithm{algorithm}
+ , mode{mode}
{
aes_box_init(&impl, algorithm, &key, mode, &iv,
ErrorDetailsThrowsInDestructor{});
@@ -110,7 +108,7 @@ namespace aes
const void* src_buf,
std::size_t src_size)
{
- std::size_t dest_size;
+ std::size_t dest_size = 0;
aes_box_encrypt_buffer(
&impl,
@@ -139,7 +137,7 @@ namespace aes
const void* src_buf,
std::size_t src_size)
{
- std::size_t dest_size;
+ std::size_t dest_size = 0;
aes_box_decrypt_buffer(
&impl,
diff --git a/utils/block_dumper.hpp b/utils/block_dumper.hpp
index 00f75f1..a07d855 100644
--- a/utils/block_dumper.hpp
+++ b/utils/block_dumper.hpp
@@ -46,7 +46,9 @@ void dump_iv(const typename aes::Types<algorithm>::Block& iv)
}
template <aes::Algorithm algorithm>
-void dump_round_keys(const char* header, 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 << header << ":\n";
for (std::size_t i = 0; i < aes::get_number_of_rounds<algorithm>(); ++i)
@@ -78,22 +80,26 @@ 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>
+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>
+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>
+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>
+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>&)
{ }
diff --git a/utils/decrypt_block.cpp b/utils/decrypt_block.cpp
index 1337d55..02a3033 100644
--- a/utils/decrypt_block.cpp
+++ b/utils/decrypt_block.cpp
@@ -37,7 +37,7 @@ namespace
if (verbose)
dump_key<algorithm>(key);
- aes::DecryptWrapper<algorithm, mode> decrypt(key, iv);
+ aes::DecryptWrapper<algorithm, mode> decrypt{key, iv};
if (verbose)
dump_wrapper<algorithm, mode>(decrypt);
diff --git a/utils/decrypt_file.cpp b/utils/decrypt_file.cpp
index beaabff..6da3d17 100644
--- a/utils/decrypt_file.cpp
+++ b/utils/decrypt_file.cpp
@@ -24,7 +24,8 @@ namespace
{
const auto ciphertext_buf = file::read_file(ciphertext_path);
const auto plaintext_buf = box.decrypt_buffer(
- ciphertext_buf.data(), ciphertext_buf.size());
+ ciphertext_buf.data(),
+ ciphertext_buf.size());
file::write_file(plaintext_path, plaintext_buf);
}
diff --git a/utils/encrypt_block.cpp b/utils/encrypt_block.cpp
index b8cb55e..0b87364 100644
--- a/utils/encrypt_block.cpp
+++ b/utils/encrypt_block.cpp
@@ -37,7 +37,7 @@ namespace
if (verbose)
dump_key<algorithm>(key);
- aes::EncryptWrapper<algorithm, mode> encrypt(key, iv);
+ aes::EncryptWrapper<algorithm, mode> encrypt{key, iv};
if (verbose)
dump_wrapper<algorithm, mode>(encrypt);
diff --git a/utils/encrypt_file.cpp b/utils/encrypt_file.cpp
index c5fa41f..570bc60 100644
--- a/utils/encrypt_file.cpp
+++ b/utils/encrypt_file.cpp
@@ -24,7 +24,8 @@ namespace
{
const auto plaintext_buf = file::read_file(plaintext_path);
const auto ciphertext_buf = box.encrypt_buffer(
- plaintext_buf.data(), plaintext_buf.size());
+ plaintext_buf.data(),
+ plaintext_buf.size());
file::write_file(ciphertext_path, ciphertext_buf);
}