diff options
Diffstat (limited to 'src/libstate/engine/openssl/arc4_openssl.cpp')
-rw-r--r-- | src/libstate/engine/openssl/arc4_openssl.cpp | 39 |
1 files changed, 39 insertions, 0 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; + } + +} |