engine.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* Written by Richard Levitte <richard@levitte.org> for the OpenSSL
* project 2000.
*/
/* ====================================================================
* Copyright (c) 2000 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* licensing@OpenSSL.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
#ifndef OPENSSL_NO_ENGINE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef OPENSSL_NO_STDIO
#define APPS_WIN16
#endif
#include "apps.h"
#define PROG engine_main
static char *engine_usage[]={
"usage: engine opts [engine ...]\n",
" -v[v[v[v]]] - verbose mode, for each engine, list its 'control commands'\n",
" -vv will additionally display each command's description\n",
" -vvv will also add the input flags for each command\n",
" -vvvv will also show internal input flags\n",
" -c - for each engine, also list the capabilities\n",
" -t - for each engine, check that they are really available\n",
" -pre <cmd> - runs command 'cmd' against the ENGINE before any attempts\n",
" to load it (if -t is used)\n",
" -post <cmd> - runs command 'cmd' against the ENGINE after loading it\n",
" (only used if -t is also provided)\n",
" NB: -pre and -post will be applied to all ENGINEs supplied on the command\n",
" line, or all supported ENGINEs if none are specified.\n",
" Eg. '-pre \"SO_PATH:/lib/libdriver.so\"' calls command \"SO_PATH\" with\n",
" argument \"/lib/libdriver.so\".\n",
};
{
return;
}
{
int l = strlen(s);
{
return 0;
**buf = '\0';
}
if (**buf != '\0')
l += 2; /* ", " */
{
}
return 0;
if (**buf != '\0')
return 1;
}
{
/* Indent before displaying input flags */
if(flags == 0)
{
return 1;
}
/* If the object is internal, mark it in a way that shows instead of
* having it part of all the other flags, even if it really is. */
{
}
if(flags & ENGINE_CMD_FLAG_NUMERIC)
{
if(started)
{
err = 1;
}
started = 1;
}
/* Now we check that no combinations of the mutually exclusive NUMERIC,
* STRING, and NO_INPUT flags have been used. Future flags that can be
* OR'd together with these would need to added after these to preserve
* the testing logic. */
if(flags & ENGINE_CMD_FLAG_STRING)
{
if(started)
{
err = 1;
}
started = 1;
}
{
if(started)
{
err = 1;
}
started = 1;
}
/* Check for unknown flags */
if(flags)
{
}
if(err)
return 1;
}
{
static const int line_wrap = 78;
int num;
int ret = 0;
int flags;
int xpos = 0;
{
#if 0
#endif
return 1;
}
cmds = sk_new_null();
if(!cmds)
goto err;
do {
int len;
/* Get the command input flags */
goto err;
{
/* Get the command name */
goto err;
goto err;
NULL) <= 0)
goto err;
/* Get the command description */
goto err;
if(len > 0)
{
goto err;
NULL) <= 0)
goto err;
}
/* Now decide on the output */
if(xpos == 0)
/* Do an indent */
else
/* Otherwise prepend a ", " */
if(verbose == 1)
{
/* We're just listing names, comma-delimited */
{
}
}
else
{
/* We're listing names plus descriptions */
/* ... and sometimes input flags */
indent))
goto err;
xpos = 0;
}
}
/* Move to the next command */
} while(num > 0);
if(xpos > 0)
ret = 1;
err:
return ret;
}
{
if(num < 0)
{
return;
}
{
char buf[256];
/* Check if this command has no ":arg" */
{
res = 0;
}
else
{
{
return;
}
arg++; /* Move past the ":" */
/* Call the command with the argument */
res = 0;
}
if(res)
else
{
}
}
}
int MAIN(int, char **);
{
int ret=1,i;
char **pp;
ENGINE *e;
int badops=1;
const char *indent = " ";
apps_startup();
goto end;
#ifdef OPENSSL_SYS_VMS
{
}
#endif
argc--;
argv++;
while (argc >= 1)
{
{
goto skip_arg_loop;
goto skip_arg_loop;
}
list_cap=1;
test_avail=1;
{
}
{
}
goto skip_arg_loop;
else
argc--;
argv++;
}
/* Looks like everything went OK */
badops = 0;
if (badops)
{
goto end;
}
{
{
}
}
{
{
const char *name = ENGINE_get_name(e);
/* Do "id" first, then "name". Easier to auto-parse. */
{
ENGINE_get_id(e), ENGINE_get_name(e));
}
if (list_cap)
{
int cap_size = 256;
int k,n;
const int *nids;
if (ENGINE_get_RSA(e) != NULL
&cap_size, 256))
goto end;
if (ENGINE_get_DSA(e) != NULL
&cap_size, 256))
goto end;
if (ENGINE_get_DH(e) != NULL
&cap_size, 256))
goto end;
if (ENGINE_get_RAND(e) != NULL
&cap_size, 256))
goto end;
fn_c = ENGINE_get_ciphers(e);
if(!fn_c) goto skip_ciphers;
for(k=0 ; k < n ; ++k)
if(!append_buf(&cap_buf,
OBJ_nid2sn(nids[k]),
&cap_size, 256))
goto end;
fn_d = ENGINE_get_digests(e);
if(!fn_d) goto skip_digests;
for(k=0 ; k < n ; ++k)
if(!append_buf(&cap_buf,
OBJ_nid2sn(nids[k]),
&cap_size, 256))
goto end;
}
if(test_avail)
{
if (ENGINE_init(e))
{
ENGINE_finish(e);
}
else
{
}
}
goto end;
ENGINE_free(e);
}
else
}
ret=0;
end:
}
#else
# if PEDANTIC
# endif
#endif