diff options
author | Jack Lloyd <[email protected]> | 2015-09-10 01:45:47 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-09-10 01:45:47 -0400 |
commit | d21de17f070863c7e0b7e8d254eb35689001a53a (patch) | |
tree | 2627df5d3c911a56dea6a56aeca693a73d66f85e /src/lib/stream | |
parent | a96a7b79662f5045f0810dfa5d5cb4ebbd04ae42 (diff) |
Fix static lib registration for block, hash, mac, stream, kdf
The support problems from having static libraries not work in the
obvious way will be endless trouble. Instead have each set of
registrations tag along in a source file for the basic type, at the
cost of some extra ifdefs. On shared libs this is harmless -
everything is going into the shared object anyway. With static libs,
this means pulling in a single block cipher pulls in the text of all
the them. But that's still strictly better than the amalgamation
(which is really pulling in everything), and it works (unlike status quo).
Diffstat (limited to 'src/lib/stream')
-rw-r--r-- | src/lib/stream/chacha/chacha.cpp | 2 | ||||
-rw-r--r-- | src/lib/stream/ctr/ctr.cpp | 2 | ||||
-rw-r--r-- | src/lib/stream/ofb/ofb.cpp | 2 | ||||
-rw-r--r-- | src/lib/stream/rc4/rc4.cpp | 2 | ||||
-rw-r--r-- | src/lib/stream/salsa20/salsa20.cpp | 2 | ||||
-rw-r--r-- | src/lib/stream/stream_cipher.cpp | 61 | ||||
-rw-r--r-- | src/lib/stream/stream_cipher.h | 10 |
7 files changed, 65 insertions, 16 deletions
diff --git a/src/lib/stream/chacha/chacha.cpp b/src/lib/stream/chacha/chacha.cpp index 9841f99a2..9aa3c2a73 100644 --- a/src/lib/stream/chacha/chacha.cpp +++ b/src/lib/stream/chacha/chacha.cpp @@ -10,8 +10,6 @@ namespace Botan { -BOTAN_REGISTER_STREAM_CIPHER_NOARGS(ChaCha); - void ChaCha::chacha(byte output[64], const u32bit input[16]) { u32bit x00 = input[ 0], x01 = input[ 1], x02 = input[ 2], x03 = input[ 3], diff --git a/src/lib/stream/ctr/ctr.cpp b/src/lib/stream/ctr/ctr.cpp index f1cdc7c42..d025a03d3 100644 --- a/src/lib/stream/ctr/ctr.cpp +++ b/src/lib/stream/ctr/ctr.cpp @@ -10,8 +10,6 @@ namespace Botan { -BOTAN_REGISTER_NAMED_T(StreamCipher, "CTR-BE", CTR_BE, CTR_BE::make); - CTR_BE* CTR_BE::make(const Spec& spec) { if(spec.algo_name() == "CTR-BE" && spec.arg_count() == 1) diff --git a/src/lib/stream/ofb/ofb.cpp b/src/lib/stream/ofb/ofb.cpp index b98f81be3..73ffef980 100644 --- a/src/lib/stream/ofb/ofb.cpp +++ b/src/lib/stream/ofb/ofb.cpp @@ -10,8 +10,6 @@ namespace Botan { -BOTAN_REGISTER_NAMED_T(StreamCipher, "OFB", OFB, OFB::make); - OFB* OFB::make(const Spec& spec) { if(spec.algo_name() == "OFB" && spec.arg_count() == 1) diff --git a/src/lib/stream/rc4/rc4.cpp b/src/lib/stream/rc4/rc4.cpp index 3fd0d2276..31fd2cca0 100644 --- a/src/lib/stream/rc4/rc4.cpp +++ b/src/lib/stream/rc4/rc4.cpp @@ -10,8 +10,6 @@ namespace Botan { -BOTAN_REGISTER_NAMED_T(StreamCipher, "RC4", RC4, RC4::make); - RC4* RC4::make(const Spec& spec) { if(spec.algo_name() == "RC4") diff --git a/src/lib/stream/salsa20/salsa20.cpp b/src/lib/stream/salsa20/salsa20.cpp index daf01dd0a..141d9e51e 100644 --- a/src/lib/stream/salsa20/salsa20.cpp +++ b/src/lib/stream/salsa20/salsa20.cpp @@ -10,8 +10,6 @@ namespace Botan { -BOTAN_REGISTER_STREAM_CIPHER_NOARGS(Salsa20); - namespace { #define SALSA20_QUARTER_ROUND(x1, x2, x3, x4) \ diff --git a/src/lib/stream/stream_cipher.cpp b/src/lib/stream/stream_cipher.cpp new file mode 100644 index 000000000..2f1538914 --- /dev/null +++ b/src/lib/stream/stream_cipher.cpp @@ -0,0 +1,61 @@ +/* +* Stream Ciphers +* (C) 2015 Jack Lloyd +* +* Botan is released under the Simplified BSD License (see license.txt) +*/ + +#include <botan/stream_cipher.h> +#include <botan/internal/stream_utils.h> + +#if defined(BOTAN_HAS_CHACHA) +#include <botan/chacha.h> +#endif + +#if defined(BOTAN_HAS_SALSA20) +#include <botan/salsa20.h> +#endif + +#if defined(BOTAN_HAS_CTR_BE) +#include <botan/ctr.h> +#endif + +#if defined(BOTAN_HAS_OFB) +#include <botan/ofb.h> +#endif + +#if defined(BOTAN_HAS_RC4) +#include <botan/rc4.h> +#endif + +namespace Botan { + +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_STREAM_CIPHER_NOARGS(ChaCha); +#endif + +#if defined(BOTAN_HAS_SALSA20) +BOTAN_REGISTER_STREAM_CIPHER_NOARGS(Salsa20); +#endif + +#if defined(BOTAN_HAS_CTR_BE) +BOTAN_REGISTER_NAMED_T(StreamCipher, "CTR-BE", CTR_BE, CTR_BE::make); +#endif + +#if defined(BOTAN_HAS_OFB) +BOTAN_REGISTER_NAMED_T(StreamCipher, "OFB", OFB, OFB::make); +#endif + +#if defined(BOTAN_HAS_RC4) +BOTAN_REGISTER_NAMED_T(StreamCipher, "RC4", RC4, RC4::make); +#endif + +} diff --git a/src/lib/stream/stream_cipher.h b/src/lib/stream/stream_cipher.h index bfdd152a7..5500bca49 100644 --- a/src/lib/stream/stream_cipher.h +++ b/src/lib/stream/stream_cipher.h @@ -20,6 +20,8 @@ namespace Botan { class BOTAN_DLL StreamCipher : public SymmetricAlgorithm { public: + typedef SCAN_Name Spec; + /** * Encrypt or decrypt a message * @param in the plaintext @@ -53,11 +55,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) - { - if(iv_len) - throw Invalid_IV_Length(name(), iv_len); - } + virtual void set_iv(const byte[], size_t iv_len); /** * @param iv_len the length of the IV in bytes @@ -70,7 +68,7 @@ class BOTAN_DLL StreamCipher : public SymmetricAlgorithm */ virtual StreamCipher* clone() const = 0; - typedef SCAN_Name Spec; + virtual ~StreamCipher(); }; } |