1 /**********************************************************************
3 * Copyright (c) 2005-2006 Cryptocom LTD *
4 * This file is distributed under the same license as OpenSSL *
6 * Implementation of control commands for GOST engine *
7 * OpenSSL 0.9.9 libraries required *
8 **********************************************************************/
11 #include <openssl/engine.h>
14 static char *gost_params[GOST_PARAM_MAX+1]={NULL};
15 static const char *gost_envnames[]={"CRYPT_PARAMS"};
16 const ENGINE_CMD_DEFN gost_cmds[]=
20 "Type of random number generator to use",
21 ENGINE_CMD_FLAG_STRING
23 { GOST_CTRL_RNG_PARAMS,
25 "Parameter for random number generator",
26 ENGINE_CMD_FLAG_STRING
28 */ { GOST_CTRL_CRYPT_PARAMS,
30 "OID of default GOST 28147-89 parameters",
31 ENGINE_CMD_FLAG_STRING
37 int gost_control_func(ENGINE *e,int cmd,long i, void *p, void (*f)(void))
39 int param = cmd-ENGINE_CMD_BASE;
41 if (param <0 || param >GOST_PARAM_MAX) return -1;
42 ret=gost_set_default_param(param,p);
46 const char *get_gost_engine_param(int param)
49 if (param <0 || param >GOST_PARAM_MAX) return NULL;
50 if (gost_params[param]!=NULL)
52 return gost_params[param];
54 tmp = getenv(gost_envnames[param]);
57 gost_params[param] = strdup(tmp);
58 return gost_params[param];
63 int gost_set_default_param(int param, const char *value)
66 if (param <0 || param >GOST_PARAM_MAX) return 0;
67 tmp = getenv(gost_envnames[param]);
68 /* if there is value in the environment, use it, else -passed string * */
70 if (gost_params[param]) free(gost_params[param]);
71 gost_params[param] = strdup(tmp);