diff options
Diffstat (limited to 'src/libstate/engine/openssl')
-rw-r--r-- | src/libstate/engine/openssl/arc4_openssl.cpp | 39 | ||||
-rw-r--r-- | src/libstate/engine/openssl/arc4_openssl.h | 32 | ||||
-rw-r--r-- | src/libstate/engine/openssl/eng_ossl.cpp | 26 | ||||
-rw-r--r-- | src/libstate/engine/openssl/info.txt | 2 | ||||
-rw-r--r-- | src/libstate/engine/openssl/ossl_bc.cpp | 2 |
5 files changed, 40 insertions, 61 deletions
diff --git a/src/libstate/engine/openssl/arc4_openssl.cpp b/src/libstate/engine/openssl/arc4_openssl.cpp index c1d0779b3..59bdd30d7 100644 --- a/src/libstate/engine/openssl/arc4_openssl.cpp +++ b/src/libstate/engine/openssl/arc4_openssl.cpp @@ -9,6 +9,28 @@ namespace Botan { +namespace { + +/** +* ARC4 as implemented by OpenSSL +*/ +class ARC4_OpenSSL : public StreamCipher + { + public: + void clear() throw() { std::memset(&state, 0, sizeof(state)); } + std::string name() const; + StreamCipher* clone() const { return new ARC4_OpenSSL(SKIP); } + + ARC4_OpenSSL(u32bit s = 0) : StreamCipher(1, 32), SKIP(s) { clear(); } + ~ARC4_OpenSSL() { clear(); } + private: + void cipher(const byte[], byte[], u32bit); + void key_schedule(const byte[], u32bit); + + const u32bit SKIP; + RC4_KEY state; + }; + /************************************************* * Return the name of this type * *************************************************/ @@ -39,3 +61,20 @@ void ARC4_OpenSSL::cipher(const byte in[], byte out[], u32bit length) } } + +/** +* Look for an OpenSSL-suported stream cipher (ARC4) +*/ +StreamCipher* +OpenSSL_Engine::find_stream_cipher(const SCAN_Name& request, + Algorithm_Factory&) const + { + if(request.algo_name() == "ARC4") + return new ARC4_OpenSSL(request.argument_as_u32bit(0, 0)); + if(request.algo_name() == "RC4_drop") + return new ARC4_OpenSSL(768); + + return 0; + } + +} diff --git a/src/libstate/engine/openssl/arc4_openssl.h b/src/libstate/engine/openssl/arc4_openssl.h deleted file mode 100644 index e1b97dda1..000000000 --- a/src/libstate/engine/openssl/arc4_openssl.h +++ /dev/null @@ -1,32 +0,0 @@ -/** -* OpenSSL's ARC4 -*/ - -#ifndef BOTAN_ARC4_OPENSSL_H__ -#define BOTAN_ARC4_OPENSSL_H__ - -#include <botan/stream_cipher.h> -#include <openssl/rc4.h> - -namespace Botan { - -class ARC4_OpenSSL : public StreamCipher - { - public: - void clear() throw() { std::memset(&state, 0, sizeof(state)); } - std::string name() const; - StreamCipher* clone() const { return new ARC4_OpenSSL(SKIP); } - - ARC4_OpenSSL(u32bit s = 0) : StreamCipher(1, 32), SKIP(s) { clear(); } - ~ARC4_OpenSSL() { clear(); } - private: - void cipher(const byte[], byte[], u32bit); - void key_schedule(const byte[], u32bit); - - const u32bit SKIP; - RC4_KEY state; - }; - -} - -#endif diff --git a/src/libstate/engine/openssl/eng_ossl.cpp b/src/libstate/engine/openssl/eng_ossl.cpp deleted file mode 100644 index 26e041293..000000000 --- a/src/libstate/engine/openssl/eng_ossl.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/** -OpenSSL Engine -(C) 2008 Jack Lloyd -*/ - -#include <botan/eng_ossl.h> -#include <botan/arc4_openssl.h> - -namespace Botan { - -/** -* Look for an OpenSSL-suported stream cipher (ARC4) -*/ -StreamCipher* -OpenSSL_Engine::find_stream_cipher(const SCAN_Name& request, - Algorithm_Factory&) - { - if(request.algo_name() == "ARC4") - return new ARC4_OpenSSL(request.argument_as_u32bit(0, 0)); - if(request.algo_name() == "RC4_drop") - return new ARC4_OpenSSL(768); - - return 0; - } - -} diff --git a/src/libstate/engine/openssl/info.txt b/src/libstate/engine/openssl/info.txt index b78d9aec3..1d8ff7fce 100644 --- a/src/libstate/engine/openssl/info.txt +++ b/src/libstate/engine/openssl/info.txt @@ -13,13 +13,11 @@ libstate </requires> <add> -arc4_openssl.h arc4_openssl.cpp bn_powm.cpp bn_wrap.cpp bn_wrap.h eng_ossl.h -eng_ossl.cpp ossl_bc.cpp ossl_dh.cpp ossl_dsa.cpp diff --git a/src/libstate/engine/openssl/ossl_bc.cpp b/src/libstate/engine/openssl/ossl_bc.cpp index c6ec0da4e..a9110f008 100644 --- a/src/libstate/engine/openssl/ossl_bc.cpp +++ b/src/libstate/engine/openssl/ossl_bc.cpp @@ -162,7 +162,7 @@ void EVP_BlockCipher::clear() throw() *************************************************/ BlockCipher* OpenSSL_Engine::find_block_cipher(const SCAN_Name& request, - Algorithm_Factory&) + Algorithm_Factory&) const { #define HANDLE_EVP_CIPHER(NAME, EVP) \ if(request.algo_name() == NAME && request.arg_count() == 0) \ |