a pain to read when using 4-space tabs.
ret=MoveFileEx(from,to,MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED);
return(ret?0:-1);
#else
- unlink(to);
- return MoveFile(from, to);
+ unlink(to);
+ return MoveFile(from, to);
#endif
}
#endif
#endif
typedef struct args_st
- {
- char **data;
+ {
+ char **data;
int count;
- } ARGS;
+ } ARGS;
int should_retry(int i);
int args_from_file(char *file, int *argc, char **argv[]);
lookup_fail(section,ENV_DATABASE);
goto err;
}
- if (BIO_read_filename(in,dbfile) <= 0)
+ if (BIO_read_filename(in,dbfile) <= 0)
{
perror(dbfile);
BIO_printf(bio_err,"unable to open '%s'\n",dbfile);
/*****************************************************************/
if (dorevoke)
{
- in=BIO_new(BIO_s_file());
- out=BIO_new(BIO_s_file());
- if ((in == NULL) || (out == NULL))
- {
- ERR_print_errors(bio_err);
- goto err;
- }
- if (infile == NULL)
- {
- BIO_printf(bio_err,"no input files\n");
- goto err;
- }
+ in=BIO_new(BIO_s_file());
+ out=BIO_new(BIO_s_file());
+ if ((in == NULL) || (out == NULL))
+ {
+ ERR_print_errors(bio_err);
+ goto err;
+ }
+ if (infile == NULL)
+ {
+ BIO_printf(bio_err,"no input files\n");
+ goto err;
+ }
else
{
- if (BIO_read_filename(in,infile) <= 0)
- {
- perror(infile);
- BIO_printf(bio_err,"error trying to load '%s' certificate\n",infile);
- goto err;
- }
- x509=PEM_read_bio_X509(in,NULL,NULL);
- if (x509 == NULL)
- {
- BIO_printf(bio_err,"unable to load '%s' certificate\n",infile);
+ if (BIO_read_filename(in,infile) <= 0)
+ {
+ perror(infile);
+ BIO_printf(bio_err,"error trying to load '%s' certificate\n",infile);
+ goto err;
+ }
+ x509=PEM_read_bio_X509(in,NULL,NULL);
+ if (x509 == NULL)
+ {
+ BIO_printf(bio_err,"unable to load '%s' certificate\n",infile);
goto err;
- }
- j=do_revoke(x509,db);
+ }
+ j=do_revoke(x509,db);
strncpy(buf[0],dbfile,BSIZE-4);
- strcat(buf[0],".new");
- if (BIO_write_filename(out,buf[0]) <= 0)
- {
- perror(dbfile);
- BIO_printf(bio_err,"unable to open '%s'\n",dbfile);
- goto err;
- }
- j=TXT_DB_write(out,db);
- if (j <= 0) goto err;
- BIO_free(in);
- BIO_free(out);
- in=NULL;
- out=NULL;
- strncpy(buf[1],dbfile,BSIZE-4);
- strcat(buf[1],".old");
- if (rename(dbfile,buf[1]) < 0)
- {
- BIO_printf(bio_err,"unable to rename %s to %s\n", dbfile, buf[1]);
- perror("reason");
- goto err;
- }
- if (rename(buf[0],dbfile) < 0)
- {
- BIO_printf(bio_err,"unable to rename %s to %s\n", buf[0],dbfile);
- perror("reason");
- rename(buf[1],dbfile);
- goto err;
- }
- BIO_printf(bio_err,"Data Base Updated\n");
- }
+ strcat(buf[0],".new");
+ if (BIO_write_filename(out,buf[0]) <= 0)
+ {
+ perror(dbfile);
+ BIO_printf(bio_err,"unable to open '%s'\n",dbfile);
+ goto err;
+ }
+ j=TXT_DB_write(out,db);
+ if (j <= 0) goto err;
+ BIO_free(in);
+ BIO_free(out);
+ in=NULL;
+ out=NULL;
+ strncpy(buf[1],dbfile,BSIZE-4);
+ strcat(buf[1],".old");
+ if (rename(dbfile,buf[1]) < 0)
+ {
+ BIO_printf(bio_err,"unable to rename %s to %s\n", dbfile, buf[1]);
+ perror("reason");
+ goto err;
+ }
+ if (rename(buf[0],dbfile) < 0)
+ {
+ BIO_printf(bio_err,"unable to rename %s to %s\n", buf[0],dbfile);
+ perror("reason");
+ rename(buf[1],dbfile);
+ goto err;
+ }
+ BIO_printf(bio_err,"Data Base Updated\n");
+ }
}
/*****************************************************************/
ret=0;
p="Valid";
else
p="\ninvalid type, Data base error\n";
- BIO_printf(bio_err,"Type :%s\n",p);;
+ BIO_printf(bio_err,"Type :%s\n",p);;
if (rrow[DB_type][0] == 'R')
{
p=rrow[DB_exp_date]; if (p == NULL) p="undef";
#ifndef NO_DSA
if (pkey->type == EVP_PKEY_DSA) dgst=EVP_dss1();
- pktmp=X509_get_pubkey(ret);
- if (EVP_PKEY_missing_parameters(pktmp) &&
+ pktmp=X509_get_pubkey(ret);
+ if (EVP_PKEY_missing_parameters(pktmp) &&
!EVP_PKEY_missing_parameters(pkey))
EVP_PKEY_copy_parameters(pktmp,pkey);
EVP_PKEY_free(pktmp);
static int do_revoke(X509 *x509, TXT_DB *db)
{
- ASN1_UTCTIME *tm=NULL;
- char *row[DB_NUMBER],**rrow,**irow;
- int ok=-1,i;
-
- for (i=0; i<DB_NUMBER; i++)
- row[i]=NULL;
- row[DB_name]=X509_NAME_oneline(x509->cert_info->subject,NULL,0);
- row[DB_serial]=BN_bn2hex(ASN1_INTEGER_to_BN(x509->cert_info->serialNumber,NULL));
- if ((row[DB_name] == NULL) || (row[DB_serial] == NULL))
- {
- BIO_printf(bio_err,"Malloc failure\n");
- goto err;
- }
- rrow=TXT_DB_get_by_index(db,DB_name,row);
- if (rrow == NULL)
- {
- BIO_printf(bio_err,"Adding Entry to DB for %s\n", row[DB_name]);
-
- /* We now just add it to the database */
- row[DB_type]=(char *)Malloc(2);
-
- tm=X509_get_notAfter(x509);
- row[DB_exp_date]=(char *)Malloc(tm->length+1);
- memcpy(row[DB_exp_date],tm->data,tm->length);
- row[DB_exp_date][tm->length]='\0';
-
- row[DB_rev_date]=NULL;
-
- /* row[DB_serial] done already */
- row[DB_file]=(char *)Malloc(8);
-
- /* row[DB_name] done already */
-
- if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
- (row[DB_file] == NULL))
- {
- BIO_printf(bio_err,"Malloc failure\n");
- goto err;
- }
- strcpy(row[DB_file],"unknown");
- row[DB_type][0]='V';
- row[DB_type][1]='\0';
-
- if ((irow=(char **)Malloc(sizeof(char *)*(DB_NUMBER+1))) == NULL)
- {
- BIO_printf(bio_err,"Malloc failure\n");
- goto err;
- }
-
- for (i=0; i<DB_NUMBER; i++)
- {
- irow[i]=row[i];
- row[i]=NULL;
- }
- irow[DB_NUMBER]=NULL;
-
- if (!TXT_DB_insert(db,irow))
- {
- BIO_printf(bio_err,"failed to update database\n");
- BIO_printf(bio_err,"TXT_DB error number %ld\n",db->error);
- goto err;
- }
-
- /* Revoke Certificate */
- do_revoke(x509,db);
-
- ok=1;
- goto err;
-
- }
- else if (index_serial_cmp(row,rrow))
- {
- BIO_printf(bio_err,"ERROR:no same serial number %s\n",
- row[DB_serial]);
- goto err;
- }
- else if (rrow[DB_type][0]=='R')
- {
- BIO_printf(bio_err,"ERROR:Already revoked, serial number %s\n",
- row[DB_serial]);
- goto err;
- }
- else
- {
- BIO_printf(bio_err,"Revoking Certificate %s.\n", rrow[DB_serial]);
- tm=X509_gmtime_adj(tm,0);
- rrow[DB_type][0]='R';
- rrow[DB_type][1]='\0';
- rrow[DB_rev_date]=(char *)Malloc(tm->length+1);
- memcpy(rrow[DB_rev_date],tm->data,tm->length);
- rrow[DB_rev_date][tm->length]='\0';
- }
- ok=1;
+ ASN1_UTCTIME *tm=NULL;
+ char *row[DB_NUMBER],**rrow,**irow;
+ int ok=-1,i;
+
+ for (i=0; i<DB_NUMBER; i++)
+ row[i]=NULL;
+ row[DB_name]=X509_NAME_oneline(x509->cert_info->subject,NULL,0);
+ row[DB_serial]=BN_bn2hex(ASN1_INTEGER_to_BN(x509->cert_info->serialNumber,NULL));
+ if ((row[DB_name] == NULL) || (row[DB_serial] == NULL))
+ {
+ BIO_printf(bio_err,"Malloc failure\n");
+ goto err;
+ }
+ rrow=TXT_DB_get_by_index(db,DB_name,row);
+ if (rrow == NULL)
+ {
+ BIO_printf(bio_err,"Adding Entry to DB for %s\n", row[DB_name]);
+
+ /* We now just add it to the database */
+ row[DB_type]=(char *)Malloc(2);
+
+ tm=X509_get_notAfter(x509);
+ row[DB_exp_date]=(char *)Malloc(tm->length+1);
+ memcpy(row[DB_exp_date],tm->data,tm->length);
+ row[DB_exp_date][tm->length]='\0';
+
+ row[DB_rev_date]=NULL;
+
+ /* row[DB_serial] done already */
+ row[DB_file]=(char *)Malloc(8);
+
+ /* row[DB_name] done already */
+
+ if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
+ (row[DB_file] == NULL))
+ {
+ BIO_printf(bio_err,"Malloc failure\n");
+ goto err;
+ }
+ strcpy(row[DB_file],"unknown");
+ row[DB_type][0]='V';
+ row[DB_type][1]='\0';
+
+ if ((irow=(char **)Malloc(sizeof(char *)*(DB_NUMBER+1))) == NULL)
+ {
+ BIO_printf(bio_err,"Malloc failure\n");
+ goto err;
+ }
+
+ for (i=0; i<DB_NUMBER; i++)
+ {
+ irow[i]=row[i];
+ row[i]=NULL;
+ }
+ irow[DB_NUMBER]=NULL;
+
+ if (!TXT_DB_insert(db,irow))
+ {
+ BIO_printf(bio_err,"failed to update database\n");
+ BIO_printf(bio_err,"TXT_DB error number %ld\n",db->error);
+ goto err;
+ }
+
+ /* Revoke Certificate */
+ do_revoke(x509,db);
+
+ ok=1;
+ goto err;
+
+ }
+ else if (index_serial_cmp(row,rrow))
+ {
+ BIO_printf(bio_err,"ERROR:no same serial number %s\n",
+ row[DB_serial]);
+ goto err;
+ }
+ else if (rrow[DB_type][0]=='R')
+ {
+ BIO_printf(bio_err,"ERROR:Already revoked, serial number %s\n",
+ row[DB_serial]);
+ goto err;
+ }
+ else
+ {
+ BIO_printf(bio_err,"Revoking Certificate %s.\n", rrow[DB_serial]);
+ tm=X509_gmtime_adj(tm,0);
+ rrow[DB_type][0]='R';
+ rrow[DB_type][1]='\0';
+ rrow[DB_rev_date]=(char *)Malloc(tm->length+1);
+ memcpy(rrow[DB_rev_date],tm->data,tm->length);
+ rrow[DB_rev_date][tm->length]='\0';
+ }
+ ok=1;
err:
- for (i=0; i<DB_NUMBER; i++)
- {
- if (row[i] != NULL)
- Free(row[i]);
- }
- ASN1_UTCTIME_free(tm);
- return(ok);
+ for (i=0; i<DB_NUMBER; i++)
+ {
+ if (row[i] != NULL)
+ Free(row[i]);
+ }
+ ASN1_UTCTIME_free(tm);
+ return(ok);
}
BIO *bmd=NULL;
const char *name;
#define PROG_NAME_SIZE 16
- char pname[PROG_NAME_SIZE];
+ char pname[PROG_NAME_SIZE];
int separator=0;
int debug=0;
BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
/* first check the program name */
- program_name(argv[0],pname,PROG_NAME_SIZE);
+ program_name(argv[0],pname,PROG_NAME_SIZE);
md=EVP_get_digestbyname(pname);
char *inf=NULL,*outf=NULL;
BIO *in=NULL,*out=NULL,*b64=NULL,*benc=NULL,*rbio=NULL,*wbio=NULL;
#define PROG_NAME_SIZE 16
- char pname[PROG_NAME_SIZE];
+ char pname[PROG_NAME_SIZE];
apps_startup();
BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
/* first check the program name */
- program_name(argv[0],pname,PROG_NAME_SIZE);
+ program_name(argv[0],pname,PROG_NAME_SIZE);
if (strcmp(pname,"base64") == 0)
base64=1;
BIO_printf (bio_err, "Netscape certificate sequence utility\n");
BIO_printf (bio_err, "Usage nseq [options]\n");
BIO_printf (bio_err, "where options are\n");
- BIO_printf (bio_err, "-in file input file\n");
- BIO_printf (bio_err, "-out file output file\n");
- BIO_printf (bio_err, "-toseq output NS Sequence file\n");
+ BIO_printf (bio_err, "-in file input file\n");
+ BIO_printf (bio_err, "-out file output file\n");
+ BIO_printf (bio_err, "-toseq output NS Sequence file\n");
EXIT(1);
}
static int dump_cert_text(BIO *out, X509 *x)
{
- char buf[256];
- X509_NAME_oneline(X509_get_subject_name(x),buf,256);
- BIO_puts(out,"subject=");
- BIO_puts(out,buf);
+ char buf[256];
+ X509_NAME_oneline(X509_get_subject_name(x),buf,256);
+ BIO_puts(out,"subject=");
+ BIO_puts(out,buf);
- X509_NAME_oneline(X509_get_issuer_name(x),buf,256);
- BIO_puts(out,"\nissuer= ");
- BIO_puts(out,buf);
- BIO_puts(out,"\n");
- return 0;
+ X509_NAME_oneline(X509_get_issuer_name(x),buf,256);
+ BIO_puts(out,"\nissuer= ");
+ BIO_puts(out,buf);
+ BIO_puts(out,"\n");
+ return 0;
}
#ifdef REF_PRINT
REF_PRINT("BIO",a);
#endif
- if (i > 0) return(1);
+ if (i > 0) return(1);
#ifdef REF_CHECK
if (i < 0)
{
goto err;
}
- /* copy app data */
- if (!CRYPTO_dup_ex_data(bio_meth,&new->ex_data,&bio->ex_data))
- goto err;
+ /* copy app data */
+ if (!CRYPTO_dup_ex_data(bio_meth,&new->ex_data,&bio->ex_data))
+ goto err;
if (ret == NULL)
{
int BIO_get_ex_new_index(long argl, char *argp, int (*new_func)(),
int (*dup_func)(), void (*free_func)())
- {
- bio_meth_num++;
- return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth,
- argl,argp,new_func,dup_func,free_func));
- }
+ {
+ bio_meth_num++;
+ return(CRYPTO_get_ex_new_index(bio_meth_num-1,&bio_meth,
+ argl,argp,new_func,dup_func,free_func));
+ }
int BIO_set_ex_data(BIO *bio, int idx, char *data)
{
int ret=0;
BIO_ACCEPT *data;
- BIO_clear_retry_flags(b);
+ BIO_clear_retry_flags(b);
data=(BIO_ACCEPT *)b->ptr;
while (b->next_bio == NULL)
static char buf[sizeof(DATE)+11];
sprintf(buf,"built on: %s",DATE);
- return(buf);
+ return(buf);
#else
return("built on: date not available");
#endif
* usually a CR so this can be trouble. No STDIO fix seems to work but
* flushing the console appears to do the trick.
*/
- {
- HANDLE inh;
- inh = GetStdHandle(STD_INPUT_HANDLE);
- FlushConsoleInputBuffer(inh);
- }
+ {
+ HANDLE inh;
+ inh = GetStdHandle(STD_INPUT_HANDLE);
+ FlushConsoleInputBuffer(inh);
+ }
#endif
return(strlen(buf));
}
/* We now need to gernerate g */
/* Set r0=(p-1)/q */
- BN_sub(test,p,BN_value_one());
- BN_div(r0,NULL,test,q,ctx);
+ BN_sub(test,p,BN_value_one());
+ BN_div(r0,NULL,test,q,ctx);
BN_set_word(test,h);
BN_MONT_CTX_set(mont,p,ctx);
}
void ERR_add_error_data(int num, ...)
- {
+ {
va_list args;
int i,n,s;
char *str,*p,*a;
{
BIO_OK_CTX *ctx;
EVP_MD_CTX *md;
- long tl= 0;
+ long tl= 0;
unsigned char tmp[EVP_MAX_MD_SIZE];
ctx=(BIO_OK_CTX *)b->ptr;
#if 0
lh_stats_bio(mh,b);
- lh_node_stats_bio(mh,b);
- lh_node_usage_stats_bio(mh,b);
+ lh_node_stats_bio(mh,b);
+ lh_node_usage_stats_bio(mh,b);
#endif
}
ssl_undefined_function,
ssl_undefined_function,
ssl23_read,
- (int (*)(struct ssl_st *, char *, int))ssl_undefined_function,
+ (int (*)(struct ssl_st *, char *, int))ssl_undefined_function,
ssl23_write,
ssl_undefined_function,
ssl_undefined_function,
}
i=ssl_verify_cert_chain(s,sk);
- if ((s->verify_mode != SSL_VERIFY_NONE) && (!i))
+ if ((s->verify_mode != SSL_VERIFY_NONE) && (!i))
{
al=ssl_verify_alarm_type(s->verify_result);
SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERTIFICATE_VERIFY_FAILED);
EVP_add_cipher(EVP_idea_cbc());
#endif
#ifndef NO_RC4
- EVP_add_cipher(EVP_rc4());
+ EVP_add_cipher(EVP_rc4());
#endif
#ifndef NO_RC2
- EVP_add_cipher(EVP_rc2_cbc());
+ EVP_add_cipher(EVP_rc2_cbc());
#endif
#ifndef NO_MD2
- EVP_add_digest(EVP_md2());
+ EVP_add_digest(EVP_md2());
#endif
#ifndef NO_MD5
EVP_add_digest(EVP_md5());
char *SSL_CIPHER_description(SSL_CIPHER *cipher, char *buf, int len)
{
- int is_export,pkl,kl;
+ int is_export,pkl,kl;
char *ver,*exp;
char *kx,*au,*enc,*mac;
unsigned long alg,alg2;
alg=cipher->algorithms;
alg2=cipher->algorithm2;
- is_export=SSL_IS_EXPORT(alg);
+ is_export=SSL_IS_EXPORT(alg);
pkl=SSL_EXPORT_PKEYLENGTH(alg);
kl=SSL_EXPORT_KEYLENGTH(alg);
- exp=is_export?" export":"";
+ exp=is_export?" export":"";
if (alg & SSL_SSLV2)
ver="SSLv2";
switch (alg&SSL_MKEY_MASK)
{
case SSL_kRSA:
- kx=is_export?(pkl == 512 ? "RSA(512)" : "RSA(1024)"):"RSA";
+ kx=is_export?(pkl == 512 ? "RSA(512)" : "RSA(1024)"):"RSA";
break;
case SSL_kDHr:
kx="DH/RSA";
kx="Fortezza";
break;
case SSL_kEDH:
- kx=is_export?(pkl == 512 ? "DH(512)" : "DH(1024)"):"DH";
+ kx=is_export?(pkl == 512 ? "DH(512)" : "DH(1024)"):"DH";
break;
default:
kx="unknown";
switch (alg&SSL_ENC_MASK)
{
case SSL_DES:
- enc=(is_export && kl == 5)?"DES(40)":"DES(56)";
+ enc=(is_export && kl == 5)?"DES(40)":"DES(56)";
break;
case SSL_3DES:
enc="3DES(168)";
break;
case SSL_RC4:
- enc=is_export?(kl == 5 ? "RC4(40)" : "RC4(56)")
+ enc=is_export?(kl == 5 ? "RC4(40)" : "RC4(56)")
:((alg2&SSL2_CF_8_BYTE_ENC)?"RC4(64)":"RC4(128)");
break;
case SSL_RC2:
- enc=is_export?(kl == 5 ? "RC2(40)" : "RC2(56)"):"RC2(128)";
+ enc=is_export?(kl == 5 ? "RC2(40)" : "RC2(56)"):"RC2(128)";
break;
case SSL_IDEA:
enc="IDEA(128)";
{
STACK_OF(X509_NAME) *sk;
X509_NAME *xn;
- SSL *ret;
+ SSL *ret;
int i;
if ((ret=SSL_new(SSL_get_SSL_CTX(s))) == NULL)
SSL_CIPHER *SSL_get_current_cipher(SSL *s)
{
- if ((s->session != NULL) && (s->session->cipher != NULL))
- return(s->session->cipher);
- return(NULL);
+ if ((s->session != NULL) && (s->session->cipher != NULL))
+ return(s->session->cipher);
+ return(NULL);
}
int ssl_init_wbio_buffer(SSL *s,int push)
int SSL_get_ex_new_index(long argl,char *argp,int (*new_func)(),
int (*dup_func)(),void (*free_func)())
- {
+ {
ssl_meth_num++;
return(CRYPTO_get_ex_new_index(ssl_meth_num-1,
&ssl_meth,argl,argp,new_func,dup_func,free_func));
- }
+ }
int SSL_set_ex_data(SSL *s,int idx,void *arg)
{
int SSL_CTX_get_ex_new_index(long argl,char *argp,int (*new_func)(),
int (*dup_func)(),void (*free_func)())
- {
+ {
ssl_ctx_meth_num++;
return(CRYPTO_get_ex_new_index(ssl_ctx_meth_num-1,
&ssl_ctx_meth,argl,argp,new_func,dup_func,free_func));
- }
+ }
int SSL_CTX_set_ex_data(SSL_CTX *s,int idx,void *arg)
{
int SSL_SESSION_get_ex_new_index(long argl, char *argp, int (*new_func)(),
int (*dup_func)(), void (*free_func)())
- {
- ssl_session_num++;
- return(CRYPTO_get_ex_new_index(ssl_session_num-1,
+ {
+ ssl_session_num++;
+ return(CRYPTO_get_ex_new_index(ssl_session_num-1,
&ssl_session_meth,
- argl,argp,new_func,dup_func,free_func));
- }
+ argl,argp,new_func,dup_func,free_func));
+ }
int SSL_SESSION_set_ex_data(SSL_SESSION *s, int idx, void *arg)
{
#ifndef NO_FP_API
int SSL_SESSION_print_fp(FILE *fp, SSL_SESSION *x)
- {
- BIO *b;
- int ret;
+ {
+ BIO *b;
+ int ret;
- if ((b=BIO_new(BIO_s_file_internal())) == NULL)
+ if ((b=BIO_new(BIO_s_file_internal())) == NULL)
{
SSLerr(SSL_F_SSL_SESSION_PRINT_FP,ERR_R_BUF_LIB);
- return(0);
+ return(0);
}
- BIO_set_fp(b,fp,BIO_NOCLOSE);
- ret=SSL_SESSION_print(b,x);
- BIO_free(b);
- return(ret);
- }
+ BIO_set_fp(b,fp,BIO_NOCLOSE);
+ ret=SSL_SESSION_print(b,x);
+ BIO_free(b);
+ return(ret);
+ }
#endif
int SSL_SESSION_print(BIO *bp, SSL_SESSION *x)