From c2e4f17c1a0d4d5115c6ede9492de1615fe392ac Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Wed, 24 Oct 2001 21:21:12 +0000 Subject: [PATCH] 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. --- CHANGES | 13 ++ apps/Makefile.ssl | 83 +++++------ apps/passwd.c | 2 +- apps/speed.c | 18 ++- apps/version.c | 2 +- crypto/crypto-lib.com | 2 +- crypto/des/Makefile.ssl | 6 +- crypto/des/asm/des-586.pl | 14 +- crypto/des/asm/des686.pl | 10 +- crypto/des/asm/desboth.pl | 8 +- crypto/des/cbc3_enc.c | 40 ++--- crypto/des/cbc_cksm.c | 8 +- crypto/des/cfb64ede.c | 18 +-- crypto/des/cfb64enc.c | 10 +- crypto/des/cfb_enc.c | 8 +- crypto/des/des.c | 68 ++++----- crypto/des/des.h | 252 ++++++++++++++------------------ crypto/des/des_enc.c | 42 +++--- crypto/des/des_locl.h | 2 +- crypto/des/des_old.c | 245 +++++++++++++++++++++++++++++++ crypto/des/des_old.h | 236 ++++++++++++++++++++++++++++++ crypto/des/des_opts.c | 204 +++++++++++++------------- crypto/des/destest.c | 144 +++++++++--------- crypto/des/ecb3_enc.c | 10 +- crypto/des/ecb_enc.c | 8 +- crypto/des/ede_cbcm_enc.c | 22 +-- crypto/des/enc_read.c | 28 ++-- crypto/des/enc_writ.c | 16 +- crypto/des/fcrypt.c | 25 ++-- crypto/des/fcrypt_b.c | 2 +- crypto/des/ncbc_enc.c | 20 +-- crypto/des/ofb64ede.c | 18 +-- crypto/des/ofb64enc.c | 8 +- crypto/des/ofb_enc.c | 8 +- crypto/des/pcbc_enc.c | 10 +- crypto/des/qud_cksm.c | 4 +- crypto/des/rand_key.c | 12 +- crypto/des/read2pwd.c | 17 ++- crypto/des/rpc_enc.c | 10 +- crypto/des/rpw.c | 2 +- crypto/des/set_key.c | 34 ++--- crypto/des/speed.c | 48 +++--- crypto/des/str2key.c | 32 ++-- crypto/des/xcbc_enc.c | 20 +-- crypto/evp/e_des.c | 18 +-- crypto/evp/e_des3.c | 34 ++--- crypto/evp/e_xcbc_d.c | 14 +- crypto/install.com | 2 +- crypto/mdc2/mdc2.h | 2 +- crypto/mdc2/mdc2dgst.c | 14 +- crypto/symhacks.h | 39 +++++ crypto/ui/ui_compat.c | 8 +- crypto/ui/ui_compat.h | 4 +- doc/crypto/des.pod | 297 +++++++++++++++++++------------------- makevms.com | 2 +- test/Makefile.ssl | 5 +- util/libeay.num | 171 +++++++++++++++------- util/mkdef.pl | 2 +- 58 files changed, 1490 insertions(+), 911 deletions(-) create mode 100644 crypto/des/des_old.c create mode 100644 crypto/des/des_old.h diff --git a/CHANGES b/CHANGES index 4ff8e00b44..755efead7d 100644 --- a/CHANGES +++ b/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. diff --git a/apps/Makefile.ssl b/apps/Makefile.ssl index 42d8ea85f9..4476a73ca8 100644 --- a/apps/Makefile.ssl +++ b/apps/Makefile.ssl @@ -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 diff --git a/apps/passwd.c b/apps/passwd.c index bb395c35a1..d3fa228bdb 100644 --- a/apps/passwd.c +++ b/apps/passwd.c @@ -16,7 +16,7 @@ #include #include #ifndef OPENSSL_NO_DES -# include +# include #endif #ifndef NO_MD5CRYPT_1 # include diff --git a/apps/speed.c b/apps/speed.c index 363ec65b0c..b5e4e0e90a 100644 --- a/apps/speed.c +++ b/apps/speed.c @@ -129,7 +129,7 @@ #endif #ifndef OPENSSL_NO_DES -#include +#include #endif #ifndef OPENSSL_NO_MD2 #include @@ -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); diff --git a/apps/version.c b/apps/version.c index 8956b7da9b..656b96278b 100644 --- a/apps/version.c +++ b/apps/version.c @@ -117,7 +117,7 @@ #include #include #include -#include +#include #include #include diff --git a/crypto/crypto-lib.com b/crypto/crypto-lib.com index 9428055708..b4d80f77fd 100644 --- a/crypto/crypto-lib.com +++ b/crypto/crypto-lib.com @@ -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" diff --git a/crypto/des/Makefile.ssl b/crypto/des/Makefile.ssl index 68fd3c4cbc..60d4d1b45b 100644 --- a/crypto/des/Makefile.ssl +++ b/crypto/des/Makefile.ssl @@ -34,7 +34,7 @@ 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 \ @@ -42,11 +42,11 @@ LIBOBJ= set_key.o ecb_enc.o cbc_enc.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) diff --git a/crypto/des/asm/des-586.pl b/crypto/des/asm/des-586.pl index c890766bc9..28b877a167 100644 --- a/crypto/des/asm/des-586.pl +++ b/crypto/des/asm/des-586.pl @@ -20,16 +20,16 @@ $L="edi"; $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)=@_; diff --git a/crypto/des/asm/des686.pl b/crypto/des/asm/des686.pl index 84c3e85438..f6dbab3315 100644 --- a/crypto/des/asm/des686.pl +++ b/crypto/des/asm/des686.pl @@ -46,15 +46,15 @@ EOF $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)=@_; diff --git a/crypto/des/asm/desboth.pl b/crypto/des/asm/desboth.pl index d5106414db..eec00886e4 100644 --- a/crypto/des/asm/desboth.pl +++ b/crypto/des/asm/desboth.pl @@ -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)); diff --git a/crypto/des/cbc3_enc.c b/crypto/des/cbc3_enc.c index c7cc7c1706..b5db4e14f7 100644 --- a/crypto/des/cbc3_enc.c +++ b/crypto/des/cbc3_enc.c @@ -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)); } diff --git a/crypto/des/cbc_cksm.c b/crypto/des/cbc_cksm.c index 69efc56b16..6c5305b99d 100644 --- a/crypto/des/cbc_cksm.c +++ b/crypto/des/cbc_cksm.c @@ -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]; diff --git a/crypto/des/cfb64ede.c b/crypto/des/cfb64ede.c index f9d13ef90a..60c1aa08db 100644 --- a/crypto/des/cfb64ede.c +++ b/crypto/des/cfb64ede.c @@ -63,10 +63,10 @@ * 64bit block we have used is contained in *num; */ -void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, des_key_schedule *ks1, - des_key_schedule *ks2, des_key_schedule *ks3, - des_cblock *ivec, int *num, int enc) +void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3, + DES_cblock *ivec, int *num, int enc) { register DES_LONG v0,v1; register long l=length; @@ -86,7 +86,7 @@ void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, ti[0]=v0; ti[1]=v1; - des_encrypt3(ti,ks1,ks2,ks3); + DES_encrypt3(ti,ks1,ks2,ks3); v0=ti[0]; v1=ti[1]; @@ -112,7 +112,7 @@ void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, ti[0]=v0; ti[1]=v1; - des_encrypt3(ti,ks1,ks2,ks3); + DES_encrypt3(ti,ks1,ks2,ks3); v0=ti[0]; v1=ti[1]; @@ -133,10 +133,10 @@ void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, } #ifdef undef /* MACRO */ -void des_ede2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, - des_key_schedule ks1, des_key_schedule ks2, des_cblock (*ivec), +void DES_ede2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + DES_key_schedule ks1, DES_key_schedule ks2, DES_cblock (*ivec), int *num, int enc) { - des_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,enc); + DES_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,enc); } #endif diff --git a/crypto/des/cfb64enc.c b/crypto/des/cfb64enc.c index 6061fb2e11..5ec8683e40 100644 --- a/crypto/des/cfb64enc.c +++ b/crypto/des/cfb64enc.c @@ -63,9 +63,9 @@ * 64bit block we have used is contained in *num; */ -void des_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, des_key_schedule *schedule, - des_cblock *ivec, int *num, int enc) +void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *schedule, + DES_cblock *ivec, int *num, int enc) { register DES_LONG v0,v1; register long l=length; @@ -82,7 +82,7 @@ void des_cfb64_encrypt(const unsigned char *in, unsigned char *out, { c2l(iv,v0); ti[0]=v0; c2l(iv,v1); ti[1]=v1; - des_encrypt1(ti,schedule,DES_ENCRYPT); + DES_encrypt1(ti,schedule,DES_ENCRYPT); iv = &(*ivec)[0]; v0=ti[0]; 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,v1); ti[1]=v1; - des_encrypt1(ti,schedule,DES_ENCRYPT); + DES_encrypt1(ti,schedule,DES_ENCRYPT); iv = &(*ivec)[0]; v0=ti[0]; l2c(v0,iv); v0=ti[1]; l2c(v0,iv); diff --git a/crypto/des/cfb_enc.c b/crypto/des/cfb_enc.c index 4af6f7fbf8..17bf77ca9e 100644 --- a/crypto/des/cfb_enc.c +++ b/crypto/des/cfb_enc.c @@ -64,8 +64,8 @@ * the second. The second 12 bits will come from the 3rd and half the 4th * byte. */ -void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, - long length, des_key_schedule *schedule, des_cblock *ivec, int enc) +void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, + long length, DES_key_schedule *schedule, DES_cblock *ivec, int enc) { register DES_LONG d0,d1,v0,v1,n=(numbits+7)/8; register DES_LONG mask0,mask1; @@ -100,7 +100,7 @@ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, l-=n; ti[0]=v0; ti[1]=v1; - des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); + DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); c2ln(in,d0,d1,n); in+=n; d0=(d0^ti[0])&mask0; @@ -132,7 +132,7 @@ void des_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, l-=n; ti[0]=v0; ti[1]=v1; - des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); + DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); c2ln(in,d0,d1,n); in+=n; /* 30-08-94 - eay - changed because l>>32 and diff --git a/crypto/des/des.c b/crypto/des/des.c index 16e5ab9eb2..a03ce161af 100644 --- a/crypto/des/des.c +++ b/crypto/des/des.c @@ -97,9 +97,9 @@ void uufwriteEnd(FILE *fp); int uufread(unsigned char *out,int size,unsigned int num,FILE *fp); int uuencode(unsigned char *in,int num,unsigned char *out); int uudecode(unsigned char *in,int num,unsigned char *out); -void des_3cbc_encrypt(des_cblock *input,des_cblock *output,long length, - des_key_schedule sk1,des_key_schedule sk2, - des_cblock *ivec1,des_cblock *ivec2,int enc); +void DES_3cbc_encrypt(DES_cblock *input,DES_cblock *output,long length, + DES_key_schedule sk1,DES_key_schedule sk2, + DES_cblock *ivec1,DES_cblock *ivec2,int enc); #ifdef OPENSSL_SYS_VMS #define EXIT(a) exit(a&0x10000000L) #else @@ -120,7 +120,7 @@ int uubufnum=0; #define OUTUUBUF (65*100) unsigned char b[OUTUUBUF]; unsigned char bb[300]; -des_cblock cksum={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; +DES_cblock cksum={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; char cksumname[200]=""; int vflag,cflag,eflag,dflag,kflag,bflag,fflag,sflag,uflag,flag3,hflag,error; @@ -361,11 +361,11 @@ void doencryption(void) #endif register int i; - des_key_schedule ks,ks2; - des_cblock iv,iv2; + DES_key_schedule ks,ks2; + DES_cblock iv,iv2; char *p; int num=0,j,k,l,rem,ll,len,last,ex=0; - des_cblock kk,k2; + DES_cblock kk,k2; FILE *O; int Exit=0; #ifndef OPENSSL_SYS_MSDOS @@ -423,19 +423,19 @@ void doencryption(void) else k2[i-8]=k; } - des_set_key_unchecked(&k2,&ks2); + DES_set_key_unchecked(&k2,&ks2); memset(k2,0,sizeof(k2)); } else if (longk || flag3) { if (flag3) { - des_string_to_2keys(key,&kk,&k2); - des_set_key_unchecked(&k2,&ks2); + DES_string_to_2keys(key,&kk,&k2); + DES_set_key_unchecked(&k2,&ks2); memset(k2,0,sizeof(k2)); } else - des_string_to_key(key,&kk); + DES_string_to_key(key,&kk); } else for (i=0; i= 8) memcpy(iv,&(obuf[l-8]),8); @@ -582,26 +582,26 @@ void doencryption(void) if (bflag && !flag3) for (i=0; i= 8) memcpy(iv,&(buf[l-8]),8); @@ -628,9 +628,9 @@ void doencryption(void) l=l-8+last; } i=0; - if (cflag) des_cbc_cksum(obuf, - (des_cblock *)cksum,(long)l/8*8,&ks, - (des_cblock *)cksum); + if (cflag) DES_cbc_cksum(obuf, + (DES_cblock *)cksum,(long)l/8*8,&ks, + (DES_cblock *)cksum); while (i != l) { j=fwrite(obuf,1,(unsigned int)l-i,DES_OUT); diff --git a/crypto/des/des.h b/crypto/des/des.h index d1ad912b1a..68fd355c79 100644 --- a/crypto/des/des.h +++ b/crypto/des/des.h @@ -63,10 +63,6 @@ #error DES is disabled. #endif -#ifdef _KERBEROS_DES_H -#error replaces . -#endif - #include /* DES_LONG */ #include /* OPENSSL_EXTERN */ @@ -79,24 +75,24 @@ extern "C" { #endif -typedef unsigned char des_cblock[8]; -typedef /* const */ unsigned char const_des_cblock[8]; -/* With "const", gcc 2.8.1 on Solaris thinks that des_cblock * - * and const_des_cblock * are incompatible pointer types. */ +typedef unsigned char DES_cblock[8]; +typedef /* const */ unsigned char const_DES_cblock[8]; +/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * + * and const_DES_cblock * are incompatible pointer types. */ -typedef struct des_ks +typedef struct DES_ks { union { - des_cblock cblock; + DES_cblock cblock; /* make sure things are correct size on machines with * 8 byte longs */ DES_LONG deslong[2]; } ks[16]; - } des_key_schedule; + } DES_key_schedule; -#define DES_KEY_SZ (sizeof(des_cblock)) -#define DES_SCHEDULE_SZ (sizeof(des_key_schedule)) +#define DES_KEY_SZ (sizeof(DES_cblock)) +#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) #define DES_ENCRYPT 1 #define DES_DECRYPT 0 @@ -104,45 +100,45 @@ typedef struct des_ks #define DES_CBC_MODE 0 #define DES_PCBC_MODE 1 -#define des_ecb2_encrypt(i,o,k1,k2,e) \ - des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) - -#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ - des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) - -#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ - des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) - -#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ - des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) - -OPENSSL_DECLARE_GLOBAL(int,des_check_key); /* defaults to false */ -#define des_check_key OPENSSL_GLOBAL_REF(des_check_key) -OPENSSL_DECLARE_GLOBAL(int,des_rw_mode); /* defaults to DES_PCBC_MODE */ -#define des_rw_mode OPENSSL_GLOBAL_REF(des_rw_mode) - -const char *des_options(void); -void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output, - des_key_schedule *ks1,des_key_schedule *ks2, - des_key_schedule *ks3, int enc); -DES_LONG des_cbc_cksum(const unsigned char *input,des_cblock *output, - long length,des_key_schedule *schedule, - const_des_cblock *ivec); -/* des_cbc_encrypt does not update the IV! Use des_ncbc_encrypt instead. */ -void des_cbc_encrypt(const unsigned char *input,unsigned char *output, - long length,des_key_schedule *schedule,des_cblock *ivec, +#define DES_ecb2_encrypt(i,o,k1,k2,e) \ + DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +OPENSSL_DECLARE_GLOBAL(int,DES_check_key); /* defaults to false */ +#define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key) +OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */ +#define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode) + +const char *DES_options(void); +void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3, int enc); +DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output, + long length,DES_key_schedule *schedule, + const_DES_cblock *ivec); +/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ +void DES_cbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, int enc); -void des_ncbc_encrypt(const unsigned char *input,unsigned char *output, - long length,des_key_schedule *schedule,des_cblock *ivec, +void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, int enc); -void des_xcbc_encrypt(const unsigned char *input,unsigned char *output, - long length,des_key_schedule *schedule,des_cblock *ivec, - const_des_cblock *inw,const_des_cblock *outw,int enc); -void des_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits, - long length,des_key_schedule *schedule,des_cblock *ivec, +void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, + const_DES_cblock *inw,const_DES_cblock *outw,int enc); +void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits, + long length,DES_key_schedule *schedule,DES_cblock *ivec, int enc); -void des_ecb_encrypt(const_des_cblock *input,des_cblock *output, - des_key_schedule *ks,int enc); +void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output, + DES_key_schedule *ks,int enc); /* This is the DES encryption function that gets called by just about every other DES routine in the library. You should not use this @@ -151,112 +147,78 @@ void des_ecb_encrypt(const_des_cblock *input,des_cblock *output, long, and this needs to be done to make sure 'non-aligned' memory access do not occur. The characters are loaded 'little endian'. 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. */ -void des_encrypt1(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_encrypt1() 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 - out. As for des_encrypt1(), 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. - IP() des_encrypt2() des_encrypt2() des_encrypt2() FP() is the same - as des_encrypt1() des_encrypt1() des_encrypt1() except faster :-). */ -void des_encrypt2(DES_LONG *data,des_key_schedule *ks, int enc); - -void des_encrypt3(DES_LONG *data, des_key_schedule *ks1, - des_key_schedule *ks2, des_key_schedule *ks3); -void des_decrypt3(DES_LONG *data, des_key_schedule *ks1, - des_key_schedule *ks2, des_key_schedule *ks3); -void des_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, + IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same + as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */ +void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc); + +void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3); +void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3); +void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output, long length, - des_key_schedule *ks1,des_key_schedule *ks2, - des_key_schedule *ks3,des_cblock *ivec,int enc); -void des_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3,DES_cblock *ivec,int enc); +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, - des_cblock *ivec1,des_cblock *ivec2, + DES_key_schedule *ks1,DES_key_schedule *ks2, + DES_key_schedule *ks3, + DES_cblock *ivec1,DES_cblock *ivec2, int enc); -void des_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, - long length,des_key_schedule *ks1, - des_key_schedule *ks2,des_key_schedule *ks3, - des_cblock *ivec,int *num,int enc); -void des_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, - long length,des_key_schedule *ks1, - des_key_schedule *ks2,des_key_schedule *ks3, - des_cblock *ivec,int *num); - -void des_xwhite_in2out(const_des_cblock *des_key,const_des_cblock *in_white, - des_cblock *out_white); - -int des_enc_read(int fd,void *buf,int len,des_key_schedule *sched, - des_cblock *iv); -int des_enc_write(int fd,const void *buf,int len,des_key_schedule *sched, - des_cblock *iv); -char *des_fcrypt(const char *buf,const char *salt, char *ret); -char *des_crypt(const char *buf,const char *salt); -#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) -char *crypt(const char *buf,const char *salt); -#endif -void des_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits, - long length,des_key_schedule *schedule,des_cblock *ivec); -void des_pcbc_encrypt(const unsigned char *input,unsigned char *output, - long length,des_key_schedule *schedule,des_cblock *ivec, +void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out, + long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int *num,int enc); +void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out, + long length,DES_key_schedule *ks1, + DES_key_schedule *ks2,DES_key_schedule *ks3, + DES_cblock *ivec,int *num); + +void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white, + DES_cblock *out_white); + +int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched, + DES_cblock *iv); +int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched, + DES_cblock *iv); +char *DES_fcrypt(const char *buf,const char *salt, char *ret); +char *DES_crypt(const char *buf,const char *salt); +void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits, + long length,DES_key_schedule *schedule,DES_cblock *ivec); +void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output, + long length,DES_key_schedule *schedule,DES_cblock *ivec, int enc); -DES_LONG des_quad_cksum(const unsigned char *input,des_cblock output[], - long length,int out_count,des_cblock *seed); -void des_random_seed(des_cblock *key); -int des_random_key(des_cblock *ret); -void des_set_odd_parity(des_cblock *key); -int des_check_key_parity(const_des_cblock *key); -int des_is_weak_key(const_des_cblock *key); -/* des_set_key (= set_key = des_key_sched = key_sched) calls - * des_set_key_checked if global variable des_check_key is set, - * des_set_key_unchecked otherwise. */ -int des_set_key(const_des_cblock *key,des_key_schedule *schedule); -int des_key_sched(const_des_cblock *key,des_key_schedule *schedule); -int des_set_key_checked(const_des_cblock *key,des_key_schedule *schedule); -void des_set_key_unchecked(const_des_cblock *key,des_key_schedule *schedule); -void des_string_to_key(const char *str,des_cblock *key); -void des_string_to_2keys(const char *str,des_cblock *key1,des_cblock *key2); -void des_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, - des_key_schedule *schedule,des_cblock *ivec,int *num, +DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[], + long length,int out_count,DES_cblock *seed); +void DES_random_seed(DES_cblock *key); +int DES_random_key(DES_cblock *ret); +void DES_set_odd_parity(DES_cblock *key); +int DES_check_key_parity(const_DES_cblock *key); +int DES_is_weak_key(const_DES_cblock *key); +/* DES_set_key (= set_key = DES_key_sched = key_sched) calls + * DES_set_key_checked if global variable DES_check_key is set, + * DES_set_key_unchecked otherwise. */ +int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule); +int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule); +int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule); +void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule); +void DES_string_to_key(const char *str,DES_cblock *key); +void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2); +void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length, + DES_key_schedule *schedule,DES_cblock *ivec,int *num, int enc); -void des_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, - des_key_schedule *schedule,des_cblock *ivec,int *num); -/* The following definitions provide compatibility with the MIT Kerberos - * library. The des_key_schedule structure is not binary compatible. */ - -#define _KERBEROS_DES_H - -#define KRBDES_ENCRYPT DES_ENCRYPT -#define KRBDES_DECRYPT DES_DECRYPT - -#ifdef KERBEROS -# define ENCRYPT DES_ENCRYPT -# define DECRYPT DES_DECRYPT -#endif - -#ifndef NCOMPAT -# define C_Block des_cblock -# define Key_schedule des_key_schedule -# define KEY_SZ DES_KEY_SZ -# define string_to_key des_string_to_key -# define read_pw_string des_read_pw_string -# define random_key des_random_key -# define pcbc_encrypt des_pcbc_encrypt -# define set_key des_set_key -# define key_sched des_key_sched -# define ecb_encrypt des_ecb_encrypt -# define cbc_encrypt des_cbc_encrypt -# define ncbc_encrypt des_ncbc_encrypt -# define xcbc_encrypt des_xcbc_encrypt -# define cbc_cksum des_cbc_cksum -# define quad_cksum des_quad_cksum -# define check_parity des_check_key_parity -#endif +void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, + DES_key_schedule *schedule,DES_cblock *ivec,int *num); -#define des_fixup_key_parity des_set_odd_parity +#define DES_fixup_key_parity DES_set_odd_parity #ifdef __cplusplus } diff --git a/crypto/des/des_enc.c b/crypto/des/des_enc.c index 81633c0c67..dfabd49198 100644 --- a/crypto/des/des_enc.c +++ b/crypto/des/des_enc.c @@ -58,7 +58,7 @@ #include "des_locl.h" -void des_encrypt1(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; #ifdef DES_PTR @@ -156,7 +156,7 @@ void des_encrypt1(DES_LONG *data, des_key_schedule *ks, int enc) l=r=t=u=0; } -void des_encrypt2(DES_LONG *data, des_key_schedule *ks, int enc) +void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc) { register DES_LONG l,r,t,u; #ifdef DES_PTR @@ -247,8 +247,8 @@ void des_encrypt2(DES_LONG *data, des_key_schedule *ks, int enc) l=r=t=u=0; } -void des_encrypt3(DES_LONG *data, des_key_schedule *ks1, - des_key_schedule *ks2, des_key_schedule *ks3) +void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3) { register DES_LONG l,r; @@ -257,9 +257,9 @@ void des_encrypt3(DES_LONG *data, des_key_schedule *ks1, IP(l,r); data[0]=l; data[1]=r; - des_encrypt2((DES_LONG *)data,ks1,DES_ENCRYPT); - des_encrypt2((DES_LONG *)data,ks2,DES_DECRYPT); - des_encrypt2((DES_LONG *)data,ks3,DES_ENCRYPT); + DES_encrypt2((DES_LONG *)data,ks1,DES_ENCRYPT); + DES_encrypt2((DES_LONG *)data,ks2,DES_DECRYPT); + DES_encrypt2((DES_LONG *)data,ks3,DES_ENCRYPT); l=data[0]; r=data[1]; FP(r,l); @@ -267,8 +267,8 @@ void des_encrypt3(DES_LONG *data, des_key_schedule *ks1, data[1]=r; } -void des_decrypt3(DES_LONG *data, des_key_schedule *ks1, - des_key_schedule *ks2, des_key_schedule *ks3) +void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3) { register DES_LONG l,r; @@ -277,9 +277,9 @@ void des_decrypt3(DES_LONG *data, des_key_schedule *ks1, IP(l,r); data[0]=l; data[1]=r; - des_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT); - des_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT); - des_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT); + DES_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT); + DES_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT); + DES_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT); l=data[0]; r=data[1]; FP(r,l); @@ -290,12 +290,12 @@ void des_decrypt3(DES_LONG *data, des_key_schedule *ks1, #ifndef DES_DEFAULT_OPTIONS #undef CBC_ENC_C__DONT_UPDATE_IV -#include "ncbc_enc.c" /* des_ncbc_encrypt */ +#include "ncbc_enc.c" /* DES_ncbc_encrypt */ -void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, - long length, des_key_schedule *ks1, - des_key_schedule *ks2, des_key_schedule *ks3, - des_cblock *ivec, int enc) +void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3, + DES_cblock *ivec, int enc) { register DES_LONG tin0,tin1; register DES_LONG tout0,tout1,xor0,xor1; @@ -322,7 +322,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, tin[0]=tin0; tin[1]=tin1; - des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); + DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); tout0=tin[0]; tout1=tin[1]; @@ -337,7 +337,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, tin[0]=tin0; tin[1]=tin1; - des_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); + DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3); tout0=tin[0]; tout1=tin[1]; @@ -364,7 +364,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, tin[0]=tin0; tin[1]=tin1; - des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); + DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); tout0=tin[0]; tout1=tin[1]; @@ -385,7 +385,7 @@ void des_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, tin[0]=tin0; tin[1]=tin1; - des_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); + DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3); tout0=tin[0]; tout1=tin[1]; diff --git a/crypto/des/des_locl.h b/crypto/des/des_locl.h index 22a24943e5..9a3ef9c9cd 100644 --- a/crypto/des/des_locl.h +++ b/crypto/des/des_locl.h @@ -412,6 +412,6 @@ OPENSSL_EXTERN const DES_LONG des_SPtrans[8][64]; -void fcrypt_body(DES_LONG *out,des_key_schedule *ks, +void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, DES_LONG Eswap0, DES_LONG Eswap1); #endif diff --git a/crypto/des/des_old.c b/crypto/des/des_old.c new file mode 100644 index 0000000000..91403587ed --- /dev/null +++ b/crypto/des/des_old.c @@ -0,0 +1,245 @@ +/* crypto/des/des_comp.c -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +#include + +const char *des_options(void) + { + return DES_options(); + } +void des_ecb3_encrypt(des_cblock *input,des_cblock *output, + des_key_schedule ks1,des_key_schedule ks2, + des_key_schedule ks3, int enc) + { + DES_ecb3_encrypt((const_DES_cblock *)input, output, + (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, + (DES_key_schedule *)ks3, enc); + } +DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output, + long length,des_key_schedule schedule,des_cblock *ivec) + { + return DES_cbc_cksum((unsigned char *)input, output, length, + (DES_key_schedule *)schedule, ivec); + } +void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec,int enc) + { + DES_cbc_encrypt((unsigned char *)input, (unsigned char *)output, + length, (DES_key_schedule *)schedule, ivec, enc); + } +void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec,int enc) + { + DES_ncbc_encrypt((unsigned char *)input, (unsigned char *)output, + length, (DES_key_schedule *)schedule, ivec, enc); + } +void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec, + des_cblock *inw,des_cblock *outw,int enc) + { + DES_xcbc_encrypt((unsigned char *)input, (unsigned char *)output, + length, (DES_key_schedule *)schedule, ivec, inw, outw, enc); + } +void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, + long length,des_key_schedule schedule,des_cblock *ivec,int enc) + { + DES_cfb_encrypt(in, out, numbits, length, + (DES_key_schedule *)schedule, ivec, enc); + } +void des_ecb_encrypt(des_cblock *input,des_cblock *output, + des_key_schedule ks,int enc) + { + DES_ecb_encrypt(input, output, (DES_key_schedule *)ks, enc); + } +void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc) + { + DES_encrypt1(data, (DES_key_schedule *)ks, enc); + } +void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc) + { + DES_encrypt2(data, (DES_key_schedule *)ks, enc); + } +void des_encrypt3(DES_LONG *data, des_key_schedule ks1, + des_key_schedule ks2, des_key_schedule ks3) + { + DES_encrypt3(data, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, + (DES_key_schedule *)ks3); + } +void des_decrypt3(DES_LONG *data, des_key_schedule ks1, + des_key_schedule ks2, des_key_schedule ks3) + { + DES_decrypt3(data, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, + (DES_key_schedule *)ks3); + } +void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, des_cblock *ivec, int enc) + { + DES_ede3_cbc_encrypt((unsigned char *)input, (unsigned char *)output, + length, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, + (DES_key_schedule *)ks3, ivec, enc); + } +void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, des_cblock *ivec, int *num, int enc) + { + DES_ede3_cfb64_encrypt(in, out, length, + (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, + (DES_key_schedule *)ks3, ivec, num, enc); + } +void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, des_cblock *ivec, int *num) + { + DES_ede3_ofb64_encrypt(in, out, length, + (DES_key_schedule *)ks1, (DES_key_schedule *)ks2, + (DES_key_schedule *)ks3, ivec, num); + } + +void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white), + des_cblock (*out_white)) + { + DES_xwhite_in2out(des_key, in_white, out_white); + } + +int des_enc_read(int fd,char *buf,int len,des_key_schedule sched, + des_cblock *iv) + { + return DES_enc_read(fd, buf, len, (DES_key_schedule *)sched, iv); + } +int des_enc_write(int fd,char *buf,int len,des_key_schedule sched, + des_cblock *iv) + { + return DES_enc_write(fd, buf, len, (DES_key_schedule *)sched, iv); + } +char *des_fcrypt(const char *buf,const char *salt, char *ret) + { + return DES_fcrypt(buf, salt, ret); + } +char *des_crypt(const char *buf,const char *salt) + { + return DES_crypt(buf, salt); + } +#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) +char *crypt(const char *buf,const char *salt) + { + return DES_crypt(buf, salt); + } +#endif +void des_ofb_encrypt(unsigned char *in,unsigned char *out, + int numbits,long length,des_key_schedule schedule,des_cblock *ivec) + { + DES_ofb_encrypt(in, out, numbits, length, (DES_key_schedule *)schedule, + ivec); + } +void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec,int enc) + { + DES_pcbc_encrypt((unsigned char *)input, (unsigned char *)output, + length, (DES_key_schedule *)schedule, ivec, enc); + } +DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output, + long length,int out_count,des_cblock *seed) + { + return DES_quad_cksum((unsigned char *)input, output, length, + out_count, seed); + } +void des_random_seed(des_cblock key) + { + DES_random_seed((DES_cblock *)key); + } +void des_random_key(des_cblock ret) + { + DES_random_key((DES_cblock *)ret); + } +void des_set_odd_parity(des_cblock *key) + { + DES_set_odd_parity(key); + } +int des_is_weak_key(des_cblock *key) + { + return DES_is_weak_key(key); + } +int des_set_key(des_cblock *key,des_key_schedule schedule) + { + return DES_set_key(key, (DES_key_schedule *)schedule); + } +int des_key_sched(des_cblock *key,des_key_schedule schedule) + { + return DES_key_sched(key, (DES_key_schedule *)schedule); + } +void des_string_to_key(char *str,des_cblock *key) + { + DES_string_to_key(str, key); + } +void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2) + { + DES_string_to_2keys(str, key1, key2); + } +void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + des_key_schedule schedule, des_cblock *ivec, int *num, int enc) + { + DES_cfb64_encrypt(in, out, length, (DES_key_schedule *)schedule, + ivec, num, enc); + } +void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + des_key_schedule schedule, des_cblock *ivec, int *num) + { + DES_ofb64_encrypt(in, out, length, (DES_key_schedule *)schedule, + ivec, num); + } diff --git a/crypto/des/des_old.h b/crypto/des/des_old.h new file mode 100644 index 0000000000..d40dcf6e37 --- /dev/null +++ b/crypto/des/des_old.h @@ -0,0 +1,236 @@ +/* crypto/des/des_comp.h -*- mode:C; c-file-style: "eay" -*- */ +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + +/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * + * The function names in here are deprecated and are only present to + * provide an interface compatible with libdes. OpenSSL now provides + * functions where "des_" has been replaced with "DES_" in the names, + * to make it possible to make incompatible changes that are needed + * for C type security and other stuff. + * + * Please consider starting to use the DES_ functions rather than the + * des_ ones. The des_ functions will dissapear completely before + * OpenSSL 1.0! + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +#ifndef HEADER_DES_COMP_H +#define HEADER_DES_COMP_H + +#ifdef OPENSSL_NO_DES +#error DES is disabled. +#endif + +#ifdef _KERBEROS_DES_H +#error replaces . +#endif + +#include /* DES_LONG */ +#include /* OPENSSL_EXTERN */ +#include +#include + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned char des_cblock[8]; +typedef struct des_ks_struct + { + union { + des_cblock _; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG pad[2]; + } ks; + } des_key_schedule[16]; + +#define DES_KEY_SZ (sizeof(DES_cblock)) +#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) + +#define DES_ENCRYPT 1 +#define DES_DECRYPT 0 + +#define DES_CBC_MODE 0 +#define DES_PCBC_MODE 1 + +#define des_ecb2_encrypt(i,o,k1,k2,e) \ + des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) + +#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ + des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) + +#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ + des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) + +#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ + des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) + +#define des_check_key DES_check_key +#define des_rw_mode DES_rw_mode + +const char *des_options(void); +void des_ecb3_encrypt(des_cblock *input,des_cblock *output, + des_key_schedule ks1,des_key_schedule ks2, + des_key_schedule ks3, int enc); +DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output, + long length,des_key_schedule schedule,des_cblock *ivec); +void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec,int enc); +void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec,int enc); +void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec, + des_cblock *inw,des_cblock *outw,int enc); +void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, + long length,des_key_schedule schedule,des_cblock *ivec,int enc); +void des_ecb_encrypt(des_cblock *input,des_cblock *output, + des_key_schedule ks,int enc); +void des_encrypt(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, + des_key_schedule ks2, des_key_schedule ks3); +void des_decrypt3(DES_LONG *data, des_key_schedule ks1, + des_key_schedule ks2, des_key_schedule ks3); +void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, des_cblock *ivec, int enc); +void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, des_cblock *ivec, int *num, int enc); +void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, des_cblock *ivec, int *num); + +void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white), + des_cblock (*out_white)); + +int des_enc_read(int fd,char *buf,int len,des_key_schedule sched, + des_cblock *iv); +int des_enc_write(int fd,char *buf,int len,des_key_schedule sched, + des_cblock *iv); +char *des_fcrypt(const char *buf,const char *salt, char *ret); +char *des_crypt(const char *buf,const char *salt); +#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) +char *crypt(const char *buf,const char *salt); +#endif +void des_ofb_encrypt(unsigned char *in,unsigned char *out, + int numbits,long length,des_key_schedule schedule,des_cblock *ivec); +void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length, + des_key_schedule schedule,des_cblock *ivec,int enc); +DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output, + long length,int out_count,des_cblock *seed); +void des_random_seed(des_cblock key); +void des_random_key(des_cblock ret); +void des_set_odd_parity(des_cblock *key); +int des_is_weak_key(des_cblock *key); +int des_set_key(des_cblock *key,des_key_schedule schedule); +int des_key_sched(des_cblock *key,des_key_schedule schedule); +void des_string_to_key(char *str,des_cblock *key); +void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2); +void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + des_key_schedule schedule, des_cblock *ivec, int *num, int enc); +void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + des_key_schedule schedule, des_cblock *ivec, int *num); + +/* The following definitions provide compatibility with the MIT Kerberos + * library. The des_key_schedule structure is not binary compatible. */ + +#define _KERBEROS_DES_H + +#define KRBDES_ENCRYPT DES_ENCRYPT +#define KRBDES_DECRYPT DES_DECRYPT + +#ifdef KERBEROS +# define ENCRYPT DES_ENCRYPT +# define DECRYPT DES_DECRYPT +#endif + +#ifndef NCOMPAT +# define C_Block des_cblock +# define Key_schedule des_key_schedule +# define KEY_SZ DES_KEY_SZ +# define string_to_key des_string_to_key +# define read_pw_string des_read_pw_string +# define random_key des_random_key +# define pcbc_encrypt des_pcbc_encrypt +# define set_key des_set_key +# define key_sched des_key_sched +# define ecb_encrypt des_ecb_encrypt +# define cbc_encrypt des_cbc_encrypt +# define ncbc_encrypt des_ncbc_encrypt +# define xcbc_encrypt des_xcbc_encrypt +# define cbc_cksum des_cbc_cksum +# define quad_cksum des_quad_cksum +# define check_parity des_check_key_parity +#endif + +#define des_fixup_key_parity DES_fixup_key_parity + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/crypto/des/des_opts.c b/crypto/des/des_opts.c index 4673c13eb3..79278b920e 100644 --- a/crypto/des/des_opts.c +++ b/crypto/des/des_opts.c @@ -118,10 +118,10 @@ extern void exit(); #undef DES_RISC2 #undef DES_PTR #undef D_ENCRYPT -#define des_encrypt1 des_encrypt_u4_cisc_idx -#define des_encrypt2 des_encrypt2_u4_cisc_idx -#define des_encrypt3 des_encrypt3_u4_cisc_idx -#define des_decrypt3 des_decrypt3_u4_cisc_idx +#define DES_encrypt1 des_encrypt_u4_cisc_idx +#define DES_encrypt2 des_encrypt2_u4_cisc_idx +#define DES_encrypt3 des_encrypt3_u4_cisc_idx +#define DES_decrypt3 des_decrypt3_u4_cisc_idx #undef HEADER_DES_LOCL_H #include "des_enc.c" @@ -130,14 +130,14 @@ extern void exit(); #undef DES_RISC2 #undef DES_PTR #undef D_ENCRYPT -#undef des_encrypt1 -#undef des_encrypt2 -#undef des_encrypt3 -#undef des_decrypt3 -#define des_encrypt1 des_encrypt_u16_cisc_idx -#define des_encrypt2 des_encrypt2_u16_cisc_idx -#define des_encrypt3 des_encrypt3_u16_cisc_idx -#define des_decrypt3 des_decrypt3_u16_cisc_idx +#undef DES_encrypt1 +#undef DES_encrypt2 +#undef DES_encrypt3 +#undef DES_decrypt3 +#define DES_encrypt1 des_encrypt_u16_cisc_idx +#define DES_encrypt2 des_encrypt2_u16_cisc_idx +#define DES_encrypt3 des_encrypt3_u16_cisc_idx +#define DES_decrypt3 des_decrypt3_u16_cisc_idx #undef HEADER_DES_LOCL_H #include "des_enc.c" @@ -146,14 +146,14 @@ extern void exit(); #undef DES_RISC2 #undef DES_PTR #undef D_ENCRYPT -#undef des_encrypt1 -#undef des_encrypt2 -#undef des_encrypt3 -#undef des_decrypt3 -#define des_encrypt1 des_encrypt_u4_risc1_idx -#define des_encrypt2 des_encrypt2_u4_risc1_idx -#define des_encrypt3 des_encrypt3_u4_risc1_idx -#define des_decrypt3 des_decrypt3_u4_risc1_idx +#undef DES_encrypt1 +#undef DES_encrypt2 +#undef DES_encrypt3 +#undef DES_decrypt3 +#define DES_encrypt1 des_encrypt_u4_risc1_idx +#define DES_encrypt2 des_encrypt2_u4_risc1_idx +#define DES_encrypt3 des_encrypt3_u4_risc1_idx +#define DES_decrypt3 des_decrypt3_u4_risc1_idx #undef HEADER_DES_LOCL_H #include "des_enc.c" @@ -166,14 +166,14 @@ extern void exit(); #define DES_RISC2 #undef DES_PTR #undef D_ENCRYPT -#undef des_encrypt1 -#undef des_encrypt2 -#undef des_encrypt3 -#undef des_decrypt3 -#define des_encrypt1 des_encrypt_u4_risc2_idx -#define des_encrypt2 des_encrypt2_u4_risc2_idx -#define des_encrypt3 des_encrypt3_u4_risc2_idx -#define des_decrypt3 des_decrypt3_u4_risc2_idx +#undef DES_encrypt1 +#undef DES_encrypt2 +#undef DES_encrypt3 +#undef DES_decrypt3 +#define DES_encrypt1 des_encrypt_u4_risc2_idx +#define DES_encrypt2 des_encrypt2_u4_risc2_idx +#define DES_encrypt3 des_encrypt3_u4_risc2_idx +#define DES_decrypt3 des_decrypt3_u4_risc2_idx #undef HEADER_DES_LOCL_H #include "des_enc.c" @@ -182,14 +182,14 @@ extern void exit(); #undef DES_RISC2 #undef DES_PTR #undef D_ENCRYPT -#undef des_encrypt1 -#undef des_encrypt2 -#undef des_encrypt3 -#undef des_decrypt3 -#define des_encrypt1 des_encrypt_u16_risc1_idx -#define des_encrypt2 des_encrypt2_u16_risc1_idx -#define des_encrypt3 des_encrypt3_u16_risc1_idx -#define des_decrypt3 des_decrypt3_u16_risc1_idx +#undef DES_encrypt1 +#undef DES_encrypt2 +#undef DES_encrypt3 +#undef DES_decrypt3 +#define DES_encrypt1 des_encrypt_u16_risc1_idx +#define DES_encrypt2 des_encrypt2_u16_risc1_idx +#define DES_encrypt3 des_encrypt3_u16_risc1_idx +#define DES_decrypt3 des_decrypt3_u16_risc1_idx #undef HEADER_DES_LOCL_H #include "des_enc.c" @@ -198,14 +198,14 @@ extern void exit(); #define DES_RISC2 #undef DES_PTR #undef D_ENCRYPT -#undef des_encrypt1 -#undef des_encrypt2 -#undef des_encrypt3 -#undef des_decrypt3 -#define des_encrypt1 des_encrypt_u16_risc2_idx -#define des_encrypt2 des_encrypt2_u16_risc2_idx -#define des_encrypt3 des_encrypt3_u16_risc2_idx -#define des_decrypt3 des_decrypt3_u16_risc2_idx +#undef DES_encrypt1 +#undef DES_encrypt2 +#undef DES_encrypt3 +#undef DES_decrypt3 +#define DES_encrypt1 des_encrypt_u16_risc2_idx +#define DES_encrypt2 des_encrypt2_u16_risc2_idx +#define DES_encrypt3 des_encrypt3_u16_risc2_idx +#define DES_decrypt3 des_decrypt3_u16_risc2_idx #undef HEADER_DES_LOCL_H #include "des_enc.c" @@ -218,14 +218,14 @@ extern void exit(); #undef DES_RISC2 #define DES_PTR #undef D_ENCRYPT -#undef des_encrypt1 -#undef des_encrypt2 -#undef des_encrypt3 -#undef des_decrypt3 -#define des_encrypt1 des_encrypt_u4_cisc_ptr -#define des_encrypt2 des_encrypt2_u4_cisc_ptr -#define des_encrypt3 des_encrypt3_u4_cisc_ptr -#define des_decrypt3 des_decrypt3_u4_cisc_ptr +#undef DES_encrypt1 +#undef DES_encrypt2 +#undef DES_encrypt3 +#undef DES_decrypt3 +#define DES_encrypt1 des_encrypt_u4_cisc_ptr +#define DES_encrypt2 des_encrypt2_u4_cisc_ptr +#define DES_encrypt3 des_encrypt3_u4_cisc_ptr +#define DES_decrypt3 des_decrypt3_u4_cisc_ptr #undef HEADER_DES_LOCL_H #include "des_enc.c" @@ -234,14 +234,14 @@ extern void exit(); #undef DES_RISC2 #define DES_PTR #undef D_ENCRYPT -#undef des_encrypt1 -#undef des_encrypt2 -#undef des_encrypt3 -#undef des_decrypt3 -#define des_encrypt1 des_encrypt_u16_cisc_ptr -#define des_encrypt2 des_encrypt2_u16_cisc_ptr -#define des_encrypt3 des_encrypt3_u16_cisc_ptr -#define des_decrypt3 des_decrypt3_u16_cisc_ptr +#undef DES_encrypt1 +#undef DES_encrypt2 +#undef DES_encrypt3 +#undef DES_decrypt3 +#define DES_encrypt1 des_encrypt_u16_cisc_ptr +#define DES_encrypt2 des_encrypt2_u16_cisc_ptr +#define DES_encrypt3 des_encrypt3_u16_cisc_ptr +#define DES_decrypt3 des_decrypt3_u16_cisc_ptr #undef HEADER_DES_LOCL_H #include "des_enc.c" @@ -250,14 +250,14 @@ extern void exit(); #undef DES_RISC2 #define DES_PTR #undef D_ENCRYPT -#undef des_encrypt1 -#undef des_encrypt2 -#undef des_encrypt3 -#undef des_decrypt3 -#define des_encrypt1 des_encrypt_u4_risc1_ptr -#define des_encrypt2 des_encrypt2_u4_risc1_ptr -#define des_encrypt3 des_encrypt3_u4_risc1_ptr -#define des_decrypt3 des_decrypt3_u4_risc1_ptr +#undef DES_encrypt1 +#undef DES_encrypt2 +#undef DES_encrypt3 +#undef DES_decrypt3 +#define DES_encrypt1 des_encrypt_u4_risc1_ptr +#define DES_encrypt2 des_encrypt2_u4_risc1_ptr +#define DES_encrypt3 des_encrypt3_u4_risc1_ptr +#define DES_decrypt3 des_decrypt3_u4_risc1_ptr #undef HEADER_DES_LOCL_H #include "des_enc.c" @@ -270,14 +270,14 @@ extern void exit(); #define DES_RISC2 #define DES_PTR #undef D_ENCRYPT -#undef des_encrypt1 -#undef des_encrypt2 -#undef des_encrypt3 -#undef des_decrypt3 -#define des_encrypt1 des_encrypt_u4_risc2_ptr -#define des_encrypt2 des_encrypt2_u4_risc2_ptr -#define des_encrypt3 des_encrypt3_u4_risc2_ptr -#define des_decrypt3 des_decrypt3_u4_risc2_ptr +#undef DES_encrypt1 +#undef DES_encrypt2 +#undef DES_encrypt3 +#undef DES_decrypt3 +#define DES_encrypt1 des_encrypt_u4_risc2_ptr +#define DES_encrypt2 des_encrypt2_u4_risc2_ptr +#define DES_encrypt3 des_encrypt3_u4_risc2_ptr +#define DES_decrypt3 des_decrypt3_u4_risc2_ptr #undef HEADER_DES_LOCL_H #include "des_enc.c" @@ -286,14 +286,14 @@ extern void exit(); #undef DES_RISC2 #define DES_PTR #undef D_ENCRYPT -#undef des_encrypt1 -#undef des_encrypt2 -#undef des_encrypt3 -#undef des_decrypt3 -#define des_encrypt1 des_encrypt_u16_risc1_ptr -#define des_encrypt2 des_encrypt2_u16_risc1_ptr -#define des_encrypt3 des_encrypt3_u16_risc1_ptr -#define des_decrypt3 des_decrypt3_u16_risc1_ptr +#undef DES_encrypt1 +#undef DES_encrypt2 +#undef DES_encrypt3 +#undef DES_decrypt3 +#define DES_encrypt1 des_encrypt_u16_risc1_ptr +#define DES_encrypt2 des_encrypt2_u16_risc1_ptr +#define DES_encrypt3 des_encrypt3_u16_risc1_ptr +#define DES_decrypt3 des_decrypt3_u16_risc1_ptr #undef HEADER_DES_LOCL_H #include "des_enc.c" @@ -302,14 +302,14 @@ extern void exit(); #define DES_RISC2 #define DES_PTR #undef D_ENCRYPT -#undef des_encrypt1 -#undef des_encrypt2 -#undef des_encrypt3 -#undef des_decrypt3 -#define des_encrypt1 des_encrypt_u16_risc2_ptr -#define des_encrypt2 des_encrypt2_u16_risc2_ptr -#define des_encrypt3 des_encrypt3_u16_risc2_ptr -#define des_decrypt3 des_decrypt3_u16_risc2_ptr +#undef DES_encrypt1 +#undef DES_encrypt2 +#undef DES_encrypt3 +#undef DES_decrypt3 +#define DES_encrypt1 des_encrypt_u16_risc2_ptr +#define DES_encrypt2 des_encrypt2_u16_risc2_ptr +#define DES_encrypt3 des_encrypt3_u16_risc2_ptr +#define DES_decrypt3 des_decrypt3_u16_risc2_ptr #undef HEADER_DES_LOCL_H #include "des_enc.c" @@ -401,7 +401,7 @@ double Time_F(int s) for (count=0,run=1; COND(cb); count++) \ { \ unsigned long d[2]; \ - func(d,&(sch[0]),DES_ENCRYPT); \ + func(d,&sch,DES_ENCRYPT); \ } \ tm[index]=Time_F(STOP); \ fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \ @@ -415,10 +415,10 @@ int main(int argc, char **argv) { long count; static unsigned char buf[BUFSIZE]; - 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; + 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; double d,tm[16],max=0; int rank[16]; char *str[16]; @@ -438,13 +438,13 @@ int main(int argc, char **argv) fprintf(stderr,"program when this computer is idle.\n"); #endif - 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); #ifndef SIGALRM fprintf(stderr,"First we calculate the approximate speed ...\n"); - des_set_key_unchecked(&key,sch); + DES_set_key_unchecked(&key,sch); count=10; do { long i; @@ -453,7 +453,7 @@ int main(int argc, char **argv) count*=2; Time_F(START); for (i=count; i; i--) - des_encrypt1(data,&(sch[0]),DES_ENCRYPT); + DES_encrypt1(data,&(sch[0]),DES_ENCRYPT); d=Time_F(STOP); } while (d < 3.0); ca=count; diff --git a/crypto/des/destest.c b/crypto/des/destest.c index 33f1656268..1c7936f398 100644 --- a/crypto/des/destest.c +++ b/crypto/des/destest.c @@ -82,10 +82,10 @@ int main(int argc, char *argv[]) return(0); } #else -#include +#include #if defined(PERL5) || defined(__FreeBSD__) -#define crypt(c,s) (des_crypt((c),(s))) +#define crypt(c,s) (DES_crypt((c),(s))) #endif /* tisk tisk - the test keys don't all have odd parity :-( */ @@ -332,8 +332,8 @@ static int ede_cfb64_test(unsigned char *cfb_cipher); int main(int argc, char *argv[]) { int i,j,err=0; - des_cblock in,out,outin,iv3,iv2; - des_key_schedule ks,ks2,ks3; + DES_cblock in,out,outin,iv3,iv2; + DES_key_schedule ks,ks2,ks3; unsigned char cbc_in[40]; unsigned char cbc_out[40]; DES_LONG cs; @@ -351,17 +351,17 @@ int main(int argc, char *argv[]) #ifndef OPENSSL_NO_DESCBCM printf("Doing cbcm\n"); - if ((j=des_set_key_checked(&cbc_key,&ks)) != 0) + if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0) { printf("Key error %d\n",j); err=1; } - if ((j=des_set_key_checked(&cbc2_key,&ks2)) != 0) + if ((j=DES_set_key_checked(&cbc2_key,&ks2)) != 0) { printf("Key error %d\n",j); err=1; } - if ((j=des_set_key_checked(&cbc3_key,&ks3)) != 0) + if ((j=DES_set_key_checked(&cbc3_key,&ks3)) != 0) { printf("Key error %d\n",j); err=1; @@ -373,25 +373,25 @@ int main(int argc, char *argv[]) memcpy(iv3,cbc_iv,sizeof(cbc_iv)); memset(iv2,'\0',sizeof iv2); - des_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,&ks,&ks2,&ks3,&iv3,&iv2, + DES_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,&ks,&ks2,&ks3,&iv3,&iv2, DES_ENCRYPT); - des_ede3_cbcm_encrypt(&cbc_data[16],&cbc_out[16],i-16,&ks,&ks2,&ks3, + DES_ede3_cbcm_encrypt(&cbc_data[16],&cbc_out[16],i-16,&ks,&ks2,&ks3, &iv3,&iv2,DES_ENCRYPT); /* if (memcmp(cbc_out,cbc3_ok, (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0) { - printf("des_ede3_cbc_encrypt encrypt error\n"); + printf("DES_ede3_cbc_encrypt encrypt error\n"); err=1; } */ memcpy(iv3,cbc_iv,sizeof(cbc_iv)); memset(iv2,'\0',sizeof iv2); - des_ede3_cbcm_encrypt(cbc_out,cbc_in,i,&ks,&ks2,&ks3,&iv3,&iv2,DES_DECRYPT); + DES_ede3_cbcm_encrypt(cbc_out,cbc_in,i,&ks,&ks2,&ks3,&iv3,&iv2,DES_DECRYPT); if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0) { int n; - printf("des_ede3_cbcm_encrypt decrypt error\n"); + printf("DES_ede3_cbcm_encrypt decrypt error\n"); for(n=0 ; n < i ; ++n) printf(" %02x",cbc_data[n]); printf("\n"); @@ -405,12 +405,12 @@ int main(int argc, char *argv[]) printf("Doing ecb\n"); for (i=0; i MAXWRITE)?MAXWRITE:(len-i),sched,iv); if (k < 0) return(k); @@ -139,11 +139,11 @@ int des_enc_write(int fd, const void *_buf, int len, rnum=((len+7)/8*8); /* round up to nearest eight */ } - if (des_rw_mode & DES_PCBC_MODE) - des_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, + if (DES_rw_mode & DES_PCBC_MODE) + DES_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, DES_ENCRYPT); else - des_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, + DES_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv, DES_ENCRYPT); /* output */ diff --git a/crypto/des/fcrypt.c b/crypto/des/fcrypt.c index caade4db9a..2758c32656 100644 --- a/crypto/des/fcrypt.c +++ b/crypto/des/fcrypt.c @@ -58,22 +58,15 @@ static unsigned const char cov_2char[64]={ 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A }; -void fcrypt_body(DES_LONG *out,des_key_schedule *ks, +void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, DES_LONG Eswap0, DES_LONG Eswap1); -#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) -char *crypt(const char *buf, const char *salt) - { - return(des_crypt(buf, salt)); - } -#endif - -char *des_crypt(const char *buf, const char *salt) +char *DES_crypt(const char *buf, const char *salt) { static char buff[14]; #ifndef CHARSET_EBCDIC - return(des_fcrypt(buf,salt,buff)); + return(DES_fcrypt(buf,salt,buff)); #else char e_salt[2+1]; char e_buf[32+1]; /* replace 32 by 8 ? */ @@ -89,14 +82,14 @@ char *des_crypt(const char *buf, const char *salt) /* Make sure we have a delimiter */ e_salt[sizeof(e_salt)-1] = e_buf[sizeof(e_buf)-1] = '\0'; - /* Convert the e_salt to ASCII, as that's what des_fcrypt works on */ + /* Convert the e_salt to ASCII, as that's what DES_fcrypt works on */ ebcdic2ascii(e_salt, e_salt, sizeof e_salt); /* Convert the cleartext password to ASCII */ ebcdic2ascii(e_buf, e_buf, sizeof e_buf); /* Encrypt it (from/to ASCII) */ - ret = des_fcrypt(e_buf,e_salt,buff); + ret = DES_fcrypt(e_buf,e_salt,buff); /* Convert the result back to EBCDIC */ ascii2ebcdic(ret, ret, strlen(ret)); @@ -106,13 +99,13 @@ char *des_crypt(const char *buf, const char *salt) } -char *des_fcrypt(const char *buf, const char *salt, char *ret) +char *DES_fcrypt(const char *buf, const char *salt, char *ret) { unsigned int i,j,x,y; DES_LONG Eswap0,Eswap1; DES_LONG out[2],ll; - des_cblock key; - des_key_schedule ks; + DES_cblock key; + DES_key_schedule ks; unsigned char bb[9]; unsigned char *b=bb; unsigned char c,u; @@ -150,7 +143,7 @@ r=(r+7)/8; for (; i<8; i++) key[i]=0; - des_set_key_unchecked(&key,&ks); + DES_set_key_unchecked(&key,&ks); fcrypt_body(&(out[0]),&ks,Eswap0,Eswap1); ll=out[0]; l2c(ll,b); diff --git a/crypto/des/fcrypt_b.c b/crypto/des/fcrypt_b.c index 86253bd5ca..8b6b0e8856 100644 --- a/crypto/des/fcrypt_b.c +++ b/crypto/des/fcrypt_b.c @@ -77,7 +77,7 @@ #define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\ (a)=(a)^(t)^(t>>(16-(n))))\ -void fcrypt_body(DES_LONG *out, des_key_schedule *ks, DES_LONG Eswap0, +void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0, DES_LONG Eswap1) { register DES_LONG l,r,t,u; diff --git a/crypto/des/ncbc_enc.c b/crypto/des/ncbc_enc.c index 6be518486e..fda23d522f 100644 --- a/crypto/des/ncbc_enc.c +++ b/crypto/des/ncbc_enc.c @@ -1,8 +1,8 @@ /* crypto/des/ncbc_enc.c */ /* * #included by: - * cbc_enc.c (des_cbc_encrypt) - * des_enc.c (des_ncbc_encrypt) + * cbc_enc.c (DES_cbc_encrypt) + * des_enc.c (DES_ncbc_encrypt) */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. @@ -64,11 +64,11 @@ #include "des_locl.h" #ifdef CBC_ENC_C__DONT_UPDATE_IV -void des_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - des_key_schedule *_schedule, des_cblock *ivec, int enc) +void DES_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, + DES_key_schedule *_schedule, DES_cblock *ivec, int enc) #else -void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, - des_key_schedule *_schedule, des_cblock *ivec, int enc) +void DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, + DES_key_schedule *_schedule, DES_cblock *ivec, int enc) #endif { register DES_LONG tin0,tin1; @@ -89,7 +89,7 @@ void des_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length, c2l(in,tin1); 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); tout0=tin[0]; l2c(tout0,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); 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); tout0=tin[0]; l2c(tout0,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,tin1); tin[1]=tin1; - des_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT); + DES_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT); tout0=tin[0]^xor0; tout1=tin[1]^xor1; 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,tin1); tin[1]=tin1; - des_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT); + DES_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT); tout0=tin[0]^xor0; tout1=tin[1]^xor1; l2cn(tout0,tout1,out,l+8); diff --git a/crypto/des/ofb64ede.c b/crypto/des/ofb64ede.c index 9f389f7c23..26bbf9a6a7 100644 --- a/crypto/des/ofb64ede.c +++ b/crypto/des/ofb64ede.c @@ -62,16 +62,16 @@ * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ -void des_ede3_ofb64_encrypt(register const unsigned char *in, +void DES_ede3_ofb64_encrypt(register const unsigned char *in, register unsigned char *out, long length, - des_key_schedule *k1, des_key_schedule *k2, - des_key_schedule *k3, des_cblock *ivec, + DES_key_schedule *k1, DES_key_schedule *k2, + DES_key_schedule *k3, DES_cblock *ivec, int *num) { register DES_LONG v0,v1; register int n= *num; register long l=length; - des_cblock d; + DES_cblock d; register char *dp; DES_LONG ti[2]; unsigned char *iv; @@ -91,7 +91,7 @@ void des_ede3_ofb64_encrypt(register const unsigned char *in, { /* ti[0]=v0; */ /* ti[1]=v1; */ - des_encrypt3(ti,k1,k2,k3); + DES_encrypt3(ti,k1,k2,k3); v0=ti[0]; v1=ti[1]; @@ -116,10 +116,10 @@ void des_ede3_ofb64_encrypt(register const unsigned char *in, } #ifdef undef /* MACRO */ -void des_ede2_ofb64_encrypt(register unsigned char *in, - register unsigned char *out, long length, des_key_schedule k1, - des_key_schedule k2, des_cblock (*ivec), int *num) +void DES_ede2_ofb64_encrypt(register unsigned char *in, + register unsigned char *out, long length, DES_key_schedule k1, + DES_key_schedule k2, DES_cblock (*ivec), int *num) { - des_ede3_ofb64_encrypt(in, out, length, k1,k2,k1, ivec, num); + DES_ede3_ofb64_encrypt(in, out, length, k1,k2,k1, ivec, num); } #endif diff --git a/crypto/des/ofb64enc.c b/crypto/des/ofb64enc.c index 11be67c46c..8ca3d49dea 100644 --- a/crypto/des/ofb64enc.c +++ b/crypto/des/ofb64enc.c @@ -62,14 +62,14 @@ * used. The extra state information to record how much of the * 64bit block we have used is contained in *num; */ -void des_ofb64_encrypt(register const unsigned char *in, +void DES_ofb64_encrypt(register const unsigned char *in, register unsigned char *out, long length, - des_key_schedule *schedule, des_cblock *ivec, int *num) + DES_key_schedule *schedule, DES_cblock *ivec, int *num) { register DES_LONG v0,v1,t; register int n= *num; register long l=length; - des_cblock d; + DES_cblock d; register unsigned char *dp; DES_LONG ti[2]; unsigned char *iv; @@ -87,7 +87,7 @@ void des_ofb64_encrypt(register const unsigned char *in, { if (n == 0) { - des_encrypt1(ti,schedule,DES_ENCRYPT); + DES_encrypt1(ti,schedule,DES_ENCRYPT); dp=d; t=ti[0]; l2c(t,dp); t=ti[1]; l2c(t,dp); diff --git a/crypto/des/ofb_enc.c b/crypto/des/ofb_enc.c index 715ecb291f..e887a3c6f4 100644 --- a/crypto/des/ofb_enc.c +++ b/crypto/des/ofb_enc.c @@ -64,9 +64,9 @@ * the second. The second 12 bits will come from the 3rd and half the 4th * byte. */ -void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, - long length, des_key_schedule *schedule, - des_cblock *ivec) +void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, + long length, DES_key_schedule *schedule, + DES_cblock *ivec) { register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8; register DES_LONG mask0,mask1; @@ -102,7 +102,7 @@ void des_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, { ti[0]=v0; ti[1]=v1; - des_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); + DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT); vv0=ti[0]; vv1=ti[1]; c2ln(in,d0,d1,n); diff --git a/crypto/des/pcbc_enc.c b/crypto/des/pcbc_enc.c index 62b2349afb..17a40f9520 100644 --- a/crypto/des/pcbc_enc.c +++ b/crypto/des/pcbc_enc.c @@ -58,9 +58,9 @@ #include "des_locl.h" -void des_pcbc_encrypt(const unsigned char *input, unsigned char *output, - long length, des_key_schedule *schedule, - des_cblock *ivec, int enc) +void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *schedule, + DES_cblock *ivec, int enc) { register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1; DES_LONG tin[2]; @@ -86,7 +86,7 @@ void des_pcbc_encrypt(const unsigned char *input, unsigned char *output, c2ln(in,sin0,sin1,length); tin[0]=sin0^xor0; tin[1]=sin1^xor1; - des_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); + DES_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT); tout0=tin[0]; tout1=tin[1]; xor0=sin0^tout0; @@ -104,7 +104,7 @@ void des_pcbc_encrypt(const unsigned char *input, unsigned char *output, c2l(in,sin1); tin[0]=sin0; tin[1]=sin1; - des_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT); + DES_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT); tout0=tin[0]^xor0; tout1=tin[1]^xor1; if (length >= 8) diff --git a/crypto/des/qud_cksm.c b/crypto/des/qud_cksm.c index 9fff989edb..dac201227e 100644 --- a/crypto/des/qud_cksm.c +++ b/crypto/des/qud_cksm.c @@ -73,8 +73,8 @@ /* Got the value MIT uses via brute force :-) 2/10/90 eay */ #define NOISE ((DES_LONG)83653421L) -DES_LONG des_quad_cksum(const unsigned char *input, des_cblock output[], - long length, int out_count, des_cblock *seed) +DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], + long length, int out_count, DES_cblock *seed) { DES_LONG z0,z1,t0,t1; int i; diff --git a/crypto/des/rand_key.c b/crypto/des/rand_key.c index ee1a6c274e..a617969f70 100644 --- a/crypto/des/rand_key.c +++ b/crypto/des/rand_key.c @@ -56,18 +56,18 @@ #include #include -void des_random_seed(des_cblock *key) +void DES_random_seed(DES_cblock *key) { - RAND_seed(key, sizeof(des_cblock)); + RAND_seed(key, sizeof(DES_cblock)); } -int des_random_key(des_cblock *ret) +int DES_random_key(DES_cblock *ret) { do { - if (RAND_bytes((unsigned char *)ret, sizeof(des_cblock)) != 1) + if (RAND_bytes((unsigned char *)ret, sizeof(DES_cblock)) != 1) return (0); - } while (des_is_weak_key(ret)); - des_set_odd_parity(ret); + } while (DES_is_weak_key(ret)); + DES_set_odd_parity(ret); return (1); } diff --git a/crypto/des/read2pwd.c b/crypto/des/read2pwd.c index a8ceaf088a..e7d8c12724 100644 --- a/crypto/des/read2pwd.c +++ b/crypto/des/read2pwd.c @@ -57,14 +57,21 @@ */ #include "des_locl.h" +#include int des_read_password(des_cblock *key, const char *prompt, int verify) { int ok; char buf[BUFSIZ],buff[BUFSIZ]; + UI *ui; - if ((ok=des_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) + ui = UI_new(); + UI_add_input_string(ui,prompt,0,buf,0,BUFSIZ-1); + if (verify) + UI_add_verify_string(ui,prompt,0,buff,0,BUFSIZ-1,buf); + if ((ok=UI_process(ui)) == 0) des_string_to_key(buf,key); + UI_free(ui); memset(buf,0,BUFSIZ); memset(buff,0,BUFSIZ); return(ok); @@ -75,9 +82,15 @@ int des_read_2passwords(des_cblock *key1, des_cblock *key2, const char *prompt, { int ok; char buf[BUFSIZ],buff[BUFSIZ]; + UI *ui; - if ((ok=des_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) + ui = UI_new(); + UI_add_input_string(ui,prompt,0,buf,0,BUFSIZ-1); + if (verify) + UI_add_verify_string(ui,prompt,0,buff,0,BUFSIZ-1,buf); + if ((ok=UI_process(ui)) == 0) des_string_to_2keys(buf,key1,key2); + UI_free(ui); memset(buf,0,BUFSIZ); memset(buff,0,BUFSIZ); return(ok); diff --git a/crypto/des/rpc_enc.c b/crypto/des/rpc_enc.c index 2a4a06672d..d937d08da5 100644 --- a/crypto/des/rpc_enc.c +++ b/crypto/des/rpc_enc.c @@ -63,19 +63,19 @@ int _des_crypt(char *buf,int len,struct desparams *desp); int _des_crypt(char *buf, int len, struct desparams *desp) { - des_key_schedule ks; + DES_key_schedule ks; int enc; - des_set_key_unchecked(&desp->des_key,&ks); + DES_set_key_unchecked(&desp->des_key,&ks); enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT; if (desp->des_mode == CBC) - des_ecb_encrypt((const_des_cblock *)desp->UDES.UDES_buf, - (des_cblock *)desp->UDES.UDES_buf,&ks, + DES_ecb_encrypt((const_DES_cblock *)desp->UDES.UDES_buf, + (DES_cblock *)desp->UDES.UDES_buf,&ks, enc); else { - des_ncbc_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf, + 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 diff --git a/crypto/des/rpw.c b/crypto/des/rpw.c index 0b6b1519b0..8a9473c4f9 100644 --- a/crypto/des/rpw.c +++ b/crypto/des/rpw.c @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) { - des_cblock k,k1; + DES_cblock k,k1; int i; printf("read passwd\n"); diff --git a/crypto/des/set_key.c b/crypto/des/set_key.c index 245b720a59..683916e71b 100644 --- a/crypto/des/set_key.c +++ b/crypto/des/set_key.c @@ -65,7 +65,7 @@ */ #include "des_locl.h" -OPENSSL_IMPLEMENT_GLOBAL(int,des_check_key); /* defaults to false */ +OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key); /* defaults to false */ static const unsigned char odd_parity[256]={ 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14, @@ -85,7 +85,7 @@ static const unsigned char odd_parity[256]={ 224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239, 241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254}; -void des_set_odd_parity(des_cblock *key) +void DES_set_odd_parity(DES_cblock *key) { int i; @@ -93,7 +93,7 @@ void des_set_odd_parity(des_cblock *key) (*key)[i]=odd_parity[(*key)[i]]; } -int des_check_key_parity(const_des_cblock *key) +int DES_check_key_parity(const_DES_cblock *key) { int i; @@ -115,7 +115,7 @@ int des_check_key_parity(const_des_cblock *key) * (and actual cblock values). */ #define NUM_WEAK_KEY 16 -static des_cblock weak_keys[NUM_WEAK_KEY]={ +static DES_cblock weak_keys[NUM_WEAK_KEY]={ /* weak keys */ {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}, {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE}, @@ -135,7 +135,7 @@ static des_cblock weak_keys[NUM_WEAK_KEY]={ {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE}, {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}}; -int des_is_weak_key(const_des_cblock *key) +int DES_is_weak_key(const_DES_cblock *key) { int i; @@ -146,7 +146,7 @@ int des_is_weak_key(const_des_cblock *key) * eay 93/06/29 * Another problem, I was comparing only the first 4 * bytes, 97/03/18 */ - if (memcmp(weak_keys[i],key,sizeof(des_cblock)) == 0) return(1); + if (memcmp(weak_keys[i],key,sizeof(DES_cblock)) == 0) return(1); return(0); } @@ -307,15 +307,15 @@ static const DES_LONG des_skb[8][64]={ 0x00002822L,0x04002822L,0x00042822L,0x04042822L, }}; -int des_set_key(const_des_cblock *key, des_key_schedule *schedule) +int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule) { - if (des_check_key) + if (DES_check_key) { - return des_set_key_checked(key, schedule); + return DES_set_key_checked(key, schedule); } else { - des_set_key_unchecked(key, schedule); + DES_set_key_unchecked(key, schedule); return 0; } } @@ -324,17 +324,17 @@ int des_set_key(const_des_cblock *key, des_key_schedule *schedule) * return -1 if key parity error, * return -2 if illegal weak key. */ -int des_set_key_checked(const_des_cblock *key, des_key_schedule *schedule) +int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule) { - if (!des_check_key_parity(key)) + if (!DES_check_key_parity(key)) return(-1); - if (des_is_weak_key(key)) + if (DES_is_weak_key(key)) return(-2); - des_set_key_unchecked(key, schedule); + DES_set_key_unchecked(key, schedule); return 0; } -void des_set_key_unchecked(const_des_cblock *key, des_key_schedule *schedule) +void DES_set_key_unchecked(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}; register DES_LONG c,d,t,s,t2; @@ -394,9 +394,9 @@ void des_set_key_unchecked(const_des_cblock *key, des_key_schedule *schedule) } } -int des_key_sched(const_des_cblock *key, des_key_schedule *schedule) +int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule) { - return(des_set_key(key,schedule)); + return(DES_set_key(key,schedule)); } /* #undef des_fixup_key_parity diff --git a/crypto/des/speed.c b/crypto/des/speed.c index 3dc7105916..48fc1d49fc 100644 --- a/crypto/des/speed.c +++ b/crypto/des/speed.c @@ -176,10 +176,10 @@ int main(int argc, char **argv) { long count; static unsigned char buf[BUFSIZE]; - 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; + 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; double a,b,c,d,e; #ifndef SIGALRM long ca,cb,cc,cd,ce; @@ -190,12 +190,12 @@ int main(int argc, char **argv) printf("program when this computer is idle.\n"); #endif - des_set_key_unchecked(&key2,sch2); - des_set_key_unchecked(&key3,sch3); + DES_set_key_unchecked(&key2,&sch2); + DES_set_key_unchecked(&key3,&sch3); #ifndef SIGALRM printf("First we calculate the approximate speed ...\n"); - des_set_key_unchecked(&key,sch); + DES_set_key_unchecked(&key,&sch); count=10; do { long i; @@ -204,7 +204,7 @@ int main(int argc, char **argv) count*=2; Time_F(START); for (i=count; i; i--) - des_encrypt1(data,&(sch[0]),DES_ENCRYPT); + DES_encrypt1(data,&sch,DES_ENCRYPT); d=Time_F(STOP); } while (d < 3.0); ca=count; @@ -225,63 +225,63 @@ int main(int argc, char **argv) Time_F(START); for (count=0,run=1; COND(ca); count++) - des_set_key_unchecked(&key,sch); + DES_set_key_unchecked(&key,&sch); d=Time_F(STOP); printf("%ld set_key's in %.2f seconds\n",count,d); a=((double)COUNT(ca))/d; #ifdef SIGALRM - printf("Doing des_encrypt's for 10 seconds\n"); + printf("Doing DES_encrypt's for 10 seconds\n"); alarm(10); #else - printf("Doing des_encrypt %ld times\n",cb); + printf("Doing DES_encrypt %ld times\n",cb); #endif Time_F(START); for (count=0,run=1; COND(cb); count++) { DES_LONG data[2]; - des_encrypt1(data,&(sch[0]),DES_ENCRYPT); + DES_encrypt1(data,&sch,DES_ENCRYPT); } 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); b=((double)COUNT(cb)*8)/d; #ifdef SIGALRM - printf("Doing des_cbc_encrypt on %ld byte blocks for 10 seconds\n", + printf("Doing DES_cbc_encrypt on %ld byte blocks for 10 seconds\n", BUFSIZE); alarm(10); #else - printf("Doing des_cbc_encrypt %ld times on %ld byte blocks\n",cc, + printf("Doing DES_cbc_encrypt %ld times on %ld byte blocks\n",cc, BUFSIZE); #endif Time_F(START); for (count=0,run=1; COND(cc); count++) - des_ncbc_encrypt(buf,buf,BUFSIZE,&(sch[0]), + DES_ncbc_encrypt(buf,buf,BUFSIZE,&sch, &key,DES_ENCRYPT); d=Time_F(STOP); - printf("%ld des_cbc_encrypt's of %ld byte blocks in %.2f second\n", + printf("%ld DES_cbc_encrypt's of %ld byte blocks in %.2f second\n", count,BUFSIZE,d); c=((double)COUNT(cc)*BUFSIZE)/d; #ifdef SIGALRM - printf("Doing des_ede_cbc_encrypt on %ld byte blocks for 10 seconds\n", + printf("Doing DES_ede_cbc_encrypt on %ld byte blocks for 10 seconds\n", BUFSIZE); alarm(10); #else - printf("Doing des_ede_cbc_encrypt %ld times on %ld byte blocks\n",cd, + printf("Doing DES_ede_cbc_encrypt %ld times on %ld byte blocks\n",cd, BUFSIZE); #endif Time_F(START); for (count=0,run=1; COND(cd); count++) - des_ede3_cbc_encrypt(buf,buf,BUFSIZE, - &(sch[0]), - &(sch2[0]), - &(sch3[0]), + DES_ede3_cbc_encrypt(buf,buf,BUFSIZE, + &sch, + &sch2, + &sch3, &key, DES_ENCRYPT); d=Time_F(STOP); - printf("%ld des_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n", + printf("%ld DES_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n", count,BUFSIZE,d); d=((double)COUNT(cd)*BUFSIZE)/d; diff --git a/crypto/des/str2key.c b/crypto/des/str2key.c index ab1d8d1166..f69bef3a6e 100644 --- a/crypto/des/str2key.c +++ b/crypto/des/str2key.c @@ -58,9 +58,9 @@ #include "des_locl.h" -void des_string_to_key(const char *str, des_cblock *key) +void DES_string_to_key(const char *str, DES_cblock *key) { - des_key_schedule ks; + DES_key_schedule ks; int i,length; register unsigned char j; @@ -85,16 +85,16 @@ void des_string_to_key(const char *str, des_cblock *key) } } #endif - des_set_odd_parity(key); - des_set_key_unchecked(key,&ks); - des_cbc_cksum((const unsigned char*)str,key,length,&ks,key); + DES_set_odd_parity(key); + DES_set_key_unchecked(key,&ks); + DES_cbc_cksum((const unsigned char*)str,key,length,&ks,key); memset(&ks,0,sizeof(ks)); - des_set_odd_parity(key); + DES_set_odd_parity(key); } -void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2) +void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2) { - des_key_schedule ks; + DES_key_schedule ks; int i,length; register unsigned char j; @@ -143,13 +143,13 @@ void des_string_to_2keys(const char *str, des_cblock *key1, des_cblock *key2) } if (length <= 8) memcpy(key2,key1,8); #endif - des_set_odd_parity(key1); - des_set_odd_parity(key2); - des_set_key_unchecked(key1,&ks); - des_cbc_cksum((const unsigned char*)str,key1,length,&ks,key1); - des_set_key_unchecked(key2,&ks); - des_cbc_cksum((const unsigned char*)str,key2,length,&ks,key2); + DES_set_odd_parity(key1); + DES_set_odd_parity(key2); + DES_set_key_unchecked(key1,&ks); + DES_cbc_cksum((const unsigned char*)str,key1,length,&ks,key1); + DES_set_key_unchecked(key2,&ks); + DES_cbc_cksum((const unsigned char*)str,key2,length,&ks,key2); memset(&ks,0,sizeof(ks)); - des_set_odd_parity(key1); - des_set_odd_parity(key2); + DES_set_odd_parity(key1); + DES_set_odd_parity(key2); } diff --git a/crypto/des/xcbc_enc.c b/crypto/des/xcbc_enc.c index bb910a080d..47246eb466 100644 --- a/crypto/des/xcbc_enc.c +++ b/crypto/des/xcbc_enc.c @@ -79,8 +79,8 @@ static unsigned char desx_white_in2out[256]={ 0xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB, }; -void des_xwhite_in2out(const_des_cblock *des_key, const_des_cblock *in_white, - des_cblock *out_white) +void DES_xwhite_in2out(const_DES_cblock *des_key, const_DES_cblock *in_white, + DES_cblock *out_white) { int out0,out1; int i; @@ -107,10 +107,10 @@ void des_xwhite_in2out(const_des_cblock *des_key, const_des_cblock *in_white, } } -void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, - long length, des_key_schedule *schedule, - des_cblock *ivec, const_des_cblock *inw, - const_des_cblock *outw, int enc) +void DES_xcbc_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *schedule, + 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; @@ -139,7 +139,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, c2l(in,tin1); tin0^=tout0^inW0; tin[0]=tin0; tin1^=tout1^inW1; tin[1]=tin1; - des_encrypt1(tin,schedule,DES_ENCRYPT); + DES_encrypt1(tin,schedule,DES_ENCRYPT); tout0=tin[0]^outW0; l2c(tout0,out); tout1=tin[1]^outW1; l2c(tout1,out); } @@ -148,7 +148,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, c2ln(in,tin0,tin1,l+8); tin0^=tout0^inW0; tin[0]=tin0; tin1^=tout1^inW1; tin[1]=tin1; - des_encrypt1(tin,schedule,DES_ENCRYPT); + DES_encrypt1(tin,schedule,DES_ENCRYPT); tout0=tin[0]^outW0; l2c(tout0,out); tout1=tin[1]^outW1; l2c(tout1,out); } @@ -164,7 +164,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, { c2l(in,tin0); tin[0]=tin0^outW0; c2l(in,tin1); tin[1]=tin1^outW1; - des_encrypt1(tin,schedule,DES_DECRYPT); + DES_encrypt1(tin,schedule,DES_DECRYPT); tout0=tin[0]^xor0^inW0; tout1=tin[1]^xor1^inW1; l2c(tout0,out); @@ -176,7 +176,7 @@ void des_xcbc_encrypt(const unsigned char *in, unsigned char *out, { c2l(in,tin0); tin[0]=tin0^outW0; c2l(in,tin1); tin[1]=tin1^outW1; - des_encrypt1(tin,schedule,DES_DECRYPT); + DES_encrypt1(tin,schedule,DES_DECRYPT); tout0=tin[0]^xor0^inW0; tout1=tin[1]^xor1^inW1; l2cn(tout0,tout1,out,l+8); diff --git a/crypto/evp/e_des.c b/crypto/evp/e_des.c index ed2594311f..3e2cf30a6b 100644 --- a/crypto/evp/e_des.c +++ b/crypto/evp/e_des.c @@ -73,34 +73,34 @@ static int des_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) { BLOCK_CIPHER_ecb_loop() - des_ecb_encrypt((des_cblock *)(in + i), (des_cblock *)(out + i), ctx->cipher_data, ctx->encrypt); + DES_ecb_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), ctx->cipher_data, ctx->encrypt); return 1; } static int des_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) { - des_ofb64_encrypt(in, out, (long)inl, ctx->cipher_data, (des_cblock *)ctx->iv, &ctx->num); + DES_ofb64_encrypt(in, out, (long)inl, ctx->cipher_data, (DES_cblock *)ctx->iv, &ctx->num); return 1; } static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) { - des_ncbc_encrypt(in, out, (long)inl, ctx->cipher_data, - (des_cblock *)ctx->iv, ctx->encrypt); + DES_ncbc_encrypt(in, out, (long)inl, ctx->cipher_data, + (DES_cblock *)ctx->iv, ctx->encrypt); return 1; } static int des_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) { - des_cfb64_encrypt(in, out, (long)inl, ctx->cipher_data, - (des_cblock *)ctx->iv, &ctx->num, ctx->encrypt); + DES_cfb64_encrypt(in, out, (long)inl, ctx->cipher_data, + (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); return 1; } -BLOCK_CIPHER_defs(des, des_key_schedule, NID_des, 8, 8, 8, +BLOCK_CIPHER_defs(des, DES_key_schedule, NID_des, 8, 8, 8, 0, des_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, @@ -110,9 +110,9 @@ BLOCK_CIPHER_defs(des, des_key_schedule, NID_des, 8, 8, 8, static int des_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { - des_cblock *deskey = (des_cblock *)key; + DES_cblock *deskey = (DES_cblock *)key; - des_set_key_unchecked(deskey,ctx->cipher_data); + DES_set_key_unchecked(deskey,ctx->cipher_data); return 1; } diff --git a/crypto/evp/e_des3.c b/crypto/evp/e_des3.c index 7a18cb618b..13b396c5d2 100644 --- a/crypto/evp/e_des3.c +++ b/crypto/evp/e_des3.c @@ -72,9 +72,9 @@ static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, typedef struct { - des_key_schedule ks1;/* key schedule */ - des_key_schedule ks2;/* key schedule (for ede) */ - des_key_schedule ks3;/* key schedule (for ede3) */ + DES_key_schedule ks1;/* key schedule */ + DES_key_schedule ks2;/* key schedule (for ede) */ + DES_key_schedule ks3;/* key schedule (for ede3) */ } DES_EDE_KEY; #define data(ctx) ((DES_EDE_KEY *)(ctx)->cipher_data) @@ -85,7 +85,7 @@ static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) { BLOCK_CIPHER_ecb_loop() - des_ecb3_encrypt((des_cblock *)(in + i), (des_cblock *)(out + i), + DES_ecb3_encrypt((DES_cblock *)(in + i), (DES_cblock *)(out + i), &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, ctx->encrypt); @@ -95,9 +95,9 @@ static int des_ede_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, static int des_ede_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) { - des_ede3_ofb64_encrypt(in, out, (long)inl, + DES_ede3_ofb64_encrypt(in, out, (long)inl, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, - (des_cblock *)ctx->iv, &ctx->num); + (DES_cblock *)ctx->iv, &ctx->num); return 1; } @@ -115,18 +115,18 @@ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, printf("\n"); } #endif /* KSSL_DEBUG */ - des_ede3_cbc_encrypt(in, out, (long)inl, + DES_ede3_cbc_encrypt(in, out, (long)inl, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, - (des_cblock *)ctx->iv, ctx->encrypt); + (DES_cblock *)ctx->iv, ctx->encrypt); return 1; } static int des_ede_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) { - des_ede3_cfb64_encrypt(in, out, (long)inl, + DES_ede3_cfb64_encrypt(in, out, (long)inl, &data(ctx)->ks1, &data(ctx)->ks2, &data(ctx)->ks3, - (des_cblock *)ctx->iv, &ctx->num, ctx->encrypt); + (DES_cblock *)ctx->iv, &ctx->num, ctx->encrypt); return 1; } @@ -150,10 +150,10 @@ BLOCK_CIPHER_defs(des_ede3, DES_EDE_KEY, NID_des_ede3, 8, 24, 8, static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { - des_cblock *deskey = (des_cblock *)key; + DES_cblock *deskey = (DES_cblock *)key; - des_set_key_unchecked(&deskey[0],&data(ctx)->ks1); - des_set_key_unchecked(&deskey[1],&data(ctx)->ks2); + DES_set_key_unchecked(&deskey[0],&data(ctx)->ks1); + DES_set_key_unchecked(&deskey[1],&data(ctx)->ks2); memcpy(&data(ctx)->ks3,&data(ctx)->ks1, sizeof(data(ctx)->ks1)); return 1; @@ -162,7 +162,7 @@ static int des_ede_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { - des_cblock *deskey = (des_cblock *)key; + DES_cblock *deskey = (DES_cblock *)key; #ifdef KSSL_DEBUG { int i; @@ -174,9 +174,9 @@ static int des_ede3_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, } #endif /* KSSL_DEBUG */ - des_set_key_unchecked(&deskey[0],&data(ctx)->ks1); - des_set_key_unchecked(&deskey[1],&data(ctx)->ks2); - des_set_key_unchecked(&deskey[2],&data(ctx)->ks3); + DES_set_key_unchecked(&deskey[0],&data(ctx)->ks1); + DES_set_key_unchecked(&deskey[1],&data(ctx)->ks2); + DES_set_key_unchecked(&deskey[2],&data(ctx)->ks3); return 1; } diff --git a/crypto/evp/e_xcbc_d.c b/crypto/evp/e_xcbc_d.c index ab94630fd2..a6f849e93d 100644 --- a/crypto/evp/e_xcbc_d.c +++ b/crypto/evp/e_xcbc_d.c @@ -71,9 +71,9 @@ static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, typedef struct { - des_key_schedule ks;/* key schedule */ - des_cblock inw; - des_cblock outw; + DES_key_schedule ks;/* key schedule */ + DES_cblock inw; + DES_cblock outw; } DESX_CBC_KEY; #define data(ctx) ((DESX_CBC_KEY *)(ctx)->cipher_data) @@ -100,9 +100,9 @@ const EVP_CIPHER *EVP_desx_cbc(void) static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { - des_cblock *deskey = (des_cblock *)key; + DES_cblock *deskey = (DES_cblock *)key; - des_set_key_unchecked(deskey,&data(ctx)->ks); + DES_set_key_unchecked(deskey,&data(ctx)->ks); memcpy(&data(ctx)->inw[0],&key[8],8); memcpy(&data(ctx)->outw[0],&key[16],8); @@ -112,8 +112,8 @@ static int desx_cbc_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) { - des_xcbc_encrypt(in,out,inl,&data(ctx)->ks, - (des_cblock *)&(ctx->iv[0]), + DES_xcbc_encrypt(in,out,inl,&data(ctx)->ks, + (DES_cblock *)&(ctx->iv[0]), &data(ctx)->inw, &data(ctx)->outw, ctx->encrypt); diff --git a/crypto/install.com b/crypto/install.com index 29763391e1..10e1847c25 100644 --- a/crypto/install.com +++ b/crypto/install.com @@ -47,7 +47,7 @@ $ EXHEADER_SHA := sha.h $ EXHEADER_MDC2 := mdc2.h $ EXHEADER_HMAC := hmac.h $ EXHEADER_RIPEMD := ripemd.h -$ EXHEADER_DES := des.h +$ EXHEADER_DES := des.h,des_old.h $ EXHEADER_RC2 := rc2.h $ EXHEADER_RC4 := rc4.h $ EXHEADER_RC5 := rc5.h diff --git a/crypto/mdc2/mdc2.h b/crypto/mdc2/mdc2.h index c4a81831bf..793a8a0f13 100644 --- a/crypto/mdc2/mdc2.h +++ b/crypto/mdc2/mdc2.h @@ -76,7 +76,7 @@ typedef struct mdc2_ctx_st { int num; unsigned char data[MDC2_BLOCK]; - des_cblock h,hh; + DES_cblock h,hh; int pad_type; /* either 1 or 2, default 1 */ } MDC2_CTX; diff --git a/crypto/mdc2/mdc2dgst.c b/crypto/mdc2/mdc2dgst.c index 88dd4e250b..32daa9b0da 100644 --- a/crypto/mdc2/mdc2dgst.c +++ b/crypto/mdc2/mdc2dgst.c @@ -125,7 +125,7 @@ static void mdc2_body(MDC2_CTX *c, const unsigned char *in, unsigned int len) register DES_LONG tin0,tin1; register DES_LONG ttin0,ttin1; DES_LONG d[2],dd[2]; - des_key_schedule k; + DES_key_schedule k; unsigned char *p; unsigned int i; @@ -136,13 +136,13 @@ static void mdc2_body(MDC2_CTX *c, const unsigned char *in, unsigned int len) c->h[0]=(c->h[0]&0x9f)|0x40; c->hh[0]=(c->hh[0]&0x9f)|0x20; - des_set_odd_parity(&c->h); - des_set_key_unchecked(&c->h,&k); - des_encrypt1(d,&k,1); + DES_set_odd_parity(&c->h); + DES_set_key_unchecked(&c->h,&k); + DES_encrypt1(d,&k,1); - des_set_odd_parity(&c->hh); - des_set_key_unchecked(&c->hh,&k); - des_encrypt1(dd,&k,1); + DES_set_odd_parity(&c->hh); + DES_set_key_unchecked(&c->hh,&k); + DES_encrypt1(dd,&k,1); ttin0=tin0^dd[0]; ttin1=tin1^dd[1]; diff --git a/crypto/symhacks.h b/crypto/symhacks.h index c7f39cfa81..b4eaa29e19 100644 --- a/crypto/symhacks.h +++ b/crypto/symhacks.h @@ -256,6 +256,45 @@ #undef X509v3_add_standard_extensions #define X509v3_add_standard_extensions oX509v3_add_standard_extensions +/* The following hacks is to make sure that the old des_ functions do not + clash with the new DES_ functions */ +#define des_options odes_options +#define des_ecb3_encrypt odes_ecb3_encrypt +#define des_cbc_cksum odes_cbc_cksum +#define des_cbc_encrypt odes_cbc_encrypt +#define des_ncbc_encrypt odes_ncbc_encrypt +#define des_xcbc_encrypt odes_xcbc_encrypt +#define des_3cbc_encrypt odes_3cbc_encrypt +#define des_cfb_encrypt odes_cfb_encrypt +#define des_ecb_encrypt odes_ecb_encrypt +#define des_encrypt odes_encrypt +#define des_encrypt2 odes_encrypt2 +#define des_encrypt3 odes_encrypt3 +#define des_decrypt3 odes_decrypt3 +#define des_ede3_cbc_encrypt odes_ede3_cbc_encrypt +#define des_ede3_cfb64_encrypt odes_ede3_cfb64_encrypt +#define des_ede3_ofb64_encrypt odes_ede3_ofb64_encrypt +#define des_xwhite_in2out odes_xwhite_in2out +#define des_enc_read odes_enc_read +#define des_enc_write odes_enc_write +#define des_fcrypt odes_fcrypt +#define des_crypt odes_crypt +#define crypt ocrypt +#define des_ofb_encrypt odes_ofb_encrypt +#define des_pcbc_encrypt odes_pcbc_encrypt +#define des_quad_cksum odes_quad_cksum +#define des_random_seed odes_random_seed +#define des_random_key odes_random_key +#define des_set_odd_parity odes_set_odd_parity +#define des_is_weak_key odes_is_weak_key +#define des_set_key odes_set_key +#define des_key_sched odes_key_sched +#define des_string_to_key odes_string_to_key +#define des_string_to_2keys odes_string_to_2keys +#define des_cfb64_encrypt odes_cfb64_encrypt +#define des_ofb64_encrypt odes_ofb64_encrypt + + #endif diff --git a/crypto/ui/ui_compat.c b/crypto/ui/ui_compat.c index 701c07c181..2b4429416f 100644 --- a/crypto/ui/ui_compat.c +++ b/crypto/ui/ui_compat.c @@ -61,26 +61,26 @@ #include #ifndef OPENSSL_NO_DES -int des_read_password(des_cblock *key, const char *prompt, int verify) +int des_read_password(DES_cblock *key, const char *prompt, int verify) { int ok; char buf[BUFSIZ],buff[BUFSIZ]; if ((ok=des_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) - des_string_to_key(buf,key); + DES_string_to_key(buf,key); memset(buf,0,BUFSIZ); memset(buff,0,BUFSIZ); return(ok); } -int des_read_2passwords(des_cblock *key1, des_cblock *key2, const char *prompt, +int des_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt, int verify) { int ok; char buf[BUFSIZ],buff[BUFSIZ]; if ((ok=des_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) - des_string_to_2keys(buf,key1,key2); + DES_string_to_2keys(buf,key1,key2); memset(buf,0,BUFSIZ); memset(buff,0,BUFSIZ); return(ok); diff --git a/crypto/ui/ui_compat.h b/crypto/ui/ui_compat.h index 6e547b6ceb..a7f62a4751 100644 --- a/crypto/ui/ui_compat.h +++ b/crypto/ui/ui_compat.h @@ -73,8 +73,8 @@ extern "C" { and are provided here for backward compatibility reasons. */ #ifndef OPENSSL_NO_DES -int des_read_password(des_cblock *key,const char *prompt,int verify); -int des_read_2passwords(des_cblock *key1,des_cblock *key2, +int des_read_password(DES_cblock *key,const char *prompt,int verify); +int des_read_2passwords(DES_cblock *key1,DES_cblock *key2, const char *prompt,int verify); #endif diff --git a/doc/crypto/des.pod b/doc/crypto/des.pod index 792149270c..23f59b670e 100644 --- a/doc/crypto/des.pod +++ b/doc/crypto/des.pod @@ -2,113 +2,112 @@ =head1 NAME -des_random_key, des_set_key, des_key_sched, des_set_key_checked, -des_set_key_unchecked, des_set_odd_parity, des_is_weak_key, -des_ecb_encrypt, des_ecb2_encrypt, des_ecb3_encrypt, des_ncbc_encrypt, -des_cfb_encrypt, des_ofb_encrypt, des_pcbc_encrypt, des_cfb64_encrypt, -des_ofb64_encrypt, des_xcbc_encrypt, des_ede2_cbc_encrypt, -des_ede2_cfb64_encrypt, des_ede2_ofb64_encrypt, des_ede3_cbc_encrypt, -des_ede3_cbcm_encrypt, des_ede3_cfb64_encrypt, des_ede3_ofb64_encrypt, -des_read_password, des_read_2passwords, des_read_pw_string, -des_cbc_cksum, des_quad_cksum, des_string_to_key, des_string_to_2keys, -des_fcrypt, des_crypt, des_enc_read, des_enc_write - DES encryption +DES_random_key, DES_set_key, DES_key_sched, DES_set_key_checked, +DES_set_key_unchecked, DES_set_odd_parity, DES_is_weak_key, +DES_ecb_encrypt, DES_ecb2_encrypt, DES_ecb3_encrypt, DES_ncbc_encrypt, +DES_cfb_encrypt, DES_ofb_encrypt, DES_pcbc_encrypt, DES_cfb64_encrypt, +DES_ofb64_encrypt, DES_xcbc_encrypt, DES_ede2_cbc_encrypt, +DES_ede2_cfb64_encrypt, DES_ede2_ofb64_encrypt, DES_ede3_cbc_encrypt, +DES_ede3_cbcm_encrypt, DES_ede3_cfb64_encrypt, DES_ede3_ofb64_encrypt, +DES_read_password, DES_read_2passwords, DES_read_pw_string, +DES_cbc_cksum, DES_quad_cksum, DES_string_to_key, DES_string_to_2keys, +DES_fcrypt, DES_crypt, DES_enc_read, DES_enc_write - DES encryption =head1 SYNOPSIS #include - void des_random_key(des_cblock *ret); + void DES_random_key(DES_cblock *ret); - int des_set_key(const_des_cblock *key, des_key_schedule *schedule); - int des_key_sched(const_des_cblock *key, des_key_schedule *schedule); - int des_set_key_checked(const_des_cblock *key, - des_key_schedule *schedule); - void des_set_key_unchecked(const_des_cblock *key, - des_key_schedule *schedule); + int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule); + int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule); + int DES_set_key_checked(const_DES_cblock *key, + DES_key_schedule *schedule); + void DES_set_key_unchecked(const_DES_cblock *key, + DES_key_schedule *schedule); - void des_set_odd_parity(des_cblock *key); - int des_is_weak_key(const_des_cblock *key); + void DES_set_odd_parity(DES_cblock *key); + int DES_is_weak_key(const_DES_cblock *key); - void des_ecb_encrypt(const_des_cblock *input, des_cblock *output, - des_key_schedule *ks, int enc); - void des_ecb2_encrypt(const_des_cblock *input, des_cblock *output, - des_key_schedule *ks1, des_key_schedule *ks2, int enc); - void des_ecb3_encrypt(const_des_cblock *input, des_cblock *output, - des_key_schedule *ks1, des_key_schedule *ks2, - des_key_schedule *ks3, int enc); + void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, + DES_key_schedule *ks, int enc); + void DES_ecb2_encrypt(const_DES_cblock *input, DES_cblock *output, + DES_key_schedule *ks1, DES_key_schedule *ks2, int enc); + void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, + DES_key_schedule *ks1, DES_key_schedule *ks2, + DES_key_schedule *ks3, int enc); - void des_ncbc_encrypt(const unsigned char *input, unsigned char *output, - long length, des_key_schedule *schedule, des_cblock *ivec, + void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *schedule, DES_cblock *ivec, int enc); - void des_cfb_encrypt(const unsigned char *in, unsigned char *out, - int numbits, long length, des_key_schedule *schedule, - des_cblock *ivec, int enc); - void des_ofb_encrypt(const unsigned char *in, unsigned char *out, - int numbits, long length, des_key_schedule *schedule, - des_cblock *ivec); - void des_pcbc_encrypt(const unsigned char *input, unsigned char *output, - long length, des_key_schedule *schedule, des_cblock *ivec, + void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, + int numbits, long length, DES_key_schedule *schedule, + DES_cblock *ivec, int enc); + void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, + int numbits, long length, DES_key_schedule *schedule, + DES_cblock *ivec); + void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *schedule, DES_cblock *ivec, int enc); - void des_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, des_key_schedule *schedule, des_cblock *ivec, + void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *schedule, DES_cblock *ivec, int *num, int enc); - void des_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, des_key_schedule *schedule, des_cblock *ivec, + void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *schedule, DES_cblock *ivec, int *num); - void des_xcbc_encrypt(const unsigned char *input, unsigned char *output, - long length, des_key_schedule *schedule, des_cblock *ivec, - const_des_cblock *inw, const_des_cblock *outw, int enc); - - void des_ede2_cbc_encrypt(const unsigned char *input, - unsigned char *output, long length, des_key_schedule *ks1, - des_key_schedule *ks2, des_cblock *ivec, int enc); - void des_ede2_cfb64_encrypt(const unsigned char *in, - unsigned char *out, long length, des_key_schedule *ks1, - des_key_schedule *ks2, des_cblock *ivec, int *num, int enc); - void des_ede2_ofb64_encrypt(const unsigned char *in, - unsigned char *out, long length, des_key_schedule *ks1, - des_key_schedule *ks2, des_cblock *ivec, int *num); - - void des_ede3_cbc_encrypt(const unsigned char *input, - unsigned char *output, long length, des_key_schedule *ks1, - des_key_schedule *ks2, des_key_schedule *ks3, des_cblock *ivec, + void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output, + long length, DES_key_schedule *schedule, DES_cblock *ivec, + const_DES_cblock *inw, const_DES_cblock *outw, int enc); + + void DES_ede2_cbc_encrypt(const unsigned char *input, + unsigned char *output, long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_cblock *ivec, int enc); + void DES_ede2_cfb64_encrypt(const unsigned char *in, + unsigned char *out, long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_cblock *ivec, int *num, int enc); + void DES_ede2_ofb64_encrypt(const unsigned char *in, + unsigned char *out, long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_cblock *ivec, int *num); + + void DES_ede3_cbc_encrypt(const unsigned char *input, + unsigned char *output, long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec, int enc); - 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, des_cblock *ivec1, des_cblock *ivec2, + 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, DES_cblock *ivec1, DES_cblock *ivec2, int enc); - void des_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, des_key_schedule *ks1, des_key_schedule *ks2, - des_key_schedule *ks3, des_cblock *ivec, int *num, int enc); - void des_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, des_key_schedule *ks1, - des_key_schedule *ks2, des_key_schedule *ks3, - des_cblock *ivec, int *num); - - int des_read_password(des_cblock *key, const char *prompt, int verify); - int des_read_2passwords(des_cblock *key1, des_cblock *key2, + void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *ks1, DES_key_schedule *ks2, + DES_key_schedule *ks3, DES_cblock *ivec, int *num, int enc); + void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, + long length, DES_key_schedule *ks1, + DES_key_schedule *ks2, DES_key_schedule *ks3, + DES_cblock *ivec, int *num); + + int DES_read_password(DES_cblock *key, const char *prompt, int verify); + int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt, int verify); - int des_read_pw_string(char *buf, int length, const char *prompt, + int DES_read_pw_string(char *buf, int length, const char *prompt, int verify); - DES_LONG des_cbc_cksum(const unsigned char *input, des_cblock *output, - long length, des_key_schedule *schedule, - const_des_cblock *ivec); - DES_LONG des_quad_cksum(const unsigned char *input, des_cblock output[], - long length, int out_count, des_cblock *seed); - void des_string_to_key(const char *str, des_cblock *key); - void des_string_to_2keys(const char *str, des_cblock *key1, - des_cblock *key2); + DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output, + long length, DES_key_schedule *schedule, + const_DES_cblock *ivec); + DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], + long length, int out_count, DES_cblock *seed); + void DES_string_to_key(const char *str, DES_cblock *key); + void DES_string_to_2keys(const char *str, DES_cblock *key1, + DES_cblock *key2); - char *des_fcrypt(const char *buf, const char *salt, char *ret); - char *des_crypt(const char *buf, const char *salt); - char *crypt(const char *buf, const char *salt); + char *DES_fcrypt(const char *buf, const char *salt, char *ret); + char *DES_crypt(const char *buf, const char *salt); - int des_enc_read(int fd, void *buf, int len, des_key_schedule *sched, - des_cblock *iv); - int des_enc_write(int fd, const void *buf, int len, - des_key_schedule *sched, des_cblock *iv); + int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched, + DES_cblock *iv); + int DES_enc_write(int fd, const void *buf, int len, + DES_key_schedule *sched, DES_cblock *iv); =head1 DESCRIPTION @@ -116,56 +115,56 @@ This library contains a fast implementation of the DES encryption algorithm. There are two phases to the use of DES encryption. The first is the -generation of a I from a key, the second is the -actual encryption. A DES key is of type I. This type is +generation of a I from a key, the second is the +actual encryption. A DES key is of type I. This type is consists of 8 bytes with odd parity. The least significant bit in each byte is the parity bit. The key schedule is an expanded form of the key; it is used to speed the encryption process. -des_random_key() generates a random key. The PRNG must be seeded +DES_random_key() generates a random key. The PRNG must be seeded prior to using this function (see L; for backward -compatibility the function des_random_seed() is available as well). +compatibility the function DES_random_seed() is available as well). If the PRNG could not generate a secure key, 0 is returned. In -earlier versions of the library, des_random_key() did not generate +earlier versions of the library, DES_random_key() did not generate secure keys. Before a DES key can be used, it must be converted into the -architecture dependent I via the -des_set_key_checked() or des_set_key_unchecked() function. +architecture dependent I via the +DES_set_key_checked() or DES_set_key_unchecked() function. -des_set_key_checked() will check that the key passed is of odd parity +DES_set_key_checked() will check that the key passed is of odd parity and is not a week or semi-weak key. If the parity is wrong, then -1 is returned. If the key is a weak key, then -2 is returned. If an error is returned, the key schedule is not generated. -des_set_key() (called des_key_sched() in the MIT library) works like -des_set_key_checked() if the I flag is non-zero, -otherwise like des_set_key_unchecked(). These functions are available +DES_set_key() (called DES_key_sched() in the MIT library) works like +DES_set_key_checked() if the I flag is non-zero, +otherwise like DES_set_key_unchecked(). These functions are available for compatibility; it is recommended to use a function that does not depend on a global variable. -des_set_odd_parity() (called des_fixup_key_parity() in the MIT +DES_set_odd_parity() (called DES_fixup_key_parity() in the MIT library) sets the parity of the passed I to odd. -des_is_weak_key() returns 1 is the passed key is a weak key, 0 if it +DES_is_weak_key() returns 1 is the passed key is a weak key, 0 if it is ok. The probability that a randomly generated key is weak is 1/2^52, so it is not really worth checking for them. The following routines mostly operate on an input and output stream of -Is. +Is. -des_ecb_encrypt() is the basic DES encryption routine that encrypts or -decrypts a single 8-byte I in I +DES_ecb_encrypt() is the basic DES encryption routine that encrypts or +decrypts a single 8-byte I in I (ECB) mode. It always transforms the input data, pointed to by I, into the output data, pointed to by the I argument. If the I argument is non-zero (DES_ENCRYPT), the I (cleartext) is encrypted in to the I (ciphertext) using the key_schedule specified by the I argument, previously set via -I. If I is zero (DES_DECRYPT), the I (now +I. If I is zero (DES_DECRYPT), the I (now ciphertext) is decrypted into the I (now cleartext). Input -and output may overlap. des_ecb_encrypt() does not return a value. +and output may overlap. DES_ecb_encrypt() does not return a value. -des_ecb3_encrypt() encrypts/decrypts the I block by using +DES_ecb3_encrypt() encrypts/decrypts the I block by using three-key Triple-DES encryption in ECB mode. This involves encrypting the input with I, decrypting with the key schedule I, and then encrypting with I. This routine greatly reduces the chances @@ -173,10 +172,10 @@ of brute force breaking of DES and has the advantage of if I, I and I are the same, it is equivalent to just encryption using ECB mode and I as the key. -The macro des_ecb2_encrypt() is provided to perform two-key Triple-DES +The macro DES_ecb2_encrypt() is provided to perform two-key Triple-DES encryption by using I for the final encryption. -des_ncbc_encrypt() encrypts/decrypts using the I +DES_ncbc_encrypt() encrypts/decrypts using the I (CBC) mode of DES. If the I argument is non-zero, the routine cipher-block-chain encrypts the cleartext data pointed to by the I argument into the ciphertext pointed to by the I @@ -186,24 +185,24 @@ I argument is not an integral multiple of eight bytes, the last block is copied to a temporary area and zero filled. The output is always an integral multiple of eight bytes. -des_xcbc_encrypt() is RSA's DESX mode of DES. It uses I and +DES_xcbc_encrypt() is RSA's DESX mode of DES. It uses I and I to 'whiten' the encryption. I and I are secret (unlike the iv) and are as such, part of the key. So the key is sort of 24 bytes. This is much better than CBC DES. -des_ede3_cbc_encrypt() implements outer triple CBC DES encryption with +DES_ede3_cbc_encrypt() implements outer triple CBC DES encryption with three keys. This means that each DES operation inside the CBC mode is really an C. This mode is used by SSL. -The des_ede2_cbc_encrypt() macro implements two-key Triple-DES by +The DES_ede2_cbc_encrypt() macro implements two-key Triple-DES by reusing I for the final encryption. C. This form of Triple-DES is used by the RSAREF library. -des_pcbc_encrypt() encrypt/decrypts using the propagating cipher block +DES_pcbc_encrypt() encrypt/decrypts using the propagating cipher block chaining mode used by Kerberos v4. Its parameters are the same as -des_ncbc_encrypt(). +DES_ncbc_encrypt(). -des_cfb_encrypt() encrypt/decrypts using cipher feedback mode. This +DES_cfb_encrypt() encrypt/decrypts using cipher feedback mode. This method takes an array of characters as input and outputs and array of characters. It does not require any padding to 8 character groups. Note: the I variable is changed and the new changed value needs to @@ -211,7 +210,7 @@ be passed to the next call to this function. Since this function runs a complete DES ECB encryption per I, this function is only suggested for use when sending small numbers of characters. -des_cfb64_encrypt() +DES_cfb64_encrypt() implements CFB mode of DES with 64bit feedback. Why is this useful you ask? Because this routine will allow you to encrypt an arbitrary number of bytes, no 8 byte padding. Each call to this @@ -219,10 +218,10 @@ routine will encrypt the input bytes to output and then update ivec and num. num contains 'how far' we are though ivec. If this does not make much sense, read more about cfb mode of DES :-). -des_ede3_cfb64_encrypt() and des_ede2_cfb64_encrypt() is the same as -des_cfb64_encrypt() except that Triple-DES is used. +DES_ede3_cfb64_encrypt() and DES_ede2_cfb64_encrypt() is the same as +DES_cfb64_encrypt() except that Triple-DES is used. -des_ofb_encrypt() encrypts using output feedback mode. This method +DES_ofb_encrypt() encrypts using output feedback mode. This method takes an array of characters as input and outputs and array of characters. It does not require any padding to 8 character groups. Note: the I variable is changed and the new changed value needs to @@ -230,17 +229,17 @@ be passed to the next call to this function. Since this function runs a complete DES ECB encryption per numbits, this function is only suggested for use when sending small numbers of characters. -des_ofb64_encrypt() is the same as des_cfb64_encrypt() using Output +DES_ofb64_encrypt() is the same as DES_cfb64_encrypt() using Output Feed Back mode. -des_ede3_ofb64_encrypt() and des_ede2_ofb64_encrypt() is the same as -des_ofb64_encrypt(), using Triple-DES. +DES_ede3_ofb64_encrypt() and DES_ede2_ofb64_encrypt() is the same as +DES_ofb64_encrypt(), using Triple-DES. The following functions are included in the DES library for -compatibility with the MIT Kerberos library. des_read_pw_string() +compatibility with the MIT Kerberos library. DES_read_pw_string() is also available under the name EVP_read_pw_string(). -des_read_pw_string() writes the string specified by I to +DES_read_pw_string() writes the string specified by I to standard output, turns echo off and reads in input string from the terminal. The string is returned in I, which must have space for at least I bytes. If I is set, the user is asked for @@ -248,21 +247,21 @@ the password twice and unless the two copies match, an error is returned. A return code of -1 indicates a system error, 1 failure due to use interaction, and 0 is success. -des_read_password() does the same and converts the password to a DES -key by calling des_string_to_key(); des_read_2password() operates in -the same way as des_read_password() except that it generates two keys -by using the des_string_to_2key() function. des_string_to_key() is +DES_read_password() does the same and converts the password to a DES +key by calling DES_string_to_key(); DES_read_2password() operates in +the same way as DES_read_password() except that it generates two keys +by using the DES_string_to_2key() function. DES_string_to_key() is available for backward compatibility with the MIT library. New applications should use a cryptographic hash function. The same -applies for des_string_to_2key(). +applies for DES_string_to_2key(). -des_cbc_cksum() produces an 8 byte checksum based on the input stream +DES_cbc_cksum() produces an 8 byte checksum based on the input stream (via CBC encryption). The last 4 bytes of the checksum are returned and the complete 8 bytes are placed in I. This function is used by Kerberos v4. Other applications should use L etc. instead. -des_quad_cksum() is a Kerberos v4 function. It returns a 4 byte +DES_quad_cksum() is a Kerberos v4 function. It returns a 4 byte checksum from the input bytes. The algorithm can be iterated over the input, depending on I, 1, 2, 3 or 4 times. If I is non-NULL, the 8 bytes generated by each pass are written into @@ -270,19 +269,19 @@ I. The following are DES-based transformations: -des_fcrypt() is a fast version of the Unix crypt(3) function. This +DES_fcrypt() is a fast version of the Unix crypt(3) function. This version takes only a small amount of space relative to other fast crypt() implementations. This is different to the normal crypt in that the third parameter is the buffer that the return value is written into. It needs to be at least 14 bytes long. This function is thread safe, unlike the normal crypt. -des_crypt() is a faster replacement for the normal system crypt(). -This function calls des_fcrypt() with a static array passed as the +DES_crypt() is a faster replacement for the normal system crypt(). +This function calls DES_fcrypt() with a static array passed as the third parameter. This emulates the normal non-thread safe semantics of crypt(3). -des_enc_write() writes I bytes to file descriptor I from +DES_enc_write() writes I bytes to file descriptor I from buffer I. The data is encrypted via I (default) using I for the key and I as a starting vector. The actual data send down I consists of 4 bytes (in network byte order) @@ -290,40 +289,40 @@ containing the length of the following encrypted data. The encrypted data then follows, padded with random data out to a multiple of 8 bytes. -des_enc_read() is used to read I bytes from file descriptor +DES_enc_read() is used to read I bytes from file descriptor I into buffer I. The data being read from I is assumed to -have come from des_enc_write() and is decrypted using I for +have come from DES_enc_write() and is decrypted using I for the key schedule and I for the initial vector. -B The data format used by des_enc_write() and des_enc_read() +B The data format used by DES_enc_write() and DES_enc_read() has a cryptographic weakness: When asked to write more than MAXWRITE -bytes, des_enc_write() will split the data into several chunks that +bytes, DES_enc_write() will split the data into several chunks that are all encrypted using the same IV. So don't use these functions unless you are sure you know what you do (in which case you might not want to use them anyway). They cannot handle non-blocking sockets. -des_enc_read() uses an internal state and thus cannot be used on +DES_enc_read() uses an internal state and thus cannot be used on multiple files. -I is used to specify the encryption mode to use with -des_enc_read() and des_end_write(). If set to I (the -default), des_pcbc_encrypt is used. If set to I -des_cbc_encrypt is used. +I is used to specify the encryption mode to use with +DES_enc_read() and DES_end_write(). If set to I (the +default), DES_pcbc_encrypt is used. If set to I +DES_cbc_encrypt is used. =head1 NOTES Single-key DES is insecure due to its short key size. ECB mode is -not suitable for most applications; see L. +not suitable for most applications; see L. The L library provides higher-level encryption functions. =head1 BUGS -des_3cbc_encrypt() is flawed and must not be used in applications. +DES_3cbc_encrypt() is flawed and must not be used in applications. -des_cbc_encrypt() does not modify B; use des_ncbc_encrypt() +DES_cbc_encrypt() does not modify B; use DES_ncbc_encrypt() instead. -des_cfb_encrypt() and des_ofb_encrypt() operates on input of 8 bits. +DES_cfb_encrypt() and DES_ofb_encrypt() operates on input of 8 bits. What this means is that if you set numbits to 12, and length to 2, the first 12 bits will come from the 1st input byte and the low half of the second input byte. The second 12 bits will have the low 8 bits @@ -333,7 +332,7 @@ implemented this way because most people will be using a multiple of 8 and because once you get into pulling bytes input bytes apart things get ugly! -des_read_pw_string() is the most machine/OS dependent function and +DES_read_pw_string() is the most machine/OS dependent function and normally generates the most problems when porting this code. =head1 CONFORMING TO @@ -349,6 +348,10 @@ crypt(3), L, L, L =head1 HISTORY +In OpenSSL 0.9.7, All des_ functions were renamed to DES_ to avoid +clashes with older versions of libdes. Compatibility des_ functions +are provided for a short while, as well as crypt(). + des_cbc_cksum(), des_cbc_encrypt(), des_ecb_encrypt(), des_is_weak_key(), des_key_sched(), des_pcbc_encrypt(), des_quad_cksum(), des_random_key(), des_read_password() and diff --git a/makevms.com b/makevms.com index daba3422ca..638d61b470 100755 --- a/makevms.com +++ b/makevms.com @@ -436,7 +436,7 @@ $ EXHEADER_SHA := sha.h $ EXHEADER_MDC2 := mdc2.h $ EXHEADER_HMAC := hmac.h $ EXHEADER_RIPEMD := ripemd.h -$ EXHEADER_DES := des.h +$ EXHEADER_DES := des.h,des_old.h $ EXHEADER_RC2 := rc2.h $ EXHEADER_RC4 := rc4.h $ EXHEADER_RC5 := rc5.h diff --git a/test/Makefile.ssl b/test/Makefile.ssl index 1013b121a9..fd9d992b82 100644 --- a/test/Makefile.ssl +++ b/test/Makefile.ssl @@ -376,8 +376,9 @@ bntest.o: ../include/openssl/sha.h ../include/openssl/stack.h bntest.o: ../include/openssl/symhacks.h ../include/openssl/x509.h bntest.o: ../include/openssl/x509_vfy.h bntest.c casttest.o: ../include/openssl/cast.h casttest.c -destest.o: ../include/openssl/des.h ../include/openssl/e_os2.h -destest.o: ../include/openssl/opensslconf.h destest.c +destest.o: ../include/openssl/des.h ../include/openssl/des_old.h +destest.o: ../include/openssl/e_os2.h ../include/openssl/opensslconf.h +destest.o: ../include/openssl/symhacks.h destest.c dhtest.o: ../include/openssl/bio.h ../include/openssl/bn.h dhtest.o: ../include/openssl/crypto.h ../include/openssl/dh.h dhtest.o: ../include/openssl/e_os2.h ../include/openssl/err.h diff --git a/util/libeay.num b/util/libeay.num index 884b473ec4..ac05c2aefc 100755 --- a/util/libeay.num +++ b/util/libeay.num @@ -701,7 +701,8 @@ bn_mul_words 707 EXIST::FUNCTION: BN_uadd 708 EXIST::FUNCTION: BN_usub 709 EXIST::FUNCTION: bn_sqr_words 710 EXIST::FUNCTION: -crypt 711 EXIST:!NeXT,!PERL5,!__FreeBSD__:FUNCTION:DES +crypt 711 EXIST:!NeXT,!PERL5,!VMS,!WIN16,!__FreeBSD__:FUNCTION:DES +ocrypt 711 EXIST:!NeXT,!PERL5,!__FreeBSD__,VMS,WIN16:FUNCTION:DES d2i_ASN1_BIT_STRING 712 EXIST::FUNCTION: d2i_ASN1_BOOLEAN 713 EXIST::FUNCTION: d2i_ASN1_HEADER 714 EXIST::FUNCTION: @@ -766,43 +767,43 @@ d2i_X509_SIG 772 EXIST::FUNCTION: d2i_X509_VAL 773 EXIST::FUNCTION: d2i_X509_bio 774 EXIST::FUNCTION:BIO d2i_X509_fp 775 EXIST::FUNCTION:FP_API -des_cbc_cksum 777 EXIST::FUNCTION:DES -des_cbc_encrypt 778 EXIST::FUNCTION:DES -des_cblock_print_file 779 NOEXIST::FUNCTION: -des_cfb64_encrypt 780 EXIST::FUNCTION:DES -des_cfb_encrypt 781 EXIST::FUNCTION:DES -des_decrypt3 782 EXIST::FUNCTION:DES -des_ecb3_encrypt 783 EXIST::FUNCTION:DES -des_ecb_encrypt 784 EXIST::FUNCTION:DES -des_ede3_cbc_encrypt 785 EXIST::FUNCTION:DES -des_ede3_cfb64_encrypt 786 EXIST::FUNCTION:DES -des_ede3_ofb64_encrypt 787 EXIST::FUNCTION:DES -des_enc_read 788 EXIST::FUNCTION:DES -des_enc_write 789 EXIST::FUNCTION:DES -des_encrypt1 790 EXIST::FUNCTION:DES -des_encrypt2 791 EXIST::FUNCTION:DES -des_encrypt3 792 EXIST::FUNCTION:DES -des_fcrypt 793 EXIST::FUNCTION:DES -des_is_weak_key 794 EXIST::FUNCTION:DES -des_key_sched 795 EXIST::FUNCTION:DES -des_ncbc_encrypt 796 EXIST::FUNCTION:DES -des_ofb64_encrypt 797 EXIST::FUNCTION:DES -des_ofb_encrypt 798 EXIST::FUNCTION:DES -des_options 799 EXIST::FUNCTION:DES -des_pcbc_encrypt 800 EXIST::FUNCTION:DES -des_quad_cksum 801 EXIST::FUNCTION:DES -des_random_key 802 EXIST::FUNCTION:DES -des_random_seed 803 EXIST::FUNCTION:DES -des_read_2passwords 804 EXIST::FUNCTION:DES -des_read_password 805 EXIST::FUNCTION:DES -des_read_pw 806 EXIST::FUNCTION: -des_read_pw_string 807 EXIST::FUNCTION: -des_set_key 808 EXIST::FUNCTION:DES -des_set_odd_parity 809 EXIST::FUNCTION:DES -des_string_to_2keys 810 EXIST::FUNCTION:DES -des_string_to_key 811 EXIST::FUNCTION:DES -des_xcbc_encrypt 812 EXIST::FUNCTION:DES -des_xwhite_in2out 813 EXIST::FUNCTION:DES +DES_cbc_cksum 777 EXIST::FUNCTION:DES +DES_cbc_encrypt 778 EXIST::FUNCTION:DES +DES_cblock_print_file 779 NOEXIST::FUNCTION: +DES_cfb64_encrypt 780 EXIST::FUNCTION:DES +DES_cfb_encrypt 781 EXIST::FUNCTION:DES +DES_decrypt3 782 EXIST::FUNCTION:DES +DES_ecb3_encrypt 783 EXIST::FUNCTION:DES +DES_ecb_encrypt 784 EXIST::FUNCTION:DES +DES_ede3_cbc_encrypt 785 EXIST::FUNCTION:DES +DES_ede3_cfb64_encrypt 786 EXIST::FUNCTION:DES +DES_ede3_ofb64_encrypt 787 EXIST::FUNCTION:DES +DES_enc_read 788 EXIST::FUNCTION:DES +DES_enc_write 789 EXIST::FUNCTION:DES +DES_encrypt1 790 EXIST::FUNCTION:DES +DES_encrypt2 791 EXIST::FUNCTION:DES +DES_encrypt3 792 EXIST::FUNCTION:DES +DES_fcrypt 793 EXIST::FUNCTION:DES +DES_is_weak_key 794 EXIST::FUNCTION:DES +DES_key_sched 795 EXIST::FUNCTION:DES +DES_ncbc_encrypt 796 EXIST::FUNCTION:DES +DES_ofb64_encrypt 797 EXIST::FUNCTION:DES +DES_ofb_encrypt 798 EXIST::FUNCTION:DES +DES_options 799 EXIST::FUNCTION:DES +DES_pcbc_encrypt 800 EXIST::FUNCTION:DES +DES_quad_cksum 801 EXIST::FUNCTION:DES +DES_random_key 802 EXIST::FUNCTION:DES +DES_random_seed 803 EXIST::FUNCTION:DES +DES_read_2passwords 804 NOEXIST::FUNCTION: +DES_read_password 805 NOEXIST::FUNCTION: +DES_read_pw 806 NOEXIST::FUNCTION: +DES_read_pw_string 807 NOEXIST::FUNCTION: +DES_set_key 808 EXIST::FUNCTION:DES +DES_set_odd_parity 809 EXIST::FUNCTION:DES +DES_string_to_2keys 810 EXIST::FUNCTION:DES +DES_string_to_key 811 EXIST::FUNCTION:DES +DES_xcbc_encrypt 812 EXIST::FUNCTION:DES +DES_xwhite_in2out 813 EXIST::FUNCTION:DES fcrypt_body 814 NOEXIST::FUNCTION: i2a_ASN1_INTEGER 815 EXIST::FUNCTION:BIO i2a_ASN1_OBJECT 816 EXIST::FUNCTION:BIO @@ -1198,7 +1199,7 @@ s2i_ASN1_OCTET_STRING 1221 EXIST::FUNCTION: X509V3_EXT_check_conf 1222 NOEXIST::FUNCTION: hex_to_string 1223 EXIST::FUNCTION: string_to_hex 1224 EXIST::FUNCTION: -des_ede3_cbcm_encrypt 1225 EXIST::FUNCTION:DES +DES_ede3_cbcm_encrypt 1225 EXIST::FUNCTION:DES RSA_padding_add_PKCS1_OAEP 1226 EXIST::FUNCTION:RSA RSA_padding_check_PKCS1_OAEP 1227 EXIST::FUNCTION:RSA X509_CRL_print_fp 1228 EXIST::FUNCTION:FP_API @@ -1666,10 +1667,10 @@ X509_add1_trust_object 2140 EXIST::FUNCTION: PKCS12_newpass 2141 EXIST::FUNCTION: SMIME_write_PKCS7 2142 EXIST::FUNCTION: SMIME_read_PKCS7 2143 EXIST::FUNCTION: -des_set_key_checked 2144 EXIST::FUNCTION:DES +DES_set_key_checked 2144 EXIST::FUNCTION:DES PKCS7_verify 2145 EXIST::FUNCTION: PKCS7_encrypt 2146 EXIST::FUNCTION: -des_set_key_unchecked 2147 EXIST::FUNCTION:DES +DES_set_key_unchecked 2147 EXIST::FUNCTION:DES SMIME_crlf_copy 2148 EXIST::FUNCTION: i2d_ASN1_PRINTABLESTRING 2149 EXIST::FUNCTION: PKCS7_get0_signers 2150 EXIST::FUNCTION: @@ -1753,14 +1754,14 @@ ASN1_STRING_TABLE_add 2245 EXIST::FUNCTION: CRYPTO_dbg_get_options 2246 EXIST::FUNCTION: AUTHORITY_INFO_ACCESS_new 2247 EXIST::FUNCTION: CRYPTO_get_mem_debug_options 2248 EXIST::FUNCTION: -des_crypt 2249 EXIST::FUNCTION:DES +DES_crypt 2249 EXIST::FUNCTION:DES PEM_write_bio_X509_REQ_NEW 2250 EXIST::FUNCTION: PEM_write_X509_REQ_NEW 2251 EXIST:!WIN16:FUNCTION: BIO_callback_ctrl 2252 EXIST::FUNCTION: RAND_egd 2253 EXIST::FUNCTION: RAND_status 2254 EXIST::FUNCTION: bn_dump1 2255 NOEXIST::FUNCTION: -des_check_key_parity 2256 EXIST::FUNCTION:DES +DES_check_key_parity 2256 EXIST::FUNCTION:DES lh_num_items 2257 EXIST::FUNCTION: RAND_event 2258 EXIST:WIN32:FUNCTION: DSO_new 2259 EXIST::FUNCTION: @@ -1870,9 +1871,9 @@ X509_STORE_CTX_trusted_stack 2452 EXIST::FUNCTION: X509_time_adj 2453 EXIST::FUNCTION: X509_check_issued 2454 EXIST::FUNCTION: ASN1_UTCTIME_cmp_time_t 2455 EXIST::FUNCTION: -des_set_weak_key_flag 2456 NOEXIST::FUNCTION: -des_check_key 2457 NOEXIST::FUNCTION: -des_rw_mode 2458 NOEXIST::FUNCTION: +DES_set_weak_key_flag 2456 NOEXIST::FUNCTION: +DES_check_key 2457 NOEXIST::FUNCTION: +DES_rw_mode 2458 NOEXIST::FUNCTION: RSA_PKCS1_RSAref 2459 NOEXIST::FUNCTION: X509_keyid_set1 2460 EXIST::FUNCTION: BIO_next 2461 EXIST::FUNCTION: @@ -2122,8 +2123,8 @@ PKCS12_decrypt_skey 2665 EXIST::FUNCTION: KRB5_AUTHENT_it 2666 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: KRB5_AUTHENT_it 2666 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: UI_dup_error_string 2667 EXIST::FUNCTION: -_shadow_des_rw_mode 2668 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:DES -_shadow_des_rw_mode 2668 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:DES +_shadow_DES_rw_mode 2668 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:DES +_shadow_DES_rw_mode 2668 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:DES RSAPublicKey_it 2669 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:RSA RSAPublicKey_it 2669 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:RSA i2d_OCSP_REQUEST 2670 EXIST::FUNCTION: @@ -2639,8 +2640,8 @@ ASN1_TBOOLEAN_it 3091 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIA ASN1_TBOOLEAN_it 3091 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: ASN1_item_new 3092 EXIST::FUNCTION: ASN1_TIME_to_generalizedtime 3093 EXIST::FUNCTION: -_shadow_des_check_key 3094 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:DES -_shadow_des_check_key 3094 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:DES +_shadow_DES_check_key 3094 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE:DES +_shadow_DES_check_key 3094 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION:DES BIGNUM_it 3095 EXIST:!EXPORT_VAR_AS_FUNCTION:VARIABLE: BIGNUM_it 3095 EXIST:EXPORT_VAR_AS_FUNCTION:FUNCTION: ENGINE_get_BN_mod_exp 3096 NOEXIST::FUNCTION: @@ -2705,3 +2706,73 @@ EVP_DecryptFinal_ex 3151 EXIST::FUNCTION: EVP_EncryptFinal_ex 3152 EXIST::FUNCTION: EVP_DigestFinal_ex 3153 EXIST::FUNCTION: X509_supported_extension 3154 EXIST::FUNCTION: +des_random_key 3155 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_random_key 3155 EXIST:VMS,WIN16:FUNCTION:DES +des_encrypt 3156 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_encrypt 3156 EXIST:VMS,WIN16:FUNCTION:DES +des_is_weak_key 3157 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_is_weak_key 3157 EXIST:VMS,WIN16:FUNCTION:DES +des_options 3158 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_options 3158 EXIST:VMS,WIN16:FUNCTION:DES +des_xwhite_in2out 3159 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_xwhite_in2out 3159 EXIST:VMS,WIN16:FUNCTION:DES +des_crypt 3160 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_crypt 3160 EXIST:VMS,WIN16:FUNCTION:DES +des_key_sched 3161 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_key_sched 3161 EXIST:VMS,WIN16:FUNCTION:DES +des_ofb64_encrypt 3162 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_ofb64_encrypt 3162 EXIST:VMS,WIN16:FUNCTION:DES +des_enc_read 3163 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_enc_read 3163 EXIST:VMS,WIN16:FUNCTION:DES +des_decrypt3 3164 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_decrypt3 3164 EXIST:VMS,WIN16:FUNCTION:DES +des_read_password 3165 EXIST::FUNCTION:DES +des_string_to_2keys 3166 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_string_to_2keys 3166 EXIST:VMS,WIN16:FUNCTION:DES +des_ede3_cbc_encrypt 3167 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_ede3_cbc_encrypt 3167 EXIST:VMS,WIN16:FUNCTION:DES +des_cbc_cksum 3168 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_cbc_cksum 3168 EXIST:VMS,WIN16:FUNCTION:DES +des_ede3_cfb64_encrypt 3169 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_ede3_cfb64_encrypt 3169 EXIST:VMS,WIN16:FUNCTION:DES +des_string_to_key 3170 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_string_to_key 3170 EXIST:VMS,WIN16:FUNCTION:DES +des_set_odd_parity 3171 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_set_odd_parity 3171 EXIST:VMS,WIN16:FUNCTION:DES +des_fcrypt 3172 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_fcrypt 3172 EXIST:VMS,WIN16:FUNCTION:DES +des_ecb3_encrypt 3173 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_ecb3_encrypt 3173 EXIST:VMS,WIN16:FUNCTION:DES +des_read_pw_string 3174 EXIST::FUNCTION: +des_cbc_encrypt 3175 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_cbc_encrypt 3175 EXIST:VMS,WIN16:FUNCTION:DES +des_cfb_encrypt 3176 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_cfb_encrypt 3176 EXIST:VMS,WIN16:FUNCTION:DES +des_quad_cksum 3177 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_quad_cksum 3177 EXIST:VMS,WIN16:FUNCTION:DES +des_read_2passwords 3178 EXIST::FUNCTION:DES +des_encrypt2 3179 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_encrypt2 3179 EXIST:VMS,WIN16:FUNCTION:DES +des_encrypt3 3180 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_encrypt3 3180 EXIST:VMS,WIN16:FUNCTION:DES +des_ede3_ofb64_encrypt 3181 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_ede3_ofb64_encrypt 3181 EXIST:VMS,WIN16:FUNCTION:DES +des_enc_write 3182 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_enc_write 3182 EXIST:VMS,WIN16:FUNCTION:DES +des_ncbc_encrypt 3183 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_ncbc_encrypt 3183 EXIST:VMS,WIN16:FUNCTION:DES +des_pcbc_encrypt 3184 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_pcbc_encrypt 3184 EXIST:VMS,WIN16:FUNCTION:DES +des_set_key 3185 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_set_key 3185 EXIST:VMS,WIN16:FUNCTION:DES +des_random_seed 3186 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_random_seed 3186 EXIST:VMS,WIN16:FUNCTION:DES +des_cfb64_encrypt 3187 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_cfb64_encrypt 3187 EXIST:VMS,WIN16:FUNCTION:DES +des_ofb_encrypt 3188 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_ofb_encrypt 3188 EXIST:VMS,WIN16:FUNCTION:DES +des_read_pw 3189 EXIST::FUNCTION: +des_xcbc_encrypt 3190 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_xcbc_encrypt 3190 EXIST:VMS,WIN16:FUNCTION:DES +des_ecb_encrypt 3191 EXIST:!VMS,!WIN16:FUNCTION:DES +odes_ecb_encrypt 3191 EXIST:VMS,WIN16:FUNCTION:DES diff --git a/util/mkdef.pl b/util/mkdef.pl index b66d05c06e..9243c0bb61 100755 --- a/util/mkdef.pl +++ b/util/mkdef.pl @@ -195,7 +195,7 @@ my $ssl="ssl/ssl.h"; $ssl.=" ssl/kssl.h"; my $crypto ="crypto/crypto.h"; -$crypto.=" crypto/des/des.h" ; # unless $no_des; +$crypto.=" crypto/des/des.h crypto/des/des_old.h" ; # unless $no_des; $crypto.=" crypto/idea/idea.h" ; # unless $no_idea; $crypto.=" crypto/rc4/rc4.h" ; # unless $no_rc4; $crypto.=" crypto/rc5/rc5.h" ; # unless $no_rc5; -- 2.25.1