aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-05-19 04:48:59 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-05-19 04:48:59 +0300
commitf0393777befc4ff1024513dab3ab6bad0e7ec45f (patch)
tree97571103c522ff60f96a8fdde35a0bbee9532837 /utils
parentrename the project (diff)
downloadaes-tools-f0393777befc4ff1024513dab3ab6bad0e7ec45f.tar.gz
aes-tools-f0393777befc4ff1024513dab3ab6bad0e7ec45f.zip
'aesni' -> 'aes'
Diffstat (limited to '')
-rw-r--r--utils/block_cmd_parser.hpp16
-rw-r--r--utils/block_dumper.hpp64
-rw-r--r--utils/data_parsers.hpp24
-rw-r--r--utils/decrypt_block.cpp86
-rw-r--r--utils/decrypt_bmp.cpp18
-rw-r--r--utils/decrypt_file.cpp18
-rw-r--r--utils/encrypt_block.cpp86
-rw-r--r--utils/encrypt_bmp.cpp18
-rw-r--r--utils/encrypt_file.cpp18
-rw-r--r--utils/file_cmd_parser.hpp14
10 files changed, 181 insertions, 181 deletions
diff --git a/utils/block_cmd_parser.hpp b/utils/block_cmd_parser.hpp
index db6da84..c343152 100644
--- a/utils/block_cmd_parser.hpp
+++ b/utils/block_cmd_parser.hpp
@@ -30,15 +30,15 @@ namespace
class Settings
{
public:
- aesni::Algorithm get_algorithm() const { return algorithm; }
- aesni::Mode get_mode() const { return mode; }
+ aes::Algorithm get_algorithm() const { return algorithm; }
+ aes::Mode get_mode() const { return mode; }
bool use_boxes() const { return use_boxes_flag; }
bool verbose() const { return verbose_flag; }
private:
- aesni::Algorithm algorithm;
- aesni::Mode mode;
+ aes::Algorithm algorithm;
+ aes::Mode mode;
bool use_boxes_flag = false;
bool verbose_flag = false;
@@ -61,8 +61,8 @@ namespace
options.add_options()
("help,h", "show this message and exit")
("use-boxes,b", po::bool_switch(&settings.use_boxes_flag)->default_value(false), "use the \"boxes\" interface")
- ("mode,m", po::value<aesni::Mode>(&settings.mode)->required(), "set mode of operation")
- ("algorithm,a", po::value<aesni::Algorithm>(&settings.algorithm)->required(), "set algorithm")
+ ("mode,m", po::value<aes::Mode>(&settings.mode)->required(), "set mode of operation")
+ ("algorithm,a", po::value<aes::Algorithm>(&settings.algorithm)->required(), "set algorithm")
("verbose,v", po::bool_switch(&settings.verbose_flag)->default_value(false), "enable verbose output");
std::vector<std::string> args;
@@ -112,7 +112,7 @@ namespace
std::string iv_string;
- if (aesni::mode_requires_initialization_vector(settings.get_mode()))
+ if (aes::mode_requires_initialization_vector(settings.get_mode()))
{
if (args.empty())
{
@@ -137,7 +137,7 @@ namespace
args.pop_front();
}
- if (aesni::mode_requires_initialization_vector(settings.get_mode()))
+ if (aes::mode_requires_initialization_vector(settings.get_mode()))
{
inputs.emplace_back(
std::move(key_string),
diff --git a/utils/block_dumper.hpp b/utils/block_dumper.hpp
index f41018d..d2b76bf 100644
--- a/utils/block_dumper.hpp
+++ b/utils/block_dumper.hpp
@@ -17,92 +17,92 @@
namespace
{
- template <aesni::Algorithm algorithm>
- void dump_block(const char* name, const typename aesni::Types<algorithm>::Block& block)
+ template <aes::Algorithm algorithm>
+ void dump_block(const char* name, const typename aes::Types<algorithm>::Block& block)
{
- std::cout << name << ": " << aesni::to_string<algorithm>(block) << "\n" << aesni::to_matrix_string<algorithm>(block) << "\n";
+ std::cout << name << ": " << aes::to_string<algorithm>(block) << "\n" << aes::to_matrix_string<algorithm>(block) << "\n";
}
- template <aesni::Algorithm algorithm>
- void dump_plaintext(const typename aesni::Types<algorithm>::Block& block)
+ template <aes::Algorithm algorithm>
+ void dump_plaintext(const typename aes::Types<algorithm>::Block& block)
{
dump_block<algorithm>("Plaintext", block);
}
- template <aesni::Algorithm algorithm>
- void dump_key(const typename aesni::Types<algorithm>::Key& key)
+ template <aes::Algorithm algorithm>
+ void dump_key(const typename aes::Types<algorithm>::Key& key)
{
- std::cout << "Key: " << aesni::to_string<algorithm>(key) << "\n\n";
+ std::cout << "Key: " << aes::to_string<algorithm>(key) << "\n\n";
}
- template <aesni::Algorithm algorithm>
- void dump_ciphertext(const typename aesni::Types<algorithm>::Block& ciphertext)
+ template <aes::Algorithm algorithm>
+ void dump_ciphertext(const typename aes::Types<algorithm>::Block& ciphertext)
{
dump_block<algorithm>("Ciphertext", ciphertext);
}
- template <aesni::Algorithm algorithm>
- void dump_iv(const typename aesni::Types<algorithm>::Block& iv)
+ template <aes::Algorithm algorithm>
+ void dump_iv(const typename aes::Types<algorithm>::Block& iv)
{
dump_block<algorithm>("Initialization vector", iv);
}
- template <aesni::Algorithm algorithm>
- void dump_round_keys(const char* name, const typename aesni::Types<algorithm>::RoundKeys& round_keys)
+ template <aes::Algorithm algorithm>
+ void dump_round_keys(const char* name, const typename aes::Types<algorithm>::RoundKeys& round_keys)
{
std::cout << name << ":\n";
- for (std::size_t i = 0; i < aesni::get_number_of_rounds<algorithm>(); ++i)
- std::cout << "\t[" << i << "]: " << aesni::to_string<algorithm>(round_keys.keys[i]) << "\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";
}
- template <aesni::Algorithm algorithm>
- void dump_encryption_keys(const typename aesni::Types<algorithm>::RoundKeys& round_keys)
+ template <aes::Algorithm algorithm>
+ void dump_encryption_keys(const typename aes::Types<algorithm>::RoundKeys& round_keys)
{
dump_round_keys<algorithm>("Encryption round keys", round_keys);
}
- template <aesni::Algorithm algorithm>
- void dump_decryption_keys(const typename aesni::Types<algorithm>::RoundKeys& round_keys)
+ template <aes::Algorithm algorithm>
+ void dump_decryption_keys(const typename aes::Types<algorithm>::RoundKeys& round_keys)
{
dump_round_keys<algorithm>("Decryption round keys", round_keys);
}
- template <aesni::Algorithm algorithm, aesni::Mode mode>
+ template <aes::Algorithm algorithm, aes::Mode mode>
void dump_wrapper(
- const aesni::EncryptWrapper<algorithm, mode>& wrapper)
+ const aes::EncryptWrapper<algorithm, mode>& wrapper)
{
dump_encryption_keys<algorithm>(wrapper.encryption_keys);
}
- template <aesni::Algorithm algorithm, aesni::Mode mode>
+ template <aes::Algorithm algorithm, aes::Mode mode>
void dump_wrapper(
- const aesni::DecryptWrapper<algorithm, mode>& wrapper)
+ const aes::DecryptWrapper<algorithm, mode>& wrapper)
{
dump_decryption_keys<algorithm>(wrapper.decryption_keys);
}
- template <aesni::Algorithm algorithm, aesni::Mode mode, typename std::enable_if<aesni::ModeRequiresInitializationVector<mode>::value>::type* = 0>
+ template <aes::Algorithm algorithm, aes::Mode mode, typename std::enable_if<aes::ModeRequiresInitializationVector<mode>::value>::type* = 0>
void dump_next_iv(
- const aesni::EncryptWrapper<algorithm, mode>& wrapper)
+ const aes::EncryptWrapper<algorithm, mode>& wrapper)
{
dump_block<algorithm>("Next initialization vector", wrapper.iv);
}
- template <aesni::Algorithm algorithm, aesni::Mode mode, typename std::enable_if<!aesni::ModeRequiresInitializationVector<mode>::value>::type* = 0>
+ template <aes::Algorithm algorithm, aes::Mode mode, typename std::enable_if<!aes::ModeRequiresInitializationVector<mode>::value>::type* = 0>
void dump_next_iv(
- const aesni::EncryptWrapper<algorithm, mode>&)
+ const aes::EncryptWrapper<algorithm, mode>&)
{ }
- template <aesni::Algorithm algorithm, aesni::Mode mode, typename std::enable_if<aesni::ModeRequiresInitializationVector<mode>::value>::type* = 0>
+ template <aes::Algorithm algorithm, aes::Mode mode, typename std::enable_if<aes::ModeRequiresInitializationVector<mode>::value>::type* = 0>
void dump_next_iv(
- const aesni::DecryptWrapper<algorithm, mode>& wrapper)
+ const aes::DecryptWrapper<algorithm, mode>& wrapper)
{
dump_block<algorithm>("Next initialization vector", wrapper.iv);
}
- template <aesni::Algorithm algorithm, aesni::Mode mode, typename std::enable_if<!aesni::ModeRequiresInitializationVector<mode>::value>::type* = 0>
+ template <aes::Algorithm algorithm, aes::Mode mode, typename std::enable_if<!aes::ModeRequiresInitializationVector<mode>::value>::type* = 0>
void dump_next_iv(
- const aesni::DecryptWrapper<algorithm, mode>&)
+ const aes::DecryptWrapper<algorithm, mode>&)
{ }
}
diff --git a/utils/data_parsers.hpp b/utils/data_parsers.hpp
index d081659..815a499 100644
--- a/utils/data_parsers.hpp
+++ b/utils/data_parsers.hpp
@@ -17,20 +17,20 @@
#include <map>
#include <string>
-static std::istream& operator>>(std::istream& is, aesni::Mode& dest)
+static std::istream& operator>>(std::istream& is, aes::Mode& dest)
{
static const char* const argument_name = "mode";
std::string src;
is >> src;
- static std::map<std::string, aesni::Mode> lookup_table =
+ static std::map<std::string, aes::Mode> lookup_table =
{
- { "ecb", AESNI_ECB },
- { "cbc", AESNI_CBC },
- { "cfb", AESNI_CFB },
- { "ofb", AESNI_OFB },
- { "ctr", AESNI_CTR },
+ { "ecb", AES_ECB },
+ { "cbc", AES_CBC },
+ { "cfb", AES_CFB },
+ { "ofb", AES_OFB },
+ { "ctr", AES_CTR },
};
const auto it = lookup_table.find(boost::algorithm::to_lower_copy(src));
@@ -42,18 +42,18 @@ static std::istream& operator>>(std::istream& is, aesni::Mode& dest)
return is;
}
-static std::istream& operator>>(std::istream& is, aesni::Algorithm& dest)
+static std::istream& operator>>(std::istream& is, aes::Algorithm& dest)
{
static const char* const argument_name = "algorithm";
std::string src;
is >> src;
- static std::map<std::string, aesni::Algorithm> lookup_table =
+ static std::map<std::string, aes::Algorithm> lookup_table =
{
- { "aes128", AESNI_AES128 },
- { "aes192", AESNI_AES192 },
- { "aes256", AESNI_AES256 },
+ { "aes128", AES_AES128 },
+ { "aes192", AES_AES192 },
+ { "aes256", AES_AES256 },
};
const auto it = lookup_table.find(boost::algorithm::to_lower_copy(src));
diff --git a/utils/decrypt_block.cpp b/utils/decrypt_block.cpp
index 7369052..2029669 100644
--- a/utils/decrypt_block.cpp
+++ b/utils/decrypt_block.cpp
@@ -21,33 +21,33 @@
namespace
{
- template <aesni::Algorithm algorithm, aesni::Mode mode>
+ template <aes::Algorithm algorithm, aes::Mode mode>
void decrypt_with_mode(
const Input& input,
bool verbose = false)
{
- typename aesni::Types<algorithm>::Block iv;
+ typename aes::Types<algorithm>::Block iv;
- if (aesni::ModeRequiresInitializationVector<mode>())
+ if (aes::ModeRequiresInitializationVector<mode>())
{
- aesni::from_string<algorithm>(iv, input.get_iv_string());
+ aes::from_string<algorithm>(iv, input.get_iv_string());
if (verbose)
dump_iv<algorithm>(iv);
}
- typename aesni::Types<algorithm>::Key key;
- aesni::from_string<algorithm>(key, input.get_key_string());
+ typename aes::Types<algorithm>::Key key;
+ aes::from_string<algorithm>(key, input.get_key_string());
if (verbose)
dump_key<algorithm>(key);
- aesni::DecryptWrapper<algorithm, mode> decrypt(key, iv);
+ aes::DecryptWrapper<algorithm, mode> decrypt(key, iv);
if (verbose)
dump_wrapper<algorithm, mode>(decrypt);
for (const auto& input_block_string : input.get_input_block_strings())
{
- typename aesni::Types<algorithm>::Block ciphertext, plaintext;
- aesni::from_string<algorithm>(ciphertext, input_block_string);
+ typename aes::Types<algorithm>::Block ciphertext, plaintext;
+ aes::from_string<algorithm>(ciphertext, input_block_string);
decrypt.decrypt_block(ciphertext, plaintext);
@@ -59,37 +59,37 @@ namespace
}
else
{
- std::cout << aesni::to_string<algorithm>(plaintext) << '\n';
+ std::cout << aes::to_string<algorithm>(plaintext) << '\n';
}
}
}
- template <aesni::Algorithm algorithm>
+ template <aes::Algorithm algorithm>
void decrypt_with_algorithm(
- aesni::Mode mode,
+ aes::Mode mode,
const Input& input,
bool verbose = false)
{
switch (mode)
{
- case AESNI_ECB:
- decrypt_with_mode<algorithm, AESNI_ECB>(input, verbose);
+ case AES_ECB:
+ decrypt_with_mode<algorithm, AES_ECB>(input, verbose);
break;
- case AESNI_CBC:
- decrypt_with_mode<algorithm, AESNI_CBC>(input, verbose);
+ case AES_CBC:
+ decrypt_with_mode<algorithm, AES_CBC>(input, verbose);
break;
- case AESNI_CFB:
- decrypt_with_mode<algorithm, AESNI_CFB>(input, verbose);
+ case AES_CFB:
+ decrypt_with_mode<algorithm, AES_CFB>(input, verbose);
break;
- case AESNI_OFB:
- decrypt_with_mode<algorithm, AESNI_OFB>(input, verbose);
+ case AES_OFB:
+ decrypt_with_mode<algorithm, AES_OFB>(input, verbose);
break;
- case AESNI_CTR:
- decrypt_with_mode<algorithm, AESNI_CTR>(input, verbose);
+ case AES_CTR:
+ decrypt_with_mode<algorithm, AES_CTR>(input, verbose);
break;
default:
@@ -99,23 +99,23 @@ namespace
}
void decrypt_using_cxx_api(
- aesni::Algorithm algorithm,
- aesni::Mode mode,
+ aes::Algorithm algorithm,
+ aes::Mode mode,
const Input& input,
bool verbose = false)
{
switch (algorithm)
{
- case AESNI_AES128:
- decrypt_with_algorithm<AESNI_AES128>(mode, input, verbose);
+ case AES_AES128:
+ decrypt_with_algorithm<AES_AES128>(mode, input, verbose);
break;
- case AESNI_AES192:
- decrypt_with_algorithm<AESNI_AES192>(mode, input, verbose);
+ case AES_AES192:
+ decrypt_with_algorithm<AES_AES192>(mode, input, verbose);
break;
- case AESNI_AES256:
- decrypt_with_algorithm<AESNI_AES256>(mode, input, verbose);
+ case AES_AES256:
+ decrypt_with_algorithm<AES_AES256>(mode, input, verbose);
break;
default:
@@ -125,41 +125,41 @@ namespace
}
void decrypt_using_particular_box(
- aesni::Box& box,
+ aes::Box& box,
const std::vector<std::string>& input_block_strings)
{
for (const auto& input_block_string : input_block_strings)
{
- aesni::Box::Block ciphertext;
+ aes::Box::Block ciphertext;
box.parse_block(ciphertext, input_block_string);
- aesni::Box::Block plaintext;
+ aes::Box::Block plaintext;
box.decrypt_block(ciphertext, plaintext);
std::cout << box.format_block(plaintext) << '\n';
}
}
void decrypt_using_boxes(
- aesni::Algorithm algorithm,
- aesni::Mode mode,
+ aes::Algorithm algorithm,
+ aes::Mode mode,
const Input& input)
{
- aesni::Box::Key key;
- aesni::Box::parse_key(key, algorithm, input.get_key_string());
+ aes::Box::Key key;
+ aes::Box::parse_key(key, algorithm, input.get_key_string());
- if (aesni::mode_requires_initialization_vector(mode))
+ if (aes::mode_requires_initialization_vector(mode))
{
- aesni::Box::Block iv;
- aesni::Box::parse_block(iv, algorithm, input.get_iv_string());
+ aes::Box::Block iv;
+ aes::Box::parse_block(iv, algorithm, input.get_iv_string());
decrypt_using_particular_box(
- aesni::Box(algorithm, key, mode, iv),
+ aes::Box(algorithm, key, mode, iv),
input.get_input_block_strings());
}
else
{
decrypt_using_particular_box(
- aesni::Box(algorithm, key),
+ aes::Box(algorithm, key),
input.get_input_block_strings());
}
}
@@ -209,7 +209,7 @@ int main(int argc, char** argv)
std::cerr << cmd_parser;
return 1;
}
- catch (const aesni::Error& e)
+ catch (const aes::Error& e)
{
std::cerr << e;
return 1;
diff --git a/utils/decrypt_bmp.cpp b/utils/decrypt_bmp.cpp
index c1f36bf..f098017 100644
--- a/utils/decrypt_bmp.cpp
+++ b/utils/decrypt_bmp.cpp
@@ -61,7 +61,7 @@ namespace
}
void decrypt_bmp(
- aesni::Box& box,
+ aes::Box& box,
const std::string& ciphertext_path,
const std::string& plaintext_path)
{
@@ -91,23 +91,23 @@ namespace
const auto& ciphertext_path = settings.get_input_path();
const auto& plaintext_path = settings.get_output_path();
- aesni::Box::Key key;
- aesni::Box::parse_key(key, algorithm, settings.get_key_string());
+ aes::Box::Key key;
+ aes::Box::parse_key(key, algorithm, settings.get_key_string());
- if (aesni::mode_requires_initialization_vector(mode))
+ if (aes::mode_requires_initialization_vector(mode))
{
- aesni::Box::Block iv;
- aesni::Box::parse_block(iv, algorithm, settings.get_iv_string());
+ aes::Box::Block iv;
+ aes::Box::parse_block(iv, algorithm, settings.get_iv_string());
decrypt_bmp(
- aesni::Box(algorithm, key, mode, iv),
+ aes::Box(algorithm, key, mode, iv),
ciphertext_path,
plaintext_path);
}
else
{
decrypt_bmp(
- aesni::Box(algorithm, key),
+ aes::Box(algorithm, key),
ciphertext_path,
plaintext_path);
}
@@ -138,7 +138,7 @@ int main(int argc, char** argv)
std::cerr << cmd_parser;
return 1;
}
- catch (const aesni::Error& e)
+ catch (const aes::Error& e)
{
std::cerr << e;
return 1;
diff --git a/utils/decrypt_file.cpp b/utils/decrypt_file.cpp
index ad7e9d0..33083b7 100644
--- a/utils/decrypt_file.cpp
+++ b/utils/decrypt_file.cpp
@@ -58,7 +58,7 @@ namespace
}
void decrypt_file(
- aesni::Box& box,
+ aes::Box& box,
const std::string& ciphertext_path,
const std::string& plaintext_path)
{
@@ -76,23 +76,23 @@ namespace
const auto& ciphertext_path = settings.get_input_path();
const auto& plaintext_path = settings.get_output_path();
- aesni::Box::Key key;
- aesni::Box::parse_key(key, algorithm, settings.get_key_string());
+ aes::Box::Key key;
+ aes::Box::parse_key(key, algorithm, settings.get_key_string());
- if (aesni::mode_requires_initialization_vector(mode))
+ if (aes::mode_requires_initialization_vector(mode))
{
- aesni::Box::Block iv;
- aesni::Box::parse_block(iv, algorithm, settings.get_iv_string());
+ aes::Box::Block iv;
+ aes::Box::parse_block(iv, algorithm, settings.get_iv_string());
decrypt_file(
- aesni::Box(algorithm, key, mode, iv),
+ aes::Box(algorithm, key, mode, iv),
ciphertext_path,
plaintext_path);
}
else
{
decrypt_file(
- aesni::Box(algorithm, key),
+ aes::Box(algorithm, key),
ciphertext_path,
plaintext_path);
}
@@ -123,7 +123,7 @@ int main(int argc, char** argv)
std::cerr << cmd_parser;
return 1;
}
- catch (const aesni::Error& e)
+ catch (const aes::Error& e)
{
std::cerr << e;
return 1;
diff --git a/utils/encrypt_block.cpp b/utils/encrypt_block.cpp
index 34b6d84..ac6a45a 100644
--- a/utils/encrypt_block.cpp
+++ b/utils/encrypt_block.cpp
@@ -21,33 +21,33 @@
namespace
{
- template <aesni::Algorithm algorithm, aesni::Mode mode>
+ template <aes::Algorithm algorithm, aes::Mode mode>
void encrypt_with_mode(
const Input& input,
bool verbose = false)
{
- typename aesni::Types<algorithm>::Block iv;
+ typename aes::Types<algorithm>::Block iv;
- if (aesni::ModeRequiresInitializationVector<mode>::value)
+ if (aes::ModeRequiresInitializationVector<mode>::value)
{
- aesni::from_string<algorithm>(iv, input.get_iv_string());
+ aes::from_string<algorithm>(iv, input.get_iv_string());
if (verbose)
dump_iv<algorithm>(iv);
}
- typename aesni::Types<algorithm>::Key key;
- aesni::from_string<algorithm>(key, input.get_key_string());
+ typename aes::Types<algorithm>::Key key;
+ aes::from_string<algorithm>(key, input.get_key_string());
if (verbose)
dump_key<algorithm>(key);
- aesni::EncryptWrapper<algorithm, mode> encrypt(key, iv);
+ aes::EncryptWrapper<algorithm, mode> encrypt(key, iv);
if (verbose)
dump_wrapper<algorithm, mode>(encrypt);
for (const auto& input_block_string : input.get_input_block_strings())
{
- typename aesni::Types<algorithm>::Block plaintext, ciphertext;
- aesni::from_string<algorithm>(plaintext, input_block_string);
+ typename aes::Types<algorithm>::Block plaintext, ciphertext;
+ aes::from_string<algorithm>(plaintext, input_block_string);
encrypt.encrypt_block(plaintext, ciphertext);
@@ -59,37 +59,37 @@ namespace
}
else
{
- std::cout << aesni::to_string<algorithm>(ciphertext) << '\n';
+ std::cout << aes::to_string<algorithm>(ciphertext) << '\n';
}
}
}
- template <aesni::Algorithm algorithm>
+ template <aes::Algorithm algorithm>
void encrypt_with_algorithm(
- aesni::Mode mode,
+ aes::Mode mode,
const Input& input,
bool verbose = false)
{
switch (mode)
{
- case AESNI_ECB:
- encrypt_with_mode<algorithm, AESNI_ECB>(input, verbose);
+ case AES_ECB:
+ encrypt_with_mode<algorithm, AES_ECB>(input, verbose);
break;
- case AESNI_CBC:
- encrypt_with_mode<algorithm, AESNI_CBC>(input, verbose);
+ case AES_CBC:
+ encrypt_with_mode<algorithm, AES_CBC>(input, verbose);
break;
- case AESNI_CFB:
- encrypt_with_mode<algorithm, AESNI_CFB>(input, verbose);
+ case AES_CFB:
+ encrypt_with_mode<algorithm, AES_CFB>(input, verbose);
break;
- case AESNI_OFB:
- encrypt_with_mode<algorithm, AESNI_OFB>(input, verbose);
+ case AES_OFB:
+ encrypt_with_mode<algorithm, AES_OFB>(input, verbose);
break;
- case AESNI_CTR:
- encrypt_with_mode<algorithm, AESNI_CTR>(input, verbose);
+ case AES_CTR:
+ encrypt_with_mode<algorithm, AES_CTR>(input, verbose);
break;
default:
@@ -99,23 +99,23 @@ namespace
}
void encrypt_using_cxx_api(
- aesni::Algorithm algorithm,
- aesni::Mode mode,
+ aes::Algorithm algorithm,
+ aes::Mode mode,
const Input& input,
bool verbose = false)
{
switch (algorithm)
{
- case AESNI_AES128:
- encrypt_with_algorithm<AESNI_AES128>(mode, input, verbose);
+ case AES_AES128:
+ encrypt_with_algorithm<AES_AES128>(mode, input, verbose);
break;
- case AESNI_AES192:
- encrypt_with_algorithm<AESNI_AES192>(mode, input, verbose);
+ case AES_AES192:
+ encrypt_with_algorithm<AES_AES192>(mode, input, verbose);
break;
- case AESNI_AES256:
- encrypt_with_algorithm<AESNI_AES256>(mode, input, verbose);
+ case AES_AES256:
+ encrypt_with_algorithm<AES_AES256>(mode, input, verbose);
break;
default:
@@ -125,40 +125,40 @@ namespace
}
void encrypt_using_particular_box(
- aesni::Box& box,
+ aes::Box& box,
const std::vector<std::string>& input_block_strings)
{
for (const auto& input_block_string : input_block_strings)
{
- aesni::Box::Block plaintext;
+ aes::Box::Block plaintext;
box.parse_block(plaintext, input_block_string);
- aesni::Box::Block ciphertext;
+ aes::Box::Block ciphertext;
box.encrypt_block(plaintext, ciphertext);
std::cout << box.format_block(ciphertext) << '\n';
}
}
void encrypt_using_boxes(
- aesni::Algorithm algorithm,
- aesni::Mode mode,
+ aes::Algorithm algorithm,
+ aes::Mode mode,
const Input& input)
{
- aesni::Box::Key key;
- aesni::Box::parse_key(key, algorithm, input.get_key_string());
+ aes::Box::Key key;
+ aes::Box::parse_key(key, algorithm, input.get_key_string());
- if (aesni::mode_requires_initialization_vector(mode))
+ if (aes::mode_requires_initialization_vector(mode))
{
- aesni::Box::Block iv;
- aesni::Box::parse_block(iv, algorithm, input.get_iv_string());
+ aes::Box::Block iv;
+ aes::Box::parse_block(iv, algorithm, input.get_iv_string());
encrypt_using_particular_box(
- aesni::Box(algorithm, key, mode, iv), input.get_input_block_strings());
+ aes::Box(algorithm, key, mode, iv), input.get_input_block_strings());
}
else
{
encrypt_using_particular_box(
- aesni::Box(algorithm, key), input.get_input_block_strings());
+ aes::Box(algorithm, key), input.get_input_block_strings());
}
}
}
@@ -207,7 +207,7 @@ int main(int argc, char** argv)
std::cerr << cmd_parser;
return 1;
}
- catch (const aesni::Error& e)
+ catch (const aes::Error& e)
{
std::cerr << e;
return 1;
diff --git a/utils/encrypt_bmp.cpp b/utils/encrypt_bmp.cpp
index ea498cb..086e14d 100644
--- a/utils/encrypt_bmp.cpp
+++ b/utils/encrypt_bmp.cpp
@@ -61,7 +61,7 @@ namespace
}
void encrypt_bmp(
- aesni::Box& box,
+ aes::Box& box,
const std::string& plaintext_path,
const std::string& ciphertext_path)
{
@@ -91,23 +91,23 @@ namespace
const auto& plaintext_path = settings.get_input_path();
const auto& ciphertext_path = settings.get_output_path();
- aesni::Box::Key key;
- aesni::Box::parse_key(key, algorithm, settings.get_key_string());
+ aes::Box::Key key;
+ aes::Box::parse_key(key, algorithm, settings.get_key_string());
- if (aesni::mode_requires_initialization_vector(mode))
+ if (aes::mode_requires_initialization_vector(mode))
{
- aesni::Box::Block iv;
- aesni::Box::parse_block(iv, algorithm, settings.get_iv_string());
+ aes::Box::Block iv;
+ aes::Box::parse_block(iv, algorithm, settings.get_iv_string());
encrypt_bmp(
- aesni::Box(algorithm, key, mode, iv),
+ aes::Box(algorithm, key, mode, iv),
plaintext_path,
ciphertext_path);
}
else
{
encrypt_bmp(
- aesni::Box(algorithm, key),
+ aes::Box(algorithm, key),
plaintext_path,
ciphertext_path);
}
@@ -138,7 +138,7 @@ int main(int argc, char** argv)
std::cerr << cmd_parser;
return 1;
}
- catch (const aesni::Error& e)
+ catch (const aes::Error& e)
{
std::cerr << e;
return 1;
diff --git a/utils/encrypt_file.cpp b/utils/encrypt_file.cpp
index 3ae8744..9a3dda8 100644
--- a/utils/encrypt_file.cpp
+++ b/utils/encrypt_file.cpp
@@ -58,7 +58,7 @@ namespace
}
void encrypt_file(
- aesni::Box& box,
+ aes::Box& box,
const std::string& plaintext_path,
const std::string& ciphertext_path)
{
@@ -76,23 +76,23 @@ namespace
const auto& plaintext_path = settings.get_input_path();
const auto& ciphertext_path = settings.get_output_path();
- aesni::Box::Key key;
- aesni::Box::parse_key(key, algorithm, settings.get_key_string());
+ aes::Box::Key key;
+ aes::Box::parse_key(key, algorithm, settings.get_key_string());
- if (aesni::mode_requires_initialization_vector(mode))
+ if (aes::mode_requires_initialization_vector(mode))
{
- aesni::Box::Block iv;
- aesni::Box::parse_block(iv, algorithm, settings.get_iv_string());
+ aes::Box::Block iv;
+ aes::Box::parse_block(iv, algorithm, settings.get_iv_string());
encrypt_file(
- aesni::Box(algorithm, key, mode, iv),
+ aes::Box(algorithm, key, mode, iv),
plaintext_path,
ciphertext_path);
}
else
{
encrypt_file(
- aesni::Box(algorithm, key),
+ aes::Box(algorithm, key),
plaintext_path,
ciphertext_path);
}
@@ -123,7 +123,7 @@ int main(int argc, char** argv)
std::cerr << cmd_parser;
return 1;
}
- catch (const aesni::Error& e)
+ catch (const aes::Error& e)
{
std::cerr << e;
return 1;
diff --git a/utils/file_cmd_parser.hpp b/utils/file_cmd_parser.hpp
index c8061fa..c59e05d 100644
--- a/utils/file_cmd_parser.hpp
+++ b/utils/file_cmd_parser.hpp
@@ -28,8 +28,8 @@ namespace
public:
Settings() = default;
- aesni::Mode get_mode() const { return mode; }
- aesni::Algorithm get_algorithm() const { return algorithm; }
+ aes::Mode get_mode() const { return mode; }
+ aes::Algorithm get_algorithm() const { return algorithm; }
const std::string& get_input_path() const { return input_path; }
const std::string& get_output_path() const { return output_path; }
@@ -38,8 +38,8 @@ namespace
const std::string& get_iv_string() const { return iv; }
private:
- aesni::Mode mode;
- aesni::Algorithm algorithm;
+ aes::Mode mode;
+ aes::Algorithm algorithm;
std::string input_path;
std::string output_path;
@@ -63,8 +63,8 @@ namespace
options.add_options()
("help,h", "show this message and exit")
- ("mode,m", po::value<aesni::Mode>(&settings.mode)->required(), "set mode of operation")
- ("algorithm,a", po::value<aesni::Algorithm>(&settings.algorithm)->required(), "set algorithm")
+ ("mode,m", po::value<aes::Mode>(&settings.mode)->required(), "set mode of operation")
+ ("algorithm,a", po::value<aes::Algorithm>(&settings.algorithm)->required(), "set algorithm")
("input-path,i", po::value<std::string>(&settings.input_path)->required(), "set input file path")
("output-path,o", po::value<std::string>(&settings.output_path)->required(), "set output file path")
("key,k", po::value<std::string>(&settings.key)->required(), "set encryption key")
@@ -81,7 +81,7 @@ namespace
po::notify(vm);
- if (aesni::mode_requires_initialization_vector(settings.get_mode()))
+ if (aes::mode_requires_initialization_vector(settings.get_mode()))
{
if (!vm.count("iv"))
{