summaryrefslogtreecommitdiffstats
path: root/crypto/engine/eng_openssl.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2002-03-06 14:15:13 +0000
committerDr. Stephen Henson <steve@openssl.org>2002-03-06 14:15:13 +0000
commit0dc092334bc785b6fb0c8b568acba3db665b7e22 (patch)
tree840b102627a53bead4f8e80f34a81f6c1610d05e /crypto/engine/eng_openssl.c
parent36c194638e86cd46d5da2b3efbe9ae5354e19096 (diff)
ENGINE module additions.
Add "init" command to control ENGINE initialization. Call ENGINE_finish on initialized ENGINEs on exit. Reorder shutdown in apps.c: modules should be shut down first. Add test private key loader to openssl ENGINE: this just loads a private key in PEM format. Fix print format for dh length parameter.
Diffstat (limited to 'crypto/engine/eng_openssl.c')
-rw-r--r--crypto/engine/eng_openssl.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/crypto/engine/eng_openssl.c b/crypto/engine/eng_openssl.c
index 97642ae230..e9d976f46b 100644
--- a/crypto/engine/eng_openssl.c
+++ b/crypto/engine/eng_openssl.c
@@ -62,11 +62,13 @@
#include "cryptlib.h"
#include <openssl/engine.h>
#include <openssl/dso.h>
+#include <openssl/pem.h>
/* This testing gunk is implemented (and explained) lower down. It also assumes
* the application explicitly calls "ENGINE_load_openssl()" because this is no
* longer automatic in ENGINE_load_builtin_engines(). */
#define TEST_ENG_OPENSSL_RC4
+#define TEST_ENG_OPENSSL_PKEY
/* #define TEST_ENG_OPENSSL_RC4_OTHERS */
#define TEST_ENG_OPENSSL_RC4_P_INIT
/* #define TEST_ENG_OPENSSL_RC4_P_CIPHER */
@@ -85,6 +87,11 @@ static int openssl_digests(ENGINE *e, const EVP_MD **digest,
const int **nids, int nid);
#endif
+#ifdef TEST_ENG_OPENSSL_PKEY
+static EVP_PKEY *openssl_load_privkey(ENGINE *eng, const char *key_id,
+ UI_METHOD *ui_method, void *callback_data);
+#endif
+
/* The constants used when creating the ENGINE */
static const char *engine_openssl_id = "openssl";
static const char *engine_openssl_name = "Software engine support";
@@ -95,6 +102,7 @@ static int bind_helper(ENGINE *e)
{
if(!ENGINE_set_id(e, engine_openssl_id)
|| !ENGINE_set_name(e, engine_openssl_name)
+#ifndef TEST_ENG_OPENSSL_NO_ALGORITHMS
#ifndef OPENSSL_NO_RSA
|| !ENGINE_set_RSA(e, RSA_get_default_method())
#endif
@@ -111,6 +119,10 @@ static int bind_helper(ENGINE *e)
#ifdef TEST_ENG_OPENSSL_SHA
|| !ENGINE_set_digests(e, openssl_digests)
#endif
+#endif
+#ifdef TEST_ENG_OPENSSL_PKEY
+ || !ENGINE_set_load_privkey_function(e, openssl_load_privkey)
+#endif
)
return 0;
/* If we add errors to this ENGINE, ensure the error handling is setup here */
@@ -317,3 +329,19 @@ static int openssl_digests(ENGINE *e, const EVP_MD **digest,
return 1;
}
#endif
+
+#ifdef TEST_ENG_OPENSSL_PKEY
+static EVP_PKEY *openssl_load_privkey(ENGINE *eng, const char *key_id,
+ UI_METHOD *ui_method, void *callback_data)
+ {
+ BIO *in;
+ EVP_PKEY *key;
+ fprintf(stderr, "(TEST_ENG_OPENSSL_PKEY)Loading Private key %s\n", key_id);
+ in = BIO_new_file(key_id, "r");
+ if (!in)
+ return NULL;
+ key = PEM_read_bio_PrivateKey(in, NULL, 0, NULL);
+ BIO_free(in);
+ return key;
+ }
+#endif