aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils/decrypt_block.cpp
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/decrypt_block.cpp
parentrename the project (diff)
downloadaes-tools-f0393777befc4ff1024513dab3ab6bad0e7ec45f.tar.gz
aes-tools-f0393777befc4ff1024513dab3ab6bad0e7ec45f.zip
'aesni' -> 'aes'
Diffstat (limited to '')
-rw-r--r--utils/decrypt_block.cpp86
1 files changed, 43 insertions, 43 deletions
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;