aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine/openssl
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-10-28 22:55:12 +0000
committerlloyd <[email protected]>2009-10-28 22:55:12 +0000
commit3623be3fd05d890309cc3da4b3a1e319e357df65 (patch)
tree34ca43fcf8a7007cc01a3919f63e9ab6763cb673 /src/engine/openssl
parentfc1e61500e77fcabe67e6d2607810c1ba071bbdd (diff)
parent9462f875b13a321f42a127166d49670ca04afcde (diff)
propagate from branch 'net.randombit.botan.1_8' (head 3158f8272a3582dd44dfb771665eb71f7d005339)
to branch 'net.randombit.botan' (head bf629b13dd132b263e76a72b7eca0f7e4ab19aac)
Diffstat (limited to 'src/engine/openssl')
-rw-r--r--src/engine/openssl/arc4_openssl.cpp2
-rw-r--r--src/engine/openssl/ossl_bc.cpp44
-rw-r--r--src/engine/openssl/ossl_md.cpp28
3 files changed, 57 insertions, 17 deletions
diff --git a/src/engine/openssl/arc4_openssl.cpp b/src/engine/openssl/arc4_openssl.cpp
index 08ed3eb10..793e1faff 100644
--- a/src/engine/openssl/arc4_openssl.cpp
+++ b/src/engine/openssl/arc4_openssl.cpp
@@ -19,7 +19,7 @@ namespace {
class ARC4_OpenSSL : public StreamCipher
{
public:
- void clear() throw() { std::memset(&state, 0, sizeof(state)); }
+ void clear() { std::memset(&state, 0, sizeof(state)); }
std::string name() const;
StreamCipher* clone() const { return new ARC4_OpenSSL(SKIP); }
diff --git a/src/engine/openssl/ossl_bc.cpp b/src/engine/openssl/ossl_bc.cpp
index 4d3761adb..7fdf54e42 100644
--- a/src/engine/openssl/ossl_bc.cpp
+++ b/src/engine/openssl/ossl_bc.cpp
@@ -18,7 +18,7 @@ namespace {
class EVP_BlockCipher : public BlockCipher
{
public:
- void clear() throw();
+ void clear();
std::string name() const { return cipher_name; }
BlockCipher* clone() const;
EVP_BlockCipher(const EVP_CIPHER*, const std::string&);
@@ -27,8 +27,8 @@ class EVP_BlockCipher : public BlockCipher
~EVP_BlockCipher();
private:
- void enc(const byte[], byte[]) const;
- void dec(const byte[], byte[]) const;
+ void encrypt_n(const byte in[], byte out[], u32bit blocks) const;
+ void decrypt_n(const byte in[], byte out[], u32bit blocks) const;
void key_schedule(const byte[], u32bit);
std::string cipher_name;
mutable EVP_CIPHER_CTX encrypt, decrypt;
@@ -90,19 +90,21 @@ EVP_BlockCipher::~EVP_BlockCipher()
/*
* Encrypt a block
*/
-void EVP_BlockCipher::enc(const byte in[], byte out[]) const
+void EVP_BlockCipher::encrypt_n(const byte in[], byte out[],
+ u32bit blocks) const
{
int out_len = 0;
- EVP_EncryptUpdate(&encrypt, out, &out_len, in, BLOCK_SIZE);
+ EVP_EncryptUpdate(&encrypt, out, &out_len, in, blocks * BLOCK_SIZE);
}
/*
* Decrypt a block
*/
-void EVP_BlockCipher::dec(const byte in[], byte out[]) const
+void EVP_BlockCipher::decrypt_n(const byte in[], byte out[],
+ u32bit blocks) const
{
int out_len = 0;
- EVP_DecryptUpdate(&decrypt, out, &out_len, in, BLOCK_SIZE);
+ EVP_DecryptUpdate(&decrypt, out, &out_len, in, blocks * BLOCK_SIZE);
}
/*
@@ -143,7 +145,7 @@ BlockCipher* EVP_BlockCipher::clone() const
/*
* Clear memory of sensitive data
*/
-void EVP_BlockCipher::clear() throw()
+void EVP_BlockCipher::clear()
{
const EVP_CIPHER* algo = EVP_CIPHER_CTX_cipher(&encrypt);
@@ -174,7 +176,7 @@ OpenSSL_Engine::find_block_cipher(const SCAN_Name& request,
if(request.algo_name() == NAME && request.arg_count() == 0) \
return new EVP_BlockCipher(EVP, NAME, MIN, MAX, MOD);
-#if 0
+#if !defined(OPENSSL_NO_AES)
/*
Using OpenSSL's AES causes crashes inside EVP on x86-64 with OpenSSL 0.9.8g
cause is unknown
@@ -184,12 +186,36 @@ OpenSSL_Engine::find_block_cipher(const SCAN_Name& request,
HANDLE_EVP_CIPHER("AES-256", EVP_aes_256_ecb());
#endif
+#if !defined(OPENSSL_NO_DES)
HANDLE_EVP_CIPHER("DES", EVP_des_ecb());
HANDLE_EVP_CIPHER_KEYLEN("TripleDES", EVP_des_ede3_ecb(), 16, 24, 8);
+#endif
+#if !defined(OPENSSL_NO_BF)
HANDLE_EVP_CIPHER_KEYLEN("Blowfish", EVP_bf_ecb(), 1, 56, 1);
+#endif
+
+#if !defined(OPENSSL_NO_CAST)
HANDLE_EVP_CIPHER_KEYLEN("CAST-128", EVP_cast5_ecb(), 1, 16, 1);
+#endif
+
+#if !defined(OPENSSL_NO_RC2)
HANDLE_EVP_CIPHER_KEYLEN("RC2", EVP_rc2_ecb(), 1, 32, 1);
+#endif
+
+#if !defined(OPENSSL_NO_RC5)
+ if(request.algo_name() == "RC5")
+ if(request.arg_as_u32bit(0, 12) == 12)
+ return new EVP_BlockCipher(EVP_rc5_32_12_16_ecb(), "RC5(12)", 1, 32, 1);
+#endif
+
+#if !defined(OPENSSL_NO_IDEA)
+ HANDLE_EVP_CIPHER("IDEA", EVP_idea_ecb());
+#endif
+
+#if !defined(OPENSSL_NO_SEED)
+ HANDLE_EVP_CIPHER("SEED", EVP_seed_ecb());
+#endif
#undef HANDLE_EVP_CIPHER
#undef HANDLE_EVP_CIPHER_KEYLEN
diff --git a/src/engine/openssl/ossl_md.cpp b/src/engine/openssl/ossl_md.cpp
index 7c8fb678c..1e01a6f25 100644
--- a/src/engine/openssl/ossl_md.cpp
+++ b/src/engine/openssl/ossl_md.cpp
@@ -18,7 +18,7 @@ namespace {
class EVP_HashFunction : public HashFunction
{
public:
- void clear() throw();
+ void clear();
std::string name() const { return algo_name; }
HashFunction* clone() const;
EVP_HashFunction(const EVP_MD*, const std::string&);
@@ -52,7 +52,7 @@ void EVP_HashFunction::final_result(byte output[])
/*
* Clear memory of sensitive data
*/
-void EVP_HashFunction::clear() throw()
+void EVP_HashFunction::clear()
{
const EVP_MD* algo = EVP_MD_CTX_md(&md);
EVP_DigestInit_ex(&md, algo, 0);
@@ -95,27 +95,41 @@ EVP_HashFunction::~EVP_HashFunction()
HashFunction* OpenSSL_Engine::find_hash(const SCAN_Name& request,
Algorithm_Factory&) const
{
-#ifndef OPENSSL_NO_SHA
+#if !defined(OPENSSL_NO_SHA)
if(request.algo_name() == "SHA-160")
return new EVP_HashFunction(EVP_sha1(), "SHA-160");
#endif
-#ifndef OPENSSL_NO_MD2
+#if !defined(OPENSSL_NO_SHA256)
+ if(request.algo_name() == "SHA-224")
+ return new EVP_HashFunction(EVP_sha224(), "SHA-224");
+ if(request.algo_name() == "SHA-256")
+ return new EVP_HashFunction(EVP_sha256(), "SHA-256");
+#endif
+
+#if !defined(OPENSSL_NO_SHA512)
+ if(request.algo_name() == "SHA-384")
+ return new EVP_HashFunction(EVP_sha384(), "SHA-384");
+ if(request.algo_name() == "SHA-512")
+ return new EVP_HashFunction(EVP_sha512(), "SHA-512");
+#endif
+
+#if !defined(OPENSSL_NO_MD2)
if(request.algo_name() == "MD2")
return new EVP_HashFunction(EVP_md2(), "MD2");
#endif
-#ifndef OPENSSL_NO_MD4
+#if !defined(OPENSSL_NO_MD4)
if(request.algo_name() == "MD4")
return new EVP_HashFunction(EVP_md4(), "MD4");
#endif
-#ifndef OPENSSL_NO_MD5
+#if !defined(OPENSSL_NO_MD5)
if(request.algo_name() == "MD5")
return new EVP_HashFunction(EVP_md5(), "MD5");
#endif
-#ifndef OPENSSL_NO_RIPEMD
+#if !defined(OPENSSL_NO_RIPEMD)
if(request.algo_name() == "RIPEMD-160")
return new EVP_HashFunction(EVP_ripemd160(), "RIPEMD-160");
#endif