aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/aesxx/utils/helpers/cmd_parser_file.hpp
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-07-22 18:31:50 +0200
committerEgor Tensin <egor@tensin.name>2026-07-22 21:07:53 +0200
commit4720b5ac21163936fb47f524037a6f12ce6e6ce2 (patch)
tree7b1f3f7f0e4047134048bb9b9967498b6f8ead12 /aesxx/utils/helpers/cmd_parser_file.hpp
parentminor refactoring (diff)
downloadaes-tools-4720b5ac21163936fb47f524037a6f12ce6e6ce2.tar.gz
aes-tools-4720b5ac21163936fb47f524037a6f12ce6e6ce2.zip
rewrite: the beginning
This a giant fuck-you to myself while I have nothing (actually, tons of things) to do in a hospital. * The giant screens of preprocessor code are gone, they always sucked, fuck them. * Switched everything to the "boxes" interface as the only one remaining. * Restuctured things in aes/ so that the files they're in make at least a little bit of sense. * Removed a bunch of cruft and prematurely generic code. * This is half-baked at best: I just made sure that the tests pass. A lot of cleanup awaits.
Diffstat (limited to 'aesxx/utils/helpers/cmd_parser_file.hpp')
-rw-r--r--aesxx/utils/helpers/cmd_parser_file.hpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/aesxx/utils/helpers/cmd_parser_file.hpp b/aesxx/utils/helpers/cmd_parser_file.hpp
index 2e710b2..8adfb1d 100644
--- a/aesxx/utils/helpers/cmd_parser_file.hpp
+++ b/aesxx/utils/helpers/cmd_parser_file.hpp
@@ -10,8 +10,10 @@
#include <aesxx/all.hpp>
+#include <boost/optional.hpp>
#include <boost/program_options.hpp>
+#include <optional>
#include <ostream>
#include <string>
#include <string_view>
@@ -39,7 +41,7 @@ public:
);
visible.add_options()(
"iv,v",
- boost::program_options::value<std::string>(&iv)->value_name("BLOCK"),
+ boost::program_options::value(&iv)->value_name("BLOCK"),
"set initialization vector"
);
visible.add_options()(
@@ -66,12 +68,6 @@ public:
SettingsParser::parse(argc, argv);
if (exit_with_usage())
return;
-
- if (aes::mode_requires_init_vector(get_mode()) && iv.empty()) {
- throw boost::program_options::error{
- "an initialization vector is required for the selected mode of operation"
- };
- }
}
aes::Algorithm get_algorithm() const {
@@ -94,12 +90,10 @@ public:
return key;
}
- bool has_iv() const {
- return !iv.empty();
- }
-
- std::string get_iv() const {
- return iv;
+ std::optional<aes::Block> get_iv() const {
+ if (iv)
+ return {*iv};
+ return {};
}
private:
@@ -110,5 +104,5 @@ private:
std::string output_path;
std::string key;
- std::string iv;
+ boost::optional<aes::Block> iv;
};