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/kdf/hkdf | |
parent | bef5303b3ec1a17bc79ccce0eecdca4874639b56 (diff) |
Add message to BOTAN_ARG_CHECK and use it more widely
Diffstat (limited to 'src/lib/kdf/hkdf')
-rw-r--r-- | src/lib/kdf/hkdf/hkdf.cpp | 13 |
1 files changed, 4 insertions, 9 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()); |