From b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 Mon Sep 17 00:00:00 2001 From: beck <> Date: Wed, 15 May 2002 02:29:21 +0000 Subject: OpenSSL 0.9.7 stable 2002 05 08 merge --- src/lib/libcrypto/des/Makefile.ssl | 267 +++++++++++++++------ src/lib/libcrypto/des/asm/crypt586.pl | 8 +- src/lib/libcrypto/des/asm/des-586.pl | 26 +- src/lib/libcrypto/des/asm/des686.pl | 20 +- src/lib/libcrypto/des/asm/desboth.pl | 8 +- src/lib/libcrypto/des/cbc3_enc.c | 52 ++-- src/lib/libcrypto/des/cbc_cksm.c | 8 +- src/lib/libcrypto/des/cfb64ede.c | 17 +- src/lib/libcrypto/des/cfb64enc.c | 10 +- src/lib/libcrypto/des/cfb_enc.c | 8 +- src/lib/libcrypto/des/des-lib.com | 4 +- src/lib/libcrypto/des/des.c | 112 ++++----- src/lib/libcrypto/des/des.h | 290 +++++++++++----------- src/lib/libcrypto/des/des_enc.c | 53 +++-- src/lib/libcrypto/des/des_locl.h | 79 +++--- src/lib/libcrypto/des/des_old.c | 271 +++++++++++++++++++++ src/lib/libcrypto/des/des_old.h | 437 ++++++++++++++++++++++++++++++++++ src/lib/libcrypto/des/des_old2.c | 82 +++++++ src/lib/libcrypto/des/des_opts.c | 212 ++++++++--------- src/lib/libcrypto/des/des_ver.h | 6 + src/lib/libcrypto/des/destest.c | 103 ++++---- src/lib/libcrypto/des/ecb3_enc.c | 9 +- src/lib/libcrypto/des/ecb_enc.c | 10 +- src/lib/libcrypto/des/ede_cbcm_enc.c | 24 +- src/lib/libcrypto/des/enc_read.c | 28 +-- src/lib/libcrypto/des/enc_writ.c | 16 +- src/lib/libcrypto/des/fcrypt.c | 81 ++++--- src/lib/libcrypto/des/fcrypt_b.c | 6 +- src/lib/libcrypto/des/ncbc_enc.c | 20 +- src/lib/libcrypto/des/ofb64ede.c | 21 +- src/lib/libcrypto/des/ofb64enc.c | 10 +- src/lib/libcrypto/des/ofb_enc.c | 7 +- src/lib/libcrypto/des/pcbc_enc.c | 9 +- src/lib/libcrypto/des/qud_cksm.c | 4 +- src/lib/libcrypto/des/rand_key.c | 13 +- src/lib/libcrypto/des/read2pwd.c | 69 +++++- src/lib/libcrypto/des/read_pwd.c | 62 ++--- src/lib/libcrypto/des/rpc_enc.c | 12 +- src/lib/libcrypto/des/rpw.c | 2 +- src/lib/libcrypto/des/set_key.c | 43 ++-- src/lib/libcrypto/des/speed.c | 54 ++--- src/lib/libcrypto/des/spr.h | 2 +- src/lib/libcrypto/des/str2key.c | 54 +++-- src/lib/libcrypto/des/xcbc_enc.c | 19 +- 44 files changed, 1829 insertions(+), 819 deletions(-) create mode 100644 src/lib/libcrypto/des/des_old.c create mode 100644 src/lib/libcrypto/des/des_old.h create mode 100644 src/lib/libcrypto/des/des_old2.c (limited to 'src/lib/libcrypto/des') diff --git a/src/lib/libcrypto/des/Makefile.ssl b/src/lib/libcrypto/des/Makefile.ssl index cc5379feb2..04a73a9326 100644 --- a/src/lib/libcrypto/des/Makefile.ssl +++ b/src/lib/libcrypto/des/Makefile.ssl @@ -6,13 +6,14 @@ DIR= des TOP= ../.. CC= cc CPP= $(CC) -E -INCLUDES=-I../../include +INCLUDES=-I$(TOP) -I../../include CFLAG=-g INSTALL_PREFIX= OPENSSLDIR= /usr/local/ssl INSTALLTOP=/usr/local/ssl MAKE= make -f Makefile.ssl -MAKEDEPEND= $(TOP)/util/domd $(TOP) +MAKEDEPPROG= makedepend +MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG) MAKEFILE= Makefile.ssl AR= ar r RANLIB= ranlib @@ -30,22 +31,23 @@ LIB=$(TOP)/libcrypto.a LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \ ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \ fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \ - qud_cksm.c rand_key.c read_pwd.c rpc_enc.c set_key.c \ - des_enc.c fcrypt_b.c read2pwd.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.c des_old2.c \ + read2pwd.c LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \ ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \ enc_read.o enc_writ.o ofb64enc.o \ ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \ - ${DES_ENC} read2pwd.o \ - fcrypt.o xcbc_enc.o read_pwd.o rpc_enc.o cbc_cksm.o \ - ede_cbcm_enc.o + ${DES_ENC} \ + fcrypt.o xcbc_enc.o rpc_enc.o cbc_cksm.o \ + ede_cbcm_enc.o des_old.o des_old2.o read2pwd.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) @@ -57,8 +59,7 @@ all: lib lib: $(LIBOBJ) $(AR) $(LIB) $(LIBOBJ) - @echo You may get an error following this line. Please ignore. - - $(RANLIB) $(LIB) + $(RANLIB) $(LIB) || echo Never mind. @touch lib des: des.o cbc3_enc.o lib @@ -141,72 +142,184 @@ clean: # DO NOT DELETE THIS LINE -- make depend depends on it. -cbc_cksm.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -cbc_cksm.o: ../../include/openssl/opensslconf.h des_locl.h -cbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -cbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h ncbc_enc.c -cfb64ede.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -cfb64ede.o: ../../include/openssl/opensslconf.h des_locl.h -cfb64enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -cfb64enc.o: ../../include/openssl/opensslconf.h des_locl.h -cfb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -cfb_enc.o: ../../include/openssl/opensslconf.h des_locl.h -des_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -des_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_locl.h ncbc_enc.c -ecb3_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -ecb3_enc.o: ../../include/openssl/opensslconf.h des_locl.h -ecb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h +cbc_cksm.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +cbc_cksm.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +cbc_cksm.o: ../../include/openssl/opensslconf.h +cbc_cksm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +cbc_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +cbc_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +cbc_cksm.o: cbc_cksm.c des_locl.h +cbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +cbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +cbc_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +cbc_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +cbc_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +cbc_enc.o: ../../include/openssl/ui_compat.h cbc_enc.c des_locl.h ncbc_enc.c +cfb64ede.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +cfb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +cfb64ede.o: ../../include/openssl/opensslconf.h +cfb64ede.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +cfb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +cfb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +cfb64ede.o: cfb64ede.c des_locl.h +cfb64enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +cfb64enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +cfb64enc.o: ../../include/openssl/opensslconf.h +cfb64enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +cfb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +cfb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +cfb64enc.o: cfb64enc.c des_locl.h +cfb_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +cfb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +cfb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +cfb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +cfb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +cfb_enc.o: ../../include/openssl/ui_compat.h cfb_enc.c des_locl.h +des_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +des_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +des_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +des_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +des_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +des_enc.o: ../../include/openssl/ui_compat.h des_enc.c des_locl.h ncbc_enc.c +des_old.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +des_old.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +des_old.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +des_old.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h +des_old.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +des_old.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +des_old.o: ../../include/openssl/ui_compat.h des_old.c +des_old2.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +des_old2.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +des_old2.o: ../../include/openssl/opensslconf.h +des_old2.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h +des_old2.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h +des_old2.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +des_old2.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +des_old2.o: des_old2.c +ecb3_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +ecb3_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +ecb3_enc.o: ../../include/openssl/opensslconf.h +ecb3_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +ecb3_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +ecb3_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +ecb3_enc.o: des_locl.h ecb3_enc.c +ecb_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +ecb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h ecb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h -ecb_enc.o: des_locl.h spr.h -ede_cbcm_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -ede_cbcm_enc.o: ../../include/openssl/opensslconf.h des_locl.h -enc_read.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h -enc_read.o: ../../include/openssl/crypto.h ../../include/openssl/des.h -enc_read.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h -enc_read.o: ../../include/openssl/err.h ../../include/openssl/lhash.h -enc_read.o: ../../include/openssl/opensslconf.h +ecb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +ecb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +ecb_enc.o: ../../include/openssl/ui_compat.h des_locl.h ecb_enc.c spr.h +ede_cbcm_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +ede_cbcm_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +ede_cbcm_enc.o: ../../include/openssl/opensslconf.h +ede_cbcm_enc.o: ../../include/openssl/opensslv.h +ede_cbcm_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +ede_cbcm_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +ede_cbcm_enc.o: ../../include/openssl/ui_compat.h des_locl.h ede_cbcm_enc.c +enc_read.o: ../../e_os.h ../../include/openssl/bio.h +enc_read.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h +enc_read.o: ../../include/openssl/des.h ../../include/openssl/des_old.h +enc_read.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +enc_read.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h enc_read.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -enc_read.o: ../cryptlib.h des_locl.h -enc_writ.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h -enc_writ.o: ../../include/openssl/crypto.h ../../include/openssl/des.h -enc_writ.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h -enc_writ.o: ../../include/openssl/err.h ../../include/openssl/lhash.h -enc_writ.o: ../../include/openssl/opensslconf.h -enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/rand.h -enc_writ.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h -enc_writ.o: ../../include/openssl/symhacks.h ../cryptlib.h des_locl.h -fcrypt.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -fcrypt.o: ../../include/openssl/opensslconf.h des_locl.h -fcrypt_b.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -fcrypt_b.o: ../../include/openssl/opensslconf.h des_locl.h -ofb64ede.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -ofb64ede.o: ../../include/openssl/opensslconf.h des_locl.h -ofb64enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -ofb64enc.o: ../../include/openssl/opensslconf.h des_locl.h -ofb_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -ofb_enc.o: ../../include/openssl/opensslconf.h des_locl.h -pcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -pcbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h -qud_cksm.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -qud_cksm.o: ../../include/openssl/opensslconf.h des_locl.h -rand_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -rand_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/rand.h -read2pwd.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -read2pwd.o: ../../include/openssl/opensslconf.h des_locl.h -read_pwd.o: ../../include/openssl/bio.h ../../include/openssl/buffer.h -read_pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h -read_pwd.o: ../../include/openssl/e_os.h ../../include/openssl/e_os2.h -read_pwd.o: ../../include/openssl/err.h ../../include/openssl/lhash.h -read_pwd.o: ../../include/openssl/opensslconf.h -read_pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h -read_pwd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h -read_pwd.o: ../cryptlib.h des_locl.h -rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -rpc_enc.o: ../../include/openssl/opensslconf.h des_locl.h des_ver.h rpc_des.h -set_key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -set_key.o: ../../include/openssl/opensslconf.h des_locl.h -str2key.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -str2key.o: ../../include/openssl/opensslconf.h des_locl.h -xcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/e_os2.h -xcbc_enc.o: ../../include/openssl/opensslconf.h des_locl.h +enc_read.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +enc_read.o: ../cryptlib.h des_locl.h enc_read.c +enc_writ.o: ../../e_os.h ../../include/openssl/bio.h +enc_writ.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h +enc_writ.o: ../../include/openssl/des.h ../../include/openssl/des_old.h +enc_writ.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h +enc_writ.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h +enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h +enc_writ.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h +enc_writ.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +enc_writ.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +enc_writ.o: ../cryptlib.h des_locl.h enc_writ.c +fcrypt.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +fcrypt.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +fcrypt.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +fcrypt.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +fcrypt.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +fcrypt.o: ../../include/openssl/ui_compat.h des_locl.h fcrypt.c +fcrypt_b.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +fcrypt_b.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +fcrypt_b.o: ../../include/openssl/opensslconf.h +fcrypt_b.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +fcrypt_b.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +fcrypt_b.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +fcrypt_b.o: des_locl.h fcrypt_b.c +ofb64ede.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +ofb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +ofb64ede.o: ../../include/openssl/opensslconf.h +ofb64ede.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +ofb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +ofb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +ofb64ede.o: des_locl.h ofb64ede.c +ofb64enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +ofb64enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +ofb64enc.o: ../../include/openssl/opensslconf.h +ofb64enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +ofb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +ofb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +ofb64enc.o: des_locl.h ofb64enc.c +ofb_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +ofb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +ofb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +ofb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +ofb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +ofb_enc.o: ../../include/openssl/ui_compat.h des_locl.h ofb_enc.c +pcbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +pcbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +pcbc_enc.o: ../../include/openssl/opensslconf.h +pcbc_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +pcbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +pcbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +pcbc_enc.o: des_locl.h pcbc_enc.c +qud_cksm.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +qud_cksm.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +qud_cksm.o: ../../include/openssl/opensslconf.h +qud_cksm.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +qud_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +qud_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +qud_cksm.o: des_locl.h qud_cksm.c +rand_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +rand_key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +rand_key.o: ../../include/openssl/opensslconf.h +rand_key.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h +rand_key.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h +rand_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +rand_key.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +rand_key.o: rand_key.c +read2pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +read2pwd.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +read2pwd.o: ../../include/openssl/opensslconf.h +read2pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +read2pwd.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +read2pwd.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +read2pwd.o: read2pwd.c +rpc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +rpc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +rpc_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +rpc_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +rpc_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +rpc_enc.o: ../../include/openssl/ui_compat.h des_locl.h des_ver.h rpc_des.h +rpc_enc.o: rpc_enc.c +set_key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +set_key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +set_key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +set_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +set_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +set_key.o: ../../include/openssl/ui_compat.h des_locl.h set_key.c +str2key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +str2key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +str2key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h +str2key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h +str2key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h +str2key.o: ../../include/openssl/ui_compat.h des_locl.h str2key.c +xcbc_enc.o: ../../include/openssl/crypto.h ../../include/openssl/des.h +xcbc_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h +xcbc_enc.o: ../../include/openssl/opensslconf.h +xcbc_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h +xcbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h +xcbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h +xcbc_enc.o: des_locl.h xcbc_enc.c diff --git a/src/lib/libcrypto/des/asm/crypt586.pl b/src/lib/libcrypto/des/asm/crypt586.pl index 197c413ea6..3d41d82f69 100644 --- a/src/lib/libcrypto/des/asm/crypt586.pl +++ b/src/lib/libcrypto/des/asm/crypt586.pl @@ -14,7 +14,7 @@ require "x86asm.pl"; $L="edi"; $R="esi"; -&external_label("des_SPtrans"); +&external_label("DES_SPtrans"); &fcrypt_body("fcrypt_body"); &asm_finish(); @@ -22,7 +22,7 @@ sub fcrypt_body { local($name,$do_ip)=@_; - &function_begin($name,"EXTRN _des_SPtrans:DWORD"); + &function_begin($name,"EXTRN _DES_SPtrans:DWORD"); &comment(""); &comment("Load the 2 words"); @@ -39,11 +39,11 @@ sub fcrypt_body { &comment(""); &comment("Round $i"); - &D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); + &D_ENCRYPT($i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); &comment(""); &comment("Round ".sprintf("%d",$i+1)); - &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); + &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); } &mov("ebx", &swtmp(0)); &mov("eax", $L); diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl index c890766bc9..0d08e8a3a9 100644 --- a/src/lib/libcrypto/des/asm/des-586.pl +++ b/src/lib/libcrypto/des/asm/des-586.pl @@ -19,21 +19,21 @@ require "desboth.pl"; $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); +&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); &asm_finish(); -sub des_encrypt +sub DES_encrypt { local($name,$do_ip)=@_; - &function_begin_B($name,"EXTRN _des_SPtrans:DWORD"); + &function_begin_B($name,"EXTRN _DES_SPtrans:DWORD"); &push("esi"); &push("edi"); @@ -80,11 +80,11 @@ sub des_encrypt { &comment(""); &comment("Round $i"); - &D_ENCRYPT($i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); + &D_ENCRYPT($i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); &comment(""); &comment("Round ".sprintf("%d",$i+1)); - &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); + &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); } &jmp(&label("end")); @@ -94,10 +94,10 @@ sub des_encrypt { &comment(""); &comment("Round $i"); - &D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); + &D_ENCRYPT(15-$i,$L,$R,$i*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); &comment(""); &comment("Round ".sprintf("%d",$i-1)); - &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"des_SPtrans","eax","ebx","ecx","edx"); + &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$ks,"DES_SPtrans","eax","ebx","ecx","edx"); } &set_label("end"); diff --git a/src/lib/libcrypto/des/asm/des686.pl b/src/lib/libcrypto/des/asm/des686.pl index 84c3e85438..d3ad5d5edd 100644 --- a/src/lib/libcrypto/des/asm/des686.pl +++ b/src/lib/libcrypto/des/asm/des686.pl @@ -46,19 +46,19 @@ 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)=@_; - &function_begin($name,"EXTRN _des_SPtrans:DWORD"); + &function_begin($name,"EXTRN _DES_SPtrans:DWORD"); &comment(""); &comment("Load the 2 words"); @@ -94,11 +94,11 @@ sub des_encrypt { &comment(""); &comment("Round $i"); - &D_ENCRYPT($L,$R,$i*2,"ebp","des_SPtrans","ecx","edx","eax","ebx"); + &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); &comment(""); &comment("Round ".sprintf("%d",$i+1)); - &D_ENCRYPT($R,$L,($i+1)*2,"ebp","des_SPtrans","ecx","edx","eax","ebx"); + &D_ENCRYPT($R,$L,($i+1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); } &jmp(&label("end")); @@ -108,10 +108,10 @@ sub des_encrypt { &comment(""); &comment("Round $i"); - &D_ENCRYPT($L,$R,$i*2,"ebp","des_SPtrans","ecx","edx","eax","ebx"); + &D_ENCRYPT($L,$R,$i*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); &comment(""); &comment("Round ".sprintf("%d",$i-1)); - &D_ENCRYPT($R,$L,($i-1)*2,"ebp","des_SPtrans","ecx","edx","eax","ebx"); + &D_ENCRYPT($R,$L,($i-1)*2,"ebp","DES_SPtrans","ecx","edx","eax","ebx"); } &set_label("end"); diff --git a/src/lib/libcrypto/des/asm/desboth.pl b/src/lib/libcrypto/des/asm/desboth.pl index d5106414db..eec00886e4 100644 --- a/src/lib/libcrypto/des/asm/desboth.pl +++ b/src/lib/libcrypto/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/src/lib/libcrypto/des/cbc3_enc.c b/src/lib/libcrypto/des/cbc3_enc.c index 527e74f3de..b5db4e14f7 100644 --- a/src/lib/libcrypto/des/cbc3_enc.c +++ b/src/lib/libcrypto/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, - (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, - (unsigned char*)output,l8,ks2,iv1,!enc); - 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)); + 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, + (unsigned char*)output,l8,&ks2,iv1,!enc); + 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)); } else { - 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, - (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, - (unsigned char*)output,length,ks1,iv1,enc); + 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, + (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, + (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/src/lib/libcrypto/des/cbc_cksm.c b/src/lib/libcrypto/des/cbc_cksm.c index b857df0985..6c5305b99d 100644 --- a/src/lib/libcrypto/des/cbc_cksm.c +++ b/src/lib/libcrypto/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/src/lib/libcrypto/des/cfb64ede.c b/src/lib/libcrypto/des/cfb64ede.c index 5362a551bf..60c1aa08db 100644 --- a/src/lib/libcrypto/des/cfb64ede.c +++ b/src/lib/libcrypto/des/cfb64ede.c @@ -63,9 +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; @@ -85,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]; @@ -111,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]; @@ -132,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/src/lib/libcrypto/des/cfb64enc.c b/src/lib/libcrypto/des/cfb64enc.c index 105530dfa3..5ec8683e40 100644 --- a/src/lib/libcrypto/des/cfb64enc.c +++ b/src/lib/libcrypto/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/src/lib/libcrypto/des/cfb_enc.c b/src/lib/libcrypto/des/cfb_enc.c index ec4fd4ea67..17bf77ca9e 100644 --- a/src/lib/libcrypto/des/cfb_enc.c +++ b/src/lib/libcrypto/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/src/lib/libcrypto/des/des-lib.com b/src/lib/libcrypto/des/des-lib.com index 2aea7a0dea..fc2c35a1ce 100644 --- a/src/lib/libcrypto/des/des-lib.com +++ b/src/lib/libcrypto/des/des-lib.com @@ -846,8 +846,8 @@ $ ENDIF $! $! Set Up Initial CC Definitions, Possibly With User Ones $! -$ CCDEFS = "VMS=1" -$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = CCDEFS + "," + USER_CCDEFS +$ CCDEFS = "" +$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = USER_CCDEFS $ CCEXTRAFLAGS = "" $ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS $ CCDISABLEWARNINGS = "" diff --git a/src/lib/libcrypto/des/des.c b/src/lib/libcrypto/des/des.c index 215d7413c0..d8c846b23d 100644 --- a/src/lib/libcrypto/des/des.c +++ b/src/lib/libcrypto/des/des.c @@ -59,25 +59,25 @@ #include #include #include -#ifndef MSDOS -#ifndef VMS #include +#ifndef OPENSSL_SYS_MSDOS +#ifndef OPENSSL_SYS_VMS #include OPENSSL_UNISTD -#else /* VMS */ +#else /* OPENSSL_SYS_VMS */ #ifdef __DECC #include #else /* not __DECC */ #include #endif /* __DECC */ -#endif /* VMS */ -#else /* MSDOS */ +#endif /* OPENSSL_SYS_VMS */ +#else /* OPENSSL_SYS_MSDOS */ #include #endif #include #include "des_ver.h" -#ifdef VMS +#ifdef OPENSSL_SYS_VMS #include #include #else @@ -88,6 +88,7 @@ #endif #include #include +#include void usage(void); void doencryption(void); @@ -96,10 +97,10 @@ 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); -#ifdef VMS +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 #define EXIT(a) exit(a) @@ -119,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; @@ -152,12 +153,14 @@ int main(int argc, char **argv) case 'c': cflag=1; strncpy(cksumname,p,200); + cksumname[sizeof(cksumname)-1]='\0'; p+=strlen(cksumname); break; case 'C': cflag=1; longk=1; strncpy(cksumname,p,200); + cksumname[sizeof(cksumname)-1]='\0'; p+=strlen(cksumname); break; case 'e': @@ -189,6 +192,7 @@ int main(int argc, char **argv) case 'u': uflag=1; strncpy(uuname,p,200); + uuname[sizeof(uuname)-1]='\0'; p+=strlen(uuname); break; case 'h': @@ -258,12 +262,12 @@ int main(int argc, char **argv) #endif if ( (in != NULL) && (out != NULL) && -#ifndef MSDOS +#ifndef OPENSSL_SYS_MSDOS (stat(in,&ins) != -1) && (stat(out,&outs) != -1) && (ins.st_dev == outs.st_dev) && (ins.st_ino == outs.st_ino)) -#else /* MSDOS */ +#else /* OPENSSL_SYS_MSDOS */ (strcmp(in,out) == 0)) #endif { @@ -298,7 +302,7 @@ int main(int argc, char **argv) EXIT(5); } -#ifdef MSDOS +#ifdef OPENSSL_SYS_MSDOS /* This should set the file to binary mode. */ { #include @@ -360,14 +364,14 @@ 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 MSDOS +#ifndef OPENSSL_SYS_MSDOS static unsigned char buf[BUFSIZE+8],obuf[BUFSIZE+8]; #else static unsigned char *buf=NULL,*obuf=NULL; @@ -422,19 +426,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); } if (rem) memcpy(buf,&(buf[l]),(unsigned int)rem); @@ -581,28 +585,28 @@ void doencryption(void) if (bflag && !flag3) for (i=0; i= 8) memcpy(iv,&(buf[l-8]),8); } @@ -627,9 +631,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); @@ -664,8 +668,8 @@ void doencryption(void) problems: memset(buf,0,sizeof(buf)); memset(obuf,0,sizeof(obuf)); - memset(ks,0,sizeof(ks)); - memset(ks2,0,sizeof(ks2)); + memset(&ks,0,sizeof(ks)); + memset(&ks2,0,sizeof(ks2)); memset(iv,0,sizeof(iv)); memset(iv2,0,sizeof(iv2)); memset(kk,0,sizeof(kk)); diff --git a/src/lib/libcrypto/des/des.h b/src/lib/libcrypto/des/des.h index 6b8a7ee11b..dfe5ff64e4 100644 --- a/src/lib/libcrypto/des/des.h +++ b/src/lib/libcrypto/des/des.h @@ -59,39 +59,52 @@ #ifndef HEADER_DES_H #define HEADER_DES_H -#ifdef NO_DES +#ifdef OPENSSL_NO_DES #error DES is disabled. #endif -#ifdef _KERBEROS_DES_H -#error replaces . -#endif - #include /* DES_LONG */ #include /* OPENSSL_EXTERN */ +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#define des_SPtrans DES_SPtrans + #ifdef __cplusplus 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_struct +typedef struct DES_ks + { + union { - union { - des_cblock cblock; - /* make sure things are correct size on machines with - * 8 byte longs */ - DES_LONG deslong[2]; - } ks; - int weak_key; - } des_key_schedule[16]; + DES_cblock cblock; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG deslong[2]; + } ks[16]; + } DES_key_schedule; + +#ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT +# ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT +# define OPENSSL_ENABLE_OLD_DES_SUPPORT +# endif +#endif -#define DES_KEY_SZ (sizeof(des_cblock)) -#define DES_SCHEDULE_SZ (sizeof(des_key_schedule)) +#ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT +# include +#endif + +#define DES_KEY_SZ (sizeof(DES_cblock)) +#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) #define DES_ENCRYPT 1 #define DES_DECRYPT 0 @@ -99,44 +112,45 @@ typedef struct des_ks_struct #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_EXTERN int des_check_key; /* defaults to false */ -OPENSSL_EXTERN int des_rw_mode; /* defaults to DES_PCBC_MODE */ -OPENSSL_EXTERN int des_set_weak_key_flag; /* set the weak key flag */ - -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 @@ -145,119 +159,81 @@ 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); -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 verify); -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); +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); -int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify); - -/* The following definitions provide compatibility with the MIT Kerberos - * library. The des_key_schedule structure is not binary compatible. */ +void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length, + DES_key_schedule *schedule,DES_cblock *ivec,int *num); -#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 +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); -typedef des_key_schedule bit_64; -#define des_fixup_key_parity des_set_odd_parity +#define DES_fixup_key_parity DES_set_odd_parity #ifdef __cplusplus } diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c index 0bd9fa39bc..1c37ab96d3 100644 --- a/src/lib/libcrypto/des/des_enc.c +++ b/src/lib/libcrypto/des/des_enc.c @@ -58,11 +58,11 @@ #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 - register const unsigned char *des_SP=(const unsigned char *)des_SPtrans; + register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans; #endif #ifndef DES_UNROLL register int i; @@ -75,7 +75,7 @@ void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc) IP(r,l); /* Things have been modified so that the initial rotate is * done outside the loop. This required the - * des_SPtrans values in sp.h to be rotated 1 bit to the right. + * DES_SPtrans values in sp.h to be rotated 1 bit to the right. * One perl script later and things have a 5% speed up on a sparc2. * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> * for pointing this out. */ @@ -84,7 +84,7 @@ void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc) r=ROTATE(r,29)&0xffffffffL; l=ROTATE(l,29)&0xffffffffL; - s=ks->ks.deslong; + s=ks->ks->deslong; /* I don't know if it is worth the effort of loop unrolling the * inner loop */ if (enc) @@ -156,11 +156,11 @@ 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 - register const unsigned char *des_SP=(const unsigned char *)des_SPtrans; + register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans; #endif #ifndef DES_UNROLL register int i; @@ -172,7 +172,7 @@ void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc) /* Things have been modified so that the initial rotate is * done outside the loop. This required the - * des_SPtrans values in sp.h to be rotated 1 bit to the right. + * DES_SPtrans values in sp.h to be rotated 1 bit to the right. * One perl script later and things have a 5% speed up on a sparc2. * Thanks to Richard Outerbridge <71755.204@CompuServe.COM> * for pointing this out. */ @@ -180,7 +180,7 @@ void des_encrypt2(DES_LONG *data, des_key_schedule ks, int enc) r=ROTATE(r,29)&0xffffffffL; l=ROTATE(l,29)&0xffffffffL; - s=ks->ks.deslong; + s=ks->ks->deslong; /* I don't know if it is worth the effort of loop unrolling the * inner loop */ if (enc) @@ -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, des_key_schedule ks2, 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, des_key_schedule ks2, 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, des_key_schedule ks2, 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,11 +290,12 @@ void des_decrypt3(DES_LONG *data, des_key_schedule ks1, des_key_schedule ks2, #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; @@ -321,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]; @@ -336,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]; @@ -363,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]; @@ -384,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/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h index 1ace8f5930..70e833be3f 100644 --- a/src/lib/libcrypto/des/des_locl.h +++ b/src/lib/libcrypto/des/des_locl.h @@ -59,19 +59,19 @@ #ifndef HEADER_DES_LOCL_H #define HEADER_DES_LOCL_H -#if defined(WIN32) || defined(WIN16) -#ifndef MSDOS -#define MSDOS +#include + +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16) +#ifndef OPENSSL_SYS_MSDOS +#define OPENSSL_SYS_MSDOS #endif #endif #include #include -#include - -#ifndef MSDOS -#if !defined(VMS) || defined(__DECC) +#ifndef OPENSSL_SYS_MSDOS +#if !defined(OPENSSL_SYS_VMS) || defined(__DECC) #ifdef OPENSSL_UNISTD # include OPENSSL_UNISTD #else @@ -82,17 +82,22 @@ #endif #include -#ifdef MSDOS /* Visual C++ 2.1 (Windows NT/95) */ +#ifdef OPENSSL_SYS_MSDOS /* Visual C++ 2.1 (Windows NT/95) */ #include #include #include #include #endif -#if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS) +#if defined(__STDC__) || defined(OPENSSL_SYS_VMS) || defined(M_XENIX) || defined(OPENSSL_SYS_MSDOS) #include #endif +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + #define ITERATIONS 16 #define HALF_ITERATIONS 8 @@ -155,7 +160,7 @@ } \ } -#if defined(WIN32) && defined(_MSC_VER) +#if defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER) #define ROTATE(a,n) (_lrotr(a,n)) #else #define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n)))) @@ -278,24 +283,24 @@ u1=(int)u&0x3f; \ u2&=0x3f; \ u>>=16L; \ - LL^=des_SPtrans[0][u1]; \ - LL^=des_SPtrans[2][u2]; \ + LL^=DES_SPtrans[0][u1]; \ + LL^=DES_SPtrans[2][u2]; \ u3=(int)u>>8L; \ u1=(int)u&0x3f; \ u3&=0x3f; \ - LL^=des_SPtrans[4][u1]; \ - LL^=des_SPtrans[6][u3]; \ + LL^=DES_SPtrans[4][u1]; \ + LL^=DES_SPtrans[6][u3]; \ u2=(int)t>>8L; \ u1=(int)t&0x3f; \ u2&=0x3f; \ t>>=16L; \ - LL^=des_SPtrans[1][u1]; \ - LL^=des_SPtrans[3][u2]; \ + LL^=DES_SPtrans[1][u1]; \ + LL^=DES_SPtrans[3][u2]; \ u3=(int)t>>8L; \ u1=(int)t&0x3f; \ u3&=0x3f; \ - LL^=des_SPtrans[5][u1]; \ - LL^=des_SPtrans[7][u3]; } + LL^=DES_SPtrans[5][u1]; \ + LL^=DES_SPtrans[7][u3]; } #endif #ifdef DES_RISC2 #define D_ENCRYPT(LL,R,S) {\ @@ -306,25 +311,25 @@ u2=(int)u>>8L; \ u1=(int)u&0x3f; \ u2&=0x3f; \ - LL^=des_SPtrans[0][u1]; \ - LL^=des_SPtrans[2][u2]; \ + LL^=DES_SPtrans[0][u1]; \ + LL^=DES_SPtrans[2][u2]; \ s1=(int)u>>16L; \ s2=(int)u>>24L; \ s1&=0x3f; \ s2&=0x3f; \ - LL^=des_SPtrans[4][s1]; \ - LL^=des_SPtrans[6][s2]; \ + LL^=DES_SPtrans[4][s1]; \ + LL^=DES_SPtrans[6][s2]; \ u2=(int)t>>8L; \ u1=(int)t&0x3f; \ u2&=0x3f; \ - LL^=des_SPtrans[1][u1]; \ - LL^=des_SPtrans[3][u2]; \ + LL^=DES_SPtrans[1][u1]; \ + LL^=DES_SPtrans[3][u2]; \ s1=(int)t>>16; \ s2=(int)t>>24L; \ s1&=0x3f; \ s2&=0x3f; \ - LL^=des_SPtrans[5][s1]; \ - LL^=des_SPtrans[7][s2]; } + LL^=DES_SPtrans[5][s1]; \ + LL^=DES_SPtrans[7][s2]; } #endif #else @@ -333,14 +338,14 @@ LOAD_DATA_tmp(R,S,u,t,E0,E1); \ t=ROTATE(t,4); \ LL^=\ - des_SPtrans[0][(u>> 2L)&0x3f]^ \ - des_SPtrans[2][(u>>10L)&0x3f]^ \ - des_SPtrans[4][(u>>18L)&0x3f]^ \ - des_SPtrans[6][(u>>26L)&0x3f]^ \ - des_SPtrans[1][(t>> 2L)&0x3f]^ \ - des_SPtrans[3][(t>>10L)&0x3f]^ \ - des_SPtrans[5][(t>>18L)&0x3f]^ \ - des_SPtrans[7][(t>>26L)&0x3f]; } + DES_SPtrans[0][(u>> 2L)&0x3f]^ \ + DES_SPtrans[2][(u>>10L)&0x3f]^ \ + DES_SPtrans[4][(u>>18L)&0x3f]^ \ + DES_SPtrans[6][(u>>26L)&0x3f]^ \ + DES_SPtrans[1][(t>> 2L)&0x3f]^ \ + DES_SPtrans[3][(t>>10L)&0x3f]^ \ + DES_SPtrans[5][(t>>18L)&0x3f]^ \ + DES_SPtrans[7][(t>>26L)&0x3f]; } #endif #endif @@ -405,8 +410,8 @@ PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \ } -OPENSSL_EXTERN const DES_LONG des_SPtrans[8][64]; +OPENSSL_EXTERN const DES_LONG DES_SPtrans[8][64]; -void fcrypt_body(DES_LONG *out,des_key_schedule ks, - DES_LONG Eswap0, DES_LONG Eswap1); +void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, + DES_LONG Eswap0, DES_LONG Eswap1); #endif diff --git a/src/lib/libcrypto/des/des_old.c b/src/lib/libcrypto/des/des_old.c new file mode 100644 index 0000000000..7e4cd7180d --- /dev/null +++ b/src/lib/libcrypto/des/des_old.c @@ -0,0 +1,271 @@ +/* crypto/des/des_old.c -*- mode:C; c-file-style: "eay" -*- */ + +/* 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 + */ + +/* 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). + * + */ + +#define OPENSSL_DES_LIBDES_COMPATIBILITY +#include +#include + +const char *_ossl_old_des_options(void) + { + return DES_options(); + } +void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_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 _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec) + { + return DES_cbc_cksum((unsigned char *)input, output, length, + (DES_key_schedule *)schedule, ivec); + } +void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc) + { + DES_cbc_encrypt((unsigned char *)input, (unsigned char *)output, + length, (DES_key_schedule *)schedule, ivec, enc); + } +void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc) + { + DES_ncbc_encrypt((unsigned char *)input, (unsigned char *)output, + length, (DES_key_schedule *)schedule, ivec, enc); + } +void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + des_key_schedule schedule,_ossl_old_des_cblock *ivec, + _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc) + { + DES_xcbc_encrypt((unsigned char *)input, (unsigned char *)output, + length, (DES_key_schedule *)schedule, ivec, inw, outw, enc); + } +void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, + long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc) + { + DES_cfb_encrypt(in, out, numbits, length, + (DES_key_schedule *)schedule, ivec, enc); + } +void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + des_key_schedule ks,int enc) + { + DES_ecb_encrypt(input, output, (DES_key_schedule *)ks, enc); + } +void _ossl_old_des_encrypt(DES_LONG *data,des_key_schedule ks, int enc) + { + DES_encrypt1(data, (DES_key_schedule *)ks, enc); + } +void _ossl_old_des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc) + { + DES_encrypt2(data, (DES_key_schedule *)ks, enc); + } +void _ossl_old_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 _ossl_old_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 _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, _ossl_old_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 _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, _ossl_old_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 _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, + long length, des_key_schedule ks1, des_key_schedule ks2, + des_key_schedule ks3, _ossl_old_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 _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), + _ossl_old_des_cblock (*out_white)) + { + DES_xwhite_in2out(des_key, in_white, out_white); + } + +int _ossl_old_des_enc_read(int fd,char *buf,int len,des_key_schedule sched, + _ossl_old_des_cblock *iv) + { + return DES_enc_read(fd, buf, len, (DES_key_schedule *)sched, iv); + } +int _ossl_old_des_enc_write(int fd,char *buf,int len,des_key_schedule sched, + _ossl_old_des_cblock *iv) + { + return DES_enc_write(fd, buf, len, (DES_key_schedule *)sched, iv); + } +char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret) + { + return DES_fcrypt(buf, salt, ret); + } +char *_ossl_old_des_crypt(const char *buf,const char *salt) + { + return DES_crypt(buf, salt); + } +char *_ossl_old_crypt(const char *buf,const char *salt) + { + return DES_crypt(buf, salt); + } +void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out, + int numbits,long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec) + { + DES_ofb_encrypt(in, out, numbits, length, (DES_key_schedule *)schedule, + ivec); + } +void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc) + { + DES_pcbc_encrypt((unsigned char *)input, (unsigned char *)output, + length, (DES_key_schedule *)schedule, ivec, enc); + } +DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + long length,int out_count,_ossl_old_des_cblock *seed) + { + return DES_quad_cksum((unsigned char *)input, output, length, + out_count, seed); + } +void _ossl_old_des_random_seed(_ossl_old_des_cblock key) + { + RAND_seed(key, sizeof(_ossl_old_des_cblock)); + } +void _ossl_old_des_random_key(_ossl_old_des_cblock ret) + { + DES_random_key((DES_cblock *)ret); + } +int _ossl_old_des_read_password(_ossl_old_des_cblock *key, const char *prompt, + int verify) + { + return DES_read_password(key, prompt, verify); + } +int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1, _ossl_old_des_cblock *key2, + const char *prompt, int verify) + { + return DES_read_2passwords(key1, key2, prompt, verify); + } +void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key) + { + DES_set_odd_parity(key); + } +int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key) + { + return DES_is_weak_key(key); + } +int _ossl_old_des_set_key(_ossl_old_des_cblock *key,des_key_schedule schedule) + { + return DES_set_key(key, (DES_key_schedule *)schedule); + } +int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,des_key_schedule schedule) + { + return DES_key_sched(key, (DES_key_schedule *)schedule); + } +void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key) + { + DES_string_to_key(str, key); + } +void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2) + { + DES_string_to_2keys(str, key1, key2); + } +void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc) + { + DES_cfb64_encrypt(in, out, length, (DES_key_schedule *)schedule, + ivec, num, enc); + } +void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num) + { + DES_ofb64_encrypt(in, out, length, (DES_key_schedule *)schedule, + ivec, num); + } diff --git a/src/lib/libcrypto/des/des_old.h b/src/lib/libcrypto/des/des_old.h new file mode 100644 index 0000000000..3778f93c15 --- /dev/null +++ b/src/lib/libcrypto/des/des_old.h @@ -0,0 +1,437 @@ +/* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */ + +/* 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 openssl 0.9.6 and older as + * well as 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. + * + * This include files has two compatibility modes: + * + * - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API + * that is compatible with libdes and SSLeay. + * - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an + * API that is compatible with OpenSSL 0.9.5x to 0.9.6x. + * + * Note that these modes break earlier snapshots of OpenSSL, where + * libdes compatibility was the only available mode or (later on) the + * prefered compatibility mode. However, after much consideration + * (and more or less violent discussions with external parties), it + * was concluded that OpenSSL should be compatible with earlier versions + * of itself before anything else. Also, in all honesty, libdes is + * an old beast that shouldn't really be used any more. + * + * Please consider starting to use the DES_ functions rather than the + * des_ ones. The des_ functions will disappear completely before + * OpenSSL 1.0! + * + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + */ + +/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL + * project 2001. + */ +/* ==================================================================== + * Copyright (c) 1998-2002 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). + * + */ + +#ifndef HEADER_DES_OLD_H +#define HEADER_DES_OLD_H + +#ifdef OPENSSL_NO_DES +#error DES is disabled. +#endif + +#ifndef HEADER_DES_H +#error You must include des.h, not des_old.h directly. +#endif + +#ifdef _KERBEROS_DES_H +#error replaces . +#endif + +#include /* DES_LONG */ +#include /* OPENSSL_EXTERN */ +#include + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef unsigned char _ossl_old_des_cblock[8]; +typedef struct _ossl_old_des_ks_struct + { + union { + _ossl_old_des_cblock _; + /* make sure things are correct size on machines with + * 8 byte longs */ + DES_LONG pad[2]; + } ks; + } _ossl_old_des_key_schedule[16]; + +#ifndef OPENSSL_DES_LIBDES_COMPATIBILITY +#define des_cblock DES_cblock +#define const_des_cblock const_DES_cblock +#define des_key_schedule DES_key_schedule +#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\ + DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e)) +#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\ + DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e)) +#define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\ + DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e)) +#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\ + DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e)) +#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\ + DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n)) +#define des_options()\ + DES_options() +#define des_cbc_cksum(i,o,l,k,iv)\ + DES_cbc_cksum((i),(o),(l),&(k),(iv)) +#define des_cbc_encrypt(i,o,l,k,iv,e)\ + DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_ncbc_encrypt(i,o,l,k,iv,e)\ + DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\ + DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e)) +#define des_cfb_encrypt(i,o,n,l,k,iv,e)\ + DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e)) +#define des_ecb_encrypt(i,o,k,e)\ + DES_ecb_encrypt((i),(o),&(k),(e)) +#define des_encrypt1(d,k,e)\ + DES_encrypt1((d),&(k),(e)) +#define des_encrypt2(d,k,e)\ + DES_encrypt2((d),&(k),(e)) +#define des_encrypt3(d,k1,k2,k3)\ + DES_encrypt3((d),&(k1),&(k2),&(k3)) +#define des_decrypt3(d,k1,k2,k3)\ + DES_decrypt3((d),&(k1),&(k2),&(k3)) +#define des_xwhite_in2out(k,i,o)\ + DES_xwhite_in2out((k),(i),(o)) +#define des_enc_read(f,b,l,k,iv)\ + DES_enc_read((f),(b),(l),&(k),(iv)) +#define des_enc_write(f,b,l,k,iv)\ + DES_enc_write((f),(b),(l),&(k),(iv)) +#define des_fcrypt(b,s,r)\ + DES_fcrypt((b),(s),(r)) +#define des_crypt(b,s)\ + DES_crypt((b),(s)) +#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) +#define crypt(b,s)\ + DES_crypt((b),(s)) +#endif +#define des_ofb_encrypt(i,o,n,l,k,iv)\ + DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv)) +#define des_pcbc_encrypt(i,o,l,k,iv,e)\ + DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e)) +#define des_quad_cksum(i,o,l,c,s)\ + DES_quad_cksum((i),(o),(l),(c),(s)) +#define des_random_seed(k)\ + _ossl_096_des_random_seed((k)) +#define des_random_key(r)\ + DES_random_key((r)) +#define des_read_password(k,p,v) \ + DES_read_password((k),(p),(v)) +#define des_read_2passwords(k1,k2,p,v) \ + DES_read_2passwords((k1),(k2),(p),(v)) +#define des_set_odd_parity(k)\ + DES_set_odd_parity((k)) +#define des_check_key_parity(k)\ + DES_check_key_parity((k)) +#define des_is_weak_key(k)\ + DES_is_weak_key((k)) +#define des_set_key(k,ks)\ + DES_set_key((k),&(ks)) +#define des_key_sched(k,ks)\ + DES_key_sched((k),&(ks)) +#define des_set_key_checked(k,ks)\ + DES_set_key_checked((k),&(ks)) +#define des_set_key_unchecked(k,ks)\ + DES_set_key_unchecked((k),&(ks)) +#define des_string_to_key(s,k)\ + DES_string_to_key((s),(k)) +#define des_string_to_2keys(s,k1,k2)\ + DES_string_to_2keys((s),(k1),(k2)) +#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\ + DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e)) +#define des_ofb64_encrypt(i,o,l,ks,iv,n)\ + DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n)) + + +#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 +#else /* libdes compatibility */ +/* Map all symbol names to _ossl_old_des_* form, so we avoid all + clashes with libdes */ +#define des_cblock _ossl_old_des_cblock +#define des_key_schedule _ossl_old_des_key_schedule +#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\ + _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e)) +#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\ + _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e)) +#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\ + _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e)) +#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\ + _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n)) +#define des_options()\ + _ossl_old_des_options() +#define des_cbc_cksum(i,o,l,k,iv)\ + _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv)) +#define des_cbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_ncbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\ + _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e)) +#define des_cfb_encrypt(i,o,n,l,k,iv,e)\ + _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e)) +#define des_ecb_encrypt(i,o,k,e)\ + _ossl_old_des_ecb_encrypt((i),(o),(k),(e)) +#define des_encrypt(d,k,e)\ + _ossl_old_des_encrypt((d),(k),(e)) +#define des_encrypt2(d,k,e)\ + _ossl_old_des_encrypt2((d),(k),(e)) +#define des_encrypt3(d,k1,k2,k3)\ + _ossl_old_des_encrypt3((d),(k1),(k2),(k3)) +#define des_decrypt3(d,k1,k2,k3)\ + _ossl_old_des_decrypt3((d),(k1),(k2),(k3)) +#define des_xwhite_in2out(k,i,o)\ + _ossl_old_des_xwhite_in2out((k),(i),(o)) +#define des_enc_read(f,b,l,k,iv)\ + _ossl_old_des_enc_read((f),(b),(l),(k),(iv)) +#define des_enc_write(f,b,l,k,iv)\ + _ossl_old_des_enc_write((f),(b),(l),(k),(iv)) +#define des_fcrypt(b,s,r)\ + _ossl_old_des_fcrypt((b),(s),(r)) +#define des_crypt(b,s)\ + _ossl_old_des_crypt((b),(s)) +#define crypt(b,s)\ + _ossl_old_crypt((b),(s)) +#define des_ofb_encrypt(i,o,n,l,k,iv)\ + _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv)) +#define des_pcbc_encrypt(i,o,l,k,iv,e)\ + _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e)) +#define des_quad_cksum(i,o,l,c,s)\ + _ossl_old_des_quad_cksum((i),(o),(l),(c),(s)) +#define des_random_seed(k)\ + _ossl_old_des_random_seed((k)) +#define des_random_key(r)\ + _ossl_old_des_random_key((r)) +#define des_read_password(k,p,v) \ + _ossl_old_des_read_password((k),(p),(v)) +#define des_read_2passwords(k1,k2,p,v) \ + _ossl_old_des_read_2passwords((k1),(k2),(p),(v)) +#define des_set_odd_parity(k)\ + _ossl_old_des_set_odd_parity((k)) +#define des_is_weak_key(k)\ + _ossl_old_des_is_weak_key((k)) +#define des_set_key(k,ks)\ + _ossl_old_des_set_key((k),(ks)) +#define des_key_sched(k,ks)\ + _ossl_old_des_key_sched((k),(ks)) +#define des_string_to_key(s,k)\ + _ossl_old_des_string_to_key((s),(k)) +#define des_string_to_2keys(s,k1,k2)\ + _ossl_old_des_string_to_2keys((s),(k1),(k2)) +#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\ + _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e)) +#define des_ofb64_encrypt(i,o,l,ks,iv,n)\ + _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n)) + + +#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 +#endif + +const char *_ossl_old_des_options(void); +void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + _ossl_old_des_key_schedule ks1,_ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, int enc); +DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec); +void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec, + _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc); +void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits, + long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + _ossl_old_des_key_schedule ks,int enc); +void _ossl_old_des_encrypt(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc); +void _ossl_old_des_encrypt2(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc); +void _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1, + _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3); +void _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1, + _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3); +void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc); +void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc); +void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out, + long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2, + _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num); + +void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white), + _ossl_old_des_cblock (*out_white)); + +int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, + _ossl_old_des_cblock *iv); +int _ossl_old_des_enc_write(int fd,char *buf,int len,_ossl_old_des_key_schedule sched, + _ossl_old_des_cblock *iv); +char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret); +char *_ossl_old_des_crypt(const char *buf,const char *salt); +#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) +char *_ossl_old_crypt(const char *buf,const char *salt); +#endif +void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out, + int numbits,long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec); +void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length, + _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc); +DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output, + long length,int out_count,_ossl_old_des_cblock *seed); +void _ossl_old_des_random_seed(_ossl_old_des_cblock key); +void _ossl_old_des_random_key(_ossl_old_des_cblock ret); +int _ossl_old_des_read_password(_ossl_old_des_cblock *key,const char *prompt,int verify); +int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2, + const char *prompt,int verify); +void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key); +int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key); +int _ossl_old_des_set_key(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule); +int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule); +void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key); +void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2); +void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, + _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc); +void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, + _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num); + +void _ossl_096_des_random_seed(des_cblock *key); + +/* The following definitions provide compatibility with the MIT Kerberos + * library. The _ossl_old_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 + +/* for DES_read_pw_string et al */ +#include + +#endif diff --git a/src/lib/libcrypto/des/des_old2.c b/src/lib/libcrypto/des/des_old2.c new file mode 100644 index 0000000000..c8fa3ee135 --- /dev/null +++ b/src/lib/libcrypto/des/des_old2.c @@ -0,0 +1,82 @@ +/* crypto/des/des_old.c -*- mode:C; c-file-style: "eay" -*- */ + +/* 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 OpenSSL 0.9.6c. 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 + */ + +/* 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). + * + */ + +#undef OPENSSL_DES_LIBDES_COMPATIBILITY +#include +#include + +void _ossl_096_des_random_seed(DES_cblock *key) + { + RAND_seed(key, sizeof(DES_cblock)); + } diff --git a/src/lib/libcrypto/des/des_opts.c b/src/lib/libcrypto/des/des_opts.c index 138ee1c6b4..79278b920e 100644 --- a/src/lib/libcrypto/des/des_opts.c +++ b/src/lib/libcrypto/des/des_opts.c @@ -59,12 +59,12 @@ /* define PART1, PART2, PART3 or PART4 to build only with a few of the options. * This is for machines with 64k code segment size restrictions. */ -#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) +#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX) #define TIMES #endif #include -#ifndef MSDOS +#ifndef OPENSSL_SYS_MSDOS #include #include OPENSSL_UNISTD #else @@ -84,7 +84,7 @@ extern void exit(); The __TMS macro will show if it was. If it wasn't defined, we should undefine TIMES, since that tells the rest of the program how things should be handled. -- Richard Levitte */ -#if defined(VMS) && defined(__DECC) && !defined(__TMS) +#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS) #undef TIMES #endif @@ -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; @@ -598,7 +598,7 @@ int main(int argc, char **argv) break; } exit(0); -#if defined(LINT) || defined(MSDOS) +#if defined(LINT) || defined(OPENSSL_SYS_MSDOS) return(0); #endif } diff --git a/src/lib/libcrypto/des/des_ver.h b/src/lib/libcrypto/des/des_ver.h index de3c02f110..0fa94d5368 100644 --- a/src/lib/libcrypto/des/des_ver.h +++ b/src/lib/libcrypto/des/des_ver.h @@ -57,5 +57,11 @@ */ #include + +#ifdef OPENSSL_BUILD_SHLIBCRYPTO +# undef OPENSSL_EXTERN +# define OPENSSL_EXTERN OPENSSL_EXPORT +#endif + OPENSSL_EXTERN char *DES_version; /* SSLeay version string */ OPENSSL_EXTERN char *libdes_version; /* old libdes version string */ diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c index df0d615d6b..58e8c35dcb 100644 --- a/src/lib/libcrypto/des/destest.c +++ b/src/lib/libcrypto/des/destest.c @@ -56,25 +56,26 @@ * [including the GNU Public Licence.] */ -#if defined(WIN32) || defined(WIN16) || defined(WINDOWS) -#ifndef MSDOS -#define MSDOS +#include +#include + +#include +#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_WINDOWS) +#ifndef OPENSSL_SYS_MSDOS +#define OPENSSL_SYS_MSDOS #endif #endif -#include -#include -#ifndef MSDOS -#if !defined(VMS) || defined(__DECC) -#include +#ifndef OPENSSL_SYS_MSDOS +#if !defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_VMS_DECC) #include OPENSSL_UNISTD -#endif /* VMS */ +#endif #else #include #endif #include -#ifdef NO_DES +#ifdef OPENSSL_NO_DES int main(int argc, char *argv[]) { printf("No DES support\n"); @@ -83,7 +84,7 @@ int main(int argc, char *argv[]) #else #include -#if defined(PERL5) || defined(__FreeBSD__) +#if defined(PERL5) || defined(__FreeBSD__) || defined(NeXT) #define crypt(c,s) (des_crypt((c),(s))) #endif @@ -348,19 +349,19 @@ int main(int argc, char *argv[]) int num; char *str; -#ifndef NO_DESCBCM +#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; @@ -372,9 +373,9 @@ 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) @@ -385,7 +386,7 @@ int main(int argc, char *argv[]) */ 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; @@ -404,7 +405,7 @@ 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/src/lib/libcrypto/des/fcrypt.c b/src/lib/libcrypto/des/fcrypt.c index 9b21f81cc2..d3d27de9f7 100644 --- a/src/lib/libcrypto/des/fcrypt.c +++ b/src/lib/libcrypto/des/fcrypt.c @@ -50,48 +50,55 @@ static unsigned const char cov_2char[64]={ 0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A }; -#ifndef NOPROTO -void fcrypt_body(DES_LONG *out,des_key_schedule ks, - DES_LONG Eswap0, DES_LONG Eswap1); +void fcrypt_body(DES_LONG *out,DES_key_schedule *ks, + DES_LONG Eswap0, DES_LONG Eswap1); -#if defined(PERL5) || defined(FreeBSD) || defined(__OpenBSD__) -char *des_crypt(const char *buf,const char *salt); -#else -char *crypt(const char *buf,const char *salt); -#endif -#else -void fcrypt_body(); -#ifdef PERL5 -char *des_crypt(); -#else -char *crypt(); -#endif -#endif - -#if defined(PERL5) || defined(FreeBSD) || defined(__OpenBSD__) -char *des_crypt(buf,salt) -#else -char *crypt(buf,salt) -#endif -const char *buf; -const char *salt; +char *DES_crypt(const char *buf, const char *salt) { static char buff[14]; - return(des_fcrypt(buf,salt,buff)); +#ifndef CHARSET_EBCDIC + return(DES_fcrypt(buf,salt,buff)); +#else + char e_salt[2+1]; + char e_buf[32+1]; /* replace 32 by 8 ? */ + char *ret; + + /* Copy at most 2 chars of salt */ + if ((e_salt[0] = salt[0]) != '\0') + e_salt[1] = salt[1]; + + /* Copy at most 32 chars of password */ + strncpy (e_buf, buf, sizeof(e_buf)); + + /* 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 */ + 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); + + /* Convert the result back to EBCDIC */ + ascii2ebcdic(ret, ret, strlen(ret)); + + return ret; +#endif } -char *des_fcrypt(buf,salt,ret) -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; @@ -104,10 +111,17 @@ char *ret; * crypt to "*". This was found when replacing the crypt in * our shared libraries. People found that the disabled * accounts effectively had no passwd :-(. */ +#ifndef CHARSET_EBCDIC x=ret[0]=((salt[0] == '\0')?'A':salt[0]); Eswap0=con_salt[x]<<2; x=ret[1]=((salt[1] == '\0')?'A':salt[1]); Eswap1=con_salt[x]<<6; +#else + x=ret[0]=((salt[0] == '\0')?os_toascii['A']:salt[0]); + Eswap0=con_salt[x]<<2; + x=ret[1]=((salt[1] == '\0')?os_toascii['A']:salt[1]); + Eswap1=con_salt[x]<<6; +#endif /* EAY r=strlen(buf); @@ -122,8 +136,8 @@ r=(r+7)/8; for (; i<8; i++) key[i]=0; - des_set_key_unchecked(&key,ks); - fcrypt_body(&(out[0]),ks,Eswap0,Eswap1); + DES_set_key_unchecked(&key,&ks); + fcrypt_body(&(out[0]),&ks,Eswap0,Eswap1); ll=out[0]; l2c(ll,b); ll=out[1]; l2c(ll,b); @@ -149,4 +163,3 @@ r=(r+7)/8; ret[13]='\0'; return(ret); } - diff --git a/src/lib/libcrypto/des/fcrypt_b.c b/src/lib/libcrypto/des/fcrypt_b.c index 22c87f5983..1390138787 100644 --- a/src/lib/libcrypto/des/fcrypt_b.c +++ b/src/lib/libcrypto/des/fcrypt_b.c @@ -77,12 +77,12 @@ #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, - DES_LONG Eswap1) +void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0, + DES_LONG Eswap1) { register DES_LONG l,r,t,u; #ifdef DES_PTR - register const unsigned char *des_SP=(const unsigned char *)des_SPtrans; + register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans; #endif register DES_LONG *s; register int j; diff --git a/src/lib/libcrypto/des/ncbc_enc.c b/src/lib/libcrypto/des/ncbc_enc.c index b8db07b199..fda23d522f 100644 --- a/src/lib/libcrypto/des/ncbc_enc.c +++ b/src/lib/libcrypto/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/src/lib/libcrypto/des/ofb64ede.c b/src/lib/libcrypto/des/ofb64ede.c index 6eafe908da..26bbf9a6a7 100644 --- a/src/lib/libcrypto/des/ofb64ede.c +++ b/src/lib/libcrypto/des/ofb64ede.c @@ -62,15 +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, - register unsigned char *out, long length, des_key_schedule k1, - des_key_schedule k2, des_key_schedule k3, des_cblock *ivec, - int *num) +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, + 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; @@ -90,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]; @@ -115,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/src/lib/libcrypto/des/ofb64enc.c b/src/lib/libcrypto/des/ofb64enc.c index 1a1d1f1ac4..8ca3d49dea 100644 --- a/src/lib/libcrypto/des/ofb64enc.c +++ b/src/lib/libcrypto/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, - register unsigned char *out, long length, des_key_schedule schedule, - des_cblock *ivec, int *num) +void DES_ofb64_encrypt(register const unsigned char *in, + register unsigned char *out, long length, + 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/src/lib/libcrypto/des/ofb_enc.c b/src/lib/libcrypto/des/ofb_enc.c index 70493e632c..e887a3c6f4 100644 --- a/src/lib/libcrypto/des/ofb_enc.c +++ b/src/lib/libcrypto/des/ofb_enc.c @@ -64,8 +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; @@ -101,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/src/lib/libcrypto/des/pcbc_enc.c b/src/lib/libcrypto/des/pcbc_enc.c index 5b987f074d..17a40f9520 100644 --- a/src/lib/libcrypto/des/pcbc_enc.c +++ b/src/lib/libcrypto/des/pcbc_enc.c @@ -58,8 +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]; @@ -85,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; @@ -103,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/src/lib/libcrypto/des/qud_cksm.c b/src/lib/libcrypto/des/qud_cksm.c index 9fff989edb..dac201227e 100644 --- a/src/lib/libcrypto/des/qud_cksm.c +++ b/src/lib/libcrypto/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/src/lib/libcrypto/des/rand_key.c b/src/lib/libcrypto/des/rand_key.c index ee1a6c274e..2398165568 100644 --- a/src/lib/libcrypto/des/rand_key.c +++ b/src/lib/libcrypto/des/rand_key.c @@ -56,18 +56,13 @@ #include #include -void des_random_seed(des_cblock *key) - { - 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/src/lib/libcrypto/des/read2pwd.c b/src/lib/libcrypto/des/read2pwd.c index a8ceaf088a..b4720c3a98 100644 --- a/src/lib/libcrypto/des/read2pwd.c +++ b/src/lib/libcrypto/des/read2pwd.c @@ -1,4 +1,57 @@ /* crypto/des/read2pwd.c */ +/* ==================================================================== + * Copyright (c) 2001-2002 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). + * + */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -56,28 +109,30 @@ * [including the GNU Public Licence.] */ -#include "des_locl.h" +#include +#include +#include -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); + if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) + 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); + if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0) + DES_string_to_2keys(buf,key1,key2); memset(buf,0,BUFSIZ); memset(buff,0,BUFSIZ); return(ok); diff --git a/src/lib/libcrypto/des/read_pwd.c b/src/lib/libcrypto/des/read_pwd.c index c27ec336e7..ae9aef620b 100644 --- a/src/lib/libcrypto/des/read_pwd.c +++ b/src/lib/libcrypto/des/read_pwd.c @@ -56,8 +56,8 @@ * [including the GNU Public Licence.] */ -#if !defined(MSDOS) && !defined(VMS) && !defined(WIN32) -#include +#include +#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WIN32) #ifdef OPENSSL_UNISTD # include OPENSSL_UNISTD #else @@ -78,7 +78,7 @@ /* #define SIGACTION */ /* Define this if you have sigaction() */ #ifdef WIN16TTY -#undef WIN16 +#undef OPENSSL_SYS_WIN16 #undef _WINDOWS #include #endif @@ -92,7 +92,7 @@ #include #include -#ifdef VMS /* prototypes for sys$whatever */ +#ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */ #include #ifdef __DECC #pragma message disable DOLLARID @@ -127,12 +127,18 @@ #undef SGTTY #endif -#if !defined(TERMIO) && !defined(TERMIOS) && !defined(VMS) && !defined(MSDOS) && !defined(MAC_OS_pre_X) && !defined(MAC_OS_GUSI_SOURCE) +#if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(MAC_OS_pre_X) && !defined(MAC_OS_GUSI_SOURCE) #undef TERMIOS #undef TERMIO #define SGTTY #endif +#if defined(OPENSSL_SYS_VSWORKS) +#undef TERMIOS +#undef TERMIO +#undef SGTTY +#endif + #ifdef TERMIOS #include #define TTY_STRUCT struct termios @@ -157,16 +163,16 @@ #define TTY_set(tty,data) ioctl(tty,TIOCSETP,data) #endif -#if !defined(_LIBC) && !defined(MSDOS) && !defined(VMS) && !defined(MAC_OS_pre_X) +#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(MAC_OS_pre_X) #include #endif -#if defined(MSDOS) && !defined(__CYGWIN32__) +#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__) #include #define fgets(a,b,c) noecho_fgets(a,b,c) #endif -#ifdef VMS +#ifdef OPENSSL_SYS_VMS #include #include #include @@ -195,17 +201,17 @@ static void read_till_nl(FILE *); static void recsig(int); static void pushsig(void); static void popsig(void); -#if defined(MSDOS) && !defined(WIN16) +#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) static int noecho_fgets(char *buf, int size, FILE *tty); #endif #ifdef SIGACTION static struct sigaction savsig[NX509_SIG]; #else - static void (*savsig[NX509_SIG])(int ); + static void (*savsig[NX509_SIG])(int ); #endif static jmp_buf save; -int des_read_pw_string(char *buf, int length, const char *prompt, +int _ossl_old_des_read_pw_string(char *buf, int length, const char *prompt, int verify) { char buff[BUFSIZ]; @@ -216,7 +222,7 @@ int des_read_pw_string(char *buf, int length, const char *prompt, return(ret); } -#ifndef WIN16 +#ifndef OPENSSL_SYS_WIN16 static void read_till_nl(FILE *in) { @@ -233,14 +239,14 @@ static void read_till_nl(FILE *in) int des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify) { -#ifdef VMS +#ifdef OPENSSL_SYS_VMS struct IOSB iosb; $DESCRIPTOR(terminal,"TT"); long tty_orig[3], tty_new[3]; long status; unsigned short channel = 0; #else -#ifndef MSDOS +#ifndef OPENSSL_SYS_MSDOS TTY_STRUCT tty_orig,tty_new; #endif #endif @@ -265,19 +271,19 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt, is_a_tty=1; tty=NULL; -#ifdef MSDOS +#ifdef OPENSSL_SYS_MSDOS if ((tty=fopen("con","r")) == NULL) tty=stdin; -#elif defined(MAC_OS_pre_X) +#elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VSWORKS) tty=stdin; #else -#ifndef MPE +#ifndef OPENSSL_SYS_MPE if ((tty=fopen("/dev/tty","r")) == NULL) #endif tty=stdin; #endif -#if defined(TTY_get) && !defined(VMS) +#if defined(TTY_get) && !defined(OPENSSL_SYS_VMS) if (TTY_get(fileno(tty),&tty_orig) == -1) { #ifdef ENOTTY @@ -296,7 +302,7 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt, } memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig)); #endif -#ifdef VMS +#ifdef OPENSSL_SYS_VMS status = sys$assign(&terminal,&channel,0,0); if (status != SS$_NORMAL) return(-1); @@ -312,15 +318,15 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt, tty_new.TTY_FLAGS &= ~ECHO; #endif -#if defined(TTY_set) && !defined(VMS) +#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS) if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1)) -#ifdef MPE +#ifdef OPENSSL_SYS_MPE ; /* MPE lies -- echo really has been disabled */ #else return(-1); #endif #endif -#ifdef VMS +#ifdef OPENSSL_SYS_VMS tty_new[0] = tty_orig[0]; tty_new[1] = tty_orig[1] | TT$M_NOECHO; tty_new[2] = tty_orig[2]; @@ -366,14 +372,14 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt, error: fprintf(stderr,"\n"); -#ifdef DEBUG +#if 0 perror("fgets(tty)"); #endif /* What can we do if there is an error? */ -#if defined(TTY_set) && !defined(VMS) +#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS) if (ps >= 2) TTY_set(fileno(tty),&tty_orig); #endif -#ifdef VMS +#ifdef OPENSSL_SYS_VMS if (ps >= 2) status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0 ,tty_orig,12,0,0,0,0); @@ -381,13 +387,13 @@ error: if (ps >= 1) popsig(); if (stdin != tty) fclose(tty); -#ifdef VMS +#ifdef OPENSSL_SYS_VMS status = sys$dassgn(channel); #endif return(!ok); } -#else /* WIN16 */ +#else /* OPENSSL_SYS_WIN16 */ int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify) { @@ -460,7 +466,7 @@ static void recsig(int i) #endif } -#if defined(MSDOS) && !defined(WIN16) +#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16) static int noecho_fgets(char *buf, int size, FILE *tty) { int i; diff --git a/src/lib/libcrypto/des/rpc_enc.c b/src/lib/libcrypto/des/rpc_enc.c index 32d96d5cae..d937d08da5 100644 --- a/src/lib/libcrypto/des/rpc_enc.c +++ b/src/lib/libcrypto/des/rpc_enc.c @@ -63,20 +63,20 @@ 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, - len,ks,&desp->des_ivec,enc); + 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 * in secure_rpc. diff --git a/src/lib/libcrypto/des/rpw.c b/src/lib/libcrypto/des/rpw.c index 0b6b1519b0..8a9473c4f9 100644 --- a/src/lib/libcrypto/des/rpw.c +++ b/src/lib/libcrypto/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/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c index 09afd4fc03..683916e71b 100644 --- a/src/lib/libcrypto/des/set_key.c +++ b/src/lib/libcrypto/des/set_key.c @@ -65,7 +65,7 @@ */ #include "des_locl.h" -OPENSSL_GLOBAL int des_check_key=0; +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; @@ -342,7 +342,11 @@ void des_set_key_unchecked(const_des_cblock *key, des_key_schedule schedule) register DES_LONG *k; register int i; - k = &schedule->ks.deslong[0]; +#if OPENBSD_DEV_CRYPTO + memcpy(schedule->key,key,sizeof schedule->key); + schedule->session=NULL; +#endif + k = &schedule->ks->deslong[0]; in = &(*key)[0]; c2l(in,c); @@ -390,13 +394,14 @@ 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 void des_fixup_key_parity(des_cblock *key) { des_set_odd_parity(key); } +*/ diff --git a/src/lib/libcrypto/des/speed.c b/src/lib/libcrypto/des/speed.c index 1223edf290..48fc1d49fc 100644 --- a/src/lib/libcrypto/des/speed.c +++ b/src/lib/libcrypto/des/speed.c @@ -59,7 +59,7 @@ /* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */ /* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */ -#if !defined(MSDOS) && (!defined(VMS) || defined(__DECC)) +#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX) #define TIMES #endif @@ -82,7 +82,7 @@ OPENSSL_DECLARE_EXIT The __TMS macro will show if it was. If it wasn't defined, we should undefine TIMES, since that tells the rest of the program how things should be handled. -- Richard Levitte */ -#if defined(VMS) && defined(__DECC) && !defined(__TMS) +#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS) #undef TIMES #endif @@ -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; @@ -304,7 +304,7 @@ int main(int argc, char **argv) printf("DES ede cbc bytes per sec = %12.2f (%9.3fuS)\n",d,8.0e6/d); printf("crypt per sec = %12.2f (%9.3fuS)\n",e,1.0e6/e); exit(0); -#if defined(LINT) || defined(MSDOS) +#if defined(LINT) || defined(OPENSSL_SYS_MSDOS) return(0); #endif } diff --git a/src/lib/libcrypto/des/spr.h b/src/lib/libcrypto/des/spr.h index b8fbdcf8d3..b91936a5a5 100644 --- a/src/lib/libcrypto/des/spr.h +++ b/src/lib/libcrypto/des/spr.h @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -OPENSSL_GLOBAL const DES_LONG des_SPtrans[8][64]={ +OPENSSL_GLOBAL const DES_LONG DES_SPtrans[8][64]={ { /* nibble 0 */ 0x02080800L, 0x00080000L, 0x02000002L, 0x02080802L, diff --git a/src/lib/libcrypto/des/str2key.c b/src/lib/libcrypto/des/str2key.c index c6abb87201..36c3f81d99 100644 --- a/src/lib/libcrypto/des/str2key.c +++ b/src/lib/libcrypto/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,22 @@ 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); - memset(ks,0,sizeof(ks)); - des_set_odd_parity(key); + DES_set_odd_parity(key); +#ifdef EXPERIMENTAL_STR_TO_STRONG_KEY + if(DES_is_weak_key(key)) + (*key)[7] ^= 0xF0; + DES_set_key(key,&ks); +#else + DES_set_key_unchecked(key,&ks); +#endif + DES_cbc_cksum((const unsigned char*)str,key,length,&ks,key); + memset(&ks,0,sizeof(ks)); + 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 +149,25 @@ 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); - 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); +#ifdef EXPERIMENTAL_STR_TO_STRONG_KEY + if(DES_is_weak_key(key1)) + (*key1)[7] ^= 0xF0; + DES_set_key(key1,&ks); +#else + DES_set_key_unchecked(key1,&ks); +#endif + DES_cbc_cksum((const unsigned char*)str,key1,length,&ks,key1); +#ifdef EXPERIMENTAL_STR_TO_STRONG_KEY + if(DES_is_weak_key(key2)) + (*key2)[7] ^= 0xF0; + DES_set_key(key2,&ks); +#else + DES_set_key_unchecked(key2,&ks); +#endif + 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); } diff --git a/src/lib/libcrypto/des/xcbc_enc.c b/src/lib/libcrypto/des/xcbc_enc.c index ccfede13ac..47246eb466 100644 --- a/src/lib/libcrypto/des/xcbc_enc.c +++ b/src/lib/libcrypto/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,9 +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; @@ -138,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); } @@ -147,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); } @@ -163,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); @@ -175,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); -- cgit v1.2.3-55-g6feb