63 #ifdef OPENSSL_NO_STDIO
68 #ifndef OPENSSL_NO_ENGINE
73 #define PROG engine_main
75 static const char *engine_usage[]={
76 "usage: engine opts [engine ...]\n",
77 " -v[v[v[v]]] - verbose mode, for each engine, list its 'control commands'\n",
78 " -vv will additionally display each command's description\n",
79 " -vvv will also add the input flags for each command\n",
80 " -vvvv will also show internal input flags\n",
81 " -c - for each engine, also list the capabilities\n",
82 " -t[t] - for each engine, check that they are really available\n",
83 " -tt will display error trace for unavailable engines\n",
84 " -pre <cmd> - runs command 'cmd' against the ENGINE before any attempts\n",
85 " to load it (if -t is used)\n",
86 " -post <cmd> - runs command 'cmd' against the ENGINE after loading it\n",
87 " (only used if -t is also provided)\n",
88 " NB: -pre and -post will be applied to all ENGINEs supplied on the command\n",
89 " line, or all supported ENGINEs if none are specified.\n",
90 " Eg. '-pre \"SO_PATH:/lib/libdriver.so\"' calls command \"SO_PATH\" with\n",
91 " argument \"/lib/libdriver.so\".\n",
95 static void identity(
char *
ptr)
100 static int append_buf(
char **buf,
const char *s,
int *size,
int step)
116 if (strlen(*buf) + strlen(s) >= (
unsigned int)*size)
132 static int util_flags(
BIO *
bio_out,
unsigned int flags,
const char *indent)
134 int started = 0, err = 0;
136 BIO_printf(bio_out,
"%s%s(input flags): ", indent, indent);
179 flags = flags & ~ENGINE_CMD_FLAG_NUMERIC &
180 ~ENGINE_CMD_FLAG_STRING &
181 ~ENGINE_CMD_FLAG_NO_INPUT &
182 ~ENGINE_CMD_FLAG_INTERNAL;
194 static int util_verbose(
ENGINE *
e,
int verbose,
BIO *bio_out,
const char *indent)
196 static const int line_wrap = 78;
206 0, NULL, NULL)) <= 0))
209 BIO_printf(bio_out,
"%s<no control commands>\n", indent);
224 if (!(flags & ENGINE_CMD_FLAG_INTERNAL) || verbose >= 4)
257 if((xpos > (
int)strlen(indent)) &&
258 (xpos + (
int)strlen(name) > line_wrap))
269 (desc == NULL) ?
"<no description>" : desc);
271 if((verbose >= 3) && !util_flags(bio_out, flags,
294 BIO *bio_out,
const char *indent)
300 BIO_printf(bio_out,
"[Error]: internal stack error\n");
303 for(loop = 0; loop <
num; loop++)
306 const char *cmd, *
arg;
310 if((arg = strstr(cmd,
":")) == NULL)
317 if((
int)(arg - cmd) > 254)
319 BIO_printf(bio_out,
"[Error]: command name too long\n");
322 memcpy(buf, cmd, (
int)(arg - cmd));
339 int MAIN(
int,
char **);
341 int MAIN(
int argc,
char **argv)
345 int verbose=0, list_cap=0, test_avail=0, test_avail_noise = 0;
352 const char *indent =
" ";
363 #ifdef OPENSSL_SYS_VMS
366 bio_out =
BIO_push(tmpbio, bio_out);
374 if (strncmp(*argv,
"-v",2) == 0)
376 if(strspn(*argv + 1,
"v") < strlen(*argv + 1))
378 if((verbose=strlen(*argv + 1)) > 4)
381 else if (strcmp(*argv,
"-c") == 0)
383 else if (strncmp(*argv,
"-t",2) == 0)
386 if(strspn(*argv + 1,
"t") < strlen(*argv + 1))
388 if((test_avail_noise = strlen(*argv + 1) - 1) > 1)
391 else if (strcmp(*argv,
"-pre") == 0)
398 else if (strcmp(*argv,
"-post") == 0)
405 else if ((strncmp(*argv,
"-h",2) == 0) ||
406 (strcmp(*argv,
"-?") == 0))
419 for (pp=engine_usage; (*pp != NULL); pp++)
440 util_do_cmds(e, pre_cmds, bio_out, indent);
449 char *cap_buf = NULL;
457 && !append_buf(&cap_buf,
"RSA",
461 && !append_buf(&cap_buf,
"DSA",
465 && !append_buf(&cap_buf,
"DH",
469 && !append_buf(&cap_buf,
"RAND",
474 if(!fn_c)
goto skip_ciphers;
475 n = fn_c(e, NULL, &nids, 0);
476 for(k=0 ; k < n ; ++k)
477 if(!append_buf(&cap_buf,
484 if(!fn_d)
goto skip_digests;
485 n = fn_d(e, NULL, &nids, 0);
486 for(k=0 ; k < n ; ++k)
487 if(!append_buf(&cap_buf,
494 if(!fn_pk)
goto skip_pmeths;
495 n = fn_pk(e, NULL, &nids, 0);
496 for(k=0 ; k < n ; ++k)
497 if(!append_buf(&cap_buf,
502 if (cap_buf && (*cap_buf !=
'\0'))
513 util_do_cmds(e, post_cmds, bio_out, indent);
524 if((verbose > 0) && !util_verbose(e, verbose, bio_out, indent))
546 static void *dummy=&dummy;