aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/misc/hotp/hotp.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-05-13 12:49:40 -0400
committerJack Lloyd <[email protected]>2018-05-13 12:49:40 -0400
commit1fcf8c6ba3f8912c9c6cba0555597ab0083eaaa2 (patch)
tree07199fd3b677dd02828f73fa1d2dcda272ee7a1f /src/lib/misc/hotp/hotp.cpp
parentbef5303b3ec1a17bc79ccce0eecdca4874639b56 (diff)
Add message to BOTAN_ARG_CHECK and use it more widely
Diffstat (limited to 'src/lib/misc/hotp/hotp.cpp')
-rw-r--r--src/lib/misc/hotp/hotp.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/misc/hotp/hotp.cpp b/src/lib/misc/hotp/hotp.cpp
index f07c11c9f..e4dc6e5e3 100644
--- a/src/lib/misc/hotp/hotp.cpp
+++ b/src/lib/misc/hotp/hotp.cpp
@@ -6,19 +6,20 @@
*/
#include <botan/hotp.h>
+#include <botan/exceptn.h>
namespace Botan {
HOTP::HOTP(const SymmetricKey& key, const std::string& hash_algo, size_t digits)
{
+ BOTAN_ARG_CHECK(digits == 6 || digits == 7 || digits == 8, "Invalid HOTP digits");
+
if(digits == 6)
m_digit_mod = 1000000;
else if(digits == 7)
m_digit_mod = 10000000;
else if(digits == 8)
m_digit_mod = 100000000;
- else
- throw Invalid_Argument("Invalid HOTP digits");
/*
RFC 4228 only supports SHA-1 but TOTP allows SHA-256 and SHA-512