diff options
author | Bodo Möller <bodo@openssl.org> | 1999-05-16 12:26:16 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 1999-05-16 12:26:16 +0000 |
commit | edf0bfb52b46bb9c8bf44e9c486be60c7087618c (patch) | |
tree | 6ad2135e6ba0e639b8938729fd55696605913011 | |
parent | e186bf96b433b85fc3a87b3ca2fd6c1929212d72 (diff) |
Change type of various DES function arguments from des_cblock
(meaning pointer to char) to des_cblock * (meaning pointer to
array with 8 char elements), which allows the compiler to
do more typechecking. (The changed argument types were of type
des_cblock * back in SSLeay, and a lot of ugly casts were
used then to turn them into pointers to elements; but it can be
done without those casts.)
Introduce new type const_des_cblock -- before, the pointers rather
than the elements pointed to were declared const, and for
some reason gcc did not complain about this (but some other
compilers did).
37 files changed, 323 insertions, 259 deletions
diff --git a/apps/speed.c b/apps/speed.c index eae1374126..a8371fb424 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -580,9 +580,9 @@ int MAIN(int argc, char **argv) #endif #ifndef NO_DES - des_set_key(key,sch); - des_set_key(key2,sch2); - des_set_key(key3,sch3); + des_set_key(&key,sch); + des_set_key(&key2,sch2); + des_set_key(&key3,sch3); #endif #ifndef NO_IDEA idea_set_encrypt_key(key16,&idea_ks); @@ -833,7 +833,7 @@ int MAIN(int argc, char **argv) Time_F(START); for (count=0,run=1; COND(c[D_CBC_DES][j]); count++) des_ncbc_encrypt(buf,buf,lengths[j],sch, - &(iv[0]),DES_ENCRYPT); + &iv,DES_ENCRYPT); d=Time_F(STOP); BIO_printf(bio_err,"%ld %s's in %.2fs\n", count,names[D_CBC_DES],d); @@ -850,7 +850,7 @@ int MAIN(int argc, char **argv) for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++) des_ede3_cbc_encrypt(buf,buf,lengths[j], sch,sch2,sch3, - &(iv[0]),DES_ENCRYPT); + &iv,DES_ENCRYPT); d=Time_F(STOP); BIO_printf(bio_err,"%ld %s's in %.2fs\n", count,names[D_EDE3_DES],d); diff --git a/crypto/des/cbc_cksm.c b/crypto/des/cbc_cksm.c index aeb0a79df9..1e543cb2a1 100644 --- a/crypto/des/cbc_cksm.c +++ b/crypto/des/cbc_cksm.c @@ -58,12 +58,15 @@ #include "des_locl.h" -DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock out, long length, - des_key_schedule schedule, const des_cblock iv) +DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock *output, + long length, + des_key_schedule schedule, const_des_cblock *ivec) { register DES_LONG tout0,tout1,tin0,tin1; register long l=length; DES_LONG tin[2]; + unsigned char *out = &(*output)[0]; + const unsigned char *iv = &(*ivec)[0]; c2l(iv,tout0); c2l(iv,tout1); diff --git a/crypto/des/cbc_enc.c b/crypto/des/cbc_enc.c index c989a7fd34..4ccabc911a 100644 --- a/crypto/des/cbc_enc.c +++ b/crypto/des/cbc_enc.c @@ -61,7 +61,7 @@ /* Note that this is inconsistent with other DES functions, in that it doesn't update ivec */ void des_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - des_key_schedule schedule, des_cblock ivec, int enc) + des_key_schedule schedule, des_cblock *ivec, int enc) { register DES_LONG tin0,tin1; register DES_LONG tout0,tout1,xor0,xor1; @@ -69,7 +69,7 @@ void des_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, DES_LONG tin[2]; unsigned char *iv; - iv=ivec; + iv = &(*ivec)[0]; if (enc) { diff --git a/crypto/des/cfb64ede.c b/crypto/des/cfb64ede.c index 1f936fa74b..5362a551bf 100644 --- a/crypto/des/cfb64ede.c +++ b/crypto/des/cfb64ede.c @@ -65,7 +65,7 @@ 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) + des_key_schedule ks3, des_cblock *ivec, int *num, int enc) { register DES_LONG v0,v1; register long l=length; @@ -73,7 +73,7 @@ void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, DES_LONG ti[2]; unsigned char *iv,c,cc; - iv=ivec; + iv=&(*ivec)[0]; if (enc) { while (l--) @@ -89,10 +89,10 @@ void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, v0=ti[0]; v1=ti[1]; - iv=ivec; + iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); - iv=ivec; + iv = &(*ivec)[0]; } c= *(in++)^iv[n]; *(out++)=c; @@ -115,10 +115,10 @@ void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, v0=ti[0]; v1=ti[1]; - iv=ivec; + iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); - iv=ivec; + iv = &(*ivec)[0]; } cc= *(in++); c=iv[n]; diff --git a/crypto/des/cfb64enc.c b/crypto/des/cfb64enc.c index e2525a781a..389a232cb3 100644 --- a/crypto/des/cfb64enc.c +++ b/crypto/des/cfb64enc.c @@ -64,8 +64,8 @@ */ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, des_key_schedule schedule, des_cblock ivec, int *num, - int enc) + long length, des_key_schedule schedule, des_cblock *ivec, + int *num, int enc) { register DES_LONG v0,v1; register long l=length; @@ -73,7 +73,7 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out, DES_LONG ti[2]; unsigned char *iv,c,cc; - iv=ivec; + iv = &(*ivec)[0]; if (enc) { while (l--) @@ -83,10 +83,10 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out, c2l(iv,v0); ti[0]=v0; c2l(iv,v1); ti[1]=v1; des_encrypt(ti,schedule,DES_ENCRYPT); - iv=ivec; + iv = &(*ivec)[0]; v0=ti[0]; l2c(v0,iv); v0=ti[1]; l2c(v0,iv); - iv=ivec; + iv = &(*ivec)[0]; } c= *(in++)^iv[n]; *(out++)=c; @@ -103,10 +103,10 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out, c2l(iv,v0); ti[0]=v0; c2l(iv,v1); ti[1]=v1; des_encrypt(ti,schedule,DES_ENCRYPT); - iv=ivec; + iv = &(*ivec)[0]; v0=ti[0]; l2c(v0,iv); v0=ti[1]; l2c(v0,iv); - iv=ivec; + iv = &(*ivec)[0]; } cc= *(in++); c=iv[n]; diff --git a/crypto/des/cfb_enc.c b/crypto/des/cfb_enc.c index 12c1d5e500..cca34dd7c5 100644 --- a/crypto/des/cfb_enc.c +++ b/crypto/des/cfb_enc.c @@ -65,7 +65,7 @@ * byte. */ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, - long length, des_key_schedule schedule, des_cblock ivec, int enc) + long length, des_key_schedule schedule, des_cblock *ivec, int enc) { register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8; register DES_LONG mask0,mask1; @@ -90,7 +90,7 @@ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, mask1=0x00000000L; } - iv=ivec; + iv = &(*ivec)[0]; c2l(iv,v0); c2l(iv,v1); if (enc) @@ -157,7 +157,7 @@ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, out+=n; } } - iv=ivec; + iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); v0=v1=d0=d1=ti[0]=ti[1]=0; diff --git a/crypto/des/des.h b/crypto/des/des.h index 348ba698f1..51958cc431 100644 --- a/crypto/des/des.h +++ b/crypto/des/des.h @@ -77,8 +77,8 @@ extern "C" { #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 const unsigned char const_des_cblock[8]; + typedef struct des_ks_struct { union { @@ -87,7 +87,9 @@ typedef struct des_ks_struct * 8 byte longs */ DES_LONG pad[2]; } ks; -#undef _ +#if defined _ +# error "_ is defined, but some strange definition the DES library cannot handle that." +#endif #define _ ks._ int weak_key; } des_key_schedule[16]; @@ -143,25 +145,25 @@ OPENSSL_EXTERN int des_rw_mode; /* defaults to DES_PCBC_MODE */ OPENSSL_EXTERN int des_set_weak_key_flag; /* set the weak key flag */ const char *des_options(void); -void des_ecb3_encrypt(const des_cblock input, des_cblock output, +void des_ecb3_encrypt(const_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(const unsigned char *input,des_cblock output, +DES_LONG des_cbc_cksum(const unsigned char *input,des_cblock *output, long length,des_key_schedule schedule, - const des_cblock ivec); + const_des_cblock *ivec); void des_cbc_encrypt(const unsigned char *input,unsigned char *output, - long length,des_key_schedule schedule,des_cblock ivec, + 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, + 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); + 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, + long length,des_key_schedule schedule,des_cblock *ivec, int enc); -void des_ecb_encrypt(const des_cblock input,des_cblock output, +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); @@ -172,29 +174,29 @@ void des_decrypt3(DES_LONG *data, des_key_schedule ks1, 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); + 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, + 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); + 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); + des_cblock *ivec,int *num); -void des_xwhite_in2out(const des_cblock des_key,const 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,void *buf,int len,des_key_schedule sched, - des_cblock iv); + des_cblock *iv); int des_enc_write(int fd,const void *buf,int len,des_key_schedule sched, - des_cblock iv); + 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); @@ -208,33 +210,33 @@ char *crypt(); #endif #endif void des_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits, - long length,des_key_schedule schedule,des_cblock ivec); + 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, + 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,const char *prompt,int verify); -int des_read_2passwords(des_cblock key1,des_cblock key2, +DES_LONG des_quad_cksum(const unsigned char *input,des_cblock 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,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_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, + 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); + 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(const des_cblock cb, FILE *fp); +void des_cblock_print_file(const_des_cblock *cb, FILE *fp); #ifdef FreeBSD /* The following functions are not in the normal unix build or the diff --git a/crypto/des/des_enc.c b/crypto/des/des_enc.c index a0ecfbc6ec..3a30e64e56 100644 --- a/crypto/des/des_enc.c +++ b/crypto/des/des_enc.c @@ -290,7 +290,7 @@ void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2, #ifndef DES_DEFAULT_OPTIONS void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, - des_key_schedule schedule, des_cblock ivec, int enc) + des_key_schedule schedule, des_cblock *ivec, int enc) { register DES_LONG tin0,tin1; register DES_LONG tout0,tout1,xor0,xor1; @@ -298,7 +298,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, DES_LONG tin[2]; unsigned char *iv; - iv=ivec; + iv = &(*ivec)[0]; if (enc) { @@ -323,7 +323,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, tout0=tin[0]; l2c(tout0,out); tout1=tin[1]; l2c(tout1,out); } - iv=ivec; + iv = &(*ivec)[0]; l2c(tout0,iv); l2c(tout1,iv); } @@ -355,7 +355,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, xor1=tin1; } - iv=ivec; + iv = &(*ivec)[0]; l2c(xor0,iv); l2c(xor1,iv); } @@ -365,7 +365,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, 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) + des_key_schedule ks3, des_cblock *ivec, int enc) { register DES_LONG tin0,tin1; register DES_LONG tout0,tout1,xor0,xor1; @@ -377,7 +377,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, in=input; out=output; - iv=ivec; + iv = &(*ivec)[0]; if (enc) { @@ -414,7 +414,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, l2c(tout0,out); l2c(tout1,out); } - iv=ivec; + iv = &(*ivec)[0]; l2c(tout0,iv); l2c(tout1,iv); } @@ -466,7 +466,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, xor1=t1; } - iv=ivec; + iv = &(*ivec)[0]; l2c(xor0,iv); l2c(xor1,iv); } diff --git a/crypto/des/destest.c b/crypto/des/destest.c index e6489ae9f5..0054fb9a97 100644 --- a/crypto/des/destest.c +++ b/crypto/des/destest.c @@ -330,17 +330,17 @@ int main(int argc, char *argv[]) #ifndef NO_DESCBCM printf("Doing cbcm\n"); - if ((j=des_key_sched(cbc_key,ks)) != 0) + if ((j=des_key_sched(&cbc_key,ks)) != 0) { printf("Key error %d\n",j); err=1; } - if ((j=des_key_sched(cbc2_key,ks2)) != 0) + if ((j=des_key_sched(&cbc2_key,ks2)) != 0) { printf("Key error %d\n",j); err=1; } - if ((j=des_key_sched(cbc3_key,ks3)) != 0) + if ((j=des_key_sched(&cbc3_key,ks3)) != 0) { printf("Key error %d\n",j); err=1; @@ -352,10 +352,10 @@ int main(int argc, char *argv[]) memcpy(iv3,cbc_iv,sizeof(cbc_iv)); memset(iv2,'\0',sizeof iv2); - des_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,iv3,iv2, + des_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,&iv2, DES_ENCRYPT); des_ede3_cbcm_encrypt(&cbc_data[16],&cbc_out[16],i-16,ks,ks2,ks3, - iv3,iv2,DES_ENCRYPT); + &iv3,&iv2,DES_ENCRYPT); /* if (memcmp(cbc_out,cbc3_ok, (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0) { @@ -365,7 +365,7 @@ int main(int argc, char *argv[]) */ memcpy(iv3,cbc_iv,sizeof(cbc_iv)); memset(iv2,'\0',sizeof iv2); - des_ede3_cbcm_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,iv3,iv2,DES_DECRYPT); + des_ede3_cbcm_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,&iv2,DES_DECRYPT); if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) { int n; @@ -384,7 +384,7 @@ int main(int argc, char *argv[]) printf("Doing ecb\n"); for (i=0; i<NUM_TESTS; i++) { - if ((j=des_key_sched(key_data[i],ks)) != 0) + if ((j=des_key_sched(&key_data[i],ks)) != 0) { printf("Key error %2d:%d\n",i+1,j); err=1; @@ -392,8 +392,8 @@ int main(int argc, char *argv[]) memcpy(in,plain_data[i],8); memset(out,0,8); memset(outin,0,8); - des_ecb_encrypt(in,out,ks,DES_ENCRYPT); - des_ecb_encrypt(out,outin,ks,DES_DECRYPT); + des_ecb_encrypt(&in,&out,ks,DES_ENCRYPT); + des_ecb_encrypt(&out,&outin,ks,DES_DECRYPT); if (memcmp(out,cipher_data[i],8) != 0) { @@ -414,17 +414,17 @@ int main(int argc, char *argv[]) printf("Doing ede ecb\n"); for (i=0; i<(NUM_TESTS-1); i++) { - if ((j=des_key_sched(key_data[i],ks)) != 0) + if ((j=des_key_sched(&key_data[i],ks)) != 0) { err=1; printf("Key error %2d:%d\n",i+1,j); } - if ((j=des_key_sched(key_data[i+1],ks2)) != 0) + if ((j=des_key_sched(&key_data[i+1],ks2)) != 0) { printf("Key error %2d:%d\n",i+2,j); err=1; } - if ((j=des_key_sched(key_data[i+2],ks3)) != 0) + if ((j=des_key_sched(&key_data[i+2],ks3)) != 0) { printf("Key error %2d:%d\n",i+3,j); err=1; @@ -432,8 +432,8 @@ int main(int argc, char *argv[]) memcpy(in,plain_data[i],8); memset(out,0,8); memset(outin,0,8); - des_ecb2_encrypt(in,out,ks,ks2,DES_ENCRYPT); - des_ecb2_encrypt(out,outin,ks,ks2,DES_DECRYPT); + des_ecb2_encrypt(&in,&out,ks,ks2,DES_ENCRYPT); + des_ecb2_encrypt(&out,&outin,ks,ks2,DES_DECRYPT); if (memcmp(out,cipher_ecb2[i],8) != 0) { @@ -452,7 +452,7 @@ int main(int argc, char *argv[]) #endif printf("Doing cbc\n"); - if ((j=des_key_sched(cbc_key,ks)) != 0) + if ((j=des_key_sched(&cbc_key,ks)) != 0) { printf("Key error %d\n",j); err=1; @@ -461,13 +461,13 @@ int main(int argc, char *argv[]) memset(cbc_in,0,40); memcpy(iv3,cbc_iv,sizeof(cbc_iv)); des_ncbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks, - iv3,DES_ENCRYPT); + &iv3,DES_ENCRYPT); if (memcmp(cbc_out,cbc_ok,32) != 0) printf("cbc_encrypt encrypt error\n"); memcpy(iv3,cbc_iv,sizeof(cbc_iv)); des_ncbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks, - iv3,DES_DECRYPT); + &iv3,DES_DECRYPT); if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)) != 0) { printf("cbc_encrypt decrypt error\n"); @@ -476,7 +476,7 @@ int main(int argc, char *argv[]) #ifndef LIBDES_LIT printf("Doing desx cbc\n"); - if ((j=des_key_sched(cbc_key,ks)) != 0) + if ((j=des_key_sched(&cbc_key,ks)) != 0) { printf("Key error %d\n",j); err=1; @@ -485,14 +485,14 @@ int main(int argc, char *argv[]) memset(cbc_in,0,40); memcpy(iv3,cbc_iv,sizeof(cbc_iv)); des_xcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks, - iv3,cbc2_key,cbc3_key, DES_ENCRYPT); + &iv3,&cbc2_key,&cbc3_key, DES_ENCRYPT); if (memcmp(cbc_out,xcbc_ok,32) != 0) { printf("des_xcbc_encrypt encrypt error\n"); } memcpy(iv3,cbc_iv,sizeof(cbc_iv)); des_xcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks, - iv3,cbc2_key,cbc3_key, DES_DECRYPT); + &iv3,&cbc2_key,&cbc3_key, DES_DECRYPT); if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) { printf("des_xcbc_encrypt decrypt error\n"); @@ -501,17 +501,17 @@ int main(int argc, char *argv[]) #endif printf("Doing ede cbc\n"); - if ((j=des_key_sched(cbc_key,ks)) != 0) + if ((j=des_key_sched(&cbc_key,ks)) != 0) { printf("Key error %d\n",j); err=1; } - if ((j=des_key_sched(cbc2_key,ks2)) != 0) + if ((j=des_key_sched(&cbc2_key,ks2)) != 0) { printf("Key error %d\n",j); err=1; } - if ((j=des_key_sched(cbc3_key,ks3)) != 0) + if ((j=des_key_sched(&cbc3_key,ks3)) != 0) { printf("Key error %d\n",j); err=1; @@ -522,9 +522,9 @@ int main(int argc, char *argv[]) /* i=((i+7)/8)*8; */ memcpy(iv3,cbc_iv,sizeof(cbc_iv)); - des_ede3_cbc_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,iv3,DES_ENCRYPT); + des_ede3_cbc_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,DES_ENCRYPT); des_ede3_cbc_encrypt(&(cbc_data[16]),&(cbc_out[16]),i-16,ks,ks2,ks3, - iv3,DES_ENCRYPT); + &iv3,DES_ENCRYPT); if (memcmp(cbc_out,cbc3_ok, (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0) { @@ -533,7 +533,7 @@ int main(int argc, char *argv[]) } memcpy(iv3,cbc_iv,sizeof(cbc_iv)); - des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,iv3,DES_DECRYPT); + des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,DES_DECRYPT); if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) { printf("des_ede3_cbc_encrypt decrypt error\n"); @@ -542,21 +542,21 @@ int main(int argc, char *argv[]) #ifndef LIBDES_LIT printf("Doing pcbc\n"); - if ((j=des_key_sched(cbc_key,ks)) != 0) + if ((j=des_key_sched(&cbc_key,ks)) != 0) { printf("Key error %d\n",j); err=1; } memset(cbc_out,0,40); memset(cbc_in,0,40); - des_pcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,cbc_iv, - DES_ENCRYPT); + des_pcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks, + &cbc_iv,DES_ENCRYPT); if (memcmp(cbc_out,pcbc_ok,32) != 0) { printf("pcbc_encrypt encrypt error\n"); err=1; } - des_pcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,cbc_iv, + des_pcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,&cbc_iv, DES_DECRYPT); if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) { @@ -582,7 +582,7 @@ int main(int argc, char *argv[]) memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); for (i=0; i<sizeof(plain); i++) des_cfb_encrypt(&(plain[i]),&(cfb_buf1[i]), - 8,1,ks,cfb_tmp,DES_ENCRYPT); + 8,1,ks,&cfb_tmp,DES_ENCRYPT); if (memcmp(cfb_cipher8,cfb_buf1,sizeof(plain)) != 0) { printf("cfb_encrypt small encrypt error\n"); @@ -592,7 +592,7 @@ int main(int argc, char *argv[]) memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); for (i=0; i<sizeof(plain); i++) des_cfb_encrypt(&(cfb_buf1[i]),&(cfb_buf2[i]), - 8,1,ks,cfb_tmp,DES_DECRYPT); + 8,1,ks,&cfb_tmp,DES_DECRYPT); if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) { printf("cfb_encrypt small decrypt error\n"); @@ -605,9 +605,9 @@ int main(int argc, char *argv[]) printf("done\n"); printf("Doing ofb\n"); - des_key_sched(ofb_key,ks); + des_key_sched(&ofb_key,ks); memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); - des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,ofb_tmp); + des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp); if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) { printf("ofb_encrypt encrypt error\n"); @@ -620,7 +620,7 @@ ofb_buf1[8+4], ofb_cipher[8+5], ofb_cipher[8+6], ofb_cipher[8+7]); err=1; } memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); - des_ofb_encrypt(ofb_buf1,ofb_buf2,64,sizeof(ofb_buf1)/8,ks,ofb_tmp); + des_ofb_encrypt(ofb_buf1,ofb_buf2,64,sizeof(ofb_buf1)/8,ks,&ofb_tmp); if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) { printf("ofb_encrypt decrypt error\n"); @@ -634,14 +634,14 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); } printf("Doing ofb64\n"); - des_key_sched(ofb_key,ks); + des_key_sched(&ofb_key,ks); memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); memset(ofb_buf1,0,sizeof(ofb_buf1)); memset(ofb_buf2,0,sizeof(ofb_buf1)); num=0; for (i=0; i<sizeof(plain); i++) { - des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ofb_tmp, + des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,&ofb_tmp, &num); } if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) |