Skip to content

Commit

Permalink
Due to an increasing number of clashes between modern OpenSSL and
Browse files Browse the repository at this point in the history
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 c2e4f17
Show file tree
Hide file tree
Showing 58 changed files with 1,490 additions and 911 deletions.
13 changes: 13 additions & 0 deletions CHANGES
Expand Up @@ -12,6 +12,19 @@
*) applies to 0.9.6a/0.9.6b/0.9.6c and 0.9.7 *) applies to 0.9.6a/0.9.6b/0.9.6c and 0.9.7
+) applies to 0.9.7 only +) 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() *) Fix SSL handshake functions and SSL_clear() such that SSL_clear()
never resets s->method to s->ctx->method when called from within never resets s->method to s->ctx->method when called from within
one of the SSL handshake functions. one of the SSL handshake functions.
Expand Down
83 changes: 42 additions & 41 deletions apps/Makefile.ssl
Expand Up @@ -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: ../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/bn.h ../include/openssl/buffer.h
passwd.o: ../include/openssl/conf.h ../include/openssl/crypto.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/des.h ../include/openssl/des_old.h
passwd.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h passwd.o: ../include/openssl/dh.h ../include/openssl/dsa.h
passwd.o: ../include/openssl/err.h ../include/openssl/evp.h passwd.o: ../include/openssl/e_os2.h ../include/openssl/err.h
passwd.o: ../include/openssl/lhash.h ../include/openssl/md5.h passwd.o: ../include/openssl/evp.h ../include/openssl/lhash.h
passwd.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h passwd.o: ../include/openssl/md5.h ../include/openssl/obj_mac.h
passwd.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h passwd.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h
passwd.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h passwd.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h
passwd.o: ../include/openssl/rand.h ../include/openssl/rsa.h passwd.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h
passwd.o: ../include/openssl/safestack.h ../include/openssl/sha.h passwd.o: ../include/openssl/rsa.h ../include/openssl/safestack.h
passwd.o: ../include/openssl/stack.h ../include/openssl/symhacks.h passwd.o: ../include/openssl/sha.h ../include/openssl/stack.h
passwd.o: ../include/openssl/txt_db.h ../include/openssl/x509.h passwd.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h
passwd.o: ../include/openssl/x509_vfy.h apps.h passwd.c 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: ../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/bn.h ../include/openssl/buffer.h
pkcs12.o: ../include/openssl/conf.h ../include/openssl/crypto.h pkcs12.o: ../include/openssl/conf.h ../include/openssl/crypto.h
Expand Down Expand Up @@ -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/blowfish.h ../include/openssl/bn.h
speed.o: ../include/openssl/buffer.h ../include/openssl/cast.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/conf.h ../include/openssl/crypto.h
speed.o: ../include/openssl/des.h ../include/openssl/dh.h speed.o: ../include/openssl/des.h ../include/openssl/des_old.h
speed.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h speed.o: ../include/openssl/dh.h ../include/openssl/dsa.h
speed.o: ../include/openssl/err.h ../include/openssl/evp.h speed.o: ../include/openssl/e_os2.h ../include/openssl/err.h
speed.o: ../include/openssl/hmac.h ../include/openssl/idea.h speed.o: ../include/openssl/evp.h ../include/openssl/hmac.h
speed.o: ../include/openssl/lhash.h ../include/openssl/md2.h speed.o: ../include/openssl/idea.h ../include/openssl/lhash.h
speed.o: ../include/openssl/md4.h ../include/openssl/md5.h speed.o: ../include/openssl/md2.h ../include/openssl/md4.h
speed.o: ../include/openssl/mdc2.h ../include/openssl/obj_mac.h speed.o: ../include/openssl/md5.h ../include/openssl/mdc2.h
speed.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h speed.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
speed.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h speed.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
speed.o: ../include/openssl/pkcs7.h ../include/openssl/rand.h speed.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h
speed.o: ../include/openssl/rc2.h ../include/openssl/rc4.h speed.o: ../include/openssl/rand.h ../include/openssl/rc2.h
speed.o: ../include/openssl/rc5.h ../include/openssl/ripemd.h speed.o: ../include/openssl/rc4.h ../include/openssl/rc5.h
speed.o: ../include/openssl/rsa.h ../include/openssl/safestack.h speed.o: ../include/openssl/ripemd.h ../include/openssl/rsa.h
speed.o: ../include/openssl/sha.h ../include/openssl/stack.h speed.o: ../include/openssl/safestack.h ../include/openssl/sha.h
speed.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h speed.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
speed.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h speed.c speed.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
speed.o: testdsa.h testrsa.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: ../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/bn.h ../include/openssl/buffer.h
spkac.o: ../include/openssl/conf.h ../include/openssl/crypto.h spkac.o: ../include/openssl/conf.h ../include/openssl/crypto.h
Expand Down Expand Up @@ -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/blowfish.h ../include/openssl/bn.h
version.o: ../include/openssl/buffer.h ../include/openssl/conf.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/crypto.h ../include/openssl/des.h
version.o: ../include/openssl/dh.h ../include/openssl/dsa.h version.o: ../include/openssl/des_old.h ../include/openssl/dh.h
version.o: ../include/openssl/e_os2.h ../include/openssl/evp.h version.o: ../include/openssl/dsa.h ../include/openssl/e_os2.h
version.o: ../include/openssl/idea.h ../include/openssl/lhash.h version.o: ../include/openssl/evp.h ../include/openssl/idea.h
version.o: ../include/openssl/md2.h ../include/openssl/obj_mac.h version.o: ../include/openssl/lhash.h ../include/openssl/md2.h
version.o: ../include/openssl/objects.h ../include/openssl/opensslconf.h version.o: ../include/openssl/obj_mac.h ../include/openssl/objects.h
version.o: ../include/openssl/opensslv.h ../include/openssl/ossl_typ.h version.o: ../include/openssl/opensslconf.h ../include/openssl/opensslv.h
version.o: ../include/openssl/pkcs7.h ../include/openssl/rc4.h version.o: ../include/openssl/ossl_typ.h ../include/openssl/pkcs7.h
version.o: ../include/openssl/rsa.h ../include/openssl/safestack.h version.o: ../include/openssl/rc4.h ../include/openssl/rsa.h
version.o: ../include/openssl/sha.h ../include/openssl/stack.h version.o: ../include/openssl/safestack.h ../include/openssl/sha.h
version.o: ../include/openssl/symhacks.h ../include/openssl/txt_db.h version.o: ../include/openssl/stack.h ../include/openssl/symhacks.h
version.o: ../include/openssl/x509.h ../include/openssl/x509_vfy.h apps.h version.o: ../include/openssl/txt_db.h ../include/openssl/x509.h
version.o: version.c 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: ../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/bn.h ../include/openssl/buffer.h
x509.o: ../include/openssl/conf.h ../include/openssl/crypto.h x509.o: ../include/openssl/conf.h ../include/openssl/crypto.h
Expand Down
2 changes: 1 addition & 1 deletion apps/passwd.c
Expand Up @@ -16,7 +16,7 @@
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#ifndef OPENSSL_NO_DES #ifndef OPENSSL_NO_DES
# include <openssl/des.h> # include <openssl/des_old.h>
#endif #endif
#ifndef NO_MD5CRYPT_1 #ifndef NO_MD5CRYPT_1
# include <openssl/evp.h> # include <openssl/evp.h>
Expand Down
18 changes: 10 additions & 8 deletions apps/speed.c
Expand Up @@ -129,7 +129,7 @@
#endif #endif


#ifndef OPENSSL_NO_DES #ifndef OPENSSL_NO_DES
#include <openssl/des.h> #include <openssl/des_old.h>
#endif #endif
#ifndef OPENSSL_NO_MD2 #ifndef OPENSSL_NO_MD2
#include <openssl/md2.h> #include <openssl/md2.h>
Expand Down Expand Up @@ -377,11 +377,13 @@ int MAIN(int argc, char **argv)
0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12}; 0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
unsigned char iv[8]; unsigned char iv[8];
#ifndef OPENSSL_NO_DES #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 key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12}; static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34}; 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 #endif
#define D_MD2 0 #define D_MD2 0
#define D_MDC2 1 #define D_MDC2 1
Expand Down Expand Up @@ -804,9 +806,9 @@ int MAIN(int argc, char **argv)
#endif #endif


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


Expand Down
2 changes: 1 addition & 1 deletion crypto/crypto-lib.com
Expand Up @@ -187,7 +187,7 @@ $ LIB_DES = "set_key,ecb_enc,cbc_enc,"+ -
"enc_read,enc_writ,ofb64enc,"+ - "enc_read,enc_writ,ofb64enc,"+ -
"ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ - "ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ -
"des_enc,fcrypt_b,"+ - "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_RC2 = "rc2_ecb,rc2_skey,rc2_cbc,rc2cfb64,rc2ofb64"
$ LIB_RC4 = "rc4_skey,rc4_enc" $ LIB_RC4 = "rc4_skey,rc4_enc"
$ LIB_RC5 = "rc5_skey,rc5_ecb,rc5_enc,rc5cfb64,rc5ofb64" $ LIB_RC5 = "rc5_skey,rc5_ecb,rc5_enc,rc5cfb64,rc5ofb64"
Expand Down
6 changes: 3 additions & 3 deletions crypto/des/Makefile.ssl
Expand Up @@ -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 \ qud_cksm.c rand_key.c rpc_enc.c set_key.c \
des_enc.c fcrypt_b.c \ des_enc.c fcrypt_b.c \
xcbc_enc.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 \ LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \ ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
enc_read.o enc_writ.o ofb64enc.o \ enc_read.o enc_writ.o ofb64enc.o \
ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \ ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
${DES_ENC} \ ${DES_ENC} \
fcrypt.o xcbc_enc.o rpc_enc.o cbc_cksm.o \ fcrypt.o xcbc_enc.o rpc_enc.o cbc_cksm.o \
ede_cbcm_enc.o ede_cbcm_enc.o des_old.o


SRC= $(LIBSRC) SRC= $(LIBSRC)


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


ALL= $(GENERAL) $(SRC) $(HEADER) ALL= $(GENERAL) $(SRC) $(HEADER)
Expand Down
14 changes: 7 additions & 7 deletions crypto/des/asm/des-586.pl
Expand Up @@ -20,16 +20,16 @@
$R="esi"; $R="esi";


&external_label("des_SPtrans"); &external_label("des_SPtrans");
&des_encrypt("des_encrypt1",1); &DES_encrypt("DES_encrypt1",1);
&des_encrypt("des_encrypt2",0); &DES_encrypt("DES_encrypt2",0);
&des_encrypt3("des_encrypt3",1); &DES_encrypt3("DES_encrypt3",1);
&des_encrypt3("des_decrypt3",0); &DES_encrypt3("DES_decrypt3",0);
&cbc("des_ncbc_encrypt","des_encrypt1","des_encrypt1",0,4,5,3,5,-1); &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); &cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5);


&asm_finish(); &asm_finish();


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


Expand Down
10 changes: 5 additions & 5 deletions crypto/des/asm/des686.pl
Expand Up @@ -46,15 +46,15 @@
$L="edi"; $L="edi";
$R="esi"; $R="esi";


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


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


&file_end(); &file_end();


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


Expand Down
8 changes: 4 additions & 4 deletions crypto/des/asm/desboth.pl
Expand Up @@ -3,7 +3,7 @@
$L="edi"; $L="edi";
$R="esi"; $R="esi";


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


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


&stack_pop(3); &stack_pop(3);
&mov($L,&DWP(0,"ebx","",0)); &mov($L,&DWP(0,"ebx","",0));
Expand Down
40 changes: 20 additions & 20 deletions crypto/des/cbc3_enc.c
Expand Up @@ -59,41 +59,41 @@
#include "des_locl.h" #include "des_locl.h"


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


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


8 changes: 4 additions & 4 deletions crypto/des/cbc_cksm.c
Expand Up @@ -58,9 +58,9 @@


#include "des_locl.h" #include "des_locl.h"


DES_LONG des_cbc_cksum(const unsigned char *in, des_cblock *output, DES_LONG DES_cbc_cksum(const unsigned char *in, DES_cblock *output,
long length, des_key_schedule *schedule, long length, DES_key_schedule *schedule,
const_des_cblock *ivec) const_DES_cblock *ivec)
{ {
register DES_LONG tout0,tout1,tin0,tin1; register DES_LONG tout0,tout1,tin0,tin1;
register long l=length; register long l=length;
Expand All @@ -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_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 */ /* fix 15/10/91 eay - thanks to keithr@sco.COM */
tout0=tin[0]; tout0=tin[0];
tout1=tin[1]; tout1=tin[1];
Expand Down

0 comments on commit c2e4f17

Please sign in to comment.