Permalink
Browse files

Due to an increasing number of clashes between modern OpenSSL and

libdes (which is still used out there) or other des implementations,
the OpenSSL DES functions are renamed to begin with DES_ instead of
des_.  Compatibility routines are provided and declared by including
openssl/des_old.h.  Those declarations are the same as were in des.h
when the OpenSSL project started, which is exactly how libdes looked
at that time, and hopefully still looks today.

The compatibility functions will be removed in some future release, at
the latest in version 1.0.
  • Loading branch information...
levitte committed Oct 24, 2001
1 parent 979689a commit c2e4f17c1a0d4d5115c6ede9492de1615fe392ac
Showing with 1,490 additions and 911 deletions.
  1. +13 −0 CHANGES
  2. +42 −41 apps/Makefile.ssl
  3. +1 −1 apps/passwd.c
  4. +10 −8 apps/speed.c
  5. +1 −1 apps/version.c
  6. +1 −1 crypto/crypto-lib.com
  7. +3 −3 crypto/des/Makefile.ssl
  8. +7 −7 crypto/des/asm/des-586.pl
  9. +5 −5 crypto/des/asm/des686.pl
  10. +4 −4 crypto/des/asm/desboth.pl
  11. +20 −20 crypto/des/cbc3_enc.c
  12. +4 −4 crypto/des/cbc_cksm.c
  13. +9 −9 crypto/des/cfb64ede.c
  14. +5 −5 crypto/des/cfb64enc.c
  15. +4 −4 crypto/des/cfb_enc.c
  16. +34 −34 crypto/des/des.c
  17. +107 −145 crypto/des/des.h
  18. +21 −21 crypto/des/des_enc.c
  19. +1 −1 crypto/des/des_locl.h
  20. +245 −0 crypto/des/des_old.c
  21. +236 −0 crypto/des/des_old.h
  22. +102 −102 crypto/des/des_opts.c
  23. +72 −72 crypto/des/destest.c
  24. +5 −5 crypto/des/ecb3_enc.c
  25. +4 −4 crypto/des/ecb_enc.c
  26. +11 −11 crypto/des/ede_cbcm_enc.c
  27. +14 −14 crypto/des/enc_read.c
  28. +8 −8 crypto/des/enc_writ.c
  29. +9 −16 crypto/des/fcrypt.c
  30. +1 −1 crypto/des/fcrypt_b.c
  31. +10 −10 crypto/des/ncbc_enc.c
  32. +9 −9 crypto/des/ofb64ede.c
  33. +4 −4 crypto/des/ofb64enc.c
  34. +4 −4 crypto/des/ofb_enc.c
  35. +5 −5 crypto/des/pcbc_enc.c
  36. +2 −2 crypto/des/qud_cksm.c
  37. +6 −6 crypto/des/rand_key.c
  38. +15 −2 crypto/des/read2pwd.c
  39. +5 −5 crypto/des/rpc_enc.c
  40. +1 −1 crypto/des/rpw.c
  41. +17 −17 crypto/des/set_key.c
  42. +24 −24 crypto/des/speed.c
  43. +16 −16 crypto/des/str2key.c
  44. +10 −10 crypto/des/xcbc_enc.c
  45. +9 −9 crypto/evp/e_des.c
  46. +17 −17 crypto/evp/e_des3.c
  47. +7 −7 crypto/evp/e_xcbc_d.c
  48. +1 −1 crypto/install.com
  49. +1 −1 crypto/mdc2/mdc2.h
  50. +7 −7 crypto/mdc2/mdc2dgst.c
  51. +39 −0 crypto/symhacks.h
  52. +4 −4 crypto/ui/ui_compat.c
  53. +2 −2 crypto/ui/ui_compat.h
  54. +150 −147 doc/crypto/des.pod
  55. +1 −1 makevms.com
  56. +3 −2 test/Makefile.ssl
  57. +121 −50 util/libeay.num
  58. +1 −1 util/mkdef.pl
13 CHANGES
@@ -12,6 +12,19 @@
*) applies to 0.9.6a/0.9.6b/0.9.6c and 0.9.7
+) applies to 0.9.7 only

+) Change all functions with names starting with des_ to be starting
with DES_ instead. This because there are increasing clashes with
libdes and other des libraries that are currently used by other
projects. The old libdes interface is provided, as well as crypt(),
if openssl/des_old.h is included. Note that crypt() is no longer
declared in openssl/des.h.

NOTE: This is a major break of an old API into a new one. Software
authors are encouraged to switch to the DES_ style functions. Some
time in the future, des_old.h and the libdes compatibility functions
will be completely removed.
[Richard Levitte]

*) Fix SSL handshake functions and SSL_clear() such that SSL_clear()
never resets s->method to s->ctx->method when called from within
one of the SSL handshake functions.
@@ -468,18 +468,19 @@ openssl.o: openssl.c progs.h s_apps.h
passwd.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
passwd.o: ../include/openssl/bn.h ../include/openssl/buffer.h
passwd.o: ../include/openssl/conf.h ../include/openssl/crypto.h
passwd.o: ../include/openssl/des.h ../include/openssl/dh.h
passwd.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
passwd.o: ../include/openssl/err.h ../include/openssl/evp.h
passwd.o: ../include/openssl/lhash.h ../include/openssl/md5.h
passwd.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
passwd.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
passwd.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h
passwd.o: ../include/openssl/rand.h ../include/openssl/rsa.h
passwd.o: ../include/openssl/safestack.h ../include/openssl/sha.h
passwd.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
passwd.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
passwd.o: ../include/openssl/x509_vfy.h apps.h passwd.c
passwd.o: ../include/openssl/des.h ../include/openssl/des_old.h
passwd.o: ../include/openssl/dh.h ../include/openssl/dsa.h
passwd.o: ../include/openssl/e_os2.h ../include/openssl/err.h
passwd.o: ../include/openssl/evp.h ../include/openssl/lhash.h
passwd.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h
passwd.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
passwd.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
passwd.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
passwd.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
passwd.o: ../include/openssl/sha.h ../include/openssl/stack.h
passwd.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
passwd.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
passwd.o: passwd.c
pkcs12.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
pkcs12.o: ../include/openssl/bn.h ../include/openssl/buffer.h
pkcs12.o: ../include/openssl/conf.h ../include/openssl/crypto.h
@@ -710,23 +711,23 @@ speed.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
speed.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
speed.o: ../include/openssl/buffer.h ../include/openssl/cast.h
speed.o: ../include/openssl/conf.h ../include/openssl/crypto.h
speed.o: ../include/openssl/des.h ../include/openssl/dh.h
speed.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
speed.o: ../include/openssl/err.h ../include/openssl/evp.h
speed.o: ../include/openssl/hmac.h ../include/openssl/idea.h
speed.o: ../include/openssl/lhash.h ../include/openssl/md2.h
speed.o: ../include/openssl/md4.h ../include/openssl/md5.h
speed.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h
speed.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
speed.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
speed.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
speed.o: ../include/openssl/rc2.h ../include/openssl/rc4.h
speed.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h
speed.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
speed.o: ../include/openssl/sha.h ../include/openssl/stack.h
speed.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
speed.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h speed.c
speed.o: testdsa.h testrsa.h
speed.o: ../include/openssl/des.h ../include/openssl/des_old.h
speed.o: ../include/openssl/dh.h ../include/openssl/dsa.h
speed.o: ../include/openssl/e_os2.h ../include/openssl/err.h
speed.o: ../include/openssl/evp.h ../include/openssl/hmac.h
speed.o: ../include/openssl/idea.h ../include/openssl/lhash.h
speed.o: ../include/openssl/md2.h ../include/openssl/md4.h
speed.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
speed.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
speed.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
speed.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h
speed.o: ../include/openssl/rand.h ../include/openssl/rc2.h
speed.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
speed.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
speed.o: ../include/openssl/safestack.h ../include/openssl/sha.h
speed.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
speed.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
speed.o: ../include/openssl/x509_vfy.h apps.h speed.c testdsa.h testrsa.h
spkac.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
spkac.o: ../include/openssl/bn.h ../include/openssl/buffer.h
spkac.o: ../include/openssl/conf.h ../include/openssl/crypto.h
@@ -760,18 +761,18 @@ version.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
version.o: ../include/openssl/blowfish.h ../include/openssl/bn.h
version.o: ../include/openssl/buffer.h ../include/openssl/conf.h
version.o: ../include/openssl/crypto.h ../include/openssl/des.h
version.o: ../include/openssl/dh.h ../include/openssl/dsa.h
version.o: ../include/openssl/e_os2.h ../include/openssl/evp.h
version.o: ../include/openssl/idea.h ../include/openssl/lhash.h
version.o: ../include/openssl/md2.h ../include/openssl/obj_mac.h
version.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
version.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
version.o: ../include/openssl/pkcs7.h ../include/openssl/rc4.h
version.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
version.o: ../include/openssl/sha.h ../include/openssl/stack.h
version.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
version.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h
version.o: version.c
version.o: ../include/openssl/des_old.h ../include/openssl/dh.h
version.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
version.o: ../include/openssl/evp.h ../include/openssl/idea.h
version.o: ../include/openssl/lhash.h ../include/openssl/md2.h
version.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
version.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
version.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h
version.o: ../include/openssl/rc4.h ../include/openssl/rsa.h
version.o: ../include/openssl/safestack.h ../include/openssl/sha.h
version.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
version.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
version.o: ../include/openssl/x509_vfy.h apps.h version.c
x509.o: ../e_os.h ../include/openssl/asn1.h ../include/openssl/bio.h
x509.o: ../include/openssl/bn.h ../include/openssl/buffer.h
x509.o: ../include/openssl/conf.h ../include/openssl/crypto.h
@@ -16,7 +16,7 @@
#include <openssl/evp.h>
#include <openssl/rand.h>
#ifndef OPENSSL_NO_DES
# include <openssl/des.h>
# include <openssl/des_old.h>
#endif
#ifndef NO_MD5CRYPT_1
# include <openssl/evp.h>
@@ -129,7 +129,7 @@
#endif

#ifndef OPENSSL_NO_DES
#include <openssl/des.h>
#include <openssl/des_old.h>
#endif
#ifndef OPENSSL_NO_MD2
#include <openssl/md2.h>
@@ -377,11 +377,13 @@ int MAIN(int argc, char **argv)
0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
unsigned char iv[8];
#ifndef OPENSSL_NO_DES
des_cblock *buf_as_des_cblock = NULL;
DES_cblock *buf_as_des_cblock = NULL;
static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
des_key_schedule sch,sch2,sch3;
DES_key_schedule sch;
DES_key_schedule sch2;
DES_key_schedule sch3;
#endif
#define D_MD2 0
#define D_MDC2 1
@@ -804,9 +806,9 @@ int MAIN(int argc, char **argv)
#endif

#ifndef OPENSSL_NO_DES
des_set_key_unchecked(&key,&sch);
des_set_key_unchecked(&key2,&sch2);
des_set_key_unchecked(&key3,&sch3);
DES_set_key_unchecked(&key,&sch);
DES_set_key_unchecked(&key2,&sch2);
DES_set_key_unchecked(&key3,&sch3);
#endif
#ifndef OPENSSL_NO_IDEA
idea_set_encrypt_key(key16,&idea_ks);
@@ -1088,7 +1090,7 @@ int MAIN(int argc, char **argv)
print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
Time_F(START,usertime);
for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
des_ncbc_encrypt(buf,buf,lengths[j],&sch,
DES_ncbc_encrypt(buf,buf,lengths[j],&sch,
&iv,DES_ENCRYPT);
d=Time_F(STOP,usertime);
BIO_printf(bio_err,"%ld %s's in %.2fs\n",
@@ -1104,7 +1106,7 @@ int MAIN(int argc, char **argv)
print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
Time_F(START,usertime);
for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
des_ede3_cbc_encrypt(buf,buf,lengths[j],
DES_ede3_cbc_encrypt(buf,buf,lengths[j],
&sch,&sch2,&sch3,
&iv,DES_ENCRYPT);
d=Time_F(STOP,usertime);
@@ -117,7 +117,7 @@
#include <openssl/crypto.h>
#include <openssl/md2.h>
#include <openssl/rc4.h>
#include <openssl/des.h>
#include <openssl/des_old.h>
#include <openssl/idea.h>
#include <openssl/blowfish.h>

@@ -187,7 +187,7 @@ $ LIB_DES = "set_key,ecb_enc,cbc_enc,"+ -
"enc_read,enc_writ,ofb64enc,"+ -
"ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ -
"des_enc,fcrypt_b,"+ -
"fcrypt,xcbc_enc,rpc_enc,cbc_cksm,ede_cbcm_enc"
"fcrypt,xcbc_enc,rpc_enc,cbc_cksm,ede_cbcm_enc,des_old"
$ LIB_RC2 = "rc2_ecb,rc2_skey,rc2_cbc,rc2cfb64,rc2ofb64"
$ LIB_RC4 = "rc4_skey,rc4_enc"
$ LIB_RC5 = "rc5_skey,rc5_ecb,rc5_enc,rc5cfb64,rc5ofb64"
@@ -34,19 +34,19 @@ LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
qud_cksm.c rand_key.c rpc_enc.c set_key.c \
des_enc.c fcrypt_b.c \
xcbc_enc.c \
str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c
str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c des_old.o

LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
enc_read.o enc_writ.o ofb64enc.o \
ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
${DES_ENC} \
fcrypt.o xcbc_enc.o rpc_enc.o cbc_cksm.o \
ede_cbcm_enc.o
ede_cbcm_enc.o des_old.o

SRC= $(LIBSRC)

EXHEADER= des.h
EXHEADER= des.h des_old.h
HEADER= des_locl.h rpc_des.h spr.h des_ver.h $(EXHEADER)

ALL= $(GENERAL) $(SRC) $(HEADER)
@@ -20,16 +20,16 @@
$R="esi";

&external_label("des_SPtrans");
&des_encrypt("des_encrypt1",1);
&des_encrypt("des_encrypt2",0);
&des_encrypt3("des_encrypt3",1);
&des_encrypt3("des_decrypt3",0);
&cbc("des_ncbc_encrypt","des_encrypt1","des_encrypt1",0,4,5,3,5,-1);
&cbc("des_ede3_cbc_encrypt","des_encrypt3","des_decrypt3",0,6,7,3,4,5);
&DES_encrypt("DES_encrypt1",1);
&DES_encrypt("DES_encrypt2",0);
&DES_encrypt3("DES_encrypt3",1);
&DES_encrypt3("DES_decrypt3",0);
&cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1);
&cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5);

&asm_finish();

sub des_encrypt
sub DES_encrypt
{
local($name,$do_ip)=@_;

@@ -46,15 +46,15 @@
$L="edi";
$R="esi";

&des_encrypt("des_encrypt1",1);
&des_encrypt("des_encrypt2",0);
&DES_encrypt("DES_encrypt1",1);
&DES_encrypt("DES_encrypt2",0);

&des_encrypt3("des_encrypt3",1);
&des_encrypt3("des_decrypt3",0);
&DES_encrypt3("DES_encrypt3",1);
&DES_encrypt3("DES_decrypt3",0);

&file_end();

sub des_encrypt
sub DES_encrypt
{
local($name,$do_ip)=@_;

@@ -3,7 +3,7 @@
$L="edi";
$R="esi";

sub des_encrypt3
sub DES_encrypt3
{
local($name,$enc)=@_;

@@ -47,15 +47,15 @@ sub des_encrypt3
&mov(&swtmp(2), (DWC(($enc)?"1":"0")));
&mov(&swtmp(1), "eax");
&mov(&swtmp(0), "ebx");
&call("des_encrypt2");
&call("DES_encrypt2");
&mov(&swtmp(2), (DWC(($enc)?"0":"1")));
&mov(&swtmp(1), "edi");
&mov(&swtmp(0), "ebx");
&call("des_encrypt2");
&call("DES_encrypt2");
&mov(&swtmp(2), (DWC(($enc)?"1":"0")));
&mov(&swtmp(1), "esi");
&mov(&swtmp(0), "ebx");
&call("des_encrypt2");
&call("DES_encrypt2");

&stack_pop(3);
&mov($L,&DWP(0,"ebx","",0));
@@ -59,41 +59,41 @@
#include "des_locl.h"

/* HAS BUGS! DON'T USE - this is only present for use in des.c */
void des_3cbc_encrypt(des_cblock *input, des_cblock *output, long length,
des_key_schedule ks1, des_key_schedule ks2, des_cblock *iv1,
des_cblock *iv2, int enc)
void DES_3cbc_encrypt(DES_cblock *input, DES_cblock *output, long length,
DES_key_schedule ks1, DES_key_schedule ks2, DES_cblock *iv1,
DES_cblock *iv2, int enc)
{
int off=((int)length-1)/8;
long l8=((length+7)/8)*8;
des_cblock niv1,niv2;
DES_cblock niv1,niv2;

if (enc == DES_ENCRYPT)
{
des_cbc_encrypt((unsigned char*)input,
DES_cbc_encrypt((unsigned char*)input,
(unsigned char*)output,length,&ks1,iv1,enc);
if (length >= sizeof(des_cblock))
memcpy(niv1,output[off],sizeof(des_cblock));
des_cbc_encrypt((unsigned char*)output,
if (length >= sizeof(DES_cblock))
memcpy(niv1,output[off],sizeof(DES_cblock));
DES_cbc_encrypt((unsigned char*)output,
(unsigned char*)output,l8,&ks2,iv1,!enc);
des_cbc_encrypt((unsigned char*)output,
DES_cbc_encrypt((unsigned char*)output,
(unsigned char*)output,l8,&ks1,iv2,enc);
if (length >= sizeof(des_cblock))
memcpy(niv2,output[off],sizeof(des_cblock));
if (length >= sizeof(DES_cblock))
memcpy(niv2,output[off],sizeof(DES_cblock));
}
else
{
if (length >= sizeof(des_cblock))
memcpy(niv2,input[off],sizeof(des_cblock));
des_cbc_encrypt((unsigned char*)input,
if (length >= sizeof(DES_cblock))
memcpy(niv2,input[off],sizeof(DES_cblock));
DES_cbc_encrypt((unsigned char*)input,
(unsigned char*)output,l8,&ks1,iv2,enc);
des_cbc_encrypt((unsigned char*)output,
DES_cbc_encrypt((unsigned char*)output,
(unsigned char*)output,l8,&ks2,iv1,!enc);
if (length >= sizeof(des_cblock))
memcpy(niv1,output[off],sizeof(des_cblock));
des_cbc_encrypt((unsigned char*)output,
if (length >= sizeof(DES_cblock))
memcpy(niv1,output[off],sizeof(DES_cblock));
DES_cbc_encrypt((unsigned char*)output,
(unsigned char*)output,length,&ks1,iv1,enc);
}
memcpy(*iv1,niv1,sizeof(des_cblock));
memcpy(*iv2,niv2,sizeof(des_cblock));
memcpy(*iv1,niv1,sizeof(DES_cblock));
memcpy(*iv2,niv2,sizeof(DES_cblock));
}

@@ -58,9 +58,9 @@

#include "des_locl.h"

DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock *output,
long length, des_key_schedule *schedule,
const_des_cblock *ivec)
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;
@@ -82,7 +82,7 @@ DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock *output,

tin0^=tout0; tin[0]=tin0;
tin1^=tout1; tin[1]=tin1;
des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
DES_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
/* fix 15/10/91 eay - thanks to keithr@sco.COM */
tout0=tin[0];
tout1=tin[1];
Oops, something went wrong.

0 comments on commit c2e4f17

Please sign in to comment.