aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/kdf
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/kdf
parentbef5303b3ec1a17bc79ccce0eecdca4874639b56 (diff)
Add message to BOTAN_ARG_CHECK and use it more widely
Diffstat (limited to 'src/lib/kdf')
-rw-r--r--src/lib/kdf/hkdf/hkdf.cpp13
-rw-r--r--src/lib/kdf/prf_tls/prf_tls.cpp1
-rw-r--r--src/lib/kdf/sp800_108/sp800_108.cpp2
3 files changed, 6 insertions, 10 deletions
diff --git a/src/lib/kdf/hkdf/hkdf.cpp b/src/lib/kdf/hkdf/hkdf.cpp
index 6ccd786c3..4b2ee1b3d 100644
--- a/src/lib/kdf/hkdf/hkdf.cpp
+++ b/src/lib/kdf/hkdf/hkdf.cpp
@@ -80,18 +80,13 @@ hkdf_expand_label(const std::string& hash_fn,
const uint8_t hash_val[], size_t hash_val_len,
size_t length)
{
- if(length > 0xFFFF)
- throw Invalid_Argument("HKDF-Expand-Label requested output too large");
- if(label.size() > 0xFF)
- throw Invalid_Argument("HKDF-Expand-Label label too long");
- if(hash_val_len > 0xFF)
- throw Invalid_Argument("HKDF-Expand-Label hash too long");
+ BOTAN_ARG_CHECK(length <= 0xFFFF, "HKDF-Expand-Label requested output too large");
+ BOTAN_ARG_CHECK(label.size() <= 0xFF, "HKDF-Expand-Label label too long");
+ BOTAN_ARG_CHECK(hash_val_len <= 0xFF, "HKDF-Expand-Label hash too long");
const uint16_t length16 = static_cast<uint16_t>(length);
- auto mac = MessageAuthenticationCode::create("HMAC(" + hash_fn + ")");
- if(!mac)
- throw Invalid_Argument("HKDF-Expand-Label with HMAC(" + hash_fn + ") not available");
+ auto mac = MessageAuthenticationCode::create_or_throw("HMAC(" + hash_fn + ")");
HKDF_Expand hkdf(mac.release());
diff --git a/src/lib/kdf/prf_tls/prf_tls.cpp b/src/lib/kdf/prf_tls/prf_tls.cpp
index d914df77e..4fde5ea58 100644
--- a/src/lib/kdf/prf_tls/prf_tls.cpp
+++ b/src/lib/kdf/prf_tls/prf_tls.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/prf_tls.h>
+#include <botan/exceptn.h>
namespace Botan {
diff --git a/src/lib/kdf/sp800_108/sp800_108.cpp b/src/lib/kdf/sp800_108/sp800_108.cpp
index 137ade106..990e10386 100644
--- a/src/lib/kdf/sp800_108/sp800_108.cpp
+++ b/src/lib/kdf/sp800_108/sp800_108.cpp
@@ -6,7 +6,7 @@
*/
#include <botan/sp800_108.h>
-
+#include <botan/exceptn.h>
#include <iterator>
namespace Botan {