+++ /dev/null
-package DES;
-
-require Exporter;
-require DynaLoader;
-@ISA = qw(Exporter DynaLoader);
-# Items to export into callers namespace by default
-# (move infrequently used names to @EXPORT_OK below)
-@EXPORT = qw(
-);
-# Other items we are prepared to export if requested
-@EXPORT_OK = qw(
-crypt
-);
-
-# Preloaded methods go here. Autoload methods go after __END__, and are
-# processed by the autosplit program.
-bootstrap DES;
-1;
-__END__
+++ /dev/null
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-#include "des.h"
-
-#define deschar char
-static STRLEN len;
-
-static int
-not_here(s)
-char *s;
-{
- croak("%s not implemented on this architecture", s);
- return -1;
-}
-
-MODULE = DES PACKAGE = DES PREFIX = des_
-
-char *
-des_crypt(buf,salt)
- char * buf
- char * salt
-
-void
-des_set_odd_parity(key)
- des_cblock * key
-PPCODE:
- {
- SV *s;
-
- s=sv_newmortal();
- sv_setpvn(s,(char *)key,8);
- des_set_odd_parity((des_cblock *)SvPV(s,na));
- PUSHs(s);
- }
-
-int
-des_is_weak_key(key)
- des_cblock * key
-
-des_key_schedule
-des_set_key(key)
- des_cblock * key
-CODE:
- des_set_key(key,RETVAL);
-OUTPUT:
-RETVAL
-
-des_cblock
-des_ecb_encrypt(input,ks,encrypt)
- des_cblock * input
- des_key_schedule * ks
- int encrypt
-CODE:
- des_ecb_encrypt(input,&RETVAL,*ks,encrypt);
-OUTPUT:
-RETVAL
-
-void
-des_cbc_encrypt(input,ks,ivec,encrypt)
- char * input
- des_key_schedule * ks
- des_cblock * ivec
- int encrypt
-PPCODE:
- {
- SV *s;
- STRLEN len,l;
- char *c;
-
- l=SvCUR(ST(0));
- len=((((unsigned long)l)+7)/8)*8;
- s=sv_newmortal();
- sv_setpvn(s,"",0);
- SvGROW(s,len);
- SvCUR_set(s,len);
- c=(char *)SvPV(s,na);
- des_cbc_encrypt((des_cblock *)input,(des_cblock *)c,
- l,*ks,ivec,encrypt);
- sv_setpvn(ST(2),(char *)c[len-8],8);
- PUSHs(s);
- }
-
-void
-des_cbc3_encrypt(input,ks1,ks2,ivec1,ivec2,encrypt)
- char * input
- des_key_schedule * ks1
- des_key_schedule * ks2
- des_cblock * ivec1
- des_cblock * ivec2
- int encrypt
-PPCODE:
- {
- SV *s;
- STRLEN len,l;
-
- l=SvCUR(ST(0));
- len=((((unsigned long)l)+7)/8)*8;
- s=sv_newmortal();
- sv_setpvn(s,"",0);
- SvGROW(s,len);
- SvCUR_set(s,len);
- des_3cbc_encrypt((des_cblock *)input,(des_cblock *)SvPV(s,na),
- l,*ks1,*ks2,ivec1,ivec2,encrypt);
- sv_setpvn(ST(3),(char *)ivec1,8);
- sv_setpvn(ST(4),(char *)ivec2,8);
- PUSHs(s);
- }
-
-void
-des_cbc_cksum(input,ks,ivec)
- char * input
- des_key_schedule * ks
- des_cblock * ivec
-PPCODE:
- {
- SV *s1,*s2;
- STRLEN len,l;
- des_cblock c;
- unsigned long i1,i2;
-
- s1=sv_newmortal();
- s2=sv_newmortal();
- l=SvCUR(ST(0));
- des_cbc_cksum((des_cblock *)input,(des_cblock *)c,
- l,*ks,ivec);
- i1=c[4]|(c[5]<<8)|(c[6]<<16)|(c[7]<<24);
- i2=c[0]|(c[1]<<8)|(c[2]<<16)|(c[3]<<24);
- sv_setiv(s1,i1);
- sv_setiv(s2,i2);
- sv_setpvn(ST(2),(char *)c,8);
- PUSHs(s1);
- PUSHs(s2);
- }
-
-void
-des_cfb_encrypt(input,numbits,ks,ivec,encrypt)
- char * input
- int numbits
- des_key_schedule * ks
- des_cblock * ivec
- int encrypt
-PPCODE:
- {
- SV *s;
- STRLEN len;
- char *c;
-
- len=SvCUR(ST(0));
- s=sv_newmortal();
- sv_setpvn(s,"",0);
- SvGROW(s,len);
- SvCUR_set(s,len);
- c=(char *)SvPV(s,na);
- des_cfb_encrypt((unsigned char *)input,(unsigned char *)c,
- (int)numbits,(long)len,*ks,ivec,encrypt);
- sv_setpvn(ST(3),(char *)ivec,8);
- PUSHs(s);
- }
-
-des_cblock *
-des_ecb3_encrypt(input,ks1,ks2,encrypt)
- des_cblock * input
- des_key_schedule * ks1
- des_key_schedule * ks2
- int encrypt
-CODE:
- {
- des_cblock c;
-
- des_ecb3_encrypt((des_cblock *)input,(des_cblock *)&c,
- *ks1,*ks2,encrypt);
- RETVAL= &c;
- }
-OUTPUT:
-RETVAL
-
-void
-des_ofb_encrypt(input,numbits,ks,ivec)
- unsigned char * input
- int numbits
- des_key_schedule * ks
- des_cblock * ivec
-PPCODE:
- {
- SV *s;
- STRLEN len,l;
- unsigned char *c;
-
- len=SvCUR(ST(0));
- s=sv_newmortal();
- sv_setpvn(s,"",0);
- SvGROW(s,len);
- SvCUR_set(s,len);
- c=(unsigned char *)SvPV(s,na);
- des_ofb_encrypt((unsigned char *)input,(unsigned char *)c,
- numbits,len,*ks,ivec);
- sv_setpvn(ST(3),(char *)ivec,8);
- PUSHs(s);
- }
-
-void
-des_pcbc_encrypt(input,ks,ivec,encrypt)
- char * input
- des_key_schedule * ks
- des_cblock * ivec
- int encrypt
-PPCODE:
- {
- SV *s;
- STRLEN len,l;
- char *c;
-
- l=SvCUR(ST(0));
- len=((((unsigned long)l)+7)/8)*8;
- s=sv_newmortal();
- sv_setpvn(s,"",0);
- SvGROW(s,len);
- SvCUR_set(s,len);
- c=(char *)SvPV(s,na);
- des_pcbc_encrypt((des_cblock *)input,(des_cblock *)c,
- l,*ks,ivec,encrypt);
- sv_setpvn(ST(2),(char *)c[len-8],8);
- PUSHs(s);
- }
-
-des_cblock *
-des_random_key()
-CODE:
- {
- des_cblock c;
-
- des_random_key(c);
- RETVAL=&c;
- }
-OUTPUT:
-RETVAL
-
-des_cblock *
-des_string_to_key(str)
-char * str
-CODE:
- {
- des_cblock c;
-
- des_string_to_key(str,&c);
- RETVAL=&c;
- }
-OUTPUT:
-RETVAL
-
-void
-des_string_to_2keys(str)
-char * str
-PPCODE:
- {
- des_cblock c1,c2;
- SV *s1,*s2;
-
- des_string_to_2keys(str,&c1,&c2);
- EXTEND(sp,2);
- s1=sv_newmortal();
- sv_setpvn(s1,(char *)c1,8);
- s2=sv_newmortal();
- sv_setpvn(s2,(char *)c2,8);
- PUSHs(s1);
- PUSHs(s2);
- }
/* General stuff */
COPYRIGHT - Copyright info.
-MODES.DES - A description of the features of the different modes of DES.
FILES - This file.
-INSTALL - How to make things compile.
-Imakefile - For use with kerberos.
README - What this package is.
VERSION - Which version this is and what was changed.
-KERBEROS - Kerberos version 4 notes.
-Makefile.PL - An old makefile to build with perl5, not current.
-Makefile.ssl - The SSLeay makefile
-Makefile.uni - The normal unix makefile.
-GNUmakefile - The makefile for use with glibc.
-makefile.bc - A Borland C makefile
-times - Some outputs from 'speed' on some machines.
-vms.com - For use when compiling under VMS
-
-/* My SunOS des(1) replacement */
-des.c - des(1) source code.
-des.man - des(1) manual.
-
-/* Testing and timing programs. */
-destest.c - Source for libdes.a test program.
-speed.c - Source for libdes.a timing program.
-rpw.c - Source for libdes.a testing password reading routines.
/* libdes.a source code */
-des_crypt.man - libdes.a manual page.
des.h - Public libdes.a header file.
ecb_enc.c - des_ecb_encrypt() source, this contains the basic DES code.
ecb3_enc.c - des_ecb3_encrypt() source.
version string.
des.doc - SSLeay documentation for the library.
-/* The perl scripts - you can ignore these files they are only
- * included for the curious */
-des.pl - des in perl anyone? des_set_key and des_ecb_encrypt
- both done in a perl library.
-testdes.pl - Testing program for des.pl
-doIP - Perl script used to develop IP xor/shift code.
-doPC1 - Perl script used to develop PC1 xor/shift code.
-doPC2 - Generates sk.h.
-PC1 - Output of doPC1 should be the same as output from PC1.
-PC2 - used in development of doPC2.
-shifts.pl - Perl library used by my perl scripts.
-
-/* I started making a perl5 dynamic library for libdes
- * but did not fully finish, these files are part of that effort. */
-DES.pm
-DES.pod
-DES.xs
-t
-typemap
-
-/* The following are for use with sun RPC implementaions. */
-rpc_des.h
-rpc_enc.c
-
-/* The following are contibuted by Mark Murray <mark@grondar.za>. They
- * are not normally built into libdes due to machine specific routines
- * contained in them. They are for use in the most recent incarnation of
- * export kerberos v 4 (eBones). */
-supp.c
-new_rkey.c
-
+++ /dev/null
-Check the CC and CFLAGS lines in the makefile
-
-If your C library does not support the times(3) function, change the
-#define TIMES to
-#undef TIMES in speed.c
-If it does, check the HZ value for the times(3) function.
-If your system does not define CLK_TCK it will be assumed to
-be 100.0.
-
-If possible use gcc v 2.7.?
-Turn on the maximum optimising (normally '-O3 -fomit-frame-pointer' for gcc)
-In recent times, some system compilers give better performace.
-
-type 'make'
-
-run './destest' to check things are ok.
-run './rpw' to check the tty code for reading passwords works.
-run './speed' to see how fast those optimisations make the library run :-)
-run './des_opts' to determin the best compile time options.
-
-The output from des_opts should be put in the makefile options and des_enc.c
-should be rebuilt. For 64 bit computers, do not use the DES_PTR option.
-For the DEC Alpha, edit des.h and change DES_LONG to 'unsigned int'
-and then you can use the 'DES_PTR' option.
-
-The file options.txt has the options listed for best speed on quite a
-few systems. Look and the options (UNROLL, PTR, RISC2 etc) and then
-turn on the relevant option in the Makefile.
-
-There are some special Makefile targets that make life easier.
-make cc - standard cc build
-make gcc - standard gcc build
-make x86-elf - x86 assembler (elf), linux-elf.
-make x86-out - x86 assembler (a.out), FreeBSD
-make x86-solaris- x86 assembler
-make x86-bsdi - x86 assembler (a.out with primative assembler).
-
-If at all possible use the assembler (for Windows NT/95, use
-asm/win32.obj to link with). The x86 assembler is very very fast.
-
-A make install will by default install
-libdes.a in /usr/local/lib/libdes.a
-des in /usr/local/bin/des
-des_crypt.man in /usr/local/man/man3/des_crypt.3
-des.man in /usr/local/man/man1/des.1
-des.h in /usr/include/des.h
-
-des(1) should be compatible with sunOS's but I have been unable to
-test it.
-
-These routines should compile on MSDOS, most 32bit and 64bit version
-of Unix (BSD and SYSV) and VMS, without modification.
-The only problems should be #include files that are in the wrong places.
-
-These routines can be compiled under MSDOS.
-I have successfully encrypted files using des(1) under MSDOS and then
-decrypted the files on a SparcStation.
-I have been able to compile and test the routines with
-Microsoft C v 5.1 and Turbo C v 2.0.
-The code in this library is in no way optimised for the 16bit
-operation of MSDOS.
-
-When building for glibc, ignore all of the above and just unpack into
-glibc-1.??/des and then gmake as per normal.
-
-As a final note on performace. Certain CPUs like sparcs and Alpha often give
-a %10 speed difference depending on the link order. It is rather anoying
-when one program reports 'x' DES encrypts a second and another reports
-'x*0.9' the speed.
+++ /dev/null
- [ This is an old file, I don't know if it is true anymore
- but I will leave the file here - eay 21/11/95 ]
-
-To use this library with Bones (kerberos without DES):
-1) Get my modified Bones - eBones. It can be found on
- gondwana.ecr.mu.oz.au (128.250.1.63) /pub/athena/eBones-p9.tar.Z
- and
- nic.funet.fi (128.214.6.100) /pub/unix/security/Kerberos/eBones-p9.tar.Z
-
-2) Unpack this library in src/lib/des, makeing sure it is version
- 3.00 or greater (libdes.tar.93-10-07.Z). This versions differences
- from the version in comp.sources.misc volume 29 patchlevel2.
- The primarily difference is that it should compile under kerberos :-).
- It can be found at.
- ftp.psy.uq.oz.au (130.102.32.1) /pub/DES/libdes.tar.93-10-07.Z
-
-Now do a normal kerberos build and things should work.
-
-One problem I found when I was build on my local sun.
----
-For sunOS 4.1.1 apply the following patch to src/util/ss/make_commands.c
-
-*** make_commands.c.orig Fri Jul 3 04:18:35 1987
---- make_commands.c Wed May 20 08:47:42 1992
-***************
-*** 98,104 ****
- if (!rename(o_file, z_file)) {
- if (!vfork()) {
- chdir("/tmp");
-! execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r", "-n",
- z_file+5, 0);
- perror("/bin/ld");
- _exit(1);
---- 98,104 ----
- if (!rename(o_file, z_file)) {
- if (!vfork()) {
- chdir("/tmp");
-! execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r",
- z_file+5, 0);
- perror("/bin/ld");
- _exit(1);
+++ /dev/null
-=pod
-
-=head1 NAME
-
-des - encrypt or decrypt data using Data Encryption Standard
-
-=head1 SYNOPSIS
-
-B<des>
-(
-B<-e>
-|
-B<-E>
-) | (
-B<-d>
-|
-B<-D>
-) | (
-B<->[B<cC>][B<ckname>]
-) |
-[
-B<-b3hfs>
-] [
-B<-k>
-I<key>
-]
-] [
-B<-u>[I<uuname>]
-[
-I<input-file>
-[
-I<output-file>
-] ]
-
-=head1 NOTE
-
-This page describes the B<des> stand-alone program, not the B<openssl des>
-command.
-
-=head1 DESCRIPTION
-
-B<des>
-encrypts and decrypts data using the
-Data Encryption Standard algorithm.
-One of
-B<-e>, B<-E>
-(for encrypt) or
-B<-d>, B<-D>
-(for decrypt) must be specified.
-It is also possible to use
-B<-c>
-or
-B<-C>
-in conjunction or instead of the a encrypt/decrypt option to generate
-a 16 character hexadecimal checksum, generated via the
-I<des_cbc_cksum>.
-
-Two standard encryption modes are supported by the
-B<des>
-program, Cipher Block Chaining (the default) and Electronic Code Book
-(specified with
-B<-b>).
-
-The key used for the DES
-algorithm is obtained by prompting the user unless the
-B<-k>
-I<key>
-option is given.
-If the key is an argument to the
-B<des>
-command, it is potentially visible to users executing
-ps(1)
-or a derivative. To minimise this possibility,
-B<des>
-takes care to destroy the key argument immediately upon entry.
-If your shell keeps a history file be careful to make sure it is not
-world readable.
-
-Since this program attempts to maintain compatibility with sunOS's
-des(1) command, there are 2 different methods used to convert the user
-supplied key to a des key.
-Whenever and one or more of
-B<-E>, B<-D>, B<-C>
-or
-B<-3>
-options are used, the key conversion procedure will not be compatible
-with the sunOS des(1) version but will use all the user supplied
-character to generate the des key.
-B<des>
-command reads from standard input unless
-I<input-file>
-is specified and writes to standard output unless
-I<output-file>
-is given.
-
-=head1 OPTIONS
-
-=over 4
-
-=item B<-b>
-
-Select ECB
-(eight bytes at a time) encryption mode.
-
-=item B<-3>
-
-Encrypt using triple encryption.
-By default triple cbc encryption is used but if the
-B<-b>
-option is used then triple ECB encryption is performed.
-If the key is less than 8 characters long, the flag has no effect.
-
-=item B<-e>
-
-Encrypt data using an 8 byte key in a manner compatible with sunOS
-des(1).
-
-=item B<-E>
-
-Encrypt data using a key of nearly unlimited length (1024 bytes).
-This will product a more secure encryption.
-
-=item B<-d>
-
-Decrypt data that was encrypted with the B<-e> option.
-
-=item B<-D>
-
-Decrypt data that was encrypted with the B<-E> option.
-
-=item B<-c>
-
-Generate a 16 character hexadecimal cbc checksum and output this to
-stderr.
-If a filename was specified after the
-B<-c>
-option, the checksum is output to that file.
-The checksum is generated using a key generated in a sunOS compatible
-manner.
-
-=item B<-C>
-
-A cbc checksum is generated in the same manner as described for the
-B<-c>
-option but the DES key is generated in the same manner as used for the
-B<-E>
-and
-B<-D>
-options
-
-=item B<-f>
-
-Does nothing - allowed for compatibility with sunOS des(1) command.
-
-=item B<-s>
-
-Does nothing - allowed for compatibility with sunOS des(1) command.
-
-=item B<-k> I<key>
-
-Use the encryption
-I<key>
-specified.
-
-=item B<-h>
-
-The
-I<key>
-is assumed to be a 16 character hexadecimal number.
-If the
-B<-3>
-option is used the key is assumed to be a 32 character hexadecimal
-number.
-
-=item B<-u>
-
-This flag is used to read and write uuencoded files. If decrypting,
-the input file is assumed to contain uuencoded, DES encrypted data.
-If encrypting, the characters following the B<-u> are used as the name of
-the uuencoded file to embed in the begin line of the uuencoded
-output. If there is no name specified after the B<-u>, the name text.des
-will be embedded in the header.
-
-=head1 SEE ALSO
-
-ps(1),
-L<des_crypt(3)|des_crypt(3)>
-
-=head1 BUGS
-
-The problem with using the
-B<-e>
-option is the short key length.
-It would be better to use a real 56-bit key rather than an
-ASCII-based 56-bit pattern. Knowing that the key was derived from ASCII
-radically reduces the time necessary for a brute-force cryptographic attack.
-My attempt to remove this problem is to add an alternative text-key to
-DES-key function. This alternative function (accessed via
-B<-E>, B<-D>, B<-S>
-and
-B<-3>)
-uses DES to help generate the key.
-
-Be carefully when using the B<-u> option. Doing B<des -ud> I<filename> will
-not decrypt filename (the B<-u> option will gobble the B<-d> option).
-
-The VMS operating system operates in a world where files are always a
-multiple of 512 bytes. This causes problems when encrypted data is
-send from Unix to VMS since a 88 byte file will suddenly be padded
-with 424 null bytes. To get around this problem, use the B<-u> option
-to uuencode the data before it is send to the VMS system.
-
-=head1 AUTHOR
-
-Eric Young (eay@cryptsoft.com)
-
-=cut
+++ /dev/null
-#
-# Origional BC Makefile from Teun <Teun.Nijssen@kub.nl>
-#
-#
-CC = bcc
-TLIB = tlib /0 /C
-# note: the -3 flag produces code for 386, 486, Pentium etc; omit it for 286s
-OPTIMIZE= -3 -O2
-#WINDOWS= -W
-CFLAGS = -c -ml -d $(OPTIMIZE) $(WINDOWS) -DMSDOS
-LFLAGS = -ml $(WINDOWS)
-
-.c.obj:
- $(CC) $(CFLAGS) $*.c
-
-.obj.exe:
- $(CC) $(LFLAGS) -e$*.exe $*.obj libdes.lib
-
-all: $(LIB) destest.exe rpw.exe des.exe speed.exe
-
-# "make clean": use a directory containing only libdes .exe and .obj files...
-clean:
- del *.exe
- del *.obj
- del libdes.lib
- del libdes.rsp
-
-OBJS= cbc_cksm.obj cbc_enc.obj ecb_enc.obj pcbc_enc.obj \
- qud_cksm.obj rand_key.obj set_key.obj str2key.obj \
- enc_read.obj enc_writ.obj fcrypt.obj cfb_enc.obj \
- ecb3_enc.obj ofb_enc.obj cbc3_enc.obj read_pwd.obj\
- cfb64enc.obj ofb64enc.obj ede_enc.obj cfb64ede.obj\
- ofb64ede.obj supp.obj
-
-LIB= libdes.lib
-
-$(LIB): $(OBJS)
- del $(LIB)
- makersp "+%s &\n" &&|
- $(OBJS)
-| >libdes.rsp
- $(TLIB) libdes.lib @libdes.rsp,nul
- del libdes.rsp
-
-destest.exe: destest.obj libdes.lib
-rpw.exe: rpw.obj libdes.lib
-speed.exe: speed.obj libdes.lib
-des.exe: des.obj libdes.lib
-
-
+++ /dev/null
-/* crypto/des/rpw.c */
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
- * All rights reserved.
- *
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * 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@cryptsoft.com).
- *
- * 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@cryptsoft.com)"
- * 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@cryptsoft.com)"
- *
- * 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 <openssl/des.h>
-
-int main(int argc, char *argv[])
- {
- DES_cblock k,k1;
- int i;
-
- printf("read passwd\n");
- if ((i=des_read_password(&k,"Enter password:",0)) == 0)
- {
- printf("password = ");
- for (i=0; i<8; i++)
- printf("%02x ",k[i]);
- }
- else
- printf("error %d\n",i);
- printf("\n");
- printf("read 2passwds and verify\n");
- if ((i=des_read_2passwords(&k,&k1,
- "Enter verified password:",1)) == 0)
- {
- printf("password1 = ");
- for (i=0; i<8; i++)
- printf("%02x ",k[i]);
- printf("\n");
- printf("password2 = ");
- for (i=0; i<8; i++)
- printf("%02x ",k1[i]);
- printf("\n");
- exit(1);
- }
- else
- {
- printf("error %d\n",i);
- exit(0);
- }
-#ifdef LINT
- return(0);
-#endif
- }
+++ /dev/null
-/* crypto/des/speed.c */
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
- * All rights reserved.
- *
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * 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@cryptsoft.com).
- *
- * 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@cryptsoft.com)"
- * 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@cryptsoft.com)"
- *
- * 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.]
- */
-
-/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
-/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
-
-#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
-#define TIMES
-#endif
-
-#include <stdio.h>
-
-#include <openssl/e_os2.h>
-#include <unistd.h>
-
-#ifndef OPENSSL_SYS_NETWARE
-#include <signal.h>
-#define crypt(c,s) (des_crypt((c),(s)))
-#endif
-
-#ifndef _IRIX
-#include <time.h>
-#endif
-#ifdef TIMES
-#include <sys/types.h>
-#include <sys/times.h>
-#endif
-
-/* Depending on the VMS version, the tms structure is perhaps defined.
- The __TMS macro will show if it was. If it wasn't defined, we should
- undefine TIMES, since that tells the rest of the program how things
- should be handled. -- Richard Levitte */
-#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
-#undef TIMES
-#endif
-
-#ifndef TIMES
-#include <sys/timeb.h>
-#endif
-
-#if defined(sun) || defined(__ultrix)
-#define _POSIX_SOURCE
-#include <limits.h>
-#include <sys/param.h>
-#endif
-
-#include <openssl/des.h>
-
-/* The following if from times(3) man page. It may need to be changed */
-#ifndef HZ
-# ifndef CLK_TCK
-# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
-# define HZ 100.0
-# else /* _BSD_CLK_TCK_ */
-# define HZ ((double)_BSD_CLK_TCK_)
-# endif
-# else /* CLK_TCK */
-# define HZ ((double)CLK_TCK)
-# endif
-#endif
-
-#define BUFSIZE ((long)1024)
-long run=0;
-
-double Time_F(int s);
-#ifdef SIGALRM
-#if defined(__STDC__) || defined(sgi) || defined(_AIX)
-#define SIGRETTYPE void
-#else
-#define SIGRETTYPE int
-#endif
-
-SIGRETTYPE sig_done(int sig);
-SIGRETTYPE sig_done(int sig)
- {
- signal(SIGALRM,sig_done);
- run=0;
-#ifdef LINT
- sig=sig;
-#endif
- }
-#endif
-
-#define START 0
-#define STOP 1
-
-double Time_F(int s)
- {
- double ret;
-#ifdef TIMES
- static struct tms tstart,tend;
-
- if (s == START)
- {
- times(&tstart);
- return(0);
- }
- else
- {
- times(&tend);
- ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
- return((ret == 0.0)?1e-6:ret);
- }
-#else /* !times() */
- static struct timeb tstart,tend;
- long i;
-
- if (s == START)
- {
- ftime(&tstart);
- return(0);
- }
- else
- {
- ftime(&tend);
- i=(long)tend.millitm-(long)tstart.millitm;
- ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
- return((ret == 0.0)?1e-6:ret);
- }
-#endif
- }
-
-int main(int argc, char **argv)
- {
- long count;
- static unsigned char buf[BUFSIZE];
- static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
- static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
- static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
- DES_key_schedule sch,sch2,sch3;
- double a,b,c,d,e;
-#ifndef SIGALRM
- long ca,cb,cc,cd,ce;
-#endif
-
-#ifndef TIMES
- printf("To get the most accurate results, try to run this\n");
- printf("program when this computer is idle.\n");
-#endif
-
- DES_set_key_unchecked(&key2,&sch2);
- DES_set_key_unchecked(&key3,&sch3);
-
-#ifndef SIGALRM
- printf("First we calculate the approximate speed ...\n");
- DES_set_key_unchecked(&key,&sch);
- count=10;
- do {
- long i;
- DES_LONG data[2];
-
- count*=2;
- Time_F(START);
- for (i=count; i; i--)
- DES_encrypt1(data,&sch,DES_ENCRYPT);
- d=Time_F(STOP);
- } while (d < 3.0);
- ca=count;
- cb=count*3;
- cc=count*3*8/BUFSIZE+1;
- cd=count*8/BUFSIZE+1;
- ce=count/20+1;
- printf("Doing set_key %ld times\n",ca);
-#define COND(d) (count != (d))
-#define COUNT(d) (d)
-#else
-#define COND(c) (run)
-#define COUNT(d) (count)
- signal(SIGALRM,sig_done);
- printf("Doing set_key for 10 seconds\n");
- alarm(10);
-#endif
-
- Time_F(START);
- for (count=0,run=1; COND(ca); count++)
- DES_set_key_unchecked(&key,&sch);
- d=Time_F(STOP);
- printf("%ld set_key's in %.2f seconds\n",count,d);
- a=((double)COUNT(ca))/d;
-
-#ifdef SIGALRM
- printf("Doing DES_encrypt's for 10 seconds\n");
- alarm(10);
-#else
- printf("Doing DES_encrypt %ld times\n",cb);
-#endif
- Time_F(START);
- for (count=0,run=1; COND(cb); count++)
- {
- DES_LONG data[2];
-
- DES_encrypt1(data,&sch,DES_ENCRYPT);
- }
- d=Time_F(STOP);
- printf("%ld DES_encrypt's in %.2f second\n",count,d);
- b=((double)COUNT(cb)*8)/d;
-
-#ifdef SIGALRM
- printf("Doing DES_cbc_encrypt on %ld byte blocks for 10 seconds\n",
- BUFSIZE);
- alarm(10);
-#else
- printf("Doing DES_cbc_encrypt %ld times on %ld byte blocks\n",cc,
- BUFSIZE);
-#endif
- Time_F(START);
- for (count=0,run=1; COND(cc); count++)
- DES_ncbc_encrypt(buf,buf,BUFSIZE,&sch,
- &key,DES_ENCRYPT);
- d=Time_F(STOP);
- printf("%ld DES_cbc_encrypt's of %ld byte blocks in %.2f second\n",
- count,BUFSIZE,d);
- c=((double)COUNT(cc)*BUFSIZE)/d;
-
-#ifdef SIGALRM
- printf("Doing DES_ede_cbc_encrypt on %ld byte blocks for 10 seconds\n",
- BUFSIZE);
- alarm(10);
-#else
- printf("Doing DES_ede_cbc_encrypt %ld times on %ld byte blocks\n",cd,
- BUFSIZE);
-#endif
- Time_F(START);
- for (count=0,run=1; COND(cd); count++)
- DES_ede3_cbc_encrypt(buf,buf,BUFSIZE,
- &sch,
- &sch2,
- &sch3,
- &key,
- DES_ENCRYPT);
- d=Time_F(STOP);
- printf("%ld DES_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n",
- count,BUFSIZE,d);
- d=((double)COUNT(cd)*BUFSIZE)/d;
-
-#ifdef SIGALRM
- printf("Doing crypt for 10 seconds\n");
- alarm(10);
-#else
- printf("Doing crypt %ld times\n",ce);
-#endif
- Time_F(START);
- for (count=0,run=1; COND(ce); count++)
- crypt("testing1","ef");
- e=Time_F(STOP);
- printf("%ld crypts in %.2f second\n",count,e);
- e=((double)COUNT(ce))/e;
-
- printf("set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
- printf("DES raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b);
- printf("DES cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
- printf("DES ede cbc bytes per sec = %12.2f (%9.3fuS)\n",d,8.0e6/d);
- printf("crypt per sec = %12.2f (%9.3fuS)\n",e,1.0e6/e);
- exit(0);
-#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
- return(0);
-#endif
- }
+++ /dev/null
-#!./perl
-
-BEGIN { push(@INC, qw(../../../lib ../../lib ../lib lib)); }
-
-use DES;
-
-$key='00000000';
-$ks=DES::set_key($key);
-@a=split(//,$ks);
-foreach (@a) { printf "%02x-",ord($_); }
-print "\n";
-
-
-$key=DES::random_key();
-print "($_)\n";
-@a=split(//,$key);
-foreach (@a) { printf "%02x-",ord($_); }
-print "\n";
-$str="this is and again into the breach";
-($k1,$k2)=DES::string_to_2keys($str);
-@a=split(//,$k1);
-foreach (@a) { printf "%02x-",ord($_); }
-print "\n";
-@a=split(//,$k2);
-foreach (@a) { printf "%02x-",ord($_); }
-print "\n";
-
+++ /dev/null
-Solaris 2.4, 486 50mhz, gcc 2.6.3
-options des ecb/s
-16 r2 i 43552.51 100.0%
-16 r1 i 43487.45 99.9%
-16 c p 43003.23 98.7%
-16 r2 p 42339.00 97.2%
-16 c i 41900.91 96.2%
-16 r1 p 41360.64 95.0%
- 4 c i 38728.48 88.9%
- 4 c p 38225.63 87.8%
- 4 r1 i 38085.79 87.4%
- 4 r2 i 37825.64 86.9%
- 4 r2 p 34611.00 79.5%
- 4 r1 p 31802.00 73.0%
--DDES_UNROLL -DDES_RISC2
-
+++ /dev/null
-Pentium 100
-Linux 2 kernel
-gcc 2.7.0 -O3 -fomit-frame-pointer
-No X server running, just a console, it makes the top speed jump from 151,000
-to 158,000 :-).
-options des ecb/s
-assember 281000.00 177.1%
-16 r1 p 158667.40 100.0%
-16 r1 i 148471.70 93.6%
-16 r2 p 143961.80 90.7%
-16 r2 i 141689.20 89.3%
- 4 r1 i 140100.00 88.3%
- 4 r2 i 134049.40 84.5%
-16 c i 124145.20 78.2%
-16 c p 121584.20 76.6%
- 4 c i 118116.00 74.4%
- 4 r2 p 117977.90 74.4%
- 4 c p 114971.40 72.5%
- 4 r1 p 114578.40 72.2%
--DDES_UNROLL -DDES_RISC1 -DDES_PTR
+++ /dev/null
-Pentium 100
-Free BSD 2.1.5 kernel
-gcc 2.7.2.2 -O3 -fomit-frame-pointer
-options des ecb/s
-assember 578000.00 133.1%
-16 r2 i 434454.80 100.0%
-16 r1 i 433621.43 99.8%
-16 r2 p 431375.69 99.3%
- 4 r1 i 423722.30 97.5%
- 4 r2 i 422399.40 97.2%
-16 r1 p 421739.40 97.1%
-16 c i 399027.94 91.8%
-16 c p 372251.70 85.7%
- 4 c i 365118.35 84.0%
- 4 c p 352880.51 81.2%
- 4 r2 p 255104.90 58.7%
- 4 r1 p 251289.18 57.8%
--DDES_UNROLL -DDES_RISC2
+++ /dev/null
-From: Paco Garcia <pgarcia@cam.es>
-
-This machine is a Bull Estrella Minitower Model MT604-100
-Processor : PPC604
-P.Speed : 100Mhz
-Data/Instr Cache : 16 K
-L2 Cache : 256 K
-PCI BUS Speed : 33 Mhz
-TransfRate PCI : 132 MB/s
-Memory : 96 MB
-
-options des ecb/s
- 4 c p 275118.61 100.0%
- 4 c i 273545.07 99.4%
- 4 r2 p 270441.02 98.3%
- 4 r1 p 253052.15 92.0%
- 4 r2 i 240842.97 87.5%
- 4 r1 i 240556.66 87.4%
-16 c i 224603.99 81.6%
-16 c p 224483.98 81.6%
-16 r2 p 215691.19 78.4%
-16 r1 p 208332.83 75.7%
-16 r1 i 199206.50 72.4%
-16 r2 i 198963.70 72.3%
--DDES_PTR
-
+++ /dev/null
-cc -O2
-DES_LONG is 'unsigned int'
-
-options des ecb/s
- 4 r2 p 181146.14 100.0%
-16 r2 p 172102.94 95.0%
- 4 r2 i 165424.11 91.3%
-16 c p 160468.64 88.6%
- 4 c p 156653.59 86.5%
- 4 c i 155245.18 85.7%
- 4 r1 p 154729.68 85.4%
-16 r2 i 154137.69 85.1%
-16 r1 p 152357.96 84.1%
-16 c i 148743.91 82.1%
- 4 r1 i 146695.59 81.0%
-16 r1 i 144961.00 80.0%
--DDES_RISC2 -DDES_PTR
-
+++ /dev/null
-HPUX 10 - 9000/887 - cc -D_HPUX_SOURCE -Aa +ESlit +O2 -Wl,-a,archive
-
-options des ecb/s
-16 c i 149448.90 100.0%
- 4 c i 145861.79 97.6%
-16 r2 i 141710.96 94.8%
-16 r1 i 139455.33 93.3%
- 4 r2 i 138800.00 92.9%
- 4 r1 i 136692.65 91.5%
-16 r2 p 110228.17 73.8%
-16 r1 p 109397.07 73.2%
-16 c p 109209.89 73.1%
- 4 c p 108014.71 72.3%
- 4 r2 p 107873.88 72.2%
- 4 r1 p 107685.83 72.1%
--DDES_UNROLL
-
+++ /dev/null
-solaris 2.5.1 - sparc 10 50mhz - gcc 2.7.2
-
-options des ecb/s
-16 c i 124382.70 100.0%
- 4 c i 118884.68 95.6%
-16 c p 112261.20 90.3%
-16 r2 i 111777.10 89.9%
-16 r2 p 108896.30 87.5%
-16 r1 p 108791.59 87.5%
- 4 c p 107290.10 86.3%
- 4 r1 p 104583.80 84.1%
-16 r1 i 104206.20 83.8%
- 4 r2 p 103709.80 83.4%
- 4 r2 i 98306.43 79.0%
- 4 r1 i 91525.80 73.6%
--DDES_UNROLL
-
+++ /dev/null
-solaris 2.5.1 usparc 167mhz?? - SC4.0 cc -fast -Xa -xO5
-
-For the ultra sparc, SunC 4.0 cc -fast -Xa -xO5, running 'des_opts'
-gives a speed of 475,000 des/s while 'speed' gives 417,000 des/s.
-I believe the difference is tied up in optimisation that the compiler
-is able to perform when the code is 'inlined'. For 'speed', the DES
-routines are being linked from a library. I'll record the higher
-speed since if performance is everything, you can always inline
-'des_enc.c'.
-
-[ 16-Jan-06 - I've been playing with the
- '-xtarget=ultra -xarch=v8plus -Xa -xO5 -Xa'
- and while it makes the des_opts numbers much slower, it makes the
- actual 'speed' numbers look better which is a realistic version of
- using the libraries. ]
-
-options des ecb/s
-16 r1 p 475516.90 100.0%
-16 r2 p 439388.10 92.4%
-16 c i 427001.40 89.8%
-16 c p 419516.50 88.2%
- 4 r2 p 409491.70 86.1%
- 4 r1 p 404266.90 85.0%
- 4 c p 398121.00 83.7%
- 4 c i 370588.40 77.9%
- 4 r1 i 362742.20 76.3%
-16 r2 i 331275.50 69.7%
-16 r1 i 324730.60 68.3%
- 4 r2 i 63535.10 13.4% <-- very very weird, must be cache problems.
--DDES_UNROLL -DDES_RISC1 -DDES_PTR
-
+++ /dev/null
-#
-# DES SECTION
-#
-deschar * T_DESCHARP
-des_cblock * T_CBLOCK
-des_cblock T_CBLOCK
-des_key_schedule T_SCHEDULE
-des_key_schedule * T_SCHEDULE
-
-INPUT
-T_CBLOCK
- $var=(des_cblock *)SvPV($arg,len);
- if (len < DES_KEY_SZ)
- {
- croak(\"$var needs to be at least %u bytes long\",DES_KEY_SZ);
- }
-
-T_SCHEDULE
- $var=(des_key_schedule *)SvPV($arg,len);
- if (len < DES_SCHEDULE_SZ)
- {
- croak(\"$var needs to be at least %u bytes long\",
- DES_SCHEDULE_SZ);
- }
-
-OUTPUT
-T_CBLOCK
- sv_setpvn($arg,(char *)$var,DES_KEY_SZ);
-
-T_SCHEDULE
- sv_setpvn($arg,(char *)$var,DES_SCHEDULE_SZ);
-
-T_DESCHARP
- sv_setpvn($arg,(char *)$var,len);
+++ /dev/null
-package DES;
-
-require Exporter;
-require DynaLoader;
-@ISA = qw(Exporter DynaLoader);
-# Items to export into callers namespace by default
-# (move infrequently used names to @EXPORT_OK below)
-@EXPORT = qw(
-);
-# Other items we are prepared to export if requested
-@EXPORT_OK = qw(
-crypt
-);
-
-# Preloaded methods go here. Autoload methods go after __END__, and are
-# processed by the autosplit program.
-bootstrap DES;
-1;
-__END__
+++ /dev/null
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-#include "des.h"
-
-#define deschar char
-static STRLEN len;
-
-static int
-not_here(s)
-char *s;
-{
- croak("%s not implemented on this architecture", s);
- return -1;
-}
-
-MODULE = DES PACKAGE = DES PREFIX = des_
-
-char *
-des_crypt(buf,salt)
- char * buf
- char * salt
-
-void
-des_set_odd_parity(key)
- des_cblock * key
-PPCODE:
- {
- SV *s;
-
- s=sv_newmortal();
- sv_setpvn(s,(char *)key,8);
- des_set_odd_parity((des_cblock *)SvPV(s,na));
- PUSHs(s);
- }
-
-int
-des_is_weak_key(key)
- des_cblock * key
-
-des_key_schedule
-des_set_key(key)
- des_cblock * key
-CODE:
- des_set_key(key,RETVAL);
-OUTPUT:
-RETVAL
-
-des_cblock
-des_ecb_encrypt(input,ks,encrypt)
- des_cblock * input
- des_key_schedule * ks
- int encrypt
-CODE:
- des_ecb_encrypt(input,&RETVAL,*ks,encrypt);
-OUTPUT:
-RETVAL
-
-void
-des_cbc_encrypt(input,ks,ivec,encrypt)
- char * input
- des_key_schedule * ks
- des_cblock * ivec
- int encrypt
-PPCODE:
- {
- SV *s;
- STRLEN len,l;
- char *c;
-
- l=SvCUR(ST(0));
- len=((((unsigned long)l)+7)/8)*8;
- s=sv_newmortal();
- sv_setpvn(s,"",0);
- SvGROW(s,len);
- SvCUR_set(s,len);
- c=(char *)SvPV(s,na);
- des_cbc_encrypt((des_cblock *)input,(des_cblock *)c,
- l,*ks,ivec,encrypt);
- sv_setpvn(ST(2),(char *)c[len-8],8);
- PUSHs(s);
- }
-
-void
-des_cbc3_encrypt(input,ks1,ks2,ivec1,ivec2,encrypt)
- char * input
- des_key_schedule * ks1
- des_key_schedule * ks2
- des_cblock * ivec1
- des_cblock * ivec2
- int encrypt
-PPCODE:
- {
- SV *s;
- STRLEN len,l;
-
- l=SvCUR(ST(0));
- len=((((unsigned long)l)+7)/8)*8;
- s=sv_newmortal();
- sv_setpvn(s,"",0);
- SvGROW(s,len);
- SvCUR_set(s,len);
- des_3cbc_encrypt((des_cblock *)input,(des_cblock *)SvPV(s,na),
- l,*ks1,*ks2,ivec1,ivec2,encrypt);
- sv_setpvn(ST(3),(char *)ivec1,8);
- sv_setpvn(ST(4),(char *)ivec2,8);
- PUSHs(s);
- }
-
-void
-des_cbc_cksum(input,ks,ivec)
- char * input
- des_key_schedule * ks
- des_cblock * ivec
-PPCODE:
- {
- SV *s1,*s2;
- STRLEN len,l;
- des_cblock c;
- unsigned long i1,i2;
-
- s1=sv_newmortal();
- s2=sv_newmortal();
- l=SvCUR(ST(0));
- des_cbc_cksum((des_cblock *)input,(des_cblock *)c,
- l,*ks,ivec);
- i1=c[4]|(c[5]<<8)|(c[6]<<16)|(c[7]<<24);
- i2=c[0]|(c[1]<<8)|(c[2]<<16)|(c[3]<<24);
- sv_setiv(s1,i1);
- sv_setiv(s2,i2);
- sv_setpvn(ST(2),(char *)c,8);
- PUSHs(s1);
- PUSHs(s2);
- }
-
-void
-des_cfb_encrypt(input,numbits,ks,ivec,encrypt)
- char * input
- int numbits
- des_key_schedule * ks
- des_cblock * ivec
- int encrypt
-PPCODE:
- {
- SV *s;
- STRLEN len;
- char *c;
-
- len=SvCUR(ST(0));
- s=sv_newmortal();
- sv_setpvn(s,"",0);
- SvGROW(s,len);
- SvCUR_set(s,len);
- c=(char *)SvPV(s,na);
- des_cfb_encrypt((unsigned char *)input,(unsigned char *)c,
- (int)numbits,(long)len,*ks,ivec,encrypt);
- sv_setpvn(ST(3),(char *)ivec,8);
- PUSHs(s);
- }
-
-des_cblock *
-des_ecb3_encrypt(input,ks1,ks2,encrypt)
- des_cblock * input
- des_key_schedule * ks1
- des_key_schedule * ks2
- int encrypt
-CODE:
- {
- des_cblock c;
-
- des_ecb3_encrypt((des_cblock *)input,(des_cblock *)&c,
- *ks1,*ks2,encrypt);
- RETVAL= &c;
- }
-OUTPUT:
-RETVAL
-
-void
-des_ofb_encrypt(input,numbits,ks,ivec)
- unsigned char * input
- int numbits
- des_key_schedule * ks
- des_cblock * ivec
-PPCODE:
- {
- SV *s;
- STRLEN len,l;
- unsigned char *c;
-
- len=SvCUR(ST(0));
- s=sv_newmortal();
- sv_setpvn(s,"",0);
- SvGROW(s,len);
- SvCUR_set(s,len);
- c=(unsigned char *)SvPV(s,na);
- des_ofb_encrypt((unsigned char *)input,(unsigned char *)c,
- numbits,len,*ks,ivec);
- sv_setpvn(ST(3),(char *)ivec,8);
- PUSHs(s);
- }
-
-void
-des_pcbc_encrypt(input,ks,ivec,encrypt)
- char * input
- des_key_schedule * ks
- des_cblock * ivec
- int encrypt
-PPCODE:
- {
- SV *s;
- STRLEN len,l;
- char *c;
-
- l=SvCUR(ST(0));
- len=((((unsigned long)l)+7)/8)*8;
- s=sv_newmortal();
- sv_setpvn(s,"",0);
- SvGROW(s,len);
- SvCUR_set(s,len);
- c=(char *)SvPV(s,na);
- des_pcbc_encrypt((des_cblock *)input,(des_cblock *)c,
- l,*ks,ivec,encrypt);
- sv_setpvn(ST(2),(char *)c[len-8],8);
- PUSHs(s);
- }
-
-des_cblock *
-des_random_key()
-CODE:
- {
- des_cblock c;
-
- des_random_key(c);
- RETVAL=&c;
- }
-OUTPUT:
-RETVAL
-
-des_cblock *
-des_string_to_key(str)
-char * str
-CODE:
- {
- des_cblock c;
-
- des_string_to_key(str,&c);
- RETVAL=&c;
- }
-OUTPUT:
-RETVAL
-
-void
-des_string_to_2keys(str)
-char * str
-PPCODE:
- {
- des_cblock c1,c2;
- SV *s1,*s2;
-
- des_string_to_2keys(str,&c1,&c2);
- EXTEND(sp,2);
- s1=sv_newmortal();
- sv_setpvn(s1,(char *)c1,8);
- s2=sv_newmortal();
- sv_setpvn(s2,(char *)c2,8);
- PUSHs(s1);
- PUSHs(s2);
- }
/* General stuff */
COPYRIGHT - Copyright info.
-MODES.DES - A description of the features of the different modes of DES.
FILES - This file.
-INSTALL - How to make things compile.
-Imakefile - For use with kerberos.
README - What this package is.
VERSION - Which version this is and what was changed.
-KERBEROS - Kerberos version 4 notes.
-Makefile.PL - An old makefile to build with perl5, not current.
-Makefile.ssl - The SSLeay makefile
-Makefile.uni - The normal unix makefile.
-GNUmakefile - The makefile for use with glibc.
-makefile.bc - A Borland C makefile
-times - Some outputs from 'speed' on some machines.
-vms.com - For use when compiling under VMS
-
-/* My SunOS des(1) replacement */
-des.c - des(1) source code.
-des.man - des(1) manual.
-
-/* Testing and timing programs. */
-destest.c - Source for libdes.a test program.
-speed.c - Source for libdes.a timing program.
-rpw.c - Source for libdes.a testing password reading routines.
/* libdes.a source code */
-des_crypt.man - libdes.a manual page.
des.h - Public libdes.a header file.
ecb_enc.c - des_ecb_encrypt() source, this contains the basic DES code.
ecb3_enc.c - des_ecb3_encrypt() source.
version string.
des.doc - SSLeay documentation for the library.
-/* The perl scripts - you can ignore these files they are only
- * included for the curious */
-des.pl - des in perl anyone? des_set_key and des_ecb_encrypt
- both done in a perl library.
-testdes.pl - Testing program for des.pl
-doIP - Perl script used to develop IP xor/shift code.
-doPC1 - Perl script used to develop PC1 xor/shift code.
-doPC2 - Generates sk.h.
-PC1 - Output of doPC1 should be the same as output from PC1.
-PC2 - used in development of doPC2.
-shifts.pl - Perl library used by my perl scripts.
-
-/* I started making a perl5 dynamic library for libdes
- * but did not fully finish, these files are part of that effort. */
-DES.pm
-DES.pod
-DES.xs
-t
-typemap
-
-/* The following are for use with sun RPC implementaions. */
-rpc_des.h
-rpc_enc.c
-
-/* The following are contibuted by Mark Murray <mark@grondar.za>. They
- * are not normally built into libdes due to machine specific routines
- * contained in them. They are for use in the most recent incarnation of
- * export kerberos v 4 (eBones). */
-supp.c
-new_rkey.c
-
+++ /dev/null
-Check the CC and CFLAGS lines in the makefile
-
-If your C library does not support the times(3) function, change the
-#define TIMES to
-#undef TIMES in speed.c
-If it does, check the HZ value for the times(3) function.
-If your system does not define CLK_TCK it will be assumed to
-be 100.0.
-
-If possible use gcc v 2.7.?
-Turn on the maximum optimising (normally '-O3 -fomit-frame-pointer' for gcc)
-In recent times, some system compilers give better performace.
-
-type 'make'
-
-run './destest' to check things are ok.
-run './rpw' to check the tty code for reading passwords works.
-run './speed' to see how fast those optimisations make the library run :-)
-run './des_opts' to determin the best compile time options.
-
-The output from des_opts should be put in the makefile options and des_enc.c
-should be rebuilt. For 64 bit computers, do not use the DES_PTR option.
-For the DEC Alpha, edit des.h and change DES_LONG to 'unsigned int'
-and then you can use the 'DES_PTR' option.
-
-The file options.txt has the options listed for best speed on quite a
-few systems. Look and the options (UNROLL, PTR, RISC2 etc) and then
-turn on the relevant option in the Makefile.
-
-There are some special Makefile targets that make life easier.
-make cc - standard cc build
-make gcc - standard gcc build
-make x86-elf - x86 assembler (elf), linux-elf.
-make x86-out - x86 assembler (a.out), FreeBSD
-make x86-solaris- x86 assembler
-make x86-bsdi - x86 assembler (a.out with primative assembler).
-
-If at all possible use the assembler (for Windows NT/95, use
-asm/win32.obj to link with). The x86 assembler is very very fast.
-
-A make install will by default install
-libdes.a in /usr/local/lib/libdes.a
-des in /usr/local/bin/des
-des_crypt.man in /usr/local/man/man3/des_crypt.3
-des.man in /usr/local/man/man1/des.1
-des.h in /usr/include/des.h
-
-des(1) should be compatible with sunOS's but I have been unable to
-test it.
-
-These routines should compile on MSDOS, most 32bit and 64bit version
-of Unix (BSD and SYSV) and VMS, without modification.
-The only problems should be #include files that are in the wrong places.
-
-These routines can be compiled under MSDOS.
-I have successfully encrypted files using des(1) under MSDOS and then
-decrypted the files on a SparcStation.
-I have been able to compile and test the routines with
-Microsoft C v 5.1 and Turbo C v 2.0.
-The code in this library is in no way optimised for the 16bit
-operation of MSDOS.
-
-When building for glibc, ignore all of the above and just unpack into
-glibc-1.??/des and then gmake as per normal.
-
-As a final note on performace. Certain CPUs like sparcs and Alpha often give
-a %10 speed difference depending on the link order. It is rather anoying
-when one program reports 'x' DES encrypts a second and another reports
-'x*0.9' the speed.
+++ /dev/null
- [ This is an old file, I don't know if it is true anymore
- but I will leave the file here - eay 21/11/95 ]
-
-To use this library with Bones (kerberos without DES):
-1) Get my modified Bones - eBones. It can be found on
- gondwana.ecr.mu.oz.au (128.250.1.63) /pub/athena/eBones-p9.tar.Z
- and
- nic.funet.fi (128.214.6.100) /pub/unix/security/Kerberos/eBones-p9.tar.Z
-
-2) Unpack this library in src/lib/des, makeing sure it is version
- 3.00 or greater (libdes.tar.93-10-07.Z). This versions differences
- from the version in comp.sources.misc volume 29 patchlevel2.
- The primarily difference is that it should compile under kerberos :-).
- It can be found at.
- ftp.psy.uq.oz.au (130.102.32.1) /pub/DES/libdes.tar.93-10-07.Z
-
-Now do a normal kerberos build and things should work.
-
-One problem I found when I was build on my local sun.
----
-For sunOS 4.1.1 apply the following patch to src/util/ss/make_commands.c
-
-*** make_commands.c.orig Fri Jul 3 04:18:35 1987
---- make_commands.c Wed May 20 08:47:42 1992
-***************
-*** 98,104 ****
- if (!rename(o_file, z_file)) {
- if (!vfork()) {
- chdir("/tmp");
-! execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r", "-n",
- z_file+5, 0);
- perror("/bin/ld");
- _exit(1);
---- 98,104 ----
- if (!rename(o_file, z_file)) {
- if (!vfork()) {
- chdir("/tmp");
-! execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r",
- z_file+5, 0);
- perror("/bin/ld");
- _exit(1);
+++ /dev/null
-=pod
-
-=head1 NAME
-
-des - encrypt or decrypt data using Data Encryption Standard
-
-=head1 SYNOPSIS
-
-B<des>
-(
-B<-e>
-|
-B<-E>
-) | (
-B<-d>
-|
-B<-D>
-) | (
-B<->[B<cC>][B<ckname>]
-) |
-[
-B<-b3hfs>
-] [
-B<-k>
-I<key>
-]
-] [
-B<-u>[I<uuname>]
-[
-I<input-file>
-[
-I<output-file>
-] ]
-
-=head1 NOTE
-
-This page describes the B<des> stand-alone program, not the B<openssl des>
-command.
-
-=head1 DESCRIPTION
-
-B<des>
-encrypts and decrypts data using the
-Data Encryption Standard algorithm.
-One of
-B<-e>, B<-E>
-(for encrypt) or
-B<-d>, B<-D>
-(for decrypt) must be specified.
-It is also possible to use
-B<-c>
-or
-B<-C>
-in conjunction or instead of the a encrypt/decrypt option to generate
-a 16 character hexadecimal checksum, generated via the
-I<des_cbc_cksum>.
-
-Two standard encryption modes are supported by the
-B<des>
-program, Cipher Block Chaining (the default) and Electronic Code Book
-(specified with
-B<-b>).
-
-The key used for the DES
-algorithm is obtained by prompting the user unless the
-B<-k>
-I<key>
-option is given.
-If the key is an argument to the
-B<des>
-command, it is potentially visible to users executing
-ps(1)
-or a derivative. To minimise this possibility,
-B<des>
-takes care to destroy the key argument immediately upon entry.
-If your shell keeps a history file be careful to make sure it is not
-world readable.
-
-Since this program attempts to maintain compatibility with sunOS's
-des(1) command, there are 2 different methods used to convert the user
-supplied key to a des key.
-Whenever and one or more of
-B<-E>, B<-D>, B<-C>
-or
-B<-3>
-options are used, the key conversion procedure will not be compatible
-with the sunOS des(1) version but will use all the user supplied
-character to generate the des key.
-B<des>
-command reads from standard input unless
-I<input-file>
-is specified and writes to standard output unless
-I<output-file>
-is given.
-
-=head1 OPTIONS
-
-=over 4
-
-=item B<-b>
-
-Select ECB
-(eight bytes at a time) encryption mode.
-
-=item B<-3>
-
-Encrypt using triple encryption.
-By default triple cbc encryption is used but if the
-B<-b>
-option is used then triple ECB encryption is performed.
-If the key is less than 8 characters long, the flag has no effect.
-
-=item B<-e>
-
-Encrypt data using an 8 byte key in a manner compatible with sunOS
-des(1).
-
-=item B<-E>
-
-Encrypt data using a key of nearly unlimited length (1024 bytes).
-This will product a more secure encryption.
-
-=item B<-d>
-
-Decrypt data that was encrypted with the B<-e> option.
-
-=item B<-D>
-
-Decrypt data that was encrypted with the B<-E> option.
-
-=item B<-c>
-
-Generate a 16 character hexadecimal cbc checksum and output this to
-stderr.
-If a filename was specified after the
-B<-c>
-option, the checksum is output to that file.
-The checksum is generated using a key generated in a sunOS compatible
-manner.
-
-=item B<-C>
-
-A cbc checksum is generated in the same manner as described for the
-B<-c>
-option but the DES key is generated in the same manner as used for the
-B<-E>
-and
-B<-D>
-options
-
-=item B<-f>
-
-Does nothing - allowed for compatibility with sunOS des(1) command.
-
-=item B<-s>
-
-Does nothing - allowed for compatibility with sunOS des(1) command.
-
-=item B<-k> I<key>
-
-Use the encryption
-I<key>
-specified.
-
-=item B<-h>
-
-The
-I<key>
-is assumed to be a 16 character hexadecimal number.
-If the
-B<-3>
-option is used the key is assumed to be a 32 character hexadecimal
-number.
-
-=item B<-u>
-
-This flag is used to read and write uuencoded files. If decrypting,
-the input file is assumed to contain uuencoded, DES encrypted data.
-If encrypting, the characters following the B<-u> are used as the name of
-the uuencoded file to embed in the begin line of the uuencoded
-output. If there is no name specified after the B<-u>, the name text.des
-will be embedded in the header.
-
-=head1 SEE ALSO
-
-ps(1),
-L<des_crypt(3)|des_crypt(3)>
-
-=head1 BUGS
-
-The problem with using the
-B<-e>
-option is the short key length.
-It would be better to use a real 56-bit key rather than an
-ASCII-based 56-bit pattern. Knowing that the key was derived from ASCII
-radically reduces the time necessary for a brute-force cryptographic attack.
-My attempt to remove this problem is to add an alternative text-key to
-DES-key function. This alternative function (accessed via
-B<-E>, B<-D>, B<-S>
-and
-B<-3>)
-uses DES to help generate the key.
-
-Be carefully when using the B<-u> option. Doing B<des -ud> I<filename> will
-not decrypt filename (the B<-u> option will gobble the B<-d> option).
-
-The VMS operating system operates in a world where files are always a
-multiple of 512 bytes. This causes problems when encrypted data is
-send from Unix to VMS since a 88 byte file will suddenly be padded
-with 424 null bytes. To get around this problem, use the B<-u> option
-to uuencode the data before it is send to the VMS system.
-
-=head1 AUTHOR
-
-Eric Young (eay@cryptsoft.com)
-
-=cut
+++ /dev/null
-#
-# Origional BC Makefile from Teun <Teun.Nijssen@kub.nl>
-#
-#
-CC = bcc
-TLIB = tlib /0 /C
-# note: the -3 flag produces code for 386, 486, Pentium etc; omit it for 286s
-OPTIMIZE= -3 -O2
-#WINDOWS= -W
-CFLAGS = -c -ml -d $(OPTIMIZE) $(WINDOWS) -DMSDOS
-LFLAGS = -ml $(WINDOWS)
-
-.c.obj:
- $(CC) $(CFLAGS) $*.c
-
-.obj.exe:
- $(CC) $(LFLAGS) -e$*.exe $*.obj libdes.lib
-
-all: $(LIB) destest.exe rpw.exe des.exe speed.exe
-
-# "make clean": use a directory containing only libdes .exe and .obj files...
-clean:
- del *.exe
- del *.obj
- del libdes.lib
- del libdes.rsp
-
-OBJS= cbc_cksm.obj cbc_enc.obj ecb_enc.obj pcbc_enc.obj \
- qud_cksm.obj rand_key.obj set_key.obj str2key.obj \
- enc_read.obj enc_writ.obj fcrypt.obj cfb_enc.obj \
- ecb3_enc.obj ofb_enc.obj cbc3_enc.obj read_pwd.obj\
- cfb64enc.obj ofb64enc.obj ede_enc.obj cfb64ede.obj\
- ofb64ede.obj supp.obj
-
-LIB= libdes.lib
-
-$(LIB): $(OBJS)
- del $(LIB)
- makersp "+%s &\n" &&|
- $(OBJS)
-| >libdes.rsp
- $(TLIB) libdes.lib @libdes.rsp,nul
- del libdes.rsp
-
-destest.exe: destest.obj libdes.lib
-rpw.exe: rpw.obj libdes.lib
-speed.exe: speed.obj libdes.lib
-des.exe: des.obj libdes.lib
-
-
+++ /dev/null
-/* crypto/des/rpw.c */
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
- * All rights reserved.
- *
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * 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@cryptsoft.com).
- *
- * 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@cryptsoft.com)"
- * 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@cryptsoft.com)"
- *
- * 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 <openssl/des.h>
-
-int main(int argc, char *argv[])
- {
- DES_cblock k,k1;
- int i;
-
- printf("read passwd\n");
- if ((i=des_read_password(&k,"Enter password:",0)) == 0)
- {
- printf("password = ");
- for (i=0; i<8; i++)
- printf("%02x ",k[i]);
- }
- else
- printf("error %d\n",i);
- printf("\n");
- printf("read 2passwds and verify\n");
- if ((i=des_read_2passwords(&k,&k1,
- "Enter verified password:",1)) == 0)
- {
- printf("password1 = ");
- for (i=0; i<8; i++)
- printf("%02x ",k[i]);
- printf("\n");
- printf("password2 = ");
- for (i=0; i<8; i++)
- printf("%02x ",k1[i]);
- printf("\n");
- exit(1);
- }
- else
- {
- printf("error %d\n",i);
- exit(0);
- }
-#ifdef LINT
- return(0);
-#endif
- }
+++ /dev/null
-/* crypto/des/speed.c */
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
- * All rights reserved.
- *
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * 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@cryptsoft.com).
- *
- * 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@cryptsoft.com)"
- * 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@cryptsoft.com)"
- *
- * 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.]
- */
-
-/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
-/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
-
-#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
-#define TIMES
-#endif
-
-#include <stdio.h>
-
-#include <openssl/e_os2.h>
-#include <unistd.h>
-
-#ifndef OPENSSL_SYS_NETWARE
-#include <signal.h>
-#define crypt(c,s) (des_crypt((c),(s)))
-#endif
-
-#ifndef _IRIX
-#include <time.h>
-#endif
-#ifdef TIMES
-#include <sys/types.h>
-#include <sys/times.h>
-#endif
-
-/* Depending on the VMS version, the tms structure is perhaps defined.
- The __TMS macro will show if it was. If it wasn't defined, we should
- undefine TIMES, since that tells the rest of the program how things
- should be handled. -- Richard Levitte */
-#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
-#undef TIMES
-#endif
-
-#ifndef TIMES
-#include <sys/timeb.h>
-#endif
-
-#if defined(sun) || defined(__ultrix)
-#define _POSIX_SOURCE
-#include <limits.h>
-#include <sys/param.h>
-#endif
-
-#include <openssl/des.h>
-
-/* The following if from times(3) man page. It may need to be changed */
-#ifndef HZ
-# ifndef CLK_TCK
-# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
-# define HZ 100.0
-# else /* _BSD_CLK_TCK_ */
-# define HZ ((double)_BSD_CLK_TCK_)
-# endif
-# else /* CLK_TCK */
-# define HZ ((double)CLK_TCK)
-# endif
-#endif
-
-#define BUFSIZE ((long)1024)
-long run=0;
-
-double Time_F(int s);
-#ifdef SIGALRM
-#if defined(__STDC__) || defined(sgi) || defined(_AIX)
-#define SIGRETTYPE void
-#else
-#define SIGRETTYPE int
-#endif
-
-SIGRETTYPE sig_done(int sig);
-SIGRETTYPE sig_done(int sig)
- {
- signal(SIGALRM,sig_done);
- run=0;
-#ifdef LINT
- sig=sig;
-#endif
- }
-#endif
-
-#define START 0
-#define STOP 1
-
-double Time_F(int s)
- {
- double ret;
-#ifdef TIMES
- static struct tms tstart,tend;
-
- if (s == START)
- {
- times(&tstart);
- return(0);
- }
- else
- {
- times(&tend);
- ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
- return((ret == 0.0)?1e-6:ret);
- }
-#else /* !times() */
- static struct timeb tstart,tend;
- long i;
-
- if (s == START)
- {
- ftime(&tstart);
- return(0);
- }
- else
- {
- ftime(&tend);
- i=(long)tend.millitm-(long)tstart.millitm;
- ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
- return((ret == 0.0)?1e-6:ret);
- }
-#endif
- }
-
-int main(int argc, char **argv)
- {
- long count;
- static unsigned char buf[BUFSIZE];
- static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
- static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
- static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
- DES_key_schedule sch,sch2,sch3;
- double a,b,c,d,e;
-#ifndef SIGALRM
- long ca,cb,cc,cd,ce;
-#endif
-
-#ifndef TIMES
- printf("To get the most accurate results, try to run this\n");
- printf("program when this computer is idle.\n");
-#endif
-
- DES_set_key_unchecked(&key2,&sch2);
- DES_set_key_unchecked(&key3,&sch3);
-
-#ifndef SIGALRM
- printf("First we calculate the approximate speed ...\n");
- DES_set_key_unchecked(&key,&sch);
- count=10;
- do {
- long i;
- DES_LONG data[2];
-
- count*=2;
- Time_F(START);
- for (i=count; i; i--)
- DES_encrypt1(data,&sch,DES_ENCRYPT);
- d=Time_F(STOP);
- } while (d < 3.0);
- ca=count;
- cb=count*3;
- cc=count*3*8/BUFSIZE+1;
- cd=count*8/BUFSIZE+1;
- ce=count/20+1;
- printf("Doing set_key %ld times\n",ca);
-#define COND(d) (count != (d))
-#define COUNT(d) (d)
-#else
-#define COND(c) (run)
-#define COUNT(d) (count)
- signal(SIGALRM,sig_done);
- printf("Doing set_key for 10 seconds\n");
- alarm(10);
-#endif
-
- Time_F(START);
- for (count=0,run=1; COND(ca); count++)
- DES_set_key_unchecked(&key,&sch);
- d=Time_F(STOP);
- printf("%ld set_key's in %.2f seconds\n",count,d);
- a=((double)COUNT(ca))/d;
-
-#ifdef SIGALRM
- printf("Doing DES_encrypt's for 10 seconds\n");
- alarm(10);
-#else
- printf("Doing DES_encrypt %ld times\n",cb);
-#endif
- Time_F(START);
- for (count=0,run=1; COND(cb); count++)
- {
- DES_LONG data[2];
-
- DES_encrypt1(data,&sch,DES_ENCRYPT);
- }
- d=Time_F(STOP);
- printf("%ld DES_encrypt's in %.2f second\n",count,d);
- b=((double)COUNT(cb)*8)/d;
-
-#ifdef SIGALRM
- printf("Doing DES_cbc_encrypt on %ld byte blocks for 10 seconds\n",
- BUFSIZE);
- alarm(10);
-#else
- printf("Doing DES_cbc_encrypt %ld times on %ld byte blocks\n",cc,
- BUFSIZE);
-#endif
- Time_F(START);
- for (count=0,run=1; COND(cc); count++)
- DES_ncbc_encrypt(buf,buf,BUFSIZE,&sch,
- &key,DES_ENCRYPT);
- d=Time_F(STOP);
- printf("%ld DES_cbc_encrypt's of %ld byte blocks in %.2f second\n",
- count,BUFSIZE,d);
- c=((double)COUNT(cc)*BUFSIZE)/d;
-
-#ifdef SIGALRM
- printf("Doing DES_ede_cbc_encrypt on %ld byte blocks for 10 seconds\n",
- BUFSIZE);
- alarm(10);
-#else
- printf("Doing DES_ede_cbc_encrypt %ld times on %ld byte blocks\n",cd,
- BUFSIZE);
-#endif
- Time_F(START);
- for (count=0,run=1; COND(cd); count++)
- DES_ede3_cbc_encrypt(buf,buf,BUFSIZE,
- &sch,
- &sch2,
- &sch3,
- &key,
- DES_ENCRYPT);
- d=Time_F(STOP);
- printf("%ld DES_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n",
- count,BUFSIZE,d);
- d=((double)COUNT(cd)*BUFSIZE)/d;
-
-#ifdef SIGALRM
- printf("Doing crypt for 10 seconds\n");
- alarm(10);
-#else
- printf("Doing crypt %ld times\n",ce);
-#endif
- Time_F(START);
- for (count=0,run=1; COND(ce); count++)
- crypt("testing1","ef");
- e=Time_F(STOP);
- printf("%ld crypts in %.2f second\n",count,e);
- e=((double)COUNT(ce))/e;
-
- printf("set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
- printf("DES raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b);
- printf("DES cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
- printf("DES ede cbc bytes per sec = %12.2f (%9.3fuS)\n",d,8.0e6/d);
- printf("crypt per sec = %12.2f (%9.3fuS)\n",e,1.0e6/e);
- exit(0);
-#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
- return(0);
-#endif
- }
+++ /dev/null
-#!./perl
-
-BEGIN { push(@INC, qw(../../../lib ../../lib ../lib lib)); }
-
-use DES;
-
-$key='00000000';
-$ks=DES::set_key($key);
-@a=split(//,$ks);
-foreach (@a) { printf "%02x-",ord($_); }
-print "\n";
-
-
-$key=DES::random_key();
-print "($_)\n";
-@a=split(//,$key);
-foreach (@a) { printf "%02x-",ord($_); }
-print "\n";
-$str="this is and again into the breach";
-($k1,$k2)=DES::string_to_2keys($str);
-@a=split(//,$k1);
-foreach (@a) { printf "%02x-",ord($_); }
-print "\n";
-@a=split(//,$k2);
-foreach (@a) { printf "%02x-",ord($_); }
-print "\n";
-
+++ /dev/null
-Solaris 2.4, 486 50mhz, gcc 2.6.3
-options des ecb/s
-16 r2 i 43552.51 100.0%
-16 r1 i 43487.45 99.9%
-16 c p 43003.23 98.7%
-16 r2 p 42339.00 97.2%
-16 c i 41900.91 96.2%
-16 r1 p 41360.64 95.0%
- 4 c i 38728.48 88.9%
- 4 c p 38225.63 87.8%
- 4 r1 i 38085.79 87.4%
- 4 r2 i 37825.64 86.9%
- 4 r2 p 34611.00 79.5%
- 4 r1 p 31802.00 73.0%
--DDES_UNROLL -DDES_RISC2
-
+++ /dev/null
-Pentium 100
-Linux 2 kernel
-gcc 2.7.0 -O3 -fomit-frame-pointer
-No X server running, just a console, it makes the top speed jump from 151,000
-to 158,000 :-).
-options des ecb/s
-assember 281000.00 177.1%
-16 r1 p 158667.40 100.0%
-16 r1 i 148471.70 93.6%
-16 r2 p 143961.80 90.7%
-16 r2 i 141689.20 89.3%
- 4 r1 i 140100.00 88.3%
- 4 r2 i 134049.40 84.5%
-16 c i 124145.20 78.2%
-16 c p 121584.20 76.6%
- 4 c i 118116.00 74.4%
- 4 r2 p 117977.90 74.4%
- 4 c p 114971.40 72.5%
- 4 r1 p 114578.40 72.2%
--DDES_UNROLL -DDES_RISC1 -DDES_PTR
+++ /dev/null
-Pentium 100
-Free BSD 2.1.5 kernel
-gcc 2.7.2.2 -O3 -fomit-frame-pointer
-options des ecb/s
-assember 578000.00 133.1%
-16 r2 i 434454.80 100.0%
-16 r1 i 433621.43 99.8%
-16 r2 p 431375.69 99.3%
- 4 r1 i 423722.30 97.5%
- 4 r2 i 422399.40 97.2%
-16 r1 p 421739.40 97.1%
-16 c i 399027.94 91.8%
-16 c p 372251.70 85.7%
- 4 c i 365118.35 84.0%
- 4 c p 352880.51 81.2%
- 4 r2 p 255104.90 58.7%
- 4 r1 p 251289.18 57.8%
--DDES_UNROLL -DDES_RISC2
+++ /dev/null
-From: Paco Garcia <pgarcia@cam.es>
-
-This machine is a Bull Estrella Minitower Model MT604-100
-Processor : PPC604
-P.Speed : 100Mhz
-Data/Instr Cache : 16 K
-L2 Cache : 256 K
-PCI BUS Speed : 33 Mhz
-TransfRate PCI : 132 MB/s
-Memory : 96 MB
-
-options des ecb/s
- 4 c p 275118.61 100.0%
- 4 c i 273545.07 99.4%
- 4 r2 p 270441.02 98.3%
- 4 r1 p 253052.15 92.0%
- 4 r2 i 240842.97 87.5%
- 4 r1 i 240556.66 87.4%
-16 c i 224603.99 81.6%
-16 c p 224483.98 81.6%
-16 r2 p 215691.19 78.4%
-16 r1 p 208332.83 75.7%
-16 r1 i 199206.50 72.4%
-16 r2 i 198963.70 72.3%
--DDES_PTR
-
+++ /dev/null
-cc -O2
-DES_LONG is 'unsigned int'
-
-options des ecb/s
- 4 r2 p 181146.14 100.0%
-16 r2 p 172102.94 95.0%
- 4 r2 i 165424.11 91.3%
-16 c p 160468.64 88.6%
- 4 c p 156653.59 86.5%
- 4 c i 155245.18 85.7%
- 4 r1 p 154729.68 85.4%
-16 r2 i 154137.69 85.1%
-16 r1 p 152357.96 84.1%
-16 c i 148743.91 82.1%
- 4 r1 i 146695.59 81.0%
-16 r1 i 144961.00 80.0%
--DDES_RISC2 -DDES_PTR
-
+++ /dev/null
-HPUX 10 - 9000/887 - cc -D_HPUX_SOURCE -Aa +ESlit +O2 -Wl,-a,archive
-
-options des ecb/s
-16 c i 149448.90 100.0%
- 4 c i 145861.79 97.6%
-16 r2 i 141710.96 94.8%
-16 r1 i 139455.33 93.3%
- 4 r2 i 138800.00 92.9%
- 4 r1 i 136692.65 91.5%
-16 r2 p 110228.17 73.8%
-16 r1 p 109397.07 73.2%
-16 c p 109209.89 73.1%
- 4 c p 108014.71 72.3%
- 4 r2 p 107873.88 72.2%
- 4 r1 p 107685.83 72.1%
--DDES_UNROLL
-
+++ /dev/null
-solaris 2.5.1 - sparc 10 50mhz - gcc 2.7.2
-
-options des ecb/s
-16 c i 124382.70 100.0%
- 4 c i 118884.68 95.6%
-16 c p 112261.20 90.3%
-16 r2 i 111777.10 89.9%
-16 r2 p 108896.30 87.5%
-16 r1 p 108791.59 87.5%
- 4 c p 107290.10 86.3%
- 4 r1 p 104583.80 84.1%
-16 r1 i 104206.20 83.8%
- 4 r2 p 103709.80 83.4%
- 4 r2 i 98306.43 79.0%
- 4 r1 i 91525.80 73.6%
--DDES_UNROLL
-
+++ /dev/null
-solaris 2.5.1 usparc 167mhz?? - SC4.0 cc -fast -Xa -xO5
-
-For the ultra sparc, SunC 4.0 cc -fast -Xa -xO5, running 'des_opts'
-gives a speed of 475,000 des/s while 'speed' gives 417,000 des/s.
-I believe the difference is tied up in optimisation that the compiler
-is able to perform when the code is 'inlined'. For 'speed', the DES
-routines are being linked from a library. I'll record the higher
-speed since if performance is everything, you can always inline
-'des_enc.c'.
-
-[ 16-Jan-06 - I've been playing with the
- '-xtarget=ultra -xarch=v8plus -Xa -xO5 -Xa'
- and while it makes the des_opts numbers much slower, it makes the
- actual 'speed' numbers look better which is a realistic version of
- using the libraries. ]
-
-options des ecb/s
-16 r1 p 475516.90 100.0%
-16 r2 p 439388.10 92.4%
-16 c i 427001.40 89.8%
-16 c p 419516.50 88.2%
- 4 r2 p 409491.70 86.1%
- 4 r1 p 404266.90 85.0%
- 4 c p 398121.00 83.7%
- 4 c i 370588.40 77.9%
- 4 r1 i 362742.20 76.3%
-16 r2 i 331275.50 69.7%
-16 r1 i 324730.60 68.3%
- 4 r2 i 63535.10 13.4% <-- very very weird, must be cache problems.
--DDES_UNROLL -DDES_RISC1 -DDES_PTR
-
+++ /dev/null
-#
-# DES SECTION
-#
-deschar * T_DESCHARP
-des_cblock * T_CBLOCK
-des_cblock T_CBLOCK
-des_key_schedule T_SCHEDULE
-des_key_schedule * T_SCHEDULE
-
-INPUT
-T_CBLOCK
- $var=(des_cblock *)SvPV($arg,len);
- if (len < DES_KEY_SZ)
- {
- croak(\"$var needs to be at least %u bytes long\",DES_KEY_SZ);
- }
-
-T_SCHEDULE
- $var=(des_key_schedule *)SvPV($arg,len);
- if (len < DES_SCHEDULE_SZ)
- {
- croak(\"$var needs to be at least %u bytes long\",
- DES_SCHEDULE_SZ);
- }
-
-OUTPUT
-T_CBLOCK
- sv_setpvn($arg,(char *)$var,DES_KEY_SZ);
-
-T_SCHEDULE
- sv_setpvn($arg,(char *)$var,DES_SCHEDULE_SZ);
-
-T_DESCHARP
- sv_setpvn($arg,(char *)$var,len);