aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-11-10 14:52:22 +0000
committerlloyd <[email protected]>2008-11-10 14:52:22 +0000
commit52fa0b875ad616dd997ac6253f92ffb18812209c (patch)
tree290c0b10f463e6d5490c1ab45559f77248efbb64
parent48e8a5487a4146e1e7dab7b6bb316bcafe957d49 (diff)
Modify OpenSSL to use SCAN_Name
-rw-r--r--src/libstate/engine/openssl/eng_ossl.cpp2
-rw-r--r--src/libstate/engine/openssl/ossl_bc.cpp40
-rw-r--r--src/libstate/engine/openssl/ossl_md.cpp39
3 files changed, 34 insertions, 47 deletions
diff --git a/src/libstate/engine/openssl/eng_ossl.cpp b/src/libstate/engine/openssl/eng_ossl.cpp
index c6dbb0ede..6aaabcbfc 100644
--- a/src/libstate/engine/openssl/eng_ossl.cpp
+++ b/src/libstate/engine/openssl/eng_ossl.cpp
@@ -4,6 +4,8 @@ OpenSSL Engine
*/
#include <botan/eng_ossl.h>
+#include <botan/arc4_openssl.h>
+#include <botan/scan_name.h>
namespace Botan {
diff --git a/src/libstate/engine/openssl/ossl_bc.cpp b/src/libstate/engine/openssl/ossl_bc.cpp
index 1863ad477..3427fce59 100644
--- a/src/libstate/engine/openssl/ossl_bc.cpp
+++ b/src/libstate/engine/openssl/ossl_bc.cpp
@@ -4,8 +4,7 @@
*************************************************/
#include <botan/eng_ossl.h>
-#include <botan/parsing.h>
-#include <botan/libstate.h>
+#include <botan/scan_name.h>
#include <openssl/evp.h>
namespace Botan {
@@ -165,36 +164,27 @@ void EVP_BlockCipher::clear() throw()
BlockCipher*
OpenSSL_Engine::find_block_cipher(const std::string& algo_spec) const
{
-#define HANDLE_EVP_CIPHER(NAME, EVP) \
- if(algo_name == NAME) \
- { \
- if(name.size() == 1) \
- return new EVP_BlockCipher(EVP, NAME); \
- throw Invalid_Algorithm_Name(algo_spec); \
- }
+ SCAN_Name request(algo_spec);
-#define HANDLE_EVP_CIPHER_KEYLEN(NAME, EVP, MIN, MAX, MOD) \
- if(algo_name == NAME) \
- { \
- if(name.size() == 1) \
- return new EVP_BlockCipher(EVP, NAME, MIN, MAX, MOD); \
- throw Invalid_Algorithm_Name(algo_spec); \
- }
+#define HANDLE_EVP_CIPHER(NAME, EVP) \
+ if(request.algo_name() == NAME && request.arg_count() == 0) \
+ return new EVP_BlockCipher(EVP, NAME);
- std::vector<std::string> name = parse_algorithm_name(algo_spec);
- if(name.size() == 0)
- return 0;
- const std::string algo_name = global_state().deref_alias(name[0]);
+#define HANDLE_EVP_CIPHER_KEYLEN(NAME, EVP, MIN, MAX, MOD) \
+ if(request.algo_name() == NAME && request.arg_count() == 0) \
+ return new EVP_BlockCipher(EVP, NAME, MIN, MAX, MOD);
- HANDLE_EVP_CIPHER_KEYLEN("Blowfish", EVP_bf_ecb(), 1, 56, 1);
- HANDLE_EVP_CIPHER_KEYLEN("CAST-128", EVP_cast5_ecb(), 1, 16, 1);
- HANDLE_EVP_CIPHER_KEYLEN("RC2", EVP_rc2_ecb(), 1, 32, 1);
- HANDLE_EVP_CIPHER_KEYLEN("TripleDES", EVP_des_ede3_ecb(), 16, 24, 8);
- HANDLE_EVP_CIPHER("DES", EVP_des_ecb());
HANDLE_EVP_CIPHER("AES-128", EVP_aes_128_ecb());
HANDLE_EVP_CIPHER("AES-192", EVP_aes_192_ecb());
HANDLE_EVP_CIPHER("AES-256", EVP_aes_256_ecb());
+ HANDLE_EVP_CIPHER("DES", EVP_des_ecb());
+ HANDLE_EVP_CIPHER_KEYLEN("TripleDES", EVP_des_ede3_ecb(), 16, 24, 8);
+
+ HANDLE_EVP_CIPHER_KEYLEN("Blowfish", EVP_bf_ecb(), 1, 56, 1);
+ HANDLE_EVP_CIPHER_KEYLEN("CAST-128", EVP_cast5_ecb(), 1, 16, 1);
+ HANDLE_EVP_CIPHER_KEYLEN("RC2", EVP_rc2_ecb(), 1, 32, 1);
+
#undef HANDLE_EVP_CIPHER
#undef HANDLE_EVP_CIPHER_KEYLEN
diff --git a/src/libstate/engine/openssl/ossl_md.cpp b/src/libstate/engine/openssl/ossl_md.cpp
index 8e24c7213..d009e4c42 100644
--- a/src/libstate/engine/openssl/ossl_md.cpp
+++ b/src/libstate/engine/openssl/ossl_md.cpp
@@ -4,8 +4,7 @@
*************************************************/
#include <botan/eng_ossl.h>
-#include <botan/parsing.h>
-#include <botan/libstate.h>
+#include <botan/scan_name.h>
#include <openssl/evp.h>
namespace Botan {
@@ -94,26 +93,22 @@ EVP_HashFunction::~EVP_HashFunction()
*************************************************/
HashFunction* OpenSSL_Engine::find_hash(const std::string& algo_spec) const
{
- std::vector<std::string> name = parse_algorithm_name(algo_spec);
- if(name.size() == 0)
- return 0;
- const std::string algo_name = global_state().deref_alias(name[0]);
-
-#define HANDLE_EVP_MD(NAME, EVP) \
- if(algo_name == NAME) \
- { \
- if(name.size() == 1) \
- return new EVP_HashFunction(EVP, NAME); \
- throw Invalid_Algorithm_Name(algo_spec); \
- }
-
- HANDLE_EVP_MD("SHA-160", EVP_sha1());
- HANDLE_EVP_MD("MD2", EVP_md2());
- HANDLE_EVP_MD("MD4", EVP_md4());
- HANDLE_EVP_MD("MD5", EVP_md5());
- HANDLE_EVP_MD("RIPEMD-160", EVP_ripemd160());
-
-#undef HANDLE_EVP_MD
+ SCAN_Name request(algo_spec);
+
+ if(request.algo_name() == "SHA-160")
+ return new EVP_HashFunction(EVP_sha1(), "SHA-160");
+
+ if(request.algo_name() == "MD2")
+ return new EVP_HashFunction(EVP_md2(), "MD2");
+
+ if(request.algo_name() == "MD4")
+ return new EVP_HashFunction(EVP_md4(), "MD4");
+
+ if(request.algo_name() == "MD5")
+ return new EVP_HashFunction(EVP_md5(), "MD5");
+
+ if(request.algo_name() == "RIPEMD-160")
+ return new EVP_HashFunction(EVP_ripemd160(), "RIPEMD-160");
return 0;
}