diff options
author | Jack Lloyd <[email protected]> | 2018-05-13 12:49:40 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-05-13 12:49:40 -0400 |
commit | 1fcf8c6ba3f8912c9c6cba0555597ab0083eaaa2 (patch) | |
tree | 07199fd3b677dd02828f73fa1d2dcda272ee7a1f /src/lib/misc/hotp/hotp.cpp | |
parent | bef5303b3ec1a17bc79ccce0eecdca4874639b56 (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.cpp | 5 |
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 |