summaryrefslogtreecommitdiffstats
path: root/engines
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2008-05-29 21:03:48 +0000
committerDr. Stephen Henson <steve@openssl.org>2008-05-29 21:03:48 +0000
commit777d717c40f271aec072540401aa117155a58624 (patch)
treec871762216dc69c2ae21a2437d89fb5781b21fbe /engines
parent143d84590f231e3df130c2602ddf9c19f5ae2be1 (diff)
Make CryptoAPI engine look more like the others....
Diffstat (limited to 'engines')
-rw-r--r--engines/e_capi.c41
1 files changed, 35 insertions, 6 deletions
diff --git a/engines/e_capi.c b/engines/e_capi.c
index 16f251cab0..c2ca152351 100644
--- a/engines/e_capi.c
+++ b/engines/e_capi.c
@@ -392,11 +392,8 @@ struct CAPI_KEY_st
HCRYPTKEY key;
};
-
-static int capi_bind_fn(ENGINE *e, const char *id)
+static int bind_capi(ENGINE *e)
{
- if (id && strcmp(id, engine_capi_id))
- return 0;
if (!ENGINE_set_id(e, engine_capi_id)
|| !ENGINE_set_name(e, engine_capi_name)
|| !ENGINE_set_init_function(e, capi_init)
@@ -413,9 +410,41 @@ static int capi_bind_fn(ENGINE *e, const char *id)
}
-
+#ifndef OPENSSL_NO_DYNAMIC_ENGINE
+static int bind_helper(ENGINE *e, const char *id)
+ {
+ if(id && (strcmp(id, engine_capi_id) != 0))
+ return 0;
+ if(!bind_capi(e))
+ return 0;
+ return 1;
+ }
IMPLEMENT_DYNAMIC_CHECK_FN()
-IMPLEMENT_DYNAMIC_BIND_FN(capi_bind_fn)
+IMPLEMENT_DYNAMIC_BIND_FN(bind_helper)
+#else
+static ENGINE *engine_capi(void)
+ {
+ ENGINE *ret = ENGINE_new();
+ if(!ret)
+ return NULL;
+ if(!bind_capi(ret))
+ {
+ ENGINE_free(ret);
+ return NULL;
+ }
+ return ret;
+ }
+
+void ENGINE_load_capi(void)
+ {
+ /* Copied from eng_[openssl|dyn].c */
+ ENGINE *toadd = engine_capi();
+ if(!toadd) return;
+ ENGINE_add(toadd);
+ ENGINE_free(toadd);
+ ERR_clear_error();
+ }
+#endif
static EVP_PKEY *capi_load_privkey(ENGINE *eng, const char *key_id,
UI_METHOD *ui_method, void *callback_data)