Since there has been reports of clashes between OpenSSL's

des_encrypt() and des_encrypt() defined on some systems (Solaris and
Unixware and maybe others), we rename des_encrypt() to des_encrypt1().
This should have very little impact on external software unless
someone has written a mode of DES, since that's all des_encrypt() is
meant for.
This commit is contained in:
Richard Levitte 2001-03-29 07:45:37 +00:00
parent 7cdd2aa128
commit 080b8cadfa
15 changed files with 42 additions and 37 deletions

11
CHANGES
View file

@ -4,11 +4,16 @@
Changes between 0.9.6 and 0.9.7 [xx XXX 2000] Changes between 0.9.6 and 0.9.7 [xx XXX 2000]
*) Rename 'des_encrypt' to 'des_encrypt1'. This avoids the clashes
with des_encrypt() defined on some operating systems, like Solaris
and UnixWare.
[Richard Levitte]
*) Check the result of RSA-CRT (see D. Boneh, R. DeMillo, R. Lipton: *) Check the result of RSA-CRT (see D. Boneh, R. DeMillo, R. Lipton:
On the Importance of Eliminating Errors in Cryptographic On the Importance of Eliminating Errors in Cryptographic
Computations, J. Cryptology 14 (2001) 2, 101-119, Computations, J. Cryptology 14 (2001) 2, 101-119,
http://theory.stanford.edu/~dabo/papers/faults.ps.gz). http://theory.stanford.edu/~dabo/papers/faults.ps.gz).
[Ulf Moeller] [Ulf Moeller]
*) MIPS assembler BIGNUM division bug fix. *) MIPS assembler BIGNUM division bug fix.
[Andy Polyakov] [Andy Polyakov]

View file

@ -82,7 +82,7 @@ DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock *output,
tin0^=tout0; tin[0]=tin0; tin0^=tout0; tin[0]=tin0;
tin1^=tout1; tin[1]=tin1; tin1^=tout1; tin[1]=tin1;
des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
/* fix 15/10/91 eay - thanks to keithr@sco.COM */ /* fix 15/10/91 eay - thanks to keithr@sco.COM */
tout0=tin[0]; tout0=tin[0];
tout1=tin[1]; tout1=tin[1];

View file

@ -82,7 +82,7 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out,
{ {
c2l(iv,v0); ti[0]=v0; c2l(iv,v0); ti[0]=v0;
c2l(iv,v1); ti[1]=v1; c2l(iv,v1); ti[1]=v1;
des_encrypt(ti,schedule,DES_ENCRYPT); des_encrypt1(ti,schedule,DES_ENCRYPT);
iv = &(*ivec)[0]; iv = &(*ivec)[0];
v0=ti[0]; l2c(v0,iv); v0=ti[0]; l2c(v0,iv);
v0=ti[1]; l2c(v0,iv); v0=ti[1]; l2c(v0,iv);
@ -102,7 +102,7 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out,
{ {
c2l(iv,v0); ti[0]=v0; c2l(iv,v0); ti[0]=v0;
c2l(iv,v1); ti[1]=v1; c2l(iv,v1); ti[1]=v1;
des_encrypt(ti,schedule,DES_ENCRYPT); des_encrypt1(ti,schedule,DES_ENCRYPT);
iv = &(*ivec)[0]; iv = &(*ivec)[0];
v0=ti[0]; l2c(v0,iv); v0=ti[0]; l2c(v0,iv);
v0=ti[1]; l2c(v0,iv); v0=ti[1]; l2c(v0,iv);

View file

@ -100,7 +100,7 @@ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
l-=n; l-=n;
ti[0]=v0; ti[0]=v0;
ti[1]=v1; ti[1]=v1;
des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT); des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
c2ln(in,d0,d1,n); c2ln(in,d0,d1,n);
in+=n; in+=n;
d0=(d0^ti[0])&mask0; d0=(d0^ti[0])&mask0;
@ -132,7 +132,7 @@ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
l-=n; l-=n;
ti[0]=v0; ti[0]=v0;
ti[1]=v1; ti[1]=v1;
des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT); des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
c2ln(in,d0,d1,n); c2ln(in,d0,d1,n);
in+=n; in+=n;
/* 30-08-94 - eay - changed because l>>32 and /* 30-08-94 - eay - changed because l>>32 and

View file

@ -153,14 +153,14 @@ void des_ecb_encrypt(const_des_cblock *input,des_cblock *output,
Data is a pointer to 2 unsigned long's and ks is the Data is a pointer to 2 unsigned long's and ks is the
des_key_schedule to use. enc, is non zero specifies encryption, des_key_schedule to use. enc, is non zero specifies encryption,
zero if decryption. */ zero if decryption. */
void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc); void des_encrypt1(DES_LONG *data,des_key_schedule ks, int enc);
/* This functions is the same as des_encrypt() except that the DES /* This functions is the same as des_encrypt1() except that the DES
initial permutation (IP) and final permutation (FP) have been left initial permutation (IP) and final permutation (FP) have been left
out. As for des_encrypt(), you should not use this function. out. As for des_encrypt1(), you should not use this function.
It is used by the routines in the library that implement triple DES. It is used by the routines in the library that implement triple DES.
IP() des_encrypt2() des_encrypt2() des_encrypt2() FP() is the same IP() des_encrypt2() des_encrypt2() des_encrypt2() FP() is the same
as des_encrypt() des_encrypt() des_encrypt() except faster :-). */ as des_encrypt1() des_encrypt1() des_encrypt1() except faster :-). */
void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc); void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
void des_encrypt3(DES_LONG *data, des_key_schedule ks1, void des_encrypt3(DES_LONG *data, des_key_schedule ks1,

View file

@ -58,7 +58,7 @@
#include "des_locl.h" #include "des_locl.h"
void des_encrypt(DES_LONG *data, des_key_schedule ks, int enc) void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc)
{ {
register DES_LONG l,r,t,u; register DES_LONG l,r,t,u;
#ifdef DES_PTR #ifdef DES_PTR

View file

@ -453,7 +453,7 @@ int main(int argc, char **argv)
count*=2; count*=2;
Time_F(START); Time_F(START);
for (i=count; i; i--) for (i=count; i; i--)
des_encrypt(data,&(sch[0]),DES_ENCRYPT); des_encrypt1(data,&(sch[0]),DES_ENCRYPT);
d=Time_F(STOP); d=Time_F(STOP);
} while (d < 3.0); } while (d < 3.0);
ca=count; ca=count;

View file

@ -114,7 +114,7 @@ void des_ecb_encrypt(const_des_cblock *input, des_cblock *output,
c2l(in,l); ll[0]=l; c2l(in,l); ll[0]=l;
c2l(in,l); ll[1]=l; c2l(in,l); ll[1]=l;
des_encrypt(ll,ks,enc); des_encrypt1(ll,ks,enc);
l=ll[0]; l2c(l,out); l=ll[0]; l2c(l,out);
l=ll[1]; l2c(l,out); l=ll[1]; l2c(l,out);
l=ll[0]=ll[1]=0; l=ll[0]=ll[1]=0;

View file

@ -95,7 +95,7 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
{ {
tin[0]=m0; tin[0]=m0;
tin[1]=m1; tin[1]=m1;
des_encrypt(tin,ks3,1); des_encrypt1(tin,ks3,1);
m0=tin[0]; m0=tin[0];
m1=tin[1]; m1=tin[1];
@ -113,13 +113,13 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
tin[0]=tin0; tin[0]=tin0;
tin[1]=tin1; tin[1]=tin1;
des_encrypt(tin,ks1,1); des_encrypt1(tin,ks1,1);
tin[0]^=m0; tin[0]^=m0;
tin[1]^=m1; tin[1]^=m1;
des_encrypt(tin,ks2,0); des_encrypt1(tin,ks2,0);
tin[0]^=m0; tin[0]^=m0;
tin[1]^=m1; tin[1]^=m1;
des_encrypt(tin,ks1,1); des_encrypt1(tin,ks1,1);
tout0=tin[0]; tout0=tin[0];
tout1=tin[1]; tout1=tin[1];
@ -146,7 +146,7 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
{ {
tin[0]=m0; tin[0]=m0;
tin[1]=m1; tin[1]=m1;
des_encrypt(tin,ks3,1); des_encrypt1(tin,ks3,1);
m0=tin[0]; m0=tin[0];
m1=tin[1]; m1=tin[1];
@ -158,13 +158,13 @@ void des_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
tin[0]=tin0; tin[0]=tin0;
tin[1]=tin1; tin[1]=tin1;
des_encrypt(tin,ks1,0); des_encrypt1(tin,ks1,0);
tin[0]^=m0; tin[0]^=m0;
tin[1]^=m1; tin[1]^=m1;
des_encrypt(tin,ks2,1); des_encrypt1(tin,ks2,1);
tin[0]^=m0; tin[0]^=m0;
tin[1]^=m1; tin[1]^=m1;
des_encrypt(tin,ks1,0); des_encrypt1(tin,ks1,0);
tout0=tin[0]; tout0=tin[0];
tout1=tin[1]; tout1=tin[1];

View file

@ -89,7 +89,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
c2l(in,tin1); c2l(in,tin1);
tin0^=tout0; tin[0]=tin0; tin0^=tout0; tin[0]=tin0;
tin1^=tout1; tin[1]=tin1; tin1^=tout1; tin[1]=tin1;
des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
tout0=tin[0]; l2c(tout0,out); tout0=tin[0]; l2c(tout0,out);
tout1=tin[1]; l2c(tout1,out); tout1=tin[1]; l2c(tout1,out);
} }
@ -98,7 +98,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
c2ln(in,tin0,tin1,l+8); c2ln(in,tin0,tin1,l+8);
tin0^=tout0; tin[0]=tin0; tin0^=tout0; tin[0]=tin0;
tin1^=tout1; tin[1]=tin1; tin1^=tout1; tin[1]=tin1;
des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
tout0=tin[0]; l2c(tout0,out); tout0=tin[0]; l2c(tout0,out);
tout1=tin[1]; l2c(tout1,out); tout1=tin[1]; l2c(tout1,out);
} }
@ -116,7 +116,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
{ {
c2l(in,tin0); tin[0]=tin0; c2l(in,tin0); tin[0]=tin0;
c2l(in,tin1); tin[1]=tin1; c2l(in,tin1); tin[1]=tin1;
des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT);
tout0=tin[0]^xor0; tout0=tin[0]^xor0;
tout1=tin[1]^xor1; tout1=tin[1]^xor1;
l2c(tout0,out); l2c(tout0,out);
@ -128,7 +128,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
{ {
c2l(in,tin0); tin[0]=tin0; c2l(in,tin0); tin[0]=tin0;
c2l(in,tin1); tin[1]=tin1; c2l(in,tin1); tin[1]=tin1;
des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT);
tout0=tin[0]^xor0; tout0=tin[0]^xor0;
tout1=tin[1]^xor1; tout1=tin[1]^xor1;
l2cn(tout0,tout1,out,l+8); l2cn(tout0,tout1,out,l+8);

View file

@ -87,7 +87,7 @@ void des_ofb64_encrypt(register const unsigned char *in,
{ {
if (n == 0) if (n == 0)
{ {
des_encrypt(ti,schedule,DES_ENCRYPT); des_encrypt1(ti,schedule,DES_ENCRYPT);
dp=d; dp=d;
t=ti[0]; l2c(t,dp); t=ti[0]; l2c(t,dp);
t=ti[1]; l2c(t,dp); t=ti[1]; l2c(t,dp);

View file

@ -101,7 +101,7 @@ void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
{ {
ti[0]=v0; ti[0]=v0;
ti[1]=v1; ti[1]=v1;
des_encrypt((DES_LONG *)ti,schedule,DES_ENCRYPT); des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
vv0=ti[0]; vv0=ti[0];
vv1=ti[1]; vv1=ti[1];
c2ln(in,d0,d1,n); c2ln(in,d0,d1,n);

View file

@ -85,7 +85,7 @@ void des_pcbc_encrypt(const unsigned char *input, unsigned char *output,
c2ln(in,sin0,sin1,length); c2ln(in,sin0,sin1,length);
tin[0]=sin0^xor0; tin[0]=sin0^xor0;
tin[1]=sin1^xor1; tin[1]=sin1^xor1;
des_encrypt((DES_LONG *)tin,schedule,DES_ENCRYPT); des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
tout0=tin[0]; tout0=tin[0];
tout1=tin[1]; tout1=tin[1];
xor0=sin0^tout0; xor0=sin0^tout0;
@ -103,7 +103,7 @@ void des_pcbc_encrypt(const unsigned char *input, unsigned char *output,
c2l(in,sin1); c2l(in,sin1);
tin[0]=sin0; tin[0]=sin0;
tin[1]=sin1; tin[1]=sin1;
des_encrypt((DES_LONG *)tin,schedule,DES_DECRYPT); des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT);
tout0=tin[0]^xor0; tout0=tin[0]^xor0;
tout1=tin[1]^xor1; tout1=tin[1]^xor1;
if (length >= 8) if (length >= 8)

View file

@ -204,7 +204,7 @@ int main(int argc, char **argv)
count*=2; count*=2;
Time_F(START); Time_F(START);
for (i=count; i; i--) for (i=count; i; i--)
des_encrypt(data,&(sch[0]),DES_ENCRYPT); des_encrypt1(data,&(sch[0]),DES_ENCRYPT);
d=Time_F(STOP); d=Time_F(STOP);
} while (d < 3.0); } while (d < 3.0);
ca=count; ca=count;
@ -241,7 +241,7 @@ int main(int argc, char **argv)
{ {
DES_LONG data[2]; DES_LONG data[2];
des_encrypt(data,&(sch[0]),DES_ENCRYPT); des_encrypt1(data,&(sch[0]),DES_ENCRYPT);
} }
d=Time_F(STOP); d=Time_F(STOP);
printf("%ld des_encrypt's in %.2f second\n",count,d); printf("%ld des_encrypt's in %.2f second\n",count,d);

View file

@ -138,7 +138,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
c2l(in,tin1); c2l(in,tin1);
tin0^=tout0^inW0; tin[0]=tin0; tin0^=tout0^inW0; tin[0]=tin0;
tin1^=tout1^inW1; tin[1]=tin1; tin1^=tout1^inW1; tin[1]=tin1;
des_encrypt(tin,schedule,DES_ENCRYPT); des_encrypt1(tin,schedule,DES_ENCRYPT);
tout0=tin[0]^outW0; l2c(tout0,out); tout0=tin[0]^outW0; l2c(tout0,out);
tout1=tin[1]^outW1; l2c(tout1,out); tout1=tin[1]^outW1; l2c(tout1,out);
} }
@ -147,7 +147,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
c2ln(in,tin0,tin1,l+8); c2ln(in,tin0,tin1,l+8);
tin0^=tout0^inW0; tin[0]=tin0; tin0^=tout0^inW0; tin[0]=tin0;
tin1^=tout1^inW1; tin[1]=tin1; tin1^=tout1^inW1; tin[1]=tin1;
des_encrypt(tin,schedule,DES_ENCRYPT); des_encrypt1(tin,schedule,DES_ENCRYPT);
tout0=tin[0]^outW0; l2c(tout0,out); tout0=tin[0]^outW0; l2c(tout0,out);
tout1=tin[1]^outW1; l2c(tout1,out); tout1=tin[1]^outW1; l2c(tout1,out);
} }
@ -163,7 +163,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
{ {
c2l(in,tin0); tin[0]=tin0^outW0; c2l(in,tin0); tin[0]=tin0^outW0;
c2l(in,tin1); tin[1]=tin1^outW1; c2l(in,tin1); tin[1]=tin1^outW1;
des_encrypt(tin,schedule,DES_DECRYPT); des_encrypt1(tin,schedule,DES_DECRYPT);
tout0=tin[0]^xor0^inW0; tout0=tin[0]^xor0^inW0;
tout1=tin[1]^xor1^inW1; tout1=tin[1]^xor1^inW1;
l2c(tout0,out); l2c(tout0,out);
@ -175,7 +175,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out,
{ {
c2l(in,tin0); tin[0]=tin0^outW0; c2l(in,tin0); tin[0]=tin0^outW0;
c2l(in,tin1); tin[1]=tin1^outW1; c2l(in,tin1); tin[1]=tin1^outW1;
des_encrypt(tin,schedule,DES_DECRYPT); des_encrypt1(tin,schedule,DES_DECRYPT);
tout0=tin[0]^xor0^inW0; tout0=tin[0]^xor0^inW0;
tout1=tin[1]^xor1^inW1; tout1=tin[1]^xor1^inW1;
l2cn(tout0,tout1,out,l+8); l2cn(tout0,tout1,out,l+8);