diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2006-09-21 13:04:43 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2006-09-21 13:04:43 +0000 |
commit | 926c41bd293461df485e1ccde391ef471abf86c1 (patch) | |
tree | 38fb7da2421faf174a9cb9cdd055c8dabfa2739d /engines/ccgost/gost_ctl.c | |
parent | 1182301ca725de1b01371d0fb9b27ae2414c21c2 (diff) |
Updated version of gost engine.
Diffstat (limited to 'engines/ccgost/gost_ctl.c')
-rw-r--r-- | engines/ccgost/gost_ctl.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/engines/ccgost/gost_ctl.c b/engines/ccgost/gost_ctl.c new file mode 100644 index 0000000000..e31e1f9776 --- /dev/null +++ b/engines/ccgost/gost_ctl.c @@ -0,0 +1,74 @@ +/********************************************************************** + * gost_ctl.c * + * Copyright (c) 2005-2006 Cryptocom LTD * + * This file is distributed under the same license as OpenSSL * + * * + * Implementation of control commands for GOST engine * + * OpenSSL 0.9.9 libraries required * + **********************************************************************/ +#include <stdlib.h> +#include <string.h> +#include <openssl/engine.h> +#include "gost_lcl.h" + +static char *gost_params[GOST_PARAM_MAX+1]={NULL}; +static const char *gost_envnames[]={"CRYPT_PARAMS"}; +const ENGINE_CMD_DEFN gost_cmds[]= + { +/* { GOST_CTRL_RNG, + "RNG", + "Type of random number generator to use", + ENGINE_CMD_FLAG_STRING + }, + { GOST_CTRL_RNG_PARAMS, + "RNG_PARAMS", + "Parameter for random number generator", + ENGINE_CMD_FLAG_STRING + }, +*/ { GOST_CTRL_CRYPT_PARAMS, + "CRYPT_PARAMS", + "OID of default GOST 28147-89 parameters", + ENGINE_CMD_FLAG_STRING + }, +{0,NULL,NULL,0} + }; + + +int gost_control_func(ENGINE *e,int cmd,long i, void *p, void (*f)(void)) + { + int param = cmd-ENGINE_CMD_BASE; + int ret=0; + if (param <0 || param >GOST_PARAM_MAX) return -1; + ret=gost_set_default_param(param,p); + return ret; + } + +const char *get_gost_engine_param(int param) + { + char *tmp; + if (param <0 || param >GOST_PARAM_MAX) return NULL; + if (gost_params[param]!=NULL) + { + return gost_params[param]; + } + tmp = getenv(gost_envnames[param]); + if (tmp) + { + gost_params[param] = strdup(tmp); + return gost_params[param]; + } + return NULL; + } + +int gost_set_default_param(int param, const char *value) + { + const char *tmp; + if (param <0 || param >GOST_PARAM_MAX) return 0; + tmp = getenv(gost_envnames[param]); + /* if there is value in the environment, use it, else -passed string * */ + if (!tmp) tmp=value; + if (gost_params[param]) free(gost_params[param]); + gost_params[param] = strdup(tmp); + + return 1; + } |