2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 10:37:41 -04:00

Remove old SDK code from CWE source base. Now entirely in SDK submodule.

This commit is contained in:
rarified
2021-10-17 16:50:42 -06:00
parent 3489b924ce
commit 8434eb25ce
368 changed files with 0 additions and 163385 deletions

View File

@ -1,122 +0,0 @@
# Microsoft Developer Studio Project File - Name="blowfish" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=blowfish - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Blowfish.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Blowfish.mak" CFG="blowfish - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "blowfish - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "blowfish - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
!IF "$(CFG)" == "blowfish - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /GB /Za /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "blowfish - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /GB /Za /W4 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "blowfish - Win32 Release"
# Name "blowfish - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter ".c"
# Begin Source File
SOURCE=.\bf_cbc.c
# End Source File
# Begin Source File
SOURCE=.\bf_cfb64.c
# End Source File
# Begin Source File
SOURCE=.\bf_ecb.c
# End Source File
# Begin Source File
SOURCE=.\bf_enc.c
# End Source File
# Begin Source File
SOURCE=.\bf_ofb64.c
# End Source File
# Begin Source File
SOURCE=.\bf_skey.c
# End Source File
# End Group
# Begin Group "Include Files"
# PROP Default_Filter ".h"
# Begin Source File
SOURCE=.\bf_locl.h
# End Source File
# Begin Source File
SOURCE=.\bf_pi.h
# End Source File
# Begin Source File
SOURCE=.\blowfish.h
# End Source File
# End Group
# End Target
# End Project

View File

@ -1,128 +0,0 @@
# Microsoft Developer Studio Project File - Name="blowfish" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=blowfish - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Blowfish.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Blowfish.mak" CFG="blowfish - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "blowfish - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "blowfish - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "blowfish - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /Za /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ELSEIF "$(CFG)" == "blowfish - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /Za /W4 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE RSC /l 0x409
# ADD RSC /l 0x409
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo
!ENDIF
# Begin Target
# Name "blowfish - Win32 Release"
# Name "blowfish - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter ".c"
# Begin Source File
SOURCE=.\bf_cbc.c
# End Source File
# Begin Source File
SOURCE=.\bf_cfb64.c
# End Source File
# Begin Source File
SOURCE=.\bf_ecb.c
# End Source File
# Begin Source File
SOURCE=.\bf_enc.c
# End Source File
# Begin Source File
SOURCE=.\bf_ofb64.c
# End Source File
# Begin Source File
SOURCE=.\bf_skey.c
# End Source File
# End Group
# Begin Group "Include Files"
# PROP Default_Filter ".h"
# Begin Source File
SOURCE=.\bf_locl.h
# End Source File
# Begin Source File
SOURCE=.\bf_pi.h
# End Source File
# Begin Source File
SOURCE=.\blowfish.h
# End Source File
# End Group
# End Target
# End Project

View File

@ -1,46 +0,0 @@
Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
All rights reserved.
This package is an Blowfish implementation written
by Eric Young (eay@mincom.oz.au).
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.
Copyright remains Eric Young's, and as such any Copyright notices in
the code are not to be removed.
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 software developed by Eric Young (eay@mincom.oz.au)
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 license 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 distrubution license
[including the GNU Public License.]
The reason behind this being stated in this direct manner is past
experience in code simply being copied and the attribution removed
from it and then being distributed as part of other packages. This
implementation was a non-trivial and unpaid effort.

View File

@ -1,14 +0,0 @@
This Eric Young's blowfish implementation, taken from his SSLeay library
and made available as a separate library.
The version number (0.7.2m) is the SSLeay version that this library was
taken from.
To build, just unpack and type make.
If you are not using gcc, edit the Makefile.
If you are compiling for an x86 box, try the assembler (it needs improving).
There are also some compile time options that can improve performance,
these are documented in the Makefile.
eric 15-Apr-1997

View File

@ -1,160 +0,0 @@
# 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
# use BF_PTR2 for intel boxes,
# BF_PTR for sparc and MIPS/SGI
# use nothing for Alpha and HP.
# There are 3 possible performance options, experiment :-)
#OPTS= -DBF_PTR # usr for sparc and MIPS/SGI
#OPTS= -DBF_PTR2 # use for pentium
#OPTS= # use for pentium pro, Alpha and HP
MAKE=make -f Makefile
CC=cc
CFLAG= -O
#CC=gcc
#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
#CFLAG= -O3 -fomit-frame-pointer
CFLAGS=$(OPTS) $(CFLAG)
CPP=$(CC) -E
AS=as
# Assember version of bf_encrypt().
BF_ENC=bf_enc.o # normal C version
#BF_ENC=asm/bx86-elf.o # elf format x86
#BF_ENC=asm/bx86-out.o # a.out format x86
#BF_ENC=asm/bx86-sol.o # solaris format x86
#BF_ENC=asm/bx86bsdi.o # bsdi format x86
LIBDIR=/usr/local/lib
BINDIR=/usr/local/bin
INCDIR=/usr/local/include
MANDIR=/usr/local/man
MAN1=1
MAN3=3
SHELL=/bin/sh
LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cbc.o bf_cfb64.o bf_ofb64.o
LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cbc.c bf_cfb64.c bf_ofb64.c
GENERAL=Makefile Makefile.ssl Makefile.uni asm bf_locl.org README \
COPYRIGHT INSTALL blowfish.doc
TESTING= bftest bfspeed
TESTING_SRC=bftest.c bfspeed.c
HEADERS=bf_locl.h blowfish.h bf_pi.h
ALL= $(GENERAL) $(TESTING_SRC) $(LIBSRC) $(HEADERS)
BLIB= libblowfish.a
all: $(BLIB) $(TESTING)
cc:
$(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
gcc:
$(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
x86-elf:
$(MAKE) BF_ENC='asm/bx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
x86-out:
$(MAKE) BF_ENC='asm/bx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
x86-solaris:
$(MAKE) BF_ENC='asm/bx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
x86-bsdi:
$(MAKE) BF_ENC='asm/bx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
# elf
asm/bx86-elf.o: asm/bx86-cpp.s asm/bx86unix.cpp
$(CPP) -DELF asm/bx86unix.cpp | $(AS) -o asm/bx86-elf.o
# solaris
asm/bx86-sol.o: asm/bx86-cpp.s asm/bx86unix.cpp
$(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s
as -o asm/bx86-sol.o asm/bx86-sol.s
rm -f asm/bx86-sol.s
# a.out
asm/bx86-out.o: asm/bx86-cpp.s asm/bx86unix.cpp
$(CPP) -DOUT asm/bx86unix.cpp | $(AS) -o asm/bx86-out.o
# bsdi
asm/bx86bsdi.o: asm/bx86-cpp.s asm/bx86unix.cpp
$(CPP) -DBSDI asm/bx86unix.cpp | $(AS) -o asm/bx86bsdi.o
test: all
./bftest
$(BLIB): $(LIBOBJ)
/bin/rm -f $(BLIB)
ar cr $(BLIB) $(LIBOBJ)
-if test -s /bin/ranlib; then /bin/ranlib $(BLIB); \
else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(BLIB); \
else exit 0; fi; fi
bftest: bftest.o $(BLIB)
$(CC) $(CFLAGS) -o bftest bftest.o $(BLIB)
bfspeed: bfspeed.o $(BLIB)
$(CC) $(CFLAGS) -o bfspeed bfspeed.o $(BLIB)
tags:
ctags $(TESTING_SRC) $(LIBBF)
tar:
tar chf libbf.tar $(ALL)
shar:
shar $(ALL) >libbf.shar
depend:
makedepend $(LIBBF) $(TESTING_SRC)
clean:
rm -f *.o tags core $(TESTING) $(BLIB) .nfs* *.old *.bak asm/*.o
dclean:
sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
mv -f Makefile.new Makefile
# Eric is probably going to choke when he next looks at this --tjh
install: $(BLIB)
if test $(INSTALLTOP); then \
echo SSL style install; \
cp $(BLIB) $(INSTALLTOP)/lib; \
if test -s /bin/ranlib; then \
/bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \
else \
if test -s /usr/bin/ranlib; then \
/usr/bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \
fi; fi; \
chmod 644 $(INSTALLTOP)/lib/$(BLIB); \
cp blowfish.h $(INSTALLTOP)/include; \
chmod 644 $(INSTALLTOP)/include/blowfish.h; \
else \
echo Standalone install; \
cp $(BLIB) $(LIBDIR)/$(BLIB); \
if test -s /bin/ranlib; then \
/bin/ranlib $(LIBDIR)/$(BLIB); \
else \
if test -s /usr/bin/ranlib; then \
/usr/bin/ranlib $(LIBDIR)/$(BLIB); \
fi; \
fi; \
chmod 644 $(LIBDIR)/$(BLIB); \
cp blowfish.h $(INCDIR)/blowfish.h; \
chmod 644 $(INCDIR)/blowfish.h; \
fi
# DO NOT DELETE THIS LINE -- make depend depends on it.

View File

@ -1,104 +0,0 @@
#
# SSLeay/crypto/blowfish/Makefile
#
DIR= bf
TOP= ../..
CC= cc
CPP= $(CC) -E
INCLUDES=
CFLAG=-g
INSTALLTOP=/usr/local/ssl
MAKE= make -f Makefile.ssl
MAKEDEPEND= makedepend -fMakefile.ssl
MAKEFILE= Makefile.ssl
BF_ENC= bf_enc.o
# or use
#DES_ENC= bx86-elf.o
CFLAGS= $(INCLUDES) $(CFLAG)
GENERAL=Makefile
TEST=bftest.c
APPS=
LIB=$(TOP)/libcrypto.a
LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cbc.c bf_cfb64.c bf_ofb64.c
LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cbc.o bf_cfb64.o bf_ofb64.o
SRC= $(LIBSRC)
EXHEADER= blowfish.h
HEADER= bf_pi.h bf_locl.h $(EXHEADER)
ALL= $(GENERAL) $(SRC) $(HEADER)
top:
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
all: lib
lib: $(LIBOBJ)
ar r $(LIB) $(LIBOBJ)
sh $(TOP)/util/ranlib.sh $(LIB)
@touch lib
# elf
asm/bx86-elf.o: asm/bx86-cpp.s asm/bx86unix.cpp
$(CPP) -DELF asm/bx86unix.cpp | as -o asm/bx86-elf.o
# solaris
asm/bx86-sol.o: asm/bx86-cpp.s asm/bx86unix.cpp
$(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s
as -o asm/bx86-sol.o asm/bx86-sol.s
rm -f asm/bx86-sol.s
# a.out
asm/bx86-out.o: asm/bx86-cpp.s asm/bx86unix.cpp
$(CPP) -DOUT asm/bx86unix.cpp | as -o asm/bx86-out.o
# bsdi
asm/bx86bsdi.o: asm/bx86-cpp.s asm/bx86unix.cpp
$(CPP) -DBSDI asm/bx86unix.cpp | as -o asm/bx86bsdi.o
files:
perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
links:
/bin/rm -f Makefile
$(TOP)/util/point.sh Makefile.ssl Makefile ;
/bin/rm -f des.doc
$(TOP)/util/point.sh ../../doc/blowfish.doc blowfish.doc ;
$(TOP)/util/mklink.sh ../../include $(EXHEADER)
$(TOP)/util/mklink.sh ../../test $(TEST)
$(TOP)/util/mklink.sh ../../apps $(APPS)
install:
@for i in $(EXHEADER) ; \
do \
(cp $$i $(INSTALLTOP)/include/$$i; \
chmod 644 $(INSTALLTOP)/include/$$i ); \
done;
tags:
ctags $(SRC)
tests:
lint:
lint -DLINT $(INCLUDES) $(SRC)>fluff
depend:
$(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC)
dclean:
perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
mv -f Makefile.new $(MAKEFILE)
clean:
/bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
errors:
# DO NOT DELETE THIS LINE -- make depend depends on it.

View File

@ -1,160 +0,0 @@
# 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
# use BF_PTR2 for intel boxes,
# BF_PTR for sparc and MIPS/SGI
# use nothing for Alpha and HP.
# There are 3 possible performance options, experiment :-)
OPTS= -DBF_PTR # usr for sparc and MIPS/SGI
#OPTS= -DBF_PTR2 # use for pentium
#OPTS= # use for pentium pro, Alpha and HP
MAKE=make -f Makefile
#CC=cc
#CFLAG= -O
CC=gcc
#CFLAG= -O4 -funroll-loops -fomit-frame-pointer
CFLAG= -O3 -fomit-frame-pointer
CFLAGS=$(OPTS) $(CFLAG)
CPP=$(CC) -E
AS=as
# Assember version of bf_encrypt().
BF_ENC=bf_enc.o # normal C version
#BF_ENC=asm/bx86-elf.o # elf format x86
#BF_ENC=asm/bx86-out.o # a.out format x86
#BF_ENC=asm/bx86-sol.o # solaris format x86
#BF_ENC=asm/bx86bsdi.o # bsdi format x86
LIBDIR=/usr/local/lib
BINDIR=/usr/local/bin
INCDIR=/usr/local/include
MANDIR=/usr/local/man
MAN1=1
MAN3=3
SHELL=/bin/sh
LIBOBJ=bf_skey.o bf_ecb.o $(BF_ENC) bf_cbc.o bf_cfb64.o bf_ofb64.o
LIBSRC=bf_skey.c bf_ecb.c bf_enc.c bf_cbc.c bf_cfb64.c bf_ofb64.c
GENERAL=Makefile Makefile.ssl Makefile.uni asm bf_locl.org README \
COPYRIGHT INSTALL blowfish.doc
TESTING= bftest bfspeed
TESTING_SRC=bftest.c bfspeed.c
HEADERS=bf_locl.h blowfish.h bf_pi.h
ALL= $(GENERAL) $(TESTING_SRC) $(LIBSRC) $(HEADERS)
BLIB= libblowfish.a
all: $(BLIB) $(TESTING)
cc:
$(MAKE) CC=cc CFLAGS="-O $(OPTS) $(CFLAG)" all
gcc:
$(MAKE) CC=gcc CFLAGS="-O3 -fomit-frame-pointer $(OPTS) $(CFLAG)" all
x86-elf:
$(MAKE) BF_ENC='asm/bx86-elf.o' CC=$(CC) CFLAGS="-DELF $(OPTS) $(CFLAG)" all
x86-out:
$(MAKE) BF_ENC='asm/bx86-out.o' CC=$(CC) CFLAGS="-DOUT $(OPTS) $(CFLAG)" all
x86-solaris:
$(MAKE) BF_ENC='asm/bx86-sol.o' CC=$(CC) CFLAGS="-DSOL $(OPTS) $(CFLAG)" all
x86-bsdi:
$(MAKE) BF_ENC='asm/bx86bsdi.o' CC=$(CC) CFLAGS="-DBSDI $(OPTS) $(CFLAG)" all
# elf
asm/bx86-elf.o: asm/bx86-cpp.s asm/bx86unix.cpp
$(CPP) -DELF asm/bx86unix.cpp | $(AS) -o asm/bx86-elf.o
# solaris
asm/bx86-sol.o: asm/bx86-cpp.s asm/bx86unix.cpp
$(CC) -E -DSOL asm/bx86unix.cpp | sed 's/^#.*//' > asm/bx86-sol.s
as -o asm/bx86-sol.o asm/bx86-sol.s
rm -f asm/bx86-sol.s
# a.out
asm/bx86-out.o: asm/bx86-cpp.s asm/bx86unix.cpp
$(CPP) -DOUT asm/bx86unix.cpp | $(AS) -o asm/bx86-out.o
# bsdi
asm/bx86bsdi.o: asm/bx86-cpp.s asm/bx86unix.cpp
$(CPP) -DBSDI asm/bx86unix.cpp | $(AS) -o asm/bx86bsdi.o
test: all
./bftest
$(BLIB): $(LIBOBJ)
/bin/rm -f $(BLIB)
ar cr $(BLIB) $(LIBOBJ)
-if test -s /bin/ranlib; then /bin/ranlib $(BLIB); \
else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(BLIB); \
else exit 0; fi; fi
bftest: bftest.o $(BLIB)
$(CC) $(CFLAGS) -o bftest bftest.o $(BLIB)
bfspeed: bfspeed.o $(BLIB)
$(CC) $(CFLAGS) -o bfspeed bfspeed.o $(BLIB)
tags:
ctags $(TESTING_SRC) $(LIBBF)
tar:
tar chf libbf.tar $(ALL)
shar:
shar $(ALL) >libbf.shar
depend:
makedepend $(LIBBF) $(TESTING_SRC)
clean:
/bin/rm -f *.o tags core $(TESTING) $(BLIB) .nfs* *.old *.bak asm/*.o
dclean:
sed -e '/^# DO NOT DELETE THIS LINE/ q' Makefile >Makefile.new
mv -f Makefile.new Makefile
# Eric is probably going to choke when he next looks at this --tjh
install: $(BLIB)
if test $(INSTALLTOP); then \
echo SSL style install; \
cp $(BLIB) $(INSTALLTOP)/lib; \
if test -s /bin/ranlib; then \
/bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \
else \
if test -s /usr/bin/ranlib; then \
/usr/bin/ranlib $(INSTALLTOP)/lib/$(BLIB); \
fi; fi; \
chmod 644 $(INSTALLTOP)/lib/$(BLIB); \
cp blowfish.h $(INSTALLTOP)/include; \
chmod 644 $(INSTALLTOP)/include/blowfish.h; \
else \
echo Standalone install; \
cp $(BLIB) $(LIBDIR)/$(BLIB); \
if test -s /bin/ranlib; then \
/bin/ranlib $(LIBDIR)/$(BLIB); \
else \
if test -s /usr/bin/ranlib; then \
/usr/bin/ranlib $(LIBDIR)/$(BLIB); \
fi; \
fi; \
chmod 644 $(LIBDIR)/$(BLIB); \
cp blowfish.h $(INCDIR)/blowfish.h; \
chmod 644 $(INCDIR)/blowfish.h; \
fi
# DO NOT DELETE THIS LINE -- make depend depends on it.

View File

@ -1,8 +0,0 @@
This is a quick packaging up of my blowfish code into a library.
It has been lifted from SSLeay.
The copyright notices seem a little harsh because I have not spent the
time to rewrite the conditions from the normal SSLeay ones.
Basically if you just want to play with the library, not a problem.
eric 15-Apr-1997

View File

@ -1,159 +0,0 @@
#!/usr/local/bin/perl
$prog="bf586.pl";
# base code is in microsft
# op dest, source
# format.
#
if ( ($ARGV[0] eq "elf"))
{ require "x86unix.pl"; }
elsif ( ($ARGV[0] eq "a.out"))
{ $aout=1; require "x86unix.pl"; }
elsif ( ($ARGV[0] eq "sol"))
{ $sol=1; require "x86unix.pl"; }
elsif ( ($ARGV[0] eq "cpp"))
{ $cpp=1; require "x86unix.pl"; }
elsif ( ($ARGV[0] eq "win32"))
{ require "x86ms.pl"; }
else
{
print STDERR <<"EOF";
Pick one target type from
elf - linux, FreeBSD etc
a.out - old linux
sol - x86 solaris
cpp - format so x86unix.cpp can be used
win32 - Windows 95/Windows NT
EOF
exit(1);
}
&comment("Don't even think of reading this code");
&comment("It was automatically generated by $prog");
&comment("Which is a perl program used to generate the x86 assember for");
&comment("any of elf, a.out, Win32, or Solaris");
&comment("It can be found in SSLeay 0.7.0+");
&comment("eric <eay\@mincom.oz.au>");
&comment("");
&file("bfx86xxxx");
$BF_ROUNDS=16;
$BF_OFF=($BF_ROUNDS+2)*4;
$L="ecx";
$R="edx";
$P="edi";
$tot="esi";
$tmp1="eax";
$tmp2="ebx";
$tmp3="ebp";
&des_encrypt("BF_encrypt");
&file_end();
sub des_encrypt
{
local($name)=@_;
&function_begin($name,3);
&comment("");
&comment("Load the 2 words");
&mov("eax",&wparam(0));
&mov($L,&DWP(0,"eax","",0));
&mov($R,&DWP(4,"eax","",0));
&comment("");
&comment("P pointer, s and enc flag");
&mov($P,&wparam(1));
&xor( $tmp1, $tmp1);
&xor( $tmp2, $tmp2);
# encrypting part
&mov("ebp",&wparam(2)); # get encrypt flag
&cmp("ebp","0");
&je(&label("start_decrypt"));
&xor($L,&DWP(0,$P,"",0));
for ($i=0; $i<$BF_ROUNDS; $i+=2)
{
&comment("");
&comment("Round $i");
&BF_ENCRYPT($i+1,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3);
&comment("");
&comment("Round ".sprintf("%d",$i+1));
&BF_ENCRYPT($i+2,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3);
}
&xor($R,&DWP(($BF_ROUNDS+1)*4,$P,"",0));
&mov("eax",&wparam(0));
&mov(&DWP(0,"eax","",0),$R);
&mov(&DWP(4,"eax","",0),$L);
&function_end_A($name);
&set_label("start_decrypt");
&xor($L,&DWP(($BF_ROUNDS+1)*4,$P,"",0));
for ($i=$BF_ROUNDS; $i>0; $i-=2)
{
&comment("");
&comment("Round $i");
&BF_ENCRYPT($i,$R,$L,$P,$tot,$tmp1,$tmp2,$tmp3);
&comment("");
&comment("Round ".sprintf("%d",$i-1));
&BF_ENCRYPT($i-1,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3);
}
&xor($R,&DWP(0,$P,"",0));
&mov("eax",&wparam(0));
&mov(&DWP(0,"eax","",0),$R);
&mov(&DWP(4,"eax","",0),$L);
&function_end_A($name);
&function_end_B($name);
}
sub BF_ENCRYPT
{
local($i,$L,$R,$P,$tot,$tmp1,$tmp2,$tmp3)=@_;
&rotr( $R, 16);
&mov( $tot, &DWP(&n2a($i*4),$P,"",0));
&movb( &LB($tmp1), &HB($R));
&movb( &LB($tmp2), &LB($R));
&rotr( $R, 16);
&xor( $L, $tot);
&mov( $tot, &DWP(&n2a($BF_OFF+0x0000),$P,$tmp1,4));
&mov( $tmp3, &DWP(&n2a($BF_OFF+0x0400),$P,$tmp2,4));
&movb( &LB($tmp1), &HB($R));
&movb( &LB($tmp2), &LB($R));
&add( $tot, $tmp3);
&mov( $tmp1, &DWP(&n2a($BF_OFF+0x0800),$P,$tmp1,4)); # delay
&xor( $tot, $tmp1);
&mov( $tmp3, &DWP(&n2a($BF_OFF+0x0C00),$P,$tmp2,4));
&add( $tot, $tmp3);
&xor( $tmp1, $tmp1);
&xor( $L, $tot);
# delay
}
sub n2a
{
sprintf("%d",$_[0]);
}

View File

@ -1,666 +0,0 @@
/* Don't even think of reading this code */
/* It was automatically generated by bf586.pl */
/* Which is a perl program used to generate the x86 assember for */
/* any of elf, a.out, Win32, or Solaris */
/* It can be found in SSLeay 0.7.0+ */
/* eric <eay@mincom.oz.au> */
.file "bfx86xxxx.s"
.version "01.01"
gcc2_compiled.:
.text
.align ALIGN
.globl BF_encrypt
TYPE(BF_encrypt,@function)
BF_encrypt:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
/* Load the 2 words */
movl 20(%esp), %eax
movl (%eax), %ecx
movl 4(%eax), %edx
/* P pointer, s and enc flag */
movl 24(%esp), %edi
xorl %eax, %eax
xorl %ebx, %ebx
movl 28(%esp), %ebp
cmpl $0, %ebp
je .L000start_decrypt
xorl (%edi), %ecx
/* Round 0 */
rorl $16, %ecx
movl 4(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 1 */
rorl $16, %edx
movl 8(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 2 */
rorl $16, %ecx
movl 12(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 3 */
rorl $16, %edx
movl 16(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 4 */
rorl $16, %ecx
movl 20(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 5 */
rorl $16, %edx
movl 24(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 6 */
rorl $16, %ecx
movl 28(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 7 */
rorl $16, %edx
movl 32(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 8 */
rorl $16, %ecx
movl 36(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 9 */
rorl $16, %edx
movl 40(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 10 */
rorl $16, %ecx
movl 44(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 11 */
rorl $16, %edx
movl 48(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 12 */
rorl $16, %ecx
movl 52(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 13 */
rorl $16, %edx
movl 56(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 14 */
rorl $16, %ecx
movl 60(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 15 */
rorl $16, %edx
movl 64(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
xorl 68(%edi), %edx
movl 20(%esp), %eax
movl %edx, (%eax)
movl %ecx, 4(%eax)
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.align ALIGN
.L000start_decrypt:
xorl 68(%edi), %ecx
/* Round 16 */
rorl $16, %ecx
movl 64(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 15 */
rorl $16, %edx
movl 60(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 14 */
rorl $16, %ecx
movl 56(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 13 */
rorl $16, %edx
movl 52(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 12 */
rorl $16, %ecx
movl 48(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 11 */
rorl $16, %edx
movl 44(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 10 */
rorl $16, %ecx
movl 40(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 9 */
rorl $16, %edx
movl 36(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 8 */
rorl $16, %ecx
movl 32(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 7 */
rorl $16, %edx
movl 28(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 6 */
rorl $16, %ecx
movl 24(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 5 */
rorl $16, %edx
movl 20(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 4 */
rorl $16, %ecx
movl 16(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 3 */
rorl $16, %edx
movl 12(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
/* Round 2 */
rorl $16, %ecx
movl 8(%edi), %esi
movb %ch, %al
movb %cl, %bl
rorl $16, %ecx
xorl %esi, %edx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %ch, %al
movb %cl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %edx
/* Round 1 */
rorl $16, %edx
movl 4(%edi), %esi
movb %dh, %al
movb %dl, %bl
rorl $16, %edx
xorl %esi, %ecx
movl 72(%edi,%eax,4),%esi
movl 1096(%edi,%ebx,4),%ebp
movb %dh, %al
movb %dl, %bl
addl %ebp, %esi
movl 2120(%edi,%eax,4),%eax
xorl %eax, %esi
movl 3144(%edi,%ebx,4),%ebp
addl %ebp, %esi
xorl %eax, %eax
xorl %esi, %ecx
xorl (%edi), %edx
movl 20(%esp), %eax
movl %edx, (%eax)
movl %ecx, 4(%eax)
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.BF_encrypt_end:
SIZE(BF_encrypt,.BF_encrypt_end-BF_encrypt)
.ident "desasm.pl"

View File

@ -1,33 +0,0 @@
#define TYPE(a,b) .type a,b
#define SIZE(a,b) .size a,b
#ifdef OUT
#define OK 1
#define BF_encrypt _BF_encrypt
#define ALIGN 4
#endif
#ifdef BSDI
#define OK 1
#define BF_encrypt _BF_encrypt
#define ALIGN 4
#undef SIZE
#undef TYPE
#endif
#if defined(ELF) || defined(SOL)
#define OK 1
#define ALIGN 16
#endif
#ifndef OK
You need to define one of
ELF - elf systems - linux-elf, NetBSD and DG-UX
OUT - a.out systems - linux-a.out and FreeBSD
SOL - solaris systems, which are elf with strange comment lines
BSDI - a.out with a very primative version of as.
#endif
#include "bx86-cpp.s"

View File

@ -1,3 +0,0 @@
If you want more of an idea of how this all works,
have a read of the readme file in SSLeay/crypto/des/asm.
SSLeay can be found at ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL.

View File

@ -1,663 +0,0 @@
; Don't even think of reading this code
; It was automatically generated by bf586.pl
; Which is a perl program used to generate the x86 assember for
; any of elf, a.out, Win32, or Solaris
; It can be found in SSLeay 0.7.0+
; eric <eay@mincom.oz.au>
;
TITLE bfx86xxxx.asm
.386
.model FLAT
_TEXT SEGMENT
PUBLIC _BF_encrypt
EXTRN _des_SPtrans:DWORD
_BF_encrypt PROC NEAR
push ebp
push ebx
push esi
push edi
;
; Load the 2 words
mov eax, DWORD PTR 20[esp]
mov ecx, DWORD PTR [eax]
mov edx, DWORD PTR 4[eax]
;
; P pointer, s and enc flag
mov edi, DWORD PTR 24[esp]
xor eax, eax
xor ebx, ebx
mov ebp, DWORD PTR 28[esp]
cmp ebp, 0
je $L000start_decrypt
xor ecx, DWORD PTR [edi]
;
; Round 0
ror ecx, 16
mov esi, DWORD PTR 4[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 1
ror edx, 16
mov esi, DWORD PTR 8[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 2
ror ecx, 16
mov esi, DWORD PTR 12[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 3
ror edx, 16
mov esi, DWORD PTR 16[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 4
ror ecx, 16
mov esi, DWORD PTR 20[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 5
ror edx, 16
mov esi, DWORD PTR 24[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 6
ror ecx, 16
mov esi, DWORD PTR 28[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 7
ror edx, 16
mov esi, DWORD PTR 32[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 8
ror ecx, 16
mov esi, DWORD PTR 36[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 9
ror edx, 16
mov esi, DWORD PTR 40[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 10
ror ecx, 16
mov esi, DWORD PTR 44[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 11
ror edx, 16
mov esi, DWORD PTR 48[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 12
ror ecx, 16
mov esi, DWORD PTR 52[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 13
ror edx, 16
mov esi, DWORD PTR 56[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 14
ror ecx, 16
mov esi, DWORD PTR 60[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 15
ror edx, 16
mov esi, DWORD PTR 64[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
xor edx, DWORD PTR 68[edi]
mov eax, DWORD PTR 20[esp]
mov DWORD PTR [eax],edx
mov DWORD PTR 4[eax],ecx
pop edi
pop esi
pop ebx
pop ebp
ret
$L000start_decrypt:
xor ecx, DWORD PTR 68[edi]
;
; Round 16
ror ecx, 16
mov esi, DWORD PTR 64[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 15
ror edx, 16
mov esi, DWORD PTR 60[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 14
ror ecx, 16
mov esi, DWORD PTR 56[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 13
ror edx, 16
mov esi, DWORD PTR 52[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 12
ror ecx, 16
mov esi, DWORD PTR 48[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 11
ror edx, 16
mov esi, DWORD PTR 44[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 10
ror ecx, 16
mov esi, DWORD PTR 40[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 9
ror edx, 16
mov esi, DWORD PTR 36[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 8
ror ecx, 16
mov esi, DWORD PTR 32[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 7
ror edx, 16
mov esi, DWORD PTR 28[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 6
ror ecx, 16
mov esi, DWORD PTR 24[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 5
ror edx, 16
mov esi, DWORD PTR 20[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 4
ror ecx, 16
mov esi, DWORD PTR 16[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 3
ror edx, 16
mov esi, DWORD PTR 12[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
;
; Round 2
ror ecx, 16
mov esi, DWORD PTR 8[edi]
mov al, ch
mov bl, cl
ror ecx, 16
xor edx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, ch
mov bl, cl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor edx, esi
;
; Round 1
ror edx, 16
mov esi, DWORD PTR 4[edi]
mov al, dh
mov bl, dl
ror edx, 16
xor ecx, esi
mov esi, DWORD PTR 72[eax*4+edi]
mov ebp, DWORD PTR 1096[ebx*4+edi]
mov al, dh
mov bl, dl
add esi, ebp
mov eax, DWORD PTR 2120[eax*4+edi]
xor esi, eax
mov ebp, DWORD PTR 3144[ebx*4+edi]
add esi, ebp
xor eax, eax
xor ecx, esi
xor edx, DWORD PTR [edi]
mov eax, DWORD PTR 20[esp]
mov DWORD PTR [eax],edx
mov DWORD PTR 4[eax],ecx
pop edi
pop esi
pop ebx
pop ebp
ret
_BF_encrypt ENDP
_TEXT ENDS
END

View File

@ -1,249 +0,0 @@
#!/usr/local/bin/perl
package x86ms;
$label="L000";
%lb=( 'eax', 'al',
'ebx', 'bl',
'ecx', 'cl',
'edx', 'dl',
'ax', 'al',
'bx', 'bl',
'cx', 'cl',
'dx', 'dl',
);
%hb=( 'eax', 'ah',
'ebx', 'bh',
'ecx', 'ch',
'edx', 'dh',
'ax', 'ah',
'bx', 'bh',
'cx', 'ch',
'dx', 'dh',
);
sub main'LB
{
(defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
return($lb{$_[0]});
}
sub main'HB
{
(defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
return($hb{$_[0]});
}
sub main'DWP
{
local($addr,$reg1,$reg2,$idx)=@_;
local($t);
local($ret)="DWORD PTR ";
$addr =~ s/^\s+//;
if ($addr =~ /^(.+)\+(.+)$/)
{
$reg2=&conv($1);
$addr="_$2";
}
elsif ($addr =~ /^[_a-zA-Z]/)
{
$addr="_$addr";
}
$reg1="$regs{$reg1}" if defined($regs{$reg1});
$reg2="$regs{$reg2}" if defined($regs{$reg2});
$ret.=$addr if ($addr ne "") && ($addr ne 0);
if ($reg2 ne "")
{
$t="";
$t="*$idx" if ($idx != 0);
$ret.="[$reg2$t+$reg1]";
}
else
{
$ret.="[$reg1]"
}
return($ret);
}
sub main'mov { &out2("mov",@_); }
sub main'movb { &out2("mov",@_); }
sub main'and { &out2("and",@_); }
sub main'or { &out2("or",@_); }
sub main'shl { &out2("shl",@_); }
sub main'shr { &out2("shr",@_); }
sub main'xor { &out2("xor",@_); }
sub main'add { &out2("add",@_); }
sub main'sub { &out2("sub",@_); }
sub main'rotl { &out2("rol",@_); }
sub main'rotr { &out2("ror",@_); }
sub main'exch { &out2("xchg",@_); }
sub main'cmp { &out2("cmp",@_); }
sub main'dec { &out1("dec",@_); }
sub main'jmp { &out1("jmp",@_); }
sub main'je { &out1("je",@_); }
sub main'jz { &out1("jz",@_); }
sub main'jnz { &out1("jnz",@_); }
sub main'push { &out1("push",@_); }
sub main'call { &out1("call",'_'.$_[0]); }
sub out2
{
local($name,$p1,$p2)=@_;
local($l,$t);
print "\t$name\t";
$t=&conv($p1).",";
$l=length($t);
print $t;
$l=4-($l+9)/8;
print "\t" x $l;
print &conv($p2);
print "\n";
}
sub out1
{
local($name,$p1)=@_;
local($l,$t);
print "\t$name\t";
print &conv($p1);
print "\n";
}
sub conv
{
local($p)=@_;
$p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
return $p;
}
sub main'file
{
local($file)=@_;
print <<"EOF";
TITLE $file.asm
.386
.model FLAT
EOF
}
sub main'function_begin
{
local($func,$num)=@_;
$params=$num*4;
print <<"EOF";
_TEXT SEGMENT
PUBLIC _$func
EXTRN _des_SPtrans:DWORD
_$func PROC NEAR
push ebp
push ebx
push esi
push edi
EOF
$stack=20;
}
sub main'function_end
{
local($func)=@_;
print <<"EOF";
pop edi
pop esi
pop ebx
pop ebp
ret
_$func ENDP
_TEXT ENDS
EOF
$stack=0;
%label=();
}
sub main'function_end_A
{
local($func)=@_;
print <<"EOF";
pop edi
pop esi
pop ebx
pop ebp
ret
EOF
}
sub main'function_end_B
{
local($func)=@_;
print <<"EOF";
_$func ENDP
_TEXT ENDS
EOF
$stack=0;
%label=();
}
sub main'file_end
{
print "END\n"
}
sub main'wparam
{
local($num)=@_;
return(&main'DWP($stack+$num*4,"esp","",0));
}
sub main'wtmp
{
local($num)=@_;
return(&main'DWP($stack+$params+$num*4,"esp","",0));
}
sub main'comment
{
foreach (@_)
{
print "\t; $_\n";
}
}
sub main'label
{
if (!defined($label{$_[0]}))
{
$label{$_[0]}="\$${label}${_[0]}";
$label++;
}
return($label{$_[0]});
}
sub main'set_label
{
if (!defined($label{$_[0]}))
{
$label{$_[0]}="${label}${_[0]}";
$label++;
}
print "$label{$_[0]}:\n";
}
sub main'file_end
{
print "END\n";
}

View File

@ -1,313 +0,0 @@
#!/usr/local/bin/perl
package x86ms;
$label="L000";
$align=($main'aout)?"4":"16";
$under=($main'aout)?"_":"";
$com_start=($main'sol)?"/":"#";
if ($main'cpp)
{
$align="ALIGN";
$under="";
$com_start='/*';
$com_end='*/';
}
%lb=( 'eax', '%al',
'ebx', '%bl',
'ecx', '%cl',
'edx', '%dl',
'ax', '%al',
'bx', '%bl',
'cx', '%cl',
'dx', '%dl',
);
%hb=( 'eax', '%ah',
'ebx', '%bh',
'ecx', '%ch',
'edx', '%dh',
'ax', '%ah',
'bx', '%bh',
'cx', '%ch',
'dx', '%dh',
);
%regs=( 'eax', '%eax',
'ebx', '%ebx',
'ecx', '%ecx',
'edx', '%edx',
'esi', '%esi',
'edi', '%edi',
'ebp', '%ebp',
'esp', '%esp',
);
sub main'LB
{
(defined($lb{$_[0]})) || die "$_[0] does not have a 'low byte'\n";
return($lb{$_[0]});
}
sub main'HB
{
(defined($hb{$_[0]})) || die "$_[0] does not have a 'high byte'\n";
return($hb{$_[0]});
}
sub main'DWP
{
local($addr,$reg1,$reg2,$idx)=@_;
$ret="";
$addr =~ s/(^|[+ \t])([A-Za-z_]+)($|[+ \t])/$1$under$2$3/;
$reg1="$regs{$reg1}" if defined($regs{$reg1});
$reg2="$regs{$reg2}" if defined($regs{$reg2});
$ret.=$addr if ($addr ne "") && ($addr ne 0);
if ($reg2 ne "")
{
$ret.="($reg1,$reg2,$idx)";
}
else
{
$ret.="($reg1)"
}
return($ret);
}
sub main'BP
{
local($addr,$reg1,$reg2,$idx)=@_;
$ret="";
$addr =~ s/(^|[+ \t])([A-Za-z_]+)($|[+ \t])/$1$under$2$3/;
$reg1="$regs{$reg1}" if defined($regs{$reg1});
$reg2="$regs{$reg2}" if defined($regs{$reg2});
$ret.=$addr if ($addr ne "") && ($addr ne 0);
if ($reg2 ne "")
{
$ret.="($reg1,$reg2,$idx)";
}
else
{
$ret.="($reg1)"
}
return($ret);
}
sub main'mov { &out2("movl",@_); }
sub main'movb { &out2("movb",@_); }
sub main'and { &out2("andl",@_); }
sub main'or { &out2("orl",@_); }
sub main'shl { &out2("sall",@_); }
sub main'shr { &out2("shrl",@_); }
sub main'xor { &out2("xorl",@_); }
sub main'add { &out2("addl",@_); }
sub main'sub { &out2("subl",@_); }
sub main'rotl { &out2("roll",@_); }
sub main'rotr { &out2("rorl",@_); }
sub main'exch { &out2("xchg",@_); }
sub main'cmp { &out2("cmpl",@_); }
sub main'jmp { &out1("jmp",@_); }
sub main'je { &out1("je",@_); }
sub main'jne { &out1("jne",@_); }
sub main'jnz { &out1("jnz",@_); }
sub main'jz { &out1("jz",@_); }
sub main'dec { &out1("decl",@_); }
sub main'push { &out1("pushl",@_); }
sub main'call { &out1("call",$under.$_[0]); }
sub out2
{
local($name,$p1,$p2)=@_;
local($l,$ll,$t);
print "\t$name\t";
$t=&conv($p2).",";
$l=length($t);
print $t;
$ll=4-($l+9)/8;
print "\t" x $ll;
print &conv($p1);
print "\n";
}
sub out1
{
local($name,$p1)=@_;
local($l,$t);
print "\t$name\t";
print &conv($p1);
print "\n";
}
sub conv
{
local($p)=@_;
# $p =~ s/0x([0-9A-Fa-f]+)/0$1h/;
$p=$regs{$p} if (defined($regs{$p}));
$p =~ s/^([0-9A-Fa-f]+)$/\$$1/;
$p =~ s/^(0x[0-9A-Fa-f]+)$/\$$1/;
return $p;
}
sub main'file
{
local($file)=@_;
print <<"EOF";
.file "$file.s"
.version "01.01"
gcc2_compiled.:
EOF
}
sub main'function_begin
{
local($func,$num)=@_;
$params=$num*4;
$func=$under.$func;
print <<"EOF";
.text
.align $align
.globl $func
EOF
if ($main'cpp)
{ printf("\tTYPE($func,\@function)\n"); }
else { printf("\t.type $func,\@function\n"); }
print <<"EOF";
$func:
pushl %ebp
pushl %ebx
pushl %esi
pushl %edi
EOF
$stack=20;
}
sub main'function_end
{
local($func)=@_;
$func=$under.$func;
print <<"EOF";
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
.${func}_end:
EOF
if ($main'cpp)
{ printf("\tSIZE($func,.${func}_end-$func)\n"); }
else { printf("\t.size\t$func,.${func}_end-$func\n"); }
print ".ident \"desasm.pl\"\n";
$stack=0;
%label=();
}
sub main'function_end_A
{
local($func)=@_;
print <<"EOF";
popl %edi
popl %esi
popl %ebx
popl %ebp
ret
EOF
}
sub main'function_end_B
{
local($func)=@_;
$func=$under.$func;
print <<"EOF";
.${func}_end:
EOF
if ($main'cpp)
{ printf("\tSIZE($func,.${func}_end-$func)\n"); }
else { printf("\t.size\t$func,.${func}_end-$func\n"); }
print ".ident \"desasm.pl\"\n";
$stack=0;
%label=();
}
sub main'wparam
{
local($num)=@_;
return(&main'DWP($stack+$num*4,"esp","",0));
}
sub main'wtmp_b
{
local($num,$b)=@_;
return(&main'BP(-(($num+1)*4)+$b,"esp","",0));
}
sub main'wtmp
{
local($num)=@_;
return(&main'DWP(-($num+1)*4,"esp","",0));
}
sub main'comment
{
foreach (@_)
{
if (/^\s*$/)
{ print "\n"; }
else
{ print "\t$com_start $_ $com_end\n"; }
}
}
sub main'label
{
if (!defined($label{$_[0]}))
{
$label{$_[0]}=".${label}${_[0]}";
$label++;
}
return($label{$_[0]});
}
sub main'set_label
{
if (!defined($label{$_[0]}))
{
$label{$_[0]}=".${label}${_[0]}";
$label++;
}
print ".align $align\n";
print "$label{$_[0]}:\n";
}
sub main'file_end
{
}

View File

@ -1,143 +0,0 @@
/* crypto/bf/bf_cbc.c */
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@mincom.oz.au).
* 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 (tjh@mincom.oz.au).
*
* 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 (eay@mincom.oz.au)"
* 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 (tjh@mincom.oz.au)"
*
* 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.]
*/
#include "blowfish.h"
#include "bf_locl.h"
void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length, BF_KEY *ks,
unsigned char *iv, int encrypt)
{
register BF_LONG tin0,tin1;
register BF_LONG tout0,tout1,xor0,xor1;
register long l=length;
BF_LONG tin[2];
if (encrypt != 0)
{
n2l(iv,tout0);
n2l(iv,tout1);
iv-=8;
for (l-=8; l>=0; l-=8)
{
n2l(in,tin0);
n2l(in,tin1);
tin0^=tout0;
tin1^=tout1;
tin[0]=tin0;
tin[1]=tin1;
BF_encrypt(tin,ks,BF_ENCRYPT);
tout0=tin[0];
tout1=tin[1];
l2n(tout0,out);
l2n(tout1,out);
}
if (l != -8)
{
n2ln(in,tin0,tin1,l+8);
tin0^=tout0;
tin1^=tout1;
tin[0]=tin0;
tin[1]=tin1;
BF_encrypt(tin,ks,BF_ENCRYPT);
tout0=tin[0];
tout1=tin[1];
l2n(tout0,out);
l2n(tout1,out);
}
l2n(tout0,iv);
l2n(tout1,iv);
}
else
{
n2l(iv,xor0);
n2l(iv,xor1);
iv-=8;
for (l-=8; l>=0; l-=8)
{
n2l(in,tin0);
n2l(in,tin1);
tin[0]=tin0;
tin[1]=tin1;
BF_encrypt(tin,ks,BF_DECRYPT);
tout0=tin[0]^xor0;
tout1=tin[1]^xor1;
l2n(tout0,out);
l2n(tout1,out);
xor0=tin0;
xor1=tin1;
}
if (l != -8)
{
n2l(in,tin0);
n2l(in,tin1);
tin[0]=tin0;
tin[1]=tin1;
BF_encrypt(tin,ks,BF_DECRYPT);
tout0=tin[0]^xor0;
tout1=tin[1]^xor1;
l2nn(tout0,tout1,out,l+8);
xor0=tin0;
xor1=tin1;
}
l2n(xor0,iv);
l2n(xor1,iv);
}
tin0=tin1=tout0=tout1=xor0=xor1=0;
tin[0]=tin[1]=0;
}

View File

@ -1,122 +0,0 @@
/* crypto/bf/bf_cfb64.c */
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@mincom.oz.au).
* 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 (tjh@mincom.oz.au).
*
* 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 (eay@mincom.oz.au)"
* 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 (tjh@mincom.oz.au)"
*
* 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.]
*/
#include "blowfish.h"
#include "bf_locl.h"
/* The input and output encrypted as though 64bit cfb mode is being
* used. The extra state information to record how much of the
* 64bit block we have used is contained in *num;
*/
void BF_cfb64_encrypt(unsigned char *in, unsigned char *out, long length, BF_KEY *schedule,
unsigned char *ivec, int *num, int encrypt)
{
register BF_LONG v0,v1,t;
register int n= *num;
register long l=length;
BF_LONG ti[2];
unsigned char *iv,c,cc;
iv=(unsigned char *)ivec;
if (encrypt != 0)
{
while (l-- != 0)
{
if (n == 0)
{
n2l(iv,v0); ti[0]=v0;
n2l(iv,v1); ti[1]=v1;
BF_encrypt((unsigned long *)ti,schedule,BF_ENCRYPT);
iv=(unsigned char *)ivec;
t=ti[0]; l2n(t,iv);
t=ti[1]; l2n(t,iv);
iv=(unsigned char *)ivec;
}
c= (unsigned char)(*(in++)^iv[n]);
*(out++)=c;
iv[n]=c;
n=(n+1)&0x07;
}
}
else
{
while (l-- != 0)
{
if (n == 0)
{
n2l(iv,v0); ti[0]=v0;
n2l(iv,v1); ti[1]=v1;
BF_encrypt((unsigned long *)ti,schedule,BF_ENCRYPT);
iv=(unsigned char *)ivec;
t=ti[0]; l2n(t,iv);
t=ti[1]; l2n(t,iv);
iv=(unsigned char *)ivec;
}
cc= *(in++);
c=iv[n];
iv[n]=cc;
*(out++)=(unsigned char)(c^cc);
n=(n+1)&0x07;
}
}
v0=v1=ti[0]=ti[1]=t=0;
c=cc=(unsigned char)0;
*num=n;
}

View File

@ -1,91 +0,0 @@
/* crypto/bf/bf_ecb.c */
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@mincom.oz.au).
* 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 (tjh@mincom.oz.au).
*
* 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 (eay@mincom.oz.au)"
* 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 (tjh@mincom.oz.au)"
*
* 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.]
*/
#include "blowfish.h"
#include "bf_locl.h"
/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper'
* (From LECTURE NOTES IN COIMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION,
* CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
*/
char *BF_version="BlowFish part of SSLeay 0.7.0 30-Jan-1997";
char *BF_options()
{
#ifdef BF_PTR
return("blowfish(ptr)");
#elif defined(BF_PTR2)
return("blowfish(ptr2)");
#else
return("blowfish(idx)");
#endif
}
void BF_ecb_encrypt(unsigned char *in, unsigned char *out, BF_KEY *ks, int encrypt)
{
BF_LONG l,d[2];
n2l(in,l); d[0]=l;
n2l(in,l); d[1]=l;
BF_encrypt(d,ks,encrypt);
l=d[0]; l2n(l,out);
l=d[1]; l2n(l,out);
l=d[0]=d[1]=0;
}

View File

@ -1,137 +0,0 @@
/* crypto/bf/bf_enc.c */
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@mincom.oz.au).
* 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 (tjh@mincom.oz.au).
*
* 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 (eay@mincom.oz.au)"
* 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 (tjh@mincom.oz.au)"
*
* 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.]
*/
#include "blowfish.h"
#include "bf_locl.h"
/* Blowfish as implemented from 'Blowfish: Springer-Verlag paper'
* (From LECTURE NOTES IN COIMPUTER SCIENCE 809, FAST SOFTWARE ENCRYPTION,
* CAMBRIDGE SECURITY WORKSHOP, CAMBRIDGE, U.K., DECEMBER 9-11, 1993)
*/
#if (BF_ROUNDS != 16) && (BF_ROUNDS != 20)
If you set BF_ROUNDS to some value other than 16 or 20, you will have
to modify the code.
#endif
void BF_encrypt(BF_LONG *data, BF_KEY *key, int encrypt)
{
register BF_LONG l,r,*p,*s;
p=key->P;
s= &(key->S[0]);
l=data[0];
r=data[1];
if (encrypt != 0)
{
l^=p[0];
BF_ENC(r,l,s,p[ 1]);
BF_ENC(l,r,s,p[ 2]);
BF_ENC(r,l,s,p[ 3]);
BF_ENC(l,r,s,p[ 4]);
BF_ENC(r,l,s,p[ 5]);
BF_ENC(l,r,s,p[ 6]);
BF_ENC(r,l,s,p[ 7]);
BF_ENC(l,r,s,p[ 8]);
BF_ENC(r,l,s,p[ 9]);
BF_ENC(l,r,s,p[10]);
BF_ENC(r,l,s,p[11]);
BF_ENC(l,r,s,p[12]);
BF_ENC(r,l,s,p[13]);
BF_ENC(l,r,s,p[14]);
BF_ENC(r,l,s,p[15]);
BF_ENC(l,r,s,p[16]);
#if BF_ROUNDS == 20
BF_ENC(r,l,s,p[17]);
BF_ENC(l,r,s,p[18]);
BF_ENC(r,l,s,p[19]);
BF_ENC(l,r,s,p[20]);
#endif
r^=p[BF_ROUNDS+1];
}
else
{
l^=p[BF_ROUNDS+1];
#if BF_ROUNDS == 20
BF_ENC(r,l,s,p[20]);
BF_ENC(l,r,s,p[19]);
BF_ENC(r,l,s,p[18]);
BF_ENC(l,r,s,p[17]);
#endif
BF_ENC(r,l,s,p[16]);
BF_ENC(l,r,s,p[15]);
BF_ENC(r,l,s,p[14]);
BF_ENC(l,r,s,p[13]);
BF_ENC(r,l,s,p[12]);
BF_ENC(l,r,s,p[11]);
BF_ENC(r,l,s,p[10]);
BF_ENC(l,r,s,p[ 9]);
BF_ENC(r,l,s,p[ 8]);
BF_ENC(l,r,s,p[ 7]);
BF_ENC(r,l,s,p[ 6]);
BF_ENC(l,r,s,p[ 5]);
BF_ENC(r,l,s,p[ 4]);
BF_ENC(l,r,s,p[ 3]);
BF_ENC(r,l,s,p[ 2]);
BF_ENC(l,r,s,p[ 1]);
r^=p[0];
}
data[1]=l&0xffffffff;
data[0]=r&0xffffffff;
}

View File

@ -1,236 +0,0 @@
/* crypto/bf/bf_local.h */
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@mincom.oz.au).
* 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 (tjh@mincom.oz.au).
*
* 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 (eay@mincom.oz.au)"
* 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 (tjh@mincom.oz.au)"
*
* 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 bf_locl.org since bf_locl.h is automatically generated from
* it during SSLeay configuration.
*
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
*/
/*
Notwithstanding the above warning, bf_locl.h is *not* regenerated
in this stand-alone implementation. The following auto-configuration
based on compiler CPU identification was added by John Walker to
avoid having to modify the Makefile to choose the best optimisation
for an individual platform.
*/
#ifdef sparc
#define BF_PTR
#endif
#ifdef mips
#define BF_PTR
#endif
/* In addition, for best performance we should define BF_PTR2 for
Pentium and below x86 machines, but not define it for Pentium
Pro and above. I don't know of any compiler-independent way
to distinguish these platforms, so I'm leaving the optimisation
as best for the newer platforms. The actual performance difference
for this application is trivial in any case. */
#undef c2l
#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
l|=((unsigned long)(*((c)++)))<< 8L, \
l|=((unsigned long)(*((c)++)))<<16L, \
l|=((unsigned long)(*((c)++)))<<24L)
/* NOTE - c is not incremented as per c2l */
#undef c2ln
#define c2ln(c,l1,l2,n) { \
c+=n; \
l1=l2=0; \
switch (n) { \
case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
case 5: l2|=((unsigned long)(*(--(c)))); \
case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
case 1: l1|=((unsigned long)(*(--(c)))); \
} \
}
#undef l2c
#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
*((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
*((c)++)=(unsigned char)(((l)>>24L)&0xff))
/* NOTE - c is not incremented as per l2c */
#undef l2cn
#define l2cn(l1,l2,c,n) { \
c+=n; \
switch (n) { \
case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
} \
}
/* NOTE - c is not incremented as per n2l */
#define n2ln(c,l1,l2,n) { \
c+=n; \
l1=l2=0; \
switch (n) { \
case 8: l2 =((unsigned long)(*(--(c)))) ; \
case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
case 6: l2|=((unsigned long)(*(--(c))))<<16; \
case 5: l2|=((unsigned long)(*(--(c))))<<24; \
case 4: l1 =((unsigned long)(*(--(c)))) ; \
case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
case 2: l1|=((unsigned long)(*(--(c))))<<16; \
case 1: l1|=((unsigned long)(*(--(c))))<<24; \
} \
}
/* NOTE - c is not incremented as per l2n */
#define l2nn(l1,l2,c,n) { \
c+=n; \
switch (n) { \
case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
} \
}
#undef n2l
#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
l|=((unsigned long)(*((c)++)))<<16L, \
l|=((unsigned long)(*((c)++)))<< 8L, \
l|=((unsigned long)(*((c)++))))
#undef l2n
#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
*((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
*((c)++)=(unsigned char)(((l) )&0xff))
/* This is actually a big endian algorithm, the most significate byte
* is used to lookup array 0 */
/* use BF_PTR2 for intel boxes,
* BF_PTR for sparc and MIPS/SGI
* use nothing for Alpha and HP.
*/
#if !defined(BF_PTR) && !defined(BF_PTR2)
#undef BF_PTR
#endif
#define BF_M 0x3fc
#define BF_0 22L
#define BF_1 14L
#define BF_2 6L
#define BF_3 2L /* left shift */
#if defined(BF_PTR2)
/* This is basically a special pentium verson */
#define BF_ENC(LL,R,S,P) \
{ \
BF_LONG t,u,v; \
u=R>>BF_0; \
v=R>>BF_1; \
u&=BF_M; \
v&=BF_M; \
t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \
u=R>>BF_2; \
t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \
v=R<<BF_3; \
u&=BF_M; \
v&=BF_M; \
t^= *(BF_LONG *)((unsigned char *)&(S[512])+u); \
LL^=P; \
t+= *(BF_LONG *)((unsigned char *)&(S[768])+v); \
LL^=t; \
}
#elif defined(BF_PTR)
/* This is normally very good */
#define BF_ENC(LL,R,S,P) \
LL^=P; \
LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \
*(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
*(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
*(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M)));
#else
/* This will always work, even on 64 bit machines and strangly enough,
* on the Alpha it is faster than the pointer versions (both 32 and 64
* versions of BF_LONG) */
#define BF_ENC(LL,R,S,P) \
LL^=P; \
LL^=((( S[ (R>>24L) ] + \
S[0x0100+((R>>16L)&0xff)])^ \
S[0x0200+((R>> 8L)&0xff)])+ \
S[0x0300+((R )&0xff)])&0xffffffff;
#endif

View File

@ -1,215 +0,0 @@
/* crypto/bf/bf_local.h */
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@mincom.oz.au).
* 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 (tjh@mincom.oz.au).
*
* 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 (eay@mincom.oz.au)"
* 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 (tjh@mincom.oz.au)"
*
* 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 bf_locl.org since bf_locl.h is automatically generated from
* it during SSLeay configuration.
*
* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
*/
#undef c2l
#define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
l|=((unsigned long)(*((c)++)))<< 8L, \
l|=((unsigned long)(*((c)++)))<<16L, \
l|=((unsigned long)(*((c)++)))<<24L)
/* NOTE - c is not incremented as per c2l */
#undef c2ln
#define c2ln(c,l1,l2,n) { \
c+=n; \
l1=l2=0; \
switch (n) { \
case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
case 5: l2|=((unsigned long)(*(--(c)))); \
case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
case 1: l1|=((unsigned long)(*(--(c)))); \
} \
}
#undef l2c
#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
*((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
*((c)++)=(unsigned char)(((l)>>24L)&0xff))
/* NOTE - c is not incremented as per l2c */
#undef l2cn
#define l2cn(l1,l2,c,n) { \
c+=n; \
switch (n) { \
case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
} \
}
/* NOTE - c is not incremented as per n2l */
#define n2ln(c,l1,l2,n) { \
c+=n; \
l1=l2=0; \
switch (n) { \
case 8: l2 =((unsigned long)(*(--(c)))) ; \
case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
case 6: l2|=((unsigned long)(*(--(c))))<<16; \
case 5: l2|=((unsigned long)(*(--(c))))<<24; \
case 4: l1 =((unsigned long)(*(--(c)))) ; \
case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
case 2: l1|=((unsigned long)(*(--(c))))<<16; \
case 1: l1|=((unsigned long)(*(--(c))))<<24; \
} \
}
/* NOTE - c is not incremented as per l2n */
#define l2nn(l1,l2,c,n) { \
c+=n; \
switch (n) { \
case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
} \
}
#undef n2l
#define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
l|=((unsigned long)(*((c)++)))<<16L, \
l|=((unsigned long)(*((c)++)))<< 8L, \
l|=((unsigned long)(*((c)++))))
#undef l2n
#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
*((c)++)=(unsigned char)(((l)>>16L)&0xff), \
*((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
*((c)++)=(unsigned char)(((l) )&0xff))
/* This is actually a big endian algorithm, the most significate byte
* is used to lookup array 0 */
/* use BF_PTR2 for intel boxes,
* BF_PTR for sparc and MIPS/SGI
* use nothing for Alpha and HP.
*/
#if !defined(BF_PTR) && !defined(BF_PTR2)
#undef BF_PTR
#endif
#define BF_M 0x3fc
#define BF_0 22L
#define BF_1 14L
#define BF_2 6L
#define BF_3 2L /* left shift */
#if defined(BF_PTR2)
/* This is basically a special pentium verson */
#define BF_ENC(LL,R,S,P) \
{ \
BF_LONG t,u,v; \
u=R>>BF_0; \
v=R>>BF_1; \
u&=BF_M; \
v&=BF_M; \
t= *(BF_LONG *)((unsigned char *)&(S[ 0])+u); \
u=R>>BF_2; \
t+= *(BF_LONG *)((unsigned char *)&(S[256])+v); \
v=R<<BF_3; \
u&=BF_M; \
v&=BF_M; \
t^= *(BF_LONG *)((unsigned char *)&(S[512])+u); \
LL^=P; \
t+= *(BF_LONG *)((unsigned char *)&(S[768])+v); \
LL^=t; \
}
#elif defined(BF_PTR)
/* This is normally very good */
#define BF_ENC(LL,R,S,P) \
LL^=P; \
LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \
*(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
*(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
*(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M)));
#else
/* This will always work, even on 64 bit machines and strangly enough,
* on the Alpha it is faster than the pointer versions (both 32 and 64
* versions of BF_LONG) */
#define BF_ENC(LL,R,S,P) \
LL^=P; \
LL^=((( S[ (R>>24L) ] + \
S[0x0100+((R>>16L)&0xff)])^ \
S[0x0200+((R>> 8L)&0xff)])+ \
S[0x0300+((R )&0xff)])&0xffffffff;
#endif

View File

@ -1,110 +0,0 @@
/* crypto/bf/bf_ofb64.c */
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@mincom.oz.au).
* 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 (tjh@mincom.oz.au).
*
* 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 (eay@mincom.oz.au)"
* 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 (tjh@mincom.oz.au)"
*
* 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.]
*/
#include "blowfish.h"
#include "bf_locl.h"
/* The input and output encrypted as though 64bit ofb mode is being
* used. The extra state information to record how much of the
* 64bit block we have used is contained in *num;
*/
void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length, BF_KEY *schedule,
unsigned char *ivec, int *num)
{
register unsigned long v0,v1,t;
register int n= *num;
register long l=length;
unsigned char d[8];
register unsigned char *dp;
unsigned long ti[2];
unsigned char *iv;
int save=0;
iv=(unsigned char *)ivec;
n2l(iv,v0);
n2l(iv,v1);
ti[0]=v0;
ti[1]=v1;
dp=(unsigned char *)d;
l2n(v0,dp);
l2n(v1,dp);
while (l-- != 0)
{
if (n == 0)
{
BF_encrypt((unsigned long *)ti,schedule,BF_ENCRYPT);
dp=(unsigned char *)d;
t=ti[0]; l2n(t,dp);
t=ti[1]; l2n(t,dp);
save++;
}
*(out++)= (unsigned char)(*(in++)^d[n]);
n=(n+1)&0x07;
}
if (save != 0)
{
v0=ti[0];
v1=ti[1];
iv=(unsigned char *)ivec;
l2n(v0,iv);
l2n(v1,iv);
}
t=v0=v1=ti[0]=ti[1]=0;
*num=n;
}

View File

@ -1,325 +0,0 @@
/* crypto/bf/bf_pi.h */
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@mincom.oz.au).
* 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 (tjh@mincom.oz.au).
*
* 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 (eay@mincom.oz.au)"
* 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 (tjh@mincom.oz.au)"
*
* 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.]
*/
static BF_KEY bf_init= {
{
0x243f6a88UL, 0x85a308d3UL, 0x13198a2eUL, 0x03707344UL,
0xa4093822UL, 0x299f31d0UL, 0x082efa98UL, 0xec4e6c89UL,
0x452821e6UL, 0x38d01377UL, 0xbe5466cfUL, 0x34e90c6cUL,
0xc0ac29b7UL, 0xc97c50ddUL, 0x3f84d5b5UL, 0xb5470917UL,
0x9216d5d9UL, 0x8979fb1bUL
},{
0xd1310ba6UL, 0x98dfb5acUL, 0x2ffd72dbUL, 0xd01adfb7UL,
0xb8e1afedUL, 0x6a267e96UL, 0xba7c9045UL, 0xf12c7f99UL,
0x24a19947UL, 0xb3916cf7UL, 0x0801f2e2UL, 0x858efc16UL,
0x636920d8UL, 0x71574e69UL, 0xa458fea3UL, 0xf4933d7eUL,
0x0d95748fUL, 0x728eb658UL, 0x718bcd58UL, 0x82154aeeUL,
0x7b54a41dUL, 0xc25a59b5UL, 0x9c30d539UL, 0x2af26013UL,
0xc5d1b023UL, 0x286085f0UL, 0xca417918UL, 0xb8db38efUL,
0x8e79dcb0UL, 0x603a180eUL, 0x6c9e0e8bUL, 0xb01e8a3eUL,
0xd71577c1UL, 0xbd314b27UL, 0x78af2fdaUL, 0x55605c60UL,
0xe65525f3UL, 0xaa55ab94UL, 0x57489862UL, 0x63e81440UL,
0x55ca396aUL, 0x2aab10b6UL, 0xb4cc5c34UL, 0x1141e8ceUL,
0xa15486afUL, 0x7c72e993UL, 0xb3ee1411UL, 0x636fbc2aUL,
0x2ba9c55dUL, 0x741831f6UL, 0xce5c3e16UL, 0x9b87931eUL,
0xafd6ba33UL, 0x6c24cf5cUL, 0x7a325381UL, 0x28958677UL,
0x3b8f4898UL, 0x6b4bb9afUL, 0xc4bfe81bUL, 0x66282193UL,
0x61d809ccUL, 0xfb21a991UL, 0x487cac60UL, 0x5dec8032UL,
0xef845d5dUL, 0xe98575b1UL, 0xdc262302UL, 0xeb651b88UL,
0x23893e81UL, 0xd396acc5UL, 0x0f6d6ff3UL, 0x83f44239UL,
0x2e0b4482UL, 0xa4842004UL, 0x69c8f04aUL, 0x9e1f9b5eUL,
0x21c66842UL, 0xf6e96c9aUL, 0x670c9c61UL, 0xabd388f0UL,
0x6a51a0d2UL, 0xd8542f68UL, 0x960fa728UL, 0xab5133a3UL,
0x6eef0b6cUL, 0x137a3be4UL, 0xba3bf050UL, 0x7efb2a98UL,
0xa1f1651dUL, 0x39af0176UL, 0x66ca593eUL, 0x82430e88UL,
0x8cee8619UL, 0x456f9fb4UL, 0x7d84a5c3UL, 0x3b8b5ebeUL,
0xe06f75d8UL, 0x85c12073UL, 0x401a449fUL, 0x56c16aa6UL,
0x4ed3aa62UL, 0x363f7706UL, 0x1bfedf72UL, 0x429b023dUL,
0x37d0d724UL, 0xd00a1248UL, 0xdb0fead3UL, 0x49f1c09bUL,
0x075372c9UL, 0x80991b7bUL, 0x25d479d8UL, 0xf6e8def7UL,
0xe3fe501aUL, 0xb6794c3bUL, 0x976ce0bdUL, 0x04c006baUL,
0xc1a94fb6UL, 0x409f60c4UL, 0x5e5c9ec2UL, 0x196a2463UL,
0x68fb6fafUL, 0x3e6c53b5UL, 0x1339b2ebUL, 0x3b52ec6fUL,
0x6dfc511fUL, 0x9b30952cUL, 0xcc814544UL, 0xaf5ebd09UL,
0xbee3d004UL, 0xde334afdUL, 0x660f2807UL, 0x192e4bb3UL,
0xc0cba857UL, 0x45c8740fUL, 0xd20b5f39UL, 0xb9d3fbdbUL,
0x5579c0bdUL, 0x1a60320aUL, 0xd6a100c6UL, 0x402c7279UL,
0x679f25feUL, 0xfb1fa3ccUL, 0x8ea5e9f8UL, 0xdb3222f8UL,
0x3c7516dfUL, 0xfd616b15UL, 0x2f501ec8UL, 0xad0552abUL,
0x323db5faUL, 0xfd238760UL, 0x53317b48UL, 0x3e00df82UL,
0x9e5c57bbUL, 0xca6f8ca0UL, 0x1a87562eUL, 0xdf1769dbUL,
0xd542a8f6UL, 0x287effc3UL, 0xac6732c6UL, 0x8c4f5573UL,
0x695b27b0UL, 0xbbca58c8UL, 0xe1ffa35dUL, 0xb8f011a0UL,
0x10fa3d98UL, 0xfd2183b8UL, 0x4afcb56cUL, 0x2dd1d35bUL,
0x9a53e479UL, 0xb6f84565UL, 0xd28e49bcUL, 0x4bfb9790UL,
0xe1ddf2daUL, 0xa4cb7e33UL, 0x62fb1341UL, 0xcee4c6e8UL,
0xef20cadaUL, 0x36774c01UL, 0xd07e9efeUL, 0x2bf11fb4UL,
0x95dbda4dUL, 0xae909198UL, 0xeaad8e71UL, 0x6b93d5a0UL,
0xd08ed1d0UL, 0xafc725e0UL, 0x8e3c5b2fUL, 0x8e7594b7UL,
0x8ff6e2fbUL, 0xf2122b64UL, 0x8888b812UL, 0x900df01cUL,
0x4fad5ea0UL, 0x688fc31cUL, 0xd1cff191UL, 0xb3a8c1adUL,
0x2f2f2218UL, 0xbe0e1777UL, 0xea752dfeUL, 0x8b021fa1UL,
0xe5a0cc0fUL, 0xb56f74e8UL, 0x18acf3d6UL, 0xce89e299UL,
0xb4a84fe0UL, 0xfd13e0b7UL, 0x7cc43b81UL, 0xd2ada8d9UL,
0x165fa266UL, 0x80957705UL, 0x93cc7314UL, 0x211a1477UL,
0xe6ad2065UL, 0x77b5fa86UL, 0xc75442f5UL, 0xfb9d35cfUL,
0xebcdaf0cUL, 0x7b3e89a0UL, 0xd6411bd3UL, 0xae1e7e49UL,
0x00250e2dUL, 0x2071b35eUL, 0x226800bbUL, 0x57b8e0afUL,
0x2464369bUL, 0xf009b91eUL, 0x5563911dUL, 0x59dfa6aaUL,
0x78c14389UL, 0xd95a537fUL, 0x207d5ba2UL, 0x02e5b9c5UL,
0x83260376UL, 0x6295cfa9UL, 0x11c81968UL, 0x4e734a41UL,
0xb3472dcaUL, 0x7b14a94aUL, 0x1b510052UL, 0x9a532915UL,
0xd60f573fUL, 0xbc9bc6e4UL, 0x2b60a476UL, 0x81e67400UL,
0x08ba6fb5UL, 0x571be91fUL, 0xf296ec6bUL, 0x2a0dd915UL,
0xb6636521UL, 0xe7b9f9b6UL, 0xff34052eUL, 0xc5855664UL,
0x53b02d5dUL, 0xa99f8fa1UL, 0x08ba4799UL, 0x6e85076aUL,
0x4b7a70e9UL, 0xb5b32944UL, 0xdb75092eUL, 0xc4192623UL,
0xad6ea6b0UL, 0x49a7df7dUL, 0x9cee60b8UL, 0x8fedb266UL,
0xecaa8c71UL, 0x699a17ffUL, 0x5664526cUL, 0xc2b19ee1UL,
0x193602a5UL, 0x75094c29UL, 0xa0591340UL, 0xe4183a3eUL,
0x3f54989aUL, 0x5b429d65UL, 0x6b8fe4d6UL, 0x99f73fd6UL,
0xa1d29c07UL, 0xefe830f5UL, 0x4d2d38e6UL, 0xf0255dc1UL,
0x4cdd2086UL, 0x8470eb26UL, 0x6382e9c6UL, 0x021ecc5eUL,
0x09686b3fUL, 0x3ebaefc9UL, 0x3c971814UL, 0x6b6a70a1UL,
0x687f3584UL, 0x52a0e286UL, 0xb79c5305UL, 0xaa500737UL,
0x3e07841cUL, 0x7fdeae5cUL, 0x8e7d44ecUL, 0x5716f2b8UL,
0xb03ada37UL, 0xf0500c0dUL, 0xf01c1f04UL, 0x0200b3ffUL,
0xae0cf51aUL, 0x3cb574b2UL, 0x25837a58UL, 0xdc0921bdUL,
0xd19113f9UL, 0x7ca92ff6UL, 0x94324773UL, 0x22f54701UL,
0x3ae5e581UL, 0x37c2dadcUL, 0xc8b57634UL, 0x9af3dda7UL,
0xa9446146UL, 0x0fd0030eUL, 0xecc8c73eUL, 0xa4751e41UL,
0xe238cd99UL, 0x3bea0e2fUL, 0x3280bba1UL, 0x183eb331UL,
0x4e548b38UL, 0x4f6db908UL, 0x6f420d03UL, 0xf60a04bfUL,
0x2cb81290UL, 0x24977c79UL, 0x5679b072UL, 0xbcaf89afUL,
0xde9a771fUL, 0xd9930810UL, 0xb38bae12UL, 0xdccf3f2eUL,
0x5512721fUL, 0x2e6b7124UL, 0x501adde6UL, 0x9f84cd87UL,
0x7a584718UL, 0x7408da17UL, 0xbc9f9abcUL, 0xe94b7d8cUL,
0xec7aec3aUL, 0xdb851dfaUL, 0x63094366UL, 0xc464c3d2UL,
0xef1c1847UL, 0x3215d908UL, 0xdd433b37UL, 0x24c2ba16UL,
0x12a14d43UL, 0x2a65c451UL, 0x50940002UL, 0x133ae4ddUL,
0x71dff89eUL, 0x10314e55UL, 0x81ac77d6UL, 0x5f11199bUL,
0x043556f1UL, 0xd7a3c76bUL, 0x3c11183bUL, 0x5924a509UL,
0xf28fe6edUL, 0x97f1fbfaUL, 0x9ebabf2cUL, 0x1e153c6eUL,
0x86e34570UL, 0xeae96fb1UL, 0x860e5e0aUL, 0x5a3e2ab3UL,
0x771fe71cUL, 0x4e3d06faUL, 0x2965dcb9UL, 0x99e71d0fUL,
0x803e89d6UL, 0x5266c825UL, 0x2e4cc978UL, 0x9c10b36aUL,
0xc6150ebaUL, 0x94e2ea78UL, 0xa5fc3c53UL, 0x1e0a2df4UL,
0xf2f74ea7UL, 0x361d2b3dUL, 0x1939260fUL, 0x19c27960UL,
0x5223a708UL, 0xf71312b6UL, 0xebadfe6eUL, 0xeac31f66UL,
0xe3bc4595UL, 0xa67bc883UL, 0xb17f37d1UL, 0x018cff28UL,
0xc332ddefUL, 0xbe6c5aa5UL, 0x65582185UL, 0x68ab9802UL,
0xeecea50fUL, 0xdb2f953bUL, 0x2aef7dadUL, 0x5b6e2f84UL,
0x1521b628UL, 0x29076170UL, 0xecdd4775UL, 0x619f1510UL,
0x13cca830UL, 0xeb61bd96UL, 0x0334fe1eUL, 0xaa0363cfUL,
0xb5735c90UL, 0x4c70a239UL, 0xd59e9e0bUL, 0xcbaade14UL,
0xeecc86bcUL, 0x60622ca7UL, 0x9cab5cabUL, 0xb2f3846eUL,
0x648b1eafUL, 0x19bdf0caUL, 0xa02369b9UL, 0x655abb50UL,
0x40685a32UL, 0x3c2ab4b3UL, 0x319ee9d5UL, 0xc021b8f7UL,
0x9b540b19UL, 0x875fa099UL, 0x95f7997eUL, 0x623d7da8UL,
0xf837889aUL, 0x97e32d77UL, 0x11ed935fUL, 0x16681281UL,
0x0e358829UL, 0xc7e61fd6UL, 0x96dedfa1UL, 0x7858ba99UL,
0x57f584a5UL, 0x1b227263UL, 0x9b83c3ffUL, 0x1ac24696UL,
0xcdb30aebUL, 0x532e3054UL, 0x8fd948e4UL, 0x6dbc3128UL,
0x58ebf2efUL, 0x34c6ffeaUL, 0xfe28ed61UL, 0xee7c3c73UL,
0x5d4a14d9UL, 0xe864b7e3UL, 0x42105d14UL, 0x203e13e0UL,
0x45eee2b6UL, 0xa3aaabeaUL, 0xdb6c4f15UL, 0xfacb4fd0UL,
0xc742f442UL, 0xef6abbb5UL, 0x654f3b1dUL, 0x41cd2105UL,
0xd81e799eUL, 0x86854dc7UL, 0xe44b476aUL, 0x3d816250UL,
0xcf62a1f2UL, 0x5b8d2646UL, 0xfc8883a0UL, 0xc1c7b6a3UL,
0x7f1524c3UL, 0x69cb7492UL, 0x47848a0bUL, 0x5692b285UL,
0x095bbf00UL, 0xad19489dUL, 0x1462b174UL, 0x23820e00UL,
0x58428d2aUL, 0x0c55f5eaUL, 0x1dadf43eUL, 0x233f7061UL,
0x3372f092UL, 0x8d937e41UL, 0xd65fecf1UL, 0x6c223bdbUL,
0x7cde3759UL, 0xcbee7460UL, 0x4085f2a7UL, 0xce77326eUL,
0xa6078084UL, 0x19f8509eUL, 0xe8efd855UL, 0x61d99735UL,
0xa969a7aaUL, 0xc50c06c2UL, 0x5a04abfcUL, 0x800bcadcUL,
0x9e447a2eUL, 0xc3453484UL, 0xfdd56705UL, 0x0e1e9ec9UL,
0xdb73dbd3UL, 0x105588cdUL, 0x675fda79UL, 0xe3674340UL,
0xc5c43465UL, 0x713e38d8UL, 0x3d28f89eUL, 0xf16dff20UL,
0x153e21e7UL, 0x8fb03d4aUL, 0xe6e39f2bUL, 0xdb83adf7UL,
0xe93d5a68UL, 0x948140f7UL, 0xf64c261cUL, 0x94692934UL,
0x411520f7UL, 0x7602d4f7UL, 0xbcf46b2eUL, 0xd4a20068UL,
0xd4082471UL, 0x3320f46aUL, 0x43b7d4b7UL, 0x500061afUL,
0x1e39f62eUL, 0x97244546UL, 0x14214f74UL, 0xbf8b8840UL,
0x4d95fc1dUL, 0x96b591afUL, 0x70f4ddd3UL, 0x66a02f45UL,
0xbfbc09ecUL, 0x03bd9785UL, 0x7fac6dd0UL, 0x31cb8504UL,
0x96eb27b3UL, 0x55fd3941UL, 0xda2547e6UL, 0xabca0a9aUL,
0x28507825UL, 0x530429f4UL, 0x0a2c86daUL, 0xe9b66dfbUL,
0x68dc1462UL, 0xd7486900UL, 0x680ec0a4UL, 0x27a18deeUL,
0x4f3ffea2UL, 0xe887ad8cUL, 0xb58ce006UL, 0x7af4d6b6UL,
0xaace1e7cUL, 0xd3375fecUL, 0xce78a399UL, 0x406b2a42UL,
0x20fe9e35UL, 0xd9f385b9UL, 0xee39d7abUL, 0x3b124e8bUL,
0x1dc9faf7UL, 0x4b6d1856UL, 0x26a36631UL, 0xeae397b2UL,
0x3a6efa74UL, 0xdd5b4332UL, 0x6841e7f7UL, 0xca7820fbUL,
0xfb0af54eUL, 0xd8feb397UL, 0x454056acUL, 0xba489527UL,
0x55533a3aUL, 0x20838d87UL, 0xfe6ba9b7UL, 0xd096954bUL,
0x55a867bcUL, 0xa1159a58UL, 0xcca92963UL, 0x99e1db33UL,
0xa62a4a56UL, 0x3f3125f9UL, 0x5ef47e1cUL, 0x9029317cUL,
0xfdf8e802UL, 0x04272f70UL, 0x80bb155cUL, 0x05282ce3UL,
0x95c11548UL, 0xe4c66d22UL, 0x48c1133fUL, 0xc70f86dcUL,
0x07f9c9eeUL, 0x41041f0fUL, 0x404779a4UL, 0x5d886e17UL,
0x325f51ebUL, 0xd59bc0d1UL, 0xf2bcc18fUL, 0x41113564UL,
0x257b7834UL, 0x602a9c60UL, 0xdff8e8a3UL, 0x1f636c1bUL,
0x0e12b4c2UL, 0x02e1329eUL, 0xaf664fd1UL, 0xcad18115UL,
0x6b2395e0UL, 0x333e92e1UL, 0x3b240b62UL, 0xeebeb922UL,
0x85b2a20eUL, 0xe6ba0d99UL, 0xde720c8cUL, 0x2da2f728UL,
0xd0127845UL, 0x95b794fdUL, 0x647d0862UL, 0xe7ccf5f0UL,
0x5449a36fUL, 0x877d48faUL, 0xc39dfd27UL, 0xf33e8d1eUL,
0x0a476341UL, 0x992eff74UL, 0x3a6f6eabUL, 0xf4f8fd37UL,
0xa812dc60UL, 0xa1ebddf8UL, 0x991be14cUL, 0xdb6e6b0dUL,
0xc67b5510UL, 0x6d672c37UL, 0x2765d43bUL, 0xdcd0e804UL,
0xf1290dc7UL, 0xcc00ffa3UL, 0xb5390f92UL, 0x690fed0bUL,
0x667b9ffbUL, 0xcedb7d9cUL, 0xa091cf0bUL, 0xd9155ea3UL,
0xbb132f88UL, 0x515bad24UL, 0x7b9479bfUL, 0x763bd6ebUL,
0x37392eb3UL, 0xcc115979UL, 0x8026e297UL, 0xf42e312dUL,
0x6842ada7UL, 0xc66a2b3bUL, 0x12754cccUL, 0x782ef11cUL,
0x6a124237UL, 0xb79251e7UL, 0x06a1bbe6UL, 0x4bfb6350UL,
0x1a6b1018UL, 0x11caedfaUL, 0x3d25bdd8UL, 0xe2e1c3c9UL,
0x44421659UL, 0x0a121386UL, 0xd90cec6eUL, 0xd5abea2aUL,
0x64af674eUL, 0xda86a85fUL, 0xbebfe988UL, 0x64e4c3feUL,
0x9dbc8057UL, 0xf0f7c086UL, 0x60787bf8UL, 0x6003604dUL,
0xd1fd8346UL, 0xf6381fb0UL, 0x7745ae04UL, 0xd736fcccUL,
0x83426b33UL, 0xf01eab71UL, 0xb0804187UL, 0x3c005e5fUL,
0x77a057beUL, 0xbde8ae24UL, 0x55464299UL, 0xbf582e61UL,
0x4e58f48fUL, 0xf2ddfda2UL, 0xf474ef38UL, 0x8789bdc2UL,
0x5366f9c3UL, 0xc8b38e74UL, 0xb475f255UL, 0x46fcd9b9UL,
0x7aeb2661UL, 0x8b1ddf84UL, 0x846a0e79UL, 0x915f95e2UL,
0x466e598eUL, 0x20b45770UL, 0x8cd55591UL, 0xc902de4cUL,
0xb90bace1UL, 0xbb8205d0UL, 0x11a86248UL, 0x7574a99eUL,
0xb77f19b6UL, 0xe0a9dc09UL, 0x662d09a1UL, 0xc4324633UL,
0xe85a1f02UL, 0x09f0be8cUL, 0x4a99a025UL, 0x1d6efe10UL,
0x1ab93d1dUL, 0x0ba5a4dfUL, 0xa186f20fUL, 0x2868f169UL,
0xdcb7da83UL, 0x573906feUL, 0xa1e2ce9bUL, 0x4fcd7f52UL,
0x50115e01UL, 0xa70683faUL, 0xa002b5c4UL, 0x0de6d027UL,
0x9af88c27UL, 0x773f8641UL, 0xc3604c06UL, 0x61a806b5UL,
0xf0177a28UL, 0xc0f586e0UL, 0x006058aaUL, 0x30dc7d62UL,
0x11e69ed7UL, 0x2338ea63UL, 0x53c2dd94UL, 0xc2c21634UL,
0xbbcbee56UL, 0x90bcb6deUL, 0xebfc7da1UL, 0xce591d76UL,
0x6f05e409UL, 0x4b7c0188UL, 0x39720a3dUL, 0x7c927c24UL,
0x86e3725fUL, 0x724d9db9UL, 0x1ac15bb4UL, 0xd39eb8fcUL,
0xed545578UL, 0x08fca5b5UL, 0xd83d7cd3UL, 0x4dad0fc4UL,
0x1e50ef5eUL, 0xb161e6f8UL, 0xa28514d9UL, 0x6c51133cUL,
0x6fd5c7e7UL, 0x56e14ec4UL, 0x362abfceUL, 0xddc6c837UL,
0xd79a3234UL, 0x92638212UL, 0x670efa8eUL, 0x406000e0UL,
0x3a39ce37UL, 0xd3faf5cfUL, 0xabc27737UL, 0x5ac52d1bUL,
0x5cb0679eUL, 0x4fa33742UL, 0xd3822740UL, 0x99bc9bbeUL,
0xd5118e9dUL, 0xbf0f7315UL, 0xd62d1c7eUL, 0xc700c47bUL,
0xb78c1b6bUL, 0x21a19045UL, 0xb26eb1beUL, 0x6a366eb4UL,
0x5748ab2fUL, 0xbc946e79UL, 0xc6a376d2UL, 0x6549c2c8UL,
0x530ff8eeUL, 0x468dde7dUL, 0xd5730a1dUL, 0x4cd04dc6UL,
0x2939bbdbUL, 0xa9ba4650UL, 0xac9526e8UL, 0xbe5ee304UL,
0xa1fad5f0UL, 0x6a2d519aUL, 0x63ef8ce2UL, 0x9a86ee22UL,
0xc089c2b8UL, 0x43242ef6UL, 0xa51e03aaUL, 0x9cf2d0a4UL,
0x83c061baUL, 0x9be96a4dUL, 0x8fe51550UL, 0xba645bd6UL,
0x2826a2f9UL, 0xa73a3ae1UL, 0x4ba99586UL, 0xef5562e9UL,
0xc72fefd3UL, 0xf752f7daUL, 0x3f046f69UL, 0x77fa0a59UL,
0x80e4a915UL, 0x87b08601UL, 0x9b09e6adUL, 0x3b3ee593UL,
0xe990fd5aUL, 0x9e34d797UL, 0x2cf0b7d9UL, 0x022b8b51UL,
0x96d5ac3aUL, 0x017da67dUL, 0xd1cf3ed6UL, 0x7c7d2d28UL,
0x1f9f25cfUL, 0xadf2b89bUL, 0x5ad6b472UL, 0x5a88f54cUL,
0xe029ac71UL, 0xe019a5e6UL, 0x47b0acfdUL, 0xed93fa9bUL,
0xe8d3c48dUL, 0x283b57ccUL, 0xf8d56629UL, 0x79132e28UL,
0x785f0191UL, 0xed756055UL, 0xf7960e44UL, 0xe3d35e8cUL,
0x15056dd4UL, 0x88f46dbaUL, 0x03a16125UL, 0x0564f0bdUL,
0xc3eb9e15UL, 0x3c9057a2UL, 0x97271aecUL, 0xa93a072aUL,
0x1b3f6d9bUL, 0x1e6321f5UL, 0xf59c66fbUL, 0x26dcf319UL,
0x7533d928UL, 0xb155fdf5UL, 0x03563482UL, 0x8aba3cbbUL,
0x28517711UL, 0xc20ad9f8UL, 0xabcc5167UL, 0xccad925fUL,
0x4de81751UL, 0x3830dc8eUL, 0x379d5862UL, 0x9320f991UL,
0xea7a90c2UL, 0xfb3e7bceUL, 0x5121ce64UL, 0x774fbe32UL,
0xa8b6e37eUL, 0xc3293d46UL, 0x48de5369UL, 0x6413e680UL,
0xa2ae0810UL, 0xdd6db224UL, 0x69852dfdUL, 0x09072166UL,
0xb39a460aUL, 0x6445c0ddUL, 0x586cdecfUL, 0x1c20c8aeUL,
0x5bbef7ddUL, 0x1b588d40UL, 0xccd2017fUL, 0x6bb4e3bbUL,
0xdda26a7eUL, 0x3a59ff45UL, 0x3e350a44UL, 0xbcb4cdd5UL,
0x72eacea8UL, 0xfa6484bbUL, 0x8d6612aeUL, 0xbf3c6f47UL,
0xd29be463UL, 0x542f5d9eUL, 0xaec2771bUL, 0xf64e6370UL,
0x740e0d8dUL, 0xe75b1357UL, 0xf8721671UL, 0xaf537d5dUL,
0x4040cb08UL, 0x4eb4e2ccUL, 0x34d2466aUL, 0x0115af84UL,
0xe1b00428UL, 0x95983a1dUL, 0x06b89fb4UL, 0xce6ea048UL,
0x6f3f3b82UL, 0x3520ab82UL, 0x011a1d4bUL, 0x277227f8UL,
0x611560b1UL, 0xe7933fdcUL, 0xbb3a792bUL, 0x344525bdUL,
0xa08839e1UL, 0x51ce794bUL, 0x2f32c9b7UL, 0xa01fbac9UL,
0xe01cc87eUL, 0xbcc7d1f6UL, 0xcf0111c3UL, 0xa1e8aac7UL,
0x1a908749UL, 0xd44fbd9aUL, 0xd0dadecbUL, 0xd50ada38UL,
0x0339c32aUL, 0xc6913667UL, 0x8df9317cUL, 0xe0b12b4fUL,
0xf79e59b7UL, 0x43f5bb3aUL, 0xf2d519ffUL, 0x27d9459cUL,
0xbf97222cUL, 0x15e6fc2aUL, 0x0f91fc71UL, 0x9b941525UL,
0xfae59361UL, 0xceb69cebUL, 0xc2a86459UL, 0x12baa8d1UL,
0xb6c1075eUL, 0xe3056a0cUL, 0x10d25065UL, 0xcb03a442UL,
0xe0ec6e0eUL, 0x1698db3bUL, 0x4c98a0beUL, 0x3278e964UL,
0x9f1f9532UL, 0xe0d392dfUL, 0xd3a0342bUL, 0x8971f21eUL,
0x1b0a7441UL, 0x4ba3348cUL, 0xc5be7120UL, 0xc37632d8UL,
0xdf359f8dUL, 0x9b992f2eUL, 0xe60b6f47UL, 0x0fe3f11dUL,
0xe54cda54UL, 0x1edad891UL, 0xce6279cfUL, 0xcd3e7e6fUL,
0x1618b166UL, 0xfd2c1d05UL, 0x848fd2c5UL, 0xf6fb2299UL,
0xf523f357UL, 0xa6327623UL, 0x93a83531UL, 0x56cccd02UL,
0xacf08162UL, 0x5a75ebb5UL, 0x6e163697UL, 0x88d273ccUL,
0xde966292UL, 0x81b949d0UL, 0x4c50901bUL, 0x71c65614UL,
0xe6c6c7bdUL, 0x327a140aUL, 0x45e1d006UL, 0xc3f27b9aUL,
0xc9aa53fdUL, 0x62a80f00UL, 0xbb25bfe2UL, 0x35bdd2f6UL,
0x71126905UL, 0xb2040222UL, 0xb6cbcf7cUL, 0xcd769c2bUL,
0x53113ec0UL, 0x1640e3d3UL, 0x38abbd60UL, 0x2547adf0UL,
0xba38209cUL, 0xf746ce76UL, 0x77afa1c5UL, 0x20756060UL,
0x85cbfe4eUL, 0x8ae88dd8UL, 0x7aaaf9b0UL, 0x4cf9aa7eUL,
0x1948c25cUL, 0x02fb8a8cUL, 0x01c36ae4UL, 0xd6ebe1f9UL,
0x90d4f869UL, 0xa65cdea0UL, 0x3f09252dUL, 0xc208e69fUL,
0xb74e6132UL, 0xce77e25bUL, 0x578fdfe3UL, 0x3ac372e6UL,
}
};

View File

@ -1,116 +0,0 @@
/* crypto/bf/bf_skey.c */
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@mincom.oz.au).
* 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 (tjh@mincom.oz.au).
*
* 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 (eay@mincom.oz.au)"
* 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 (tjh@mincom.oz.au)"
*
* 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.]
*/
#include <stdio.h>
#include <string.h>
#include "blowfish.h"
#include "bf_locl.h"
#include "bf_pi.h"
void BF_set_key(BF_KEY *key, int len, unsigned char *data)
{
int i;
BF_LONG *p,ri,in[2];
unsigned char *d,*end;
memcpy((char *)key,(char *)&bf_init,sizeof(BF_KEY));
p=key->P;
if (len > ((BF_ROUNDS+2)*4)) len=(BF_ROUNDS+2)*4;
d=data;
end= &(data[len]);
for (i=0; i<(BF_ROUNDS+2); i++)
{
ri= (BF_LONG)*(d++);
if (d >= end) d=data;
ri<<=8;
ri|= *(d++);
if (d >= end) d=data;
ri<<=8;
ri|= *(d++);
if (d >= end) d=data;
ri<<=8;
ri|= *(d++);
if (d >= end) d=data;
p[i]^=ri;
}
in[0]=0L;
in[1]=0L;
for (i=0; i<(BF_ROUNDS+2); i+=2)
{
BF_encrypt(in,key,BF_ENCRYPT);
p[i ]=in[0];
p[i+1]=in[1];
}
p=key->S;
for (i=0; i<4*256; i+=2)
{
BF_encrypt(in,key,BF_ENCRYPT);
p[i ]=in[0];
p[i+1]=in[1];
}
}

View File

@ -1,149 +0,0 @@
The Blowfish library.
Blowfish is a block cipher that operates on 64bit (8 byte) quantities. It
uses variable size key, but 128bit (16 byte) key would normally be considered
good. It can be used in all the modes that DES can be used. This
library implements the ecb, cbc, cfb64, ofb64 modes.
Blowfish is quite a bit faster that DES, and much faster than IDEA or
RC2. It is one of the faster block ciphers.
For all calls that have an 'input' and 'output' variables, they can be the
same.
This library requires the inclusion of 'blowfish.h'.
All of the encryption functions take what is called an BF_KEY as an
argument. An BF_KEY is an expanded form of the Blowfish key.
For all modes of the Blowfish algorithm, the BF_KEY used for
decryption is the same one that was used for encryption.
The define BF_ENCRYPT is passed to specify encryption for the functions
that require an encryption/decryption flag. BF_DECRYPT is passed to
specify decryption.
Please note that any of the encryption modes specified in my DES library
could be used with Blowfish. I have only implemented ecb, cbc, cfb64 and
ofb64 for the following reasons.
- ecb is the basic Blowfish encryption.
- cbc is the normal 'chaining' form for block ciphers.
- cfb64 can be used to encrypt single characters, therefore input and output
do not need to be a multiple of 8.
- ofb64 is similar to cfb64 but is more like a stream cipher, not as
secure (not cipher feedback) but it does not have an encrypt/decrypt mode.
- If you want triple Blowfish, thats 384 bits of key and you must be totally
obsessed with security. Still, if you want it, it is simple enough to
copy the function from the DES library and change the des_encrypt to
BF_encrypt; an exercise left for the paranoid reader :-).
The functions are as follows:
void BF_set_key(
BF_KEY *ks;
int len;
unsigned char *key;
BF_set_key converts an 'len' byte key into a BF_KEY.
A 'ks' is an expanded form of the 'key' which is used to
perform actual encryption. It can be regenerated from the Blowfish key
so it only needs to be kept when encryption or decryption is about
to occur. Don't save or pass around BF_KEY's since they
are CPU architecture dependent, 'key's are not. Blowfish is an
interesting cipher in that it can be used with a variable length
key. 'len' is the length of 'key' to be used as the key.
A 'len' of 16 is recomended by me, but blowfish can use upto
72 bytes. As a warning, blowfish has a very very slow set_key
function, it actually runs BF_encrypt 521 times.
void BF_encrypt(
unsigned long *data,
BF_KEY *key,
int encrypt);
This is the Blowfish encryption function that gets called by just about
every other Blowfish routine in the library. You should not use this
function except to implement 'modes' of Blowfish.
I say this because the
functions that call this routine do the conversion from 'char *' to
long, and this needs to be done to make sure 'non-aligned' memory
access do not occur.
Data is a pointer to 2 unsigned long's and key is the
BF_KEY to use. Encryption or decryption is indicated by 'encrypt'.
which can have the values BF_ENCRYPT or BF_DECRYPT.
void BF_ecb_encrypt(
unsigned char *in,
unsigned char *out,
BF_KEY *key,
int encrypt);
This is the basic Electronic Code Book form of Blowfish (in DES this
mode is called Electronic Code Book so I'm going to use the term
for blowfish as well.
Input is encrypted into output using the key represented by
key. Depending on the encrypt, encryption or
decryption occurs. Input is 8 bytes long and output is 8 bytes.
void BF_cbc_encrypt(
unsigned char *in,
unsigned char *out,
long length,
BF_KEY *ks,
unsigned char *ivec,
int encrypt);
This routine implements Blowfish in Cipher Block Chaining mode.
Input, which should be a multiple of 8 bytes is encrypted
(or decrypted) to output which will also be a multiple of 8 bytes.
The number of bytes is in length (and from what I've said above,
should be a multiple of 8). If length is not a multiple of 8, bad
things will probably happen. ivec is the initialisation vector.
This function updates iv after each call so that it can be passed to
the next call to BF_cbc_encrypt().
void BF_cfb64_encrypt(
unsigned char *in,
unsigned char *out,
long length,
BF_KEY *schedule,
unsigned char *ivec,
int *num,
int encrypt);
This is one of the more useful functions in this Blowfish library, it
implements CFB mode of Blowfish with 64bit feedback.
This allows you to encrypt an arbitrary number of bytes,
you do not require 8 byte padding. Each call to this
routine will encrypt the input bytes to output and then update ivec
and num. Num contains 'how far' we are though ivec.
'Encrypt' is used to indicate encryption or decryption.
CFB64 mode operates by using the cipher to generate a stream
of bytes which is used to encrypt the plain text.
The cipher text is then encrypted to generate the next 64 bits to
be xored (incrementally) with the next 64 bits of plain
text. As can be seen from this, to encrypt or decrypt,
the same 'cipher stream' needs to be generated but the way the next
block of data is gathered for encryption is different for
encryption and decryption.
void BF_ofb64_encrypt(
unsigned char *in,
unsigned char *out,
long length,
BF_KEY *schedule,
unsigned char *ivec,
int *num);
This functions implements OFB mode of Blowfish with 64bit feedback.
This allows you to encrypt an arbitrary number of bytes,
you do not require 8 byte padding. Each call to this
routine will encrypt the input bytes to output and then update ivec
and num. Num contains 'how far' we are though ivec.
This is in effect a stream cipher, there is no encryption or
decryption mode.
For reading passwords, I suggest using des_read_pw_string() from my DES library.
To generate a password from a text string, I suggest using MD5 (or MD2) to
produce a 16 byte message digest that can then be passed directly to
BF_set_key().
=====
For more information about the specific Blowfish modes in this library
(ecb, cbc, cfb and ofb), read the section entitled 'Modes of DES' from the
documentation on my DES library. What is said about DES is directly
applicable for Blowfish.

View File

@ -1,114 +0,0 @@
/* crypto/bf/blowfish.h */
/* Copyright (C) 1995-1997 Eric Young (eay@mincom.oz.au)
* All rights reserved.
*
* This package is an SSL implementation written
* by Eric Young (eay@mincom.oz.au).
* 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 (tjh@mincom.oz.au).
*
* 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 (eay@mincom.oz.au)"
* 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 (tjh@mincom.oz.au)"
*
* 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.]
*/
#ifndef HEADER_BLOWFISH_H
#define HEADER_BLOWFISH_H
#ifdef __cplusplus
extern "C" {
#endif
#define BF_ENCRYPT 1
#define BF_DECRYPT 0
/* If you make this 'unsigned int' the pointer variants will work on
* the Alpha, otherwise they will not. Strangly using the '8 byte'
* BF_LONG and the default 'non-pointer' inner loop is the best configuration
* for the Alpha */
#define BF_LONG unsigned long
#define BF_ROUNDS 16
#define BF_BLOCK 8
typedef struct bf_key_st
{
BF_LONG P[BF_ROUNDS+2];
BF_LONG S[4*256];
} BF_KEY;
#ifndef NOPROTO
void BF_set_key(BF_KEY *key, int len, unsigned char *data);
void BF_ecb_encrypt(unsigned char *in,unsigned char *out,BF_KEY *key,
int encrypt);
void BF_encrypt(BF_LONG *data,BF_KEY *key,int encrypt);
void BF_cbc_encrypt(unsigned char *in, unsigned char *out, long length,
BF_KEY *ks, unsigned char *iv, int encrypt);
void BF_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
BF_KEY *schedule, unsigned char *ivec, int *num, int encrypt);
void BF_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
BF_KEY *schedule, unsigned char *ivec, int *num);
char *BF_options(void);
#else
void BF_set_key();
void BF_ecb_encrypt();
void BF_encrypt();
void BF_cbc_encrypt();
void BF_cfb64_encrypt();
void BF_ofb64_encrypt();
char *BF_options();
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,194 +0,0 @@
/*
HawkVoice Direct Interface (HVDI) cross platform network voice library
Copyright (C) 2001 Phil Frisbie, Jr. (phil@hawksoft.com)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Or go to http://www.gnu.org/copyleft/lgpl.html
*/
#ifndef HVDI_H
#define HVDI_H
#include "blowfish/blowfish.h"
#ifdef __cplusplus
extern "C" {
#endif
#define HVDI_MAJOR_VERSION 0
#define HVDI_MINOR_VERSION 7
#define HVDI_VERSION_STRING "HVDI 0.7 beta"
/* This was copied from nl.h so that it did not need to be included */
#if defined WIN32 || defined WIN64
#pragma warning (disable:4514) /* disable "unreferenced inline function has
been removed" warning */
/* The default build for Windows is as a DLL. */
/* If you want a static library, define WIN_STATIC_LIB. */
#ifdef WIN_STATIC_LIB
#define NL_EXP
#else
#if defined __LCC__
#define NL_EXP extern
#else
#define NL_EXP __declspec(dllexport)
#endif
#endif
#define NL_APIENTRY __stdcall
#define NL_CALLBACK __cdecl
#ifdef __GNUC__
#define NL_INLINE extern __inline__
#else
#define NL_INLINE __inline
#endif
#else
#define NL_EXP extern
#define NL_APIENTRY
#define NL_CALLBACK
#ifdef __GNUC__
#define NL_INLINE extern __inline__
#else
#define NL_INLINE inline /* assuming C99 compliant compiler */
#endif /* __GNUC__ */
#endif /* WIN32 || WIN64 */
#ifndef NL_INVALID
#define NL_INVALID (-1)
#define NL_FALSE (0)
#define NL_TRUE (1)
#endif
/* We will use HVDI or hvdi to prefix all HawkVoiceDI defines and functions */
/*
The internal state of the codec. This is READ ONLY! You can read hvdi_dec_state->codec
if you want to know what type of codec is being used on the other side, but DO NOT
write to this structure!! I could have hidden these structures behind an index, but
this IS low level quick and dirty ;)
hvdi_enc_state and hvdi_dec_state are defined separately to help the compiler spot
your mistakes ;)
*/
typedef struct
{
unsigned char codec; /* the codec used with the last packet */
unsigned short sequence;/* the sequence number of the last packet */
void *state; /* the codec state */
} hvdi_enc_state;
typedef struct
{
unsigned char codec; /* the codec used with the last packet */
unsigned short sequence;/* the sequence number of the last packet */
void *state; /* the codec state */
} hvdi_dec_state;
typedef struct
{
int rate; /* HVDI_VOX_FAST, HVDI_VOX_MEDIUM, or HVDI_VOX_SLOW */
int noisethreshold; /* 0(always pass) to 1000(never pass), 300 is a good starting point */
int samplecount; /* init to 0; used internally by hvdiVOX */
} hvdi_vox;
typedef struct
{
unsigned long lcmrate; /* least common multiple of rates */
unsigned long inskip, outskip; /* LCM increments for I & O rates */
unsigned long total;
unsigned long intot, outtot; /* total samples in terms of LCM rate */
long lastsamp;
} hvdi_rate;
typedef struct
{
unsigned int sample_max;
int counter;
float gain;
float peak;
int silence_counter;
} hvdi_agc;
/* The basic codecs, from hawkvoice.h */
#define HV_2_4K_CODEC 0x0001 /* LPC-10 2.4 Kbps codec */
#define HV_4_8K_CODEC 0x0002 /* LPC 4.8 Kbps codec */
#define HV_13_2K_CODEC 0x0004 /* GSM 13.2 Kbps codec */
#define HV_32K_CODEC 0x0008 /* Intel/DVI ADPCM 32 Kbps codec */
#define HV_64K_CODEC 0x0010 /* G.711 u-law 64 Kbps codec */
#define HV_1_4K_CODEC 0x0011 /* OpenLPC 1.4 Kbps codec */
#define HV_1_8K_CODEC 0x0012 /* OpenLPC 1.8 Kbps codec */
/* Alternate codec names */
#define HV_LPC10_CODEC HV_2_4K_CODEC
#define HV_LPC_CODEC HV_4_8K_CODEC
#define HV_GSM_CODEC HV_13_2K_CODEC
#define HV_ADPCM_32_CODEC HV_32K_CODEC
#define HV_PCM_64_CODEC HV_64K_CODEC
#define HV_G_711_CODEC HV_64K_CODEC
#define HV_ULAW_CODEC HV_64K_CODEC
#define HV_LPC_1_4_CODEC HV_1_4K_CODEC
#define HV_LPC_1_8_CODEC HV_1_8K_CODEC
/* VOX options */
/* how many samples of silence to wait after voice stops */
#define HVDI_VOX_FAST 4000 /* 1/2 second */
#define HVDI_VOX_MEDIUM 8000 /* 1 second */
#define HVDI_VOX_SLOW 12000 /* 1 1/2 seconds */
/* HawkVoiceDI API */
NL_EXP hvdi_enc_state* NL_APIENTRY hvdiCreateEncoderState(void);
NL_EXP hvdi_dec_state* NL_APIENTRY hvdiCreateDecoderState(void);
NL_EXP void NL_APIENTRY hvdiFreeEncoderState(hvdi_enc_state *state);
NL_EXP void NL_APIENTRY hvdiFreeDecoderState(hvdi_dec_state *state);
NL_EXP int NL_APIENTRY hvdiSetCodec(unsigned char codec, hvdi_enc_state *state);
NL_EXP BF_KEY* NL_APIENTRY hvdiMakeEncryptionKey(const char *string);
NL_EXP int NL_APIENTRY hvdiIsVoicePacket(unsigned char *packet, int length);
NL_EXP int NL_APIENTRY hvdiDecodePacket(unsigned char *packet, int paclen, short *buffer,
int buflen, BF_KEY *key, hvdi_dec_state *state);
NL_EXP int NL_APIENTRY hvdiEncodePacket(short *buffer, int buflen, unsigned char *packet,
int paclen, BF_KEY *key, hvdi_enc_state *state);
NL_EXP int NL_APIENTRY hvdiVOX(short *buffer, int buflen, hvdi_vox *vox);
NL_EXP void NL_APIENTRY hvdiRateInit(hvdi_rate *rate, int inrate, int outrate);
NL_EXP void NL_APIENTRY hvdiRateFlow(hvdi_rate *rate, short *inbuf, short *outbuf, int *inlen, int *outlen);
NL_EXP void NL_APIENTRY hvdiAGCInit(hvdi_agc *agc, float level);
NL_EXP void NL_APIENTRY hvdiAGC(hvdi_agc *agc, short *buffer, int len);
NL_EXP void NL_APIENTRY hvdiMix(short *outbuf, short **inbuf, int number, int inlen);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* HVDI_H */