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
#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);
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);
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);
#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);
#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)
{
*/
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;
{
DES_LONG ti[2];
unsigned char *iv,c,cc;
- iv=(unsigned char *)ivec;
+ iv=ivec;
if (enc)
{
while (l--)
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;
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];
*/
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;
{
DES_LONG ti[2];
unsigned char *iv,c,cc;
- iv=(unsigned char *)ivec;
+ iv=ivec;
if (enc)
{
while (l--)
{
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;
{
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];
* 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;
mask1=0x00000000L;
}
- iv=(unsigned char *)ivec;
+ iv=ivec;
c2l(iv,v0);
c2l(iv,v1);
if (enc)
out+=n;
}
}
- iv=(unsigned char *)ivec;
+ iv=ivec;
l2c(v0,iv);
l2c(v1,iv);
v0=v1=d0=d1=ti[0]=ti[1]=0;
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;
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;
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)
{
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;
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)
{
#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;
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");
#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;
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");
#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;
/* 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)
{
}
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");
#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");
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");
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");
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");
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");
}
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)
{
}
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");
}
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));
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)
{
}
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");
}
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",
}
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;
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 ");
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;
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;
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;
}
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;
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;
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;
#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;
}
-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);
#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,
{
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)
{
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);
}
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);
}
char *buf;
int len;
des_key_schedule sched;
-des_cblock (*iv);
+des_cblock iv;
{
/* data to be unencrypted */
int net_num=0;
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;
{
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 :-( */
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);
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();
static char *outbuf=NULL;
char shortbuf[8];
char *p;
+ const char *cp;
static int start=1;
if (outbuf == NULL)
/* 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();
}
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;
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);
* 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;
unsigned char *iv;
int save=0;
- iv=(unsigned char *)ivec;
+ iv=ivec;
c2l(iv,v0);
c2l(iv,v1);
ti[0]=v0;
{
/* 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];
{
/* v0=ti[0];
v1=ti[1];*/
- iv=(unsigned char *)ivec;
+ iv=ivec;
l2c(v0,iv);
l2c(v1,iv);
}
* 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++;
{
v0=ti[0];
v1=ti[1];
- iv=(unsigned char *)ivec;
+ iv=ivec;
l2c(v0,iv);
l2c(v1,iv);
}
* 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;
mask1=0x00000000L;
}
- iv=(unsigned char *)ivec;
+ iv=ivec;
c2l(iv,v0);
c2l(iv,v1);
ti[0]=v0;
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;
#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;
#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;
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++)
{
}
else
{
- lp=output[out_count-i-1];
+ lp=&output[out_count-i-1];
l2n(z1,lp);
l2n(z0,lp);
}
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));
#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;
}
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;
char *buf;
char *buff;
int size;
-char *prompt;
+const char *prompt;
int verify;
{
#ifdef VMS
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.
#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
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);
{0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}};
int des_is_weak_key(key)
-des_cblock (*key);
+const des_cblock key;
{
int i;
* 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};
}
int des_key_sched(key, schedule)
-des_cblock (*key);
+const des_cblock key;
des_key_schedule schedule;
{
return(des_set_key(key,schedule));
extern int des_check_key;
void des_string_to_key(str, key)
-char *str;
-des_cblock (*key);
+const char *str;
+des_cblock key;
{
des_key_schedule ks;
int i,length;
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
- des_set_odd_parity((des_cblock *)key);
+ des_set_odd_parity(key);
i=des_check_key;
des_check_key=0;
- des_set_key((des_cblock *)key,ks);
+ des_set_key(key,ks);
des_check_key=i;
- des_cbc_cksum((des_cblock *)str,(des_cblock *)key,(long)length,ks,
- (des_cblock *)key);
+ des_cbc_cksum(str,key,length,ks,key);
memset(ks,0,sizeof(ks));
- des_set_odd_parity((des_cblock *)key);
+ des_set_odd_parity(key);
}
void des_string_to_2keys(str, key1, key2)
-char *str;
-des_cblock (*key1);
-des_cblock (*key2);
+const char *str;
+des_cblock key1;
+des_cblock key2;
{
des_key_schedule ks;
int i,length;
{
for (i=0; i<length; i++)
{
- (*key2)[i]=(*key1)[i]=(str[i]<<1);
+ key2[i]=key1[i]=(str[i]<<1);
}
}
else
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 */
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
{
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);
#endif
- des_set_odd_parity((des_cblock *)key1);
- des_set_odd_parity((des_cblock *)key2);
+ des_set_odd_parity(key1);
+ des_set_odd_parity(key2);
i=des_check_key;
des_check_key=0;
- des_set_key((des_cblock *)key1,ks);
- des_cbc_cksum((des_cblock *)str,(des_cblock *)key1,(long)length,ks,
- (des_cblock *)key1);
- des_set_key((des_cblock *)key2,ks);
- des_cbc_cksum((des_cblock *)str,(des_cblock *)key2,(long)length,ks,
- (des_cblock *)key2);
+ des_set_key(key1,ks);
+ des_cbc_cksum(str,key1,length,ks,key1);
+ des_set_key(key2,ks);
+ des_cbc_cksum(str,key2,length,ks,key2);
des_check_key=i;
memset(ks,0,sizeof(ks));
des_set_odd_parity(key1);
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: supp.c,v 1.1.1.2 1998/12/21 10:55:04 rse Exp $
+ * $Id: supp.c,v 1.2 1999/02/13 18:52:21 ben Exp $
*/
#include <stdio.h>
#include "des_locl.h"
void des_cblock_print_file(cb, fp)
- des_cblock *cb;
+ const des_cblock cb;
FILE *fp;
{
int i;
0xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB,
};
-void des_xwhite_in2out(des_key,in_white,out_white)
-des_cblock (*des_key);
-des_cblock (*in_white);
-des_cblock (*out_white);
+void des_xwhite_in2out(key,in,out)
+const des_cblock key;
+const des_cblock in;
+des_cblock out;
{
- unsigned char *key,*in,*out;
int out0,out1;
int i;
- key=(unsigned char *)des_key;
- in=(unsigned char *)in_white;
- out=(unsigned char *)out_white;
-
out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0;
out0=out1=0;
for (i=0; i<8; i++)
}
}
-void des_xcbc_encrypt(input, output, length, schedule, ivec, inw,outw,enc)
-des_cblock (*input);
-des_cblock (*output);
+void des_xcbc_encrypt(in, out, length, schedule, ivec, inw,outw,enc)
+const unsigned char *in;
+unsigned char *out;
long length;
des_key_schedule schedule;
-des_cblock (*ivec);
-des_cblock (*inw);
-des_cblock (*outw);
+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;
register DES_LONG inW0,inW1,outW0,outW1;
- register unsigned char *in,*out;
+ register const unsigned char *in2;
register long l=length;
DES_LONG tin[2];
unsigned char *iv;
- in=(unsigned char *)inw;
- c2l(in,inW0);
- c2l(in,inW1);
- in=(unsigned char *)outw;
- c2l(in,outW0);
- c2l(in,outW1);
+ in2=inw;
+ c2l(in2,inW0);
+ c2l(in2,inW1);
+ in2=outw;
+ c2l(in2,outW0);
+ c2l(in2,outW1);
- in=(unsigned char *)input;
- out=(unsigned char *)output;
- iv=(unsigned char *)ivec;
+ iv=ivec;
if (enc)
{
c2l(in,tin1);
tin0^=tout0^inW0; tin[0]=tin0;
tin1^=tout1^inW1; tin[1]=tin1;
- des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
+ des_encrypt(tin,schedule,DES_ENCRYPT);
tout0=tin[0]^outW0; l2c(tout0,out);
tout1=tin[1]^outW1; l2c(tout1,out);
}
c2ln(in,tin0,tin1,l+8);
tin0^=tout0^inW0; tin[0]=tin0;
tin1^=tout1^inW1; tin[1]=tin1;
- des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT);
+ des_encrypt(tin,schedule,DES_ENCRYPT);
tout0=tin[0]^outW0; l2c(tout0,out);
tout1=tin[1]^outW1; l2c(tout1,out);
}
- iv=(unsigned char *)ivec;
+ iv=ivec;
l2c(tout0,iv);
l2c(tout1,iv);
}
{
c2l(in,tin0); tin[0]=tin0^outW0;
c2l(in,tin1); tin[1]=tin1^outW1;
- des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
+ des_encrypt(tin,schedule,DES_DECRYPT);
tout0=tin[0]^xor0^inW0;
tout1=tin[1]^xor1^inW1;
l2c(tout0,out);
{
c2l(in,tin0); tin[0]=tin0^outW0;
c2l(in,tin1); tin[1]=tin1^outW1;
- des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT);
+ des_encrypt(tin,schedule,DES_DECRYPT);
tout0=tin[0]^xor0^inW0;
tout1=tin[1]^xor1^inW1;
l2cn(tout0,tout1,out,l+8);
xor1=tin1;
}
- iv=(unsigned char *)ivec;
+ iv=ivec;
l2c(xor0,iv);
l2c(xor1,iv);
}
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
- des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
+ des_set_key(key,ctx->c.des_ede.ks1);
+ des_set_key(&(key[8]),ctx->c.des_ede.ks2);
memcpy( (char *)ctx->c.des_ede.ks3,
(char *)ctx->c.des_ede.ks1,
sizeof(ctx->c.des_ede.ks1));
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
- des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
- des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
+ des_set_key(key,ctx->c.des_ede.ks1);
+ des_set_key(&(key[8]),ctx->c.des_ede.ks2);
+ des_set_key(&(key[16]),ctx->c.des_ede.ks3);
}
}
unsigned char *in;
unsigned int inl;
{
- des_ede3_cbc_encrypt(
- (des_cblock *)in,(des_cblock *)out,
- (long)inl, ctx->c.des_ede.ks1,
+ des_ede3_cbc_encrypt(in,out,inl, ctx->c.des_ede.ks1,
ctx->c.des_ede.ks2,ctx->c.des_ede.ks3,
- (des_cblock *)&(ctx->iv[0]),
+ &(ctx->iv[0]),
ctx->encrypt);
}
memcpy(&(ctx->oiv[0]),iv,8);
memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
- des_set_key((des_cblock *)key,ctx->c.des_ks);
+ des_set_key(key,ctx->c.des_ks);
}
static void des_cfb_cipher(ctx,out,in,inl)
des_cfb64_encrypt(
in,out,
(long)inl, ctx->c.des_ks,
- (des_cblock *)&(ctx->iv[0]),
+ &(ctx->iv[0]),
&ctx->num,ctx->encrypt);
}
{
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
- des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
+ des_set_key(key,ctx->c.des_ede.ks1);
+ des_set_key(&(key[8]),ctx->c.des_ede.ks2);
memcpy( (char *)ctx->c.des_ede.ks3,
(char *)ctx->c.des_ede.ks1,
sizeof(ctx->c.des_ede.ks1));
{
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.des_ede.ks1);
- des_set_key((des_cblock *)&(key[8]),ctx->c.des_ede.ks2);
- des_set_key((des_cblock *)&(key[16]),ctx->c.des_ede.ks3);
+ des_set_key(key,ctx->c.des_ede.ks1);
+ des_set_key(&(key[8]),ctx->c.des_ede.ks2);
+ des_set_key(&(key[16]),ctx->c.des_ede.ks3);
}
}
inl-=8;
for (i=0; i<=inl; i+=8)
{
- des_ecb3_encrypt(
- (des_cblock *)&(in[i]),(des_cblock *)&(out[i]),
+ des_ecb3_encrypt(&(in[i]),&(out[i]),
ctx->c.des_ede.ks1,
ctx->c.des_ede.ks2,
ctx->c.des_ede.ks3,
int enc;
{
if (key != NULL)
- des_set_key((des_cblock *)key,ctx->c.des_ks);
+ des_set_key(key,ctx->c.des_ks);
}
static void des_ecb_cipher(ctx,out,in,inl)
inl-=8;
for (i=0; i<=inl; i+=8)
{
- des_ecb_encrypt(
- (des_cblock *)&(in[i]),(des_cblock *)&(out[i]),
- ctx->c.des_ks,ctx->encrypt);
+ des_ecb_encrypt(&(in[i]),&(out[i]),ctx->c.des_ks,ctx->encrypt);
}
}
memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
if (key != NULL)
{
- des_set_key((des_cblock *)key,ctx->c.desx_cbc.ks);
+ des_set_key(key,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);
}
unsigned char *in;
unsigned int inl;
{
- des_xcbc_encrypt(
- (des_cblock *)in,(des_cblock *)out,
- (long)inl, ctx->c.desx_cbc.ks,
- (des_cblock *)&(ctx->iv[0]),
- (des_cblock *)&(ctx->c.desx_cbc.inw[0]),
- (des_cblock *)&(ctx->c.desx_cbc.outw[0]),
+ 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]),
ctx->encrypt);
}
register DES_LONG tin0,tin1;
register DES_LONG ttin0,ttin1;
DES_LONG d[2],dd[2];
- des_cblock *h,*hh;
+ unsigned char *h,*hh;
des_key_schedule k;
unsigned char *p;
unsigned int i;
- h= (des_cblock *)&(c->h[0]);
- hh= (des_cblock *)&(c->hh[0]);
+ h= c->h;
+ hh= c->hh;
for (i=0; i<len; i+=8)
{
c2l(in,tin0); d[0]=dd[0]=tin0;
c2l(in,tin1); d[1]=dd[1]=tin1;
- (*h)[0]=((*h)[0]&0x9f)|0x40;
- (*hh)[0]=((*hh)[0]&0x9f)|0x20;
+ h[0]=(h[0]&0x9f)|0x40;
+ hh[0]=(hh[0]&0x9f)|0x20;
des_set_odd_parity(h);
des_set_key(h,k);
- des_encrypt((DES_LONG *)d,k,1);
+ des_encrypt(d,k,1);
des_set_odd_parity(hh);
des_set_key(hh,k);
- des_encrypt((DES_LONG *)dd,k,1);
+ des_encrypt(dd,k,1);
ttin0=tin0^dd[0];
ttin1=tin1^dd[1];
tin0^=d[0];
tin1^=d[1];
- p=(unsigned char *)h;
+ p=h;
l2c(tin0,p);
l2c(ttin1,p);
p=(unsigned char *)hh;
&(nid_objs[19]),/* OBJ_rsa 2 5 8 1 1 */
&(nid_objs[96]),/* OBJ_mdc2WithRSA 2 5 8 3 100 */
&(nid_objs[95]),/* OBJ_mdc2 2 5 8 3 101 */
-&(nid_objs[124]),/* OBJ_rle_compression 1 1 1 1 666.1 */
&(nid_objs[125]),/* OBJ_zlib_compression 1 1 1 1 666.2 */
+&(nid_objs[124]),/* OBJ_rle_compression 1 1 1 1 666.1 */
&(nid_objs[104]),/* OBJ_md5WithRSA 1 3 14 3 2 3 */
&(nid_objs[29]),/* OBJ_des_ecb 1 3 14 3 2 6 */
&(nid_objs[31]),/* OBJ_des_cbc 1 3 14 3 2 7 */