diff options
author | lloyd <[email protected]> | 2008-11-10 21:51:08 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-10 21:51:08 +0000 |
commit | 88b635f50937f926097b76c7834baead3b936dfe (patch) | |
tree | c267d904c6b1bfb6f59a0ad9db5a52d5d36ca9c3 | |
parent | f144d769db322df4f4c65331951b2ebafdd16f4e (diff) |
Move x86 Serpent to the asm engine module.
Move OpenSSL's RC4 back into a single file again.
-rw-r--r-- | src/libstate/engine/asm_engine/asm_engine.cpp | 15 | ||||
-rw-r--r-- | src/libstate/engine/asm_engine/asm_engine.h | 3 | ||||
-rw-r--r-- | src/libstate/engine/def_engine/lookup_block.cpp | 9 | ||||
-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 |
8 files changed, 55 insertions, 73 deletions
diff --git a/src/libstate/engine/asm_engine/asm_engine.cpp b/src/libstate/engine/asm_engine/asm_engine.cpp index 8dfc93b2e..9f113b1ce 100644 --- a/src/libstate/engine/asm_engine/asm_engine.cpp +++ b/src/libstate/engine/asm_engine/asm_engine.cpp @@ -6,6 +6,10 @@ #include <botan/asm_engine.h> #include <botan/hash.h> +#if defined(BOTAN_HAS_SERPENT_IA32) + #include <botan/serp_ia32.h> +#endif + #if defined(BOTAN_HAS_MD4_IA32) #include <botan/md4_ia32.h> #endif @@ -28,12 +32,17 @@ namespace Botan { -/* -BlockCipher* Assembler_Engine::find_block_cipher(const std::string&) const +BlockCipher* +Assembler_Engine::find_block_cipher(const SCAN_Name& request, + Algorithm_Factory&) const { +#if defined(BOTAN_HAS_SERPENT_IA32) + if(request.algo_name() == "Serpent") + return new Serpent_IA32; +#endif + return 0; } -*/ HashFunction* Assembler_Engine::find_hash(const SCAN_Name& request, Algorithm_Factory&) const diff --git a/src/libstate/engine/asm_engine/asm_engine.h b/src/libstate/engine/asm_engine/asm_engine.h index cb27e19c1..6a4188617 100644 --- a/src/libstate/engine/asm_engine/asm_engine.h +++ b/src/libstate/engine/asm_engine/asm_engine.h @@ -15,7 +15,8 @@ class BOTAN_DLL Assembler_Engine : public Engine public: std::string provider_name() const { return "asm"; } private: - //BlockCipher* find_block_cipher(const std::string&) const; + BlockCipher* find_block_cipher(const SCAN_Name&, + Algorithm_Factory&) const; HashFunction* find_hash(const SCAN_Name& reqeust, Algorithm_Factory&) const; diff --git a/src/libstate/engine/def_engine/lookup_block.cpp b/src/libstate/engine/def_engine/lookup_block.cpp index de4265ba4..ce981ae0c 100644 --- a/src/libstate/engine/def_engine/lookup_block.cpp +++ b/src/libstate/engine/def_engine/lookup_block.cpp @@ -81,10 +81,6 @@ #include <botan/serpent.h> #endif -#if defined(BOTAN_HAS_SERPENT_IA32) - #include <botan/serp_ia32.h> -#endif - #if defined(BOTAN_HAS_SKIPJACK) #include <botan/skipjack.h> #endif @@ -202,10 +198,7 @@ Default_Engine::find_block_cipher(const SCAN_Name& request, return new SEED; #endif -#if defined(BOTAN_HAS_SERPENT_IA32) - if(request.algo_name() == "Serpent") - return new Serpent_IA32; -#elif defined(BOTAN_HAS_SERPENT) +#if defined(BOTAN_HAS_SERPENT) if(request.algo_name() == "Serpent") return new Serpent; #endif 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) \ |