# A few of my development configs
"purify", "purify gcc:-g -DPURIFY -Wall:-lsocket -lnsl::::",
"debug", "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror:-lefence::::",
+"debug-ben", "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -Wformat -Wshadow -Werror:::::",
"debug-rse","gcc:-DTERMIOS -DL_ENDIAN -O -g -ggdb3 -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm",
"dist", "cc:-O -DNOPROTO::::",
}
static int certify(xret,infile,pkey,x509,dgst,policy,db,serial,startdate,days,
- batch,ext_sect,conf,verbose)
+ batch,ext_sect,lconf,verbose)
X509 **xret;
char *infile;
EVP_PKEY *pkey;
int days;
int batch;
char *ext_sect;
-LHASH *conf;
+LHASH *lconf;
int verbose;
{
X509_REQ *req=NULL;
BIO_printf(bio_err,"Signature ok\n");
ok=do_body(xret,pkey,x509,dgst,policy,db,serial,startdate,
- days,batch,verbose,req,ext_sect,conf);
+ days,batch,verbose,req,ext_sect,lconf);
err:
if (req != NULL) X509_REQ_free(req);
}
static int certify_cert(xret,infile,pkey,x509,dgst,policy,db,serial,startdate,
- days, batch,ext_sect,conf,verbose)
+ days,batch,ext_sect,lconf,verbose)
X509 **xret;
char *infile;
EVP_PKEY *pkey;
int days;
int batch;
char *ext_sect;
-LHASH *conf;
+LHASH *lconf;
int verbose;
{
X509 *req=NULL;
goto err;
ok=do_body(xret,pkey,x509,dgst,policy,db,serial,startdate,days,
- batch,verbose,rreq,ext_sect,conf);
+ batch,verbose,rreq,ext_sect,lconf);
err:
if (rreq != NULL) X509_REQ_free(rreq);
}
static int do_body(xret,pkey,x509,dgst,policy,db,serial,startdate,days,
- batch,verbose,req, ext_sect,conf)
+ batch,verbose,req,ext_sect,lconf)
X509 **xret;
EVP_PKEY *pkey;
X509 *x509;
int verbose;
X509_REQ *req;
char *ext_sect;
-LHASH *conf;
+LHASH *lconf;
{
X509_NAME *name=NULL,*CAname=NULL,*subject=NULL;
ASN1_UTCTIME *tm,*tmptm;
ctx.crl = NULL;
ctx.flags = 0;
- if(!X509V3_EXT_add_conf(conf, &ctx, ext_sect, ret)) goto err;
+ if(!X509V3_EXT_add_conf(lconf, &ctx, ext_sect, ret)) goto err;
}
}
static int certify_spkac(xret,infile,pkey,x509,dgst,policy,db,serial,
- startdate,days,ext_sect,conf,verbose)
+ startdate,days,ext_sect,lconf,verbose)
X509 **xret;
char *infile;
EVP_PKEY *pkey;
char *startdate;
int days;
char *ext_sect;
-LHASH *conf;
+LHASH *lconf;
int verbose;
{
STACK *sk=NULL;
X509_REQ_set_pubkey(req,pktmp);
EVP_PKEY_free(pktmp);
ok=do_body(xret,pkey,x509,dgst,policy,db,serial,startdate,
- days,1,verbose,req,ext_sect,conf);
+ days,1,verbose,req,ext_sect,lconf);
err:
if (req != NULL) X509_REQ_free(req);
if (parms != NULL) CONF_free(parms);
int i2d_ASN1_TIME(ASN1_TIME *a,unsigned char **pp);
ASN1_TIME * d2i_ASN1_TIME(ASN1_TIME **a,unsigned char **pp, long length);
+ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
+
/* for the is_set parameter to i2d_ASN1_SET */
#define IS_SEQUENCE 0
des_cblock out;
long length;
des_key_schedule schedule;
-des_cblock iv;
+const des_cblock iv;
{
register DES_LONG tout0,tout1,tin0,tin1;
register long l=length;
#endif
typedef unsigned char des_cblock[8];
+typedef unsigned char *des_cblocks; /* Unfortunately there's no way to say that
+ we want a multiple of 8 */
typedef struct des_ks_struct
{
union {
#endif
#ifndef NOPROTO
char *des_options(void);
-void des_ecb3_encrypt(des_cblock *input,des_cblock *output,
- des_key_schedule ks1,des_key_schedule ks2,
- des_key_schedule ks3, int enc);
-DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output,
- long length,des_key_schedule schedule,des_cblock *ivec);
-void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
- des_key_schedule schedule,des_cblock *ivec,int enc);
-void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length,
- des_key_schedule schedule,des_cblock *ivec,int enc);
-void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length,
- des_key_schedule schedule,des_cblock *ivec,
- des_cblock *inw,des_cblock *outw,int enc);
-void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
- long length,des_key_schedule schedule,des_cblock *ivec,int enc);
-void des_ecb_encrypt(des_cblock *input,des_cblock *output,
- des_key_schedule ks,int enc);
+void des_ecb3_encrypt(const unsigned char *input,unsigned char *output,
+ des_key_schedule ks1,des_key_schedule ks2,
+ des_key_schedule ks3, int enc);
+DES_LONG des_cbc_cksum(const unsigned char *input,des_cblock output,
+ long length,des_key_schedule schedule,
+ const des_cblock ivec);
+void des_cbc_encrypt(const unsigned char *input,unsigned char *output,
+ long length,des_key_schedule schedule,des_cblock ivec,
+ int enc);
+void des_ncbc_encrypt(const unsigned char *input,unsigned char *output,
+ long length,des_key_schedule schedule,des_cblock ivec,
+ int enc);
+void des_xcbc_encrypt(const unsigned char *input,unsigned char *output,
+ long length,des_key_schedule schedule,des_cblock ivec,
+ const des_cblock inw,const des_cblock outw,int enc);
+void des_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
+ long length,des_key_schedule schedule,des_cblock ivec,
+ int enc);
+void des_ecb_encrypt(const des_cblock input,des_cblock output,
+ des_key_schedule ks,int enc);
void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
des_key_schedule ks2, des_key_schedule ks3);
void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
des_key_schedule ks2, des_key_schedule ks3);
-void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output,
- long length, des_key_schedule ks1, des_key_schedule ks2,
- des_key_schedule ks3, des_cblock *ivec, int enc);
-void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
- long length, des_key_schedule ks1, des_key_schedule ks2,
- des_key_schedule ks3, des_cblock *ivec, int *num, int enc);
-void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
- long length, des_key_schedule ks1, des_key_schedule ks2,
- des_key_schedule ks3, des_cblock *ivec, int *num);
+void des_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output,
+ long length,
+ des_key_schedule ks1,des_key_schedule ks2,
+ des_key_schedule ks3,des_cblock ivec,int enc);
+void des_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out,
+ long length,
+ des_key_schedule ks1,des_key_schedule ks2,
+ des_key_schedule ks3,
+ des_cblock ivec1,des_cblock ivec2,
+ int enc);
+void des_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out,
+ long length,des_key_schedule ks1,
+ des_key_schedule ks2,des_key_schedule ks3,
+ des_cblock ivec,int *num,int enc);
+void des_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out,
+ long length,des_key_schedule ks1,
+ des_key_schedule ks2,des_key_schedule ks3,
+ des_cblock ivec,int *num);
-void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white),
- des_cblock (*out_white));
+void des_xwhite_in2out(const des_cblock des_key,const des_cblock in_white,
+ des_cblock out_white);
int des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
- des_cblock *iv);
-int des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
- des_cblock *iv);
+ des_cblock iv);
+int des_enc_write(int fd,const char *buf,int len,des_key_schedule sched,
+ des_cblock iv);
char *des_fcrypt(const char *buf,const char *salt, char *ret);
#if defined(PERL5) || defined(__FreeBSD__)
char *des_crypt(const char *buf,const char *salt);
char *crypt();
#endif
#endif
-void des_ofb_encrypt(unsigned char *in,unsigned char *out,
- int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
-void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
- des_key_schedule schedule,des_cblock *ivec,int enc);
-DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output,
- long length,int out_count,des_cblock *seed);
+void des_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
+ long length,des_key_schedule schedule,des_cblock ivec);
+void des_pcbc_encrypt(const unsigned char *input,unsigned char *output,
+ long length,des_key_schedule schedule,des_cblock ivec,
+ int enc);
+DES_LONG des_quad_cksum(const unsigned char *input,des_cblocks output,
+ long length,int out_count,des_cblock seed);
void des_random_seed(des_cblock key);
void des_random_key(des_cblock ret);
-int des_read_password(des_cblock *key,char *prompt,int verify);
-int des_read_2passwords(des_cblock *key1,des_cblock *key2,
- char *prompt,int verify);
-int des_read_pw_string(char *buf,int length,char *prompt,int verify);
-void des_set_odd_parity(des_cblock *key);
-int des_is_weak_key(des_cblock *key);
-int des_set_key(des_cblock *key,des_key_schedule schedule);
-int des_key_sched(des_cblock *key,des_key_schedule schedule);
-void des_string_to_key(char *str,des_cblock *key);
-void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2);
-void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
- des_key_schedule schedule, des_cblock *ivec, int *num, int enc);
-void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
- des_key_schedule schedule, des_cblock *ivec, int *num);
-int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify);
+int des_read_password(des_cblock key,const char *prompt,int verify);
+int des_read_2passwords(des_cblock key1,des_cblock key2,
+ const char *prompt,int verify);
+int des_read_pw_string(char *buf,int length,const char *prompt,int verify);
+void des_set_odd_parity(des_cblock key);
+int des_is_weak_key(const des_cblock key);
+int des_set_key(const des_cblock key,des_key_schedule schedule);
+int des_key_sched(const des_cblock key,des_key_schedule schedule);
+void des_string_to_key(const char *str,des_cblock key);
+void des_string_to_2keys(const char *str,des_cblock key1,des_cblock key2);
+void des_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length,
+ des_key_schedule schedule,des_cblock ivec,int *num,
+ int enc);
+void des_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length,
+ des_key_schedule schedule,des_cblock ivec,int *num);
+int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify);
/* Extra functions from Mark Murray <mark@grondar.za> */
-void des_cblock_print_file(des_cblock *cb, FILE *fp);
+void des_cblock_print_file(const des_cblock cb, FILE *fp);
/* The following functions are not in the normal unix build or the
* SSLeay build. When using the SSLeay build, use RAND_seed()
* and RAND_bytes() instead. */
#ifndef DES_DEFAULT_OPTIONS
-void des_ncbc_encrypt(input, output, length, schedule, ivec, enc)
-des_cblock (*input);
-des_cblock (*output);
+void des_ncbc_encrypt(in, out, length, schedule, ivec, enc)
+const unsigned char *in;
+unsigned char *out;
long length;
des_key_schedule schedule;
-des_cblock (*ivec);
+des_cblock ivec;
int enc;
{
register DES_LONG tin0,tin1;
register DES_LONG tout0,tout1,xor0,xor1;
- register unsigned char *in,*out;
register long l=length;
DES_LONG tin[2];
unsigned char *iv;
- in=(unsigned char *)input;
- out=(unsigned char *)output;
- iv=(unsigned char *)ivec;
+ iv=ivec;
if (enc)
{
tout0=tin[0]; l2c(tout0,out);
tout1=tin[1]; l2c(tout1,out);
}
- iv=(unsigned char *)ivec;
+ iv=ivec;
l2c(tout0,iv);
l2c(tout1,iv);
}
xor1=tin1;
}
- iv=(unsigned char *)ivec;
+ iv=ivec;
l2c(xor0,iv);
l2c(xor1,iv);
}
}
void des_ede3_cbc_encrypt(input, output, length, ks1, ks2, ks3, ivec, enc)
-des_cblock (*input);
-des_cblock (*output);
+const unsigned char *input;
+unsigned char *output;
long length;
des_key_schedule ks1;
des_key_schedule ks2;
des_key_schedule ks3;
-des_cblock (*ivec);
+des_cblock ivec;
int enc;
{
register DES_LONG tin0,tin1;
void des_ecb_encrypt(in, out, ks, enc)
-const unsigned char *in;
-unsigned char *out;
+const des_cblock in;
+des_cblock out;
des_key_schedule ks;
int enc;
{
int des_read_pw_string(buf, length, prompt, verify)
char *buf;
int length;
-char *prompt;
+const char *prompt;
int verify;
{
char buff[BUFSIZ];
memcpy(&(ctx->oiv[0]),iv,8);
memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- des_set_key((des_cblock *)key,ctx->c.des_ks);
+ des_set_key(key,ctx->c.des_ks);
}
static void des_cbc_cipher(ctx,out,in,inl)
unsigned char *in;
unsigned int inl;
{
- des_ncbc_encrypt(
- (des_cblock *)in,(des_cblock *)out,
- (long)inl, ctx->c.des_ks,
- (des_cblock *)&(ctx->iv[0]),
- ctx->encrypt);
+ des_ncbc_encrypt(in,out,inl,ctx->c.des_ks,&(ctx->iv[0]),ctx->encrypt);
}
memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
- des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
+ des_set_key(key,ctx->c.des_ede.ks1);
+ des_set_key(&(key[8]),ctx->c.des_ede.ks2);
memcpy( (char *)ctx->c.des_ede.ks3,
(char *)ctx->c.des_ede.ks1,
sizeof(ctx->c.des_ede.ks1));
memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
- des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
- des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
+ des_set_key(key,ctx->c.des_ede.ks1);
+ des_set_key(&(key[8]),ctx->c.des_ede.ks2);
+ des_set_key(&(key[16]),ctx->c.des_ede.ks3);
}
}
unsigned char *in;
unsigned int inl;
{
- des_ede3_cfb64_encrypt(
- in,out,(long)inl,
- ctx->c.des_ede.ks1,
- ctx->c.des_ede.ks2,
- ctx->c.des_ede.ks3,
- (des_cblock *)&(ctx->iv[0]),
- &ctx->num,ctx->encrypt);
+ des_ede3_cfb64_encrypt(in,out,(long)inl,
+ ctx->c.des_ede.ks1,
+ ctx->c.des_ede.ks2,
+ ctx->c.des_ede.ks3,
+ &(ctx->iv[0]),&ctx->num,ctx->encrypt);
}
memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
- des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
+ des_set_key(key,ctx->c.des_ede.ks1);
+ des_set_key(&(key[8]),ctx->c.des_ede.ks2);
memcpy( (char *)ctx->c.des_ede.ks3,
(char *)ctx->c.des_ede.ks1,
sizeof(ctx->c.des_ede.ks1));
memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
- des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
- des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
+ des_set_key(key,ctx->c.des_ede.ks1);
+ des_set_key(&(key[8]),ctx->c.des_ede.ks2);
+ des_set_key(&(key[16]),ctx->c.des_ede.ks3);
}
}
unsigned char *in;
unsigned int inl;
{
- des_ede3_ofb64_encrypt(
- in,out,
- (long)inl,
- ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
- (des_cblock *)&(ctx->iv[0]),
- &ctx->num);
+ des_ede3_ofb64_encrypt(in,out,inl,ctx->c.des_ede.ks1,
+ ctx->c.des_ede.ks2, ctx->c.des_ede.ks3,
+ &(ctx->iv[0]),&ctx->num);
}
memcpy(&(ctx->oiv[0]),iv,8);
memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- des_set_key((des_cblock *)key,ctx->c.des_ks);
+ des_set_key(key,ctx->c.des_ks);
}
static void des_ofb_cipher(ctx,out,in,inl)
unsigned char *in;
unsigned int inl;
{
- des_ofb64_encrypt(
- in,out,
- (long)inl, ctx->c.des_ks,
- (des_cblock *)&(ctx->iv[0]),
- &ctx->num);
+ des_ofb64_encrypt(in,out,inl,ctx->c.des_ks,&(ctx->iv[0]),&ctx->num);
}
register DES_LONG tin0,tin1;
register DES_LONG ttin0,ttin1;
DES_LONG d[2],dd[2];
- unsigned char *h,*hh;
des_key_schedule k;
unsigned char *p;
unsigned int i;
- h= c->h;
- hh= c->hh;
-
for (i=0; i<len; i+=8)
{
c2l(in,tin0); d[0]=dd[0]=tin0;
c2l(in,tin1); d[1]=dd[1]=tin1;
- h[0]=(h[0]&0x9f)|0x40;
- hh[0]=(hh[0]&0x9f)|0x20;
+ c->h[0]=(c->h[0]&0x9f)|0x40;
+ c->hh[0]=(c->hh[0]&0x9f)|0x20;
- des_set_odd_parity(h);
- des_set_key(h,k);
+ des_set_odd_parity(c->h);
+ des_set_key(c->h,k);
des_encrypt(d,k,1);
- des_set_odd_parity(hh);
- des_set_key(hh,k);
+ des_set_odd_parity(c->hh);
+ des_set_key(c->hh,k);
des_encrypt(dd,k,1);
ttin0=tin0^dd[0];
tin0^=d[0];
tin1^=d[1];
- p=h;
+ p=c->h;
l2c(tin0,p);
l2c(ttin1,p);
- p=(unsigned char *)hh;
+ p=c->hh;
l2c(ttin0,p);
l2c(tin1,p);
}