diff options
author | Bodo Möller <bodo@openssl.org> | 1999-05-16 14:26:16 +0200 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 1999-05-16 14:26:16 +0200 |
commit | edf0bfb52b46bb9c8bf44e9c486be60c7087618c (patch) | |
tree | 6ad2135e6ba0e639b8938729fd55696605913011 /crypto | |
parent | Added a comment pointing out the behaviour of "openssl x509 -conf ...", (diff) | |
download | openssl-edf0bfb52b46bb9c8bf44e9c486be60c7087618c.tar.xz openssl-edf0bfb52b46bb9c8bf44e9c486be60c7087618c.zip |
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).
Diffstat (limited to 'crypto')
36 files changed, 318 insertions, 254 deletions
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) @@ -651,7 +651,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); } memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); num=0; - des_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,ofb_tmp,&num); + des_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,&ofb_tmp,&num); if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) { printf("ofb64_encrypt decrypt error\n"); @@ -659,7 +659,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); } printf("Doing ede_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)); @@ -667,7 +667,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); for (i=0; i<sizeof(plain); i++) { des_ede3_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ks,ks, - ofb_tmp,&num); + &ofb_tmp,&num); } if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0) { @@ -677,7 +677,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv)); num=0; des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks, - ks,ks,ofb_tmp,&num); + ks,ks,&ofb_tmp,&num); if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0) { printf("ede_ofb64_encrypt decrypt error\n"); @@ -685,8 +685,8 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); } printf("Doing cbc_cksum\n"); - des_key_sched(cbc_key,ks); - cs=des_cbc_cksum(cbc_data,cret,strlen((char *)cbc_data),ks,cbc_iv); + des_key_sched(&cbc_key,ks); + cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv); if (cs != cbc_cksum_ret) { printf("bad return value (%08lX), should be %08lX\n", @@ -704,8 +704,8 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); quad_cksum returns up to 4 groups of 8 bytes, this test gets it to produce 2 groups then treats them as 4 groups of 4 bytes. Ben 13 Feb 1999 */ - cs=quad_cksum(cbc_data,(des_cblocks)qret,strlen((char *)cbc_data),2, - cbc_iv); + cs=quad_cksum(cbc_data,(des_cblock *)qret,strlen((char *)cbc_data),2, + &cbc_iv); { /* Big-endian fix */ static DES_LONG l=1; @@ -769,7 +769,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); printf(" %d",i); des_ncbc_encrypt(&(cbc_out[i]),cbc_in, strlen((char *)cbc_data)+1,ks, - cbc_iv,DES_ENCRYPT); + &cbc_iv,DES_ENCRYPT); } printf("\noutput word alignment test"); for (i=0; i<4; i++) @@ -777,7 +777,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]); printf(" %d",i); des_ncbc_encrypt(cbc_out,&(cbc_in[i]), strlen((char *)cbc_data)+1,ks, - cbc_iv,DES_ENCRYPT); + &cbc_iv,DES_ENCRYPT); } printf("\n"); printf("fast crypt test "); @@ -824,9 +824,9 @@ static int cfb_test(int bits, unsigned char *cfb_cipher) des_key_schedule ks; int i,err=0; - des_key_sched(cfb_key,ks); + des_key_sched(&cfb_key,ks); memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); - des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,cfb_tmp, + des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp, DES_ENCRYPT); if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) { @@ -836,7 +836,7 @@ static int cfb_test(int bits, unsigned char *cfb_cipher) printf("%s\n",pt(&(cfb_buf1[i]))); } memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); - des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,sizeof(plain),ks,cfb_tmp, + des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,sizeof(plain),ks,&cfb_tmp, DES_DECRYPT); if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) { @@ -853,12 +853,12 @@ static int cfb64_test(unsigned char *cfb_cipher) des_key_schedule ks; int err=0,i,n; - des_key_sched(cfb_key,ks); + des_key_sched(&cfb_key,ks); memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); n=0; - des_cfb64_encrypt(plain,cfb_buf1,12,ks,cfb_tmp,&n,DES_ENCRYPT); + des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT); des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),sizeof(plain)-12,ks, - cfb_tmp,&n,DES_ENCRYPT); + &cfb_tmp,&n,DES_ENCRYPT); if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) { err=1; @@ -868,9 +868,9 @@ static int cfb64_test(unsigned char *cfb_cipher) } memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); n=0; - des_cfb64_encrypt(cfb_buf1,cfb_buf2,17,ks,cfb_tmp,&n,DES_DECRYPT); + des_cfb64_encrypt(cfb_buf1,cfb_buf2,17,ks,&cfb_tmp,&n,DES_DECRYPT); des_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]), - sizeof(plain)-17,ks,cfb_tmp,&n,DES_DECRYPT); + sizeof(plain)-17,ks,&cfb_tmp,&n,DES_DECRYPT); if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) { err=1; @@ -886,14 +886,14 @@ static int ede_cfb64_test(unsigned char *cfb_cipher) des_key_schedule ks; int err=0,i,n; - des_key_sched(cfb_key,ks); + des_key_sched(&cfb_key,ks); memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); n=0; - des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,cfb_tmp,&n, + des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n, DES_ENCRYPT); des_ede3_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]), sizeof(plain)-12,ks,ks,ks, - cfb_tmp,&n,DES_ENCRYPT); + &cfb_tmp,&n,DES_ENCRYPT); if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0) { err=1; @@ -904,10 +904,10 @@ static int ede_cfb64_test(unsigned char *cfb_cipher) memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv)); n=0; des_ede3_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks,ks,ks, - cfb_tmp,&n,DES_DECRYPT); + &cfb_tmp,&n,DES_DECRYPT); des_ede3_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]), sizeof(plain)-17,ks,ks,ks, - cfb_tmp,&n,DES_DECRYPT); + &cfb_tmp,&n,DES_DECRYPT); if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0) { err=1; diff --git a/crypto/des/ecb3_enc.c b/crypto/des/ecb3_enc.c index 5ffcdd7fda..fb28b97e1a 100644 --- a/crypto/des/ecb3_enc.c +++ b/crypto/des/ecb3_enc.c @@ -58,12 +58,14 @@ #include "des_locl.h" -void des_ecb3_encrypt(const des_cblock in, des_cblock out, +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) { register DES_LONG l0,l1; DES_LONG ll[2]; + const unsigned char *in = &(*input)[0]; + unsigned char *out = &(*output)[0]; c2l(in,l0); c2l(in,l1); diff --git a/crypto/des/ecb_enc.c b/crypto/des/ecb_enc.c index dfeb187088..badb7e1149 100644 --- a/crypto/des/ecb_enc.c +++ b/crypto/des/ecb_enc.c @@ -103,11 +103,14 @@ const char *des_options(void) } -void des_ecb_encrypt(const des_cblock in, des_cblock out, des_key_schedule ks, +void des_ecb_encrypt(const_des_cblock *input, des_cblock *output, + des_key_schedule ks, int enc) { register DES_LONG l; DES_LONG ll[2]; + const unsigned char *in = &(*input)[0]; + unsigned char *out = &(*output)[0]; c2l(in,l); ll[0]=l; c2l(in,l); ll[1]=l; diff --git a/crypto/des/ede_cbcm_enc.c b/crypto/des/ede_cbcm_enc.c index 302e32ef48..c53062481d 100644 --- a/crypto/des/ede_cbcm_enc.c +++ b/crypto/des/ede_cbcm_enc.c @@ -73,7 +73,8 @@ http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/1998/CS/CS0928.ps.gz 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) + des_key_schedule ks3, des_cblock *ivec1, des_cblock *ivec2, + int enc) { register DES_LONG tin0,tin1; register DES_LONG tout0,tout1,xor0,xor1,m0,m1; @@ -81,8 +82,8 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, DES_LONG tin[2]; unsigned char *iv1,*iv2; - iv1=ivec1; - iv2=ivec2; + iv1 = &(*ivec1)[0]; + iv2 = &(*ivec2)[0]; if (enc) { @@ -125,11 +126,11 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, l2c(tout0,out); l2c(tout1,out); } - iv1=ivec1; + iv1=&(*ivec1)[0]; l2c(m0,iv1); l2c(m1,iv1); - iv2=ivec2; + iv2=&(*ivec2)[0]; l2c(tout0,iv2); l2c(tout1,iv2); } @@ -182,11 +183,11 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, xor1=t1; } - iv1=ivec1; + iv1=&(*ivec1)[0]; l2c(m0,iv1); l2c(m1,iv1); - iv2=ivec2; + iv2=&(*ivec2)[0]; l2c(xor0,iv2); l2c(xor1,iv2); } diff --git a/crypto/des/enc_read.c b/crypto/des/enc_read.c index 51694a8bcf..694970ccd2 100644 --- a/crypto/des/enc_read.c +++ b/crypto/des/enc_read.c @@ -85,7 +85,7 @@ OPENSSL_GLOBAL int des_rw_mode=DES_PCBC_MODE; int des_enc_read(int fd, void *buf, int len, des_key_schedule sched, - des_cblock iv) + des_cblock *iv) { /* data to be unencrypted */ int net_num=0; diff --git a/crypto/des/enc_writ.c b/crypto/des/enc_writ.c index 763765ec39..26c39037a9 100644 --- a/crypto/des/enc_writ.c +++ b/crypto/des/enc_writ.c @@ -77,7 +77,7 @@ */ int des_enc_write(int fd, const void *_buf, int len, - des_key_schedule sched, des_cblock iv) + des_key_schedule sched, des_cblock *iv) { #ifdef _LIBC extern int srandom(); diff --git a/crypto/des/fcrypt.c b/crypto/des/fcrypt.c index db27108a32..db2454114f 100644 --- a/crypto/des/fcrypt.c +++ b/crypto/des/fcrypt.c @@ -108,7 +108,7 @@ r=(r+7)/8; for (; i<8; i++) key[i]=0; - des_set_key(key,ks); + des_set_key(&key,ks); fcrypt_body(&(out[0]),ks,Eswap0,Eswap1); ll=out[0]; l2c(ll,b); diff --git a/crypto/des/ofb64ede.c b/crypto/des/ofb64ede.c index 36245de793..6eafe908da 100644 --- a/crypto/des/ofb64ede.c +++ b/crypto/des/ofb64ede.c @@ -64,7 +64,8 @@ */ void des_ede3_ofb64_encrypt(register const unsigned char *in, register unsigned char *out, long length, des_key_schedule k1, - des_key_schedule k2, des_key_schedule k3, des_cblock ivec, int *num) + des_key_schedule k2, des_key_schedule k3, des_cblock *ivec, + int *num) { register DES_LONG v0,v1; register int n= *num; @@ -75,7 +76,7 @@ void des_ede3_ofb64_encrypt(register const unsigned char *in, unsigned char *iv; int save=0; - iv=ivec; + iv = &(*ivec)[0]; c2l(iv,v0); c2l(iv,v1); ti[0]=v0; @@ -105,7 +106,7 @@ void des_ede3_ofb64_encrypt(register const unsigned char *in, { /* v0=ti[0]; v1=ti[1];*/ - iv=ivec; + iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); } diff --git a/crypto/des/ofb64enc.c b/crypto/des/ofb64enc.c index 545c749c55..64953959ca 100644 --- a/crypto/des/ofb64enc.c +++ b/crypto/des/ofb64enc.c @@ -64,7 +64,7 @@ */ void des_ofb64_encrypt(register const unsigned char *in, register unsigned char *out, long length, des_key_schedule schedule, - des_cblock ivec, int *num) + des_cblock *ivec, int *num) { register DES_LONG v0,v1,t; register int n= *num; @@ -75,7 +75,7 @@ void des_ofb64_encrypt(register const unsigned char *in, unsigned char *iv; int save=0; - iv=ivec; + iv = &(*ivec)[0]; c2l(iv,v0); c2l(iv,v1); ti[0]=v0; @@ -100,7 +100,7 @@ void des_ofb64_encrypt(register const unsigned char *in, { v0=ti[0]; v1=ti[1]; - iv=ivec; + iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); } diff --git a/crypto/des/ofb_enc.c b/crypto/des/ofb_enc.c index 9ee221ea8f..a8f425a575 100644 --- a/crypto/des/ofb_enc.c +++ b/crypto/des/ofb_enc.c @@ -65,7 +65,7 @@ * byte. */ 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) { register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8; register DES_LONG mask0,mask1; @@ -92,7 +92,7 @@ void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, mask1=0x00000000L; } - iv=ivec; + iv = &(*ivec)[0]; c2l(iv,v0); c2l(iv,v1); ti[0]=v0; @@ -126,7 +126,7 @@ void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, v1=((v1>>num)|(vv0<<(32-num)))&0xffffffffL; } } - iv=ivec; + iv = &(*ivec)[0]; l2c(v0,iv); l2c(v1,iv); v0=v1=d0=d1=ti[0]=ti[1]=vv0=vv1=0; diff --git a/crypto/des/pcbc_enc.c b/crypto/des/pcbc_enc.c index 1880217560..dd69a26d4a 100644 --- a/crypto/des/pcbc_enc.c +++ b/crypto/des/pcbc_enc.c @@ -59,7 +59,7 @@ #include "des_locl.h" void des_pcbc_encrypt(const unsigned char *input, unsigned char *output, - 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 sin0,sin1,xor0,xor1,tout0,tout1; DES_LONG tin[2]; @@ -68,7 +68,7 @@ void des_pcbc_encrypt(const unsigned char *input, unsigned char *output, in=input; out=output; - iv=ivec; + iv = &(*ivec)[0]; if (enc) { diff --git a/crypto/des/qud_cksm.c b/crypto/des/qud_cksm.c index 09797f2257..6ce8c61b42 100644 --- a/crypto/des/qud_cksm.c +++ b/crypto/des/qud_cksm.c @@ -73,8 +73,8 @@ /* Got the value MIT uses via brute force :-) 2/10/90 eay */ #define NOISE ((DES_LONG)83653421L) -DES_LONG des_quad_cksum(const unsigned char *input, des_cblocks output, - long length, int out_count, des_cblock seed) +DES_LONG des_quad_cksum(const unsigned char *input, des_cblock output[], + long length, int out_count, des_cblock *seed) { DES_LONG z0,z1,t0,t1; int i; @@ -83,10 +83,10 @@ DES_LONG des_quad_cksum(const unsigned char *input, des_cblocks output, unsigned char *lp; if (out_count < 1) out_count=1; - lp=output; + lp = &(output[0])[0]; - z0=Q_B0(seed[0])|Q_B1(seed[1])|Q_B2(seed[2])|Q_B3(seed[3]); - z1=Q_B0(seed[4])|Q_B1(seed[5])|Q_B2(seed[6])|Q_B3(seed[7]); + z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]); + z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]); for (i=0; ((i<4)&&(i<out_count)); i++) { @@ -129,7 +129,7 @@ DES_LONG des_quad_cksum(const unsigned char *input, des_cblocks output, } else { - lp=&output[(out_count-i-1)*8]; + lp = &(output[out_count-i-1])[0]; l2n(z1,lp); l2n(z0,lp); } diff --git a/crypto/des/rand_key.c b/crypto/des/rand_key.c index 00db2bef77..fc11792cda 100644 --- a/crypto/des/rand_key.c +++ b/crypto/des/rand_key.c @@ -62,13 +62,13 @@ static int seed=0; static des_cblock init; -void des_random_seed(des_cblock key) +void des_random_seed(des_cblock *key) { - memcpy(init,key,sizeof(des_cblock)); + memcpy(&init,key,sizeof(des_cblock)); seed=1; } -void des_random_key(unsigned char *ret) +void des_random_key(des_cblock *ret) { des_key_schedule ks; static DES_LONG c=0; @@ -99,13 +99,13 @@ void des_random_key(unsigned char *ret) t=(DES_LONG)((pid)|((c++)<<16)); l2c(t,p); - des_set_odd_parity(data); - des_set_key(data,ks); - des_cbc_cksum(key,key,sizeof(key),ks,data); + des_set_odd_parity(&data); + des_set_key(&data,ks); + des_cbc_cksum(key,&key,sizeof(key),ks,&data); - des_set_odd_parity(key); - des_set_key(key,ks); - des_cbc_cksum(key,data,sizeof(key),ks,key); + des_set_odd_parity(&key); + des_set_key(&key,ks); + des_cbc_cksum(key,&data,sizeof(key),ks,&key); memcpy(ret,data,sizeof(key)); memset(key,0,sizeof(key)); diff --git a/crypto/des/read2pwd.c b/crypto/des/read2pwd.c index 1534f79e65..a8ceaf088a 100644 --- a/crypto/des/read2pwd.c +++ b/crypto/des/read2pwd.c @@ -58,7 +58,7 @@ #include "des_locl.h" -int des_read_password(des_cblock key, const char *prompt, int verify) +int des_read_password(des_cblock *key, const char *prompt, int verify) { int ok; char buf[BUFSIZ],buff[BUFSIZ]; @@ -70,7 +70,7 @@ int des_read_password(des_cblock key, const char *prompt, int verify) return(ok); } -int des_read_2passwords(des_cblock key1, des_cblock key2, const char *prompt, +int des_read_2passwords(des_cblock *key1, des_cblock *key2, const char *prompt, int verify) { int ok; diff --git a/crypto/des/rpc_enc.c b/crypto/des/rpc_enc.c index e34c9af503..c96c204147 100644 --- a/crypto/des/rpc_enc.c +++ b/crypto/des/rpc_enc.c @@ -66,16 +66,17 @@ int _des_crypt(char *buf, int len, struct desparams *desp) des_key_schedule ks; int enc; - des_set_key(desp->des_key,ks); + des_set_key(&desp->des_key,ks); enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT; if (desp->des_mode == CBC) - des_ecb_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf,ks, + des_ecb_encrypt((const_des_cblock *)desp->UDES.UDES_buf, + (des_cblock *)desp->UDES.UDES_buf,ks, enc); else { des_ncbc_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf, - len,ks,desp->des_ivec,enc); + len,ks,&desp->des_ivec,enc); #ifdef undef /* len will always be %8 if called from common_crypt * in secure_rpc. diff --git a/crypto/des/set_key.c b/crypto/des/set_key.c index 11ef8913d4..70b870f4b0 100644 --- a/crypto/des/set_key.c +++ b/crypto/des/set_key.c @@ -67,24 +67,24 @@ #include "podd.h" #include "sk.h" -static int check_parity(const des_cblock key); +static int check_parity(const_des_cblock *key); OPENSSL_GLOBAL int des_check_key=0; -void des_set_odd_parity(des_cblock key) +void des_set_odd_parity(des_cblock *key) { int i; for (i=0; i<DES_KEY_SZ; i++) - key[i]=odd_parity[key[i]]; + (*key)[i]=odd_parity[(*key)[i]]; } -static int check_parity(const des_cblock key) +static int check_parity(const_des_cblock *key) { int i; for (i=0; i<DES_KEY_SZ; i++) { - if (key[i] != odd_parity[key[i]]) + if ((*key)[i] != odd_parity[(*key)[i]]) return(0); } return(1); @@ -120,7 +120,7 @@ static des_cblock weak_keys[NUM_WEAK_KEY]={ {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE}, {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}}; -int des_is_weak_key(const des_cblock key) +int des_is_weak_key(const_des_cblock *key) { int i; @@ -149,7 +149,7 @@ int des_is_weak_key(const des_cblock key) * return -1 if key parity error, * return -2 if illegal weak key. */ -int des_set_key(const des_cblock key, des_key_schedule schedule) +int des_set_key(const_des_cblock *key, des_key_schedule schedule) { static int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0}; register DES_LONG c,d,t,s,t2; @@ -167,7 +167,7 @@ int des_set_key(const des_cblock key, des_key_schedule schedule) } k=(DES_LONG *)schedule; - in=key; + in = &(*key)[0]; c2l(in,c); c2l(in,d); @@ -228,7 +228,7 @@ int des_set_key(const des_cblock key, des_key_schedule schedule) return(0); } -int des_key_sched(const des_cblock key, des_key_schedule schedule) +int des_key_sched(const_des_cblock *key, des_key_schedule schedule) { return(des_set_key(key,schedule)); } diff --git a/crypto/des/str2key.c b/crypto/des/str2key.c index 674079b14b..24841452f1 100644 --- a/crypto/des/str2key.c +++ b/crypto/des/str2key.c @@ -60,7 +60,7 @@ OPENSSL_EXTERN int des_check_key; -void des_string_to_key(const char *str, des_cblock key) +void des_string_to_key(const char *str, des_cblock *key) { des_key_schedule ks; int i,length; @@ -70,20 +70,20 @@ void des_string_to_key(const char *str, des_cblock key) length=strlen(str); #ifdef OLD_STR_TO_KEY for (i=0; i<length; i++) - key[i%8]^=(str[i]<<1); + (*key)[i%8]^=(str[i]<<1); #else /* MIT COMPATIBLE */ for (i=0; i<length; i++) { j=str[i]; if ((i%16) < 8) - key[i%8]^=(j<<1); + (*key)[i%8]^=(j<<1); else { /* Reverse the bit order 05/05/92 eay */ j=((j<<4)&0xf0)|((j>>4)&0x0f); j=((j<<2)&0xcc)|((j>>2)&0x33); j=((j<<1)&0xaa)|((j>>1)&0x55); - key[7-(i%8)]^=j; + (*key)[7-(i%8)]^=j; } } #endif @@ -97,7 +97,7 @@ void des_string_to_key(const char *str, des_cblock key) des_set_odd_parity(key); } -void des_string_to_2keys(const char *str, des_cblock key1, des_cblock key2) +void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2) { des_key_schedule ks; int i,length; @@ -111,7 +111,7 @@ void des_string_to_2keys(const char *str, des_cblock key1, des_cblock key2) { for (i=0; i<length; i++) { - key2[i]=key1[i]=(str[i]<<1); + (*key2)[i]=(*key1)[i]=(str[i]<<1); } } else @@ -119,9 +119,9 @@ void des_string_to_2keys(const char *str, des_cblock key1, des_cblock key2) for (i=0; i<length; i++) { if ((i/8)&1) - key2[i%8]^=(str[i]<<1); + (*key2)[i%8]^=(str[i]<<1); else - key1[i%8]^=(str[i]<<1); + (*key1)[i%8]^=(str[i]<<1); } } #else /* MIT COMPATIBLE */ @@ -131,9 +131,9 @@ void des_string_to_2keys(const char *str, des_cblock key1, des_cblock key2) if ((i%32) < 16) { if ((i%16) < 8) - key1[i%8]^=(j<<1); + (*key1)[i%8]^=(j<<1); else - key2[i%8]^=(j<<1); + (*key2)[i%8]^=(j<<1); } else { @@ -141,9 +141,9 @@ void des_string_to_2keys(const char *str, des_cblock key1, des_cblock key2) j=((j<<2)&0xcc)|((j>>2)&0x33); j=((j<<1)&0xaa)|((j>>1)&0x55); if ((i%16) < 8) - key1[7-(i%8)]^=j; + (*key1)[7-(i%8)]^=j; else - key2[7-(i%8)]^=j; + (*key2)[7-(i%8)]^=j; } } if (length <= 8) memcpy(key2,key1,8); diff --git a/crypto/des/supp.c b/crypto/des/supp.c index 8fa0a3e8e4..e51b36c916 100644 --- a/crypto/des/supp.c +++ b/crypto/des/supp.c @@ -87,13 +87,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: supp.c,v 1.4 1999/04/19 21:28:07 ulf Exp $ + * $Id: supp.c,v 1.5 1999/05/16 12:25:45 bodo Exp $ */ #include <stdio.h> #include "des_locl.h" -void des_cblock_print_file(const des_cblock cb, FILE *fp) +void des_cblock_print_file(const_des_cblock *cb, FILE *fp) { int i; const unsigned int *p = (const unsigned int *)cb; diff --git a/crypto/des/xcbc_enc.c b/crypto/des/xcbc_enc.c index 0d3b6a4d04..51e17e6b8a 100644 --- a/crypto/des/xcbc_enc.c +++ b/crypto/des/xcbc_enc.c @@ -79,11 +79,14 @@ static unsigned char desx_white_in2out[256]={ 0xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB, }; -void des_xwhite_in2out(const des_cblock key, const des_cblock in, - des_cblock out) +void des_xwhite_in2out(const_des_cblock *des_key, const_des_cblock *in_white, + des_cblock *out_white) { int out0,out1; int i; + const unsigned char *key = &(*des_key)[0]; + const unsigned char *in = &(*in_white)[0]; + unsigned char *out = &(*out_white)[0]; out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0; out0=out1=0; @@ -104,9 +107,9 @@ void des_xwhite_in2out(const des_cblock key, const des_cblock in, } } -void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, long length, - des_key_schedule schedule, des_cblock ivec, const des_cblock inw, - const des_cblock outw, int enc) +void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, + long length, des_key_schedule schedule, des_cblock *ivec, + const_des_cblock *inw, const_des_cblock *outw, int enc) { register DES_LONG tin0,tin1; register DES_LONG tout0,tout1,xor0,xor1; @@ -116,14 +119,14 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, long length, DES_LONG tin[2]; unsigned char *iv; - in2=inw; + in2 = &(*inw)[0]; c2l(in2,inW0); c2l(in2,inW1); - in2=outw; + in2 = &(*outw)[0]; c2l(in2,outW0); c2l(in2,outW1); - iv=ivec; + iv = &(*ivec)[0]; if (enc) { @@ -148,7 +151,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, long length, tout0=tin[0]^outW0; l2c(tout0,out); tout1=tin[1]^outW1; l2c(tout1,out); } - iv=ivec; + iv = &(*ivec)[0]; l2c(tout0,iv); l2c(tout1,iv); } @@ -180,7 +183,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, long length, xor1=tin1; } - iv=ivec; + iv = &(*ivec)[0]; l2c(xor0,iv); l2c(xor1,iv); } diff --git a/crypto/evp/e_cbc_3d.c b/crypto/evp/e_cbc_3d.c index 3c16f5a4e0..02ccc6dc90 100644 --- a/crypto/evp/e_cbc_3d.c +++ b/crypto/evp/e_cbc_3d.c @@ -107,14 +107,16 @@ EVP_CIPHER *EVP_des_ede3_cbc(void) static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { + des_cblock *deskey = (des_cblock *)key; + if (iv != NULL) memcpy(&(ctx->oiv[0]),iv,8); memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); - if (key != NULL) + if (deskey != NULL) { - des_set_key(key,ctx->c.des_ede.ks1); - des_set_key(&(key[8]),ctx->c.des_ede.ks2); + des_set_key(&deskey[0],ctx->c.des_ede.ks1); + des_set_key(&deskey[1],ctx->c.des_ede.ks2); memcpy( (char *)ctx->c.des_ede.ks3, (char *)ctx->c.des_ede.ks1, sizeof(ctx->c.des_ede.ks1)); @@ -124,15 +126,17 @@ static void des_cbc_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, static void des_cbc_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { + des_cblock *deskey = (des_cblock *)key; + if (iv != NULL) memcpy(&(ctx->oiv[0]),iv,8); memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); - if (key != NULL) + if (deskey != NULL) { - 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); + des_set_key(&deskey[0],ctx->c.des_ede.ks1); + des_set_key(&deskey[1],ctx->c.des_ede.ks2); + des_set_key(&deskey[2],ctx->c.des_ede.ks3); } } @@ -141,7 +145,7 @@ static void des_cbc_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, { des_ede3_cbc_encrypt(in,out,inl, ctx->c.des_ede.ks1, ctx->c.des_ede.ks2,ctx->c.des_ede.ks3, - &(ctx->iv[0]), + (des_cblock *) &(ctx->iv[0]), ctx->encrypt); } #endif diff --git a/crypto/evp/e_cbc_d.c b/crypto/evp/e_cbc_d.c index f394fa4806..9203f3f52d 100644 --- a/crypto/evp/e_cbc_d.c +++ b/crypto/evp/e_cbc_d.c @@ -87,16 +87,20 @@ EVP_CIPHER *EVP_des_cbc(void) static void des_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { + des_cblock *deskey = (des_cblock *)key; + if (iv != NULL) memcpy(&(ctx->oiv[0]),iv,8); memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); - if (key != NULL) - des_set_key(key,ctx->c.des_ks); + if (deskey != NULL) + des_set_key(deskey,ctx->c.des_ks); } static void des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl) { - des_ncbc_encrypt(in,out,inl,ctx->c.des_ks,&(ctx->iv[0]),ctx->encrypt); + des_ncbc_encrypt(in,out,inl,ctx->c.des_ks, + (des_cblock *)&(ctx->iv[0]), + ctx->encrypt); } #endif diff --git a/crypto/evp/e_cfb_3d.c b/crypto/evp/e_cfb_3d.c index 7a6a65b29c..bd32b072e2 100644 --- a/crypto/evp/e_cfb_3d.c +++ b/crypto/evp/e_cfb_3d.c @@ -107,15 +107,17 @@ EVP_CIPHER *EVP_des_ede3_cfb(void) static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { + des_cblock *deskey = (des_cblock *)key; + ctx->num=0; if (iv != NULL) memcpy(&(ctx->oiv[0]),iv,8); memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); - if (key != NULL) + if (deskey != NULL) { - des_set_key(key,ctx->c.des_ede.ks1); - des_set_key(&(key[8]),ctx->c.des_ede.ks2); + des_set_key(&deskey[0],ctx->c.des_ede.ks1); + des_set_key(&deskey[1],ctx->c.des_ede.ks2); memcpy( (char *)ctx->c.des_ede.ks3, (char *)ctx->c.des_ede.ks1, sizeof(ctx->c.des_ede.ks1)); @@ -125,16 +127,18 @@ static void des_ede_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, static void des_ede3_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { + des_cblock *deskey = (des_cblock *)key; + ctx->num=0; if (iv != NULL) memcpy(&(ctx->oiv[0]),iv,8); memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); - if (key != NULL) + if (deskey != NULL) { - 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); + des_set_key(&deskey[0],ctx->c.des_ede.ks1); + des_set_key(&deskey[1],ctx->c.des_ede.ks2); + des_set_key(&deskey[2],ctx->c.des_ede.ks3); } } @@ -145,6 +149,7 @@ static void des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3, - &(ctx->iv[0]),&ctx->num,ctx->encrypt); + (des_cblock*)&(ctx->iv[0]), + &ctx->num,ctx->encrypt); } #endif diff --git a/crypto/evp/e_cfb_d.c b/crypto/evp/e_cfb_d.c index 8b77430157..6bdf20b646 100644 --- a/crypto/evp/e_cfb_d.c +++ b/crypto/evp/e_cfb_d.c @@ -87,13 +87,15 @@ EVP_CIPHER *EVP_des_cfb(void) static void des_cfb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { + des_cblock *deskey = (des_cblock *)key; + ctx->num=0; if (iv != NULL) memcpy(&(ctx->oiv[0]),iv,8); memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); - if (key != NULL) - des_set_key(key,ctx->c.des_ks); + if (deskey != NULL) + des_set_key(deskey,ctx->c.des_ks); } static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, @@ -102,7 +104,7 @@ static void des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, des_cfb64_encrypt( in,out, (long)inl, ctx->c.des_ks, - &(ctx->iv[0]), + (des_cblock *)&(ctx->iv[0]), &ctx->num,ctx->encrypt); } #endif diff --git a/crypto/evp/e_ecb_3d.c b/crypto/evp/e_ecb_3d.c index 7bceceeb6c..354a8b79a7 100644 --- a/crypto/evp/e_ecb_3d.c +++ b/crypto/evp/e_ecb_3d.c @@ -106,10 +106,12 @@ EVP_CIPHER *EVP_des_ede3(void) static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { - if (key != NULL) + des_cblock *deskey = (des_cblock *)key; + + if (deskey != NULL) { - des_set_key(key,ctx->c.des_ede.ks1); - des_set_key(&(key[8]),ctx->c.des_ede.ks2); + des_set_key(&deskey[0],ctx->c.des_ede.ks1); + des_set_key(&deskey[1],ctx->c.des_ede.ks2); memcpy( (char *)ctx->c.des_ede.ks3, (char *)ctx->c.des_ede.ks1, sizeof(ctx->c.des_ede.ks1)); @@ -119,11 +121,13 @@ static void des_ede_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, static void des_ede3_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { - if (key != NULL) + des_cblock *deskey = (des_cblock *)key; + + if (deskey != NULL) { - 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); + des_set_key(&deskey[0],ctx->c.des_ede.ks1); + des_set_key(&deskey[1],ctx->c.des_ede.ks2); + des_set_key(&deskey[2],ctx->c.des_ede.ks3); } } @@ -131,16 +135,24 @@ static void des_ede_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl) { unsigned int i; + des_cblock *output /* = (des_cblock *)out */; + des_cblock *input /* = (des_cblock *)in */; if (inl < 8) return; inl-=8; for (i=0; i<=inl; i+=8) { - des_ecb3_encrypt(&(in[i]),&(out[i]), + output = (des_cblock *)(out + i); + input = (des_cblock *)(in + i); + + des_ecb3_encrypt(input,output, ctx->c.des_ede.ks1, ctx->c.des_ede.ks2, ctx->c.des_ede.ks3, ctx->encrypt); + + /* output++; */ + /* input++; */ } } #endif diff --git a/crypto/evp/e_ecb_d.c b/crypto/evp/e_ecb_d.c index 3496ca5180..5fb4e64b1c 100644 --- a/crypto/evp/e_ecb_d.c +++ b/crypto/evp/e_ecb_d.c @@ -87,20 +87,32 @@ EVP_CIPHER *EVP_des_ecb(void) static void des_ecb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { - if (key != NULL) - des_set_key(key,ctx->c.des_ks); + des_cblock *deskey = (des_cblock *)key; + + if (deskey != NULL) + des_set_key(deskey,ctx->c.des_ks); } static void des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl) { unsigned int i; + des_cblock *output /* = (des_cblock *)out */; + des_cblock *input /* = (des_cblock *)in */; if (inl < 8) return; inl-=8; for (i=0; i<=inl; i+=8) { - des_ecb_encrypt(&(in[i]),&(out[i]),ctx->c.des_ks,ctx->encrypt); + /* Either this ... */ + output = (des_cblock *)(out + i); + input = (des_cblock *)(in + i); + + des_ecb_encrypt(input,output,ctx->c.des_ks,ctx->encrypt); + + /* ... or this. */ + /* output++; */ + /* input++; */ } } #endif diff --git a/crypto/evp/e_ofb_3d.c b/crypto/evp/e_ofb_3d.c index dba58c118a..5233567c0c 100644 --- a/crypto/evp/e_ofb_3d.c +++ b/crypto/evp/e_ofb_3d.c @@ -107,15 +107,17 @@ EVP_CIPHER *EVP_des_ede3_ofb(void) static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { + des_cblock *deskey = (des_cblock *)key; + ctx->num=0; if (iv != NULL) memcpy(&(ctx->oiv[0]),iv,8); memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); - if (key != NULL) + if (deskey != NULL) { - des_set_key(key,ctx->c.des_ede.ks1); - des_set_key(&(key[8]),ctx->c.des_ede.ks2); + des_set_key(&deskey[0],ctx->c.des_ede.ks1); + des_set_key(&deskey[1],ctx->c.des_ede.ks2); memcpy( (char *)ctx->c.des_ede.ks3, (char *)ctx->c.des_ede.ks1, sizeof(ctx->c.des_ede.ks1)); @@ -125,16 +127,18 @@ static void des_ede_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, static void des_ede3_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { + des_cblock *deskey = (des_cblock *)key; + ctx->num=0; if (iv != NULL) memcpy(&(ctx->oiv[0]),iv,8); memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); - if (key != NULL) + if (deskey != NULL) { - 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); + des_set_key(&deskey[0],ctx->c.des_ede.ks1); + des_set_key(&deskey[1],ctx->c.des_ede.ks2); + des_set_key(&deskey[2],ctx->c.des_ede.ks3); } } @@ -143,6 +147,6 @@ static void des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, { 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); + (des_cblock *)&(ctx->iv[0]),&ctx->num); } #endif diff --git a/crypto/evp/e_ofb_d.c b/crypto/evp/e_ofb_d.c index fd75b7344d..398b3a002e 100644 --- a/crypto/evp/e_ofb_d.c +++ b/crypto/evp/e_ofb_d.c @@ -87,18 +87,21 @@ EVP_CIPHER *EVP_des_ofb(void) static void des_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { + des_cblock *deskey = (des_cblock *)key; + ctx->num=0; if (iv != NULL) memcpy(&(ctx->oiv[0]),iv,8); memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); - if (key != NULL) - des_set_key(key,ctx->c.des_ks); + if (deskey != NULL) + des_set_key(deskey,ctx->c.des_ks); } static void des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl) { - des_ofb64_encrypt(in,out,inl,ctx->c.des_ks,&(ctx->iv[0]),&ctx->num); + des_ofb64_encrypt(in,out,inl,ctx->c.des_ks, + (des_cblock *)&(ctx->iv[0]),&ctx->num); } #endif diff --git a/crypto/evp/e_xcbc_d.c b/crypto/evp/e_xcbc_d.c index 3238de021d..3a6628a75c 100644 --- a/crypto/evp/e_xcbc_d.c +++ b/crypto/evp/e_xcbc_d.c @@ -87,12 +87,14 @@ EVP_CIPHER *EVP_desx_cbc(void) static void desx_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, unsigned char *iv, int enc) { + des_cblock *deskey = (des_cblock *)key; + if (iv != NULL) memcpy(&(ctx->oiv[0]),iv,8); memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8); - if (key != NULL) + if (deskey != NULL) { - des_set_key(key,ctx->c.desx_cbc.ks); + des_set_key(deskey,ctx->c.desx_cbc.ks); memcpy(&(ctx->c.desx_cbc.inw[0]),&(key[8]),8); memcpy(&(ctx->c.desx_cbc.outw[0]),&(key[16]),8); } @@ -102,9 +104,9 @@ static void desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, unsigned char *in, unsigned int inl) { des_xcbc_encrypt(in,out,inl,ctx->c.desx_cbc.ks, - &(ctx->iv[0]), - &(ctx->c.desx_cbc.inw[0]), - &(ctx->c.desx_cbc.outw[0]), + (des_cblock *)&(ctx->iv[0]), + &ctx->c.desx_cbc.inw, + &ctx->c.desx_cbc.outw, ctx->encrypt); } #endif diff --git a/crypto/mdc2/mdc2dgst.c b/crypto/mdc2/mdc2dgst.c index 8b5314fed8..4fc39ed86c 100644 --- a/crypto/mdc2/mdc2dgst.c +++ b/crypto/mdc2/mdc2dgst.c @@ -134,12 +134,12 @@ static void mdc2_body(MDC2_CTX *c, unsigned char *in, unsigned int len) c->h[0]=(c->h[0]&0x9f)|0x40; c->hh[0]=(c->hh[0]&0x9f)|0x20; - des_set_odd_parity(c->h); - des_set_key(c->h,k); + des_set_odd_parity(&c->h); + des_set_key(&c->h,k); des_encrypt(d,k,1); - des_set_odd_parity(c->hh); - des_set_key(c->hh,k); + des_set_odd_parity(&c->hh); + des_set_key(&c->hh,k); des_encrypt(dd,k,1); ttin0=tin0^dd[0]; |