aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/stream
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/stream
parentbef5303b3ec1a17bc79ccce0eecdca4874639b56 (diff)
Add message to BOTAN_ARG_CHECK and use it more widely
Diffstat (limited to 'src/lib/stream')
-rw-r--r--src/lib/stream/chacha/chacha.cpp5
-rw-r--r--src/lib/stream/ctr/ctr.cpp5
-rw-r--r--src/lib/stream/ofb/ofb.cpp1
-rw-r--r--src/lib/stream/salsa20/salsa20.cpp1
-rw-r--r--src/lib/stream/shake_cipher/shake_cipher.cpp1
-rw-r--r--src/lib/stream/stream_cipher.cpp1
6 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/stream/chacha/chacha.cpp b/src/lib/stream/chacha/chacha.cpp
index 0f1e082cf..acf79cbd9 100644
--- a/src/lib/stream/chacha/chacha.cpp
+++ b/src/lib/stream/chacha/chacha.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/chacha.h>
+#include <botan/exceptn.h>
#include <botan/loadstor.h>
#include <botan/cpuid.h>
@@ -13,8 +14,8 @@ namespace Botan {
ChaCha::ChaCha(size_t rounds) : m_rounds(rounds)
{
- if(m_rounds != 8 && m_rounds != 12 && m_rounds != 20)
- throw Invalid_Argument("ChaCha only supports 8, 12 or 20 rounds");
+ BOTAN_ARG_CHECK(m_rounds == 8 || m_rounds == 12 || m_rounds == 20,
+ "ChaCha only supports 8, 12 or 20 rounds");
}
std::string ChaCha::provider() const
diff --git a/src/lib/stream/ctr/ctr.cpp b/src/lib/stream/ctr/ctr.cpp
index c63bdebdc..261646344 100644
--- a/src/lib/stream/ctr/ctr.cpp
+++ b/src/lib/stream/ctr/ctr.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/ctr.h>
+#include <botan/exceptn.h>
#include <botan/loadstor.h>
namespace Botan {
@@ -30,8 +31,8 @@ CTR_BE::CTR_BE(BlockCipher* cipher, size_t ctr_size) :
m_pad(m_counter.size()),
m_pad_pos(0)
{
- if(m_ctr_size < 4 || m_ctr_size > m_block_size)
- throw Invalid_Argument("Invalid CTR-BE counter size");
+ BOTAN_ARG_CHECK(m_ctr_size >= 4 && m_ctr_size <= m_block_size,
+ "Invalid CTR-BE counter size");
}
void CTR_BE::clear()
diff --git a/src/lib/stream/ofb/ofb.cpp b/src/lib/stream/ofb/ofb.cpp
index 75b7048aa..ca3971dc2 100644
--- a/src/lib/stream/ofb/ofb.cpp
+++ b/src/lib/stream/ofb/ofb.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/ofb.h>
+#include <botan/exceptn.h>
namespace Botan {
diff --git a/src/lib/stream/salsa20/salsa20.cpp b/src/lib/stream/salsa20/salsa20.cpp
index ce22adcb7..46499e69e 100644
--- a/src/lib/stream/salsa20/salsa20.cpp
+++ b/src/lib/stream/salsa20/salsa20.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/salsa20.h>
+#include <botan/exceptn.h>
#include <botan/loadstor.h>
namespace Botan {
diff --git a/src/lib/stream/shake_cipher/shake_cipher.cpp b/src/lib/stream/shake_cipher/shake_cipher.cpp
index 72a8fd885..f6cac8354 100644
--- a/src/lib/stream/shake_cipher/shake_cipher.cpp
+++ b/src/lib/stream/shake_cipher/shake_cipher.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/shake_cipher.h>
+#include <botan/exceptn.h>
#include <botan/sha3.h>
#include <botan/loadstor.h>
diff --git a/src/lib/stream/stream_cipher.cpp b/src/lib/stream/stream_cipher.cpp
index 77e68d129..692464723 100644
--- a/src/lib/stream/stream_cipher.cpp
+++ b/src/lib/stream/stream_cipher.cpp
@@ -7,6 +7,7 @@
#include <botan/stream_cipher.h>
#include <botan/scan_name.h>
+#include <botan/exceptn.h>
#if defined(BOTAN_HAS_CHACHA)
#include <botan/chacha.h>