aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-07-21 11:27:44 -0400
committerJack Lloyd <[email protected]>2016-07-21 11:27:44 -0400
commitcf00df79de807d2ff236cc4c21c1f7549cbfad2f (patch)
treee13bc9adb3989bf907359be93916a7d15accf5af
parent308c7d5eda678566edd26e9ab20edbe772f46363 (diff)
parentadfc3e082d176f2f5141374f507a13d575898cff (diff)
Merge GH #544 Make StreamCipher::set_iv pure virtual
-rw-r--r--src/lib/prov/openssl/openssl_rc4.cpp6
-rw-r--r--src/lib/stream/rc4/rc4.cpp6
-rw-r--r--src/lib/stream/rc4/rc4.h2
-rw-r--r--src/lib/stream/stream_cipher.cpp6
-rw-r--r--src/lib/stream/stream_cipher.h2
5 files changed, 15 insertions, 7 deletions
diff --git a/src/lib/prov/openssl/openssl_rc4.cpp b/src/lib/prov/openssl/openssl_rc4.cpp
index 070cdb14d..d6246e4ab 100644
--- a/src/lib/prov/openssl/openssl_rc4.cpp
+++ b/src/lib/prov/openssl/openssl_rc4.cpp
@@ -12,6 +12,7 @@
#include <botan/internal/algo_registry.h>
#include <botan/internal/openssl.h>
#include <botan/parsing.h>
+#include <botan/exceptn.h>
#include <openssl/rc4.h>
namespace Botan {
@@ -46,6 +47,11 @@ class OpenSSL_RC4 : public StreamCipher
explicit OpenSSL_RC4(size_t skip = 0) : m_skip(skip) { clear(); }
~OpenSSL_RC4() { clear(); }
+ void set_iv(const byte*, size_t) override
+ {
+ throw Exception("RC4 does not support an IV");
+ }
+
void seek(u64bit) override
{
throw Exception("RC4 does not support seeking");
diff --git a/src/lib/stream/rc4/rc4.cpp b/src/lib/stream/rc4/rc4.cpp
index a4dea9e2b..e5ea2e2b8 100644
--- a/src/lib/stream/rc4/rc4.cpp
+++ b/src/lib/stream/rc4/rc4.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/rc4.h>
+#include <botan/exceptn.h>
namespace Botan {
@@ -35,6 +36,11 @@ void RC4::cipher(const byte in[], byte out[], size_t length)
m_position += length;
}
+void RC4::set_iv(const byte*, size_t)
+ {
+ throw Exception("RC4 does not support an IV");
+ }
+
/*
* Generate cipher stream
*/
diff --git a/src/lib/stream/rc4/rc4.h b/src/lib/stream/rc4/rc4.h
index 88798fae6..82dd6097b 100644
--- a/src/lib/stream/rc4/rc4.h
+++ b/src/lib/stream/rc4/rc4.h
@@ -21,6 +21,8 @@ class BOTAN_DLL RC4 final : public StreamCipher
public:
void cipher(const byte in[], byte out[], size_t length) override;
+ void set_iv(const byte iv[], size_t iv_len) override;
+
void clear() override;
std::string name() const override;
diff --git a/src/lib/stream/stream_cipher.cpp b/src/lib/stream/stream_cipher.cpp
index 6f98df1fb..cd6400d8f 100644
--- a/src/lib/stream/stream_cipher.cpp
+++ b/src/lib/stream/stream_cipher.cpp
@@ -44,12 +44,6 @@ std::vector<std::string> StreamCipher::providers(const std::string& algo_spec)
StreamCipher::StreamCipher() {}
StreamCipher::~StreamCipher() {}
-void StreamCipher::set_iv(const byte[], size_t iv_len)
- {
- if(!valid_iv_length(iv_len))
- throw Invalid_IV_Length(name(), iv_len);
- }
-
#if defined(BOTAN_HAS_CHACHA)
BOTAN_REGISTER_T_1LEN(StreamCipher, ChaCha, 20);
#endif
diff --git a/src/lib/stream/stream_cipher.h b/src/lib/stream/stream_cipher.h
index 56bd2d5d9..e08bee0ce 100644
--- a/src/lib/stream/stream_cipher.h
+++ b/src/lib/stream/stream_cipher.h
@@ -67,7 +67,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm
* @param iv the initialization vector
* @param iv_len the length of the IV in bytes
*/
- virtual void set_iv(const byte[], size_t iv_len);
+ virtual void set_iv(const byte[], size_t iv_len) = 0;
/**
* @param iv_len the length of the IV in bytes