This commit is contained in:
Martin Willi
2006-05-10 12:44:32 +00:00
parent 2af2b9fec5
commit 1cc981b9af
2 changed files with 0 additions and 553 deletions
-245
View File
@@ -1,245 +0,0 @@
#ifndef FREESWANSRCDIR
#FREESWANSRCDIR=../..
#endif
#
#include ${FREESWANSRCDIR}/Makefile.inc
#
#KLIPSD=${FREESWANSRCDIR}/linux
#SRCDIR=${KLIPSD}/crypto/ciphers/des
#
#VPATH =${SRCDIR}
# You must select the correct terminal control system to be used to
# turn character echo off when reading passwords. There a 5 systems
# SGTTY - the old BSD system
# TERMIO - most system V boxes
# TERMIOS - SGI (ala IRIX).
# VMS - the DEC operating system
# MSDOS - we all know what it is :-)
# read_pwd.c makes a reasonable guess at what is correct.
# Targets
# make - twidle the options yourself :-)
# make cc - standard cc options
# make gcc - standard gcc options
# make x86-elf - linux-elf etc
# make x86-out - linux-a.out, FreeBSD etc
# make x86-solaris
# make x86-bdsi
# If you are on a DEC Alpha, edit des.h and change the DES_LONG
# define to 'unsigned int'. I have seen this give a %20 speedup.
OPTS0= -DLIBDES_LIT -DRAND -DTERMIO #-DNOCONST
# Version 1.94 has changed the strings_to_key function so that it is
# now compatible with MITs when the string is longer than 8 characters.
# If you wish to keep the old version, uncomment the following line.
# This will affect the -E/-D options on des(1).
#OPTS1= -DOLD_STR_TO_KEY
# There are 4 possible performance options
# -DDES_PTR
# -DDES_RISC1
# -DDES_RISC2 (only one of DES_RISC1 and DES_RISC2)
# -DDES_UNROLL
# after the initial build, run 'des_opts' to see which options are best
# for your platform. There are some listed in options.txt
#OPTS2= -DDES_PTR
#OPTS3= -DDES_RISC1 # or DES_RISC2
#OPTS4= -DDES_UNROLL
OPTS= $(OPTS0) $(OPTS1) $(OPTS2) $(OPTS3) $(OPTS4)
MAKE=make -f Makefile
#CC=cc
#CFLAG= -O
#CC=gcc
#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
# normally overridden by FreeS/WAN Makefiles anyway
CFLAG= -O3 -fomit-frame-pointer -I${KLIPSD}/include -I${SRCDIR}
CFLAGS=$(OPTS) $(CFLAG) $(USERCOMPILE)
CPP=$(CC) -E
# Assember version of des_encrypt*().
DES_ENC=des_enc.o fcrypt_b.o # normal C version
#DES_ENC=asm/dx86-elf.o asm/yx86-elf.o # elf format x86
#DES_ENC=asm/dx86-out.o asm/yx86-out.o # a.out format x86
#DES_ENC=asm/dx86-sol.o asm/yx86-sol.o # solaris format x86
#DES_ENC=asm/dx86bsdi.o asm/yx86basi.o # bsdi format x86
LIBDIR=$(DESTDIR)$(INC_USRLOCAL)/lib
INCDIR=$(DESTDIR)$(INC_USRLOCAL)/include
MANDIR=$(MANTREE)
MAN1=1
MAN3=3
SHELL=/bin/sh
MAN1=1
MAN3=3
SHELL=/bin/sh
OBJ_LIT=cbc_enc.o ecb_enc.o $(DES_ENC) fcrypt.o set_key.o
OBJ_FULL=cbc_cksm.o $(OBJ_LIT) pcbc_enc.o \
xcbc_enc.o qud_cksm.o \
cfb64ede.o cfb64enc.o cfb_enc.o ecb3_enc.o \
enc_read.o enc_writ.o ofb64ede.o ofb64enc.o ofb_enc.o \
rand_key.o read_pwd.o read2pwd.o rpc_enc.o str2key.o supp.o
GENERAL_LIT=COPYRIGHT INSTALL README VERSION Makefile des_crypt.man \
des.doc options.txt asm
GENERAL_FULL=$(GENERAL_LIT) FILES Imakefile times vms.com KERBEROS MODES.DES \
des.man DES.pm DES.pod DES.xs Makefile.PL dess.S des3s.S \
Makefile.uni typemap t Makefile.ssl makefile.bc Makefile.lit \
des.org des_locl.org
TESTING_LIT= destest speed des_opts
TESTING_FULL= rpw $(TESTING_LIT)
TESTING_SRC_LIT=destest.c speed.c des_opts.c
TESTING_SRC_FULL=rpw.c $(TESTING_SRC_LIT)
HEADERS_LIT=des_ver.h des.h des_locl.h podd.h sk.h spr.h
HEADERS_FULL= $(HEADERS_LIT) rpc_des.h
LIBDES_LIT=cbc_enc.c ecb_enc.c fcrypt.c set_key.c des_enc.c fcrypt_b.c
LIBDES_FULL= cbc_cksm.c pcbc_enc.c qud_cksm.c \
cfb64ede.c cfb64enc.c cfb_enc.c ecb3_enc.c \
enc_read.c enc_writ.c ofb64ede.c ofb64enc.c ofb_enc.c \
rand_key.c rpc_enc.c str2key.c supp.c \
xcbc_enc.c $(LIBDES_LIT) read_pwd.c read2pwd.c
PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
OBJ= $(OBJ_LIT)
GENERAL=$(GENERAL_LIT)
TESTING=$(TESTING_LIT)
TESTING_SRC=$(TESTING_SRC_LIT)
HEADERS=$(HEADERS_LIT)
LIBDES= $(LIBDES_LIT)
ALL= $(GENERAL) $(TESTING_SRC) $(LIBDES) $(PERL) $(HEADERS)
DLIB= libdes.a
.PHONY: all cc gcc x86-elf x86-out x86-solaris x86-bsdi test tar_lit \
tar shar depend clean dclean install check checkprograms
all: $(DLIB) $(TESTING)
programs: $(DLIB)
cc:
$(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
gcc:
$(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
x86-elf:
$(MAKE) DES_ENC='asm/dx86-elf.o asm/yx86-elf.o' CC='$(CC)' CFLAGS="-DELF $(OPTS) $(CFLAG)" all
x86-out:
$(MAKE) DES_ENC='asm/dx86-out.o asm/yx86-out.o' CC='$(CC)' CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
x86-solaris:
$(MAKE) DES_ENC='asm/dx86-sol.o asm/yx86-sol.o' CC='$(CC)' CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
x86-bsdi:
$(MAKE) DES_ENC='asm/dx86bsdi.o asm/yx86bsdi.o' CC='$(CC)' CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
# elf
asm/dx86-elf.o: asm/dx86unix.S
$(CPP) -DELF asm/dx86unix.S | $(AS) -o asm/dx86-elf.o
asm/yx86-elf.o: asm/yx86unix.S
$(CPP) -DELF asm/yx86unix.S | $(AS) -o asm/yx86-elf.o
# solaris
asm/dx86-sol.o: asm/dx86unix.S
$(CC) -E -DSOL asm/dx86unix.S | sed 's/^#.*//' > asm/dx86-sol.s
as -o asm/dx86-sol.o asm/dx86-sol.s
rm -f asm/dx86-sol.s
asm/yx86-sol.o: asm/yx86unix.S
$(CC) -E -DSOL asm/yx86unix.S | sed 's/^#.*//' > asm/yx86-sol.s
as -o asm/yx86-sol.o asm/yx86-sol.s
rm -f asm/yx86-sol.s
# a.out
asm/dx86-out.o: asm/dx86unix.S
$(CPP) -DOUT asm/dx86unix.S | $(AS) -o asm/dx86-out.o
asm/yx86-out.o: asm/yx86unix.S
$(CPP) -DOUT asm/yx86unix.S | $(AS) -o asm/yx86-out.o
# bsdi
asm/dx86bsdi.o: asm/dx86unix.S
$(CPP) -DBSDI asm/dx86unix.S | $(AS) -o asm/dx86bsdi.o
asm/yx86bsdi.o: asm/yx86unix.S
$(CPP) -DBSDI asm/yx86unix.S | $(AS) -o asm/yx86bsdi.o
asm/dx86unix.S:
(cd asm; perl des-586.pl cpp >dx86unix.S)
asm/yx86unix.S:
(cd asm; perl crypt586.pl cpp >yx86unix.S)
test: all
./destest
$(DLIB): $(OBJ)
rm -f $(DLIB)
$(AR) crs $(DLIB) $(OBJ)
des_opts: des_opts.o $(DLIB)
$(CC) $(CFLAGS) -o des_opts des_opts.o $(DLIB)
destest: destest.o $(DLIB)
$(CC) $(CFLAGS) -o destest destest.o $(DLIB)
rpw: rpw.o $(DLIB)
$(CC) $(CFLAGS) -o rpw rpw.o $(DLIB)
speed: speed.o $(DLIB)
$(CC) $(CFLAGS) -o speed speed.o $(DLIB)
des: des.o $(DLIB)
$(CC) $(CFLAGS) -o des des.o $(DLIB)
tags:
ctags $(TESTING_SRC) $(LIBDES)
tar_lit:
/bin/mv Makefile Makefile.tmp
/bin/cp Makefile.lit Makefile
tar chf libdes-l.tar $(LIBDES_LIT) $(HEADERS_LIT) \
$(GENERAL_LIT) $(TESTING_SRC_LIT)
/bin/rm -f Makefile
/bin/mv Makefile.tmp Makefile
tar:
tar chf libdes.tar $(ALL)
shar:
shar $(ALL) >libdes.shar
depend:
makedepend $(LIBDES) $(TESTING_SRC)
clean:
/bin/rm -f *.o tags core $(TESTING) $(DLIB) .nfs* *.old *.bak asm/*.o \
asm/*.S
dclean:
sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
mv -f Makefile.new Makefile
install install_file_list:
@true
check:
echo no checks in lib right now.
checkprograms:
# DO NOT DELETE THIS LINE -- make depend depends on it.
-308
View File
@@ -1,308 +0,0 @@
/* crypto/des/des.org */
/* Copyright (C) 1995-1997 Eric Young ([email protected])
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young ([email protected]).
* The implementation was written so as to conform with Netscapes SSL.
*
* This library is free for commercial and non-commercial use as long as
* the following conditions are aheared to. The following conditions
* apply to all code found in this distribution, be it the RC4, RSA,
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
* included with this distribution is covered by the same copyright terms
* except that the holder is Tim Hudson ([email protected]).
*
* Copyright remains Eric Young's, and as such any Copyright notices in
* the code are not to be removed.
* If this package is used in a product, Eric Young should be given attribution
* as the author of the parts of the library used.
* This can be in the form of a textual message at program startup or
* in documentation (online or textual) provided with the package.
*
* 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 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 acknowledgement:
* "This product includes cryptographic software written by
* Eric Young ([email protected])"
* The word 'cryptographic' can be left out if the rouines from the library
* being used are not cryptographic related :-).
* 4. If you include any Windows specific code (or a derivative thereof) from
* the apps directory (application code) you must include an acknowledgement:
* "This product includes software written by Tim Hudson ([email protected])"
*
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
* ANY EXPRESS 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 AUTHOR OR 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.
*
* The licence and distribution terms for any publically available version or
* derivative of this code cannot be changed. i.e. this code cannot simply be
* copied and put under another distribution licence
* [including the GNU Public Licence.]
*/
/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
*
* Always modify des.org since des.h is automatically generated from
* it during SSLeay configuration.
*
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
*/
#ifndef HEADER_DES_H
#define HEADER_DES_H
#ifdef __cplusplus
extern "C" {
#endif
/* If this is set to 'unsigned int' on a DEC Alpha, this gives about a
* %20 speed up (longs are 8 bytes, int's are 4). */
/* Must be unsigned int on ia64/Itanium or DES breaks badly */
#ifdef __KERNEL__
#include <linux/types.h>
#else
#include <sys/types.h>
#endif
#ifndef DES_LONG
#define DES_LONG u_int32_t
#endif
typedef unsigned char des_cblock[8];
typedef struct des_ks_struct
{
union {
des_cblock _;
/* make sure things are correct size on machines with
* 8 byte longs */
DES_LONG pad[2];
} ks;
#undef _
#define _ ks._
} des_key_schedule[16];
#define DES_KEY_SZ (sizeof(des_cblock))
#define DES_SCHEDULE_SZ (sizeof(des_key_schedule))
#define DES_ENCRYPT 1
#define DES_DECRYPT 0
#define DES_CBC_MODE 0
#define DES_PCBC_MODE 1
#define des_ecb2_encrypt(i,o,k1,k2,e) \
des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
#define C_Block des_cblock
#define Key_schedule des_key_schedule
#ifdef KERBEROS
#define ENCRYPT DES_ENCRYPT
#define DECRYPT DES_DECRYPT
#endif
#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
/* For compatibility with the MIT lib - eay 20/05/92 */
typedef des_key_schedule bit_64;
#define des_fixup_key_parity des_set_odd_parity
#define des_check_key_parity check_parity
extern int des_check_key; /* defaults to false */
extern int des_rw_mode; /* defaults to DES_PCBC_MODE */
/* The next line is used to disable full ANSI prototypes, if your
* compiler has problems with the prototypes, make sure this line always
* evaluates to true :-) */
#if defined(MSDOS) || defined(__STDC__)
#undef NOPROTO
#endif
#ifndef NOPROTO
char *des_options(void);
void des_ecb3_encrypt(des_cblock *input,des_cblock *output,
des_key_schedule ks1,des_key_schedule ks2,
des_key_schedule ks3, int enc);
DES_LONG des_cbc_cksum(des_cblock *input,des_cblock *output,
long length,des_key_schedule schedule,des_cblock *ivec);
void des_cbc_encrypt(des_cblock *input,des_cblock *output,long length,
des_key_schedule schedule,des_cblock *ivec,int enc);
void des_ncbc_encrypt(des_cblock *input,des_cblock *output,long length,
des_key_schedule schedule,des_cblock *ivec,int enc);
void des_xcbc_encrypt(des_cblock *input,des_cblock *output,long length,
des_key_schedule schedule,des_cblock *ivec,
des_cblock *inw,des_cblock *outw,int enc);
void des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
long length,des_key_schedule schedule,des_cblock *ivec,int enc);
void des_ecb_encrypt(des_cblock *input,des_cblock *output,
des_key_schedule ks,int enc);
void des_encrypt(DES_LONG *data,des_key_schedule ks, int enc);
void des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc);
void des_encrypt3(DES_LONG *data, des_key_schedule ks1,
des_key_schedule ks2, des_key_schedule ks3);
void des_decrypt3(DES_LONG *data, des_key_schedule ks1,
des_key_schedule ks2, des_key_schedule ks3);
void des_ede3_cbc_encrypt(des_cblock *input, des_cblock *output,
long length, des_key_schedule ks1, des_key_schedule ks2,
des_key_schedule ks3, des_cblock *ivec, int enc);
void des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
long length, des_key_schedule ks1, des_key_schedule ks2,
des_key_schedule ks3, des_cblock *ivec, int *num, int enc);
void des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
long length, des_key_schedule ks1, des_key_schedule ks2,
des_key_schedule ks3, des_cblock *ivec, int *num);
void des_xwhite_in2out(des_cblock (*des_key), des_cblock (*in_white),
des_cblock (*out_white));
int des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
des_cblock *iv);
int des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
des_cblock *iv);
char *des_fcrypt(const char *buf,const char *salt, char *ret);
#ifdef PERL5
char *des_crypt(const char *buf,const char *salt);
#else
/* some stupid compilers complain because I have declared char instead
* of const char */
#ifndef __KERNEL__
#ifdef HEADER_DES_LOCL_H
char *crypt(const char *buf,const char *salt);
#else /* HEADER_DES_LOCL_H */
char *crypt(void);
#endif /* HEADER_DES_LOCL_H */
#endif /* __KERNEL__ */
#endif /* PERL5 */
void des_ofb_encrypt(unsigned char *in,unsigned char *out,
int numbits,long length,des_key_schedule schedule,des_cblock *ivec);
void des_pcbc_encrypt(des_cblock *input,des_cblock *output,long length,
des_key_schedule schedule,des_cblock *ivec,int enc);
DES_LONG des_quad_cksum(des_cblock *input,des_cblock *output,
long length,int out_count,des_cblock *seed);
void des_random_seed(des_cblock key);
void des_random_key(des_cblock ret);
int des_read_password(des_cblock *key,char *prompt,int verify);
int des_read_2passwords(des_cblock *key1,des_cblock *key2,
char *prompt,int verify);
int des_read_pw_string(char *buf,int length,char *prompt,int verify);
void des_set_odd_parity(des_cblock *key);
int des_is_weak_key(des_cblock *key);
int des_set_key(des_cblock *key,des_key_schedule schedule);
int des_key_sched(des_cblock *key,des_key_schedule schedule);
void des_string_to_key(char *str,des_cblock *key);
void des_string_to_2keys(char *str,des_cblock *key1,des_cblock *key2);
void des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
des_key_schedule schedule, des_cblock *ivec, int *num, int enc);
void des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
des_key_schedule schedule, des_cblock *ivec, int *num);
int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify);
/* Extra functions from Mark Murray <[email protected]> */
/* The following functions are not in the normal unix build or the
* SSLeay build. When using the SSLeay build, use RAND_seed()
* and RAND_bytes() instead. */
int des_new_random_key(des_cblock *key);
void des_init_random_number_generator(des_cblock *key);
void des_set_random_generator_seed(des_cblock *key);
void des_set_sequence_number(des_cblock new_sequence_number);
void des_generate_random_block(des_cblock *block);
#else
char *des_options();
void des_ecb3_encrypt();
DES_LONG des_cbc_cksum();
void des_cbc_encrypt();
void des_ncbc_encrypt();
void des_xcbc_encrypt();
void des_cfb_encrypt();
void des_ede3_cfb64_encrypt();
void des_ede3_ofb64_encrypt();
void des_ecb_encrypt();
void des_encrypt();
void des_encrypt2();
void des_encrypt3();
void des_decrypt3();
void des_ede3_cbc_encrypt();
int des_enc_read();
int des_enc_write();
char *des_fcrypt();
#ifdef PERL5
char *des_crypt();
#else
char *crypt();
#endif
void des_ofb_encrypt();
void des_pcbc_encrypt();
DES_LONG des_quad_cksum();
void des_random_seed();
void des_random_key();
int des_read_password();
int des_read_2passwords();
int des_read_pw_string();
void des_set_odd_parity();
int des_is_weak_key();
int des_set_key();
int des_key_sched();
void des_string_to_key();
void des_string_to_2keys();
void des_cfb64_encrypt();
void des_ofb64_encrypt();
int des_read_pw();
void des_xwhite_in2out();
/* Extra functions from Mark Murray <[email protected]> */
/* The following functions are not in the normal unix build or the
* SSLeay build. When using the SSLeay build, use RAND_seed()
* and RAND_bytes() instead. */
#ifdef FreeBSD
int des_new_random_key();
void des_init_random_number_generator();
void des_set_random_generator_seed();
void des_set_sequence_number();
void des_generate_random_block();
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif