aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils/encrypt_block.cpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-08-04 04:37:12 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-08-04 04:37:12 +0300
commit0c593583dccd88e90450972e6a1b9e6bc67e0911 (patch)
treed38de5fb6255fec9424bf9694c1cf3fcfd8b9c39 /utils/encrypt_block.cpp
parenttest/toolkit.py: fix utility names (diff)
downloadaes-tools-0c593583dccd88e90450972e6a1b9e6bc67e0911.tar.gz
aes-tools-0c593583dccd88e90450972e6a1b9e6bc67e0911.zip
utils: bugfix & refactoring
Diffstat (limited to '')
-rw-r--r--utils/encrypt_block.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/utils/encrypt_block.cpp b/utils/encrypt_block.cpp
index a40cc67..c8313a6 100644
--- a/utils/encrypt_block.cpp
+++ b/utils/encrypt_block.cpp
@@ -6,15 +6,19 @@
* See LICENSE.txt for details.
*/
-#include "block_common.hpp"
+#include "block_cmd_parser.hpp"
+#include "block_dumper.hpp"
#include <aesni/all.h>
#include <aesnixx/all.hpp>
+#include <boost/program_options.hpp>
+
#include <deque>
#include <exception>
#include <iostream>
+#include <iterator>
#include <string>
namespace
@@ -211,14 +215,16 @@ int main(int argc, char** argv)
try
{
CommandLineParser cmd_parser("encrypt_block.exe");
+ cmd_parser.parse(argc, argv);
- if (!cmd_parser.parse_options(argc, argv))
+ if (cmd_parser.requested_help())
+ {
+ std::cout << cmd_parser;
return 0;
+ }
- const auto algorithm = cmd_parser.get_algorithm();
- const auto mode = cmd_parser.get_mode();
-
- auto args = cmd_parser.get_args();
+ std::deque<std::string> args{ std::make_move_iterator(cmd_parser.args.begin()),
+ std::make_move_iterator(cmd_parser.args.end()) };
while (!args.empty())
{
@@ -239,13 +245,13 @@ int main(int argc, char** argv)
args.pop_front();
}
- const auto success = cmd_parser.use_boxes()
- ? encrypt_using_boxes(algorithm, mode, key, plaintexts)
- : encrypt_using_cxx_api(algorithm, mode, key, plaintexts, cmd_parser.verbose());
+ const auto success = cmd_parser.use_boxes
+ ? encrypt_using_boxes(cmd_parser.algorithm, cmd_parser.mode, key, plaintexts)
+ : encrypt_using_cxx_api(cmd_parser.algorithm, cmd_parser.mode, key, plaintexts, cmd_parser.verbose);
if (!success)
{
- cmd_parser.print_usage();
+ std::cout << cmd_parser;
return 1;
}
}