Browse Source

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.
master
Richard Levitte 21 years ago
parent
commit
c2e4f17c1a
58 changed files with 1490 additions and 911 deletions
  1. +13
    -0
      CHANGES
  2. +42
    -41
      apps/Makefile.ssl
  3. +1
    -1
      apps/passwd.c
  4. +10
    -8
      apps/speed.c
  5. +1
    -1
      apps/version.c
  6. +1
    -1
      crypto/crypto-lib.com
  7. +3
    -3
      crypto/des/Makefile.ssl
  8. +7
    -7
      crypto/des/asm/des-586.pl
  9. +5
    -5
      crypto/des/asm/des686.pl
  10. +4
    -4
      crypto/des/asm/desboth.pl
  11. +20
    -20
      crypto/des/cbc3_enc.c
  12. +4
    -4
      crypto/des/cbc_cksm.c
  13. +9
    -9
      crypto/des/cfb64ede.c
  14. +5
    -5
      crypto/des/cfb64enc.c
  15. +4
    -4
      crypto/des/cfb_enc.c
  16. +34
    -34
      crypto/des/des.c
  17. +107
    -145
      crypto/des/des.h
  18. +21
    -21
      crypto/des/des_enc.c
  19. +1
    -1
      crypto/des/des_locl.h
  20. +245
    -0
      crypto/des/des_old.c
  21. +236
    -0
      crypto/des/des_old.h
  22. +102
    -102
      crypto/des/des_opts.c
  23. +72
    -72
      crypto/des/destest.c
  24. +5
    -5
      crypto/des/ecb3_enc.c
  25. +4
    -4
      crypto/des/ecb_enc.c
  26. +11
    -11
      crypto/des/ede_cbcm_enc.c
  27. +14
    -14
      crypto/des/enc_read.c
  28. +8
    -8
      crypto/des/enc_writ.c
  29. +9
    -16
      crypto/des/fcrypt.c
  30. +1
    -1
      crypto/des/fcrypt_b.c
  31. +10
    -10
      crypto/des/ncbc_enc.c
  32. +9
    -9
      crypto/des/ofb64ede.c
  33. +4
    -4
      crypto/des/ofb64enc.c
  34. +4
    -4
      crypto/des/ofb_enc.c
  35. +5
    -5
      crypto/des/pcbc_enc.c
  36. +2
    -2
      crypto/des/qud_cksm.c
  37. +6
    -6
      crypto/des/rand_key.c
  38. +15
    -2
      crypto/des/read2pwd.c
  39. +5
    -5
      crypto/des/rpc_enc.c
  40. +1
    -1
      crypto/des/rpw.c
  41. +17
    -17
      crypto/des/set_key.c
  42. +24
    -24
      crypto/des/speed.c
  43. +16
    -16
      crypto/des/str2key.c
  44. +10
    -10
      crypto/des/xcbc_enc.c
  45. +9
    -9
      crypto/evp/e_des.c
  46. +17
    -17
      crypto/evp/e_des3.c
  47. +7
    -7
      crypto/evp/e_xcbc_d.c
  48. +1
    -1
      crypto/install.com
  49. +1
    -1
      crypto/mdc2/mdc2.h
  50. +7
    -7
      crypto/mdc2/mdc2dgst.c
  51. +39
    -0
      crypto/symhacks.h
  52. +4
    -4
      crypto/ui/ui_compat.c
  53. +2
    -2
      crypto/ui/ui_compat.h
  54. +150
    -147
      doc/crypto/des.pod
  55. +1
    -1
      makevms.com
  56. +3
    -2
      test/Makefile.ssl
  57. +121
    -50
      util/libeay.num
  58. +1
    -1
      util/mkdef.pl

+ 13
- 0
CHANGES View File

@ -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.


+ 42
- 41
apps/Makefile.ssl View File

@ -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


+ 1
- 1
apps/passwd.c View File

@ -16,7 +16,7 @@
#include <openssl/evp.h>
#include <openssl/rand.h>
#ifndef OPENSSL_NO_DES
# include <openssl/des.h>
# include <openssl/des_old.h>
#endif
#ifndef NO_MD5CRYPT_1
# include <openssl/evp.h>


+ 10
- 8
apps/speed.c View File

@ -129,7 +129,7 @@
#endif
#ifndef OPENSSL_NO_DES
#include <openssl/des.h>
#include <openssl/des_old.h>
#endif
#ifndef OPENSSL_NO_MD2
#include <openssl/md2.h>
@ -377,11 +377,13 @@ int MAIN(int argc, char **argv)
0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
unsigned char iv[8];
#ifndef OPENSSL_NO_DES
des_cblock *buf_as_des_cblock = NULL;
DES_cblock *buf_as_des_cblock = NULL;
static des_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
static des_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
static des_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
des_key_schedule sch,sch2,sch3;
DES_key_schedule sch;
DES_key_schedule sch2;
DES_key_schedule sch3;
#endif
#define D_MD2 0
#define D_MDC2 1
@ -804,9 +806,9 @@ int MAIN(int argc, char **argv)
#endif
#ifndef OPENSSL_NO_DES
des_set_key_unchecked(&key,&sch);
des_set_key_unchecked(&key2,&sch2);
des_set_key_unchecked(&key3,&sch3);
DES_set_key_unchecked(&key,&sch);
DES_set_key_unchecked(&key2,&sch2);
DES_set_key_unchecked(&key3,&sch3);
#endif
#ifndef OPENSSL_NO_IDEA
idea_set_encrypt_key(key16,&idea_ks);
@ -1088,7 +1090,7 @@ int MAIN(int argc, char **argv)
print_message(names[D_CBC_DES],c[D_CBC_DES][j],lengths[j]);
Time_F(START,usertime);
for (count=0,run=1; COND(c[D_CBC_DES][j]); count++)
des_ncbc_encrypt(buf,buf,lengths[j],&sch,
DES_ncbc_encrypt(buf,buf,lengths[j],&sch,
&iv,DES_ENCRYPT);
d=Time_F(STOP,usertime);
BIO_printf(bio_err,"%ld %s's in %.2fs\n",
@ -1104,7 +1106,7 @@ int MAIN(int argc, char **argv)
print_message(names[D_EDE3_DES],c[D_EDE3_DES][j],lengths[j]);
Time_F(START,usertime);
for (count=0,run=1; COND(c[D_EDE3_DES][j]); count++)
des_ede3_cbc_encrypt(buf,buf,lengths[j],
DES_ede3_cbc_encrypt(buf,buf,lengths[j],
&sch,&sch2,&sch3,
&iv,DES_ENCRYPT);
d=Time_F(STOP,usertime);


+ 1
- 1
apps/version.c View File

@ -117,7 +117,7 @@
#include <openssl/crypto.h>
#include <openssl/md2.h>
#include <openssl/rc4.h>
#include <openssl/des.h>
#include <openssl/des_old.h>
#include <openssl/idea.h>
#include <openssl/blowfish.h>


+ 1
- 1
crypto/crypto-lib.com View File

@ -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"


+ 3
- 3
crypto/des/Makefile.ssl View File

@ -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)


+ 7
- 7
crypto/des/asm/des-586.pl View File

@ -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)=@_;


+ 5
- 5
crypto/des/asm/des686.pl View File

@ -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)=@_;


+ 4
- 4
crypto/des/asm/desboth.pl View File

@ -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));


+ 20
- 20
crypto/des/cbc3_enc.c View File

@ -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));
}

+ 4
- 4
crypto/des/cbc_cksm.c View File

@ -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];


+ 9
- 9
crypto/des/cfb64ede.c View File

@ -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

+ 5
- 5
crypto/des/cfb64enc.c View File

@ -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);


+ 4
- 4
crypto/des/cfb_enc.c View File

@ -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


+ 34
- 34
crypto/des/des.c View File

@ -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<KEYSIZ; i++)
@ -453,7 +453,7 @@ void doencryption(void)
kk[i]=key[i]|0x80;
}
des_set_key_unchecked(&kk,&ks);
DES_set_key_unchecked(&kk,&ks);
memset(key,0,sizeof(key));
memset(kk,0,sizeof(kk));
/* woops - A bug that does not showup under unix :-( */
@ -492,7 +492,7 @@ void doencryption(void)
if (cflag)
{
des_cbc_cksum(buf,&cksum,
DES_cbc_cksum(buf,&cksum,
(long)len,&ks,&cksum);
if (!eflag)
{
@ -503,15 +503,15 @@ void doencryption(void)
if (bflag && !flag3)
for (i=0; i<l; i+=8)
des_ecb_encrypt(
(des_cblock *)&(buf[i]),
(des_cblock *)&(obuf[i]),
DES_ecb_encrypt(
(DES_cblock *)&(buf[i]),
(DES_cblock *)&(obuf[i]),
&ks,do_encrypt);
else if (flag3 && bflag)
for (i=0; i<l; i+=8)
des_ecb2_encrypt(
(des_cblock *)&(buf[i]),
(des_cblock *)&(obuf[i]),
DES_ecb2_encrypt(
(DES_cblock *)&(buf[i]),
(DES_cblock *)&(obuf[i]),
&ks,&ks2,do_encrypt);
else if (flag3 && !bflag)
{
@ -519,8 +519,8 @@ void doencryption(void)
if (rem) memcpy(tmpbuf,&(buf[l]),
(unsigned int)rem);
des_3cbc_encrypt(
(des_cblock *)buf,(des_cblock *)obuf,
DES_3cbc_encrypt(
(DES_cblock *)buf,(DES_cblock *)obuf,
(long)l,ks,ks2,&iv,
&iv2,do_encrypt);
if (rem) memcpy(&(buf[l]),tmpbuf,
@ -528,7 +528,7 @@ void doencryption(void)
}
else
{
des_cbc_encrypt(
DES_cbc_encrypt(
buf,obuf,
(long)l,&ks,&iv,do_encrypt);
if (l >= 8) memcpy(iv,&(obuf[l-8]),8);
@ -582,26 +582,26 @@ void doencryption(void)
if (bflag && !flag3)
for (i=0; i<l; i+=8)
des_ecb_encrypt(
(des_cblock *)&(buf[i]),
(des_cblock *)&(obuf[i]),
DES_ecb_encrypt(
(DES_cblock *)&(buf[i]),
(DES_cblock *)&(obuf[i]),
&ks,do_encrypt);
else if (flag3 && bflag)
for (i=0; i<l; i+=8)
des_ecb2_encrypt(
(des_cblock *)&(buf[i]),
(des_cblock *)&(obuf[i]),
DES_ecb2_encrypt(
(DES_cblock *)&(buf[i]),
(DES_cblock *)&(obuf[i]),
&ks,&ks2,do_encrypt);
else if (flag3 && !bflag)
{
des_3cbc_encrypt(
(des_cblock *)buf,(des_cblock *)obuf,
DES_3cbc_encrypt(
(DES_cblock *)buf,(DES_cblock *)obuf,
(long)l,ks,ks2,&iv,
&iv2,do_encrypt);
}
else
{
des_cbc_encrypt(
DES_cbc_encrypt(
buf,obuf,
(long)l,&ks,&iv,do_encrypt);
if (l >= 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);


+ 107
- 145
crypto/des/des.h View File

@ -63,10 +63,6 @@
#error DES is disabled.
#endif
#ifdef _KERBEROS_DES_H
#error <openssl/des.h> replaces <kerberos/des.h>.
#endif
#include <openssl/opensslconf.h> /* DES_LONG */
#include <openssl/e_os2.h> /* 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
}


+ 21
- 21
crypto/des/des_enc.c View File

@ -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];


+ 1
- 1
crypto/des/des_locl.h View File

@ -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

+ 245
- 0
crypto/des/des_old.c View File

@ -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 <openssl/des_old.h>
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)
{