summaryrefslogtreecommitdiffstats
path: root/crypto/engine
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2002-01-22 01:40:18 +0000
committerDr. Stephen Henson <steve@openssl.org>2002-01-22 01:40:18 +0000
commitdf5eaa8a5297d42d1b44cfcf1210e7b016d3f7c1 (patch)
treec33133c2de7ca506de2789946bbdcd58b783ad89 /crypto/engine
parent6ce46d69f5d940b07e8f4f191121546c3f33ada6 (diff)
default_algorithms option in ENGINE config.
Diffstat (limited to 'crypto/engine')
-rw-r--r--crypto/engine/eng_cnf.c9
-rw-r--r--crypto/engine/eng_err.c2
-rw-r--r--crypto/engine/eng_fat.c39
-rw-r--r--crypto/engine/engine.h3
4 files changed, 51 insertions, 2 deletions
diff --git a/crypto/engine/eng_cnf.c b/crypto/engine/eng_cnf.c
index 8e3f894f66..3f5aa73943 100644
--- a/crypto/engine/eng_cnf.c
+++ b/crypto/engine/eng_cnf.c
@@ -138,7 +138,12 @@ int int_engine_configure(char *name, char *value, const CONF *cnf)
*/
if (!strcmp(ctrlvalue, "EMPTY"))
ctrlvalue = NULL;
- if (!ENGINE_ctrl_cmd_string(e,
+ if (!strcmp(ctrlname, "default_algorithms"))
+ {
+ if (!ENGINE_set_default_string(e, ctrlvalue))
+ goto err;
+ }
+ else if (!ENGINE_ctrl_cmd_string(e,
ctrlname, ctrlvalue, 0))
return 0;
}
@@ -151,7 +156,7 @@ int int_engine_configure(char *name, char *value, const CONF *cnf)
ENGINE_free(e);
return ret;
}
-
+
static int int_engine_module_init(CONF_IMODULE *md, const CONF *cnf)
{
diff --git a/crypto/engine/eng_err.c b/crypto/engine/eng_err.c
index f3c0c35863..8771a8d261 100644
--- a/crypto/engine/eng_err.c
+++ b/crypto/engine/eng_err.c
@@ -90,6 +90,7 @@ static ERR_STRING_DATA ENGINE_str_functs[]=
{ERR_PACK(0,ENGINE_F_ENGINE_MODULE_INIT,0), "ENGINE_MODULE_INIT"},
{ERR_PACK(0,ENGINE_F_ENGINE_NEW,0), "ENGINE_new"},
{ERR_PACK(0,ENGINE_F_ENGINE_REMOVE,0), "ENGINE_remove"},
+{ERR_PACK(0,ENGINE_F_ENGINE_SET_DEFAULT_STRING,0), "ENGINE_set_default_string"},
{ERR_PACK(0,ENGINE_F_ENGINE_SET_DEFAULT_TYPE,0), "ENGINE_SET_DEFAULT_TYPE"},
{ERR_PACK(0,ENGINE_F_ENGINE_SET_ID,0), "ENGINE_set_id"},
{ERR_PACK(0,ENGINE_F_ENGINE_SET_NAME,0), "ENGINE_set_name"},
@@ -133,6 +134,7 @@ static ERR_STRING_DATA ENGINE_str_reasons[]=
{ENGINE_R_INVALID_ARGUMENT ,"invalid argument"},
{ENGINE_R_INVALID_CMD_NAME ,"invalid cmd name"},
{ENGINE_R_INVALID_CMD_NUMBER ,"invalid cmd number"},
+{ENGINE_R_INVALID_STRING ,"invalid string"},
{ENGINE_R_MISSING_KEY_COMPONENTS ,"missing key components"},
{ENGINE_R_NOT_INITIALISED ,"not initialised"},
{ENGINE_R_NOT_LOADED ,"not loaded"},
diff --git a/crypto/engine/eng_fat.c b/crypto/engine/eng_fat.c
index 3fb379f37c..e101530ab1 100644
--- a/crypto/engine/eng_fat.c
+++ b/crypto/engine/eng_fat.c
@@ -57,6 +57,7 @@
#include "cryptlib.h"
#include "eng_int.h"
#include <openssl/engine.h>
+#include <openssl/conf.h>
int ENGINE_set_default(ENGINE *e, unsigned int flags)
{
@@ -81,6 +82,44 @@ int ENGINE_set_default(ENGINE *e, unsigned int flags)
return 1;
}
+/* Set default algorithms using a string */
+
+int int_def_cb(char *alg, int len, void *arg)
+ {
+ unsigned int *pflags = arg;
+ if (!strncmp(alg, "ALL", len))
+ *pflags |= ENGINE_METHOD_ALL;
+ else if (!strncmp(alg, "RSA", len))
+ *pflags |= ENGINE_METHOD_RSA;
+ else if (!strncmp(alg, "DSA", len))
+ *pflags |= ENGINE_METHOD_DSA;
+ else if (!strncmp(alg, "DH", len))
+ *pflags |= ENGINE_METHOD_DH;
+ else if (!strncmp(alg, "RAND", len))
+ *pflags |= ENGINE_METHOD_RAND;
+ else if (!strncmp(alg, "CIPHERS", len))
+ *pflags |= ENGINE_METHOD_CIPHERS;
+ else if (!strncmp(alg, "DIGESTS", len))
+ *pflags |= ENGINE_METHOD_DIGESTS;
+ else
+ return 0;
+ return 1;
+ }
+
+
+int ENGINE_set_default_string(ENGINE *e, char *list)
+ {
+ unsigned int flags = 0;
+ if (!CONF_parse_list(list, ',', 1, int_def_cb, &flags))
+ {
+ ENGINEerr(ENGINE_F_ENGINE_SET_DEFAULT_STRING,
+ ENGINE_R_INVALID_STRING);
+ ERR_add_error_data(2, "str=",list);
+ return 0;
+ }
+ return ENGINE_set_default(e, flags);
+ }
+
int ENGINE_register_complete(ENGINE *e)
{
ENGINE_register_ciphers(e);
diff --git a/crypto/engine/engine.h b/crypto/engine/engine.h
index 291841abcc..1dcb53bb1b 100644
--- a/crypto/engine/engine.h
+++ b/crypto/engine/engine.h
@@ -503,6 +503,7 @@ ENGINE *ENGINE_get_digest_engine(int nid);
* structure will have had its reference count up'd so the caller
* should still free their own reference 'e'. */
int ENGINE_set_default_RSA(ENGINE *e);
+int ENGINE_set_default_string(ENGINE *e, char *list);
/* Same for the other "methods" */
int ENGINE_set_default_DSA(ENGINE *e);
int ENGINE_set_default_DH(ENGINE *e);
@@ -651,6 +652,7 @@ void ERR_load_ENGINE_strings(void);
#define ENGINE_F_ENGINE_MODULE_INIT 187
#define ENGINE_F_ENGINE_NEW 122
#define ENGINE_F_ENGINE_REMOVE 123
+#define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189
#define ENGINE_F_ENGINE_SET_DEFAULT_TYPE 126
#define ENGINE_F_ENGINE_SET_ID 129
#define ENGINE_F_ENGINE_SET_NAME 130
@@ -691,6 +693,7 @@ void ERR_load_ENGINE_strings(void);
#define ENGINE_R_INVALID_ARGUMENT 143
#define ENGINE_R_INVALID_CMD_NAME 137
#define ENGINE_R_INVALID_CMD_NUMBER 138
+#define ENGINE_R_INVALID_STRING 150
#define ENGINE_R_MISSING_KEY_COMPONENTS 111
#define ENGINE_R_NOT_INITIALISED 117
#define ENGINE_R_NOT_LOADED 112