Browse Source

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).
master
Bodo Möller 24 years ago
parent
commit
edf0bfb52b
37 changed files with 323 additions and 259 deletions
  1. +5
    -5
      apps/speed.c
  2. +5
    -2
      crypto/des/cbc_cksm.c
  3. +2
    -2
      crypto/des/cbc_enc.c
  4. +6
    -6
      crypto/des/cfb64ede.c
  5. +7
    -7
      crypto/des/cfb64enc.c
  6. +3
    -3
      crypto/des/cfb_enc.c
  7. +39
    -37
      crypto/des/des.h
  8. +8
    -8
      crypto/des/des_enc.c
  9. +60
    -60
      crypto/des/destest.c
  10. +3
    -1
      crypto/des/ecb3_enc.c
  11. +4
    -1
      crypto/des/ecb_enc.c
  12. +8
    -7
      crypto/des/ede_cbcm_enc.c
  13. +1
    -1
      crypto/des/enc_read.c
  14. +1
    -1
      crypto/des/enc_writ.c
  15. +1
    -1
      crypto/des/fcrypt.c
  16. +4
    -3
      crypto/des/ofb64ede.c
  17. +3
    -3
      crypto/des/ofb64enc.c
  18. +3
    -3
      crypto/des/ofb_enc.c
  19. +2
    -2
      crypto/des/pcbc_enc.c
  20. +6
    -6
      crypto/des/qud_cksm.c
  21. +9
    -9
      crypto/des/rand_key.c
  22. +2
    -2
      crypto/des/read2pwd.c
  23. +4
    -3
      crypto/des/rpc_enc.c
  24. +9
    -9
      crypto/des/set_key.c
  25. +12
    -12
      crypto/des/str2key.c
  26. +2
    -2
      crypto/des/supp.c
  27. +13
    -10
      crypto/des/xcbc_enc.c
  28. +12
    -8
      crypto/evp/e_cbc_3d.c
  29. +7
    -3
      crypto/evp/e_cbc_d.c
  30. +13
    -8
      crypto/evp/e_cfb_3d.c
  31. +5
    -3
      crypto/evp/e_cfb_d.c
  32. +20
    -8
      crypto/evp/e_ecb_3d.c
  33. +15
    -3
      crypto/evp/e_ecb_d.c
  34. +12
    -8
      crypto/evp/e_ofb_3d.c
  35. +6
    -3
      crypto/evp/e_ofb_d.c
  36. +7
    -5
      crypto/evp/e_xcbc_d.c
  37. +4
    -4
      crypto/mdc2/mdc2dgst.c

+ 5
- 5
apps/speed.c View File

@ -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);


+ 5
- 2
crypto/des/cbc_cksm.c View File

@ -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);


+ 2
- 2
crypto/des/cbc_enc.c View File

@ -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)
{


+ 6
- 6
crypto/des/cfb64ede.c View File

@ -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];


+ 7
- 7
crypto/des/cfb64enc.c View File

@ -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];


+ 3
- 3
crypto/des/cfb_enc.c View File

@ -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;


+ 39
- 37
crypto/des/des.h View File

@ -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


+ 8
- 8
crypto/des/des_enc.c View File

@ -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);
}


+ 60
- 60
crypto/des/destest.c View File

@ -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;


+ 3
- 1
crypto/des/ecb3_enc.c View File

@ -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);


+ 4
- 1
crypto/des/ecb_enc.c View File

@ -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;


+ 8
- 7
crypto/des/ede_cbcm_enc.c View File

@ -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);
}


+ 1
- 1
crypto/des/enc_read.c View File

@ -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;


+ 1
- 1
crypto/des/enc_writ.c View File

@ -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();


+ 1
- 1
crypto/des/fcrypt.c View File

@ -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);


+ 4
- 3
crypto/des/ofb64ede.c View File

@ -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);
}


+ 3
- 3
crypto/des/ofb64enc.c View File

@ -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);
}


+ 3
- 3
crypto/des/ofb_enc.c View File

@ -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;


+ 2
- 2
crypto/des/pcbc_enc.c View File

@ -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)
{


+ 6
- 6
crypto/des/qud_cksm.c View File

@ -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);
}


+ 9
- 9
crypto/des/rand_key.c View File

@ -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));


+ 2
- 2
crypto/des/read2pwd.c View File

@ -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;


+ 4
- 3
crypto/des/rpc_enc.c View File

@ -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.


+ 9
- 9
crypto/des/set_key.c View File

@ -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);