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>
12 #include <openssl/buffer.h>
15 static char *gost_params[GOST_PARAM_MAX+1]={NULL};
16 static const char *gost_envnames[]={"CRYPT_PARAMS"};
17 const ENGINE_CMD_DEFN gost_cmds[]=
21 "Type of random number generator to use",
22 ENGINE_CMD_FLAG_STRING
24 { GOST_CTRL_RNG_PARAMS,
26 "Parameter for random number generator",
27 ENGINE_CMD_FLAG_STRING
29 */ { GOST_CTRL_CRYPT_PARAMS,
31 "OID of default GOST 28147-89 parameters",
32 ENGINE_CMD_FLAG_STRING
38 int gost_control_func(ENGINE *e,int cmd,long i, void *p, void (*f)(void))
40 int param = cmd-ENGINE_CMD_BASE;
42 if (param <0 || param >GOST_PARAM_MAX) return -1;
43 ret=gost_set_default_param(param,p);
47 const char *get_gost_engine_param(int param)
50 if (param <0 || param >GOST_PARAM_MAX) return NULL;
51 if (gost_params[param]!=NULL)
53 return gost_params[param];
55 tmp = getenv(gost_envnames[param]);
58 gost_params[param] = BUF_strdup(tmp);
59 return gost_params[param];
64 int gost_set_default_param(int param, const char *value)
67 if (param <0 || param >GOST_PARAM_MAX) return 0;
68 tmp = getenv(gost_envnames[param]);
69 /* if there is value in the environment, use it, else -passed string * */
71 if (gost_params[param]) free(gost_params[param]);
72 gost_params[param] = BUF_strdup(tmp);