apps.c revision 9dc0df1bac950d6e491f9a7c7e4888f2b301cb15
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@cryptsoft.com).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* 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 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 the
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* "This product includes cryptographic software written by
* Eric Young (eay@cryptsoft.com)"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS 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 AUTHOR OR 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.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
/* ====================================================================
* Copyright (c) 1998-2001 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
* openssl-core@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).
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <openssl/safestack.h>
#ifndef OPENSSL_NO_ENGINE
#endif
#ifndef OPENSSL_NO_RSA
#endif
#define NON_MAIN
#include "apps.h"
typedef struct {
const char *name;
unsigned long flag;
unsigned long mask;
} NAME_EX_TBL;
#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA)
/* Looks like this stuff is worth moving into separate function */
static EVP_PKEY *
const char *key_descrip, int format);
#endif
#ifdef undef /* never finished - probably never will be :-) */
{
int num,i;
unsigned int len;
char *p;
return(0);
*argc=0;
if (len <= 1) return(0);
i=0;
for (p=buf; *p; p++)
if (*p == '\n') i++;
num=0;
p=buf;
for (;;)
{
if (!*p) break;
if (*p == '#') /* comment line */
{
while (*p && (*p != '\n')) p++;
continue;
}
/* else we have a line */
*(arg++)=p;
num++;
while (*p && ((*p != ' ') && (*p != '\t') && (*p != '\n')))
p++;
if (!*p) break;
if (*p == '\n')
{
*(p++)='\0';
continue;
}
/* else it is a tab or space */
p++;
while (*p && ((*p == ' ') || (*p == '\t') || (*p == '\n')))
p++;
if (!*p) break;
if (*p == '\n')
{
p++;
continue;
}
*(arg++)=p++;
num++;
while (*p && (*p != '\n')) p++;
if (!*p) break;
/* else *p == '\n' */
*(p++)='\0';
}
return(1);
}
#endif
int str2fmt(char *s)
{
if ((*s == 'D') || (*s == 'd'))
return(FORMAT_ASN1);
else if ((*s == 'T') || (*s == 't'))
return(FORMAT_TEXT);
else if ((*s == 'P') || (*s == 'p'))
return(FORMAT_PEM);
else if ((*s == 'N') || (*s == 'n'))
return(FORMAT_NETSCAPE);
else if ((*s == 'S') || (*s == 's'))
return(FORMAT_SMIME);
else if ((*s == '1')
return(FORMAT_PKCS12);
else if ((*s == 'E') || (*s == 'e'))
return(FORMAT_ENGINE);
else
return(FORMAT_UNDEF);
}
#if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_NETWARE)
{
int i,n;
char *p=NULL;
/* find the last '/', '\' or ':' */
for (i=n-1; i>0; i--)
{
{
p= &(in[i+1]);
break;
}
}
if (p == NULL)
p=in;
n=strlen(p);
#if defined(OPENSSL_SYS_NETWARE)
/* strip off trailing .nlm if present. */
if ((n > 4) && (p[n-4] == '.') &&
((p[n-3] == 'n') || (p[n-3] == 'N')) &&
((p[n-2] == 'l') || (p[n-2] == 'L')) &&
((p[n-1] == 'm') || (p[n-1] == 'M')))
n-=4;
#else
/* strip off trailing .exe if present. */
if ((n > 4) && (p[n-4] == '.') &&
((p[n-3] == 'e') || (p[n-3] == 'E')) &&
((p[n-2] == 'x') || (p[n-2] == 'X')) &&
((p[n-1] == 'e') || (p[n-1] == 'E')))
n-=4;
#endif
if (n > size-1)
n=size-1;
for (i=0; i<n; i++)
{
if ((p[i] >= 'A') && (p[i] <= 'Z'))
else
out[i]=p[i];
}
out[n]='\0';
}
#else
#ifdef OPENSSL_SYS_VMS
{
char *p=in, *q;
char *chars=":]>";
while(*chars != '\0')
{
if (q > p)
p = q + 1;
chars++;
}
q=strrchr(p,'.');
if (q == NULL)
q = p + strlen(p);
if (q-p >= size)
{
}
else
{
out[q-p]='\0';
}
}
#else
{
char *p;
if (p != NULL)
p++;
else
p=in;
}
#endif
#endif
{
char *p;
*argc=0;
i=0;
{
}
num=0;
p=buf;
for (;;)
{
/* first scan over white space */
if (!*p) break;
while (*p && ((*p == ' ') || (*p == '\t') || (*p == '\n')))
p++;
if (!*p) break;
/* The start of something good :-) */
{
char **tmp_p;
sizeof(char *)*tlen);
return 0;
/* initialize newly allocated data */
}
/* now look for the end of this */
if ((*p == '\'') || (*p == '\"')) /* scan for closing quote */
{
i= *(p++);
while (*p && (*p != i))
p++;
*p='\0';
}
else
{
while (*p && ((*p != ' ') &&
(*p != '\t') && (*p != '\n')))
p++;
if (*p == '\0')
p--;
else
*p='\0';
}
p++;
}
return(1);
}
#ifndef APP_INIT
{
return(1);
}
#endif
{
char *p;
OPENSSL_free(p);
OPENSSL_free(p);
return 0;
}
{
}
{
&& UI_get0_user_data(ui))
{
switch(UI_get_string_type(uis))
{
case UIT_PROMPT:
case UIT_VERIFY:
{
const char *password =
{
return 1;
}
}
default:
break;
}
}
}
{
&& UI_get0_user_data(ui))
{
switch(UI_get_string_type(uis))
{
case UIT_PROMPT:
case UIT_VERIFY:
{
const char *password =
return 1;
}
default:
break;
}
}
}
{
}
int setup_ui_method(void)
{
return 0;
}
void destroy_ui_method(void)
{
if(ui_method)
{
}
}
{
int res = 0;
const char *prompt_info = NULL;
if (cb_data)
{
if (cb_data->prompt_info)
}
if (password)
{
return res;
}
if (ui)
{
int ok = 0;
int ui_flags = 0;
if (ok >= 0)
{
}
if (ok >= 0)
do
{
}
if (buff)
{
}
if (ok >= 0)
if (ok == -1)
{
res = 0;
}
if (ok == -2)
{
res = 0;
}
}
return res;
}
{
int same;
else same = 1;
if(arg1) {
if(!*pass1) return 0;
if(arg2) {
if(!*pass2) return 0;
return 1;
}
{
int i;
if(!tmp) {
return NULL;
}
return BUF_strdup(tmp);
}
if(!pwdbio) {
return NULL;
}
if((i < 0) || !pwdbio) {
return NULL;
}
/* Can't do BIO_gets on an fd BIO so add a buffering BIO */
if(!pwdbio) {
return NULL;
}
} else {
return NULL;
}
}
if(keepbio != 1) {
}
if(i <= 0) {
return NULL;
}
return BUF_strdup(tpass);
}
{
char *p;
int i;
{
return 1;
}
return 0;
}
for(i = 0; i < sk_CONF_VALUE_num(sktmp); i++) {
return 0;
}
}
return 1;
}
{
const char *pass;
char tpass[PEM_BUFSIZE];
{
goto die;
}
/* See if an empty password will do */
pass = "";
else
{
if (!pem_cb)
if (len < 0)
{
desc);
goto die;
}
if (len < PEM_BUFSIZE)
{
"Mac verify error (wrong password?) in PKCS12 file for %s\n", desc);
goto die;
}
}
die:
if (p12)
return ret;
}
{
{
goto end;
}
{
}
else
{
{
cert_descrip, file);
goto end;
}
}
if (format == FORMAT_ASN1)
else if (format == FORMAT_NETSCAPE)
{
const unsigned char *p,*op;
int size=0,i;
/* We sort of have to do it this way because it is sort of nice
* to read the header first and check it, then
* try to read the certificate */
buf=BUF_MEM_new();
for (;;)
{
goto end;
size+=i;
if (i == 0) break;
if (i < 0)
{
perror("reading certificate");
goto end;
}
}
op=p;
/* First load the header */
goto end;
{
goto end;
}
/* header is ok, so now read the object */
p=op;
goto end;
}
else if (format == FORMAT_PEM)
else if (format == FORMAT_PKCS12)
{
goto end;
}
else {
goto end;
}
end:
if (x == NULL)
{
}
return(x);
}
{
{
goto end;
}
#ifndef OPENSSL_NO_ENGINE
if (format == FORMAT_ENGINE)
{
if (!e)
else
goto end;
}
#endif
{
goto end;
}
{
}
else
{
key_descrip, file);
goto end;
}
if (format == FORMAT_ASN1)
{
}
else if (format == FORMAT_PEM)
{
}
#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA)
#endif
else if (format == FORMAT_PKCS12)
{
goto end;
}
else
{
goto end;
}
end:
return(pkey);
}
{
{
goto end;
}
#ifndef OPENSSL_NO_ENGINE
if (format == FORMAT_ENGINE)
{
if (!e)
else
goto end;
}
#endif
{
goto end;
}
{
}
else
{
key_descrip, file);
goto end;
}
if (format == FORMAT_ASN1)
{
}
else if (format == FORMAT_PEM)
{
}
#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA)
#endif
else
{
goto end;
}
end:
return(pkey);
}
#if !defined(OPENSSL_NO_RC4) && !defined(OPENSSL_NO_RSA)
static EVP_PKEY *
const char *key_descrip, int format)
{
const unsigned char *p;
int size, i;
buf=BUF_MEM_new();
pkey = EVP_PKEY_new();
size = 0;
goto error;
for (;;)
{
goto error;
size += i;
if (i == 0)
break;
if (i < 0)
{
key_descrip, file);
goto error;
}
}
goto error;
return pkey;
return NULL;
}
#endif /* ndef OPENSSL_NO_RC4 */
{
int i;
{
goto end;
}
else
{
{
cert_descrip, file);
goto end;
}
}
if (format == FORMAT_PEM)
{
if(!othercerts)
{
othercerts = NULL;
goto end;
}
for(i = 0; i < sk_X509_INFO_num(allcerts); i++)
{
{
}
}
goto end;
}
else {
goto end;
}
end:
if (othercerts == NULL)
{
}
return(othercerts);
}
/* Return error for unknown extensions */
#define X509V3_EXT_DEFAULT 0
/* Print error for unknown extensions */
/* ASN1 parse unknown extensions */
/* BIO_dump unknown extensions */
{
static const NAME_EX_TBL cert_tbl[] = {
{ "no_header", X509_FLAG_NO_HEADER, 0},
{ "no_version", X509_FLAG_NO_VERSION, 0},
{ "no_serial", X509_FLAG_NO_SERIAL, 0},
{ "no_signame", X509_FLAG_NO_SIGNAME, 0},
{ "no_validity", X509_FLAG_NO_VALIDITY, 0},
{ "no_subject", X509_FLAG_NO_SUBJECT, 0},
{ "no_issuer", X509_FLAG_NO_ISSUER, 0},
{ "no_pubkey", X509_FLAG_NO_PUBKEY, 0},
{ "no_extensions", X509_FLAG_NO_EXTENSIONS, 0},
{ "no_sigdump", X509_FLAG_NO_SIGDUMP, 0},
{ "no_aux", X509_FLAG_NO_AUX, 0},
{ "no_attributes", X509_FLAG_NO_ATTRIBUTES, 0},
{ NULL, 0, 0}
};
}
{
static const NAME_EX_TBL ex_tbl[] = {
{ "esc_2253", ASN1_STRFLGS_ESC_2253, 0},
{ "esc_ctrl", ASN1_STRFLGS_ESC_CTRL, 0},
{ "esc_msb", ASN1_STRFLGS_ESC_MSB, 0},
{ "use_quote", ASN1_STRFLGS_ESC_QUOTE, 0},
{ "utf8", ASN1_STRFLGS_UTF8_CONVERT, 0},
{ "ignore_type", ASN1_STRFLGS_IGNORE_TYPE, 0},
{ "show_type", ASN1_STRFLGS_SHOW_TYPE, 0},
{ "dump_all", ASN1_STRFLGS_DUMP_ALL, 0},
{ "dump_nostr", ASN1_STRFLGS_DUMP_UNKNOWN, 0},
{ "dump_der", ASN1_STRFLGS_DUMP_DER, 0},
{ "dn_rev", XN_FLAG_DN_REV, 0},
{ "align", XN_FLAG_FN_ALIGN, 0},
{ "space_eq", XN_FLAG_SPC_EQ, 0},
{ "dump_unknown", XN_FLAG_DUMP_UNKNOWN_FIELDS, 0},
{ NULL, 0, 0}
};
}
{
else
return 0;
return 1;
}
{
return 1;
for(i = 0; i < sk_X509_EXTENSION_num(exts); i++) {
/* Does extension exist? */
if (idx != -1) {
/* If normal copy don't override existing extension */
if (copy_type == EXT_COPY_ADD)
continue;
/* Delete all extensions of same type */
do {
X509_delete_ext(x, idx);
} while (idx != -1);
}
goto end;
}
ret = 1;
end:
return ret;
}
{
int i, ret = 1;
if(!arg) return 0;
for (i = 0; i < sk_CONF_VALUE_num(vals); i++) {
ret = 0;
}
return ret;
}
{
char c;
const NAME_EX_TBL *ptbl;
c = arg[0];
if(c == '-') {
c = 0;
arg++;
} else if (c == '+') {
c = 1;
arg++;
} else c = 1;
return 1;
}
}
return 0;
}
{
char *buf;
char mline = 0;
int indent = 0;
mline = 1;
indent = 4;
}
if(lflags == XN_FLAG_COMPAT) {
} else {
}
}
{
if (CAfile) {
goto end;
}
if (CApath) {
goto end;
}
return store;
end:
return NULL;
}
#ifndef OPENSSL_NO_ENGINE
/* Try to load an engine in a shareable library */
{
if (e)
{
{
ENGINE_free(e);
e = NULL;
}
}
return e;
}
{
if (engine)
{
{
return NULL;
}
{
return NULL;
}
if (debug)
{
0, err, 0);
}
if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
{
ENGINE_free(e);
return NULL;
}
/* Free our "structural" reference. */
ENGINE_free(e);
}
return e;
}
#endif
{
if (!cnf)
if (!cnf)
return 1;
{
return 0;
}
return 1;
}
char *make_config_name()
{
const char *t=X509_get_default_cert_area();
char *p;
p=OPENSSL_malloc(len);
BUF_strlcpy(p,t,len);
#ifndef OPENSSL_SYS_VMS
#endif
return p;
}
static unsigned long index_serial_hash(const char **a)
{
const char *n;
n=a[DB_serial];
while (*n == '0') n++;
return(lh_strhash(n));
}
static int index_serial_cmp(const char **a, const char **b)
{
}
static int index_name_qual(char **a)
{ return(a[0][0] == 'V'); }
static unsigned long index_name_hash(const char **a)
{ return(lh_strhash(a[DB_name])); }
int index_name_cmp(const char **a, const char **b)
b[DB_name])); }
static IMPLEMENT_LHASH_HASH_FN(index_serial_hash,const char **)
static IMPLEMENT_LHASH_COMP_FN(index_serial_cmp,const char **)
static IMPLEMENT_LHASH_HASH_FN(index_name_hash,const char **)
static IMPLEMENT_LHASH_COMP_FN(index_name_cmp,const char **)
#define BSIZE 256
{
{
goto err;
}
{
if (!create)
{
goto err;
}
else
{
}
}
else
{
{
goto err;
}
{
goto err;
}
}
{
}
err:
return(ret);
}
{
int ret=0;
int j;
j = strlen(serialfile);
else
if (j >= BSIZE)
{
goto err;
}
else
{
#ifndef OPENSSL_SYS_VMS
#else
#endif
}
#ifdef RL_DEBUG
#endif
{
goto err;
}
{
goto err;
}
{
goto err;
}
ret=1;
if (retai)
{
}
err:
return(ret);
}
{
int i,j;
if (i > j) j = i;
if (j + 1 >= BSIZE)
{
goto err;
}
#ifndef OPENSSL_SYS_VMS
#else
#endif
#ifndef OPENSSL_SYS_VMS
#else
#endif
{
#ifdef ENOTDIR
#endif
)
goto err;
}
else
{
#ifdef RL_DEBUG
#endif
{
"unable to rename %s to %s\n",
perror("reason");
goto err;
}
}
#ifdef RL_DEBUG
buf[0],serialfile);
#endif
{
"unable to rename %s to %s\n",
buf[0],serialfile);
perror("reason");
goto err;
}
return 1;
err:
return 0;
}
{
int ret = 0;
if (b)
btmp = b;
else
if (!btmp)
return 0;
goto error;
goto error;
ret = 1;
if (!b)
return ret;
}
{
long errorline= -1;
{
goto err;
}
{
goto err;
}
{
goto err;
}
#ifndef OPENSSL_SYS_VMS
#else
#endif
{
if (errorline > 0)
{
"error on line %ld of db attribute file '%s'\n"
goto err;
}
else
{
dbattr_conf = NULL;
}
}
{
goto err;
}
if (db_attr)
else
{
}
if (dbattr_conf)
{
if (p)
{
#ifdef RL_DEBUG
#endif
}
}
err:
return retdb;
}
{
{
"error creating serial number index:(%ld,%ld,%ld)\n",
return 0;
}
{
return 0;
}
return 1;
}
{
int j;
{
goto err;
}
if (j + 6 >= BSIZE)
{
goto err;
}
#ifndef OPENSSL_SYS_VMS
#else
#endif
#ifndef OPENSSL_SYS_VMS
#else
#endif
#ifndef OPENSSL_SYS_VMS
#else
#endif
#ifdef RL_DEBUG
#endif
{
goto err;
}
if (j <= 0) goto err;
#ifdef RL_DEBUG
#endif
{
goto err;
}
return 1;
err:
return 0;
}
{
int i,j;
if (i > j) j = i;
if (j + 6 >= BSIZE)
{
goto err;
}
#ifndef OPENSSL_SYS_VMS
#else
#endif
#ifndef OPENSSL_SYS_VMS
dbfile, new_suffix);
#else
dbfile, new_suffix);
#endif
#ifndef OPENSSL_SYS_VMS
dbfile, new_suffix);
#else
dbfile, new_suffix);
#endif
#ifndef OPENSSL_SYS_VMS
dbfile, old_suffix);
#else
dbfile, old_suffix);
#endif
#ifndef OPENSSL_SYS_VMS
dbfile, old_suffix);
#else
dbfile, old_suffix);
#endif
{
#ifdef ENOTDIR
#endif
)
goto err;
}
else
{
#ifdef RL_DEBUG
#endif
{
"unable to rename %s to %s\n",
perror("reason");
goto err;
}
}
#ifdef RL_DEBUG
#endif
{
"unable to rename %s to %s\n",
perror("reason");
goto err;
}
{
#ifdef ENOTDIR
#endif
)
goto err;
}
else
{
#ifdef RL_DEBUG
#endif
{
"unable to rename %s to %s\n",
perror("reason");
goto err;
}
}
#ifdef RL_DEBUG
#endif
{
"unable to rename %s to %s\n",
perror("reason");
goto err;
}
return 1;
err:
return 0;
}
{
if (db)
{
}
}
{
if (str)
{
switch (*str)
{
case 'f': /* false */
case 'F': /* FALSE */
case 'n': /* no */
case 'N': /* NO */
case '0': /* 0 */
ret = 0;
break;
case 't': /* true */
case 'T': /* TRUE */
case 'y': /* yes */
case 'Y': /* YES */
case '1': /* 1 */
ret = 0;
break;
default:
break;
}
}
return ret;
}
/*
* where characters may be escaped by \
*/
{
size_t buflen = strlen(subject)+1; /* to copy the types and values into. due to escaping, the copy can only become shorter */
int i, ne_num = 0;
int nid;
{
goto error;
}
if (*subject != '/')
{
goto error;
}
sp++; /* skip leading / */
/* no multivalued RDN by default */
while (*sp)
{
/* collect type */
while (*sp)
{
{
if (*++sp)
else
{
goto error;
}
}
else if (*sp == '=')
{
sp++;
*bp++ = '\0';
break;
}
else
}
if (!*sp)
{
BIO_printf(bio_err, "end of string encountered while processing type of subject name element #%d\n", ne_num);
goto error;
}
while (*sp)
{
if (*sp == '\\')
{
if (*++sp)
else
{
goto error;
}
}
else if (*sp == '/')
{
sp++;
/* no multivalued RDN by default */
break;
}
{
/* a not escaped + signals a mutlivalued RDN */
sp++;
break;
}
else
}
*bp++ = '\0';
ne_num++;
}
if (!(n = X509_NAME_new()))
goto error;
for (i = 0; i < ne_num; i++)
{
{
continue;
}
if (!*ne_values[i])
{
continue;
}
goto error;
}
return n;
X509_NAME_free(n);
if (ne_values)
if (ne_types)
if (buf)
return NULL;
}
/* This code MUST COME AFTER anything that uses rename() */
#ifdef OPENSSL_SYS_WIN32
{
#ifndef OPENSSL_SYS_WINCE
/* Windows rename gives an error if 'to' exists, so delete it
* first and ignore file not found errror
*/
return -1;
#else
/* convert strings to UNICODE */
{
int i;
{
}
return result;
}
#endif
}
#endif
{
unsigned long flags = 0;
int i;
int purpose = 0;
{
if (!argn)
*badarg = 1;
else
{
if (!otmp)
{
argn);
*badarg = 1;
}
}
(*pargs)++;
}
{
if (!argn)
*badarg = 1;
else
{
if(i < 0)
{
*badarg = 1;
}
else
{
xptmp = X509_PURPOSE_get0(i);
}
}
(*pargs)++;
}
else
return 0;
if (*badarg)
{
if (*pm)
goto end;
}
{
*badarg = 1;
goto end;
}
if (otmp)
if (flags)
if (purpose)
end:
(*pargs)++;
if (pargc)
return 1;
}
{
int i;
if (nodes)
{
for (i = 0; i < sk_X509_POLICY_NODE_num(nodes); i++)
{
}
}
else
}
{
int explicit_policy;
int free_out = 0;
{
free_out = 1;
}
if (free_out)
}