Browse Source

Fix ghastly DES declarations, and all consequential warnings.

master
Ben Laurie 24 years ago
parent
commit
4e31df2cd7
34 changed files with 291 additions and 351 deletions
  1. +6
    -0
      CHANGES
  2. +8
    -11
      apps/speed.c
  3. +4
    -9
      crypto/des/cbc_cksm.c
  4. +7
    -8
      crypto/des/cbc_enc.c
  5. +9
    -9
      crypto/des/cfb64ede.c
  6. +9
    -11
      crypto/des/cfb64enc.c
  7. +4
    -4
      crypto/des/cfb_enc.c
  8. +76
    -94
      crypto/des/destest.c
  9. +3
    -6
      crypto/des/ecb3_enc.c
  10. +3
    -6
      crypto/des/ecb_enc.c
  11. +7
    -10
      crypto/des/ede_cbcm_enc.c
  12. +11
    -17
      crypto/des/enc_read.c
  13. +9
    -10
      crypto/des/enc_writ.c
  14. +1
    -1
      crypto/des/fcrypt.c
  15. +5
    -5
      crypto/des/ofb64ede.c
  16. +8
    -8
      crypto/des/ofb64enc.c
  17. +4
    -4
      crypto/des/ofb_enc.c
  18. +3
    -3
      crypto/des/pcbc_enc.c
  19. +7
    -7
      crypto/des/qud_cksm.c
  20. +6
    -8
      crypto/des/rand_key.c
  21. +5
    -5
      crypto/des/read2pwd.c
  22. +1
    -1
      crypto/des/read_pwd.c
  23. +5
    -7
      crypto/des/rpc_enc.c
  24. +8
    -8
      crypto/des/set_key.c
  25. +25
    -28
      crypto/des/str2key.c
  26. +2
    -2
      crypto/des/supp.c
  27. +24
    -31
      crypto/des/xcbc_enc.c
  28. +7
    -9
      crypto/evp/e_cbc_3d.c
  29. +2
    -2
      crypto/evp/e_cfb_d.c
  30. +6
    -7
      crypto/evp/e_ecb_3d.c
  31. +2
    -4
      crypto/evp/e_ecb_d.c
  32. +5
    -7
      crypto/evp/e_xcbc_d.c
  33. +8
    -8
      crypto/mdc2/mdc2dgst.c
  34. +1
    -1
      crypto/objects/obj_dat.h

+ 6
- 0
CHANGES View File

@ -5,6 +5,12 @@
Changes between 0.9.1c and 0.9.2
*) Major rework of DES function declarations, in the pursuit of correctness
and purity. As a result, many evil casts evaporated, and some weirdness,
too. You may find this causes warnings in your code. Zapping your evil
casts will probably fix them. Mostly.
[Ben Laurie]
*) Fix for a typo in asn1.h. Bug fix to object creation script
obj_dat.pl. It considered a zero in an object definition to mean
"end of object": none of the objects in objects.h have any zeros


+ 8
- 11
apps/speed.c View File

@ -601,9 +601,9 @@ char **argv;
#endif
#ifndef NO_DES
des_set_key((C_Block *)key,sch);
des_set_key((C_Block *)key2,sch2);
des_set_key((C_Block *)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);
@ -851,10 +851,8 @@ char **argv;
print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
Time_F(START);
for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
des_ncbc_encrypt((C_Block *)buf,
(C_Block *)buf,
(long)lengths[j],sch,
(C_Block *)&(iv[0]),DES_ENCRYPT);
des_ncbc_encrypt(buf,buf,lengths[j],sch,
&(iv[0]),DES_ENCRYPT);
d=Time_F(STOP);
BIO_printf(bio_err,"%ld %s's in %.2fs\n",
count,names[D_CBC_DES],d);
@ -869,10 +867,9 @@ char **argv;
print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
Time_F(START);
for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
des_ede3_cbc_encrypt((C_Block *)buf,
(C_Block *)buf,
(long)lengths[j],sch,sch2,sch3,
(C_Block *)&(iv[0]),DES_ENCRYPT);
des_ede3_cbc_encrypt(buf,buf,lengths[j],
sch,sch2,sch3,
&(iv[0]),DES_ENCRYPT);
d=Time_F(STOP);
BIO_printf(bio_err,"%ld %s's in %.2fs\n",
count,names[D_EDE3_DES],d);


+ 4
- 9
crypto/des/cbc_cksm.c View File

@ -58,21 +58,16 @@
#include "des_locl.h"
DES_LONG des_cbc_cksum(input, output, length, schedule, ivec)
des_cblock (*input);
des_cblock (*output);
DES_LONG des_cbc_cksum(in, out, length, schedule, iv)
const unsigned char *in;
des_cblock out;
long length;
des_key_schedule schedule;
des_cblock (*ivec);
des_cblock iv;
{
register DES_LONG tout0,tout1,tin0,tin1;
register long l=length;
DES_LONG tin[2];
unsigned char *in,*out,*iv;
in=(unsigned char *)input;
out=(unsigned char *)output;
iv=(unsigned char *)ivec;
c2l(iv,tout0);
c2l(iv,tout1);


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

@ -58,24 +58,23 @@
#include "des_locl.h"
void des_cbc_encrypt(input, output, length, schedule, ivec, enc)
des_cblock (*input);
des_cblock (*output);
/* Note that this is inconsistent with other DES functions, in that it doesn't
update ivec */
void des_cbc_encrypt(in, out, length, schedule, ivec, enc)
const unsigned char *in;
unsigned char *out;
long length;
des_key_schedule schedule;
des_cblock (*ivec);
des_cblock ivec;
int enc;
{
register DES_LONG tin0,tin1;
register DES_LONG tout0,tout1,xor0,xor1;
register unsigned char *in,*out;
register long l=length;
DES_LONG tin[2];
unsigned char *iv;
in=(unsigned char *)input;
out=(unsigned char *)output;
iv=(unsigned char *)ivec;
iv=ivec;
if (enc)
{


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

@ -64,11 +64,11 @@
*/
void des_ede3_cfb64_encrypt(in, out, length, ks1,ks2,ks3, ivec, num, enc)
unsigned char *in;
const unsigned char *in;
unsigned char *out;
long length;
des_key_schedule ks1,ks2,ks3;
des_cblock (*ivec);
des_cblock ivec;
int *num;
int enc;
{
@ -78,7 +78,7 @@ int enc;
DES_LONG ti[2];
unsigned char *iv,c,cc;
iv=(unsigned char *)ivec;
iv=ivec;
if (enc)
{
while (l--)
@ -90,14 +90,14 @@ int enc;
ti[0]=v0;
ti[1]=v1;
des_encrypt3((DES_LONG *)ti,ks1,ks2,ks3);
des_encrypt3(ti,ks1,ks2,ks3);
v0=ti[0];
v1=ti[1];
iv=(unsigned char *)ivec;
iv=ivec;
l2c(v0,iv);
l2c(v1,iv);
iv=(unsigned char *)ivec;
iv=ivec;
}
c= *(in++)^iv[n];
*(out++)=c;
@ -116,14 +116,14 @@ int enc;
ti[0]=v0;
ti[1]=v1;
des_encrypt3((DES_LONG *)ti,ks1,ks2,ks3);
des_encrypt3(ti,ks1,ks2,ks3);
v0=ti[0];
v1=ti[1];
iv=(unsigned char *)ivec;
iv=ivec;
l2c(v0,iv);
l2c(v1,iv);
iv=(unsigned char *)ivec;
iv=ivec;
}
cc= *(in++);
c=iv[n];


+ 9
- 11
crypto/des/cfb64enc.c View File

@ -64,11 +64,11 @@
*/
void des_cfb64_encrypt(in, out, length, schedule, ivec, num, enc)
unsigned char *in;
const unsigned char *in;
unsigned char *out;
long length;
des_key_schedule schedule;
des_cblock (*ivec);
des_cblock ivec;
int *num;
int enc;
{
@ -78,7 +78,7 @@ int enc;
DES_LONG ti[2];
unsigned char *iv,c,cc;
iv=(unsigned char *)ivec;
iv=ivec;
if (enc)
{
while (l--)
@ -87,12 +87,11 @@ int enc;
{
c2l(iv,v0); ti[0]=v0;
c2l(iv,v1); ti[1]=v1;
des_encrypt((DES_LONG *)ti,
schedule,DES_ENCRYPT);
iv=(unsigned char *)ivec;
des_encrypt(ti,schedule,DES_ENCRYPT);
iv=ivec;
v0=ti[0]; l2c(v0,iv);
v0=ti[1]; l2c(v0,iv);
iv=(unsigned char *)ivec;
iv=ivec;
}
c= *(in++)^iv[n];
*(out++)=c;
@ -108,12 +107,11 @@ int enc;
{
c2l(iv,v0); ti[0]=v0;
c2l(iv,v1); ti[1]=v1;
des_encrypt((DES_LONG *)ti,
schedule,DES_ENCRYPT);
iv=(unsigned char *)ivec;
des_encrypt(ti,schedule,DES_ENCRYPT);
iv=ivec;
v0=ti[0]; l2c(v0,iv);
v0=ti[1]; l2c(v0,iv);
iv=(unsigned char *)ivec;
iv=ivec;
}
cc= *(in++);
c=iv[n];


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

@ -65,12 +65,12 @@
* byte.
*/
void des_cfb_encrypt(in, out, numbits, length, schedule, ivec, enc)
unsigned char *in;
const unsigned char *in;
unsigned char *out;
int numbits;
long length;
des_key_schedule schedule;
des_cblock (*ivec);
des_cblock ivec;
int enc;
{
register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8;
@ -96,7 +96,7 @@ int enc;
mask1=0x00000000L;
}
iv=(unsigned char *)ivec;
iv=ivec;
c2l(iv,v0);
c2l(iv,v1);
if (enc)
@ -163,7 +163,7 @@ int enc;
out+=n;
}
}
iv=(unsigned char *)ivec;
iv=ivec;
l2c(v0,iv);
l2c(v1,iv);
v0=v1=d0=d1=ti[0]=ti[1]=0;


+ 76
- 94
crypto/des/destest.c View File

@ -329,17 +329,17 @@ char *argv[];
char *str;
printf("Doing cbcm\n");
if ((j=des_key_sched((C_Block *)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((C_Block *)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((C_Block *)cbc3_key,ks3)) != 0)
if ((j=des_key_sched(cbc3_key,ks3)) != 0)
{
printf("Key error %d\n",j);
err=1;
@ -383,7 +383,7 @@ char *argv[];
printf("Doing ecb\n");
for (i=0; i<NUM_TESTS; i++)
{
if ((j=des_key_sched((C_Block *)(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;
@ -391,8 +391,8 @@ char *argv[];
memcpy(in,plain_data[i],8);
memset(out,0,8);
memset(outin,0,8);
des_ecb_encrypt((C_Block *)in,(C_Block *)out,ks,DES_ENCRYPT);
des_ecb_encrypt((C_Block *)out,(C_Block *)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)
{
@ -413,17 +413,17 @@ char *argv[];
printf("Doing ede ecb\n");
for (i=0; i<(NUM_TESTS-1); i++)
{
if ((j=des_key_sched((C_Block *)(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((C_Block *)(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((C_Block *)(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;
@ -431,10 +431,8 @@ char *argv[];
memcpy(in,plain_data[i],8);
memset(out,0,8);
memset(outin,0,8);
des_ecb2_encrypt((C_Block *)in,(C_Block *)out,ks,ks2,
DES_ENCRYPT);
des_ecb2_encrypt((C_Block *)out,(C_Block *)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)
{
@ -453,7 +451,7 @@ char *argv[];
#endif
printf("Doing cbc\n");
if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0)
if ((j=des_key_sched(cbc_key,ks)) != 0)
{
printf("Key error %d\n",j);
err=1;
@ -461,16 +459,14 @@ char *argv[];
memset(cbc_out,0,40);
memset(cbc_in,0,40);
memcpy(iv3,cbc_iv,sizeof(cbc_iv));
des_ncbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out,
(long)strlen((char *)cbc_data)+1,ks,
(C_Block *)iv3,DES_ENCRYPT);
des_ncbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
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((C_Block *)cbc_out,(C_Block *)cbc_in,
(long)strlen((char *)cbc_data)+1,ks,
(C_Block *)iv3,DES_DECRYPT);
des_ncbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
iv3,DES_DECRYPT);
if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)) != 0)
{
printf("cbc_encrypt decrypt error\n");
@ -479,7 +475,7 @@ char *argv[];
#ifndef LIBDES_LIT
printf("Doing desx cbc\n");
if ((j=des_key_sched((C_Block *)cbc_key,ks)) != 0)
if ((j=des_key_sched(cbc_key,ks)) != 0)
{
printf("Key error %d\n",j);
err=1;
@ -487,19 +483,15 @@ char *argv[];
memset(cbc_out,0,40);
memset(cbc_in,0,40);
memcpy(iv3,cbc_iv,sizeof(cbc_iv));
des_xcbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out,
(long)strlen((char *)cbc_data)+1,ks,
(C_Block *)iv3,
(C_Block *)cbc2_key, (C_Block *)cbc3_key, DES_ENCRYPT);
des_xcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
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((C_Block *)cbc_out,(C_Block *)cbc_in,
(long)strlen((char *)cbc_data)+1,ks,
(C_Block *)iv3,
(C_Block *)cbc2_key, (C_Block *)cbc3_key, DES_DECRYPT);
des_xcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
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");
@ -508,17 +500,17 @@ char *argv[];
#endif
printf("Doing ede cbc\n");
if ((j=des_key_sched((C_Block *)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((C_Block *)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((C_Block *)cbc3_key,ks3)) != 0)
if ((j=des_key_sched(cbc3_key,ks3)) != 0)
{
printf("Key error %d\n",j);
err=1;
@ -529,11 +521,9 @@ char *argv[];
/* i=((i+7)/8)*8; */
memcpy(iv3,cbc_iv,sizeof(cbc_iv));
des_ede3_cbc_encrypt((C_Block *)cbc_data,(C_Block *)cbc_out,
16L,ks,ks2,ks3,(C_Block *)iv3,DES_ENCRYPT);
des_ede3_cbc_encrypt((C_Block *)&(cbc_data[16]),
(C_Block *)&(cbc_out[16]),
(long)i-16,ks,ks2,ks3,(C_Block *)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);
if (memcmp(cbc_out,cbc3_ok,
(unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
{
@ -542,8 +532,7 @@ char *argv[];
}
memcpy(iv3,cbc_iv,sizeof(cbc_iv));
des_ede3_cbc_encrypt((C_Block *)cbc_out,(C_Block *)cbc_in,
(long)i,ks,ks2,ks3,(C_Block *)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(cbc_data)+1) != 0)
{
printf("des_ede3_cbc_encrypt decrypt error\n");
@ -552,22 +541,22 @@ char *argv[];
#ifndef LIBDES_LIT
printf("Doing pcbc\n");
if ((j=des_key_sched((C_Block *)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((C_Block *)cbc_data,(C_Block *)cbc_out,
(long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv,DES_ENCRYPT);
des_pcbc_encrypt(cbc_data,cbc_out,strlen(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((C_Block *)cbc_out,(C_Block *)cbc_in,
(long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv,DES_DECRYPT);
des_pcbc_encrypt(cbc_out,cbc_in,strlen(cbc_data)+1,ks,cbc_iv,
DES_DECRYPT);
if (memcmp(cbc_in,cbc_data,strlen(cbc_data)+1) != 0)
{
printf("pcbc_encrypt decrypt error\n");
@ -592,7 +581,7 @@ 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,(long)1,ks,(C_Block *)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");
@ -602,7 +591,7 @@ 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,(long)1,ks,(C_Block *)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");
@ -615,10 +604,9 @@ char *argv[];
printf("done\n");
printf("Doing ofb\n");
des_key_sched((C_Block *)ofb_key,ks);
des_key_sched(ofb_key,ks);
memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
des_ofb_encrypt(plain,ofb_buf1,64,(long)sizeof(plain)/8,ks,
(C_Block *)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");
@ -631,8 +619,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,(long)sizeof(ofb_buf1)/8,ks,
(C_Block *)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");
@ -646,15 +633,15 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
}
printf("Doing ofb64\n");
des_key_sched((C_Block *)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,
(C_Block *)ofb_tmp,&num);
des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ofb_tmp,
&num);
}
if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
{
@ -663,8 +650,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,(long)sizeof(ofb_buf1),ks,
(C_Block *)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");
@ -672,7 +658,7 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
}
printf("Doing ede_ofb64\n");
des_key_sched((C_Block *)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));
@ -680,7 +666,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,
(C_Block *)ofb_tmp,&num);
ofb_tmp,&num);
}
if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
{
@ -689,8 +675,8 @@ 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,(long)sizeof(ofb_buf1),ks,
ks,ks,(C_Block *)ofb_tmp,&num);
des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,
ks,ks,ofb_tmp,&num);
if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
{
printf("ede_ofb64_encrypt decrypt error\n");
@ -698,9 +684,8 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
}
printf("Doing cbc_cksum\n");
des_key_sched((C_Block *)cbc_key,ks);
cs=des_cbc_cksum((C_Block *)cbc_data,(C_Block *)cret,
(long)strlen(cbc_data),ks,(C_Block *)cbc_iv);
des_key_sched(cbc_key,ks);
cs=des_cbc_cksum(cbc_data,cret,strlen(cbc_data),ks,cbc_iv);
if (cs != cbc_cksum_ret)
{
printf("bad return value (%08lX), should be %08lX\n",
@ -714,8 +699,11 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
}
printf("Doing quad_cksum\n");
cs=quad_cksum((C_Block *)cbc_data,(C_Block *)qret,
(long)strlen(cbc_data),2,(C_Block *)cbc_iv);
/* This is obviously done this way especially to puzzle me. Although
quad_cksum returns up to 4 groups of 8 bytes, this test gets it to
produce 2 groupos then treats them as 4 groups of 4 bytes.
Ben 13 Feb 1999 */
cs=quad_cksum(cbc_data,(des_cblocks)qret,strlen(cbc_data),2,cbc_iv);
{ /* Big-endian fix */
static DES_LONG l=1;
@ -777,17 +765,15 @@ plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
for (i=0; i<4; i++)
{
printf(" %d",i);
des_ncbc_encrypt((C_Block *)&(cbc_out[i]),(C_Block *)cbc_in,
(long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv,
DES_ENCRYPT);
des_ncbc_encrypt(&(cbc_out[i]),cbc_in,strlen(cbc_data)+1,ks,
cbc_iv,DES_ENCRYPT);
}
printf("\noutput word alignment test");
for (i=0; i<4; i++)
{
printf(" %d",i);
des_ncbc_encrypt((C_Block *)cbc_out,(C_Block *)&(cbc_in[i]),
(long)strlen(cbc_data)+1,ks,(C_Block *)cbc_iv,
DES_ENCRYPT);
des_ncbc_encrypt(cbc_out,&(cbc_in[i]),strlen(cbc_data)+1,ks,
cbc_iv,DES_ENCRYPT);
}
printf("\n");
printf("fast crypt test ");
@ -837,10 +823,10 @@ unsigned char *cfb_cipher;
des_key_schedule ks;
int i,err=0;
des_key_sched((C_Block *)cfb_key,ks);
des_key_sched(cfb_key,ks);
memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
des_cfb_encrypt(plain,cfb_buf1,bits,(long)sizeof(plain),ks,
(C_Block *)cfb_tmp,DES_ENCRYPT);
des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,cfb_tmp,
DES_ENCRYPT);
if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
{
err=1;
@ -849,8 +835,8 @@ 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,(long)sizeof(plain),ks,
(C_Block *)cfb_tmp,DES_DECRYPT);
des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,sizeof(plain),ks,cfb_tmp,
DES_DECRYPT);
if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
{
err=1;
@ -867,14 +853,12 @@ unsigned char *cfb_cipher;
des_key_schedule ks;
int err=0,i,n;
des_key_sched((C_Block *)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,(long)12,ks,
(C_Block *)cfb_tmp,&n,DES_ENCRYPT);
des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
(long)sizeof(plain)-12,ks,
(C_Block *)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);
if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
{
err=1;
@ -884,11 +868,9 @@ unsigned char *cfb_cipher;
}
memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
n=0;
des_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks,
(C_Block *)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]),
(long)sizeof(plain)-17,ks,
(C_Block *)cfb_tmp,&n,DES_DECRYPT);
sizeof(plain)-17,ks,cfb_tmp,&n,DES_DECRYPT);
if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
{
err=1;
@ -905,14 +887,14 @@ unsigned char *cfb_cipher;
des_key_schedule ks;
int err=0,i,n;
des_key_sched((C_Block *)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,(long)12,ks,ks,ks,
(C_Block *)cfb_tmp,&n,DES_ENCRYPT);
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]),
(long)sizeof(plain)-12,ks,ks,ks,
(C_Block *)cfb_tmp,&n,DES_ENCRYPT);
sizeof(plain)-12,ks,ks,ks,
cfb_tmp,&n,DES_ENCRYPT);
if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
{
err=1;
@ -923,10 +905,10 @@ 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,
(C_Block *)cfb_tmp,&n,DES_DECRYPT);
cfb_tmp,&n,DES_DECRYPT);
des_ede3_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
(long)sizeof(plain)-17,ks,ks,ks,
(C_Block *)cfb_tmp,&n,DES_DECRYPT);
sizeof(plain)-17,ks,ks,ks,
cfb_tmp,&n,DES_DECRYPT);
if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
{
err=1;


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

@ -58,20 +58,17 @@
#include "des_locl.h"
void des_ecb3_encrypt(input, output, ks1, ks2, ks3, enc)
des_cblock (*input);
des_cblock (*output);
void des_ecb3_encrypt(in, out, ks1, ks2, ks3, enc)
const des_cblock in;
des_cblock out;
des_key_schedule ks1;
des_key_schedule ks2;
des_key_schedule ks3;
int enc;
{
register DES_LONG l0,l1;
register unsigned char *in,*out;
DES_LONG ll[2];
in=(unsigned char *)input;
out=(unsigned char *)output;
c2l(in,l0);
c2l(in,l1);
ll[0]=l0;


+ 3
- 6
crypto/des/ecb_enc.c View File

@ -102,18 +102,15 @@ char *des_options()
}
void des_ecb_encrypt(input, output, ks, enc)
des_cblock (*input);
des_cblock (*output);
void des_ecb_encrypt(in, out, ks, enc)
const unsigned char *in;
unsigned char *out;
des_key_schedule ks;
int enc;
{
register DES_LONG l;
register unsigned char *in,*out;
DES_LONG ll[2];
in=(unsigned char *)input;
out=(unsigned char *)output;
c2l(in,l); ll[0]=l;
c2l(in,l); ll[1]=l;
des_encrypt(ll,ks,enc);


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

@ -65,7 +65,7 @@ Feedback Masking, by Coppersmith, Johnson and Matyas, (IBM and Certicom).
#include "des_locl.h"
void des_ede3_cbcm_encrypt(const unsigned char *input,unsigned char *output,
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,
@ -74,15 +74,12 @@ void des_ede3_cbcm_encrypt(const unsigned char *input,unsigned char *output,
{
register DES_LONG tin0,tin1;
register DES_LONG tout0,tout1,xor0,xor1,m0,m1;
register unsigned char *in,*out;
register long l=length;
DES_LONG tin[2];
unsigned char *iv1,*iv2;
in=(unsigned char *)input;
out=(unsigned char *)output;
iv1=(unsigned char *)ivec1;
iv2=(unsigned char *)ivec2;
iv1=ivec1;
iv2=ivec2;
if (enc)
{
@ -125,11 +122,11 @@ void des_ede3_cbcm_encrypt(const unsigned char *input,unsigned char *output,
l2c(tout0,out);
l2c(tout1,out);
}
iv1=(unsigned char *)ivec1;
iv1=ivec1;
l2c(m0,iv1);
l2c(m1,iv1);
iv2=(unsigned char *)ivec2;
iv2=ivec2;
l2c(tout0,iv2);
l2c(tout1,iv2);
}
@ -182,11 +179,11 @@ void des_ede3_cbcm_encrypt(const unsigned char *input,unsigned char *output,
xor1=t1;
}
iv1=(unsigned char *)ivec1;
iv1=ivec1;
l2c(m0,iv1);
l2c(m1,iv1);
iv2=(unsigned char *)ivec2;
iv2=ivec2;
l2c(xor0,iv2);
l2c(xor1,iv2);
}


+ 11
- 17
crypto/des/enc_read.c View File

@ -69,7 +69,7 @@ int fd;
char *buf;
int len;
des_key_schedule sched;
des_cblock (*iv);
des_cblock iv;
{
/* data to be unencrypted */
int net_num=0;
@ -165,11 +165,9 @@ des_cblock (*iv);
if (len < num)
{
if (des_rw_mode & DES_PCBC_MODE)
des_pcbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
num,sched,iv,DES_DECRYPT);
des_pcbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT);
else
des_cbc_encrypt((des_cblock *)net,(des_cblock *)unnet,
num,sched,iv,DES_DECRYPT);
des_cbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT);
memcpy(buf,unnet,(unsigned int)len);
unnet_start=len;
unnet_left=(int)num-len;
@ -189,13 +187,11 @@ des_cblock (*iv);
{
if (des_rw_mode & DES_PCBC_MODE)
des_pcbc_encrypt((des_cblock *)net,
(des_cblock *)tmpbuf,
num,sched,iv,DES_DECRYPT);
des_pcbc_encrypt(net,tmpbuf,num,sched,iv,
DES_DECRYPT);
else
des_cbc_encrypt((des_cblock *)net,
(des_cblock *)tmpbuf,
num,sched,iv,DES_DECRYPT);
des_cbc_encrypt(net,tmpbuf,num,sched,iv,
DES_DECRYPT);
/* eay 26/08/92 fix a bug that returned more
* bytes than you asked for (returned len bytes :-( */
@ -204,13 +200,11 @@ des_cblock (*iv);
else
{
if (des_rw_mode & DES_PCBC_MODE)
des_pcbc_encrypt((des_cblock *)net,
(des_cblock *)buf,num,sched,iv,
DES_DECRYPT);
des_pcbc_encrypt(net,buf,num,sched,iv,
DES_DECRYPT);
else
des_cbc_encrypt((des_cblock *)net,
(des_cblock *)buf,num,sched,iv,
DES_DECRYPT);
des_cbc_encrypt(net,buf,num,sched,iv,
DES_DECRYPT);
}
}
return((int)num);


+ 9
- 10
crypto/des/enc_writ.c View File

@ -62,10 +62,10 @@
int des_enc_write(fd, buf, len, sched, iv)
int fd;
char *buf;
const char *buf;
int len;
des_key_schedule sched;
des_cblock (*iv);
des_cblock iv;
{
#ifdef _LIBC
extern int srandom();
@ -79,6 +79,7 @@ des_cblock (*iv);
static char *outbuf=NULL;
char shortbuf[8];
char *p;
const char *cp;
static int start=1;
if (outbuf == NULL)
@ -117,7 +118,7 @@ des_cblock (*iv);
/* pad short strings */
if (len < 8)
{
p=shortbuf;
cp=shortbuf;
memcpy(shortbuf,buf,(unsigned int)len);
for (i=len; i<8; i++)
shortbuf[i]=random();
@ -125,18 +126,16 @@ des_cblock (*iv);
}
else
{
p=buf;
cp=buf;
rnum=((len+7)/8*8); /* round up to nearest eight */
}
if (des_rw_mode & DES_PCBC_MODE)
des_pcbc_encrypt((des_cblock *)p,
(des_cblock *)&(outbuf[HDRSIZE]),
(long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
des_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv,
DES_ENCRYPT);
else
des_cbc_encrypt((des_cblock *)p,
(des_cblock *)&(outbuf[HDRSIZE]),
(long)((len<8)?8:len),sched,iv,DES_ENCRYPT);
des_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv,
DES_ENCRYPT);
/* output */
outnum=(int)rnum+HDRSIZE;


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

@ -123,7 +123,7 @@ r=(r+7)/8;
for (; i<8; i++)
key[i]=0;
des_set_key((des_cblock *)(key),ks);
des_set_key(key,ks);
fcrypt_body(&(out[0]),ks,Eswap0,Eswap1);
ll=out[0]; l2c(ll,b);


+ 5
- 5
crypto/des/ofb64ede.c View File

@ -63,11 +63,11 @@
* 64bit block we have used is contained in *num;
*/
void des_ede3_ofb64_encrypt(in, out, length, k1,k2,k3, ivec, num)
register unsigned char *in;
register const unsigned char *in;
register unsigned char *out;
long length;
des_key_schedule k1,k2,k3;
des_cblock (*ivec);
des_cblock ivec;
int *num;
{
register DES_LONG v0,v1;
@ -79,7 +79,7 @@ int *num;
unsigned char *iv;
int save=0;
iv=(unsigned char *)ivec;
iv=ivec;
c2l(iv,v0);
c2l(iv,v1);
ti[0]=v0;
@ -93,7 +93,7 @@ int *num;
{
/* ti[0]=v0; */
/* ti[1]=v1; */
des_encrypt3((DES_LONG *)ti,k1,k2,k3);
des_encrypt3(ti,k1,k2,k3);
v0=ti[0];
v1=ti[1];
@ -109,7 +109,7 @@ int *num;
{
/* v0=ti[0];
v1=ti[1];*/
iv=(unsigned char *)ivec;
iv=ivec;
l2c(v0,iv);
l2c(v1,iv);
}


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

@ -63,36 +63,36 @@
* 64bit block we have used is contained in *num;
*/
void des_ofb64_encrypt(in, out, length, schedule, ivec, num)
register unsigned char *in;
register const unsigned char *in;
register unsigned char *out;
long length;
des_key_schedule schedule;
des_cblock (*ivec);
des_cblock ivec;
int *num;
{
register DES_LONG v0,v1,t;
register int n= *num;
register long l=length;
des_cblock d;
register char *dp;
register unsigned char *dp;
DES_LONG ti[2];
unsigned char *iv;
int save=0;
iv=(unsigned char *)ivec;
iv=ivec;
c2l(iv,v0);
c2l(iv,v1);
ti[0]=v0;
ti[1]=v1;
dp=(char *)d;
dp=d;
l2c(v0,dp);
l2c(v1,dp);
while (l--)
{
if (n == 0)
{
des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT);
dp=(char *)d;
des_encrypt(ti,schedule,DES_ENCRYPT);
dp=d;
t=ti[0]; l2c(t,dp);
t=ti[1]; l2c(t,dp);
save++;
@ -104,7 +104,7 @@ int *num;
{
v0=ti[0];
v1=ti[1];
iv=(unsigned char *)ivec;
iv=ivec;
l2c(v0,iv);
l2c(v1,iv);
}


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

@ -65,12 +65,12 @@
* byte.
*/
void des_ofb_encrypt(in, out, numbits, length, schedule, ivec)
unsigned char *in;
const unsigned char *in;
unsigned char *out;
int numbits;
long length;
des_key_schedule schedule;
des_cblock (*ivec);
des_cblock ivec;
{
register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8;
register DES_LONG mask0,mask1;
@ -97,7 +97,7 @@ des_cblock (*ivec);
mask1=0x00000000L;
}
iv=(unsigned char *)ivec;
iv=ivec;
c2l(iv,v0);
c2l(iv,v1);
ti[0]=v0;
@ -131,7 +131,7 @@ des_cblock (*ivec);
v1=((v1>>num)|(vv0<<(32-num)))&0xffffffffL;
}
}
iv=(unsigned char *)ivec;
iv=ivec;
l2c(v0,iv);
l2c(v1,iv);
v0=v1=d0=d1=ti[0]=ti[1]=vv0=vv1=0;


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

@ -59,11 +59,11 @@
#include "des_locl.h"
void des_pcbc_encrypt(input, output, length, schedule, ivec, enc)
des_cblock (*input);
des_cblock (*output);
const unsigned char *input;
unsigned char *output;
long length;
des_key_schedule schedule;
des_cblock (*ivec);
des_cblock ivec;
int enc;
{
register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1;


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

@ -74,11 +74,11 @@
#define NOISE ((DES_LONG)83653421L)
DES_LONG des_quad_cksum(input, output, length, out_count, seed)
des_cblock (*input);
des_cblock (*output);
const unsigned char *input;
des_cblocks output;
long length;
int out_count;
des_cblock (*seed);
des_cblock seed;
{
DES_LONG z0,z1,t0,t1;
int i;
@ -87,10 +87,10 @@ des_cblock (*seed);
unsigned char *lp;
if (out_count < 1) out_count=1;
lp=(unsigned char *)output;
lp=output;
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++)
{
@ -133,7 +133,7 @@ des_cblock (*seed);
}
else
{
lp=output[out_count-i-1];
lp=&output[out_count-i-1];
l2n(z1,lp);
l2n(z0,lp);
}


+ 6
- 8
crypto/des/rand_key.c View File

@ -101,15 +101,13 @@ unsigned char *ret;
t=(DES_LONG)((pid)|((c++)<<16));
l2c(t,p);
des_set_odd_parity((des_cblock *)data);
des_set_key((des_cblock *)data,ks);
des_cbc_cksum((des_cblock *)key,(des_cblock *)key,
(long)sizeof(key),ks,(des_cblock *)data);
des_set_odd_parity(data);
des_set_key(data,ks);
des_cbc_cksum(key,key,sizeof(key),ks,data);
des_set_odd_parity((des_cblock *)key);
des_set_key((des_cblock *)key,ks);
des_cbc_cksum((des_cblock *)key,(des_cblock *)data,
(long)sizeof(key),ks,(des_cblock *)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));


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

@ -59,8 +59,8 @@
#include "des_locl.h"
int des_read_password(key, prompt, verify)
des_cblock (*key);
char *prompt;
des_cblock key;
const char *prompt;
int verify;
{
int ok;
@ -74,9 +74,9 @@ int verify;
}
int des_read_2passwords(key1, key2, prompt, verify)
des_cblock (*key1);
des_cblock (*key2);
char *prompt;
des_cblock key1;
des_cblock key2;
const char *prompt;
int verify;
{
int ok;


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

@ -209,7 +209,7 @@ int des_read_pw(buf, buff, size, prompt, verify)
char *buf;
char *buff;
int size;
char *prompt;
const char *prompt;
int verify;
{
#ifdef VMS


+ 5
- 7
crypto/des/rpc_enc.c View File

@ -74,18 +74,16 @@ struct desparams *desp;
des_key_schedule ks;
int enc;
des_set_key((des_cblock *)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((des_cblock *)desp->UDES.UDES_buf,
(des_cblock *)desp->UDES.UDES_buf,ks,enc);
des_ecb_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf,ks,
enc);
else
{
des_ncbc_encrypt((des_cblock *)desp->UDES.UDES_buf,
(des_cblock *)desp->UDES.UDES_buf,
(long)len,ks,
(des_cblock *)desp->des_ivec,enc);
des_ncbc_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf,
len,ks,desp->des_ivec,enc);
#ifdef undef
/* len will always be %8 if called from common_crypt
* in secure_rpc.


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

@ -68,7 +68,7 @@
#include "sk.h"
#ifndef NOPROTO
static int check_parity(des_cblock (*key));
static int check_parity(const des_cblock key);
#else
static int check_parity();
#endif
@ -76,22 +76,22 @@ static int check_parity();
int des_check_key=0;
void des_set_odd_parity(key)
des_cblock (*key);
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(key)
des_cblock (*key);
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);
@ -128,7 +128,7 @@ static des_cblock weak_keys[NUM_WEAK_KEY]={
{0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}};
int des_is_weak_key(key)
des_cblock (*key);
const des_cblock key;
{
int i;
@ -158,7 +158,7 @@ des_cblock (*key);
* return -2 if illegal weak key.
*/
int des_set_key(key, schedule)
des_cblock (*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};
@ -239,7 +239,7 @@ des_key_schedule schedule;
}
int des_key_sched(key, schedule)
des_cblock (*key);
const des_cblock key;
des_key_schedule schedule;
{