if (desc == NULL)
desc = "certificate";
- if (uri == NULL) {
- unbuffer(stdin);
- uri = "";
- }
(void)load_key_cert_crl(uri, maybe_stdin, pass, desc, NULL, &cert, NULL);
if (cert == NULL) {
BIO_printf(bio_err, "Unable to load %s\n", desc);
/* the format parameter is meanwhile not needed anymore and thus ignored */
X509 *load_cert(const char *uri, int format, const char *desc)
{
- return load_cert_pass(uri, 0, NULL, desc);
+ return load_cert_pass(uri, 1, NULL, desc);
}
/* the format parameter is meanwhile not needed anymore and thus ignored */
return rv;
}
+void app_bail_out(char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ BIO_vprintf(bio_err, fmt, args);
+ va_end(args);
+ ERR_print_errors(bio_err);
+ exit(1);
+}
+
void* app_malloc(int sz, const char *what)
{
void *vp = OPENSSL_malloc(sz);
- if (vp == NULL) {
- BIO_printf(bio_err, "%s: Could not allocate %d bytes for %s\n",
- opt_getprog(), sz, what);
- ERR_print_errors(bio_err);
- exit(1);
- }
+ if (vp == NULL)
+ app_bail_out("%s: Could not allocate %d bytes for %s\n",
+ opt_getprog(), sz, what);
return vp;
}
}
#endif
-ENGINE *setup_engine(const char *engine, int debug)
+ENGINE *setup_engine_methods(const char *id, unsigned int methods, int debug)
{
ENGINE *e = NULL;
#ifndef OPENSSL_NO_ENGINE
- if (engine != NULL) {
- if (strcmp(engine, "auto") == 0) {
+ if (id != NULL) {
+ if (strcmp(id, "auto") == 0) {
BIO_printf(bio_err, "Enabling auto ENGINE support\n");
ENGINE_register_all_complete();
return NULL;
}
- if ((e = ENGINE_by_id(engine)) == NULL
- && (e = try_load_engine(engine)) == NULL) {
- BIO_printf(bio_err, "Invalid engine \"%s\"\n", engine);
+ if ((e = ENGINE_by_id(id)) == NULL
+ && (e = try_load_engine(id)) == NULL) {
+ BIO_printf(bio_err, "Invalid engine \"%s\"\n", id);
ERR_print_errors(bio_err);
return NULL;
}
- if (debug) {
- ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM, 0, bio_err, 0);
- }
- ENGINE_ctrl_cmd(e, "SET_USER_INTERFACE", 0, (void *)get_ui_method(),
- 0, 1);
- if (!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
+ if (debug)
+ (void)ENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM, 0, bio_err, 0);
+ if (!ENGINE_ctrl_cmd(e, "SET_USER_INTERFACE", 0,
+ (void *)get_ui_method(), 0, 1)
+ || !ENGINE_set_default(e, methods)) {
BIO_printf(bio_err, "Cannot use engine \"%s\"\n", ENGINE_get_id(e));
ERR_print_errors(bio_err);
ENGINE_free(e);
void release_engine(ENGINE *e)
{
#ifndef OPENSSL_NO_ENGINE
- if (e != NULL)
- /* Free our "structural" reference. */
- ENGINE_free(e);
+ /* Free our "structural" reference. */
+ ENGINE_free(e);
#endif
}
goto err;
}
- while (*cp) {
+ while (*cp != '\0') {
char *bp = work;
char *typestr = bp;
unsigned char *valstr;
nextismulti = 0;
/* Collect the type */
- while (*cp && *cp != '=')
+ while (*cp != '\0' && *cp != '=')
*bp++ = *cp++;
if (*cp == '\0') {
BIO_printf(bio_err,
- "%s: Hit end of string before finding the '='\n",
- opt_getprog());
+ "%s: Hit end of string before finding the '='\n",
+ opt_getprog());
goto err;
}
*bp++ = '\0';
/* Collect the value. */
valstr = (unsigned char *)bp;
- for (; *cp && *cp != '/'; *bp++ = *cp++) {
+ for (; *cp != '\0' && *cp != '/'; *bp++ = *cp++) {
if (canmulti && *cp == '+') {
nextismulti = 1;
break;
*bp++ = '\0';
/* If not at EOS (must be + or /), move forward. */
- if (*cp)
+ if (*cp != '\0')
++cp;
/* Parse */
if (!X509_NAME_add_entry_by_NID(n, nid, chtype,
valstr, strlen((char *)valstr),
-1, ismulti ? -1 : 0)) {
+ ERR_print_errors(bio_err);
BIO_printf(bio_err, "%s: Error adding name attribute \"/%s=%s\"\n",
opt_getprog(), typestr ,valstr);
goto err;
return ret;
}
-#elif defined(OPENSSL_SYSTEM_VMS)
-# include <time.h>
-# include <times.h>
-
-double app_tminterval(int stop, int usertime)
-{
- static clock_t tmstart;
- double ret = 0;
- clock_t now;
-# ifdef __TMS
- struct tms rus;
-
- now = times(&rus);
- if (usertime)
- now = rus.tms_utime;
-# else
- if (usertime)
- now = clock(); /* sum of user and kernel times */
- else {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- now = (clock_t)((unsigned long long)tv.tv_sec * CLK_TCK +
- (unsigned long long)tv.tv_usec * (1000000 / CLK_TCK)
- );
- }
-# endif
- if (stop == TM_START)
- tmstart = now;
- else
- ret = (now - tmstart) / (double)(CLK_TCK);
-
- return ret;
-}
-
#elif defined(_SC_CLK_TCK) /* by means of unistd.h */
# include <sys/times.h>
double app_tminterval(int stop, int usertime)
{
double ret = 0;
- clock_t now;
- static clock_t tmstart;
- long int tck = sysconf(_SC_CLK_TCK);
-# ifdef __TMS
struct tms rus;
+ clock_t now = times(&rus);
+ static clock_t tmstart;
- now = times(&rus);
if (usertime)
now = rus.tms_utime;
-# else
- if (usertime)
- now = clock(); /* sum of user and kernel times */
- else {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- now = (clock_t)((unsigned long long)tv.tv_sec * tck +
- (unsigned long long)tv.tv_usec * (1000000 / tck)
- );
- }
-# endif
if (stop == TM_START) {
tmstart = now;
} else {
+ long int tck = sysconf(_SC_CLK_TCK);
ret = (now - tmstart) / (double)tck;
}