aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cli/utils.cpp')
-rw-r--r--src/cli/utils.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/cli/utils.cpp b/src/cli/utils.cpp
index 2bf03c760..63e0fc7d6 100644
--- a/src/cli/utils.cpp
+++ b/src/cli/utils.cpp
@@ -328,7 +328,15 @@ class Generate_Bcrypt final : public Command
const std::string password = get_arg("password");
const size_t wf = get_arg_sz("work-factor");
- output() << Botan::generate_bcrypt(password, rng(), wf) << "\n";
+ if(wf < 4 || wf > 18)
+ {
+ error_output() << "Invalid bcrypt work factor\n";
+ }
+ else
+ {
+ const uint16_t wf16 = static_cast<uint16_t>(wf);
+ output() << Botan::generate_bcrypt(password, rng(), wf16) << "\n";
+ }
}
};