summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/des
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/des')
-rw-r--r--src/lib/libcrypto/des/COPYRIGHT50
-rw-r--r--src/lib/libcrypto/des/DES.pm19
-rw-r--r--src/lib/libcrypto/des/DES.xs268
-rw-r--r--src/lib/libcrypto/des/FILES096
-rw-r--r--src/lib/libcrypto/des/INSTALL69
-rw-r--r--src/lib/libcrypto/des/Imakefile35
-rw-r--r--src/lib/libcrypto/des/KERBEROS41
-rw-r--r--src/lib/libcrypto/des/Makefile278
-rw-r--r--src/lib/libcrypto/des/README54
-rw-r--r--src/lib/libcrypto/des/VERSION412
-rw-r--r--src/lib/libcrypto/des/asm/crypt586.pl209
-rw-r--r--src/lib/libcrypto/des/asm/des-586.pl453
-rw-r--r--src/lib/libcrypto/des/asm/des_enc.m42099
-rw-r--r--src/lib/libcrypto/des/asm/desboth.pl79
-rw-r--r--src/lib/libcrypto/des/asm/readme131
-rw-r--r--src/lib/libcrypto/des/cbc3_enc.c99
-rw-r--r--src/lib/libcrypto/des/cbc_cksm.c106
-rw-r--r--src/lib/libcrypto/des/cbc_enc.c61
-rw-r--r--src/lib/libcrypto/des/cfb64ede.c254
-rw-r--r--src/lib/libcrypto/des/cfb64enc.c121
-rw-r--r--src/lib/libcrypto/des/cfb_enc.c195
-rw-r--r--src/lib/libcrypto/des/des-lib.com1005
-rw-r--r--src/lib/libcrypto/des/des.c932
-rw-r--r--src/lib/libcrypto/des/des.h247
-rw-r--r--src/lib/libcrypto/des/des.pod217
-rw-r--r--src/lib/libcrypto/des/des3s.cpp67
-rw-r--r--src/lib/libcrypto/des/des_enc.c404
-rw-r--r--src/lib/libcrypto/des/des_locl.h432
-rw-r--r--src/lib/libcrypto/des/des_old.c273
-rw-r--r--src/lib/libcrypto/des/des_old.h446
-rw-r--r--src/lib/libcrypto/des/des_old2.c82
-rw-r--r--src/lib/libcrypto/des/des_opts.c608
-rw-r--r--src/lib/libcrypto/des/des_ver.h71
-rw-r--r--src/lib/libcrypto/des/dess.cpp67
-rw-r--r--src/lib/libcrypto/des/destest.c952
-rw-r--r--src/lib/libcrypto/des/ecb3_enc.c83
-rw-r--r--src/lib/libcrypto/des/ecb_enc.c122
-rw-r--r--src/lib/libcrypto/des/ede_cbcm_enc.c199
-rw-r--r--src/lib/libcrypto/des/enc_read.c240
-rw-r--r--src/lib/libcrypto/des/enc_writ.c179
-rw-r--r--src/lib/libcrypto/des/fcrypt.c170
-rw-r--r--src/lib/libcrypto/des/fcrypt_b.c146
-rw-r--r--src/lib/libcrypto/des/makefile.bc50
-rw-r--r--src/lib/libcrypto/des/ncbc_enc.c148
-rw-r--r--src/lib/libcrypto/des/ofb64ede.c125
-rw-r--r--src/lib/libcrypto/des/ofb64enc.c110
-rw-r--r--src/lib/libcrypto/des/ofb_enc.c135
-rw-r--r--src/lib/libcrypto/des/options.txt39
-rw-r--r--src/lib/libcrypto/des/pcbc_enc.c123
-rw-r--r--src/lib/libcrypto/des/qud_cksm.c139
-rw-r--r--src/lib/libcrypto/des/rand_key.c68
-rw-r--r--src/lib/libcrypto/des/read2pwd.c140
-rw-r--r--src/lib/libcrypto/des/read_pwd.c521
-rw-r--r--src/lib/libcrypto/des/rpc_des.h133
-rw-r--r--src/lib/libcrypto/des/rpc_enc.c98
-rw-r--r--src/lib/libcrypto/des/rpw.c99
-rw-r--r--src/lib/libcrypto/des/set_key.c407
-rw-r--r--src/lib/libcrypto/des/speed.c314
-rw-r--r--src/lib/libcrypto/des/spr.h204
-rw-r--r--src/lib/libcrypto/des/str2key.c174
-rw-r--r--src/lib/libcrypto/des/t/test27
-rw-r--r--src/lib/libcrypto/des/times/486-50.sol16
-rw-r--r--src/lib/libcrypto/des/times/586-100.lnx20
-rw-r--r--src/lib/libcrypto/des/times/686-200.fre18
-rw-r--r--src/lib/libcrypto/des/times/aix.cc26
-rw-r--r--src/lib/libcrypto/des/times/alpha.cc18
-rw-r--r--src/lib/libcrypto/des/times/hpux.cc17
-rw-r--r--src/lib/libcrypto/des/times/sparc.gcc17
-rw-r--r--src/lib/libcrypto/des/times/usparc.cc31
-rw-r--r--src/lib/libcrypto/des/typemap34
-rw-r--r--src/lib/libcrypto/des/xcbc_enc.c197
71 files changed, 0 insertions, 15519 deletions
diff --git a/src/lib/libcrypto/des/COPYRIGHT b/src/lib/libcrypto/des/COPYRIGHT
deleted file mode 100644
index 5469e1e469..0000000000
--- a/src/lib/libcrypto/des/COPYRIGHT
+++ /dev/null
@@ -1,50 +0,0 @@
1Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
2All rights reserved.
3
4This package is an DES implementation written by Eric Young (eay@cryptsoft.com).
5The implementation was written so as to conform with MIT's libdes.
6
7This library is free for commercial and non-commercial use as long as
8the following conditions are aheared to. The following conditions
9apply to all code found in this distribution.
10
11Copyright remains Eric Young's, and as such any Copyright notices in
12the code are not to be removed.
13If this package is used in a product, Eric Young should be given attribution
14as the author of that the SSL library. This can be in the form of a textual
15message at program startup or in documentation (online or textual) provided
16with the package.
17
18Redistribution and use in source and binary forms, with or without
19modification, are permitted provided that the following conditions
20are met:
211. Redistributions of source code must retain the copyright
22 notice, this list of conditions and the following disclaimer.
232. Redistributions in binary form must reproduce the above copyright
24 notice, this list of conditions and the following disclaimer in the
25 documentation and/or other materials provided with the distribution.
263. All advertising materials mentioning features or use of this software
27 must display the following acknowledgement:
28 This product includes software developed by Eric Young (eay@cryptsoft.com)
29
30THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
31ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
34FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40SUCH DAMAGE.
41
42The license and distribution terms for any publically available version or
43derivative of this code cannot be changed. i.e. this code cannot simply be
44copied and put under another distrubution license
45[including the GNU Public License.]
46
47The reason behind this being stated in this direct manner is past
48experience in code simply being copied and the attribution removed
49from it and then being distributed as part of other packages. This
50implementation was a non-trivial and unpaid effort.
diff --git a/src/lib/libcrypto/des/DES.pm b/src/lib/libcrypto/des/DES.pm
deleted file mode 100644
index 6a175b6ca4..0000000000
--- a/src/lib/libcrypto/des/DES.pm
+++ /dev/null
@@ -1,19 +0,0 @@
1package DES;
2
3require Exporter;
4require DynaLoader;
5@ISA = qw(Exporter DynaLoader);
6# Items to export into callers namespace by default
7# (move infrequently used names to @EXPORT_OK below)
8@EXPORT = qw(
9);
10# Other items we are prepared to export if requested
11@EXPORT_OK = qw(
12crypt
13);
14
15# Preloaded methods go here. Autoload methods go after __END__, and are
16# processed by the autosplit program.
17bootstrap DES;
181;
19__END__
diff --git a/src/lib/libcrypto/des/DES.xs b/src/lib/libcrypto/des/DES.xs
deleted file mode 100644
index b8050b9edf..0000000000
--- a/src/lib/libcrypto/des/DES.xs
+++ /dev/null
@@ -1,268 +0,0 @@
1#include "EXTERN.h"
2#include "perl.h"
3#include "XSUB.h"
4#include "des.h"
5
6#define deschar char
7static STRLEN len;
8
9static int
10not_here(s)
11char *s;
12{
13 croak("%s not implemented on this architecture", s);
14 return -1;
15}
16
17MODULE = DES PACKAGE = DES PREFIX = des_
18
19char *
20des_crypt(buf,salt)
21 char * buf
22 char * salt
23
24void
25des_set_odd_parity(key)
26 des_cblock * key
27PPCODE:
28 {
29 SV *s;
30
31 s=sv_newmortal();
32 sv_setpvn(s,(char *)key,8);
33 des_set_odd_parity((des_cblock *)SvPV(s,na));
34 PUSHs(s);
35 }
36
37int
38des_is_weak_key(key)
39 des_cblock * key
40
41des_key_schedule
42des_set_key(key)
43 des_cblock * key
44CODE:
45 des_set_key(key,RETVAL);
46OUTPUT:
47RETVAL
48
49des_cblock
50des_ecb_encrypt(input,ks,encrypt)
51 des_cblock * input
52 des_key_schedule * ks
53 int encrypt
54CODE:
55 des_ecb_encrypt(input,&RETVAL,*ks,encrypt);
56OUTPUT:
57RETVAL
58
59void
60des_cbc_encrypt(input,ks,ivec,encrypt)
61 char * input
62 des_key_schedule * ks
63 des_cblock * ivec
64 int encrypt
65PPCODE:
66 {
67 SV *s;
68 STRLEN len,l;
69 char *c;
70
71 l=SvCUR(ST(0));
72 len=((((unsigned long)l)+7)/8)*8;
73 s=sv_newmortal();
74 sv_setpvn(s,"",0);
75 SvGROW(s,len);
76 SvCUR_set(s,len);
77 c=(char *)SvPV(s,na);
78 des_cbc_encrypt((des_cblock *)input,(des_cblock *)c,
79 l,*ks,ivec,encrypt);
80 sv_setpvn(ST(2),(char *)c[len-8],8);
81 PUSHs(s);
82 }
83
84void
85des_cbc3_encrypt(input,ks1,ks2,ivec1,ivec2,encrypt)
86 char * input
87 des_key_schedule * ks1
88 des_key_schedule * ks2
89 des_cblock * ivec1
90 des_cblock * ivec2
91 int encrypt
92PPCODE:
93 {
94 SV *s;
95 STRLEN len,l;
96
97 l=SvCUR(ST(0));
98 len=((((unsigned long)l)+7)/8)*8;
99 s=sv_newmortal();
100 sv_setpvn(s,"",0);
101 SvGROW(s,len);
102 SvCUR_set(s,len);
103 des_3cbc_encrypt((des_cblock *)input,(des_cblock *)SvPV(s,na),
104 l,*ks1,*ks2,ivec1,ivec2,encrypt);
105 sv_setpvn(ST(3),(char *)ivec1,8);
106 sv_setpvn(ST(4),(char *)ivec2,8);
107 PUSHs(s);
108 }
109
110void
111des_cbc_cksum(input,ks,ivec)
112 char * input
113 des_key_schedule * ks
114 des_cblock * ivec
115PPCODE:
116 {
117 SV *s1,*s2;
118 STRLEN len,l;
119 des_cblock c;
120 unsigned long i1,i2;
121
122 s1=sv_newmortal();
123 s2=sv_newmortal();
124 l=SvCUR(ST(0));
125 des_cbc_cksum((des_cblock *)input,(des_cblock *)c,
126 l,*ks,ivec);
127 i1=c[4]|(c[5]<<8)|(c[6]<<16)|(c[7]<<24);
128 i2=c[0]|(c[1]<<8)|(c[2]<<16)|(c[3]<<24);
129 sv_setiv(s1,i1);
130 sv_setiv(s2,i2);
131 sv_setpvn(ST(2),(char *)c,8);
132 PUSHs(s1);
133 PUSHs(s2);
134 }
135
136void
137des_cfb_encrypt(input,numbits,ks,ivec,encrypt)
138 char * input
139 int numbits
140 des_key_schedule * ks
141 des_cblock * ivec
142 int encrypt
143PPCODE:
144 {
145 SV *s;
146 STRLEN len;
147 char *c;
148
149 len=SvCUR(ST(0));
150 s=sv_newmortal();
151 sv_setpvn(s,"",0);
152 SvGROW(s,len);
153 SvCUR_set(s,len);
154 c=(char *)SvPV(s,na);
155 des_cfb_encrypt((unsigned char *)input,(unsigned char *)c,
156 (int)numbits,(long)len,*ks,ivec,encrypt);
157 sv_setpvn(ST(3),(char *)ivec,8);
158 PUSHs(s);
159 }
160
161des_cblock *
162des_ecb3_encrypt(input,ks1,ks2,encrypt)
163 des_cblock * input
164 des_key_schedule * ks1
165 des_key_schedule * ks2
166 int encrypt
167CODE:
168 {
169 des_cblock c;
170
171 des_ecb3_encrypt((des_cblock *)input,(des_cblock *)&c,
172 *ks1,*ks2,encrypt);
173 RETVAL= &c;
174 }
175OUTPUT:
176RETVAL
177
178void
179des_ofb_encrypt(input,numbits,ks,ivec)
180 unsigned char * input
181 int numbits
182 des_key_schedule * ks
183 des_cblock * ivec
184PPCODE:
185 {
186 SV *s;
187 STRLEN len,l;
188 unsigned char *c;
189
190 len=SvCUR(ST(0));
191 s=sv_newmortal();
192 sv_setpvn(s,"",0);
193 SvGROW(s,len);
194 SvCUR_set(s,len);
195 c=(unsigned char *)SvPV(s,na);
196 des_ofb_encrypt((unsigned char *)input,(unsigned char *)c,
197 numbits,len,*ks,ivec);
198 sv_setpvn(ST(3),(char *)ivec,8);
199 PUSHs(s);
200 }
201
202void
203des_pcbc_encrypt(input,ks,ivec,encrypt)
204 char * input
205 des_key_schedule * ks
206 des_cblock * ivec
207 int encrypt
208PPCODE:
209 {
210 SV *s;
211 STRLEN len,l;
212 char *c;
213
214 l=SvCUR(ST(0));
215 len=((((unsigned long)l)+7)/8)*8;
216 s=sv_newmortal();
217 sv_setpvn(s,"",0);
218 SvGROW(s,len);
219 SvCUR_set(s,len);
220 c=(char *)SvPV(s,na);
221 des_pcbc_encrypt((des_cblock *)input,(des_cblock *)c,
222 l,*ks,ivec,encrypt);
223 sv_setpvn(ST(2),(char *)c[len-8],8);
224 PUSHs(s);
225 }
226
227des_cblock *
228des_random_key()
229CODE:
230 {
231 des_cblock c;
232
233 des_random_key(c);
234 RETVAL=&c;
235 }
236OUTPUT:
237RETVAL
238
239des_cblock *
240des_string_to_key(str)
241char * str
242CODE:
243 {
244 des_cblock c;
245
246 des_string_to_key(str,&c);
247 RETVAL=&c;
248 }
249OUTPUT:
250RETVAL
251
252void
253des_string_to_2keys(str)
254char * str
255PPCODE:
256 {
257 des_cblock c1,c2;
258 SV *s1,*s2;
259
260 des_string_to_2keys(str,&c1,&c2);
261 EXTEND(sp,2);
262 s1=sv_newmortal();
263 sv_setpvn(s1,(char *)c1,8);
264 s2=sv_newmortal();
265 sv_setpvn(s2,(char *)c2,8);
266 PUSHs(s1);
267 PUSHs(s2);
268 }
diff --git a/src/lib/libcrypto/des/FILES0 b/src/lib/libcrypto/des/FILES0
deleted file mode 100644
index 4c7ea2de7a..0000000000
--- a/src/lib/libcrypto/des/FILES0
+++ /dev/null
@@ -1,96 +0,0 @@
1/* General stuff */
2COPYRIGHT - Copyright info.
3MODES.DES - A description of the features of the different modes of DES.
4FILES - This file.
5INSTALL - How to make things compile.
6Imakefile - For use with kerberos.
7README - What this package is.
8VERSION - Which version this is and what was changed.
9KERBEROS - Kerberos version 4 notes.
10Makefile.PL - An old makefile to build with perl5, not current.
11Makefile.ssl - The SSLeay makefile
12Makefile.uni - The normal unix makefile.
13GNUmakefile - The makefile for use with glibc.
14makefile.bc - A Borland C makefile
15times - Some outputs from 'speed' on some machines.
16vms.com - For use when compiling under VMS
17
18/* My SunOS des(1) replacement */
19des.c - des(1) source code.
20des.man - des(1) manual.
21
22/* Testing and timing programs. */
23destest.c - Source for libdes.a test program.
24speed.c - Source for libdes.a timing program.
25rpw.c - Source for libdes.a testing password reading routines.
26
27/* libdes.a source code */
28des_crypt.man - libdes.a manual page.
29des.h - Public libdes.a header file.
30ecb_enc.c - des_ecb_encrypt() source, this contains the basic DES code.
31ecb3_enc.c - des_ecb3_encrypt() source.
32cbc_ckm.c - des_cbc_cksum() source.
33cbc_enc.c - des_cbc_encrypt() source.
34ncbc_enc.c - des_cbc_encrypt() that is 'normal' in that it copies
35 the new iv values back in the passed iv vector.
36ede_enc.c - des_ede3_cbc_encrypt() cbc mode des using triple DES.
37cbc3_enc.c - des_3cbc_encrypt() source, don't use this function.
38cfb_enc.c - des_cfb_encrypt() source.
39cfb64enc.c - des_cfb64_encrypt() cfb in 64 bit mode but setup to be
40 used as a stream cipher.
41cfb64ede.c - des_ede3_cfb64_encrypt() cfb in 64 bit mode but setup to be
42 used as a stream cipher and using triple DES.
43ofb_enc.c - des_cfb_encrypt() source.
44ofb64_enc.c - des_ofb_encrypt() ofb in 64 bit mode but setup to be
45 used as a stream cipher.
46ofb64ede.c - des_ede3_ofb64_encrypt() ofb in 64 bit mode but setup to be
47 used as a stream cipher and using triple DES.
48enc_read.c - des_enc_read() source.
49enc_writ.c - des_enc_write() source.
50pcbc_enc.c - des_pcbc_encrypt() source.
51qud_cksm.c - quad_cksum() source.
52rand_key.c - des_random_key() source.
53read_pwd.c - Source for des_read_password() plus related functions.
54set_key.c - Source for des_set_key().
55str2key.c - Covert a string of any length into a key.
56fcrypt.c - A small, fast version of crypt(3).
57des_locl.h - Internal libdes.a header file.
58podd.h - Odd parity tables - used in des_set_key().
59sk.h - Lookup tables used in des_set_key().
60spr.h - What is left of the S tables - used in ecb_encrypt().
61des_ver.h - header file for the external definition of the
62 version string.
63des.doc - SSLeay documentation for the library.
64
65/* The perl scripts - you can ignore these files they are only
66 * included for the curious */
67des.pl - des in perl anyone? des_set_key and des_ecb_encrypt
68 both done in a perl library.
69testdes.pl - Testing program for des.pl
70doIP - Perl script used to develop IP xor/shift code.
71doPC1 - Perl script used to develop PC1 xor/shift code.
72doPC2 - Generates sk.h.
73PC1 - Output of doPC1 should be the same as output from PC1.
74PC2 - used in development of doPC2.
75shifts.pl - Perl library used by my perl scripts.
76
77/* I started making a perl5 dynamic library for libdes
78 * but did not fully finish, these files are part of that effort. */
79DES.pm
80DES.pod
81DES.xs
82t
83typemap
84
85/* The following are for use with sun RPC implementaions. */
86rpc_des.h
87rpc_enc.c
88
89/* The following are contibuted by Mark Murray <mark@grondar.za>. They
90 * are not normally built into libdes due to machine specific routines
91 * contained in them. They are for use in the most recent incarnation of
92 * export kerberos v 4 (eBones). */
93supp.c
94new_rkey.c
95
96
diff --git a/src/lib/libcrypto/des/INSTALL b/src/lib/libcrypto/des/INSTALL
deleted file mode 100644
index 8aebdfe110..0000000000
--- a/src/lib/libcrypto/des/INSTALL
+++ /dev/null
@@ -1,69 +0,0 @@
1Check the CC and CFLAGS lines in the makefile
2
3If your C library does not support the times(3) function, change the
4#define TIMES to
5#undef TIMES in speed.c
6If it does, check the HZ value for the times(3) function.
7If your system does not define CLK_TCK it will be assumed to
8be 100.0.
9
10If possible use gcc v 2.7.?
11Turn on the maximum optimising (normally '-O3 -fomit-frame-pointer' for gcc)
12In recent times, some system compilers give better performace.
13
14type 'make'
15
16run './destest' to check things are ok.
17run './rpw' to check the tty code for reading passwords works.
18run './speed' to see how fast those optimisations make the library run :-)
19run './des_opts' to determin the best compile time options.
20
21The output from des_opts should be put in the makefile options and des_enc.c
22should be rebuilt. For 64 bit computers, do not use the DES_PTR option.
23For the DEC Alpha, edit des.h and change DES_LONG to 'unsigned int'
24and then you can use the 'DES_PTR' option.
25
26The file options.txt has the options listed for best speed on quite a
27few systems. Look and the options (UNROLL, PTR, RISC2 etc) and then
28turn on the relevant option in the Makefile.
29
30There are some special Makefile targets that make life easier.
31make cc - standard cc build
32make gcc - standard gcc build
33make x86-elf - x86 assembler (elf), linux-elf.
34make x86-out - x86 assembler (a.out), FreeBSD
35make x86-solaris- x86 assembler
36make x86-bsdi - x86 assembler (a.out with primative assembler).
37
38If at all possible use the assembler (for Windows NT/95, use
39asm/win32.obj to link with). The x86 assembler is very very fast.
40
41A make install will by default install
42libdes.a in /usr/local/lib/libdes.a
43des in /usr/local/bin/des
44des_crypt.man in /usr/local/man/man3/des_crypt.3
45des.man in /usr/local/man/man1/des.1
46des.h in /usr/include/des.h
47
48des(1) should be compatible with sunOS's but I have been unable to
49test it.
50
51These routines should compile on MSDOS, most 32bit and 64bit version
52of Unix (BSD and SYSV) and VMS, without modification.
53The only problems should be #include files that are in the wrong places.
54
55These routines can be compiled under MSDOS.
56I have successfully encrypted files using des(1) under MSDOS and then
57decrypted the files on a SparcStation.
58I have been able to compile and test the routines with
59Microsoft C v 5.1 and Turbo C v 2.0.
60The code in this library is in no way optimised for the 16bit
61operation of MSDOS.
62
63When building for glibc, ignore all of the above and just unpack into
64glibc-1.??/des and then gmake as per normal.
65
66As a final note on performace. Certain CPUs like sparcs and Alpha often give
67a %10 speed difference depending on the link order. It is rather anoying
68when one program reports 'x' DES encrypts a second and another reports
69'x*0.9' the speed.
diff --git a/src/lib/libcrypto/des/Imakefile b/src/lib/libcrypto/des/Imakefile
deleted file mode 100644
index 1b9b5629e1..0000000000
--- a/src/lib/libcrypto/des/Imakefile
+++ /dev/null
@@ -1,35 +0,0 @@
1# This Imakefile has not been tested for a while but it should still
2# work when placed in the correct directory in the kerberos v 4 distribution
3
4SRCS= cbc_cksm.c cbc_enc.c ecb_enc.c pcbc_enc.c \
5 qud_cksm.c rand_key.c read_pwd.c set_key.c str2key.c \
6 enc_read.c enc_writ.c fcrypt.c cfb_enc.c \
7 ecb3_enc.c ofb_enc.c ofb64enc.c
8
9OBJS= cbc_cksm.o cbc_enc.o ecb_enc.o pcbc_enc.o \
10 qud_cksm.o rand_key.o read_pwd.o set_key.o str2key.o \
11 enc_read.o enc_writ.o fcrypt.o cfb_enc.o \
12 ecb3_enc.o ofb_enc.o ofb64enc.o
13
14GENERAL=COPYRIGHT FILES INSTALL Imakefile README VERSION makefile times \
15 vms.com KERBEROS
16DES= des.c des.man
17TESTING=destest.c speed.c rpw.c
18LIBDES= des_crypt.man des.h des_locl.h podd.h sk.h spr.h
19
20PERL= des.pl testdes.pl doIP doPC1 doPC2 PC1 PC2 shifts.pl
21
22CODE= $(GENERAL) $(DES) $(TESTING) $(SRCS) $(LIBDES) $(PERL)
23
24SRCDIR=$(SRCTOP)/lib/des
25
26DBG= -O
27INCLUDE= -I$(SRCDIR)
28CC= cc
29
30library_obj_rule()
31
32install_library_target(des,$(OBJS),$(SRCS),)
33
34test(destest,libdes.a,)
35test(rpw,libdes.a,)
diff --git a/src/lib/libcrypto/des/KERBEROS b/src/lib/libcrypto/des/KERBEROS
deleted file mode 100644
index f401b10014..0000000000
--- a/src/lib/libcrypto/des/KERBEROS
+++ /dev/null
@@ -1,41 +0,0 @@
1 [ This is an old file, I don't know if it is true anymore
2 but I will leave the file here - eay 21/11/95 ]
3
4To use this library with Bones (kerberos without DES):
51) Get my modified Bones - eBones. It can be found on
6 gondwana.ecr.mu.oz.au (128.250.1.63) /pub/athena/eBones-p9.tar.Z
7 and
8 nic.funet.fi (128.214.6.100) /pub/unix/security/Kerberos/eBones-p9.tar.Z
9
102) Unpack this library in src/lib/des, makeing sure it is version
11 3.00 or greater (libdes.tar.93-10-07.Z). This versions differences
12 from the version in comp.sources.misc volume 29 patchlevel2.
13 The primarily difference is that it should compile under kerberos :-).
14 It can be found at.
15 ftp.psy.uq.oz.au (130.102.32.1) /pub/DES/libdes.tar.93-10-07.Z
16
17Now do a normal kerberos build and things should work.
18
19One problem I found when I was build on my local sun.
20---
21For sunOS 4.1.1 apply the following patch to src/util/ss/make_commands.c
22
23*** make_commands.c.orig Fri Jul 3 04:18:35 1987
24--- make_commands.c Wed May 20 08:47:42 1992
25***************
26*** 98,104 ****
27 if (!rename(o_file, z_file)) {
28 if (!vfork()) {
29 chdir("/tmp");
30! execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r", "-n",
31 z_file+5, 0);
32 perror("/bin/ld");
33 _exit(1);
34--- 98,104 ----
35 if (!rename(o_file, z_file)) {
36 if (!vfork()) {
37 chdir("/tmp");
38! execl("/bin/ld", "ld", "-o", o_file+5, "-s", "-r",
39 z_file+5, 0);
40 perror("/bin/ld");
41 _exit(1);
diff --git a/src/lib/libcrypto/des/Makefile b/src/lib/libcrypto/des/Makefile
deleted file mode 100644
index ae982265fd..0000000000
--- a/src/lib/libcrypto/des/Makefile
+++ /dev/null
@@ -1,278 +0,0 @@
1#
2# OpenSSL/crypto/des/Makefile
3#
4
5DIR= des
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=-I$(TOP) -I../../include
10CFLAG=-g
11MAKEFILE= Makefile
12AR= ar r
13RANLIB= ranlib
14DES_ENC= des_enc.o fcrypt_b.o
15
16CFLAGS= $(INCLUDES) $(CFLAG)
17ASFLAGS= $(INCLUDES) $(ASFLAG)
18AFLAGS= $(ASFLAGS)
19
20GENERAL=Makefile
21TEST=destest.c
22APPS=
23
24LIB=$(TOP)/libcrypto.a
25LIBSRC= cbc_cksm.c cbc_enc.c cfb64enc.c cfb_enc.c \
26 ecb3_enc.c ecb_enc.c enc_read.c enc_writ.c \
27 fcrypt.c ofb64enc.c ofb_enc.c pcbc_enc.c \
28 qud_cksm.c rand_key.c rpc_enc.c set_key.c \
29 des_enc.c fcrypt_b.c \
30 xcbc_enc.c \
31 str2key.c cfb64ede.c ofb64ede.c ede_cbcm_enc.c des_old.c des_old2.c \
32 read2pwd.c
33
34LIBOBJ= set_key.o ecb_enc.o cbc_enc.o \
35 ecb3_enc.o cfb64enc.o cfb64ede.o cfb_enc.o ofb64ede.o \
36 enc_read.o enc_writ.o ofb64enc.o \
37 ofb_enc.o str2key.o pcbc_enc.o qud_cksm.o rand_key.o \
38 ${DES_ENC} \
39 fcrypt.o xcbc_enc.o rpc_enc.o cbc_cksm.o \
40 ede_cbcm_enc.o des_old.o des_old2.o read2pwd.o
41
42SRC= $(LIBSRC)
43
44EXHEADER= des.h des_old.h
45HEADER= des_locl.h rpc_des.h spr.h des_ver.h $(EXHEADER)
46
47ALL= $(GENERAL) $(SRC) $(HEADER)
48
49top:
50 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
51
52all: lib
53
54lib: $(LIBOBJ)
55 $(AR) $(LIB) $(LIBOBJ)
56 $(RANLIB) $(LIB) || echo Never mind.
57 @touch lib
58
59des: des.o cbc3_enc.o lib
60 $(CC) $(CFLAGS) -o des des.o cbc3_enc.o $(LIB)
61
62des_enc-sparc.S: asm/des_enc.m4
63 m4 -B 8192 asm/des_enc.m4 > des_enc-sparc.S
64
65des-586.s: asm/des-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
66 $(PERL) asm/des-586.pl $(PERLASM_SCHEME) $(CFLAGS) > $@
67crypt586.s: asm/crypt586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
68 $(PERL) asm/crypt586.pl $(PERLASM_SCHEME) $(CFLAGS) > $@
69
70files:
71 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
72
73links:
74 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
75 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
76 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
77
78# We need to use force because 'install' matches 'INSTALL' on case
79# insensitive systems
80FRC.install:
81install: FRC.install
82 @[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
83 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
84 do \
85 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
86 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
87 done;
88
89tags:
90 ctags $(SRC)
91
92tests:
93
94lint:
95 lint -DLINT $(INCLUDES) $(SRC)>fluff
96
97depend:
98 @[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
99 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
100
101dclean:
102 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
103 mv -f Makefile.new $(MAKEFILE)
104
105clean:
106 rm -f *.s *.o *.obj des lib tags core .pure .nfs* *.old *.bak fluff
107
108# DO NOT DELETE THIS LINE -- make depend depends on it.
109
110cbc_cksm.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
111cbc_cksm.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
112cbc_cksm.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
113cbc_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
114cbc_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
115cbc_cksm.o: cbc_cksm.c des_locl.h
116cbc_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
117cbc_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
118cbc_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
119cbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
120cbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
121cbc_enc.o: cbc_enc.c des_locl.h ncbc_enc.c
122cfb64ede.o: ../../e_os.h ../../include/openssl/des.h
123cfb64ede.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
124cfb64ede.o: ../../include/openssl/opensslconf.h
125cfb64ede.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
126cfb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
127cfb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
128cfb64ede.o: cfb64ede.c des_locl.h
129cfb64enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
130cfb64enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
131cfb64enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
132cfb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
133cfb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
134cfb64enc.o: cfb64enc.c des_locl.h
135cfb_enc.o: ../../e_os.h ../../include/openssl/des.h
136cfb_enc.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
137cfb_enc.o: ../../include/openssl/opensslconf.h ../../include/openssl/ossl_typ.h
138cfb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
139cfb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
140cfb_enc.o: ../../include/openssl/ui_compat.h cfb_enc.c des_locl.h
141des_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
142des_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
143des_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
144des_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
145des_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
146des_enc.o: des_enc.c des_locl.h ncbc_enc.c spr.h
147des_old.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
148des_old.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
149des_old.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
150des_old.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
151des_old.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
152des_old.o: ../../include/openssl/ui_compat.h des_old.c
153des_old2.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
154des_old2.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
155des_old2.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
156des_old2.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
157des_old2.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
158des_old2.o: ../../include/openssl/ui_compat.h des_old2.c
159ecb3_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
160ecb3_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
161ecb3_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
162ecb3_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
163ecb3_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
164ecb3_enc.o: des_locl.h ecb3_enc.c
165ecb_enc.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
166ecb_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
167ecb_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
168ecb_enc.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
169ecb_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
170ecb_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
171ecb_enc.o: ../../include/openssl/ui_compat.h des_locl.h des_ver.h ecb_enc.c
172ede_cbcm_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
173ede_cbcm_enc.o: ../../include/openssl/e_os2.h
174ede_cbcm_enc.o: ../../include/openssl/opensslconf.h
175ede_cbcm_enc.o: ../../include/openssl/ossl_typ.h
176ede_cbcm_enc.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
177ede_cbcm_enc.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
178ede_cbcm_enc.o: ../../include/openssl/ui_compat.h des_locl.h ede_cbcm_enc.c
179enc_read.o: ../../e_os.h ../../include/openssl/bio.h
180enc_read.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
181enc_read.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
182enc_read.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
183enc_read.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
184enc_read.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
185enc_read.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
186enc_read.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
187enc_read.o: ../../include/openssl/ui_compat.h ../cryptlib.h des_locl.h
188enc_read.o: enc_read.c
189enc_writ.o: ../../e_os.h ../../include/openssl/bio.h
190enc_writ.o: ../../include/openssl/buffer.h ../../include/openssl/crypto.h
191enc_writ.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
192enc_writ.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
193enc_writ.o: ../../include/openssl/lhash.h ../../include/openssl/opensslconf.h
194enc_writ.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
195enc_writ.o: ../../include/openssl/rand.h ../../include/openssl/safestack.h
196enc_writ.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
197enc_writ.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
198enc_writ.o: ../cryptlib.h des_locl.h enc_writ.c
199fcrypt.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
200fcrypt.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
201fcrypt.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
202fcrypt.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
203fcrypt.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
204fcrypt.o: des_locl.h fcrypt.c
205fcrypt_b.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
206fcrypt_b.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
207fcrypt_b.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
208fcrypt_b.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
209fcrypt_b.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
210fcrypt_b.o: des_locl.h fcrypt_b.c
211ofb64ede.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
212ofb64ede.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
213ofb64ede.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
214ofb64ede.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
215ofb64ede.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
216ofb64ede.o: des_locl.h ofb64ede.c
217ofb64enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
218ofb64enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
219ofb64enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
220ofb64enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
221ofb64enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
222ofb64enc.o: des_locl.h ofb64enc.c
223ofb_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
224ofb_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
225ofb_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
226ofb_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
227ofb_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
228ofb_enc.o: des_locl.h ofb_enc.c
229pcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
230pcbc_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
231pcbc_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
232pcbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
233pcbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
234pcbc_enc.o: des_locl.h pcbc_enc.c
235qud_cksm.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
236qud_cksm.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
237qud_cksm.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
238qud_cksm.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
239qud_cksm.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
240qud_cksm.o: des_locl.h qud_cksm.c
241rand_key.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
242rand_key.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
243rand_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/rand.h
244rand_key.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
245rand_key.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
246rand_key.o: ../../include/openssl/ui_compat.h rand_key.c
247read2pwd.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
248read2pwd.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
249read2pwd.o: ../../include/openssl/opensslconf.h
250read2pwd.o: ../../include/openssl/opensslv.h ../../include/openssl/ossl_typ.h
251read2pwd.o: ../../include/openssl/safestack.h ../../include/openssl/stack.h
252read2pwd.o: ../../include/openssl/symhacks.h ../../include/openssl/ui.h
253read2pwd.o: ../../include/openssl/ui_compat.h read2pwd.c
254rpc_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
255rpc_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
256rpc_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
257rpc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
258rpc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
259rpc_enc.o: des_locl.h des_ver.h rpc_des.h rpc_enc.c
260set_key.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
261set_key.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
262set_key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
263set_key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
264set_key.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
265set_key.o: des_locl.h set_key.c
266str2key.o: ../../include/openssl/crypto.h ../../include/openssl/des.h
267str2key.o: ../../include/openssl/des_old.h ../../include/openssl/e_os2.h
268str2key.o: ../../include/openssl/opensslconf.h ../../include/openssl/opensslv.h
269str2key.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
270str2key.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
271str2key.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
272str2key.o: des_locl.h str2key.c
273xcbc_enc.o: ../../include/openssl/des.h ../../include/openssl/des_old.h
274xcbc_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
275xcbc_enc.o: ../../include/openssl/ossl_typ.h ../../include/openssl/safestack.h
276xcbc_enc.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
277xcbc_enc.o: ../../include/openssl/ui.h ../../include/openssl/ui_compat.h
278xcbc_enc.o: des_locl.h xcbc_enc.c
diff --git a/src/lib/libcrypto/des/README b/src/lib/libcrypto/des/README
deleted file mode 100644
index 621a5ab467..0000000000
--- a/src/lib/libcrypto/des/README
+++ /dev/null
@@ -1,54 +0,0 @@
1
2 libdes, Version 4.01 10-Jan-97
3
4 Copyright (c) 1997, Eric Young
5 All rights reserved.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms specified in COPYRIGHT.
9
10--
11The primary ftp site for this library is
12ftp://ftp.psy.uq.oz.au/pub/Crypto/DES/libdes-x.xx.tar.gz
13libdes is now also shipped with SSLeay. Primary ftp site of
14ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL/SSLeay-x.x.x.tar.gz
15
16The best way to build this library is to build it as part of SSLeay.
17
18This kit builds a DES encryption library and a DES encryption program.
19It supports ecb, cbc, ofb, cfb, triple ecb, triple cbc, triple ofb,
20triple cfb, desx, and MIT's pcbc encryption modes and also has a fast
21implementation of crypt(3).
22It contains support routines to read keys from a terminal,
23generate a random key, generate a key from an arbitrary length string,
24read/write encrypted data from/to a file descriptor.
25
26The implementation was written so as to conform with the manual entry
27for the des_crypt(3) library routines from MIT's project Athena.
28
29destest should be run after compilation to test the des routines.
30rpw should be run after compilation to test the read password routines.
31The des program is a replacement for the sun des command. I believe it
32conforms to the sun version.
33
34The Imakefile is setup for use in the kerberos distribution.
35
36These routines are best compiled with gcc or any other good
37optimising compiler.
38Just turn you optimiser up to the highest settings and run destest
39after the build to make sure everything works.
40
41I believe these routines are close to the fastest and most portable DES
42routines that use small lookup tables (4.5k) that are publicly available.
43The fcrypt routine is faster than ufc's fcrypt (when compiling with
44gcc2 -O2) on the sparc 2 (1410 vs 1270) but is not so good on other machines
45(on a sun3/260 168 vs 336). It is a function of CPU on chip cache size.
46[ 10-Jan-97 and a function of an incorrect speed testing program in
47 ufc which gave much better test figures that reality ].
48
49It is worth noting that on sparc and Alpha CPUs, performance of the DES
50library can vary by upto %10 due to the positioning of files after application
51linkage.
52
53Eric Young (eay@cryptsoft.com)
54
diff --git a/src/lib/libcrypto/des/VERSION b/src/lib/libcrypto/des/VERSION
deleted file mode 100644
index c7d01542bc..0000000000
--- a/src/lib/libcrypto/des/VERSION
+++ /dev/null
@@ -1,412 +0,0 @@
1 Fixed the weak key values which were wrong :-(
2 Defining SIGACTION causes sigaction() to be used instead of signal().
3 SIGUSR1/SIGUSR2 are no longer mapped in the read tty stuff because it
4 can cause problems. This should hopefully not affect normal
5 applications.
6
7Version 4.04
8 Fixed a few tests in destest. Also added x86 assember for
9 des_ncbc_encrypt() which is the standard cbc mode function.
10 This makes a very very large performace difference.
11 Ariel Glenn ariel@columbia.edu reports that the terminal
12 'turn echo off' can return (errno == EINVAL) under solaris
13 when redirection is used. So I now catch that as well as ENOTTY.
14
15
16Version 4.03
17 Left a static out of enc_write.c, which caused to buffer to be
18 continiously malloc()ed. Does anyone use these functions? I keep
19 on feeling like removing them since I only had these in there
20 for a version of kerberised login. Anyway, this was pointed out
21 by Theo de Raadt <deraadt@cvs.openbsd.org>
22 The 'n' bit ofb code was wrong, it was not shifting the shift
23 register. It worked correctly for n == 64. Thanks to
24 Gigi Ankeny <Gigi.Ankeny@Eng.Sun.COM> for pointing this one out.
25
26Version 4.02
27 I was doing 'if (memcmp(weak_keys[i],key,sizeof(key)) == 0)'
28 when checking for weak keys which is wrong :-(, pointed out by
29 Markus F.X.J. Oberhumer <markus.oberhumer@jk.uni-linz.ac.at>.
30
31Version 4.01
32 Even faster inner loop in the DES assembler for x86 and a modification
33 for IP/FP which is faster on x86. Both of these changes are
34 from Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>. His
35 changes make the assembler run %40 faster on a pentium. This is just
36 a case of getting the instruction sequence 'just right'.
37 All credit to 'Svend' :-)
38 Quite a few special x86 'make' targets.
39 A libdes-l (lite) distribution.
40
41Version 4.00
42 After a bit of a pause, I'll up the major version number since this
43 is mostly a performace release. I've added x86 assembler and
44 added more options for performance. A %28 speedup for gcc
45 on a pentium and the assembler is a %50 speedup.
46 MIPS CPU's, sparc and Alpha are the main CPU's with speedups.
47 Run des_opts to work out which options should be used.
48 DES_RISC1/DES_RISC2 use alternative inner loops which use
49 more registers but should give speedups on any CPU that does
50 dual issue (pentium). DES_UNROLL unrolls the inner loop,
51 which costs in code size.
52
53Version 3.26
54 I've finally removed one of the shifts in D_ENCRYPT. This
55 meant I've changed the des_SPtrans table (spr.h), the set_key()
56 function and some things in des_enc.c. This has definitly
57 made things faster :-). I've known about this one for some
58 time but I've been too lazy to follow it up :-).
59 Noticed that in the D_ENCRYPT() macro, we can just do L^=(..)^(..)^..
60 instead of L^=((..)|(..)|(..).. This should save a register at
61 least.
62 Assember for x86. The file to replace is des_enc.c, which is replaced
63 by one of the assembler files found in asm. Look at des/asm/readme
64 for more info.
65
66 /* Modification to fcrypt so it can be compiled to support
67 HPUX 10.x's long password format, define -DLONGCRYPT to use this.
68 Thanks to Jens Kupferschmidt <bt1cu@hpboot.rz.uni-leipzig.de>. */
69
70 SIGWINCH case put in des_read_passwd() so the function does not
71 'exit' if this function is recieved.
72
73Version 3.25 17/07/96
74 Modified read_pwd.c so that stdin can be read if not a tty.
75 Thanks to Jeff Barber <jeffb@issl.atl.hp.com> for the patches.
76 des_init_random_number_generator() shortened due to VMS linker
77 limits.
78 Added RSA's DESX cbc mode. It is a form of cbc encryption, with 2
79 8 byte quantites xored before and after encryption.
80 des_xcbc_encryption() - the name is funny to preserve the des_
81 prefix on all functions.
82
83Version 3.24 20/04/96
84 The DES_PTR macro option checked and used by SSLeay configuration
85
86Version 3.23 11/04/96
87 Added DES_LONG. If defined to 'unsigned int' on the DEC Alpha,
88 it gives a %20 speedup :-)
89 Fixed the problem with des.pl under perl5. The patches were
90 sent by Ed Kubaitis (ejk@uiuc.edu).
91 if fcrypt.c, changed values to handle illegal salt values the way
92 normal crypt() implementations do. Some programs apparently use
93 them :-(. The patch was sent by Bjorn Gronvall <bg@sics.se>
94
95Version 3.22 29/11/95
96 Bug in des(1), an error with the uuencoding stuff when the
97 'data' is small, thanks to Geoff Keating <keagchon@mehta.anu.edu.au>
98 for the patch.
99
100Version 3.21 22/11/95
101 After some emailing back and forth with
102 Colin Plumb <colin@nyx10.cs.du.edu>, I've tweaked a few things
103 and in a future version I will probably put in some of the
104 optimisation he suggested for use with the DES_USE_PTR option.
105 Extra routines from Mark Murray <mark@grondar.za> for use in
106 freeBSD. They mostly involve random number generation for use
107 with kerberos. They involve evil machine specific system calls
108 etc so I would normally suggest pushing this stuff into the
109 application and/or using RAND_seed()/RAND_bytes() if you are
110 using this DES library as part of SSLeay.
111 Redone the read_pw() function so that it is cleaner and
112 supports termios, thanks to Sameer Parekh <sameer@c2.org>
113 for the initial patches for this.
114 Renamed 3ecb_encrypt() to ecb3_encrypt(). This has been
115 done just to make things more consistent.
116 I have also now added triple DES versions of cfb and ofb.
117
118Version 3.20
119 Damn, Damn, Damn, as pointed out by Mike_Spreitzer.PARC@xerox.com,
120 my des_random_seed() function was only copying 4 bytes of the
121 passed seed into the init structure. It is now fixed to copy 8.
122 My own suggestion is to used something like MD5 :-)
123
124Version 3.19
125 While looking at my code one day, I though, why do I keep on
126 calling des_encrypt(in,out,ks,enc) when every function that
127 calls it has in and out the same. So I dropped the 'out'
128 parameter, people should not be using this function.
129
130Version 3.18 30/08/95
131 Fixed a few bit with the distribution and the filenames.
132 3.17 had been munged via a move to DOS and back again.
133 NO CODE CHANGES
134
135Version 3.17 14/07/95
136 Fixed ede3 cbc which I had broken in 3.16. I have also
137 removed some unneeded variables in 7-8 of the routines.
138
139Version 3.16 26/06/95
140 Added des_encrypt2() which does not use IP/FP, used by triple
141 des routines. Tweaked things a bit elsewhere. %13 speedup on
142 sparc and %6 on a R4400 for ede3 cbc mode.
143
144Version 3.15 06/06/95
145 Added des_ncbc_encrypt(), it is des_cbc mode except that it is
146 'normal' and copies the new iv value back over the top of the
147 passed parameter.
148 CHANGED des_ede3_cbc_encrypt() so that it too now overwrites
149 the iv. THIS WILL BREAK EXISTING CODE, but since this function
150 only new, I feel I can change it, not so with des_cbc_encrypt :-(.
151 I need to update the documentation.
152
153Version 3.14 31/05/95
154 New release upon the world, as part of my SSL implementation.
155 New copyright and usage stuff. Basically free for all to use
156 as long as you say it came from me :-)
157
158Version 3.13 31/05/95
159 A fix in speed.c, if HZ is not defined, I set it to 100.0
160 which is reasonable for most unixes except SunOS 4.x.
161 I now have a #ifdef sun but timing for SunOS 4.x looked very
162 good :-(. At my last job where I used SunOS 4.x, it was
163 defined to be 60.0 (look at the old INSTALL documentation), at
164 the last release had it changed to 100.0 since I now work with
165 Solaris2 and SVR4 boxes.
166 Thanks to Rory Chisholm <rchishol@math.ethz.ch> for pointing this
167 one out.
168
169Version 3.12 08/05/95
170 As pointed out by The Crypt Keeper <tck@bend.UCSD.EDU>,
171 my D_ENCRYPT macro in crypt() had an un-necessary variable.
172 It has been removed.
173
174Version 3.11 03/05/95
175 Added des_ede3_cbc_encrypt() which is cbc mode des with 3 keys
176 and one iv. It is a standard and I needed it for my SSL code.
177 It makes more sense to use this for triple DES than
178 3cbc_encrypt(). I have also added (or should I say tested :-)
179 cfb64_encrypt() which is cfb64 but it will encrypt a partial
180 number of bytes - 3 bytes in 3 bytes out. Again this is for
181 my SSL library, as a form of encryption to use with SSL
182 telnet.
183
184Version 3.10 22/03/95
185 Fixed a bug in 3cbc_encrypt() :-(. When making repeated calls
186 to cbc3_encrypt, the 2 iv values that were being returned to
187 be used in the next call were reversed :-(.
188 Many thanks to Bill Wade <wade@Stoner.COM> for pointing out
189 this error.
190
191Version 3.09 01/02/95
192 Fixed des_random_key to far more random, it was rather feeble
193 with regards to picking the initial seed. The problem was
194 pointed out by Olaf Kirch <okir@monad.swb.de>.
195
196Version 3.08 14/12/94
197 Added Makefile.PL so libdes can be built into perl5.
198 Changed des_locl.h so RAND is always defined.
199
200Version 3.07 05/12/94
201 Added GNUmake and stuff so the library can be build with
202 glibc.
203
204Version 3.06 30/08/94
205 Added rpc_enc.c which contains _des_crypt. This is for use in
206 secure_rpc v 4.0
207 Finally fixed the cfb_enc problems.
208 Fixed a few parameter parsing bugs in des (-3 and -b), thanks
209 to Rob McMillan <R.McMillan@its.gu.edu.au>
210
211Version 3.05 21/04/94
212 for unsigned long l; gcc does not produce ((l>>34) == 0)
213 This causes bugs in cfb_enc.
214 Thanks to Hadmut Danisch <danisch@ira.uka.de>
215
216Version 3.04 20/04/94
217 Added a version number to des.c and libdes.a
218
219Version 3.03 12/01/94
220 Fixed a bug in non zero iv in 3cbc_enc.
221
222Version 3.02 29/10/93
223 I now work in a place where there are 6+ architectures and 14+
224 OS versions :-).
225 Fixed TERMIO definition so the most sys V boxes will work :-)
226
227Release upon comp.sources.misc
228Version 3.01 08/10/93
229 Added des_3cbc_encrypt()
230
231Version 3.00 07/10/93
232 Fixed up documentation.
233 quad_cksum definitely compatible with MIT's now.
234
235Version 2.30 24/08/93
236 Triple DES now defaults to triple cbc but can do triple ecb
237 with the -b flag.
238 Fixed some MSDOS uuen/uudecoding problems, thanks to
239 Added prototypes.
240
241Version 2.22 29/06/93
242 Fixed a bug in des_is_weak_key() which stopped it working :-(
243 thanks to engineering@MorningStar.Com.
244
245Version 2.21 03/06/93
246 des(1) with no arguments gives quite a bit of help.
247 Added -c (generate ckecksum) flag to des(1).
248 Added -3 (triple DES) flag to des(1).
249 Added cfb and ofb routines to the library.
250
251Version 2.20 11/03/93
252 Added -u (uuencode) flag to des(1).
253 I have been playing with byte order in quad_cksum to make it
254 compatible with MIT's version. All I can say is avid this
255 function if possible since MIT's output is endian dependent.
256
257Version 2.12 14/10/92
258 Added MSDOS specific macro in ecb_encrypt which gives a %70
259 speed up when the code is compiled with turbo C.
260
261Version 2.11 12/10/92
262 Speedup in set_key (recoding of PC-1)
263 I now do it in 47 simple operations, down from 60.
264 Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov)
265 for motivating me to look for a faster system :-)
266 The speedup is probably less that 1% but it is still 13
267 instructions less :-).
268
269Version 2.10 06/10/92
270 The code now works on the 64bit ETA10 and CRAY without modifications or
271 #defines. I believe the code should work on any machine that
272 defines long, int or short to be 8 bytes long.
273 Thanks to Shabbir J. Safdar (shabby@mentor.cc.purdue.edu)
274 for helping me fix the code to run on 64bit machines (he had
275 access to an ETA10).
276 Thanks also to John Fletcher <john_fletcher@lccmail.ocf.llnl.gov>
277 for testing the routines on a CRAY.
278 read_password.c has been renamed to read_passwd.c
279 string_to_key.c has been renamed to string2key.c
280
281Version 2.00 14/09/92
282 Made mods so that the library should work on 64bit CPU's.
283 Removed all my uchar and ulong defs. To many different
284 versions of unix define them in their header files in too many
285 different combinations :-)
286 IRIX - Sillicon Graphics mods (mostly in read_password.c).
287 Thanks to Andrew Daviel (advax@erich.triumf.ca)
288
289Version 1.99 26/08/92
290 Fixed a bug or 2 in enc_read.c
291 Fixed a bug in enc_write.c
292 Fixed a pseudo bug in fcrypt.c (very obscure).
293
294Version 1.98 31/07/92
295 Support for the ETA10. This is a strange machine that defines
296 longs and ints as 8 bytes and shorts as 4 bytes.
297 Since I do evil things with long * that assume that they are 4
298 bytes. Look in the Makefile for the option to compile for
299 this machine. quad_cksum appears to have problems but I
300 will don't have the time to fix it right now, and this is not
301 a function that uses DES and so will not effect the main uses
302 of the library.
303
304Version 1.97 20/05/92 eay
305 Fixed the Imakefile and made some changes to des.h to fix some
306 problems when building this package with Kerberos v 4.
307
308Version 1.96 18/05/92 eay
309 Fixed a small bug in string_to_key() where problems could
310 occur if des_check_key was set to true and the string
311 generated a weak key.
312
313Patch2 posted to comp.sources.misc
314Version 1.95 13/05/92 eay
315 Added an alternative version of the D_ENCRYPT macro in
316 ecb_encrypt and fcrypt. Depending on the compiler, one version or the
317 other will be faster. This was inspired by
318 Dana How <how@isl.stanford.edu>, and her pointers about doing the
319 *(ulong *)((uchar *)ptr+(value&0xfc))
320 vs
321 ptr[value&0x3f]
322 to stop the C compiler doing a <<2 to convert the long array index.
323
324Version 1.94 05/05/92 eay
325 Fixed an incompatibility between my string_to_key and the MIT
326 version. When the key is longer than 8 chars, I was wrapping
327 with a different method. To use the old version, define
328 OLD_STR_TO_KEY in the makefile. Thanks to
329 viktor@newsu.shearson.com (Viktor Dukhovni).
330
331Version 1.93 28/04/92 eay
332 Fixed the VMS mods so that echo is now turned off in
333 read_password. Thanks again to brennan@coco.cchs.su.oz.AU.
334 MSDOS support added. The routines can be compiled with
335 Turbo C (v2.0) and MSC (v5.1). Make sure MSDOS is defined.
336
337Patch1 posted to comp.sources.misc
338Version 1.92 13/04/92 eay
339 Changed D_ENCRYPT so that the rotation of R occurs outside of
340 the loop. This required rotating all the longs in sp.h (now
341 called spr.h). Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
342 speed.c has been changed so it will work without SIGALRM. If
343 times(3) is not present it will try to use ftime() instead.
344
345Version 1.91 08/04/92 eay
346 Added -E/-D options to des(1) so it can use string_to_key.
347 Added SVR4 mods suggested by witr@rwwa.COM
348 Added VMS mods suggested by brennan@coco.cchs.su.oz.AU. If
349 anyone knows how to turn of tty echo in VMS please tell me or
350 implement it yourself :-).
351 Changed FILE *IN/*OUT to *DES_IN/*DES_OUT since it appears VMS
352 does not like IN/OUT being used.
353
354Libdes posted to comp.sources.misc
355Version 1.9 24/03/92 eay
356 Now contains a fast small crypt replacement.
357 Added des(1) command.
358 Added des_rw_mode so people can use cbc encryption with
359 enc_read and enc_write.
360
361Version 1.8 15/10/91 eay
362 Bug in cbc_cksum.
363 Many thanks to Keith Reynolds (keithr@sco.COM) for pointing this
364 one out.
365
366Version 1.7 24/09/91 eay
367 Fixed set_key :-)
368 set_key is 4 times faster and takes less space.
369 There are a few minor changes that could be made.
370
371Version 1.6 19/09/1991 eay
372 Finally go IP and FP finished.
373 Now I need to fix set_key.
374 This version is quite a bit faster that 1.51
375
376Version 1.52 15/06/1991 eay
377 20% speedup in ecb_encrypt by changing the E bit selection
378 to use 2 32bit words. This also required modification of the
379 sp table. There is still a way to speedup the IP and IP-1
380 (hints from outer@sq.com) still working on this one :-(.
381
382Version 1.51 07/06/1991 eay
383 Faster des_encrypt by loop unrolling
384 Fixed bug in quad_cksum.c (thanks to hughes@logos.ucs.indiana.edu)
385
386Version 1.50 28/05/1991 eay
387 Optimised the code a bit more for the sparc. I have improved the
388 speed of the inner des_encrypt by speeding up the initial and
389 final permutations.
390
391Version 1.40 23/10/1990 eay
392 Fixed des_random_key, it did not produce a random key :-(
393
394Version 1.30 2/10/1990 eay
395 Have made des_quad_cksum the same as MIT's, the full package
396 should be compatible with MIT's
397 Have tested on a DECstation 3100
398 Still need to fix des_set_key (make it faster).
399 Does des_cbc_encrypts at 70.5k/sec on a 3100.
400
401Version 1.20 18/09/1990 eay
402 Fixed byte order dependencies.
403 Fixed (I hope) all the word alignment problems.
404 Speedup in des_ecb_encrypt.
405
406Version 1.10 11/09/1990 eay
407 Added des_enc_read and des_enc_write.
408 Still need to fix des_quad_cksum.
409 Still need to document des_enc_read and des_enc_write.
410
411Version 1.00 27/08/1990 eay
412
diff --git a/src/lib/libcrypto/des/asm/crypt586.pl b/src/lib/libcrypto/des/asm/crypt586.pl
deleted file mode 100644
index e36f7d44bd..0000000000
--- a/src/lib/libcrypto/des/asm/crypt586.pl
+++ /dev/null
@@ -1,209 +0,0 @@
1#!/usr/local/bin/perl
2#
3# The inner loop instruction sequence and the IP/FP modifications are from
4# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
5# I've added the stuff needed for crypt() but I've not worried about making
6# things perfect.
7#
8
9$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
10push(@INC,"${dir}","${dir}../../perlasm");
11require "x86asm.pl";
12
13&asm_init($ARGV[0],"crypt586.pl");
14
15$L="edi";
16$R="esi";
17
18&external_label("DES_SPtrans");
19&fcrypt_body("fcrypt_body");
20&asm_finish();
21
22sub fcrypt_body
23 {
24 local($name,$do_ip)=@_;
25
26 &function_begin($name);
27
28 &comment("");
29 &comment("Load the 2 words");
30 $trans="ebp";
31
32 &xor( $L, $L);
33 &xor( $R, $R);
34
35 # PIC-ification:-)
36 &picmeup("edx","DES_SPtrans");
37 #if ($cpp) { &picmeup("edx","DES_SPtrans"); }
38 #else { &lea("edx",&DWP("DES_SPtrans")); }
39 &push("edx"); # becomes &swtmp(1)
40 #
41 &mov($trans,&wparam(1)); # reloaded with DES_SPtrans in D_ENCRYPT
42
43 &push(&DWC(25)); # add a variable
44
45 &set_label("start");
46 for ($i=0; $i<16; $i+=2)
47 {
48 &comment("");
49 &comment("Round $i");
50 &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx");
51
52 &comment("");
53 &comment("Round ".sprintf("%d",$i+1));
54 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx");
55 }
56 &mov("ebx", &swtmp(0));
57 &mov("eax", $L);
58 &dec("ebx");
59 &mov($L, $R);
60 &mov($R, "eax");
61 &mov(&swtmp(0), "ebx");
62 &jnz(&label("start"));
63
64 &comment("");
65 &comment("FP");
66 &mov("edx",&wparam(0));
67
68 &FP_new($R,$L,"eax",3);
69 &mov(&DWP(0,"edx","",0),"eax");
70 &mov(&DWP(4,"edx","",0),$L);
71
72 &add("esp",8); # remove variables
73
74 &function_end($name);
75 }
76
77sub D_ENCRYPT
78 {
79 local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t)=@_;
80
81 &mov( $u, &wparam(2)); # 2
82 &mov( $t, $R);
83 &shr( $t, 16); # 1
84 &mov( $tmp2, &wparam(3)); # 2
85 &xor( $t, $R); # 1
86
87 &and( $u, $t); # 2
88 &and( $t, $tmp2); # 2
89
90 &mov( $tmp1, $u);
91 &shl( $tmp1, 16); # 1
92 &mov( $tmp2, $t);
93 &shl( $tmp2, 16); # 1
94 &xor( $u, $tmp1); # 2
95 &xor( $t, $tmp2); # 2
96 &mov( $tmp1, &DWP(&n2a($S*4),$trans,"",0)); # 2
97 &xor( $u, $tmp1);
98 &mov( $tmp2, &DWP(&n2a(($S+1)*4),$trans,"",0)); # 2
99 &xor( $u, $R);
100 &xor( $t, $R);
101 &xor( $t, $tmp2);
102
103 &and( $u, "0xfcfcfcfc" ); # 2
104 &xor( $tmp1, $tmp1); # 1
105 &and( $t, "0xcfcfcfcf" ); # 2
106 &xor( $tmp2, $tmp2);
107 &movb( &LB($tmp1), &LB($u) );
108 &movb( &LB($tmp2), &HB($u) );
109 &rotr( $t, 4 );
110 &mov( $trans, &swtmp(1));
111 &xor( $L, &DWP(" ",$trans,$tmp1,0));
112 &movb( &LB($tmp1), &LB($t) );
113 &xor( $L, &DWP("0x200",$trans,$tmp2,0));
114 &movb( &LB($tmp2), &HB($t) );
115 &shr( $u, 16);
116 &xor( $L, &DWP("0x100",$trans,$tmp1,0));
117 &movb( &LB($tmp1), &HB($u) );
118 &shr( $t, 16);
119 &xor( $L, &DWP("0x300",$trans,$tmp2,0));
120 &movb( &LB($tmp2), &HB($t) );
121 &and( $u, "0xff" );
122 &and( $t, "0xff" );
123 &mov( $tmp1, &DWP("0x600",$trans,$tmp1,0));
124 &xor( $L, $tmp1);
125 &mov( $tmp1, &DWP("0x700",$trans,$tmp2,0));
126 &xor( $L, $tmp1);
127 &mov( $tmp1, &DWP("0x400",$trans,$u,0));
128 &xor( $L, $tmp1);
129 &mov( $tmp1, &DWP("0x500",$trans,$t,0));
130 &xor( $L, $tmp1);
131 &mov( $trans, &wparam(1));
132 }
133
134sub n2a
135 {
136 sprintf("%d",$_[0]);
137 }
138
139# now has a side affect of rotating $a by $shift
140sub R_PERM_OP
141 {
142 local($a,$b,$tt,$shift,$mask,$last)=@_;
143
144 &rotl( $a, $shift ) if ($shift != 0);
145 &mov( $tt, $a );
146 &xor( $a, $b );
147 &and( $a, $mask );
148 if ($notlast eq $b)
149 {
150 &xor( $b, $a );
151 &xor( $tt, $a );
152 }
153 else
154 {
155 &xor( $tt, $a );
156 &xor( $b, $a );
157 }
158 &comment("");
159 }
160
161sub IP_new
162 {
163 local($l,$r,$tt,$lr)=@_;
164
165 &R_PERM_OP($l,$r,$tt, 4,"0xf0f0f0f0",$l);
166 &R_PERM_OP($r,$tt,$l,20,"0xfff0000f",$l);
167 &R_PERM_OP($l,$tt,$r,14,"0x33333333",$r);
168 &R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r);
169 &R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r);
170
171 if ($lr != 3)
172 {
173 if (($lr-3) < 0)
174 { &rotr($tt, 3-$lr); }
175 else { &rotl($tt, $lr-3); }
176 }
177 if ($lr != 2)
178 {
179 if (($lr-2) < 0)
180 { &rotr($r, 2-$lr); }
181 else { &rotl($r, $lr-2); }
182 }
183 }
184
185sub FP_new
186 {
187 local($l,$r,$tt,$lr)=@_;
188
189 if ($lr != 2)
190 {
191 if (($lr-2) < 0)
192 { &rotl($r, 2-$lr); }
193 else { &rotr($r, $lr-2); }
194 }
195 if ($lr != 3)
196 {
197 if (($lr-3) < 0)
198 { &rotl($l, 3-$lr); }
199 else { &rotr($l, $lr-3); }
200 }
201
202 &R_PERM_OP($l,$r,$tt, 0,"0xaaaaaaaa",$r);
203 &R_PERM_OP($tt,$r,$l,23,"0x03fc03fc",$r);
204 &R_PERM_OP($l,$r,$tt,10,"0x33333333",$l);
205 &R_PERM_OP($r,$tt,$l,18,"0xfff0000f",$l);
206 &R_PERM_OP($l,$tt,$r,12,"0xf0f0f0f0",$r);
207 &rotr($tt , 4);
208 }
209
diff --git a/src/lib/libcrypto/des/asm/des-586.pl b/src/lib/libcrypto/des/asm/des-586.pl
deleted file mode 100644
index 5b5f39cebd..0000000000
--- a/src/lib/libcrypto/des/asm/des-586.pl
+++ /dev/null
@@ -1,453 +0,0 @@
1#!/usr/local/bin/perl
2#
3# The inner loop instruction sequence and the IP/FP modifications are from
4# Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk>
5#
6
7$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
8push(@INC,"${dir}","${dir}../../perlasm");
9require "x86asm.pl";
10require "cbc.pl";
11require "desboth.pl";
12
13# base code is in microsft
14# op dest, source
15# format.
16#
17
18&asm_init($ARGV[0],"des-586.pl");
19
20$L="edi";
21$R="esi";
22$trans="ebp";
23$small_footprint=1 if (grep(/\-DOPENSSL_SMALL_FOOTPRINT/,@ARGV));
24# one can discuss setting this variable to 1 unconditionally, as
25# the folded loop is only 3% slower than unrolled, but >7 times smaller
26
27&public_label("DES_SPtrans");
28
29&DES_encrypt_internal();
30&DES_decrypt_internal();
31&DES_encrypt("DES_encrypt1",1);
32&DES_encrypt("DES_encrypt2",0);
33&DES_encrypt3("DES_encrypt3",1);
34&DES_encrypt3("DES_decrypt3",0);
35&cbc("DES_ncbc_encrypt","DES_encrypt1","DES_encrypt1",0,4,5,3,5,-1);
36&cbc("DES_ede3_cbc_encrypt","DES_encrypt3","DES_decrypt3",0,6,7,3,4,5);
37&DES_SPtrans();
38
39&asm_finish();
40
41sub DES_encrypt_internal()
42 {
43 &function_begin_B("_x86_DES_encrypt");
44
45 if ($small_footprint)
46 {
47 &lea("edx",&DWP(128,"ecx"));
48 &push("edx");
49 &push("ecx");
50 &set_label("eloop");
51 &D_ENCRYPT(0,$L,$R,0,$trans,"eax","ebx","ecx","edx",&swtmp(0));
52 &comment("");
53 &D_ENCRYPT(1,$R,$L,2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
54 &comment("");
55 &add("ecx",16);
56 &cmp("ecx",&swtmp(1));
57 &mov(&swtmp(0),"ecx");
58 &jb(&label("eloop"));
59 &add("esp",8);
60 }
61 else
62 {
63 &push("ecx");
64 for ($i=0; $i<16; $i+=2)
65 {
66 &comment("Round $i");
67 &D_ENCRYPT($i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
68 &comment("Round ".sprintf("%d",$i+1));
69 &D_ENCRYPT($i+1,$R,$L,($i+1)*2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
70 }
71 &add("esp",4);
72 }
73 &ret();
74
75 &function_end_B("_x86_DES_encrypt");
76 }
77
78sub DES_decrypt_internal()
79 {
80 &function_begin_B("_x86_DES_decrypt");
81
82 if ($small_footprint)
83 {
84 &push("ecx");
85 &lea("ecx",&DWP(128,"ecx"));
86 &push("ecx");
87 &set_label("dloop");
88 &D_ENCRYPT(0,$L,$R,-2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
89 &comment("");
90 &D_ENCRYPT(1,$R,$L,-4,$trans,"eax","ebx","ecx","edx",&swtmp(0));
91 &comment("");
92 &sub("ecx",16);
93 &cmp("ecx",&swtmp(1));
94 &mov(&swtmp(0),"ecx");
95 &ja(&label("dloop"));
96 &add("esp",8);
97 }
98 else
99 {
100 &push("ecx");
101 for ($i=15; $i>0; $i-=2)
102 {
103 &comment("Round $i");
104 &D_ENCRYPT(15-$i,$L,$R,$i*2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
105 &comment("Round ".sprintf("%d",$i-1));
106 &D_ENCRYPT(15-$i+1,$R,$L,($i-1)*2,$trans,"eax","ebx","ecx","edx",&swtmp(0));
107 }
108 &add("esp",4);
109 }
110 &ret();
111
112 &function_end_B("_x86_DES_decrypt");
113 }
114
115sub DES_encrypt
116 {
117 local($name,$do_ip)=@_;
118
119 &function_begin_B($name);
120
121 &push("esi");
122 &push("edi");
123
124 &comment("");
125 &comment("Load the 2 words");
126
127 if ($do_ip)
128 {
129 &mov($R,&wparam(0));
130 &xor( "ecx", "ecx" );
131
132 &push("ebx");
133 &push("ebp");
134
135 &mov("eax",&DWP(0,$R,"",0));
136 &mov("ebx",&wparam(2)); # get encrypt flag
137 &mov($L,&DWP(4,$R,"",0));
138 &comment("");
139 &comment("IP");
140 &IP_new("eax",$L,$R,3);
141 }
142 else
143 {
144 &mov("eax",&wparam(0));
145 &xor( "ecx", "ecx" );
146
147 &push("ebx");
148 &push("ebp");
149
150 &mov($R,&DWP(0,"eax","",0));
151 &mov("ebx",&wparam(2)); # get encrypt flag
152 &rotl($R,3);
153 &mov($L,&DWP(4,"eax","",0));
154 &rotl($L,3);
155 }
156
157 # PIC-ification:-)
158 &call (&label("pic_point"));
159 &set_label("pic_point");
160 &blindpop($trans);
161 &lea ($trans,&DWP(&label("DES_SPtrans")."-".&label("pic_point"),$trans));
162
163 &mov( "ecx", &wparam(1) );
164
165 &cmp("ebx","0");
166 &je(&label("decrypt"));
167 &call("_x86_DES_encrypt");
168 &jmp(&label("done"));
169 &set_label("decrypt");
170 &call("_x86_DES_decrypt");
171 &set_label("done");
172
173 if ($do_ip)
174 {
175 &comment("");
176 &comment("FP");
177 &mov("edx",&wparam(0));
178 &FP_new($L,$R,"eax",3);
179
180 &mov(&DWP(0,"edx","",0),"eax");
181 &mov(&DWP(4,"edx","",0),$R);
182 }
183 else
184 {
185 &comment("");
186 &comment("Fixup");
187 &rotr($L,3); # r
188 &mov("eax",&wparam(0));
189 &rotr($R,3); # l
190 &mov(&DWP(0,"eax","",0),$L);
191 &mov(&DWP(4,"eax","",0),$R);
192 }
193
194 &pop("ebp");
195 &pop("ebx");
196 &pop("edi");
197 &pop("esi");
198 &ret();
199
200 &function_end_B($name);
201 }
202
203sub D_ENCRYPT
204 {
205 local($r,$L,$R,$S,$trans,$u,$tmp1,$tmp2,$t,$wp1)=@_;
206
207 &mov( $u, &DWP(&n2a($S*4),$tmp2,"",0));
208 &xor( $tmp1, $tmp1);
209 &mov( $t, &DWP(&n2a(($S+1)*4),$tmp2,"",0));
210 &xor( $u, $R);
211 &xor( $tmp2, $tmp2);
212 &xor( $t, $R);
213 &and( $u, "0xfcfcfcfc" );
214 &and( $t, "0xcfcfcfcf" );
215 &movb( &LB($tmp1), &LB($u) );
216 &movb( &LB($tmp2), &HB($u) );
217 &rotr( $t, 4 );
218 &xor( $L, &DWP(" ",$trans,$tmp1,0));
219 &movb( &LB($tmp1), &LB($t) );
220 &xor( $L, &DWP("0x200",$trans,$tmp2,0));
221 &movb( &LB($tmp2), &HB($t) );
222 &shr( $u, 16);
223 &xor( $L, &DWP("0x100",$trans,$tmp1,0));
224 &movb( &LB($tmp1), &HB($u) );
225 &shr( $t, 16);
226 &xor( $L, &DWP("0x300",$trans,$tmp2,0));
227 &movb( &LB($tmp2), &HB($t) );
228 &and( $u, "0xff" );
229 &and( $t, "0xff" );
230 &xor( $L, &DWP("0x600",$trans,$tmp1,0));
231 &xor( $L, &DWP("0x700",$trans,$tmp2,0));
232 &mov( $tmp2, $wp1 );
233 &xor( $L, &DWP("0x400",$trans,$u,0));
234 &xor( $L, &DWP("0x500",$trans,$t,0));
235 }
236
237sub n2a
238 {
239 sprintf("%d",$_[0]);
240 }
241
242# now has a side affect of rotating $a by $shift
243sub R_PERM_OP
244 {
245 local($a,$b,$tt,$shift,$mask,$last)=@_;
246
247 &rotl( $a, $shift ) if ($shift != 0);
248 &mov( $tt, $a );
249 &xor( $a, $b );
250 &and( $a, $mask );
251 # This can never succeed, and besides it is difficult to see what the
252 # idea was - Ben 13 Feb 99
253 if (!$last eq $b)
254 {
255 &xor( $b, $a );
256 &xor( $tt, $a );
257 }
258 else
259 {
260 &xor( $tt, $a );
261 &xor( $b, $a );
262 }
263 &comment("");
264 }
265
266sub IP_new
267 {
268 local($l,$r,$tt,$lr)=@_;
269
270 &R_PERM_OP($l,$r,$tt, 4,"0xf0f0f0f0",$l);
271 &R_PERM_OP($r,$tt,$l,20,"0xfff0000f",$l);
272 &R_PERM_OP($l,$tt,$r,14,"0x33333333",$r);
273 &R_PERM_OP($tt,$r,$l,22,"0x03fc03fc",$r);
274 &R_PERM_OP($l,$r,$tt, 9,"0xaaaaaaaa",$r);
275
276 if ($lr != 3)
277 {
278 if (($lr-3) < 0)
279 { &rotr($tt, 3-$lr); }
280 else { &rotl($tt, $lr-3); }
281 }
282 if ($lr != 2)
283 {
284 if (($lr-2) < 0)
285 { &rotr($r, 2-$lr); }
286 else { &rotl($r, $lr-2); }
287 }
288 }
289
290sub FP_new
291 {
292 local($l,$r,$tt,$lr)=@_;
293
294 if ($lr != 2)
295 {
296 if (($lr-2) < 0)
297 { &rotl($r, 2-$lr); }
298 else { &rotr($r, $lr-2); }
299 }
300 if ($lr != 3)
301 {
302 if (($lr-3) < 0)
303 { &rotl($l, 3-$lr); }
304 else { &rotr($l, $lr-3); }
305 }
306
307 &R_PERM_OP($l,$r,$tt, 0,"0xaaaaaaaa",$r);
308 &R_PERM_OP($tt,$r,$l,23,"0x03fc03fc",$r);
309 &R_PERM_OP($l,$r,$tt,10,"0x33333333",$l);
310 &R_PERM_OP($r,$tt,$l,18,"0xfff0000f",$l);
311 &R_PERM_OP($l,$tt,$r,12,"0xf0f0f0f0",$r);
312 &rotr($tt , 4);
313 }
314
315sub DES_SPtrans
316 {
317 &set_label("DES_SPtrans",64);
318 &data_word(0x02080800, 0x00080000, 0x02000002, 0x02080802);
319 &data_word(0x02000000, 0x00080802, 0x00080002, 0x02000002);
320 &data_word(0x00080802, 0x02080800, 0x02080000, 0x00000802);
321 &data_word(0x02000802, 0x02000000, 0x00000000, 0x00080002);
322 &data_word(0x00080000, 0x00000002, 0x02000800, 0x00080800);
323 &data_word(0x02080802, 0x02080000, 0x00000802, 0x02000800);
324 &data_word(0x00000002, 0x00000800, 0x00080800, 0x02080002);
325 &data_word(0x00000800, 0x02000802, 0x02080002, 0x00000000);
326 &data_word(0x00000000, 0x02080802, 0x02000800, 0x00080002);
327 &data_word(0x02080800, 0x00080000, 0x00000802, 0x02000800);
328 &data_word(0x02080002, 0x00000800, 0x00080800, 0x02000002);
329 &data_word(0x00080802, 0x00000002, 0x02000002, 0x02080000);
330 &data_word(0x02080802, 0x00080800, 0x02080000, 0x02000802);
331 &data_word(0x02000000, 0x00000802, 0x00080002, 0x00000000);
332 &data_word(0x00080000, 0x02000000, 0x02000802, 0x02080800);
333 &data_word(0x00000002, 0x02080002, 0x00000800, 0x00080802);
334 # nibble 1
335 &data_word(0x40108010, 0x00000000, 0x00108000, 0x40100000);
336 &data_word(0x40000010, 0x00008010, 0x40008000, 0x00108000);
337 &data_word(0x00008000, 0x40100010, 0x00000010, 0x40008000);
338 &data_word(0x00100010, 0x40108000, 0x40100000, 0x00000010);
339 &data_word(0x00100000, 0x40008010, 0x40100010, 0x00008000);
340 &data_word(0x00108010, 0x40000000, 0x00000000, 0x00100010);
341 &data_word(0x40008010, 0x00108010, 0x40108000, 0x40000010);
342 &data_word(0x40000000, 0x00100000, 0x00008010, 0x40108010);
343 &data_word(0x00100010, 0x40108000, 0x40008000, 0x00108010);
344 &data_word(0x40108010, 0x00100010, 0x40000010, 0x00000000);
345 &data_word(0x40000000, 0x00008010, 0x00100000, 0x40100010);
346 &data_word(0x00008000, 0x40000000, 0x00108010, 0x40008010);
347 &data_word(0x40108000, 0x00008000, 0x00000000, 0x40000010);
348 &data_word(0x00000010, 0x40108010, 0x00108000, 0x40100000);
349 &data_word(0x40100010, 0x00100000, 0x00008010, 0x40008000);
350 &data_word(0x40008010, 0x00000010, 0x40100000, 0x00108000);
351 # nibble 2
352 &data_word(0x04000001, 0x04040100, 0x00000100, 0x04000101);
353 &data_word(0x00040001, 0x04000000, 0x04000101, 0x00040100);
354 &data_word(0x04000100, 0x00040000, 0x04040000, 0x00000001);
355 &data_word(0x04040101, 0x00000101, 0x00000001, 0x04040001);
356 &data_word(0x00000000, 0x00040001, 0x04040100, 0x00000100);
357 &data_word(0x00000101, 0x04040101, 0x00040000, 0x04000001);
358 &data_word(0x04040001, 0x04000100, 0x00040101, 0x04040000);
359 &data_word(0x00040100, 0x00000000, 0x04000000, 0x00040101);
360 &data_word(0x04040100, 0x00000100, 0x00000001, 0x00040000);
361 &data_word(0x00000101, 0x00040001, 0x04040000, 0x04000101);
362 &data_word(0x00000000, 0x04040100, 0x00040100, 0x04040001);
363 &data_word(0x00040001, 0x04000000, 0x04040101, 0x00000001);
364 &data_word(0x00040101, 0x04000001, 0x04000000, 0x04040101);
365 &data_word(0x00040000, 0x04000100, 0x04000101, 0x00040100);
366 &data_word(0x04000100, 0x00000000, 0x04040001, 0x00000101);
367 &data_word(0x04000001, 0x00040101, 0x00000100, 0x04040000);
368 # nibble 3
369 &data_word(0x00401008, 0x10001000, 0x00000008, 0x10401008);
370 &data_word(0x00000000, 0x10400000, 0x10001008, 0x00400008);
371 &data_word(0x10401000, 0x10000008, 0x10000000, 0x00001008);
372 &data_word(0x10000008, 0x00401008, 0x00400000, 0x10000000);
373 &data_word(0x10400008, 0x00401000, 0x00001000, 0x00000008);
374 &data_word(0x00401000, 0x10001008, 0x10400000, 0x00001000);
375 &data_word(0x00001008, 0x00000000, 0x00400008, 0x10401000);
376 &data_word(0x10001000, 0x10400008, 0x10401008, 0x00400000);
377 &data_word(0x10400008, 0x00001008, 0x00400000, 0x10000008);
378 &data_word(0x00401000, 0x10001000, 0x00000008, 0x10400000);
379 &data_word(0x10001008, 0x00000000, 0x00001000, 0x00400008);
380 &data_word(0x00000000, 0x10400008, 0x10401000, 0x00001000);
381 &data_word(0x10000000, 0x10401008, 0x00401008, 0x00400000);
382 &data_word(0x10401008, 0x00000008, 0x10001000, 0x00401008);
383 &data_word(0x00400008, 0x00401000, 0x10400000, 0x10001008);
384 &data_word(0x00001008, 0x10000000, 0x10000008, 0x10401000);
385 # nibble 4
386 &data_word(0x08000000, 0x00010000, 0x00000400, 0x08010420);
387 &data_word(0x08010020, 0x08000400, 0x00010420, 0x08010000);
388 &data_word(0x00010000, 0x00000020, 0x08000020, 0x00010400);
389 &data_word(0x08000420, 0x08010020, 0x08010400, 0x00000000);
390 &data_word(0x00010400, 0x08000000, 0x00010020, 0x00000420);
391 &data_word(0x08000400, 0x00010420, 0x00000000, 0x08000020);
392 &data_word(0x00000020, 0x08000420, 0x08010420, 0x00010020);
393 &data_word(0x08010000, 0x00000400, 0x00000420, 0x08010400);
394 &data_word(0x08010400, 0x08000420, 0x00010020, 0x08010000);
395 &data_word(0x00010000, 0x00000020, 0x08000020, 0x08000400);
396 &data_word(0x08000000, 0x00010400, 0x08010420, 0x00000000);
397 &data_word(0x00010420, 0x08000000, 0x00000400, 0x00010020);
398 &data_word(0x08000420, 0x00000400, 0x00000000, 0x08010420);
399 &data_word(0x08010020, 0x08010400, 0x00000420, 0x00010000);
400 &data_word(0x00010400, 0x08010020, 0x08000400, 0x00000420);
401 &data_word(0x00000020, 0x00010420, 0x08010000, 0x08000020);
402 # nibble 5
403 &data_word(0x80000040, 0x00200040, 0x00000000, 0x80202000);
404 &data_word(0x00200040, 0x00002000, 0x80002040, 0x00200000);
405 &data_word(0x00002040, 0x80202040, 0x00202000, 0x80000000);
406 &data_word(0x80002000, 0x80000040, 0x80200000, 0x00202040);
407 &data_word(0x00200000, 0x80002040, 0x80200040, 0x00000000);
408 &data_word(0x00002000, 0x00000040, 0x80202000, 0x80200040);
409 &data_word(0x80202040, 0x80200000, 0x80000000, 0x00002040);
410 &data_word(0x00000040, 0x00202000, 0x00202040, 0x80002000);
411 &data_word(0x00002040, 0x80000000, 0x80002000, 0x00202040);
412 &data_word(0x80202000, 0x00200040, 0x00000000, 0x80002000);
413 &data_word(0x80000000, 0x00002000, 0x80200040, 0x00200000);
414 &data_word(0x00200040, 0x80202040, 0x00202000, 0x00000040);
415 &data_word(0x80202040, 0x00202000, 0x00200000, 0x80002040);
416 &data_word(0x80000040, 0x80200000, 0x00202040, 0x00000000);
417 &data_word(0x00002000, 0x80000040, 0x80002040, 0x80202000);
418 &data_word(0x80200000, 0x00002040, 0x00000040, 0x80200040);
419 # nibble 6
420 &data_word(0x00004000, 0x00000200, 0x01000200, 0x01000004);
421 &data_word(0x01004204, 0x00004004, 0x00004200, 0x00000000);
422 &data_word(0x01000000, 0x01000204, 0x00000204, 0x01004000);
423 &data_word(0x00000004, 0x01004200, 0x01004000, 0x00000204);
424 &data_word(0x01000204, 0x00004000, 0x00004004, 0x01004204);
425 &data_word(0x00000000, 0x01000200, 0x01000004, 0x00004200);
426 &data_word(0x01004004, 0x00004204, 0x01004200, 0x00000004);
427 &data_word(0x00004204, 0x01004004, 0x00000200, 0x01000000);
428 &data_word(0x00004204, 0x01004000, 0x01004004, 0x00000204);
429 &data_word(0x00004000, 0x00000200, 0x01000000, 0x01004004);
430 &data_word(0x01000204, 0x00004204, 0x00004200, 0x00000000);
431 &data_word(0x00000200, 0x01000004, 0x00000004, 0x01000200);
432 &data_word(0x00000000, 0x01000204, 0x01000200, 0x00004200);
433 &data_word(0x00000204, 0x00004000, 0x01004204, 0x01000000);
434 &data_word(0x01004200, 0x00000004, 0x00004004, 0x01004204);
435 &data_word(0x01000004, 0x01004200, 0x01004000, 0x00004004);
436 # nibble 7
437 &data_word(0x20800080, 0x20820000, 0x00020080, 0x00000000);
438 &data_word(0x20020000, 0x00800080, 0x20800000, 0x20820080);
439 &data_word(0x00000080, 0x20000000, 0x00820000, 0x00020080);
440 &data_word(0x00820080, 0x20020080, 0x20000080, 0x20800000);
441 &data_word(0x00020000, 0x00820080, 0x00800080, 0x20020000);
442 &data_word(0x20820080, 0x20000080, 0x00000000, 0x00820000);
443 &data_word(0x20000000, 0x00800000, 0x20020080, 0x20800080);
444 &data_word(0x00800000, 0x00020000, 0x20820000, 0x00000080);
445 &data_word(0x00800000, 0x00020000, 0x20000080, 0x20820080);
446 &data_word(0x00020080, 0x20000000, 0x00000000, 0x00820000);
447 &data_word(0x20800080, 0x20020080, 0x20020000, 0x00800080);
448 &data_word(0x20820000, 0x00000080, 0x00800080, 0x20020000);
449 &data_word(0x20820080, 0x00800000, 0x20800000, 0x20000080);
450 &data_word(0x00820000, 0x00020080, 0x20020080, 0x20800000);
451 &data_word(0x00000080, 0x20820000, 0x00820080, 0x00000000);
452 &data_word(0x20000000, 0x20800080, 0x00020000, 0x00820080);
453 }
diff --git a/src/lib/libcrypto/des/asm/des_enc.m4 b/src/lib/libcrypto/des/asm/des_enc.m4
deleted file mode 100644
index 3280595478..0000000000
--- a/src/lib/libcrypto/des/asm/des_enc.m4
+++ /dev/null
@@ -1,2099 +0,0 @@
1! des_enc.m4
2! des_enc.S (generated from des_enc.m4)
3!
4! UltraSPARC assembler version of the LibDES/SSLeay/OpenSSL des_enc.c file.
5!
6! Version 1.0. 32-bit version.
7!
8! June 8, 2000.
9!
10! Version 2.0. 32/64-bit, PIC-ification, blended CPU adaptation
11! by Andy Polyakov.
12!
13! January 1, 2003.
14!
15! Assembler version: Copyright Svend Olaf Mikkelsen.
16!
17! Original C code: Copyright Eric A. Young.
18!
19! This code can be freely used by LibDES/SSLeay/OpenSSL users.
20!
21! The LibDES/SSLeay/OpenSSL copyright notices must be respected.
22!
23! This version can be redistributed.
24!
25! To expand the m4 macros: m4 -B 8192 des_enc.m4 > des_enc.S
26!
27! Global registers 1 to 5 are used. This is the same as done by the
28! cc compiler. The UltraSPARC load/store little endian feature is used.
29!
30! Instruction grouping often refers to one CPU cycle.
31!
32! Assemble through gcc: gcc -c -mcpu=ultrasparc -o des_enc.o des_enc.S
33!
34! Assemble through cc: cc -c -xarch=v8plusa -o des_enc.o des_enc.S
35!
36! Performance improvement according to './apps/openssl speed des'
37!
38! 32-bit build:
39! 23% faster than cc-5.2 -xarch=v8plus -xO5
40! 115% faster than gcc-3.2.1 -m32 -mcpu=ultrasparc -O5
41! 64-bit build:
42! 50% faster than cc-5.2 -xarch=v9 -xO5
43! 100% faster than gcc-3.2.1 -m64 -mcpu=ultrasparc -O5
44!
45
46.ident "des_enc.m4 2.1"
47.file "des_enc-sparc.S"
48
49#if defined(__SUNPRO_C) && defined(__sparcv9)
50# define ABI64 /* They've said -xarch=v9 at command line */
51#elif defined(__GNUC__) && defined(__arch64__)
52# define ABI64 /* They've said -m64 at command line */
53#endif
54
55#ifdef ABI64
56 .register %g2,#scratch
57 .register %g3,#scratch
58# define FRAME -192
59# define BIAS 2047
60# define LDPTR ldx
61# define STPTR stx
62# define ARG0 128
63# define ARGSZ 8
64# ifndef OPENSSL_SYSNAME_ULTRASPARC
65# define OPENSSL_SYSNAME_ULTRASPARC
66# endif
67#else
68# define FRAME -96
69# define BIAS 0
70# define LDPTR ld
71# define STPTR st
72# define ARG0 68
73# define ARGSZ 4
74#endif
75
76#define LOOPS 7
77
78#define global0 %g0
79#define global1 %g1
80#define global2 %g2
81#define global3 %g3
82#define global4 %g4
83#define global5 %g5
84
85#define local0 %l0
86#define local1 %l1
87#define local2 %l2
88#define local3 %l3
89#define local4 %l4
90#define local5 %l5
91#define local7 %l6
92#define local6 %l7
93
94#define in0 %i0
95#define in1 %i1
96#define in2 %i2
97#define in3 %i3
98#define in4 %i4
99#define in5 %i5
100#define in6 %i6
101#define in7 %i7
102
103#define out0 %o0
104#define out1 %o1
105#define out2 %o2
106#define out3 %o3
107#define out4 %o4
108#define out5 %o5
109#define out6 %o6
110#define out7 %o7
111
112#define stub stb
113
114changequote({,})
115
116
117! Macro definitions:
118
119
120! {ip_macro}
121!
122! The logic used in initial and final permutations is the same as in
123! the C code. The permutations are done with a clever shift, xor, and
124! technique.
125!
126! The macro also loads address sbox 1 to 5 to global 1 to 5, address
127! sbox 6 to local6, and addres sbox 8 to out3.
128!
129! Rotates the halfs 3 left to bring the sbox bits in convenient positions.
130!
131! Loads key first round from address in parameter 5 to out0, out1.
132!
133! After the the original LibDES initial permutation, the resulting left
134! is in the variable initially used for right and vice versa. The macro
135! implements the possibility to keep the halfs in the original registers.
136!
137! parameter 1 left
138! parameter 2 right
139! parameter 3 result left (modify in first round)
140! parameter 4 result right (use in first round)
141! parameter 5 key address
142! parameter 6 1/2 for include encryption/decryption
143! parameter 7 1 for move in1 to in3
144! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
145! parameter 9 1 for load ks3 and ks2 to in4 and in3
146
147define(ip_macro, {
148
149! {ip_macro}
150! $1 $2 $4 $3 $5 $6 $7 $8 $9
151
152 ld [out2+256], local1
153 srl $2, 4, local4
154
155 xor local4, $1, local4
156 ifelse($7,1,{mov in1, in3},{nop})
157
158 ld [out2+260], local2
159 and local4, local1, local4
160 ifelse($8,1,{mov in3, in4},{})
161 ifelse($8,2,{mov in4, in3},{})
162
163 ld [out2+280], out4 ! loop counter
164 sll local4, 4, local1
165 xor $1, local4, $1
166
167 ld [out2+264], local3
168 srl $1, 16, local4
169 xor $2, local1, $2
170
171 ifelse($9,1,{LDPTR KS3, in4},{})
172 xor local4, $2, local4
173 nop !sethi %hi(DES_SPtrans), global1 ! sbox addr
174
175 ifelse($9,1,{LDPTR KS2, in3},{})
176 and local4, local2, local4
177 nop !or global1, %lo(DES_SPtrans), global1 ! sbox addr
178
179 sll local4, 16, local1
180 xor $2, local4, $2
181
182 srl $2, 2, local4
183 xor $1, local1, $1
184
185 sethi %hi(16711680), local5
186 xor local4, $1, local4
187
188 and local4, local3, local4
189 or local5, 255, local5
190
191 sll local4, 2, local2
192 xor $1, local4, $1
193
194 srl $1, 8, local4
195 xor $2, local2, $2
196
197 xor local4, $2, local4
198 add global1, 768, global4
199
200 and local4, local5, local4
201 add global1, 1024, global5
202
203 ld [out2+272], local7
204 sll local4, 8, local1
205 xor $2, local4, $2
206
207 srl $2, 1, local4
208 xor $1, local1, $1
209
210 ld [$5], out0 ! key 7531
211 xor local4, $1, local4
212 add global1, 256, global2
213
214 ld [$5+4], out1 ! key 8642
215 and local4, local7, local4
216 add global1, 512, global3
217
218 sll local4, 1, local1
219 xor $1, local4, $1
220
221 sll $1, 3, local3
222 xor $2, local1, $2
223
224 sll $2, 3, local2
225 add global1, 1280, local6 ! address sbox 8
226
227 srl $1, 29, local4
228 add global1, 1792, out3 ! address sbox 8
229
230 srl $2, 29, local1
231 or local4, local3, $4
232
233 or local2, local1, $3
234
235 ifelse($6, 1, {
236
237 ld [out2+284], local5 ! 0x0000FC00 used in the rounds
238 or local2, local1, $3
239 xor $4, out0, local1
240
241 call .des_enc.1
242 and local1, 252, local1
243
244 },{})
245
246 ifelse($6, 2, {
247
248 ld [out2+284], local5 ! 0x0000FC00 used in the rounds
249 or local2, local1, $3
250 xor $4, out0, local1
251
252 call .des_dec.1
253 and local1, 252, local1
254
255 },{})
256})
257
258
259! {rounds_macro}
260!
261! The logic used in the DES rounds is the same as in the C code,
262! except that calculations for sbox 1 and sbox 5 begin before
263! the previous round is finished.
264!
265! In each round one half (work) is modified based on key and the
266! other half (use).
267!
268! In this version we do two rounds in a loop repeated 7 times
269! and two rounds seperately.
270!
271! One half has the bits for the sboxes in the following positions:
272!
273! 777777xx555555xx333333xx111111xx
274!
275! 88xx666666xx444444xx222222xx8888
276!
277! The bits for each sbox are xor-ed with the key bits for that box.
278! The above xx bits are cleared, and the result used for lookup in
279! the sbox table. Each sbox entry contains the 4 output bits permuted
280! into 32 bits according to the P permutation.
281!
282! In the description of DES, left and right are switched after
283! each round, except after last round. In this code the original
284! left and right are kept in the same register in all rounds, meaning
285! that after the 16 rounds the result for right is in the register
286! originally used for left.
287!
288! parameter 1 first work (left in first round)
289! parameter 2 first use (right in first round)
290! parameter 3 enc/dec 1/-1
291! parameter 4 loop label
292! parameter 5 key address register
293! parameter 6 optional address for key next encryption/decryption
294! parameter 7 not empty for include retl
295!
296! also compares in2 to 8
297
298define(rounds_macro, {
299
300! {rounds_macro}
301! $1 $2 $3 $4 $5 $6 $7 $8 $9
302
303 xor $2, out0, local1
304
305 ld [out2+284], local5 ! 0x0000FC00
306 ba $4
307 and local1, 252, local1
308
309 .align 32
310
311$4:
312 ! local6 is address sbox 6
313 ! out3 is address sbox 8
314 ! out4 is loop counter
315
316 ld [global1+local1], local1
317 xor $2, out1, out1 ! 8642
318 xor $2, out0, out0 ! 7531
319 ! fmovs %f0, %f0 ! fxor used for alignment
320
321 srl out1, 4, local0 ! rotate 4 right
322 and out0, local5, local3 ! 3
323 ! fmovs %f0, %f0
324
325 ld [$5+$3*8], local7 ! key 7531 next round
326 srl local3, 8, local3 ! 3
327 and local0, 252, local2 ! 2
328 ! fmovs %f0, %f0
329
330 ld [global3+local3],local3 ! 3
331 sll out1, 28, out1 ! rotate
332 xor $1, local1, $1 ! 1 finished, local1 now sbox 7
333
334 ld [global2+local2], local2 ! 2
335 srl out0, 24, local1 ! 7
336 or out1, local0, out1 ! rotate
337
338 ldub [out2+local1], local1 ! 7 (and 0xFC)
339 srl out1, 24, local0 ! 8
340 and out1, local5, local4 ! 4
341
342 ldub [out2+local0], local0 ! 8 (and 0xFC)
343 srl local4, 8, local4 ! 4
344 xor $1, local2, $1 ! 2 finished local2 now sbox 6
345
346 ld [global4+local4],local4 ! 4
347 srl out1, 16, local2 ! 6
348 xor $1, local3, $1 ! 3 finished local3 now sbox 5
349
350 ld [out3+local0],local0 ! 8
351 and local2, 252, local2 ! 6
352 add global1, 1536, local5 ! address sbox 7
353
354 ld [local6+local2], local2 ! 6
355 srl out0, 16, local3 ! 5
356 xor $1, local4, $1 ! 4 finished
357
358 ld [local5+local1],local1 ! 7
359 and local3, 252, local3 ! 5
360 xor $1, local0, $1 ! 8 finished
361
362 ld [global5+local3],local3 ! 5
363 xor $1, local2, $1 ! 6 finished
364 subcc out4, 1, out4
365
366 ld [$5+$3*8+4], out0 ! key 8642 next round
367 xor $1, local7, local2 ! sbox 5 next round
368 xor $1, local1, $1 ! 7 finished
369
370 srl local2, 16, local2 ! sbox 5 next round
371 xor $1, local3, $1 ! 5 finished
372
373 ld [$5+$3*16+4], out1 ! key 8642 next round again
374 and local2, 252, local2 ! sbox5 next round
375! next round
376 xor $1, local7, local7 ! 7531
377
378 ld [global5+local2], local2 ! 5
379 srl local7, 24, local3 ! 7
380 xor $1, out0, out0 ! 8642
381
382 ldub [out2+local3], local3 ! 7 (and 0xFC)
383 srl out0, 4, local0 ! rotate 4 right
384 and local7, 252, local1 ! 1
385
386 sll out0, 28, out0 ! rotate
387 xor $2, local2, $2 ! 5 finished local2 used
388
389 srl local0, 8, local4 ! 4
390 and local0, 252, local2 ! 2
391 ld [local5+local3], local3 ! 7
392
393 srl local0, 16, local5 ! 6
394 or out0, local0, out0 ! rotate
395 ld [global2+local2], local2 ! 2
396
397 srl out0, 24, local0
398 ld [$5+$3*16], out0 ! key 7531 next round
399 and local4, 252, local4 ! 4
400
401 and local5, 252, local5 ! 6
402 ld [global4+local4], local4 ! 4
403 xor $2, local3, $2 ! 7 finished local3 used
404
405 and local0, 252, local0 ! 8
406 ld [local6+local5], local5 ! 6
407 xor $2, local2, $2 ! 2 finished local2 now sbox 3
408
409 srl local7, 8, local2 ! 3 start
410 ld [out3+local0], local0 ! 8
411 xor $2, local4, $2 ! 4 finished
412
413 and local2, 252, local2 ! 3
414 ld [global1+local1], local1 ! 1
415 xor $2, local5, $2 ! 6 finished local5 used
416
417 ld [global3+local2], local2 ! 3
418 xor $2, local0, $2 ! 8 finished
419 add $5, $3*16, $5 ! enc add 8, dec add -8 to key pointer
420
421 ld [out2+284], local5 ! 0x0000FC00
422 xor $2, out0, local4 ! sbox 1 next round
423 xor $2, local1, $2 ! 1 finished
424
425 xor $2, local2, $2 ! 3 finished
426#ifdef OPENSSL_SYSNAME_ULTRASPARC
427 bne,pt %icc, $4
428#else
429 bne $4
430#endif
431 and local4, 252, local1 ! sbox 1 next round
432
433! two rounds more:
434
435 ld [global1+local1], local1
436 xor $2, out1, out1
437 xor $2, out0, out0
438
439 srl out1, 4, local0 ! rotate
440 and out0, local5, local3
441
442 ld [$5+$3*8], local7 ! key 7531
443 srl local3, 8, local3
444 and local0, 252, local2
445
446 ld [global3+local3],local3
447 sll out1, 28, out1 ! rotate
448 xor $1, local1, $1 ! 1 finished, local1 now sbox 7
449
450 ld [global2+local2], local2
451 srl out0, 24, local1
452 or out1, local0, out1 ! rotate
453
454 ldub [out2+local1], local1
455 srl out1, 24, local0
456 and out1, local5, local4
457
458 ldub [out2+local0], local0
459 srl local4, 8, local4
460 xor $1, local2, $1 ! 2 finished local2 now sbox 6
461
462 ld [global4+local4],local4
463 srl out1, 16, local2
464 xor $1, local3, $1 ! 3 finished local3 now sbox 5
465
466 ld [out3+local0],local0
467 and local2, 252, local2
468 add global1, 1536, local5 ! address sbox 7
469
470 ld [local6+local2], local2
471 srl out0, 16, local3
472 xor $1, local4, $1 ! 4 finished
473
474 ld [local5+local1],local1
475 and local3, 252, local3
476 xor $1, local0, $1
477
478 ld [global5+local3],local3
479 xor $1, local2, $1 ! 6 finished
480 cmp in2, 8
481
482 ifelse($6,{}, {}, {ld [out2+280], out4}) ! loop counter
483 xor $1, local7, local2 ! sbox 5 next round
484 xor $1, local1, $1 ! 7 finished
485
486 ld [$5+$3*8+4], out0
487 srl local2, 16, local2 ! sbox 5 next round
488 xor $1, local3, $1 ! 5 finished
489
490 and local2, 252, local2
491! next round (two rounds more)
492 xor $1, local7, local7 ! 7531
493
494 ld [global5+local2], local2
495 srl local7, 24, local3
496 xor $1, out0, out0 ! 8642
497
498 ldub [out2+local3], local3
499 srl out0, 4, local0 ! rotate
500 and local7, 252, local1
501
502 sll out0, 28, out0 ! rotate
503 xor $2, local2, $2 ! 5 finished local2 used
504
505 srl local0, 8, local4
506 and local0, 252, local2
507 ld [local5+local3], local3
508
509 srl local0, 16, local5
510 or out0, local0, out0 ! rotate
511 ld [global2+local2], local2
512
513 srl out0, 24, local0
514 ifelse($6,{}, {}, {ld [$6], out0}) ! key next encryption/decryption
515 and local4, 252, local4
516
517 and local5, 252, local5
518 ld [global4+local4], local4
519 xor $2, local3, $2 ! 7 finished local3 used
520
521 and local0, 252, local0
522 ld [local6+local5], local5
523 xor $2, local2, $2 ! 2 finished local2 now sbox 3
524
525 srl local7, 8, local2 ! 3 start
526 ld [out3+local0], local0
527 xor $2, local4, $2
528
529 and local2, 252, local2
530 ld [global1+local1], local1
531 xor $2, local5, $2 ! 6 finished local5 used
532
533 ld [global3+local2], local2
534 srl $1, 3, local3
535 xor $2, local0, $2
536
537 ifelse($6,{}, {}, {ld [$6+4], out1}) ! key next encryption/decryption
538 sll $1, 29, local4
539 xor $2, local1, $2
540
541 ifelse($7,{}, {}, {retl})
542 xor $2, local2, $2
543})
544
545
546! {fp_macro}
547!
548! parameter 1 right (original left)
549! parameter 2 left (original right)
550! parameter 3 1 for optional store to [in0]
551! parameter 4 1 for load input/output address to local5/7
552!
553! The final permutation logic switches the halfes, meaning that
554! left and right ends up the the registers originally used.
555
556define(fp_macro, {
557
558! {fp_macro}
559! $1 $2 $3 $4 $5 $6 $7 $8 $9
560
561 ! initially undo the rotate 3 left done after initial permutation
562 ! original left is received shifted 3 right and 29 left in local3/4
563
564 sll $2, 29, local1
565 or local3, local4, $1
566
567 srl $2, 3, $2
568 sethi %hi(0x55555555), local2
569
570 or $2, local1, $2
571 or local2, %lo(0x55555555), local2
572
573 srl $2, 1, local3
574 sethi %hi(0x00ff00ff), local1
575 xor local3, $1, local3
576 or local1, %lo(0x00ff00ff), local1
577 and local3, local2, local3
578 sethi %hi(0x33333333), local4
579 sll local3, 1, local2
580
581 xor $1, local3, $1
582
583 srl $1, 8, local3
584 xor $2, local2, $2
585 xor local3, $2, local3
586 or local4, %lo(0x33333333), local4
587 and local3, local1, local3
588 sethi %hi(0x0000ffff), local1
589 sll local3, 8, local2
590
591 xor $2, local3, $2
592
593 srl $2, 2, local3
594 xor $1, local2, $1
595 xor local3, $1, local3
596 or local1, %lo(0x0000ffff), local1
597 and local3, local4, local3
598 sethi %hi(0x0f0f0f0f), local4
599 sll local3, 2, local2
600
601 ifelse($4,1, {LDPTR INPUT, local5})
602 xor $1, local3, $1
603
604 ifelse($4,1, {LDPTR OUTPUT, local7})
605 srl $1, 16, local3
606 xor $2, local2, $2
607 xor local3, $2, local3
608 or local4, %lo(0x0f0f0f0f), local4
609 and local3, local1, local3
610 sll local3, 16, local2
611
612 xor $2, local3, local1
613
614 srl local1, 4, local3
615 xor $1, local2, $1
616 xor local3, $1, local3
617 and local3, local4, local3
618 sll local3, 4, local2
619
620 xor $1, local3, $1
621
622 ! optional store:
623
624 ifelse($3,1, {st $1, [in0]})
625
626 xor local1, local2, $2
627
628 ifelse($3,1, {st $2, [in0+4]})
629
630})
631
632
633! {fp_ip_macro}
634!
635! Does initial permutation for next block mixed with
636! final permutation for current block.
637!
638! parameter 1 original left
639! parameter 2 original right
640! parameter 3 left ip
641! parameter 4 right ip
642! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
643! 2: mov in4 to in3
644!
645! also adds -8 to length in2 and loads loop counter to out4
646
647define(fp_ip_macro, {
648
649! {fp_ip_macro}
650! $1 $2 $3 $4 $5 $6 $7 $8 $9
651
652 define({temp1},{out4})
653 define({temp2},{local3})
654
655 define({ip1},{local1})
656 define({ip2},{local2})
657 define({ip4},{local4})
658 define({ip5},{local5})
659
660 ! $1 in local3, local4
661
662 ld [out2+256], ip1
663 sll out5, 29, temp1
664 or local3, local4, $1
665
666 srl out5, 3, $2
667 ifelse($5,2,{mov in4, in3})
668
669 ld [out2+272], ip5
670 srl $4, 4, local0
671 or $2, temp1, $2
672
673 srl $2, 1, temp1
674 xor temp1, $1, temp1
675
676 and temp1, ip5, temp1
677 xor local0, $3, local0
678
679 sll temp1, 1, temp2
680 xor $1, temp1, $1
681
682 and local0, ip1, local0
683 add in2, -8, in2
684
685 sll local0, 4, local7
686 xor $3, local0, $3
687
688 ld [out2+268], ip4
689 srl $1, 8, temp1
690 xor $2, temp2, $2
691 ld [out2+260], ip2
692 srl $3, 16, local0
693 xor $4, local7, $4
694 xor temp1, $2, temp1
695 xor local0, $4, local0
696 and temp1, ip4, temp1
697 and local0, ip2, local0
698 sll temp1, 8, temp2
699 xor $2, temp1, $2
700 sll local0, 16, local7
701 xor $4, local0, $4
702
703 srl $2, 2, temp1
704 xor $1, temp2, $1
705
706 ld [out2+264], temp2 ! ip3
707 srl $4, 2, local0
708 xor $3, local7, $3
709 xor temp1, $1, temp1
710 xor local0, $3, local0
711 and temp1, temp2, temp1
712 and local0, temp2, local0
713 sll temp1, 2, temp2
714 xor $1, temp1, $1
715 sll local0, 2, local7
716 xor $3, local0, $3
717
718 srl $1, 16, temp1
719 xor $2, temp2, $2
720 srl $3, 8, local0
721 xor $4, local7, $4
722 xor temp1, $2, temp1
723 xor local0, $4, local0
724 and temp1, ip2, temp1
725 and local0, ip4, local0
726 sll temp1, 16, temp2
727 xor $2, temp1, local4
728 sll local0, 8, local7
729 xor $4, local0, $4
730
731 srl $4, 1, local0
732 xor $3, local7, $3
733
734 srl local4, 4, temp1
735 xor local0, $3, local0
736
737 xor $1, temp2, $1
738 and local0, ip5, local0
739
740 sll local0, 1, local7
741 xor temp1, $1, temp1
742
743 xor $3, local0, $3
744 xor $4, local7, $4
745
746 sll $3, 3, local5
747 and temp1, ip1, temp1
748
749 sll temp1, 4, temp2
750 xor $1, temp1, $1
751
752 ifelse($5,1,{LDPTR KS2, in4})
753 sll $4, 3, local2
754 xor local4, temp2, $2
755
756 ! reload since used as temporar:
757
758 ld [out2+280], out4 ! loop counter
759
760 srl $3, 29, local0
761 ifelse($5,1,{add in4, 120, in4})
762
763 ifelse($5,1,{LDPTR KS1, in3})
764 srl $4, 29, local7
765
766 or local0, local5, $4
767 or local2, local7, $3
768
769})
770
771
772
773! {load_little_endian}
774!
775! parameter 1 address
776! parameter 2 destination left
777! parameter 3 destination right
778! parameter 4 temporar
779! parameter 5 label
780
781define(load_little_endian, {
782
783! {load_little_endian}
784! $1 $2 $3 $4 $5 $6 $7 $8 $9
785
786 ! first in memory to rightmost in register
787
788#ifdef OPENSSL_SYSNAME_ULTRASPARC
789 andcc $1, 3, global0
790 bne,pn %icc, $5
791 nop
792
793 lda [$1] 0x88, $2
794 add $1, 4, $4
795
796 ba,pt %icc, $5a
797 lda [$4] 0x88, $3
798#endif
799
800$5:
801 ldub [$1+3], $2
802
803 ldub [$1+2], $4
804 sll $2, 8, $2
805 or $2, $4, $2
806
807 ldub [$1+1], $4
808 sll $2, 8, $2
809 or $2, $4, $2
810
811 ldub [$1+0], $4
812 sll $2, 8, $2
813 or $2, $4, $2
814
815
816 ldub [$1+3+4], $3
817
818 ldub [$1+2+4], $4
819 sll $3, 8, $3
820 or $3, $4, $3
821
822 ldub [$1+1+4], $4
823 sll $3, 8, $3
824 or $3, $4, $3
825
826 ldub [$1+0+4], $4
827 sll $3, 8, $3
828 or $3, $4, $3
829$5a:
830
831})
832
833
834! {load_little_endian_inc}
835!
836! parameter 1 address
837! parameter 2 destination left
838! parameter 3 destination right
839! parameter 4 temporar
840! parameter 4 label
841!
842! adds 8 to address
843
844define(load_little_endian_inc, {
845
846! {load_little_endian_inc}
847! $1 $2 $3 $4 $5 $6 $7 $8 $9
848
849 ! first in memory to rightmost in register
850
851#ifdef OPENSSL_SYSNAME_ULTRASPARC
852 andcc $1, 3, global0
853 bne,pn %icc, $5
854 nop
855
856 lda [$1] 0x88, $2
857 add $1, 4, $1
858
859 lda [$1] 0x88, $3
860 ba,pt %icc, $5a
861 add $1, 4, $1
862#endif
863
864$5:
865 ldub [$1+3], $2
866
867 ldub [$1+2], $4
868 sll $2, 8, $2
869 or $2, $4, $2
870
871 ldub [$1+1], $4
872 sll $2, 8, $2
873 or $2, $4, $2
874
875 ldub [$1+0], $4
876 sll $2, 8, $2
877 or $2, $4, $2
878
879 ldub [$1+3+4], $3
880 add $1, 8, $1
881
882 ldub [$1+2+4-8], $4
883 sll $3, 8, $3
884 or $3, $4, $3
885
886 ldub [$1+1+4-8], $4
887 sll $3, 8, $3
888 or $3, $4, $3
889
890 ldub [$1+0+4-8], $4
891 sll $3, 8, $3
892 or $3, $4, $3
893$5a:
894
895})
896
897
898! {load_n_bytes}
899!
900! Loads 1 to 7 bytes little endian
901! Remaining bytes are zeroed.
902!
903! parameter 1 address
904! parameter 2 length
905! parameter 3 destination register left
906! parameter 4 destination register right
907! parameter 5 temp
908! parameter 6 temp2
909! parameter 7 label
910! parameter 8 return label
911
912define(load_n_bytes, {
913
914! {load_n_bytes}
915! $1 $2 $5 $6 $7 $8 $7 $8 $9
916
917$7.0: call .+8
918 sll $2, 2, $6
919
920 add %o7,$7.jmp.table-$7.0,$5
921
922 add $5, $6, $5
923 mov 0, $4
924
925 ld [$5], $5
926
927 jmp %o7+$5
928 mov 0, $3
929
930$7.7:
931 ldub [$1+6], $5
932 sll $5, 16, $5
933 or $3, $5, $3
934$7.6:
935 ldub [$1+5], $5
936 sll $5, 8, $5
937 or $3, $5, $3
938$7.5:
939 ldub [$1+4], $5
940 or $3, $5, $3
941$7.4:
942 ldub [$1+3], $5
943 sll $5, 24, $5
944 or $4, $5, $4
945$7.3:
946 ldub [$1+2], $5
947 sll $5, 16, $5
948 or $4, $5, $4
949$7.2:
950 ldub [$1+1], $5
951 sll $5, 8, $5
952 or $4, $5, $4
953$7.1:
954 ldub [$1+0], $5
955 ba $8
956 or $4, $5, $4
957
958 .align 4
959
960$7.jmp.table:
961 .word 0
962 .word $7.1-$7.0
963 .word $7.2-$7.0
964 .word $7.3-$7.0
965 .word $7.4-$7.0
966 .word $7.5-$7.0
967 .word $7.6-$7.0
968 .word $7.7-$7.0
969})
970
971
972! {store_little_endian}
973!
974! parameter 1 address
975! parameter 2 source left
976! parameter 3 source right
977! parameter 4 temporar
978
979define(store_little_endian, {
980
981! {store_little_endian}
982! $1 $2 $3 $4 $5 $6 $7 $8 $9
983
984 ! rightmost in register to first in memory
985
986#ifdef OPENSSL_SYSNAME_ULTRASPARC
987 andcc $1, 3, global0
988 bne,pn %icc, $5
989 nop
990
991 sta $2, [$1] 0x88
992 add $1, 4, $4
993
994 ba,pt %icc, $5a
995 sta $3, [$4] 0x88
996#endif
997
998$5:
999 and $2, 255, $4
1000 stub $4, [$1+0]
1001
1002 srl $2, 8, $4
1003 and $4, 255, $4
1004 stub $4, [$1+1]
1005
1006 srl $2, 16, $4
1007 and $4, 255, $4
1008 stub $4, [$1+2]
1009
1010 srl $2, 24, $4
1011 stub $4, [$1+3]
1012
1013
1014 and $3, 255, $4
1015 stub $4, [$1+0+4]
1016
1017 srl $3, 8, $4
1018 and $4, 255, $4
1019 stub $4, [$1+1+4]
1020
1021 srl $3, 16, $4
1022 and $4, 255, $4
1023 stub $4, [$1+2+4]
1024
1025 srl $3, 24, $4
1026 stub $4, [$1+3+4]
1027
1028$5a:
1029
1030})
1031
1032
1033! {store_n_bytes}
1034!
1035! Stores 1 to 7 bytes little endian
1036!
1037! parameter 1 address
1038! parameter 2 length
1039! parameter 3 source register left
1040! parameter 4 source register right
1041! parameter 5 temp
1042! parameter 6 temp2
1043! parameter 7 label
1044! parameter 8 return label
1045
1046define(store_n_bytes, {
1047
1048! {store_n_bytes}
1049! $1 $2 $5 $6 $7 $8 $7 $8 $9
1050
1051$7.0: call .+8
1052 sll $2, 2, $6
1053
1054 add %o7,$7.jmp.table-$7.0,$5
1055
1056 add $5, $6, $5
1057
1058 ld [$5], $5
1059
1060 jmp %o7+$5
1061 nop
1062
1063$7.7:
1064 srl $3, 16, $5
1065 and $5, 0xff, $5
1066 stub $5, [$1+6]
1067$7.6:
1068 srl $3, 8, $5
1069 and $5, 0xff, $5
1070 stub $5, [$1+5]
1071$7.5:
1072 and $3, 0xff, $5
1073 stub $5, [$1+4]
1074$7.4:
1075 srl $4, 24, $5
1076 stub $5, [$1+3]
1077$7.3:
1078 srl $4, 16, $5
1079 and $5, 0xff, $5
1080 stub $5, [$1+2]
1081$7.2:
1082 srl $4, 8, $5
1083 and $5, 0xff, $5
1084 stub $5, [$1+1]
1085$7.1:
1086 and $4, 0xff, $5
1087
1088
1089 ba $8
1090 stub $5, [$1]
1091
1092 .align 4
1093
1094$7.jmp.table:
1095
1096 .word 0
1097 .word $7.1-$7.0
1098 .word $7.2-$7.0
1099 .word $7.3-$7.0
1100 .word $7.4-$7.0
1101 .word $7.5-$7.0
1102 .word $7.6-$7.0
1103 .word $7.7-$7.0
1104})
1105
1106
1107define(testvalue,{1})
1108
1109define(register_init, {
1110
1111! For test purposes:
1112
1113 sethi %hi(testvalue), local0
1114 or local0, %lo(testvalue), local0
1115
1116 ifelse($1,{},{}, {mov local0, $1})
1117 ifelse($2,{},{}, {mov local0, $2})
1118 ifelse($3,{},{}, {mov local0, $3})
1119 ifelse($4,{},{}, {mov local0, $4})
1120 ifelse($5,{},{}, {mov local0, $5})
1121 ifelse($6,{},{}, {mov local0, $6})
1122 ifelse($7,{},{}, {mov local0, $7})
1123 ifelse($8,{},{}, {mov local0, $8})
1124
1125 mov local0, local1
1126 mov local0, local2
1127 mov local0, local3
1128 mov local0, local4
1129 mov local0, local5
1130 mov local0, local7
1131 mov local0, local6
1132 mov local0, out0
1133 mov local0, out1
1134 mov local0, out2
1135 mov local0, out3
1136 mov local0, out4
1137 mov local0, out5
1138 mov local0, global1
1139 mov local0, global2
1140 mov local0, global3
1141 mov local0, global4
1142 mov local0, global5
1143
1144})
1145
1146.section ".text"
1147
1148 .align 32
1149
1150.des_enc:
1151
1152 ! key address in3
1153 ! loads key next encryption/decryption first round from [in4]
1154
1155 rounds_macro(in5, out5, 1, .des_enc.1, in3, in4, retl)
1156
1157
1158 .align 32
1159
1160.des_dec:
1161
1162 ! implemented with out5 as first parameter to avoid
1163 ! register exchange in ede modes
1164
1165 ! key address in4
1166 ! loads key next encryption/decryption first round from [in3]
1167
1168 rounds_macro(out5, in5, -1, .des_dec.1, in4, in3, retl)
1169
1170
1171
1172! void DES_encrypt1(data, ks, enc)
1173! *******************************
1174
1175 .align 32
1176 .global DES_encrypt1
1177 .type DES_encrypt1,#function
1178
1179DES_encrypt1:
1180
1181 save %sp, FRAME, %sp
1182
1183 sethi %hi(.PIC.DES_SPtrans-1f),global1
1184 or global1,%lo(.PIC.DES_SPtrans-1f),global1
11851: call .+8
1186 add %o7,global1,global1
1187 sub global1,.PIC.DES_SPtrans-.des_and,out2
1188
1189 ld [in0], in5 ! left
1190 cmp in2, 0 ! enc
1191
1192#ifdef OPENSSL_SYSNAME_ULTRASPARC
1193 be,pn %icc, .encrypt.dec ! enc/dec
1194#else
1195 be .encrypt.dec
1196#endif
1197 ld [in0+4], out5 ! right
1198
1199 ! parameter 6 1/2 for include encryption/decryption
1200 ! parameter 7 1 for move in1 to in3
1201 ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
1202
1203 ip_macro(in5, out5, in5, out5, in3, 0, 1, 1)
1204
1205 rounds_macro(in5, out5, 1, .des_encrypt1.1, in3, in4) ! in4 not used
1206
1207 fp_macro(in5, out5, 1) ! 1 for store to [in0]
1208
1209 ret
1210 restore
1211
1212.encrypt.dec:
1213
1214 add in1, 120, in3 ! use last subkey for first round
1215
1216 ! parameter 6 1/2 for include encryption/decryption
1217 ! parameter 7 1 for move in1 to in3
1218 ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
1219
1220 ip_macro(in5, out5, out5, in5, in4, 2, 0, 1) ! include dec, ks in4
1221
1222 fp_macro(out5, in5, 1) ! 1 for store to [in0]
1223
1224 ret
1225 restore
1226
1227.DES_encrypt1.end:
1228 .size DES_encrypt1,.DES_encrypt1.end-DES_encrypt1
1229
1230
1231! void DES_encrypt2(data, ks, enc)
1232!*********************************
1233
1234 ! encrypts/decrypts without initial/final permutation
1235
1236 .align 32
1237 .global DES_encrypt2
1238 .type DES_encrypt2,#function
1239
1240DES_encrypt2:
1241
1242 save %sp, FRAME, %sp
1243
1244 sethi %hi(.PIC.DES_SPtrans-1f),global1
1245 or global1,%lo(.PIC.DES_SPtrans-1f),global1
12461: call .+8
1247 add %o7,global1,global1
1248 sub global1,.PIC.DES_SPtrans-.des_and,out2
1249
1250 ! Set sbox address 1 to 6 and rotate halfs 3 left
1251 ! Errors caught by destest? Yes. Still? *NO*
1252
1253 !sethi %hi(DES_SPtrans), global1 ! address sbox 1
1254
1255 !or global1, %lo(DES_SPtrans), global1 ! sbox 1
1256
1257 add global1, 256, global2 ! sbox 2
1258 add global1, 512, global3 ! sbox 3
1259
1260 ld [in0], out5 ! right
1261 add global1, 768, global4 ! sbox 4
1262 add global1, 1024, global5 ! sbox 5
1263
1264 ld [in0+4], in5 ! left
1265 add global1, 1280, local6 ! sbox 6
1266 add global1, 1792, out3 ! sbox 8
1267
1268 ! rotate
1269
1270 sll in5, 3, local5
1271 mov in1, in3 ! key address to in3
1272
1273 sll out5, 3, local7
1274 srl in5, 29, in5
1275
1276 srl out5, 29, out5
1277 add in5, local5, in5
1278
1279 add out5, local7, out5
1280 cmp in2, 0
1281
1282 ! we use our own stackframe
1283
1284#ifdef OPENSSL_SYSNAME_ULTRASPARC
1285 be,pn %icc, .encrypt2.dec ! decryption
1286#else
1287 be .encrypt2.dec
1288#endif
1289 STPTR in0, [%sp+BIAS+ARG0+0*ARGSZ]
1290
1291 ld [in3], out0 ! key 7531 first round
1292 mov LOOPS, out4 ! loop counter
1293
1294 ld [in3+4], out1 ! key 8642 first round
1295 sethi %hi(0x0000FC00), local5
1296
1297 call .des_enc
1298 mov in3, in4
1299
1300 ! rotate
1301 sll in5, 29, in0
1302 srl in5, 3, in5
1303 sll out5, 29, in1
1304 add in5, in0, in5
1305 srl out5, 3, out5
1306 LDPTR [%sp+BIAS+ARG0+0*ARGSZ], in0
1307 add out5, in1, out5
1308 st in5, [in0]
1309 st out5, [in0+4]
1310
1311 ret
1312 restore
1313
1314
1315.encrypt2.dec:
1316
1317 add in3, 120, in4
1318
1319 ld [in4], out0 ! key 7531 first round
1320 mov LOOPS, out4 ! loop counter
1321
1322 ld [in4+4], out1 ! key 8642 first round
1323 sethi %hi(0x0000FC00), local5
1324
1325 mov in5, local1 ! left expected in out5
1326 mov out5, in5
1327
1328 call .des_dec
1329 mov local1, out5
1330
1331.encrypt2.finish:
1332
1333 ! rotate
1334 sll in5, 29, in0
1335 srl in5, 3, in5
1336 sll out5, 29, in1
1337 add in5, in0, in5
1338 srl out5, 3, out5
1339 LDPTR [%sp+BIAS+ARG0+0*ARGSZ], in0
1340 add out5, in1, out5
1341 st out5, [in0]
1342 st in5, [in0+4]
1343
1344 ret
1345 restore
1346
1347.DES_encrypt2.end:
1348 .size DES_encrypt2, .DES_encrypt2.end-DES_encrypt2
1349
1350
1351! void DES_encrypt3(data, ks1, ks2, ks3)
1352! **************************************
1353
1354 .align 32
1355 .global DES_encrypt3
1356 .type DES_encrypt3,#function
1357
1358DES_encrypt3:
1359
1360 save %sp, FRAME, %sp
1361
1362 sethi %hi(.PIC.DES_SPtrans-1f),global1
1363 or global1,%lo(.PIC.DES_SPtrans-1f),global1
13641: call .+8
1365 add %o7,global1,global1
1366 sub global1,.PIC.DES_SPtrans-.des_and,out2
1367
1368 ld [in0], in5 ! left
1369 add in2, 120, in4 ! ks2
1370
1371 ld [in0+4], out5 ! right
1372 mov in3, in2 ! save ks3
1373
1374 ! parameter 6 1/2 for include encryption/decryption
1375 ! parameter 7 1 for mov in1 to in3
1376 ! parameter 8 1 for mov in3 to in4
1377 ! parameter 9 1 for load ks3 and ks2 to in4 and in3
1378
1379 ip_macro(in5, out5, in5, out5, in3, 1, 1, 0, 0)
1380
1381 call .des_dec
1382 mov in2, in3 ! preload ks3
1383
1384 call .des_enc
1385 nop
1386
1387 fp_macro(in5, out5, 1)
1388
1389 ret
1390 restore
1391
1392.DES_encrypt3.end:
1393 .size DES_encrypt3,.DES_encrypt3.end-DES_encrypt3
1394
1395
1396! void DES_decrypt3(data, ks1, ks2, ks3)
1397! **************************************
1398
1399 .align 32
1400 .global DES_decrypt3
1401 .type DES_decrypt3,#function
1402
1403DES_decrypt3:
1404
1405 save %sp, FRAME, %sp
1406
1407 sethi %hi(.PIC.DES_SPtrans-1f),global1
1408 or global1,%lo(.PIC.DES_SPtrans-1f),global1
14091: call .+8
1410 add %o7,global1,global1
1411 sub global1,.PIC.DES_SPtrans-.des_and,out2
1412
1413 ld [in0], in5 ! left
1414 add in3, 120, in4 ! ks3
1415
1416 ld [in0+4], out5 ! right
1417 mov in2, in3 ! ks2
1418
1419 ! parameter 6 1/2 for include encryption/decryption
1420 ! parameter 7 1 for mov in1 to in3
1421 ! parameter 8 1 for mov in3 to in4
1422 ! parameter 9 1 for load ks3 and ks2 to in4 and in3
1423
1424 ip_macro(in5, out5, out5, in5, in4, 2, 0, 0, 0)
1425
1426 call .des_enc
1427 add in1, 120, in4 ! preload ks1
1428
1429 call .des_dec
1430 nop
1431
1432 fp_macro(out5, in5, 1)
1433
1434 ret
1435 restore
1436
1437.DES_decrypt3.end:
1438 .size DES_decrypt3,.DES_decrypt3.end-DES_decrypt3
1439
1440! void DES_ncbc_encrypt(input, output, length, schedule, ivec, enc)
1441! *****************************************************************
1442
1443
1444 .align 32
1445 .global DES_ncbc_encrypt
1446 .type DES_ncbc_encrypt,#function
1447
1448DES_ncbc_encrypt:
1449
1450 save %sp, FRAME, %sp
1451
1452 define({INPUT}, { [%sp+BIAS+ARG0+0*ARGSZ] })
1453 define({OUTPUT}, { [%sp+BIAS+ARG0+1*ARGSZ] })
1454 define({IVEC}, { [%sp+BIAS+ARG0+4*ARGSZ] })
1455
1456 sethi %hi(.PIC.DES_SPtrans-1f),global1
1457 or global1,%lo(.PIC.DES_SPtrans-1f),global1
14581: call .+8
1459 add %o7,global1,global1
1460 sub global1,.PIC.DES_SPtrans-.des_and,out2
1461
1462 cmp in5, 0 ! enc
1463
1464#ifdef OPENSSL_SYSNAME_ULTRASPARC
1465 be,pn %icc, .ncbc.dec
1466#else
1467 be .ncbc.dec
1468#endif
1469 STPTR in4, IVEC
1470
1471 ! addr left right temp label
1472 load_little_endian(in4, in5, out5, local3, .LLE1) ! iv
1473
1474 addcc in2, -8, in2 ! bytes missing when first block done
1475
1476#ifdef OPENSSL_SYSNAME_ULTRASPARC
1477 bl,pn %icc, .ncbc.enc.seven.or.less
1478#else
1479 bl .ncbc.enc.seven.or.less
1480#endif
1481 mov in3, in4 ! schedule
1482
1483.ncbc.enc.next.block:
1484
1485 load_little_endian(in0, out4, global4, local3, .LLE2) ! block
1486
1487.ncbc.enc.next.block_1:
1488
1489 xor in5, out4, in5 ! iv xor
1490 xor out5, global4, out5 ! iv xor
1491
1492 ! parameter 8 1 for move in3 to in4, 2 for move in4 to in3
1493 ip_macro(in5, out5, in5, out5, in3, 0, 0, 2)
1494
1495.ncbc.enc.next.block_2:
1496
1497!// call .des_enc ! compares in2 to 8
1498! rounds inlined for alignment purposes
1499
1500 add global1, 768, global4 ! address sbox 4 since register used below
1501
1502 rounds_macro(in5, out5, 1, .ncbc.enc.1, in3, in4) ! include encryption ks in3
1503
1504#ifdef OPENSSL_SYSNAME_ULTRASPARC
1505 bl,pn %icc, .ncbc.enc.next.block_fp
1506#else
1507 bl .ncbc.enc.next.block_fp
1508#endif
1509 add in0, 8, in0 ! input address
1510
1511 ! If 8 or more bytes are to be encrypted after this block,
1512 ! we combine final permutation for this block with initial
1513 ! permutation for next block. Load next block:
1514
1515 load_little_endian(in0, global3, global4, local5, .LLE12)
1516
1517 ! parameter 1 original left
1518 ! parameter 2 original right
1519 ! parameter 3 left ip
1520 ! parameter 4 right ip
1521 ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
1522 ! 2: mov in4 to in3
1523 !
1524 ! also adds -8 to length in2 and loads loop counter to out4
1525
1526 fp_ip_macro(out0, out1, global3, global4, 2)
1527
1528 store_little_endian(in1, out0, out1, local3, .SLE10) ! block
1529
1530 ld [in3], out0 ! key 7531 first round next block
1531 mov in5, local1
1532 xor global3, out5, in5 ! iv xor next block
1533
1534 ld [in3+4], out1 ! key 8642
1535 add global1, 512, global3 ! address sbox 3 since register used
1536 xor global4, local1, out5 ! iv xor next block
1537
1538 ba .ncbc.enc.next.block_2
1539 add in1, 8, in1 ! output adress
1540
1541.ncbc.enc.next.block_fp:
1542
1543 fp_macro(in5, out5)
1544
1545 store_little_endian(in1, in5, out5, local3, .SLE1) ! block
1546
1547 addcc in2, -8, in2 ! bytes missing when next block done
1548
1549#ifdef OPENSSL_SYSNAME_ULTRASPARC
1550 bpos,pt %icc, .ncbc.enc.next.block ! also jumps if 0
1551#else
1552 bpos .ncbc.enc.next.block
1553#endif
1554 add in1, 8, in1
1555
1556.ncbc.enc.seven.or.less:
1557
1558 cmp in2, -8
1559
1560#ifdef OPENSSL_SYSNAME_ULTRASPARC
1561 ble,pt %icc, .ncbc.enc.finish
1562#else
1563 ble .ncbc.enc.finish
1564#endif
1565 nop
1566
1567 add in2, 8, local1 ! bytes to load
1568
1569 ! addr, length, dest left, dest right, temp, temp2, label, ret label
1570 load_n_bytes(in0, local1, global4, out4, local2, local3, .LNB1, .ncbc.enc.next.block_1)
1571
1572 ! Loads 1 to 7 bytes little endian to global4, out4
1573
1574
1575.ncbc.enc.finish:
1576
1577 LDPTR IVEC, local4
1578 store_little_endian(local4, in5, out5, local5, .SLE2) ! ivec
1579
1580 ret
1581 restore
1582
1583
1584.ncbc.dec:
1585
1586 STPTR in0, INPUT
1587 cmp in2, 0 ! length
1588 add in3, 120, in3
1589
1590 LDPTR IVEC, local7 ! ivec
1591#ifdef OPENSSL_SYSNAME_ULTRASPARC
1592 ble,pn %icc, .ncbc.dec.finish
1593#else
1594 ble .ncbc.dec.finish
1595#endif
1596 mov in3, in4 ! schedule
1597
1598 STPTR in1, OUTPUT
1599 mov in0, local5 ! input
1600
1601 load_little_endian(local7, in0, in1, local3, .LLE3) ! ivec
1602
1603.ncbc.dec.next.block:
1604
1605 load_little_endian(local5, in5, out5, local3, .LLE4) ! block
1606
1607 ! parameter 6 1/2 for include encryption/decryption
1608 ! parameter 7 1 for mov in1 to in3
1609 ! parameter 8 1 for mov in3 to in4
1610
1611 ip_macro(in5, out5, out5, in5, in4, 2, 0, 1) ! include decryprion ks in4
1612
1613 fp_macro(out5, in5, 0, 1) ! 1 for input and output address to local5/7
1614
1615 ! in2 is bytes left to be stored
1616 ! in2 is compared to 8 in the rounds
1617
1618 xor out5, in0, out4 ! iv xor
1619#ifdef OPENSSL_SYSNAME_ULTRASPARC
1620 bl,pn %icc, .ncbc.dec.seven.or.less
1621#else
1622 bl .ncbc.dec.seven.or.less
1623#endif
1624 xor in5, in1, global4 ! iv xor
1625
1626 ! Load ivec next block now, since input and output address might be the same.
1627
1628 load_little_endian_inc(local5, in0, in1, local3, .LLE5) ! iv
1629
1630 store_little_endian(local7, out4, global4, local3, .SLE3)
1631
1632 STPTR local5, INPUT
1633 add local7, 8, local7
1634 addcc in2, -8, in2
1635
1636#ifdef OPENSSL_SYSNAME_ULTRASPARC
1637 bg,pt %icc, .ncbc.dec.next.block
1638#else
1639 bg .ncbc.dec.next.block
1640#endif
1641 STPTR local7, OUTPUT
1642
1643
1644.ncbc.dec.store.iv:
1645
1646 LDPTR IVEC, local4 ! ivec
1647 store_little_endian(local4, in0, in1, local5, .SLE4)
1648
1649.ncbc.dec.finish:
1650
1651 ret
1652 restore
1653
1654.ncbc.dec.seven.or.less:
1655
1656 load_little_endian_inc(local5, in0, in1, local3, .LLE13) ! ivec
1657
1658 store_n_bytes(local7, in2, global4, out4, local3, local4, .SNB1, .ncbc.dec.store.iv)
1659
1660
1661.DES_ncbc_encrypt.end:
1662 .size DES_ncbc_encrypt, .DES_ncbc_encrypt.end-DES_ncbc_encrypt
1663
1664
1665! void DES_ede3_cbc_encrypt(input, output, lenght, ks1, ks2, ks3, ivec, enc)
1666! **************************************************************************
1667
1668
1669 .align 32
1670 .global DES_ede3_cbc_encrypt
1671 .type DES_ede3_cbc_encrypt,#function
1672
1673DES_ede3_cbc_encrypt:
1674
1675 save %sp, FRAME, %sp
1676
1677 define({KS1}, { [%sp+BIAS+ARG0+3*ARGSZ] })
1678 define({KS2}, { [%sp+BIAS+ARG0+4*ARGSZ] })
1679 define({KS3}, { [%sp+BIAS+ARG0+5*ARGSZ] })
1680
1681 sethi %hi(.PIC.DES_SPtrans-1f),global1
1682 or global1,%lo(.PIC.DES_SPtrans-1f),global1
16831: call .+8
1684 add %o7,global1,global1
1685 sub global1,.PIC.DES_SPtrans-.des_and,out2
1686
1687 LDPTR [%fp+BIAS+ARG0+7*ARGSZ], local3 ! enc
1688 LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
1689 cmp local3, 0 ! enc
1690
1691#ifdef OPENSSL_SYSNAME_ULTRASPARC
1692 be,pn %icc, .ede3.dec
1693#else
1694 be .ede3.dec
1695#endif
1696 STPTR in4, KS2
1697
1698 STPTR in5, KS3
1699
1700 load_little_endian(local4, in5, out5, local3, .LLE6) ! ivec
1701
1702 addcc in2, -8, in2 ! bytes missing after next block
1703
1704#ifdef OPENSSL_SYSNAME_ULTRASPARC
1705 bl,pn %icc, .ede3.enc.seven.or.less
1706#else
1707 bl .ede3.enc.seven.or.less
1708#endif
1709 STPTR in3, KS1
1710
1711.ede3.enc.next.block:
1712
1713 load_little_endian(in0, out4, global4, local3, .LLE7)
1714
1715.ede3.enc.next.block_1:
1716
1717 LDPTR KS2, in4
1718 xor in5, out4, in5 ! iv xor
1719 xor out5, global4, out5 ! iv xor
1720
1721 LDPTR KS1, in3
1722 add in4, 120, in4 ! for decryption we use last subkey first
1723 nop
1724
1725 ip_macro(in5, out5, in5, out5, in3)
1726
1727.ede3.enc.next.block_2:
1728
1729 call .des_enc ! ks1 in3
1730 nop
1731
1732 call .des_dec ! ks2 in4
1733 LDPTR KS3, in3
1734
1735 call .des_enc ! ks3 in3 compares in2 to 8
1736 nop
1737
1738#ifdef OPENSSL_SYSNAME_ULTRASPARC
1739 bl,pn %icc, .ede3.enc.next.block_fp
1740#else
1741 bl .ede3.enc.next.block_fp
1742#endif
1743 add in0, 8, in0
1744
1745 ! If 8 or more bytes are to be encrypted after this block,
1746 ! we combine final permutation for this block with initial
1747 ! permutation for next block. Load next block:
1748
1749 load_little_endian(in0, global3, global4, local5, .LLE11)
1750
1751 ! parameter 1 original left
1752 ! parameter 2 original right
1753 ! parameter 3 left ip
1754 ! parameter 4 right ip
1755 ! parameter 5 1: load ks1/ks2 to in3/in4, add 120 to in4
1756 ! 2: mov in4 to in3
1757 !
1758 ! also adds -8 to length in2 and loads loop counter to out4
1759
1760 fp_ip_macro(out0, out1, global3, global4, 1)
1761
1762 store_little_endian(in1, out0, out1, local3, .SLE9) ! block
1763
1764 mov in5, local1
1765 xor global3, out5, in5 ! iv xor next block
1766
1767 ld [in3], out0 ! key 7531
1768 add global1, 512, global3 ! address sbox 3
1769 xor global4, local1, out5 ! iv xor next block
1770
1771 ld [in3+4], out1 ! key 8642
1772 add global1, 768, global4 ! address sbox 4
1773 ba .ede3.enc.next.block_2
1774 add in1, 8, in1
1775
1776.ede3.enc.next.block_fp:
1777
1778 fp_macro(in5, out5)
1779
1780 store_little_endian(in1, in5, out5, local3, .SLE5) ! block
1781
1782 addcc in2, -8, in2 ! bytes missing when next block done
1783
1784#ifdef OPENSSL_SYSNAME_ULTRASPARC
1785 bpos,pt %icc, .ede3.enc.next.block
1786#else
1787 bpos .ede3.enc.next.block
1788#endif
1789 add in1, 8, in1
1790
1791.ede3.enc.seven.or.less:
1792
1793 cmp in2, -8
1794
1795#ifdef OPENSSL_SYSNAME_ULTRASPARC
1796 ble,pt %icc, .ede3.enc.finish
1797#else
1798 ble .ede3.enc.finish
1799#endif
1800 nop
1801
1802 add in2, 8, local1 ! bytes to load
1803
1804 ! addr, length, dest left, dest right, temp, temp2, label, ret label
1805 load_n_bytes(in0, local1, global4, out4, local2, local3, .LNB2, .ede3.enc.next.block_1)
1806
1807.ede3.enc.finish:
1808
1809 LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
1810 store_little_endian(local4, in5, out5, local5, .SLE6) ! ivec
1811
1812 ret
1813 restore
1814
1815.ede3.dec:
1816
1817 STPTR in0, INPUT
1818 add in5, 120, in5
1819
1820 STPTR in1, OUTPUT
1821 mov in0, local5
1822 add in3, 120, in3
1823
1824 STPTR in3, KS1
1825 cmp in2, 0
1826
1827#ifdef OPENSSL_SYSNAME_ULTRASPARC
1828 ble %icc, .ede3.dec.finish
1829#else
1830 ble .ede3.dec.finish
1831#endif
1832 STPTR in5, KS3
1833
1834 LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local7 ! iv
1835 load_little_endian(local7, in0, in1, local3, .LLE8)
1836
1837.ede3.dec.next.block:
1838
1839 load_little_endian(local5, in5, out5, local3, .LLE9)
1840
1841 ! parameter 6 1/2 for include encryption/decryption
1842 ! parameter 7 1 for mov in1 to in3
1843 ! parameter 8 1 for mov in3 to in4
1844 ! parameter 9 1 for load ks3 and ks2 to in4 and in3
1845
1846 ip_macro(in5, out5, out5, in5, in4, 2, 0, 0, 1) ! inc .des_dec ks3 in4
1847
1848 call .des_enc ! ks2 in3
1849 LDPTR KS1, in4
1850
1851 call .des_dec ! ks1 in4
1852 nop
1853
1854 fp_macro(out5, in5, 0, 1) ! 1 for input and output address local5/7
1855
1856 ! in2 is bytes left to be stored
1857 ! in2 is compared to 8 in the rounds
1858
1859 xor out5, in0, out4
1860#ifdef OPENSSL_SYSNAME_ULTRASPARC
1861 bl,pn %icc, .ede3.dec.seven.or.less
1862#else
1863 bl .ede3.dec.seven.or.less
1864#endif
1865 xor in5, in1, global4
1866
1867 load_little_endian_inc(local5, in0, in1, local3, .LLE10) ! iv next block
1868
1869 store_little_endian(local7, out4, global4, local3, .SLE7) ! block
1870
1871 STPTR local5, INPUT
1872 addcc in2, -8, in2
1873 add local7, 8, local7
1874
1875#ifdef OPENSSL_SYSNAME_ULTRASPARC
1876 bg,pt %icc, .ede3.dec.next.block
1877#else
1878 bg .ede3.dec.next.block
1879#endif
1880 STPTR local7, OUTPUT
1881
1882.ede3.dec.store.iv:
1883
1884 LDPTR [%fp+BIAS+ARG0+6*ARGSZ], local4 ! ivec
1885 store_little_endian(local4, in0, in1, local5, .SLE8) ! ivec
1886
1887.ede3.dec.finish:
1888
1889 ret
1890 restore
1891
1892.ede3.dec.seven.or.less:
1893
1894 load_little_endian_inc(local5, in0, in1, local3, .LLE14) ! iv
1895
1896 store_n_bytes(local7, in2, global4, out4, local3, local4, .SNB2, .ede3.dec.store.iv)
1897
1898
1899.DES_ede3_cbc_encrypt.end:
1900 .size DES_ede3_cbc_encrypt,.DES_ede3_cbc_encrypt.end-DES_ede3_cbc_encrypt
1901
1902 .align 256
1903 .type .des_and,#object
1904 .size .des_and,284
1905
1906.des_and:
1907
1908! This table is used for AND 0xFC when it is known that register
1909! bits 8-31 are zero. Makes it possible to do three arithmetic
1910! operations in one cycle.
1911
1912 .byte 0, 0, 0, 0, 4, 4, 4, 4
1913 .byte 8, 8, 8, 8, 12, 12, 12, 12
1914 .byte 16, 16, 16, 16, 20, 20, 20, 20
1915 .byte 24, 24, 24, 24, 28, 28, 28, 28
1916 .byte 32, 32, 32, 32, 36, 36, 36, 36
1917 .byte 40, 40, 40, 40, 44, 44, 44, 44
1918 .byte 48, 48, 48, 48, 52, 52, 52, 52
1919 .byte 56, 56, 56, 56, 60, 60, 60, 60
1920 .byte 64, 64, 64, 64, 68, 68, 68, 68
1921 .byte 72, 72, 72, 72, 76, 76, 76, 76
1922 .byte 80, 80, 80, 80, 84, 84, 84, 84
1923 .byte 88, 88, 88, 88, 92, 92, 92, 92
1924 .byte 96, 96, 96, 96, 100, 100, 100, 100
1925 .byte 104, 104, 104, 104, 108, 108, 108, 108
1926 .byte 112, 112, 112, 112, 116, 116, 116, 116
1927 .byte 120, 120, 120, 120, 124, 124, 124, 124
1928 .byte 128, 128, 128, 128, 132, 132, 132, 132
1929 .byte 136, 136, 136, 136, 140, 140, 140, 140
1930 .byte 144, 144, 144, 144, 148, 148, 148, 148
1931 .byte 152, 152, 152, 152, 156, 156, 156, 156
1932 .byte 160, 160, 160, 160, 164, 164, 164, 164
1933 .byte 168, 168, 168, 168, 172, 172, 172, 172
1934 .byte 176, 176, 176, 176, 180, 180, 180, 180
1935 .byte 184, 184, 184, 184, 188, 188, 188, 188
1936 .byte 192, 192, 192, 192, 196, 196, 196, 196
1937 .byte 200, 200, 200, 200, 204, 204, 204, 204
1938 .byte 208, 208, 208, 208, 212, 212, 212, 212
1939 .byte 216, 216, 216, 216, 220, 220, 220, 220
1940 .byte 224, 224, 224, 224, 228, 228, 228, 228
1941 .byte 232, 232, 232, 232, 236, 236, 236, 236
1942 .byte 240, 240, 240, 240, 244, 244, 244, 244
1943 .byte 248, 248, 248, 248, 252, 252, 252, 252
1944
1945 ! 5 numbers for initil/final permutation
1946
1947 .word 0x0f0f0f0f ! offset 256
1948 .word 0x0000ffff ! 260
1949 .word 0x33333333 ! 264
1950 .word 0x00ff00ff ! 268
1951 .word 0x55555555 ! 272
1952
1953 .word 0 ! 276
1954 .word LOOPS ! 280
1955 .word 0x0000FC00 ! 284
1956
1957 .global DES_SPtrans
1958 .type DES_SPtrans,#object
1959 .size DES_SPtrans,2048
1960.align 64
1961DES_SPtrans:
1962.PIC.DES_SPtrans:
1963 ! nibble 0
1964 .word 0x02080800, 0x00080000, 0x02000002, 0x02080802
1965 .word 0x02000000, 0x00080802, 0x00080002, 0x02000002
1966 .word 0x00080802, 0x02080800, 0x02080000, 0x00000802
1967 .word 0x02000802, 0x02000000, 0x00000000, 0x00080002
1968 .word 0x00080000, 0x00000002, 0x02000800, 0x00080800
1969 .word 0x02080802, 0x02080000, 0x00000802, 0x02000800
1970 .word 0x00000002, 0x00000800, 0x00080800, 0x02080002
1971 .word 0x00000800, 0x02000802, 0x02080002, 0x00000000
1972 .word 0x00000000, 0x02080802, 0x02000800, 0x00080002
1973 .word 0x02080800, 0x00080000, 0x00000802, 0x02000800
1974 .word 0x02080002, 0x00000800, 0x00080800, 0x02000002
1975 .word 0x00080802, 0x00000002, 0x02000002, 0x02080000
1976 .word 0x02080802, 0x00080800, 0x02080000, 0x02000802
1977 .word 0x02000000, 0x00000802, 0x00080002, 0x00000000
1978 .word 0x00080000, 0x02000000, 0x02000802, 0x02080800
1979 .word 0x00000002, 0x02080002, 0x00000800, 0x00080802
1980 ! nibble 1
1981 .word 0x40108010, 0x00000000, 0x00108000, 0x40100000
1982 .word 0x40000010, 0x00008010, 0x40008000, 0x00108000
1983 .word 0x00008000, 0x40100010, 0x00000010, 0x40008000
1984 .word 0x00100010, 0x40108000, 0x40100000, 0x00000010
1985 .word 0x00100000, 0x40008010, 0x40100010, 0x00008000
1986 .word 0x00108010, 0x40000000, 0x00000000, 0x00100010
1987 .word 0x40008010, 0x00108010, 0x40108000, 0x40000010
1988 .word 0x40000000, 0x00100000, 0x00008010, 0x40108010
1989 .word 0x00100010, 0x40108000, 0x40008000, 0x00108010
1990 .word 0x40108010, 0x00100010, 0x40000010, 0x00000000
1991 .word 0x40000000, 0x00008010, 0x00100000, 0x40100010
1992 .word 0x00008000, 0x40000000, 0x00108010, 0x40008010
1993 .word 0x40108000, 0x00008000, 0x00000000, 0x40000010
1994 .word 0x00000010, 0x40108010, 0x00108000, 0x40100000
1995 .word 0x40100010, 0x00100000, 0x00008010, 0x40008000
1996 .word 0x40008010, 0x00000010, 0x40100000, 0x00108000
1997 ! nibble 2
1998 .word 0x04000001, 0x04040100, 0x00000100, 0x04000101
1999 .word 0x00040001, 0x04000000, 0x04000101, 0x00040100
2000 .word 0x04000100, 0x00040000, 0x04040000, 0x00000001
2001 .word 0x04040101, 0x00000101, 0x00000001, 0x04040001
2002 .word 0x00000000, 0x00040001, 0x04040100, 0x00000100
2003 .word 0x00000101, 0x04040101, 0x00040000, 0x04000001
2004 .word 0x04040001, 0x04000100, 0x00040101, 0x04040000
2005 .word 0x00040100, 0x00000000, 0x04000000, 0x00040101
2006 .word 0x04040100, 0x00000100, 0x00000001, 0x00040000
2007 .word 0x00000101, 0x00040001, 0x04040000, 0x04000101
2008 .word 0x00000000, 0x04040100, 0x00040100, 0x04040001
2009 .word 0x00040001, 0x04000000, 0x04040101, 0x00000001
2010 .word 0x00040101, 0x04000001, 0x04000000, 0x04040101
2011 .word 0x00040000, 0x04000100, 0x04000101, 0x00040100
2012 .word 0x04000100, 0x00000000, 0x04040001, 0x00000101
2013 .word 0x04000001, 0x00040101, 0x00000100, 0x04040000
2014 ! nibble 3
2015 .word 0x00401008, 0x10001000, 0x00000008, 0x10401008
2016 .word 0x00000000, 0x10400000, 0x10001008, 0x00400008
2017 .word 0x10401000, 0x10000008, 0x10000000, 0x00001008
2018 .word 0x10000008, 0x00401008, 0x00400000, 0x10000000
2019 .word 0x10400008, 0x00401000, 0x00001000, 0x00000008
2020 .word 0x00401000, 0x10001008, 0x10400000, 0x00001000
2021 .word 0x00001008, 0x00000000, 0x00400008, 0x10401000
2022 .word 0x10001000, 0x10400008, 0x10401008, 0x00400000
2023 .word 0x10400008, 0x00001008, 0x00400000, 0x10000008
2024 .word 0x00401000, 0x10001000, 0x00000008, 0x10400000
2025 .word 0x10001008, 0x00000000, 0x00001000, 0x00400008
2026 .word 0x00000000, 0x10400008, 0x10401000, 0x00001000
2027 .word 0x10000000, 0x10401008, 0x00401008, 0x00400000
2028 .word 0x10401008, 0x00000008, 0x10001000, 0x00401008
2029 .word 0x00400008, 0x00401000, 0x10400000, 0x10001008
2030 .word 0x00001008, 0x10000000, 0x10000008, 0x10401000
2031 ! nibble 4
2032 .word 0x08000000, 0x00010000, 0x00000400, 0x08010420
2033 .word 0x08010020, 0x08000400, 0x00010420, 0x08010000
2034 .word 0x00010000, 0x00000020, 0x08000020, 0x00010400
2035 .word 0x08000420, 0x08010020, 0x08010400, 0x00000000
2036 .word 0x00010400, 0x08000000, 0x00010020, 0x00000420
2037 .word 0x08000400, 0x00010420, 0x00000000, 0x08000020
2038 .word 0x00000020, 0x08000420, 0x08010420, 0x00010020
2039 .word 0x08010000, 0x00000400, 0x00000420, 0x08010400
2040 .word 0x08010400, 0x08000420, 0x00010020, 0x08010000
2041 .word 0x00010000, 0x00000020, 0x08000020, 0x08000400
2042 .word 0x08000000, 0x00010400, 0x08010420, 0x00000000
2043 .word 0x00010420, 0x08000000, 0x00000400, 0x00010020
2044 .word 0x08000420, 0x00000400, 0x00000000, 0x08010420
2045 .word 0x08010020, 0x08010400, 0x00000420, 0x00010000
2046 .word 0x00010400, 0x08010020, 0x08000400, 0x00000420
2047 .word 0x00000020, 0x00010420, 0x08010000, 0x08000020
2048 ! nibble 5
2049 .word 0x80000040, 0x00200040, 0x00000000, 0x80202000
2050 .word 0x00200040, 0x00002000, 0x80002040, 0x00200000
2051 .word 0x00002040, 0x80202040, 0x00202000, 0x80000000
2052 .word 0x80002000, 0x80000040, 0x80200000, 0x00202040
2053 .word 0x00200000, 0x80002040, 0x80200040, 0x00000000
2054 .word 0x00002000, 0x00000040, 0x80202000, 0x80200040
2055 .word 0x80202040, 0x80200000, 0x80000000, 0x00002040
2056 .word 0x00000040, 0x00202000, 0x00202040, 0x80002000
2057 .word 0x00002040, 0x80000000, 0x80002000, 0x00202040
2058 .word 0x80202000, 0x00200040, 0x00000000, 0x80002000
2059 .word 0x80000000, 0x00002000, 0x80200040, 0x00200000
2060 .word 0x00200040, 0x80202040, 0x00202000, 0x00000040
2061 .word 0x80202040, 0x00202000, 0x00200000, 0x80002040
2062 .word 0x80000040, 0x80200000, 0x00202040, 0x00000000
2063 .word 0x00002000, 0x80000040, 0x80002040, 0x80202000
2064 .word 0x80200000, 0x00002040, 0x00000040, 0x80200040
2065 ! nibble 6
2066 .word 0x00004000, 0x00000200, 0x01000200, 0x01000004
2067 .word 0x01004204, 0x00004004, 0x00004200, 0x00000000
2068 .word 0x01000000, 0x01000204, 0x00000204, 0x01004000
2069 .word 0x00000004, 0x01004200, 0x01004000, 0x00000204
2070 .word 0x01000204, 0x00004000, 0x00004004, 0x01004204
2071 .word 0x00000000, 0x01000200, 0x01000004, 0x00004200
2072 .word 0x01004004, 0x00004204, 0x01004200, 0x00000004
2073 .word 0x00004204, 0x01004004, 0x00000200, 0x01000000
2074 .word 0x00004204, 0x01004000, 0x01004004, 0x00000204
2075 .word 0x00004000, 0x00000200, 0x01000000, 0x01004004
2076 .word 0x01000204, 0x00004204, 0x00004200, 0x00000000
2077 .word 0x00000200, 0x01000004, 0x00000004, 0x01000200
2078 .word 0x00000000, 0x01000204, 0x01000200, 0x00004200
2079 .word 0x00000204, 0x00004000, 0x01004204, 0x01000000
2080 .word 0x01004200, 0x00000004, 0x00004004, 0x01004204
2081 .word 0x01000004, 0x01004200, 0x01004000, 0x00004004
2082 ! nibble 7
2083 .word 0x20800080, 0x20820000, 0x00020080, 0x00000000
2084 .word 0x20020000, 0x00800080, 0x20800000, 0x20820080
2085 .word 0x00000080, 0x20000000, 0x00820000, 0x00020080
2086 .word 0x00820080, 0x20020080, 0x20000080, 0x20800000
2087 .word 0x00020000, 0x00820080, 0x00800080, 0x20020000
2088 .word 0x20820080, 0x20000080, 0x00000000, 0x00820000
2089 .word 0x20000000, 0x00800000, 0x20020080, 0x20800080
2090 .word 0x00800000, 0x00020000, 0x20820000, 0x00000080
2091 .word 0x00800000, 0x00020000, 0x20000080, 0x20820080
2092 .word 0x00020080, 0x20000000, 0x00000000, 0x00820000
2093 .word 0x20800080, 0x20020080, 0x20020000, 0x00800080
2094 .word 0x20820000, 0x00000080, 0x00800080, 0x20020000
2095 .word 0x20820080, 0x00800000, 0x20800000, 0x20000080
2096 .word 0x00820000, 0x00020080, 0x20020080, 0x20800000
2097 .word 0x00000080, 0x20820000, 0x00820080, 0x00000000
2098 .word 0x20000000, 0x20800080, 0x00020000, 0x00820080
2099
diff --git a/src/lib/libcrypto/des/asm/desboth.pl b/src/lib/libcrypto/des/asm/desboth.pl
deleted file mode 100644
index eec00886e4..0000000000
--- a/src/lib/libcrypto/des/asm/desboth.pl
+++ /dev/null
@@ -1,79 +0,0 @@
1#!/usr/local/bin/perl
2
3$L="edi";
4$R="esi";
5
6sub DES_encrypt3
7 {
8 local($name,$enc)=@_;
9
10 &function_begin_B($name,"");
11 &push("ebx");
12 &mov("ebx",&wparam(0));
13
14 &push("ebp");
15 &push("esi");
16
17 &push("edi");
18
19 &comment("");
20 &comment("Load the data words");
21 &mov($L,&DWP(0,"ebx","",0));
22 &mov($R,&DWP(4,"ebx","",0));
23 &stack_push(3);
24
25 &comment("");
26 &comment("IP");
27 &IP_new($L,$R,"edx",0);
28
29 # put them back
30
31 if ($enc)
32 {
33 &mov(&DWP(4,"ebx","",0),$R);
34 &mov("eax",&wparam(1));
35 &mov(&DWP(0,"ebx","",0),"edx");
36 &mov("edi",&wparam(2));
37 &mov("esi",&wparam(3));
38 }
39 else
40 {
41 &mov(&DWP(4,"ebx","",0),$R);
42 &mov("esi",&wparam(1));
43 &mov(&DWP(0,"ebx","",0),"edx");
44 &mov("edi",&wparam(2));
45 &mov("eax",&wparam(3));
46 }
47 &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
48 &mov(&swtmp(1), "eax");
49 &mov(&swtmp(0), "ebx");
50 &call("DES_encrypt2");
51 &mov(&swtmp(2), (DWC(($enc)?"0":"1")));
52 &mov(&swtmp(1), "edi");
53 &mov(&swtmp(0), "ebx");
54 &call("DES_encrypt2");
55 &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
56 &mov(&swtmp(1), "esi");
57 &mov(&swtmp(0), "ebx");
58 &call("DES_encrypt2");
59
60 &stack_pop(3);
61 &mov($L,&DWP(0,"ebx","",0));
62 &mov($R,&DWP(4,"ebx","",0));
63
64 &comment("");
65 &comment("FP");
66 &FP_new($L,$R,"eax",0);
67
68 &mov(&DWP(0,"ebx","",0),"eax");
69 &mov(&DWP(4,"ebx","",0),$R);
70
71 &pop("edi");
72 &pop("esi");
73 &pop("ebp");
74 &pop("ebx");
75 &ret();
76 &function_end_B($name);
77 }
78
79
diff --git a/src/lib/libcrypto/des/asm/readme b/src/lib/libcrypto/des/asm/readme
deleted file mode 100644
index 1beafe253b..0000000000
--- a/src/lib/libcrypto/des/asm/readme
+++ /dev/null
@@ -1,131 +0,0 @@
1First up, let me say I don't like writing in assembler. It is not portable,
2dependant on the particular CPU architecture release and is generally a pig
3to debug and get right. Having said that, the x86 architecture is probably
4the most important for speed due to number of boxes and since
5it appears to be the worst architecture to to get
6good C compilers for. So due to this, I have lowered myself to do
7assembler for the inner DES routines in libdes :-).
8
9The file to implement in assembler is des_enc.c. Replace the following
104 functions
11des_encrypt1(DES_LONG data[2],des_key_schedule ks, int encrypt);
12des_encrypt2(DES_LONG data[2],des_key_schedule ks, int encrypt);
13des_encrypt3(DES_LONG data[2],des_key_schedule ks1,ks2,ks3);
14des_decrypt3(DES_LONG data[2],des_key_schedule ks1,ks2,ks3);
15
16They encrypt/decrypt the 64 bits held in 'data' using
17the 'ks' key schedules. The only difference between the 4 functions is that
18des_encrypt2() does not perform IP() or FP() on the data (this is an
19optimization for when doing triple DES and des_encrypt3() and des_decrypt3()
20perform triple des. The triple DES routines are in here because it does
21make a big difference to have them located near the des_encrypt2 function
22at link time..
23
24Now as we all know, there are lots of different operating systems running on
25x86 boxes, and unfortunately they normally try to make sure their assembler
26formating is not the same as the other peoples.
27The 4 main formats I know of are
28Microsoft Windows 95/Windows NT
29Elf Includes Linux and FreeBSD(?).
30a.out The older Linux.
31Solaris Same as Elf but different comments :-(.
32
33Now I was not overly keen to write 4 different copies of the same code,
34so I wrote a few perl routines to output the correct assembler, given
35a target assembler type. This code is ugly and is just a hack.
36The libraries are x86unix.pl and x86ms.pl.
37des586.pl, des686.pl and des-som[23].pl are the programs to actually
38generate the assembler.
39
40So to generate elf assembler
41perl des-som3.pl elf >dx86-elf.s
42For Windows 95/NT
43perl des-som2.pl win32 >win32.asm
44
45[ update 4 Jan 1996 ]
46I have added another way to do things.
47perl des-som3.pl cpp >dx86-cpp.s
48generates a file that will be included by dx86unix.cpp when it is compiled.
49To build for elf, a.out, solaris, bsdi etc,
50cc -E -DELF asm/dx86unix.cpp | as -o asm/dx86-elf.o
51cc -E -DSOL asm/dx86unix.cpp | as -o asm/dx86-sol.o
52cc -E -DOUT asm/dx86unix.cpp | as -o asm/dx86-out.o
53cc -E -DBSDI asm/dx86unix.cpp | as -o asm/dx86bsdi.o
54This was done to cut down the number of files in the distribution.
55
56Now the ugly part. I acquired my copy of Intels
57"Optimization's For Intel's 32-Bit Processors" and found a few interesting
58things. First, the aim of the exersize is to 'extract' one byte at a time
59from a word and do an array lookup. This involves getting the byte from
60the 4 locations in the word and moving it to a new word and doing the lookup.
61The most obvious way to do this is
62xor eax, eax # clear word
63movb al, cl # get low byte
64xor edi DWORD PTR 0x100+des_SP[eax] # xor in word
65movb al, ch # get next byte
66xor edi DWORD PTR 0x300+des_SP[eax] # xor in word
67shr ecx 16
68which seems ok. For the pentium, this system appears to be the best.
69One has to do instruction interleaving to keep both functional units
70operating, but it is basically very efficient.
71
72Now the crunch. When a full register is used after a partial write, eg.
73mov al, cl
74xor edi, DWORD PTR 0x100+des_SP[eax]
75386 - 1 cycle stall
76486 - 1 cycle stall
77586 - 0 cycle stall
78686 - at least 7 cycle stall (page 22 of the above mentioned document).
79
80So the technique that produces the best results on a pentium, according to
81the documentation, will produce hideous results on a pentium pro.
82
83To get around this, des686.pl will generate code that is not as fast on
84a pentium, should be very good on a pentium pro.
85mov eax, ecx # copy word
86shr ecx, 8 # line up next byte
87and eax, 0fch # mask byte
88xor edi DWORD PTR 0x100+des_SP[eax] # xor in array lookup
89mov eax, ecx # get word
90shr ecx 8 # line up next byte
91and eax, 0fch # mask byte
92xor edi DWORD PTR 0x300+des_SP[eax] # xor in array lookup
93
94Due to the execution units in the pentium, this actually works quite well.
95For a pentium pro it should be very good. This is the type of output
96Visual C++ generates.
97
98There is a third option. instead of using
99mov al, ch
100which is bad on the pentium pro, one may be able to use
101movzx eax, ch
102which may not incur the partial write penalty. On the pentium,
103this instruction takes 4 cycles so is not worth using but on the
104pentium pro it appears it may be worth while. I need access to one to
105experiment :-).
106
107eric (20 Oct 1996)
108
10922 Nov 1996 - I have asked people to run the 2 different version on pentium
110pros and it appears that the intel documentation is wrong. The
111mov al,bh is still faster on a pentium pro, so just use the des586.pl
112install des686.pl
113
1143 Dec 1996 - I added des_encrypt3/des_decrypt3 because I have moved these
115functions into des_enc.c because it does make a massive performance
116difference on some boxes to have the functions code located close to
117the des_encrypt2() function.
118
1199 Jan 1997 - des-som2.pl is now the correct perl script to use for
120pentiums. It contains an inner loop from
121Svend Olaf Mikkelsen <svolaf@inet.uni-c.dk> which does raw ecb DES calls at
122273,000 per second. He had a previous version at 250,000 and the best
123I was able to get was 203,000. The content has not changed, this is all
124due to instruction sequencing (and actual instructions choice) which is able
125to keep both functional units of the pentium going.
126We may have lost the ugly register usage restrictions when x86 went 32 bit
127but for the pentium it has been replaced by evil instruction ordering tricks.
128
12913 Jan 1997 - des-som3.pl, more optimizations from Svend Olaf.
130raw DES at 281,000 per second on a pentium 100.
131
diff --git a/src/lib/libcrypto/des/cbc3_enc.c b/src/lib/libcrypto/des/cbc3_enc.c
deleted file mode 100644
index b5db4e14f7..0000000000
--- a/src/lib/libcrypto/des/cbc3_enc.c
+++ /dev/null
@@ -1,99 +0,0 @@
1/* crypto/des/cbc3_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60
61/* HAS BUGS! DON'T USE - this is only present for use in des.c */
62void DES_3cbc_encrypt(DES_cblock *input, DES_cblock *output, long length,
63 DES_key_schedule ks1, DES_key_schedule ks2, DES_cblock *iv1,
64 DES_cblock *iv2, int enc)
65 {
66 int off=((int)length-1)/8;
67 long l8=((length+7)/8)*8;
68 DES_cblock niv1,niv2;
69
70 if (enc == DES_ENCRYPT)
71 {
72 DES_cbc_encrypt((unsigned char*)input,
73 (unsigned char*)output,length,&ks1,iv1,enc);
74 if (length >= sizeof(DES_cblock))
75 memcpy(niv1,output[off],sizeof(DES_cblock));
76 DES_cbc_encrypt((unsigned char*)output,
77 (unsigned char*)output,l8,&ks2,iv1,!enc);
78 DES_cbc_encrypt((unsigned char*)output,
79 (unsigned char*)output,l8,&ks1,iv2,enc);
80 if (length >= sizeof(DES_cblock))
81 memcpy(niv2,output[off],sizeof(DES_cblock));
82 }
83 else
84 {
85 if (length >= sizeof(DES_cblock))
86 memcpy(niv2,input[off],sizeof(DES_cblock));
87 DES_cbc_encrypt((unsigned char*)input,
88 (unsigned char*)output,l8,&ks1,iv2,enc);
89 DES_cbc_encrypt((unsigned char*)output,
90 (unsigned char*)output,l8,&ks2,iv1,!enc);
91 if (length >= sizeof(DES_cblock))
92 memcpy(niv1,output[off],sizeof(DES_cblock));
93 DES_cbc_encrypt((unsigned char*)output,
94 (unsigned char*)output,length,&ks1,iv1,enc);
95 }
96 memcpy(*iv1,niv1,sizeof(DES_cblock));
97 memcpy(*iv2,niv2,sizeof(DES_cblock));
98 }
99
diff --git a/src/lib/libcrypto/des/cbc_cksm.c b/src/lib/libcrypto/des/cbc_cksm.c
deleted file mode 100644
index 09a7ba56aa..0000000000
--- a/src/lib/libcrypto/des/cbc_cksm.c
+++ /dev/null
@@ -1,106 +0,0 @@
1/* crypto/des/cbc_cksm.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60
61DES_LONG DES_cbc_cksum(const unsigned char *in, DES_cblock *output,
62 long length, DES_key_schedule *schedule,
63 const_DES_cblock *ivec)
64 {
65 register DES_LONG tout0,tout1,tin0,tin1;
66 register long l=length;
67 DES_LONG tin[2];
68 unsigned char *out = &(*output)[0];
69 const unsigned char *iv = &(*ivec)[0];
70
71 c2l(iv,tout0);
72 c2l(iv,tout1);
73 for (; l>0; l-=8)
74 {
75 if (l >= 8)
76 {
77 c2l(in,tin0);
78 c2l(in,tin1);
79 }
80 else
81 c2ln(in,tin0,tin1,l);
82
83 tin0^=tout0; tin[0]=tin0;
84 tin1^=tout1; tin[1]=tin1;
85 DES_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
86 /* fix 15/10/91 eay - thanks to keithr@sco.COM */
87 tout0=tin[0];
88 tout1=tin[1];
89 }
90 if (out != NULL)
91 {
92 l2c(tout0,out);
93 l2c(tout1,out);
94 }
95 tout0=tin0=tin1=tin[0]=tin[1]=0;
96 /*
97 Transform the data in tout1 so that it will
98 match the return value that the MIT Kerberos
99 mit_des_cbc_cksum API returns.
100 */
101 tout1 = ((tout1 >> 24L) & 0x000000FF)
102 | ((tout1 >> 8L) & 0x0000FF00)
103 | ((tout1 << 8L) & 0x00FF0000)
104 | ((tout1 << 24L) & 0xFF000000);
105 return(tout1);
106 }
diff --git a/src/lib/libcrypto/des/cbc_enc.c b/src/lib/libcrypto/des/cbc_enc.c
deleted file mode 100644
index 677903ae4e..0000000000
--- a/src/lib/libcrypto/des/cbc_enc.c
+++ /dev/null
@@ -1,61 +0,0 @@
1/* crypto/des/cbc_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#define CBC_ENC_C__DONT_UPDATE_IV
60
61#include "ncbc_enc.c" /* des_cbc_encrypt */
diff --git a/src/lib/libcrypto/des/cfb64ede.c b/src/lib/libcrypto/des/cfb64ede.c
deleted file mode 100644
index de34ecceb9..0000000000
--- a/src/lib/libcrypto/des/cfb64ede.c
+++ /dev/null
@@ -1,254 +0,0 @@
1/* crypto/des/cfb64ede.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60#include "e_os.h"
61
62/* The input and output encrypted as though 64bit cfb mode is being
63 * used. The extra state information to record how much of the
64 * 64bit block we have used is contained in *num;
65 */
66
67void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out,
68 long length, DES_key_schedule *ks1,
69 DES_key_schedule *ks2, DES_key_schedule *ks3,
70 DES_cblock *ivec, int *num, int enc)
71 {
72 register DES_LONG v0,v1;
73 register long l=length;
74 register int n= *num;
75 DES_LONG ti[2];
76 unsigned char *iv,c,cc;
77
78 iv=&(*ivec)[0];
79 if (enc)
80 {
81 while (l--)
82 {
83 if (n == 0)
84 {
85 c2l(iv,v0);
86 c2l(iv,v1);
87
88 ti[0]=v0;
89 ti[1]=v1;
90 DES_encrypt3(ti,ks1,ks2,ks3);
91 v0=ti[0];
92 v1=ti[1];
93
94 iv = &(*ivec)[0];
95 l2c(v0,iv);
96 l2c(v1,iv);
97 iv = &(*ivec)[0];
98 }
99 c= *(in++)^iv[n];
100 *(out++)=c;
101 iv[n]=c;
102 n=(n+1)&0x07;
103 }
104 }
105 else
106 {
107 while (l--)
108 {
109 if (n == 0)
110 {
111 c2l(iv,v0);
112 c2l(iv,v1);
113
114 ti[0]=v0;
115 ti[1]=v1;
116 DES_encrypt3(ti,ks1,ks2,ks3);
117 v0=ti[0];
118 v1=ti[1];
119
120 iv = &(*ivec)[0];
121 l2c(v0,iv);
122 l2c(v1,iv);
123 iv = &(*ivec)[0];
124 }
125 cc= *(in++);
126 c=iv[n];
127 iv[n]=cc;
128 *(out++)=c^cc;
129 n=(n+1)&0x07;
130 }
131 }
132 v0=v1=ti[0]=ti[1]=c=cc=0;
133 *num=n;
134 }
135
136#ifdef undef /* MACRO */
137void DES_ede2_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
138 DES_key_schedule ks1, DES_key_schedule ks2, DES_cblock (*ivec),
139 int *num, int enc)
140 {
141 DES_ede3_cfb64_encrypt(in,out,length,ks1,ks2,ks1,ivec,num,enc);
142 }
143#endif
144
145/* This is compatible with the single key CFB-r for DES, even thought that's
146 * not what EVP needs.
147 */
148
149void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out,
150 int numbits,long length,DES_key_schedule *ks1,
151 DES_key_schedule *ks2,DES_key_schedule *ks3,
152 DES_cblock *ivec,int enc)
153 {
154 register DES_LONG d0,d1,v0,v1;
155 register unsigned long l=length,n=((unsigned int)numbits+7)/8;
156 register int num=numbits,i;
157 DES_LONG ti[2];
158 unsigned char *iv;
159 unsigned char ovec[16];
160
161 if (num > 64) return;
162 iv = &(*ivec)[0];
163 c2l(iv,v0);
164 c2l(iv,v1);
165 if (enc)
166 {
167 while (l >= n)
168 {
169 l-=n;
170 ti[0]=v0;
171 ti[1]=v1;
172 DES_encrypt3(ti,ks1,ks2,ks3);
173 c2ln(in,d0,d1,n);
174 in+=n;
175 d0^=ti[0];
176 d1^=ti[1];
177 l2cn(d0,d1,out,n);
178 out+=n;
179 /* 30-08-94 - eay - changed because l>>32 and
180 * l<<32 are bad under gcc :-( */
181 if (num == 32)
182 { v0=v1; v1=d0; }
183 else if (num == 64)
184 { v0=d0; v1=d1; }
185 else
186 {
187 iv=&ovec[0];
188 l2c(v0,iv);
189 l2c(v1,iv);
190 l2c(d0,iv);
191 l2c(d1,iv);
192 /* shift ovec left most of the bits... */
193 memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0));
194 /* now the remaining bits */
195 if(num%8 != 0)
196 for(i=0 ; i < 8 ; ++i)
197 {
198 ovec[i]<<=num%8;
199 ovec[i]|=ovec[i+1]>>(8-num%8);
200 }
201 iv=&ovec[0];
202 c2l(iv,v0);
203 c2l(iv,v1);
204 }
205 }
206 }
207 else
208 {
209 while (l >= n)
210 {
211 l-=n;
212 ti[0]=v0;
213 ti[1]=v1;
214 DES_encrypt3(ti,ks1,ks2,ks3);
215 c2ln(in,d0,d1,n);
216 in+=n;
217 /* 30-08-94 - eay - changed because l>>32 and
218 * l<<32 are bad under gcc :-( */
219 if (num == 32)
220 { v0=v1; v1=d0; }
221 else if (num == 64)
222 { v0=d0; v1=d1; }
223 else
224 {
225 iv=&ovec[0];
226 l2c(v0,iv);
227 l2c(v1,iv);
228 l2c(d0,iv);
229 l2c(d1,iv);
230 /* shift ovec left most of the bits... */
231 memmove(ovec,ovec+num/8,8+(num%8 ? 1 : 0));
232 /* now the remaining bits */
233 if(num%8 != 0)
234 for(i=0 ; i < 8 ; ++i)
235 {
236 ovec[i]<<=num%8;
237 ovec[i]|=ovec[i+1]>>(8-num%8);
238 }
239 iv=&ovec[0];
240 c2l(iv,v0);
241 c2l(iv,v1);
242 }
243 d0^=ti[0];
244 d1^=ti[1];
245 l2cn(d0,d1,out,n);
246 out+=n;
247 }
248 }
249 iv = &(*ivec)[0];
250 l2c(v0,iv);
251 l2c(v1,iv);
252 v0=v1=d0=d1=ti[0]=ti[1]=0;
253 }
254
diff --git a/src/lib/libcrypto/des/cfb64enc.c b/src/lib/libcrypto/des/cfb64enc.c
deleted file mode 100644
index 5ec8683e40..0000000000
--- a/src/lib/libcrypto/des/cfb64enc.c
+++ /dev/null
@@ -1,121 +0,0 @@
1/* crypto/des/cfb64enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60
61/* The input and output encrypted as though 64bit cfb mode is being
62 * used. The extra state information to record how much of the
63 * 64bit block we have used is contained in *num;
64 */
65
66void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,
67 long length, DES_key_schedule *schedule,
68 DES_cblock *ivec, int *num, int enc)
69 {
70 register DES_LONG v0,v1;
71 register long l=length;
72 register int n= *num;
73 DES_LONG ti[2];
74 unsigned char *iv,c,cc;
75
76 iv = &(*ivec)[0];
77 if (enc)
78 {
79 while (l--)
80 {
81 if (n == 0)
82 {
83 c2l(iv,v0); ti[0]=v0;
84 c2l(iv,v1); ti[1]=v1;
85 DES_encrypt1(ti,schedule,DES_ENCRYPT);
86 iv = &(*ivec)[0];
87 v0=ti[0]; l2c(v0,iv);
88 v0=ti[1]; l2c(v0,iv);
89 iv = &(*ivec)[0];
90 }
91 c= *(in++)^iv[n];
92 *(out++)=c;
93 iv[n]=c;
94 n=(n+1)&0x07;
95 }
96 }
97 else
98 {
99 while (l--)
100 {
101 if (n == 0)
102 {
103 c2l(iv,v0); ti[0]=v0;
104 c2l(iv,v1); ti[1]=v1;
105 DES_encrypt1(ti,schedule,DES_ENCRYPT);
106 iv = &(*ivec)[0];
107 v0=ti[0]; l2c(v0,iv);
108 v0=ti[1]; l2c(v0,iv);
109 iv = &(*ivec)[0];
110 }
111 cc= *(in++);
112 c=iv[n];
113 iv[n]=cc;
114 *(out++)=c^cc;
115 n=(n+1)&0x07;
116 }
117 }
118 v0=v1=ti[0]=ti[1]=c=cc=0;
119 *num=n;
120 }
121
diff --git a/src/lib/libcrypto/des/cfb_enc.c b/src/lib/libcrypto/des/cfb_enc.c
deleted file mode 100644
index 720f29a28e..0000000000
--- a/src/lib/libcrypto/des/cfb_enc.c
+++ /dev/null
@@ -1,195 +0,0 @@
1/* crypto/des/cfb_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "e_os.h"
60#include "des_locl.h"
61#include <assert.h>
62
63/* The input and output are loaded in multiples of 8 bits.
64 * What this means is that if you hame numbits=12 and length=2
65 * the first 12 bits will be retrieved from the first byte and half
66 * the second. The second 12 bits will come from the 3rd and half the 4th
67 * byte.
68 */
69/* Until Aug 1 2003 this function did not correctly implement CFB-r, so it
70 * will not be compatible with any encryption prior to that date. Ben. */
71void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
72 long length, DES_key_schedule *schedule, DES_cblock *ivec,
73 int enc)
74 {
75 register DES_LONG d0,d1,v0,v1;
76 register unsigned long l=length;
77 register int num=numbits/8,n=(numbits+7)/8,i,rem=numbits%8;
78 DES_LONG ti[2];
79 unsigned char *iv;
80#ifndef L_ENDIAN
81 unsigned char ovec[16];
82#else
83 unsigned int sh[4];
84 unsigned char *ovec=(unsigned char *)sh;
85
86 /* I kind of count that compiler optimizes away this assertioni,*/
87 assert (sizeof(sh[0])==4); /* as this holds true for all, */
88 /* but 16-bit platforms... */
89
90#endif
91
92 if (numbits<=0 || numbits > 64) return;
93 iv = &(*ivec)[0];
94 c2l(iv,v0);
95 c2l(iv,v1);
96 if (enc)
97 {
98 while (l >= (unsigned long)n)
99 {
100 l-=n;
101 ti[0]=v0;
102 ti[1]=v1;
103 DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
104 c2ln(in,d0,d1,n);
105 in+=n;
106 d0^=ti[0];
107 d1^=ti[1];
108 l2cn(d0,d1,out,n);
109 out+=n;
110 /* 30-08-94 - eay - changed because l>>32 and
111 * l<<32 are bad under gcc :-( */
112 if (numbits == 32)
113 { v0=v1; v1=d0; }
114 else if (numbits == 64)
115 { v0=d0; v1=d1; }
116 else
117 {
118#ifndef L_ENDIAN
119 iv=&ovec[0];
120 l2c(v0,iv);
121 l2c(v1,iv);
122 l2c(d0,iv);
123 l2c(d1,iv);
124#else
125 sh[0]=v0, sh[1]=v1, sh[2]=d0, sh[3]=d1;
126#endif
127 if (rem==0)
128 memmove(ovec,ovec+num,8);
129 else
130 for(i=0 ; i < 8 ; ++i)
131 ovec[i]=ovec[i+num]<<rem |
132 ovec[i+num+1]>>(8-rem);
133#ifdef L_ENDIAN
134 v0=sh[0], v1=sh[1];
135#else
136 iv=&ovec[0];
137 c2l(iv,v0);
138 c2l(iv,v1);
139#endif
140 }
141 }
142 }
143 else
144 {
145 while (l >= (unsigned long)n)
146 {
147 l-=n;
148 ti[0]=v0;
149 ti[1]=v1;
150 DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
151 c2ln(in,d0,d1,n);
152 in+=n;
153 /* 30-08-94 - eay - changed because l>>32 and
154 * l<<32 are bad under gcc :-( */
155 if (numbits == 32)
156 { v0=v1; v1=d0; }
157 else if (numbits == 64)
158 { v0=d0; v1=d1; }
159 else
160 {
161#ifndef L_ENDIAN
162 iv=&ovec[0];
163 l2c(v0,iv);
164 l2c(v1,iv);
165 l2c(d0,iv);
166 l2c(d1,iv);
167#else
168 sh[0]=v0, sh[1]=v1, sh[2]=d0, sh[3]=d1;
169#endif
170 if (rem==0)
171 memmove(ovec,ovec+num,8);
172 else
173 for(i=0 ; i < 8 ; ++i)
174 ovec[i]=ovec[i+num]<<rem |
175 ovec[i+num+1]>>(8-rem);
176#ifdef L_ENDIAN
177 v0=sh[0], v1=sh[1];
178#else
179 iv=&ovec[0];
180 c2l(iv,v0);
181 c2l(iv,v1);
182#endif
183 }
184 d0^=ti[0];
185 d1^=ti[1];
186 l2cn(d0,d1,out,n);
187 out+=n;
188 }
189 }
190 iv = &(*ivec)[0];
191 l2c(v0,iv);
192 l2c(v1,iv);
193 v0=v1=d0=d1=ti[0]=ti[1]=0;
194 }
195
diff --git a/src/lib/libcrypto/des/des-lib.com b/src/lib/libcrypto/des/des-lib.com
deleted file mode 100644
index 348f1c0470..0000000000
--- a/src/lib/libcrypto/des/des-lib.com
+++ /dev/null
@@ -1,1005 +0,0 @@
1$!
2$! DES-LIB.COM
3$! Written By: Robert Byer
4$! Vice-President
5$! A-Com Computing, Inc.
6$! byer@mail.all-net.net
7$!
8$! Changes by Richard Levitte <richard@levitte.org>
9$!
10$! This command files compiles and creates the
11$! "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" library. The "xxx" denotes the machine
12$! architecture of ALPHA, IA64 or VAX.
13$!
14$! It was re-written to try to determine which "C" compiler to try to use
15$! or the user can specify a compiler in P3.
16$!
17$! Specify one of the following to build just that part, specify "ALL" to
18$! just build everything.
19$!
20$! ALL To Just Build "Everything".
21$! LIBRARY To Just Build The [.xxx.EXE.CRYPTO.DES]LIBDES.OLB Library.
22$! DESTEST To Just Build The [.xxx.EXE.CRYPTO.DES]DESTEST.EXE Program.
23$! SPEED To Just Build The [.xxx.EXE.CRYPTO.DES]SPEED.EXE Program.
24$! RPW To Just Build The [.xxx.EXE.CRYPTO.DES]RPW.EXE Program.
25$! DES To Just Build The [.xxx.EXE.CRYPTO.DES]DES.EXE Program.
26$! DES_OPTS To Just Build The [.xxx.EXE.CRYPTO.DES]DES_OPTS.EXE Program.
27$!
28$! Specify either DEBUG or NODEBUG as P2 to compile with or without
29$! debugging information.
30$!
31$! Specify which compiler at P3 to try to compile under.
32$!
33$! VAXC For VAX C.
34$! DECC For DEC C.
35$! GNUC For GNU C.
36$!
37$! If you don't speficy a compiler, it will try to determine which
38$! "C" compiler to try to use.
39$!
40$! P4, if defined, sets a compiler thread NOT needed on OpenVMS 7.1 (and up)
41$!
42$!
43$! Make sure we know what architecture we run on.
44$!
45$!
46$! Check Which Architecture We Are Using.
47$!
48$ IF (F$GETSYI("CPU").LT.128)
49$ THEN
50$!
51$! The Architecture Is VAX
52$!
53$ ARCH := VAX
54$!
55$! Else...
56$!
57$ ELSE
58$!
59$! The Architecture Is Alpha, IA64 or whatever comes in the future.
60$!
61$ ARCH = F$EDIT( F$GETSYI( "ARCH_NAME"), "UPCASE")
62$ IF (ARCH .EQS. "") THEN ARCH = "UNK"
63$!
64$! End The Architecture Check.
65$!
66$ ENDIF
67$!
68$! Define The OBJ Directory Name.
69$!
70$ OBJ_DIR := SYS$DISK:[--.'ARCH'.OBJ.CRYPTO.DES]
71$!
72$! Define The EXE Directory Name.
73$!
74$ EXE_DIR :== SYS$DISK:[--.'ARCH'.EXE.CRYPTO.DES]
75$!
76$! Check To Make Sure We Have Valid Command Line Parameters.
77$!
78$ GOSUB CHECK_OPTIONS
79$!
80$! Tell The User What Kind of Machine We Run On.
81$!
82$ WRITE SYS$OUTPUT "Compiling On A ",ARCH," Machine."
83$!
84$! Check To See If The Architecture Specific OBJ Directory Exists.
85$!
86$ IF (F$PARSE(OBJ_DIR).EQS."")
87$ THEN
88$!
89$! It Dosen't Exist, So Create It.
90$!
91$ CREATE/DIR 'OBJ_DIR'
92$!
93$! End The Architecture Specific OBJ Directory Check.
94$!
95$ ENDIF
96$!
97$! Check To See If The Architecture Specific Directory Exists.
98$!
99$ IF (F$PARSE(EXE_DIR).EQS."")
100$ THEN
101$!
102$! It Dosen't Exist, So Create It.
103$!
104$ CREATE/DIR 'EXE_DIR'
105$!
106$! End The Architecture Specific Directory Check.
107$!
108$ ENDIF
109$!
110$! Define The Library Name.
111$!
112$ LIB_NAME := 'EXE_DIR'LIBDES.OLB
113$!
114$! Check To See What We Are To Do.
115$!
116$ IF (BUILDALL.EQS."TRUE")
117$ THEN
118$!
119$! Since Nothing Special Was Specified, Do Everything.
120$!
121$ GOSUB LIBRARY
122$ GOSUB DESTEST
123$ GOSUB SPEED
124$ GOSUB RPW
125$ GOSUB DES
126$ GOSUB DES_OPTS
127$!
128$! Else...
129$!
130$ ELSE
131$!
132$! Build Just What The User Wants Us To Build.
133$!
134$ GOSUB 'BUILDALL'
135$!
136$! End The BUILDALL Check.
137$!
138$ ENDIF
139$!
140$! Time To EXIT.
141$!
142$ EXIT
143$ LIBRARY:
144$!
145$! Tell The User That We Are Compiling.
146$!
147$ WRITE SYS$OUTPUT "Compiling The ",LIB_NAME," Files."
148$!
149$! Check To See If We Already Have A "[.xxx.EXE.CRYPTO.DES]LIBDES.OLB" Library...
150$!
151$ IF (F$SEARCH(LIB_NAME).EQS."")
152$ THEN
153$!
154$! Guess Not, Create The Library.
155$!
156$ LIBRARY/CREATE/OBJECT 'LIB_NAME'
157$!
158$! End The Library Exist Check.
159$!
160$ ENDIF
161$!
162$! Define The DES Library Files.
163$!
164$ LIB_DES = "set_key,ecb_enc,cbc_enc,"+ -
165 "ecb3_enc,cfb64enc,cfb64ede,cfb_enc,ofb64ede,"+ -
166 "enc_read,enc_writ,ofb64enc,"+ -
167 "ofb_enc,str2key,pcbc_enc,qud_cksm,rand_key,"+ -
168 "des_enc,fcrypt_b,read2pwd,"+ -
169 "fcrypt,xcbc_enc,read_pwd,rpc_enc,cbc_cksm,supp"
170$!
171$! Define A File Counter And Set It To "0".
172$!
173$ FILE_COUNTER = 0
174$!
175$! Top Of The File Loop.
176$!
177$ NEXT_FILE:
178$!
179$! O.K, Extract The File Name From The File List.
180$!
181$ FILE_NAME = F$ELEMENT(FILE_COUNTER,",",LIB_DES)
182$!
183$! Check To See If We Are At The End Of The File List.
184$!
185$ IF (FILE_NAME.EQS.",") THEN GOTO FILE_DONE
186$!
187$! Increment The Counter.
188$!
189$ FILE_COUNTER = FILE_COUNTER + 1
190$!
191$! Create The Source File Name.
192$!
193$ SOURCE_FILE = "SYS$DISK:[]" + FILE_NAME + ".C"
194$!
195$! Tell The User We Are Compiling The Source File.
196$!
197$ WRITE SYS$OUTPUT " ",FILE_NAME,".C"
198$!
199$! Create The Object File Name.
200$!
201$ OBJECT_FILE = OBJ_DIR + FILE_NAME + "." + ARCH + "OBJ"
202$ ON WARNING THEN GOTO NEXT_FILE
203$!
204$! Check To See If The File We Want To Compile Actually Exists.
205$!
206$ IF (F$SEARCH(SOURCE_FILE).EQS."")
207$ THEN
208$!
209$! Tell The User That The File Dosen't Exist.
210$!
211$ WRITE SYS$OUTPUT ""
212$ WRITE SYS$OUTPUT "The File ",SOURCE_FILE," Dosen't Exist."
213$ WRITE SYS$OUTPUT ""
214$!
215$! Exit The Build.
216$!
217$ EXIT
218$!
219$! End The File Exists Check.
220$!
221$ ENDIF
222$!
223$! Compile The File.
224$!
225$ ON ERROR THEN GOTO NEXT_FILE
226$ CC/OBJECT='OBJECT_FILE' 'SOURCE_FILE'
227$!
228$! Add It To The Library.
229$!
230$ LIBRARY/REPLACE/OBJECT 'LIB_NAME' 'OBJECT_FILE'
231$!
232$! Time To Clean Up The Object File.
233$!
234$ DELETE 'OBJECT_FILE';*
235$!
236$! Go Back And Do It Again.
237$!
238$ GOTO NEXT_FILE
239$!
240$! All Done With This Library Part.
241$!
242$ FILE_DONE:
243$!
244$! Tell The User That We Are All Done.
245$!
246$ WRITE SYS$OUTPUT "Library ",LIB_NAME," Built."
247$!
248$! All Done, Time To Return.
249$!
250$ RETURN
251$!
252$! Compile The DESTEST Program.
253$!
254$ DESTEST:
255$!
256$! Check To See If We Have The Proper Libraries.
257$!
258$ GOSUB LIB_CHECK
259$!
260$! Check To See If We Have A Linker Option File.
261$!
262$ GOSUB CHECK_OPT_FILE
263$!
264$! Check To See If The File We Want To Compile Actually Exists.
265$!
266$ IF (F$SEARCH("SYS$DISK:[]DESTEST.C").EQS."")
267$ THEN
268$!
269$! Tell The User That The File Dosen't Exist.
270$!
271$ WRITE SYS$OUTPUT ""
272$ WRITE SYS$OUTPUT "The File DESTEST.C Dosen't Exist."
273$ WRITE SYS$OUTPUT ""
274$!
275$! Exit The Build.
276$!
277$ EXIT
278$!
279$! End The DESTEST.C File Check.
280$!
281$ ENDIF
282$!
283$! Tell The User What We Are Building.
284$!
285$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"DESTEST.EXE"
286$!
287$! Compile The DESTEST Program.
288$!
289$ CC/OBJECT='OBJ_DIR'DESTEST.OBJ SYS$DISK:[]DESTEST.C
290$!
291$! Link The DESTEST Program.
292$!
293$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'DESTEST.EXE -
294 'OBJ_DIR'DESTEST.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
295$!
296$! All Done, Time To Return.
297$!
298$ RETURN
299$!
300$! Compile The SPEED Program.
301$!
302$ SPEED:
303$!
304$! Check To See If We Have The Proper Libraries.
305$!
306$ GOSUB LIB_CHECK
307$!
308$! Check To See If We Have A Linker Option File.
309$!
310$ GOSUB CHECK_OPT_FILE
311$!
312$! Check To See If The File We Want To Compile Actually Exists.
313$!
314$ IF (F$SEARCH("SYS$DISK:[]SPEED.C").EQS."")
315$ THEN
316$!
317$! Tell The User That The File Dosen't Exist.
318$!
319$ WRITE SYS$OUTPUT ""
320$ WRITE SYS$OUTPUT "The File SPEED.C Dosen't Exist."
321$ WRITE SYS$OUTPUT ""
322$!
323$! Exit The Build.
324$!
325$ EXIT
326$!
327$! End The SPEED.C File Check.
328$!
329$ ENDIF
330$!
331$! Tell The User What We Are Building.
332$!
333$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"SPEED.EXE"
334$!
335$! Compile The SPEED Program.
336$!
337$ CC/OBJECT='OBJ_DIR'SPEED.OBJ SYS$DISK:[]SPEED.C
338$!
339$! Link The SPEED Program.
340$!
341$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'SPEED.EXE -
342 'OBJ_DIR'SPEED.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
343$!
344$! All Done, Time To Return.
345$!
346$ RETURN
347$!
348$! Compile The RPW Program.
349$!
350$ RPW:
351$!
352$! Check To See If We Have The Proper Libraries.
353$!
354$ GOSUB LIB_CHECK
355$!
356$! Check To See If We Have A Linker Option File.
357$!
358$ GOSUB CHECK_OPT_FILE
359$!
360$! Check To See If The File We Want To Compile Actually Exists.
361$!
362$ IF (F$SEARCH("SYS$DISK:[]RPW.C").EQS."")
363$ THEN
364$!
365$! Tell The User That The File Dosen't Exist.
366$!
367$ WRITE SYS$OUTPUT ""
368$ WRITE SYS$OUTPUT "The File RPW.C Dosen't Exist."
369$ WRITE SYS$OUTPUT ""
370$!
371$! Exit The Build.
372$!
373$ EXIT
374$!
375$! End The RPW.C File Check.
376$!
377$ ENDIF
378$!
379$! Tell The User What We Are Building.
380$!
381$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"RPW.EXE"
382$!
383$! Compile The RPW Program.
384$!
385$ CC/OBJECT='OBJ_DIR'RPW.OBJ SYS$DISK:[]RPW.C
386$!
387$! Link The RPW Program.
388$!
389$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'RPW.EXE -
390 'OBJ_DIR'RPW.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
391$!
392$! All Done, Time To Return.
393$!
394$ RETURN
395$!
396$! Compile The DES Program.
397$!
398$ DES:
399$!
400$! Check To See If We Have The Proper Libraries.
401$!
402$ GOSUB LIB_CHECK
403$!
404$! Check To See If We Have A Linker Option File.
405$!
406$ GOSUB CHECK_OPT_FILE
407$!
408$! Check To See If The File We Want To Compile Actually Exists.
409$!
410$ IF (F$SEARCH("SYS$DISK:[]DES.C").EQS."")
411$ THEN
412$!
413$! Tell The User That The File Dosen't Exist.
414$!
415$ WRITE SYS$OUTPUT ""
416$ WRITE SYS$OUTPUT "The File DES.C Dosen't Exist."
417$ WRITE SYS$OUTPUT ""
418$!
419$! Exit The Build.
420$!
421$ EXIT
422$!
423$! End The DES.C File Check.
424$!
425$ ENDIF
426$!
427$! Tell The User What We Are Building.
428$!
429$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"DES.EXE"
430$!
431$! Compile The DES Program.
432$!
433$ CC/OBJECT='OBJ_DIR'DES.OBJ SYS$DISK:[]DES.C
434$ CC/OBJECT='OBJ_DIR'DES.OBJ SYS$DISK:[]CBC3_ENC.C
435$!
436$! Link The DES Program.
437$!
438$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'DES.EXE -
439 'OBJ_DIR'DES.OBJ,'OBJ_DIR'CBC3_ENC.OBJ,-
440 'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
441$!
442$! All Done, Time To Return.
443$!
444$ RETURN
445$!
446$! Compile The DES_OPTS Program.
447$!
448$ DES_OPTS:
449$!
450$! Check To See If We Have The Proper Libraries.
451$!
452$ GOSUB LIB_CHECK
453$!
454$! Check To See If We Have A Linker Option File.
455$!
456$ GOSUB CHECK_OPT_FILE
457$!
458$! Check To See If The File We Want To Compile Actually Exists.
459$!
460$ IF (F$SEARCH("SYS$DISK:[]DES_OPTS.C").EQS."")
461$ THEN
462$!
463$! Tell The User That The File Dosen't Exist.
464$!
465$ WRITE SYS$OUTPUT ""
466$ WRITE SYS$OUTPUT "The File DES_OPTS.C Dosen't Exist."
467$ WRITE SYS$OUTPUT ""
468$!
469$! Exit The Build.
470$!
471$ EXIT
472$!
473$! End The DES_OPTS.C File Check.
474$!
475$ ENDIF
476$!
477$! Tell The User What We Are Building.
478$!
479$ WRITE SYS$OUTPUT "Building ",EXE_DIR,"DES_OPTS.EXE"
480$!
481$! Compile The DES_OPTS Program.
482$!
483$ CC/OBJECT='OBJ_DIR'DES_OPTS.OBJ SYS$DISK:[]DES_OPTS.C
484$!
485$! Link The DES_OPTS Program.
486$!
487$ LINK/'DEBUGGER'/'TRACEBACK'/CONTIGUOUS/EXE='EXE_DIR'DES_OPTS.EXE -
488 'OBJ_DIR'DES_OPTS.OBJ,'LIB_NAME'/LIBRARY,'OPT_FILE'/OPTION
489$!
490$! All Done, Time To Return.
491$!
492$ RETURN
493$ EXIT
494$!
495$! Check For The Link Option FIle.
496$!
497$ CHECK_OPT_FILE:
498$!
499$! Check To See If We Need To Make A VAX C Option File.
500$!
501$ IF (COMPILER.EQS."VAXC")
502$ THEN
503$!
504$! Check To See If We Already Have A VAX C Linker Option File.
505$!
506$ IF (F$SEARCH(OPT_FILE).EQS."")
507$ THEN
508$!
509$! We Need A VAX C Linker Option File.
510$!
511$ CREATE 'OPT_FILE'
512$DECK
513!
514! Default System Options File To Link Agianst
515! The Sharable VAX C Runtime Library.
516!
517SYS$SHARE:VAXCRTL.EXE/SHARE
518$EOD
519$!
520$! End The Option File Check.
521$!
522$ ENDIF
523$!
524$! End The VAXC Check.
525$!
526$ ENDIF
527$!
528$! Check To See If We Need A GNU C Option File.
529$!
530$ IF (COMPILER.EQS."GNUC")
531$ THEN
532$!
533$! Check To See If We Already Have A GNU C Linker Option File.
534$!
535$ IF (F$SEARCH(OPT_FILE).EQS."")
536$ THEN
537$!
538$! We Need A GNU C Linker Option File.
539$!
540$ CREATE 'OPT_FILE'
541$DECK
542!
543! Default System Options File To Link Agianst
544! The Sharable C Runtime Library.
545!
546GNU_CC:[000000]GCCLIB/LIBRARY
547SYS$SHARE:VAXCRTL/SHARE
548$EOD
549$!
550$! End The Option File Check.
551$!
552$ ENDIF
553$!
554$! End The GNU C Check.
555$!
556$ ENDIF
557$!
558$! Check To See If We Need A DEC C Option File.
559$!
560$ IF (COMPILER.EQS."DECC")
561$ THEN
562$!
563$! Check To See If We Already Have A DEC C Linker Option File.
564$!
565$ IF (F$SEARCH(OPT_FILE).EQS."")
566$ THEN
567$!
568$! Figure Out If We Need An non-VAX Or A VAX Linker Option File.
569$!
570$ IF (F$GETSYI("CPU").LT.128)
571$ THEN
572$!
573$! We Need A DEC C Linker Option File For VAX.
574$!
575$ CREATE 'OPT_FILE'
576$DECK
577!
578! Default System Options File To Link Agianst
579! The Sharable DEC C Runtime Library.
580!
581SYS$SHARE:DECC$SHR.EXE/SHARE
582$EOD
583$!
584$! Else...
585$!
586$ ELSE
587$!
588$! Create The non-VAX Linker Option File.
589$!
590$ CREATE 'OPT_FILE'
591$DECK
592!
593! Default System Options File For non-VAX To Link Agianst
594! The Sharable C Runtime Library.
595!
596SYS$SHARE:CMA$OPEN_LIB_SHR/SHARE
597SYS$SHARE:CMA$OPEN_RTL/SHARE
598$EOD
599$!
600$! End The DEC C Option File Check.
601$!
602$ ENDIF
603$!
604$! End The Option File Search.
605$!
606$ ENDIF
607$!
608$! End The DEC C Check.
609$!
610$ ENDIF
611$!
612$! Tell The User What Linker Option File We Are Using.
613$!
614$ WRITE SYS$OUTPUT "Using Linker Option File ",OPT_FILE,"."
615$!
616$! Time To RETURN.
617$!
618$ RETURN
619$!
620$! Library Check.
621$!
622$ LIB_CHECK:
623$!
624$! Look For The Library LIBDES.OLB.
625$!
626$ IF (F$SEARCH(LIB_NAME).EQS."")
627$ THEN
628$!
629$! Tell The User We Can't Find The [.xxx.CRYPTO.DES]LIBDES.OLB Library.
630$!
631$ WRITE SYS$OUTPUT ""
632$ WRITE SYS$OUTPUT "Can't Find The Library ",LIB_NAME,"."
633$ WRITE SYS$OUTPUT "We Can't Link Without It."
634$ WRITE SYS$OUTPUT ""
635$!
636$! Since We Can't Link Without It, Exit.
637$!
638$ EXIT
639$ ENDIF
640$!
641$! Time To Return.
642$!
643$ RETURN
644$!
645$! Check The User's Options.
646$!
647$ CHECK_OPTIONS:
648$!
649$! Check To See If We Are To "Just Build Everything".
650$!
651$ IF (P1.EQS."ALL")
652$ THEN
653$!
654$! P1 Is "ALL", So Build Everything.
655$!
656$ BUILDALL = "TRUE"
657$!
658$! Else...
659$!
660$ ELSE
661$!
662$! Else, Check To See If P1 Has A Valid Argument.
663$!
664$ IF (P1.EQS."LIBRARY").OR.(P1.EQS."DESTEST").OR.(P1.EQS."SPEED") -
665 .OR.(P1.EQS."RPW").OR.(P1.EQS."DES").OR.(P1.EQS."DES_OPTS")
666$ THEN
667$!
668$! A Valid Argument.
669$!
670$ BUILDALL = P1
671$!
672$! Else...
673$!
674$ ELSE
675$!
676$! Tell The User We Don't Know What They Want.
677$!
678$ WRITE SYS$OUTPUT ""
679$ WRITE SYS$OUTPUT "The Option ",P1," Is Invalid. The Valid Options Are:"
680$ WRITE SYS$OUTPUT ""
681$ WRITE SYS$OUTPUT " ALL : Just Build Everything."
682$ WRITE SYS$OUTPUT " LIBRARY : To Compile Just The [.xxx.EXE.CRYPTO.DES]LIBDES.OLB Library."
683$ WRITE SYS$OUTPUT " DESTEST : To Compile Just The [.xxx.EXE.CRYPTO.DES]DESTEST.EXE Program."
684$ WRITE SYS$OUTPUT " SPEED : To Compile Just The [.xxx.EXE.CRYPTO.DES]SPEED.EXE Program."
685$ WRITE SYS$OUTPUT " RPW : To Compile Just The [.xxx.EXE.CRYPTO.DES]RPW.EXE Program."
686$ WRITE SYS$OUTPUT " DES : To Compile Just The [.xxx.EXE.CRYPTO.DES]DES.EXE Program."
687$ WRITE SYS$OUTPUT " DES_OPTS : To Compile Just The [.xxx.EXE.CRYTPO.DES]DES_OPTS.EXE Program."
688$ WRITE SYS$OUTPUT ""
689$ WRITE SYS$OUTPUT " Where 'xxx' Stands For: "
690$ WRITE SYS$OUTPUT ""
691$ WRITE SYS$OUTPUT " ALPHA : Alpha Architecture."
692$ WRITE SYS$OUTPUT " IA64 : IA64 Architecture."
693$ WRITE SYS$OUTPUT " VAX : VAX Architecture."
694$ WRITE SYS$OUTPUT ""
695$!
696$! Time To EXIT.
697$!
698$ EXIT
699$!
700$! End The Valid Argument Check.
701$!
702$ ENDIF
703$!
704$! End The P1 Check.
705$!
706$ ENDIF
707$!
708$! Check To See If We Are To Compile Without Debugger Information.
709$!
710$ IF (P2.EQS."NODEBUG")
711$ THEN
712$!
713$! P2 Is Blank, So Compile Without Debugger Information.
714$!
715$ DEBUGGER = "NODEBUG"
716$ TRACEBACK = "NOTRACEBACK"
717$ GCC_OPTIMIZE = "OPTIMIZE"
718$ CC_OPTIMIZE = "OPTIMIZE"
719$ WRITE SYS$OUTPUT "No Debugger Information Will Be Produced During Compile."
720$ WRITE SYS$OUTPUT "Compiling With Compiler Optimization."
721$!
722$! Else...
723$!
724$ ELSE
725$!
726$! Check To See If We Are To Compile With Debugger Information.
727$!
728$ IF (P2.EQS."DEBUG")
729$ THEN
730$!
731$! Compile With Debugger Information.
732$!
733$ DEBUGGER = "DEBUG"
734$ TRACEBACK = "TRACEBACK"
735$ GCC_OPTIMIZE = "NOOPTIMIZE"
736$ CC_OPTIMIZE = "NOOPTIMIZE"
737$ WRITE SYS$OUTPUT "Debugger Information Will Be Produced During Compile."
738$ WRITE SYS$OUTPUT "Compiling Without Compiler Optimization."
739$!
740$! Else...
741$!
742$ ELSE
743$!
744$! Tell The User Entered An Invalid Option..
745$!
746$ WRITE SYS$OUTPUT ""
747$ WRITE SYS$OUTPUT "The Option ",P2," Is Invalid. The Valid Options Are:"
748$ WRITE SYS$OUTPUT ""
749$ WRITE SYS$OUTPUT " DEBUG : Compile With The Debugger Information."
750$ WRITE SYS$OUTPUT " NODEBUG : Compile Without The Debugger Information."
751$ WRITE SYS$OUTPUT ""
752$!
753$! Time To EXIT.
754$!
755$ EXIT
756$!
757$! End The Valid Argument Check.
758$!
759$ ENDIF
760$!
761$! End The P2 Check.
762$!
763$ ENDIF
764$!
765$! Special Threads For OpenVMS v7.1 Or Later.
766$!
767$! Written By: Richard Levitte
768$! richard@levitte.org
769$!
770$!
771$! Check To See If We Have A Option For P4.
772$!
773$ IF (P4.EQS."")
774$ THEN
775$!
776$! Get The Version Of VMS We Are Using.
777$!
778$ ISSEVEN := ""
779$ TMP = F$ELEMENT(0,"-",F$EXTRACT(1,4,F$GETSYI("VERSION")))
780$ TMP = F$INTEGER(F$ELEMENT(0,".",TMP)+F$ELEMENT(1,".",TMP))
781$!
782$! Check To See If The VMS Version Is v7.1 Or Later.
783$!
784$ IF (TMP.GE.71)
785$ THEN
786$!
787$! We Have OpenVMS v7.1 Or Later, So Use The Special Threads.
788$!
789$ ISSEVEN := ,PTHREAD_USE_D4
790$!
791$! End The VMS Version Check.
792$!
793$ ENDIF
794$!
795$! End The P4 Check.
796$!
797$ ENDIF
798$!
799$! Check To See If P3 Is Blank.
800$!
801$ IF (P3.EQS."")
802$ THEN
803$!
804$! O.K., The User Didn't Specify A Compiler, Let's Try To
805$! Find Out Which One To Use.
806$!
807$! Check To See If We Have GNU C.
808$!
809$ IF (F$TRNLNM("GNU_CC").NES."")
810$ THEN
811$!
812$! Looks Like GNUC, Set To Use GNUC.
813$!
814$ P3 = "GNUC"
815$!
816$! Else...
817$!
818$ ELSE
819$!
820$! Check To See If We Have VAXC Or DECC.
821$!
822$ IF (ARCH.NES."VAX").OR.(F$TRNLNM("DECC$CC_DEFAULT").NES."")
823$ THEN
824$!
825$! Looks Like DECC, Set To Use DECC.
826$!
827$ P3 = "DECC"
828$!
829$! Else...
830$!
831$ ELSE
832$!
833$! Looks Like VAXC, Set To Use VAXC.
834$!
835$ P3 = "VAXC"
836$!
837$! End The VAXC Compiler Check.
838$!
839$ ENDIF
840$!
841$! End The DECC & VAXC Compiler Check.
842$!
843$ ENDIF
844$!
845$! End The Compiler Check.
846$!
847$ ENDIF
848$!
849$! Set Up Initial CC Definitions, Possibly With User Ones
850$!
851$ CCDEFS = ""
852$ IF F$TYPE(USER_CCDEFS) .NES. "" THEN CCDEFS = USER_CCDEFS
853$ CCEXTRAFLAGS = ""
854$ IF F$TYPE(USER_CCFLAGS) .NES. "" THEN CCEXTRAFLAGS = USER_CCFLAGS
855$ CCDISABLEWARNINGS = ""
856$ IF F$TYPE(USER_CCDISABLEWARNINGS) .NES. "" THEN -
857 CCDISABLEWARNINGS = USER_CCDISABLEWARNINGS
858$!
859$! Check To See If The User Entered A Valid Paramter.
860$!
861$ IF (P3.EQS."VAXC").OR.(P3.EQS."DECC").OR.(P3.EQS."GNUC")
862$ THEN
863$!
864$! Check To See If The User Wanted DECC.
865$!
866$ IF (P3.EQS."DECC")
867$ THEN
868$!
869$! Looks Like DECC, Set To Use DECC.
870$!
871$ COMPILER = "DECC"
872$!
873$! Tell The User We Are Using DECC.
874$!
875$ WRITE SYS$OUTPUT "Using DECC 'C' Compiler."
876$!
877$! Use DECC...
878$!
879$ CC = "CC"
880$ IF ARCH.EQS."VAX" .AND. F$TRNLNM("DECC$CC_DEFAULT").NES."/DECC" -
881 THEN CC = "CC/DECC"
882$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/STANDARD=ANSI89" + -
883 "/NOLIST/PREFIX=ALL" + CCEXTRAFLAGS
884$!
885$! Define The Linker Options File Name.
886$!
887$ OPT_FILE = "''EXE_DIR'VAX_DECC_OPTIONS.OPT"
888$!
889$! End DECC Check.
890$!
891$ ENDIF
892$!
893$! Check To See If We Are To Use VAXC.
894$!
895$ IF (P3.EQS."VAXC")
896$ THEN
897$!
898$! Looks Like VAXC, Set To Use VAXC.
899$!
900$ COMPILER = "VAXC"
901$!
902$! Tell The User We Are Using VAX C.
903$!
904$ WRITE SYS$OUTPUT "Using VAXC 'C' Compiler."
905$!
906$! Compile Using VAXC.
907$!
908$ CC = "CC"
909$ IF ARCH.NES."VAX"
910$ THEN
911$ WRITE SYS$OUTPUT "There is no VAX C on ''ARCH'!"
912$ EXIT
913$ ENDIF
914$ IF F$TRNLNM("DECC$CC_DEFAULT").EQS."/DECC" THEN CC = "CC/VAXC"
915$ CC = CC + "/''CC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS
916$ CCDEFS = """VAXC""," + CCDEFS
917$!
918$! Define <sys> As SYS$COMMON:[SYSLIB]
919$!
920$ DEFINE/NOLOG SYS SYS$COMMON:[SYSLIB]
921$!
922$! Define The Linker Options File Name.
923$!
924$ OPT_FILE = "''EXE_DIR'VAX_VAXC_OPTIONS.OPT"
925$!
926$! End VAXC Check
927$!
928$ ENDIF
929$!
930$! Check To See If We Are To Use GNU C.
931$!
932$ IF (P3.EQS."GNUC")
933$ THEN
934$!
935$! Looks Like GNUC, Set To Use GNUC.
936$!
937$ COMPILER = "GNUC"
938$!
939$! Tell The User We Are Using GNUC.
940$!
941$ WRITE SYS$OUTPUT "Using GNU 'C' Compiler."
942$!
943$! Use GNU C...
944$!
945$ CC = "GCC/NOCASE_HACK/''GCC_OPTIMIZE'/''DEBUGGER'/NOLIST" + CCEXTRAFLAGS
946$!
947$! Define The Linker Options File Name.
948$!
949$ OPT_FILE = "''EXE_DIR'VAX_GNUC_OPTIONS.OPT"
950$!
951$! End The GNU C Check.
952$!
953$ ENDIF
954$!
955$! Set up default defines
956$!
957$ CCDEFS = """FLAT_INC=1""," + CCDEFS
958$!
959$! Finish up the definition of CC.
960$!
961$ IF COMPILER .EQS. "DECC"
962$ THEN
963$ IF CCDISABLEWARNINGS .EQS. ""
964$ THEN
965$ CC4DISABLEWARNINGS = "DOLLARID"
966$ ELSE
967$ CC4DISABLEWARNINGS = CCDISABLEWARNINGS + ",DOLLARID"
968$ CCDISABLEWARNINGS = "/WARNING=(DISABLE=(" + CCDISABLEWARNINGS + "))"
969$ ENDIF
970$ CC4DISABLEWARNINGS = "/WARNING=(DISABLE=(" + CC4DISABLEWARNINGS + "))"
971$ ELSE
972$ CCDISABLEWARNINGS = ""
973$ CC4DISABLEWARNINGS = ""
974$ ENDIF
975$ CC = CC + "/DEFINE=(" + CCDEFS + ")" + CCDISABLEWARNINGS
976$!
977$! Show user the result
978$!
979$ WRITE SYS$OUTPUT "Main Compiling Command: ",CC
980$!
981$! Else The User Entered An Invalid Argument.
982$!
983$ ELSE
984$!
985$! Tell The User We Don't Know What They Want.
986$!
987$ WRITE SYS$OUTPUT ""
988$ WRITE SYS$OUTPUT "The Option ",P3," Is Invalid. The Valid Options Are:"
989$ WRITE SYS$OUTPUT ""
990$ WRITE SYS$OUTPUT " VAXC : To Compile With VAX C."
991$ WRITE SYS$OUTPUT " DECC : To Compile With DEC C."
992$ WRITE SYS$OUTPUT " GNUC : To Compile With GNU C."
993$ WRITE SYS$OUTPUT ""
994$!
995$! Time To EXIT.
996$!
997$ EXIT
998$!
999$! End The P3 Check.
1000$!
1001$ ENDIF
1002$!
1003$! Time To RETURN...
1004$!
1005$ RETURN
diff --git a/src/lib/libcrypto/des/des.c b/src/lib/libcrypto/des/des.c
deleted file mode 100644
index 343135ff9e..0000000000
--- a/src/lib/libcrypto/des/des.c
+++ /dev/null
@@ -1,932 +0,0 @@
1/* crypto/des/des.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
62#include <openssl/opensslconf.h>
63#ifndef OPENSSL_SYS_MSDOS
64#ifndef OPENSSL_SYS_VMS
65#include OPENSSL_UNISTD
66#else /* OPENSSL_SYS_VMS */
67#ifdef __DECC
68#include <unistd.h>
69#else /* not __DECC */
70#include <math.h>
71#endif /* __DECC */
72#endif /* OPENSSL_SYS_VMS */
73#else /* OPENSSL_SYS_MSDOS */
74#include <io.h>
75#endif
76
77#include <time.h>
78#include "des_ver.h"
79
80#ifdef OPENSSL_SYS_VMS
81#include <types.h>
82#include <stat.h>
83#else
84#ifndef _IRIX
85#include <sys/types.h>
86#endif
87#include <sys/stat.h>
88#endif
89#include <openssl/des.h>
90#include <openssl/rand.h>
91#include <openssl/ui_compat.h>
92
93void usage(void);
94void doencryption(void);
95int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp);
96void uufwriteEnd(FILE *fp);
97int uufread(unsigned char *out,int size,unsigned int num,FILE *fp);
98int uuencode(unsigned char *in,int num,unsigned char *out);
99int uudecode(unsigned char *in,int num,unsigned char *out);
100void DES_3cbc_encrypt(DES_cblock *input,DES_cblock *output,long length,
101 DES_key_schedule sk1,DES_key_schedule sk2,
102 DES_cblock *ivec1,DES_cblock *ivec2,int enc);
103#ifdef OPENSSL_SYS_VMS
104#define EXIT(a) exit(a&0x10000000L)
105#else
106#define EXIT(a) exit(a)
107#endif
108
109#define BUFSIZE (8*1024)
110#define VERIFY 1
111#define KEYSIZ 8
112#define KEYSIZB 1024 /* should hit tty line limit first :-) */
113char key[KEYSIZB+1];
114int do_encrypt,longk=0;
115FILE *DES_IN,*DES_OUT,*CKSUM_OUT;
116char uuname[200];
117unsigned char uubuf[50];
118int uubufnum=0;
119#define INUUBUFN (45*100)
120#define OUTUUBUF (65*100)
121unsigned char b[OUTUUBUF];
122unsigned char bb[300];
123DES_cblock cksum={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
124char cksumname[200]="";
125
126int vflag,cflag,eflag,dflag,kflag,bflag,fflag,sflag,uflag,flag3,hflag,error;
127
128int main(int argc, char **argv)
129 {
130 int i;
131 struct stat ins,outs;
132 char *p;
133 char *in=NULL,*out=NULL;
134
135 vflag=cflag=eflag=dflag=kflag=hflag=bflag=fflag=sflag=uflag=flag3=0;
136 error=0;
137 memset(key,0,sizeof(key));
138
139 for (i=1; i<argc; i++)
140 {
141 p=argv[i];
142 if ((p[0] == '-') && (p[1] != '\0'))
143 {
144 p++;
145 while (*p)
146 {
147 switch (*(p++))
148 {
149 case '3':
150 flag3=1;
151 longk=1;
152 break;
153 case 'c':
154 cflag=1;
155 strncpy(cksumname,p,200);
156 cksumname[sizeof(cksumname)-1]='\0';
157 p+=strlen(cksumname);
158 break;
159 case 'C':
160 cflag=1;
161 longk=1;
162 strncpy(cksumname,p,200);
163 cksumname[sizeof(cksumname)-1]='\0';
164 p+=strlen(cksumname);
165 break;
166 case 'e':
167 eflag=1;
168 break;
169 case 'v':
170 vflag=1;
171 break;
172 case 'E':
173 eflag=1;
174 longk=1;
175 break;
176 case 'd':
177 dflag=1;
178 break;
179 case 'D':
180 dflag=1;
181 longk=1;
182 break;
183 case 'b':
184 bflag=1;
185 break;
186 case 'f':
187 fflag=1;
188 break;
189 case 's':
190 sflag=1;
191 break;
192 case 'u':
193 uflag=1;
194 strncpy(uuname,p,200);
195 uuname[sizeof(uuname)-1]='\0';
196 p+=strlen(uuname);
197 break;
198 case 'h':
199 hflag=1;
200 break;
201 case 'k':
202 kflag=1;
203 if ((i+1) == argc)
204 {
205 fputs("must have a key with the -k option\n",stderr);
206 error=1;
207 }
208 else
209 {
210 int j;
211
212 i++;
213 strncpy(key,argv[i],KEYSIZB);
214 for (j=strlen(argv[i])-1; j>=0; j--)
215 argv[i][j]='\0';
216 }
217 break;
218 default:
219 fprintf(stderr,"'%c' unknown flag\n",p[-1]);
220 error=1;
221 break;
222 }
223 }
224 }
225 else
226 {
227 if (in == NULL)
228 in=argv[i];
229 else if (out == NULL)
230 out=argv[i];
231 else
232 error=1;
233 }
234 }
235 if (error) usage();
236 /* We either
237 * do checksum or
238 * do encrypt or
239 * do decrypt or
240 * do decrypt then ckecksum or
241 * do checksum then encrypt
242 */
243 if (((eflag+dflag) == 1) || cflag)
244 {
245 if (eflag) do_encrypt=DES_ENCRYPT;
246 if (dflag) do_encrypt=DES_DECRYPT;
247 }
248 else
249 {
250 if (vflag)
251 {
252#ifndef _Windows
253 fprintf(stderr,"des(1) built with %s\n",libdes_version);
254#endif
255 EXIT(1);
256 }
257 else usage();
258 }
259
260#ifndef _Windows
261 if (vflag) fprintf(stderr,"des(1) built with %s\n",libdes_version);
262#endif
263 if ( (in != NULL) &&
264 (out != NULL) &&
265#ifndef OPENSSL_SYS_MSDOS
266 (stat(in,&ins) != -1) &&
267 (stat(out,&outs) != -1) &&
268 (ins.st_dev == outs.st_dev) &&
269 (ins.st_ino == outs.st_ino))
270#else /* OPENSSL_SYS_MSDOS */
271 (strcmp(in,out) == 0))
272#endif
273 {
274 fputs("input and output file are the same\n",stderr);
275 EXIT(3);
276 }
277
278 if (!kflag)
279 if (des_read_pw_string(key,KEYSIZB+1,"Enter key:",eflag?VERIFY:0))
280 {
281 fputs("password error\n",stderr);
282 EXIT(2);
283 }
284
285 if (in == NULL)
286 DES_IN=stdin;
287 else if ((DES_IN=fopen(in,"r")) == NULL)
288 {
289 perror("opening input file");
290 EXIT(4);
291 }
292
293 CKSUM_OUT=stdout;
294 if (out == NULL)
295 {
296 DES_OUT=stdout;
297 CKSUM_OUT=stderr;
298 }
299 else if ((DES_OUT=fopen(out,"w")) == NULL)
300 {
301 perror("opening output file");
302 EXIT(5);
303 }
304
305#ifdef OPENSSL_SYS_MSDOS
306 /* This should set the file to binary mode. */
307 {
308#include <fcntl.h>
309 if (!(uflag && dflag))
310 setmode(fileno(DES_IN),O_BINARY);
311 if (!(uflag && eflag))
312 setmode(fileno(DES_OUT),O_BINARY);
313 }
314#endif
315
316 doencryption();
317 fclose(DES_IN);
318 fclose(DES_OUT);
319 EXIT(0);
320 }
321
322void usage(void)
323 {
324 char **u;
325 static const char *Usage[]={
326"des <options> [input-file [output-file]]",
327"options:",
328"-v : des(1) version number",
329"-e : encrypt using SunOS compatible user key to DES key conversion.",
330"-E : encrypt ",
331"-d : decrypt using SunOS compatible user key to DES key conversion.",
332"-D : decrypt ",
333"-c[ckname] : generate a cbc_cksum using SunOS compatible user key to",
334" DES key conversion and output to ckname (stdout default,",
335" stderr if data being output on stdout). The checksum is",
336" generated before encryption and after decryption if used",
337" in conjunction with -[eEdD].",
338"-C[ckname] : generate a cbc_cksum as for -c but compatible with -[ED].",
339"-k key : use key 'key'",
340"-h : the key that is entered will be a hexadecimal number",
341" that is used directly as the des key",
342"-u[uuname] : input file is uudecoded if -[dD] or output uuencoded data if -[eE]",
343" (uuname is the filename to put in the uuencode header).",
344"-b : encrypt using DES in ecb encryption mode, the default is cbc mode.",
345"-3 : encrypt using triple DES encryption. This uses 2 keys",
346" generated from the input key. If the input key is less",
347" than 8 characters long, this is equivalent to normal",
348" encryption. Default is triple cbc, -b makes it triple ecb.",
349NULL
350};
351 for (u=(char **)Usage; *u; u++)
352 {
353 fputs(*u,stderr);
354 fputc('\n',stderr);
355 }
356
357 EXIT(1);
358 }
359
360void doencryption(void)
361 {
362#ifdef _LIBC
363 extern unsigned long time();
364#endif
365
366 register int i;
367 DES_key_schedule ks,ks2;
368 DES_cblock iv,iv2;
369 char *p;
370 int num=0,j,k,l,rem,ll,len,last,ex=0;
371 DES_cblock kk,k2;
372 FILE *O;
373 int Exit=0;
374#ifndef OPENSSL_SYS_MSDOS
375 static unsigned char buf[BUFSIZE+8],obuf[BUFSIZE+8];
376#else
377 static unsigned char *buf=NULL,*obuf=NULL;
378
379 if (buf == NULL)
380 {
381 if ( (( buf=OPENSSL_malloc(BUFSIZE+8)) == NULL) ||
382 ((obuf=OPENSSL_malloc(BUFSIZE+8)) == NULL))
383 {
384 fputs("Not enough memory\n",stderr);
385 Exit=10;
386 goto problems;
387 }
388 }
389#endif
390
391 if (hflag)
392 {
393 j=(flag3?16:8);
394 p=key;
395 for (i=0; i<j; i++)
396 {
397 k=0;
398 if ((*p <= '9') && (*p >= '0'))
399 k=(*p-'0')<<4;
400 else if ((*p <= 'f') && (*p >= 'a'))
401 k=(*p-'a'+10)<<4;
402 else if ((*p <= 'F') && (*p >= 'A'))
403 k=(*p-'A'+10)<<4;
404 else
405 {
406 fputs("Bad hex key\n",stderr);
407 Exit=9;
408 goto problems;
409 }
410 p++;
411 if ((*p <= '9') && (*p >= '0'))
412 k|=(*p-'0');
413 else if ((*p <= 'f') && (*p >= 'a'))
414 k|=(*p-'a'+10);
415 else if ((*p <= 'F') && (*p >= 'A'))
416 k|=(*p-'A'+10);
417 else
418 {
419 fputs("Bad hex key\n",stderr);
420 Exit=9;
421 goto problems;
422 }
423 p++;
424 if (i < 8)
425 kk[i]=k;
426 else
427 k2[i-8]=k;
428 }
429 DES_set_key_unchecked(&k2,&ks2);
430 OPENSSL_cleanse(k2,sizeof(k2));
431 }
432 else if (longk || flag3)
433 {
434 if (flag3)
435 {
436 DES_string_to_2keys(key,&kk,&k2);
437 DES_set_key_unchecked(&k2,&ks2);
438 OPENSSL_cleanse(k2,sizeof(k2));
439 }
440 else
441 DES_string_to_key(key,&kk);
442 }
443 else
444 for (i=0; i<KEYSIZ; i++)
445 {
446 l=0;
447 k=key[i];
448 for (j=0; j<8; j++)
449 {
450 if (k&1) l++;
451 k>>=1;
452 }
453 if (l & 1)
454 kk[i]=key[i]&0x7f;
455 else
456 kk[i]=key[i]|0x80;
457 }
458
459 DES_set_key_unchecked(&kk,&ks);
460 OPENSSL_cleanse(key,sizeof(key));
461 OPENSSL_cleanse(kk,sizeof(kk));
462 /* woops - A bug that does not showup under unix :-( */
463 memset(iv,0,sizeof(iv));
464 memset(iv2,0,sizeof(iv2));
465
466 l=1;
467 rem=0;
468 /* first read */
469 if (eflag || (!dflag && cflag))
470 {
471 for (;;)
472 {
473 num=l=fread(&(buf[rem]),1,BUFSIZE,DES_IN);
474 l+=rem;
475 num+=rem;
476 if (l < 0)
477 {
478 perror("read error");
479 Exit=6;
480 goto problems;
481 }
482
483 rem=l%8;
484 len=l-rem;
485 if (feof(DES_IN))
486 {
487 for (i=7-rem; i>0; i--)
488 RAND_pseudo_bytes(buf + l++, 1);
489 buf[l++]=rem;
490 ex=1;
491 len+=rem;
492 }
493 else
494 l-=rem;
495
496 if (cflag)
497 {
498 DES_cbc_cksum(buf,&cksum,
499 (long)len,&ks,&cksum);
500 if (!eflag)
501 {
502 if (feof(DES_IN)) break;
503 else continue;
504 }
505 }
506
507 if (bflag && !flag3)
508 for (i=0; i<l; i+=8)
509 DES_ecb_encrypt(
510 (DES_cblock *)&(buf[i]),
511 (DES_cblock *)&(obuf[i]),
512 &ks,do_encrypt);
513 else if (flag3 && bflag)
514 for (i=0; i<l; i+=8)
515 DES_ecb2_encrypt(
516 (DES_cblock *)&(buf[i]),
517 (DES_cblock *)&(obuf[i]),
518 &ks,&ks2,do_encrypt);
519 else if (flag3 && !bflag)
520 {
521 char tmpbuf[8];
522
523 if (rem) memcpy(tmpbuf,&(buf[l]),
524 (unsigned int)rem);
525 DES_3cbc_encrypt(
526 (DES_cblock *)buf,(DES_cblock *)obuf,
527 (long)l,ks,ks2,&iv,
528 &iv2,do_encrypt);
529 if (rem) memcpy(&(buf[l]),tmpbuf,
530 (unsigned int)rem);
531 }
532 else
533 {
534 DES_cbc_encrypt(
535 buf,obuf,
536 (long)l,&ks,&iv,do_encrypt);
537 if (l >= 8) memcpy(iv,&(obuf[l-8]),8);
538 }
539 if (rem) memcpy(buf,&(buf[l]),(unsigned int)rem);
540
541 i=0;
542 while (i < l)
543 {
544 if (uflag)
545 j=uufwrite(obuf,1,(unsigned int)l-i,
546 DES_OUT);
547 else
548 j=fwrite(obuf,1,(unsigned int)l-i,
549 DES_OUT);
550 if (j == -1)
551 {
552 perror("Write error");
553 Exit=7;
554 goto problems;
555 }
556 i+=j;
557 }
558 if (feof(DES_IN))
559 {
560 if (uflag) uufwriteEnd(DES_OUT);
561 break;
562 }
563 }
564 }
565 else /* decrypt */
566 {
567 ex=1;
568 for (;;)
569 {
570 if (ex) {
571 if (uflag)
572 l=uufread(buf,1,BUFSIZE,DES_IN);
573 else
574 l=fread(buf,1,BUFSIZE,DES_IN);
575 ex=0;
576 rem=l%8;
577 l-=rem;
578 }
579 if (l < 0)
580 {
581 perror("read error");
582 Exit=6;
583 goto problems;
584 }
585
586 if (bflag && !flag3)
587 for (i=0; i<l; i+=8)
588 DES_ecb_encrypt(
589 (DES_cblock *)&(buf[i]),
590 (DES_cblock *)&(obuf[i]),
591 &ks,do_encrypt);
592 else if (flag3 && bflag)
593 for (i=0; i<l; i+=8)
594 DES_ecb2_encrypt(
595 (DES_cblock *)&(buf[i]),
596 (DES_cblock *)&(obuf[i]),
597 &ks,&ks2,do_encrypt);
598 else if (flag3 && !bflag)
599 {
600 DES_3cbc_encrypt(
601 (DES_cblock *)buf,(DES_cblock *)obuf,
602 (long)l,ks,ks2,&iv,
603 &iv2,do_encrypt);
604 }
605 else
606 {
607 DES_cbc_encrypt(
608 buf,obuf,
609 (long)l,&ks,&iv,do_encrypt);
610 if (l >= 8) memcpy(iv,&(buf[l-8]),8);
611 }
612
613 if (uflag)
614 ll=uufread(&(buf[rem]),1,BUFSIZE,DES_IN);
615 else
616 ll=fread(&(buf[rem]),1,BUFSIZE,DES_IN);
617 ll+=rem;
618 rem=ll%8;
619 ll-=rem;
620 if (feof(DES_IN) && (ll == 0))
621 {
622 last=obuf[l-1];
623
624 if ((last > 7) || (last < 0))
625 {
626 fputs("The file was not decrypted correctly.\n",
627 stderr);
628 Exit=8;
629 last=0;
630 }
631 l=l-8+last;
632 }
633 i=0;
634 if (cflag) DES_cbc_cksum(obuf,
635 (DES_cblock *)cksum,(long)l/8*8,&ks,
636 (DES_cblock *)cksum);
637 while (i != l)
638 {
639 j=fwrite(obuf,1,(unsigned int)l-i,DES_OUT);
640 if (j == -1)
641 {
642 perror("Write error");
643 Exit=7;
644 goto problems;
645 }
646 i+=j;
647 }
648 l=ll;
649 if ((l == 0) && feof(DES_IN)) break;
650 }
651 }
652 if (cflag)
653 {
654 l=0;
655 if (cksumname[0] != '\0')
656 {
657 if ((O=fopen(cksumname,"w")) != NULL)
658 {
659 CKSUM_OUT=O;
660 l=1;
661 }
662 }
663 for (i=0; i<8; i++)
664 fprintf(CKSUM_OUT,"%02X",cksum[i]);
665 fprintf(CKSUM_OUT,"\n");
666 if (l) fclose(CKSUM_OUT);
667 }
668problems:
669 OPENSSL_cleanse(buf,sizeof(buf));
670 OPENSSL_cleanse(obuf,sizeof(obuf));
671 OPENSSL_cleanse(&ks,sizeof(ks));
672 OPENSSL_cleanse(&ks2,sizeof(ks2));
673 OPENSSL_cleanse(iv,sizeof(iv));
674 OPENSSL_cleanse(iv2,sizeof(iv2));
675 OPENSSL_cleanse(kk,sizeof(kk));
676 OPENSSL_cleanse(k2,sizeof(k2));
677 OPENSSL_cleanse(uubuf,sizeof(uubuf));
678 OPENSSL_cleanse(b,sizeof(b));
679 OPENSSL_cleanse(bb,sizeof(bb));
680 OPENSSL_cleanse(cksum,sizeof(cksum));
681 if (Exit) EXIT(Exit);
682 }
683
684/* We ignore this parameter but it should be > ~50 I believe */
685int uufwrite(unsigned char *data, int size, unsigned int num, FILE *fp)
686 {
687 int i,j,left,rem,ret=num;
688 static int start=1;
689
690 if (start)
691 {
692 fprintf(fp,"begin 600 %s\n",
693 (uuname[0] == '\0')?"text.d":uuname);
694 start=0;
695 }
696
697 if (uubufnum)
698 {
699 if (uubufnum+num < 45)
700 {
701 memcpy(&(uubuf[uubufnum]),data,(unsigned int)num);
702 uubufnum+=num;
703 return(num);
704 }
705 else
706 {
707 i=45-uubufnum;
708 memcpy(&(uubuf[uubufnum]),data,(unsigned int)i);
709 j=uuencode((unsigned char *)uubuf,45,b);
710 fwrite(b,1,(unsigned int)j,fp);
711 uubufnum=0;
712 data+=i;
713 num-=i;
714 }
715 }
716
717 for (i=0; i<(((int)num)-INUUBUFN); i+=INUUBUFN)
718 {
719 j=uuencode(&(data[i]),INUUBUFN,b);
720 fwrite(b,1,(unsigned int)j,fp);
721 }
722 rem=(num-i)%45;
723 left=(num-i-rem);
724 if (left)
725 {
726 j=uuencode(&(data[i]),left,b);
727 fwrite(b,1,(unsigned int)j,fp);
728 i+=left;
729 }
730 if (i != num)
731 {
732 memcpy(uubuf,&(data[i]),(unsigned int)rem);
733 uubufnum=rem;
734 }
735 return(ret);
736 }
737
738void uufwriteEnd(FILE *fp)
739 {
740 int j;
741 static const char *end=" \nend\n";
742
743 if (uubufnum != 0)
744 {
745 uubuf[uubufnum]='\0';
746 uubuf[uubufnum+1]='\0';
747 uubuf[uubufnum+2]='\0';
748 j=uuencode(uubuf,uubufnum,b);
749 fwrite(b,1,(unsigned int)j,fp);
750 }
751 fwrite(end,1,strlen(end),fp);
752 }
753
754/* int size: should always be > ~ 60; I actually ignore this parameter :-) */
755int uufread(unsigned char *out, int size, unsigned int num, FILE *fp)
756 {
757 int i,j,tot;
758 static int done=0;
759 static int valid=0;
760 static int start=1;
761
762 if (start)
763 {
764 for (;;)
765 {
766 b[0]='\0';
767 fgets((char *)b,300,fp);
768 if (b[0] == '\0')
769 {
770 fprintf(stderr,"no 'begin' found in uuencoded input\n");
771 return(-1);
772 }
773 if (strncmp((char *)b,"begin ",6) == 0) break;
774 }
775 start=0;
776 }
777 if (done) return(0);
778 tot=0;
779 if (valid)
780 {
781 memcpy(out,bb,(unsigned int)valid);
782 tot=valid;
783 valid=0;
784 }
785 for (;;)
786 {
787 b[0]='\0';
788 fgets((char *)b,300,fp);
789 if (b[0] == '\0') break;
790 i=strlen((char *)b);
791 if ((b[0] == 'e') && (b[1] == 'n') && (b[2] == 'd'))
792 {
793 done=1;
794 while (!feof(fp))
795 {
796 fgets((char *)b,300,fp);
797 }
798 break;
799 }
800 i=uudecode(b,i,bb);
801 if (i < 0) break;
802 if ((i+tot+8) > num)
803 {
804 /* num to copy to make it a multiple of 8 */
805 j=(num/8*8)-tot-8;
806 memcpy(&(out[tot]),bb,(unsigned int)j);
807 tot+=j;
808 memcpy(bb,&(bb[j]),(unsigned int)i-j);
809 valid=i-j;
810 break;
811 }
812 memcpy(&(out[tot]),bb,(unsigned int)i);
813 tot+=i;
814 }
815 return(tot);
816 }
817
818#define ccc2l(c,l) (l =((DES_LONG)(*((c)++)))<<16, \
819 l|=((DES_LONG)(*((c)++)))<< 8, \
820 l|=((DES_LONG)(*((c)++))))
821
822#define l2ccc(l,c) (*((c)++)=(unsigned char)(((l)>>16)&0xff), \
823 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \
824 *((c)++)=(unsigned char)(((l) )&0xff))
825
826
827int uuencode(unsigned char *in, int num, unsigned char *out)
828 {
829 int j,i,n,tot=0;
830 DES_LONG l;
831 register unsigned char *p;
832 p=out;
833
834 for (j=0; j<num; j+=45)
835 {
836 if (j+45 > num)
837 i=(num-j);
838 else i=45;
839 *(p++)=i+' ';
840 for (n=0; n<i; n+=3)
841 {
842 ccc2l(in,l);
843 *(p++)=((l>>18)&0x3f)+' ';
844 *(p++)=((l>>12)&0x3f)+' ';
845 *(p++)=((l>> 6)&0x3f)+' ';
846 *(p++)=((l )&0x3f)+' ';
847 tot+=4;
848 }
849 *(p++)='\n';
850 tot+=2;
851 }
852 *p='\0';
853 l=0;
854 return(tot);
855 }
856
857int uudecode(unsigned char *in, int num, unsigned char *out)
858 {
859 int j,i,k;
860 unsigned int n=0,space=0;
861 DES_LONG l;
862 DES_LONG w,x,y,z;
863 unsigned int blank=(unsigned int)'\n'-' ';
864
865 for (j=0; j<num; )
866 {
867 n= *(in++)-' ';
868 if (n == blank)
869 {
870 n=0;
871 in--;
872 }
873 if (n > 60)
874 {
875 fprintf(stderr,"uuencoded line length too long\n");
876 return(-1);
877 }
878 j++;
879
880 for (i=0; i<n; j+=4,i+=3)
881 {
882 /* the following is for cases where spaces are
883 * removed from lines.
884 */
885 if (space)
886 {
887 w=x=y=z=0;
888 }
889 else
890 {
891 w= *(in++)-' ';
892 x= *(in++)-' ';
893 y= *(in++)-' ';
894 z= *(in++)-' ';
895 }
896 if ((w > 63) || (x > 63) || (y > 63) || (z > 63))
897 {
898 k=0;
899 if (w == blank) k=1;
900 if (x == blank) k=2;
901 if (y == blank) k=3;
902 if (z == blank) k=4;
903 space=1;
904 switch (k) {
905 case 1: w=0; in--;
906 case 2: x=0; in--;
907 case 3: y=0; in--;
908 case 4: z=0; in--;
909 break;
910 case 0:
911 space=0;
912 fprintf(stderr,"bad uuencoded data values\n");
913 w=x=y=z=0;
914 return(-1);
915 break;
916 }
917 }
918 l=(w<<18)|(x<<12)|(y<< 6)|(z );
919 l2ccc(l,out);
920 }
921 if (*(in++) != '\n')
922 {
923 fprintf(stderr,"missing nl in uuencoded line\n");
924 w=x=y=z=0;
925 return(-1);
926 }
927 j++;
928 }
929 *out='\0';
930 w=x=y=z=0;
931 return(n);
932 }
diff --git a/src/lib/libcrypto/des/des.h b/src/lib/libcrypto/des/des.h
deleted file mode 100644
index 7318593699..0000000000
--- a/src/lib/libcrypto/des/des.h
+++ /dev/null
@@ -1,247 +0,0 @@
1/* crypto/des/des.h */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef HEADER_DES_H
60#define HEADER_DES_H
61
62#include <openssl/e_os2.h> /* OPENSSL_EXTERN, OPENSSL_NO_DES,
63 DES_LONG (via openssl/opensslconf.h */
64
65#ifdef OPENSSL_NO_DES
66#error DES is disabled.
67#endif
68
69#ifdef OPENSSL_BUILD_SHLIBCRYPTO
70# undef OPENSSL_EXTERN
71# define OPENSSL_EXTERN OPENSSL_EXPORT
72#endif
73
74#define des_SPtrans DES_SPtrans
75
76#ifdef __cplusplus
77extern "C" {
78#endif
79
80typedef unsigned char DES_cblock[8];
81typedef /* const */ unsigned char const_DES_cblock[8];
82/* With "const", gcc 2.8.1 on Solaris thinks that DES_cblock *
83 * and const_DES_cblock * are incompatible pointer types. */
84
85typedef struct DES_ks
86 {
87 union
88 {
89 DES_cblock cblock;
90 /* make sure things are correct size on machines with
91 * 8 byte longs */
92 DES_LONG deslong[2];
93 } ks[16];
94 } DES_key_schedule;
95
96#ifndef OPENSSL_DISABLE_OLD_DES_SUPPORT
97# ifndef OPENSSL_ENABLE_OLD_DES_SUPPORT
98# define OPENSSL_ENABLE_OLD_DES_SUPPORT
99# endif
100#endif
101
102#ifdef OPENSSL_ENABLE_OLD_DES_SUPPORT
103# include <openssl/des_old.h>
104#endif
105
106#define DES_KEY_SZ (sizeof(DES_cblock))
107#define DES_SCHEDULE_SZ (sizeof(DES_key_schedule))
108
109#define DES_ENCRYPT 1
110#define DES_DECRYPT 0
111
112#define DES_CBC_MODE 0
113#define DES_PCBC_MODE 1
114
115#define DES_ecb2_encrypt(i,o,k1,k2,e) \
116 DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
117
118#define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
119 DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
120
121#define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
122 DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
123
124#define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
125 DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
126
127OPENSSL_DECLARE_GLOBAL(int,DES_check_key); /* defaults to false */
128#define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key)
129OPENSSL_DECLARE_GLOBAL(int,DES_rw_mode); /* defaults to DES_PCBC_MODE */
130#define DES_rw_mode OPENSSL_GLOBAL_REF(DES_rw_mode)
131
132const char *DES_options(void);
133void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
134 DES_key_schedule *ks1,DES_key_schedule *ks2,
135 DES_key_schedule *ks3, int enc);
136DES_LONG DES_cbc_cksum(const unsigned char *input,DES_cblock *output,
137 long length,DES_key_schedule *schedule,
138 const_DES_cblock *ivec);
139/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */
140void DES_cbc_encrypt(const unsigned char *input,unsigned char *output,
141 long length,DES_key_schedule *schedule,DES_cblock *ivec,
142 int enc);
143void DES_ncbc_encrypt(const unsigned char *input,unsigned char *output,
144 long length,DES_key_schedule *schedule,DES_cblock *ivec,
145 int enc);
146void DES_xcbc_encrypt(const unsigned char *input,unsigned char *output,
147 long length,DES_key_schedule *schedule,DES_cblock *ivec,
148 const_DES_cblock *inw,const_DES_cblock *outw,int enc);
149void DES_cfb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
150 long length,DES_key_schedule *schedule,DES_cblock *ivec,
151 int enc);
152void DES_ecb_encrypt(const_DES_cblock *input,DES_cblock *output,
153 DES_key_schedule *ks,int enc);
154
155/* This is the DES encryption function that gets called by just about
156 every other DES routine in the library. You should not use this
157 function except to implement 'modes' of DES. I say this because the
158 functions that call this routine do the conversion from 'char *' to
159 long, and this needs to be done to make sure 'non-aligned' memory
160 access do not occur. The characters are loaded 'little endian'.
161 Data is a pointer to 2 unsigned long's and ks is the
162 DES_key_schedule to use. enc, is non zero specifies encryption,
163 zero if decryption. */
164void DES_encrypt1(DES_LONG *data,DES_key_schedule *ks, int enc);
165
166/* This functions is the same as DES_encrypt1() except that the DES
167 initial permutation (IP) and final permutation (FP) have been left
168 out. As for DES_encrypt1(), you should not use this function.
169 It is used by the routines in the library that implement triple DES.
170 IP() DES_encrypt2() DES_encrypt2() DES_encrypt2() FP() is the same
171 as DES_encrypt1() DES_encrypt1() DES_encrypt1() except faster :-). */
172void DES_encrypt2(DES_LONG *data,DES_key_schedule *ks, int enc);
173
174void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
175 DES_key_schedule *ks2, DES_key_schedule *ks3);
176void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
177 DES_key_schedule *ks2, DES_key_schedule *ks3);
178void DES_ede3_cbc_encrypt(const unsigned char *input,unsigned char *output,
179 long length,
180 DES_key_schedule *ks1,DES_key_schedule *ks2,
181 DES_key_schedule *ks3,DES_cblock *ivec,int enc);
182void DES_ede3_cbcm_encrypt(const unsigned char *in,unsigned char *out,
183 long length,
184 DES_key_schedule *ks1,DES_key_schedule *ks2,
185 DES_key_schedule *ks3,
186 DES_cblock *ivec1,DES_cblock *ivec2,
187 int enc);
188void DES_ede3_cfb64_encrypt(const unsigned char *in,unsigned char *out,
189 long length,DES_key_schedule *ks1,
190 DES_key_schedule *ks2,DES_key_schedule *ks3,
191 DES_cblock *ivec,int *num,int enc);
192void DES_ede3_cfb_encrypt(const unsigned char *in,unsigned char *out,
193 int numbits,long length,DES_key_schedule *ks1,
194 DES_key_schedule *ks2,DES_key_schedule *ks3,
195 DES_cblock *ivec,int enc);
196void DES_ede3_ofb64_encrypt(const unsigned char *in,unsigned char *out,
197 long length,DES_key_schedule *ks1,
198 DES_key_schedule *ks2,DES_key_schedule *ks3,
199 DES_cblock *ivec,int *num);
200#if 0
201void DES_xwhite_in2out(const_DES_cblock *DES_key,const_DES_cblock *in_white,
202 DES_cblock *out_white);
203#endif
204
205int DES_enc_read(int fd,void *buf,int len,DES_key_schedule *sched,
206 DES_cblock *iv);
207int DES_enc_write(int fd,const void *buf,int len,DES_key_schedule *sched,
208 DES_cblock *iv);
209char *DES_fcrypt(const char *buf,const char *salt, char *ret);
210char *DES_crypt(const char *buf,const char *salt);
211void DES_ofb_encrypt(const unsigned char *in,unsigned char *out,int numbits,
212 long length,DES_key_schedule *schedule,DES_cblock *ivec);
213void DES_pcbc_encrypt(const unsigned char *input,unsigned char *output,
214 long length,DES_key_schedule *schedule,DES_cblock *ivec,
215 int enc);
216DES_LONG DES_quad_cksum(const unsigned char *input,DES_cblock output[],
217 long length,int out_count,DES_cblock *seed);
218int DES_random_key(DES_cblock *ret);
219void DES_set_odd_parity(DES_cblock *key);
220int DES_check_key_parity(const_DES_cblock *key);
221int DES_is_weak_key(const_DES_cblock *key);
222/* DES_set_key (= set_key = DES_key_sched = key_sched) calls
223 * DES_set_key_checked if global variable DES_check_key is set,
224 * DES_set_key_unchecked otherwise. */
225int DES_set_key(const_DES_cblock *key,DES_key_schedule *schedule);
226int DES_key_sched(const_DES_cblock *key,DES_key_schedule *schedule);
227int DES_set_key_checked(const_DES_cblock *key,DES_key_schedule *schedule);
228void DES_set_key_unchecked(const_DES_cblock *key,DES_key_schedule *schedule);
229void DES_string_to_key(const char *str,DES_cblock *key);
230void DES_string_to_2keys(const char *str,DES_cblock *key1,DES_cblock *key2);
231void DES_cfb64_encrypt(const unsigned char *in,unsigned char *out,long length,
232 DES_key_schedule *schedule,DES_cblock *ivec,int *num,
233 int enc);
234void DES_ofb64_encrypt(const unsigned char *in,unsigned char *out,long length,
235 DES_key_schedule *schedule,DES_cblock *ivec,int *num);
236
237int DES_read_password(DES_cblock *key, const char *prompt, int verify);
238int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt,
239 int verify);
240
241#define DES_fixup_key_parity DES_set_odd_parity
242
243#ifdef __cplusplus
244}
245#endif
246
247#endif
diff --git a/src/lib/libcrypto/des/des.pod b/src/lib/libcrypto/des/des.pod
deleted file mode 100644
index bf479e83d2..0000000000
--- a/src/lib/libcrypto/des/des.pod
+++ /dev/null
@@ -1,217 +0,0 @@
1=pod
2
3=head1 NAME
4
5des - encrypt or decrypt data using Data Encryption Standard
6
7=head1 SYNOPSIS
8
9B<des>
10(
11B<-e>
12|
13B<-E>
14) | (
15B<-d>
16|
17B<-D>
18) | (
19B<->[B<cC>][B<ckname>]
20) |
21[
22B<-b3hfs>
23] [
24B<-k>
25I<key>
26]
27] [
28B<-u>[I<uuname>]
29[
30I<input-file>
31[
32I<output-file>
33] ]
34
35=head1 NOTE
36
37This page describes the B<des> stand-alone program, not the B<openssl des>
38command.
39
40=head1 DESCRIPTION
41
42B<des>
43encrypts and decrypts data using the
44Data Encryption Standard algorithm.
45One of
46B<-e>, B<-E>
47(for encrypt) or
48B<-d>, B<-D>
49(for decrypt) must be specified.
50It is also possible to use
51B<-c>
52or
53B<-C>
54in conjunction or instead of the a encrypt/decrypt option to generate
55a 16 character hexadecimal checksum, generated via the
56I<des_cbc_cksum>.
57
58Two standard encryption modes are supported by the
59B<des>
60program, Cipher Block Chaining (the default) and Electronic Code Book
61(specified with
62B<-b>).
63
64The key used for the DES
65algorithm is obtained by prompting the user unless the
66B<-k>
67I<key>
68option is given.
69If the key is an argument to the
70B<des>
71command, it is potentially visible to users executing
72ps(1)
73or a derivative. To minimise this possibility,
74B<des>
75takes care to destroy the key argument immediately upon entry.
76If your shell keeps a history file be careful to make sure it is not
77world readable.
78
79Since this program attempts to maintain compatibility with sunOS's
80des(1) command, there are 2 different methods used to convert the user
81supplied key to a des key.
82Whenever and one or more of
83B<-E>, B<-D>, B<-C>
84or
85B<-3>
86options are used, the key conversion procedure will not be compatible
87with the sunOS des(1) version but will use all the user supplied
88character to generate the des key.
89B<des>
90command reads from standard input unless
91I<input-file>
92is specified and writes to standard output unless
93I<output-file>
94is given.
95
96=head1 OPTIONS
97
98=over 4
99
100=item B<-b>
101
102Select ECB
103(eight bytes at a time) encryption mode.
104
105=item B<-3>
106
107Encrypt using triple encryption.
108By default triple cbc encryption is used but if the
109B<-b>
110option is used then triple ECB encryption is performed.
111If the key is less than 8 characters long, the flag has no effect.
112
113=item B<-e>
114
115Encrypt data using an 8 byte key in a manner compatible with sunOS
116des(1).
117
118=item B<-E>
119
120Encrypt data using a key of nearly unlimited length (1024 bytes).
121This will product a more secure encryption.
122
123=item B<-d>
124
125Decrypt data that was encrypted with the B<-e> option.
126
127=item B<-D>
128
129Decrypt data that was encrypted with the B<-E> option.
130
131=item B<-c>
132
133Generate a 16 character hexadecimal cbc checksum and output this to
134stderr.
135If a filename was specified after the
136B<-c>
137option, the checksum is output to that file.
138The checksum is generated using a key generated in a sunOS compatible
139manner.
140
141=item B<-C>
142
143A cbc checksum is generated in the same manner as described for the
144B<-c>
145option but the DES key is generated in the same manner as used for the
146B<-E>
147and
148B<-D>
149options
150
151=item B<-f>
152
153Does nothing - allowed for compatibility with sunOS des(1) command.
154
155=item B<-s>
156
157Does nothing - allowed for compatibility with sunOS des(1) command.
158
159=item B<-k> I<key>
160
161Use the encryption
162I<key>
163specified.
164
165=item B<-h>
166
167The
168I<key>
169is assumed to be a 16 character hexadecimal number.
170If the
171B<-3>
172option is used the key is assumed to be a 32 character hexadecimal
173number.
174
175=item B<-u>
176
177This flag is used to read and write uuencoded files. If decrypting,
178the input file is assumed to contain uuencoded, DES encrypted data.
179If encrypting, the characters following the B<-u> are used as the name of
180the uuencoded file to embed in the begin line of the uuencoded
181output. If there is no name specified after the B<-u>, the name text.des
182will be embedded in the header.
183
184=head1 SEE ALSO
185
186ps(1),
187L<des_crypt(3)|des_crypt(3)>
188
189=head1 BUGS
190
191The problem with using the
192B<-e>
193option is the short key length.
194It would be better to use a real 56-bit key rather than an
195ASCII-based 56-bit pattern. Knowing that the key was derived from ASCII
196radically reduces the time necessary for a brute-force cryptographic attack.
197My attempt to remove this problem is to add an alternative text-key to
198DES-key function. This alternative function (accessed via
199B<-E>, B<-D>, B<-S>
200and
201B<-3>)
202uses DES to help generate the key.
203
204Be carefully when using the B<-u> option. Doing B<des -ud> I<filename> will
205not decrypt filename (the B<-u> option will gobble the B<-d> option).
206
207The VMS operating system operates in a world where files are always a
208multiple of 512 bytes. This causes problems when encrypted data is
209send from Unix to VMS since a 88 byte file will suddenly be padded
210with 424 null bytes. To get around this problem, use the B<-u> option
211to uuencode the data before it is send to the VMS system.
212
213=head1 AUTHOR
214
215Eric Young (eay@cryptsoft.com)
216
217=cut
diff --git a/src/lib/libcrypto/des/des3s.cpp b/src/lib/libcrypto/des/des3s.cpp
deleted file mode 100644
index 02d527c057..0000000000
--- a/src/lib/libcrypto/des/des3s.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
1//
2// gettsc.inl
3//
4// gives access to the Pentium's (secret) cycle counter
5//
6// This software was written by Leonard Janke (janke@unixg.ubc.ca)
7// in 1996-7 and is entered, by him, into the public domain.
8
9#if defined(__WATCOMC__)
10void GetTSC(unsigned long&);
11#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax];
12#elif defined(__GNUC__)
13inline
14void GetTSC(unsigned long& tsc)
15{
16 asm volatile(".byte 15, 49\n\t"
17 : "=eax" (tsc)
18 :
19 : "%edx", "%eax");
20}
21#elif defined(_MSC_VER)
22inline
23void GetTSC(unsigned long& tsc)
24{
25 unsigned long a;
26 __asm _emit 0fh
27 __asm _emit 31h
28 __asm mov a, eax;
29 tsc=a;
30}
31#endif
32
33#include <stdio.h>
34#include <stdlib.h>
35#include <openssl/des.h>
36
37void main(int argc,char *argv[])
38 {
39 des_key_schedule key1,key2,key3;
40 unsigned long s1,s2,e1,e2;
41 unsigned long data[2];
42 int i,j;
43
44 for (j=0; j<6; j++)
45 {
46 for (i=0; i<1000; i++) /**/
47 {
48 des_encrypt3(&data[0],key1,key2,key3);
49 GetTSC(s1);
50 des_encrypt3(&data[0],key1,key2,key3);
51 des_encrypt3(&data[0],key1,key2,key3);
52 des_encrypt3(&data[0],key1,key2,key3);
53 GetTSC(e1);
54 GetTSC(s2);
55 des_encrypt3(&data[0],key1,key2,key3);
56 des_encrypt3(&data[0],key1,key2,key3);
57 des_encrypt3(&data[0],key1,key2,key3);
58 des_encrypt3(&data[0],key1,key2,key3);
59 GetTSC(e2);
60 des_encrypt3(&data[0],key1,key2,key3);
61 }
62
63 printf("des %d %d (%d)\n",
64 e1-s1,e2-s2,((e2-s2)-(e1-s1)));
65 }
66 }
67
diff --git a/src/lib/libcrypto/des/des_enc.c b/src/lib/libcrypto/des/des_enc.c
deleted file mode 100644
index 5c47553a5a..0000000000
--- a/src/lib/libcrypto/des/des_enc.c
+++ /dev/null
@@ -1,404 +0,0 @@
1/* crypto/des/des_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60#include "spr.h"
61
62#ifndef OPENBSD_DES_ASM
63
64void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc)
65 {
66 register DES_LONG l,r,t,u;
67#ifdef DES_PTR
68 register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans;
69#endif
70#ifndef DES_UNROLL
71 register int i;
72#endif
73 register DES_LONG *s;
74
75 r=data[0];
76 l=data[1];
77
78 IP(r,l);
79 /* Things have been modified so that the initial rotate is
80 * done outside the loop. This required the
81 * DES_SPtrans values in sp.h to be rotated 1 bit to the right.
82 * One perl script later and things have a 5% speed up on a sparc2.
83 * Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
84 * for pointing this out. */
85 /* clear the top bits on machines with 8byte longs */
86 /* shift left by 2 */
87 r=ROTATE(r,29)&0xffffffffL;
88 l=ROTATE(l,29)&0xffffffffL;
89
90 s=ks->ks->deslong;
91 /* I don't know if it is worth the effort of loop unrolling the
92 * inner loop */
93 if (enc)
94 {
95#ifdef DES_UNROLL
96 D_ENCRYPT(l,r, 0); /* 1 */
97 D_ENCRYPT(r,l, 2); /* 2 */
98 D_ENCRYPT(l,r, 4); /* 3 */
99 D_ENCRYPT(r,l, 6); /* 4 */
100 D_ENCRYPT(l,r, 8); /* 5 */
101 D_ENCRYPT(r,l,10); /* 6 */
102 D_ENCRYPT(l,r,12); /* 7 */
103 D_ENCRYPT(r,l,14); /* 8 */
104 D_ENCRYPT(l,r,16); /* 9 */
105 D_ENCRYPT(r,l,18); /* 10 */
106 D_ENCRYPT(l,r,20); /* 11 */
107 D_ENCRYPT(r,l,22); /* 12 */
108 D_ENCRYPT(l,r,24); /* 13 */
109 D_ENCRYPT(r,l,26); /* 14 */
110 D_ENCRYPT(l,r,28); /* 15 */
111 D_ENCRYPT(r,l,30); /* 16 */
112#else
113 for (i=0; i<32; i+=4)
114 {
115 D_ENCRYPT(l,r,i+0); /* 1 */
116 D_ENCRYPT(r,l,i+2); /* 2 */
117 }
118#endif
119 }
120 else
121 {
122#ifdef DES_UNROLL
123 D_ENCRYPT(l,r,30); /* 16 */
124 D_ENCRYPT(r,l,28); /* 15 */
125 D_ENCRYPT(l,r,26); /* 14 */
126 D_ENCRYPT(r,l,24); /* 13 */
127 D_ENCRYPT(l,r,22); /* 12 */
128 D_ENCRYPT(r,l,20); /* 11 */
129 D_ENCRYPT(l,r,18); /* 10 */
130 D_ENCRYPT(r,l,16); /* 9 */
131 D_ENCRYPT(l,r,14); /* 8 */
132 D_ENCRYPT(r,l,12); /* 7 */
133 D_ENCRYPT(l,r,10); /* 6 */
134 D_ENCRYPT(r,l, 8); /* 5 */
135 D_ENCRYPT(l,r, 6); /* 4 */
136 D_ENCRYPT(r,l, 4); /* 3 */
137 D_ENCRYPT(l,r, 2); /* 2 */
138 D_ENCRYPT(r,l, 0); /* 1 */
139#else
140 for (i=30; i>0; i-=4)
141 {
142 D_ENCRYPT(l,r,i-0); /* 16 */
143 D_ENCRYPT(r,l,i-2); /* 15 */
144 }
145#endif
146 }
147
148 /* rotate and clear the top bits on machines with 8byte longs */
149 l=ROTATE(l,3)&0xffffffffL;
150 r=ROTATE(r,3)&0xffffffffL;
151
152 FP(r,l);
153 data[0]=l;
154 data[1]=r;
155 l=r=t=u=0;
156 }
157
158void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc)
159 {
160 register DES_LONG l,r,t,u;
161#ifdef DES_PTR
162 register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans;
163#endif
164#ifndef DES_UNROLL
165 register int i;
166#endif
167 register DES_LONG *s;
168
169 r=data[0];
170 l=data[1];
171
172 /* Things have been modified so that the initial rotate is
173 * done outside the loop. This required the
174 * DES_SPtrans values in sp.h to be rotated 1 bit to the right.
175 * One perl script later and things have a 5% speed up on a sparc2.
176 * Thanks to Richard Outerbridge <71755.204@CompuServe.COM>
177 * for pointing this out. */
178 /* clear the top bits on machines with 8byte longs */
179 r=ROTATE(r,29)&0xffffffffL;
180 l=ROTATE(l,29)&0xffffffffL;
181
182 s=ks->ks->deslong;
183 /* I don't know if it is worth the effort of loop unrolling the
184 * inner loop */
185 if (enc)
186 {
187#ifdef DES_UNROLL
188 D_ENCRYPT(l,r, 0); /* 1 */
189 D_ENCRYPT(r,l, 2); /* 2 */
190 D_ENCRYPT(l,r, 4); /* 3 */
191 D_ENCRYPT(r,l, 6); /* 4 */
192 D_ENCRYPT(l,r, 8); /* 5 */
193 D_ENCRYPT(r,l,10); /* 6 */
194 D_ENCRYPT(l,r,12); /* 7 */
195 D_ENCRYPT(r,l,14); /* 8 */
196 D_ENCRYPT(l,r,16); /* 9 */
197 D_ENCRYPT(r,l,18); /* 10 */
198 D_ENCRYPT(l,r,20); /* 11 */
199 D_ENCRYPT(r,l,22); /* 12 */
200 D_ENCRYPT(l,r,24); /* 13 */
201 D_ENCRYPT(r,l,26); /* 14 */
202 D_ENCRYPT(l,r,28); /* 15 */
203 D_ENCRYPT(r,l,30); /* 16 */
204#else
205 for (i=0; i<32; i+=4)
206 {
207 D_ENCRYPT(l,r,i+0); /* 1 */
208 D_ENCRYPT(r,l,i+2); /* 2 */
209 }
210#endif
211 }
212 else
213 {
214#ifdef DES_UNROLL
215 D_ENCRYPT(l,r,30); /* 16 */
216 D_ENCRYPT(r,l,28); /* 15 */
217 D_ENCRYPT(l,r,26); /* 14 */
218 D_ENCRYPT(r,l,24); /* 13 */
219 D_ENCRYPT(l,r,22); /* 12 */
220 D_ENCRYPT(r,l,20); /* 11 */
221 D_ENCRYPT(l,r,18); /* 10 */
222 D_ENCRYPT(r,l,16); /* 9 */
223 D_ENCRYPT(l,r,14); /* 8 */
224 D_ENCRYPT(r,l,12); /* 7 */
225 D_ENCRYPT(l,r,10); /* 6 */
226 D_ENCRYPT(r,l, 8); /* 5 */
227 D_ENCRYPT(l,r, 6); /* 4 */
228 D_ENCRYPT(r,l, 4); /* 3 */
229 D_ENCRYPT(l,r, 2); /* 2 */
230 D_ENCRYPT(r,l, 0); /* 1 */
231#else
232 for (i=30; i>0; i-=4)
233 {
234 D_ENCRYPT(l,r,i-0); /* 16 */
235 D_ENCRYPT(r,l,i-2); /* 15 */
236 }
237#endif
238 }
239 /* rotate and clear the top bits on machines with 8byte longs */
240 data[0]=ROTATE(l,3)&0xffffffffL;
241 data[1]=ROTATE(r,3)&0xffffffffL;
242 l=r=t=u=0;
243 }
244
245#endif /* OPENBSD_DES_ASM */
246
247void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1,
248 DES_key_schedule *ks2, DES_key_schedule *ks3)
249 {
250 register DES_LONG l,r;
251
252 l=data[0];
253 r=data[1];
254 IP(l,r);
255 data[0]=l;
256 data[1]=r;
257 DES_encrypt2((DES_LONG *)data,ks1,DES_ENCRYPT);
258 DES_encrypt2((DES_LONG *)data,ks2,DES_DECRYPT);
259 DES_encrypt2((DES_LONG *)data,ks3,DES_ENCRYPT);
260 l=data[0];
261 r=data[1];
262 FP(r,l);
263 data[0]=l;
264 data[1]=r;
265 }
266
267void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1,
268 DES_key_schedule *ks2, DES_key_schedule *ks3)
269 {
270 register DES_LONG l,r;
271
272 l=data[0];
273 r=data[1];
274 IP(l,r);
275 data[0]=l;
276 data[1]=r;
277 DES_encrypt2((DES_LONG *)data,ks3,DES_DECRYPT);
278 DES_encrypt2((DES_LONG *)data,ks2,DES_ENCRYPT);
279 DES_encrypt2((DES_LONG *)data,ks1,DES_DECRYPT);
280 l=data[0];
281 r=data[1];
282 FP(r,l);
283 data[0]=l;
284 data[1]=r;
285 }
286
287#ifndef DES_DEFAULT_OPTIONS
288
289#undef CBC_ENC_C__DONT_UPDATE_IV
290#include "ncbc_enc.c" /* DES_ncbc_encrypt */
291
292void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output,
293 long length, DES_key_schedule *ks1,
294 DES_key_schedule *ks2, DES_key_schedule *ks3,
295 DES_cblock *ivec, int enc)
296 {
297 register DES_LONG tin0,tin1;
298 register DES_LONG tout0,tout1,xor0,xor1;
299 register const unsigned char *in;
300 unsigned char *out;
301 register long l=length;
302 DES_LONG tin[2];
303 unsigned char *iv;
304
305 in=input;
306 out=output;
307 iv = &(*ivec)[0];
308
309 if (enc)
310 {
311 c2l(iv,tout0);
312 c2l(iv,tout1);
313 for (l-=8; l>=0; l-=8)
314 {
315 c2l(in,tin0);
316 c2l(in,tin1);
317 tin0^=tout0;
318 tin1^=tout1;
319
320 tin[0]=tin0;
321 tin[1]=tin1;
322 DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
323 tout0=tin[0];
324 tout1=tin[1];
325
326 l2c(tout0,out);
327 l2c(tout1,out);
328 }
329 if (l != -8)
330 {
331 c2ln(in,tin0,tin1,l+8);
332 tin0^=tout0;
333 tin1^=tout1;
334
335 tin[0]=tin0;
336 tin[1]=tin1;
337 DES_encrypt3((DES_LONG *)tin,ks1,ks2,ks3);
338 tout0=tin[0];
339 tout1=tin[1];
340
341 l2c(tout0,out);
342 l2c(tout1,out);
343 }
344 iv = &(*ivec)[0];
345 l2c(tout0,iv);
346 l2c(tout1,iv);
347 }
348 else
349 {
350 register DES_LONG t0,t1;
351
352 c2l(iv,xor0);
353 c2l(iv,xor1);
354 for (l-=8; l>=0; l-=8)
355 {
356 c2l(in,tin0);
357 c2l(in,tin1);
358
359 t0=tin0;
360 t1=tin1;
361
362 tin[0]=tin0;
363 tin[1]=tin1;
364 DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
365 tout0=tin[0];
366 tout1=tin[1];
367
368 tout0^=xor0;
369 tout1^=xor1;
370 l2c(tout0,out);
371 l2c(tout1,out);
372 xor0=t0;
373 xor1=t1;
374 }
375 if (l != -8)
376 {
377 c2l(in,tin0);
378 c2l(in,tin1);
379
380 t0=tin0;
381 t1=tin1;
382
383 tin[0]=tin0;
384 tin[1]=tin1;
385 DES_decrypt3((DES_LONG *)tin,ks1,ks2,ks3);
386 tout0=tin[0];
387 tout1=tin[1];
388
389 tout0^=xor0;
390 tout1^=xor1;
391 l2cn(tout0,tout1,out,l+8);
392 xor0=t0;
393 xor1=t1;
394 }
395
396 iv = &(*ivec)[0];
397 l2c(xor0,iv);
398 l2c(xor1,iv);
399 }
400 tin0=tin1=tout0=tout1=xor0=xor1=0;
401 tin[0]=tin[1]=0;
402 }
403
404#endif /* DES_DEFAULT_OPTIONS */
diff --git a/src/lib/libcrypto/des/des_locl.h b/src/lib/libcrypto/des/des_locl.h
deleted file mode 100644
index a3b512e9b0..0000000000
--- a/src/lib/libcrypto/des/des_locl.h
+++ /dev/null
@@ -1,432 +0,0 @@
1/* crypto/des/des_locl.h */
2/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#ifndef HEADER_DES_LOCL_H
60#define HEADER_DES_LOCL_H
61
62#include <openssl/e_os2.h>
63
64#if defined(OPENSSL_SYS_WIN32)
65#ifndef OPENSSL_SYS_MSDOS
66#define OPENSSL_SYS_MSDOS
67#endif
68#endif
69
70#include <stdio.h>
71#include <stdlib.h>
72
73#ifndef OPENSSL_SYS_MSDOS
74#if !defined(OPENSSL_SYS_VMS) || defined(__DECC)
75#ifdef OPENSSL_UNISTD
76# include OPENSSL_UNISTD
77#else
78# include <unistd.h>
79#endif
80#include <math.h>
81#endif
82#endif
83#include <openssl/des.h>
84
85#ifdef OPENSSL_SYS_MSDOS /* Visual C++ 2.1 (Windows NT/95) */
86#include <stdlib.h>
87#include <errno.h>
88#include <time.h>
89#include <io.h>
90#endif
91
92#if defined(__STDC__) || defined(OPENSSL_SYS_VMS) || defined(M_XENIX) || defined(OPENSSL_SYS_MSDOS)
93#include <string.h>
94#endif
95
96#ifdef OPENSSL_BUILD_SHLIBCRYPTO
97# undef OPENSSL_EXTERN
98# define OPENSSL_EXTERN OPENSSL_EXPORT
99#endif
100
101#define ITERATIONS 16
102#define HALF_ITERATIONS 8
103
104/* used in des_read and des_write */
105#define MAXWRITE (1024*16)
106#define BSIZE (MAXWRITE+4)
107
108#define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
109 l|=((DES_LONG)(*((c)++)))<< 8L, \
110 l|=((DES_LONG)(*((c)++)))<<16L, \
111 l|=((DES_LONG)(*((c)++)))<<24L)
112
113/* NOTE - c is not incremented as per c2l */
114#define c2ln(c,l1,l2,n) { \
115 c+=n; \
116 l1=l2=0; \
117 switch (n) { \
118 case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \
119 case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \
120 case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \
121 case 5: l2|=((DES_LONG)(*(--(c)))); \
122 case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \
123 case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \
124 case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \
125 case 1: l1|=((DES_LONG)(*(--(c)))); \
126 } \
127 }
128
129#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
130 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
131 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
132 *((c)++)=(unsigned char)(((l)>>24L)&0xff))
133
134/* replacements for htonl and ntohl since I have no idea what to do
135 * when faced with machines with 8 byte longs. */
136#define HDRSIZE 4
137
138#define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \
139 l|=((DES_LONG)(*((c)++)))<<16L, \
140 l|=((DES_LONG)(*((c)++)))<< 8L, \
141 l|=((DES_LONG)(*((c)++))))
142
143#define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
144 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
145 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
146 *((c)++)=(unsigned char)(((l) )&0xff))
147
148/* NOTE - c is not incremented as per l2c */
149#define l2cn(l1,l2,c,n) { \
150 c+=n; \
151 switch (n) { \
152 case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
153 case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
154 case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
155 case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
156 case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
157 case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
158 case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
159 case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
160 } \
161 }
162
163#if (defined(OPENSSL_SYS_WIN32) && defined(_MSC_VER)) || defined(__ICC)
164#define ROTATE(a,n) (_lrotr(a,n))
165#elif defined(__GNUC__) && __GNUC__>=2 && !defined(__STRICT_ANSI__) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)
166# if defined(__i386) || defined(__i386__) || defined(__x86_64) || defined(__x86_64__)
167# define ROTATE(a,n) ({ register unsigned int ret; \
168 asm ("rorl %1,%0" \
169 : "=r"(ret) \
170 : "I"(n),"0"(a) \
171 : "cc"); \
172 ret; \
173 })
174# endif
175#endif
176#ifndef ROTATE
177#define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n))))
178#endif
179
180/* Don't worry about the LOAD_DATA() stuff, that is used by
181 * fcrypt() to add it's little bit to the front */
182
183#ifdef DES_FCRYPT
184
185#define LOAD_DATA_tmp(R,S,u,t,E0,E1) \
186 { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); }
187
188#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
189 t=R^(R>>16L); \
190 u=t&E0; t&=E1; \
191 tmp=(u<<16); u^=R^s[S ]; u^=tmp; \
192 tmp=(t<<16); t^=R^s[S+1]; t^=tmp
193#else
194#define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g)
195#define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
196 u=R^s[S ]; \
197 t=R^s[S+1]
198#endif
199
200/* The changes to this macro may help or hinder, depending on the
201 * compiler and the architecture. gcc2 always seems to do well :-).
202 * Inspired by Dana How <how@isl.stanford.edu>
203 * DO NOT use the alternative version on machines with 8 byte longs.
204 * It does not seem to work on the Alpha, even when DES_LONG is 4
205 * bytes, probably an issue of accessing non-word aligned objects :-( */
206#ifdef DES_PTR
207
208/* It recently occurred to me that 0^0^0^0^0^0^0 == 0, so there
209 * is no reason to not xor all the sub items together. This potentially
210 * saves a register since things can be xored directly into L */
211
212#if defined(DES_RISC1) || defined(DES_RISC2)
213#ifdef DES_RISC1
214#define D_ENCRYPT(LL,R,S) { \
215 unsigned int u1,u2,u3; \
216 LOAD_DATA(R,S,u,t,E0,E1,u1); \
217 u2=(int)u>>8L; \
218 u1=(int)u&0xfc; \
219 u2&=0xfc; \
220 t=ROTATE(t,4); \
221 u>>=16L; \
222 LL^= *(const DES_LONG *)(des_SP +u1); \
223 LL^= *(const DES_LONG *)(des_SP+0x200+u2); \
224 u3=(int)(u>>8L); \
225 u1=(int)u&0xfc; \
226 u3&=0xfc; \
227 LL^= *(const DES_LONG *)(des_SP+0x400+u1); \
228 LL^= *(const DES_LONG *)(des_SP+0x600+u3); \
229 u2=(int)t>>8L; \
230 u1=(int)t&0xfc; \
231 u2&=0xfc; \
232 t>>=16L; \
233 LL^= *(const DES_LONG *)(des_SP+0x100+u1); \
234 LL^= *(const DES_LONG *)(des_SP+0x300+u2); \
235 u3=(int)t>>8L; \
236 u1=(int)t&0xfc; \
237 u3&=0xfc; \
238 LL^= *(const DES_LONG *)(des_SP+0x500+u1); \
239 LL^= *(const DES_LONG *)(des_SP+0x700+u3); }
240#endif
241#ifdef DES_RISC2
242#define D_ENCRYPT(LL,R,S) { \
243 unsigned int u1,u2,s1,s2; \
244 LOAD_DATA(R,S,u,t,E0,E1,u1); \
245 u2=(int)u>>8L; \
246 u1=(int)u&0xfc; \
247 u2&=0xfc; \
248 t=ROTATE(t,4); \
249 LL^= *(const DES_LONG *)(des_SP +u1); \
250 LL^= *(const DES_LONG *)(des_SP+0x200+u2); \
251 s1=(int)(u>>16L); \
252 s2=(int)(u>>24L); \
253 s1&=0xfc; \
254 s2&=0xfc; \
255 LL^= *(const DES_LONG *)(des_SP+0x400+s1); \
256 LL^= *(const DES_LONG *)(des_SP+0x600+s2); \
257 u2=(int)t>>8L; \
258 u1=(int)t&0xfc; \
259 u2&=0xfc; \
260 LL^= *(const DES_LONG *)(des_SP+0x100+u1); \
261 LL^= *(const DES_LONG *)(des_SP+0x300+u2); \
262 s1=(int)(t>>16L); \
263 s2=(int)(t>>24L); \
264 s1&=0xfc; \
265 s2&=0xfc; \
266 LL^= *(const DES_LONG *)(des_SP+0x500+s1); \
267 LL^= *(const DES_LONG *)(des_SP+0x700+s2); }
268#endif
269#else
270#define D_ENCRYPT(LL,R,S) { \
271 LOAD_DATA_tmp(R,S,u,t,E0,E1); \
272 t=ROTATE(t,4); \
273 LL^= \
274 *(const DES_LONG *)(des_SP +((u )&0xfc))^ \
275 *(const DES_LONG *)(des_SP+0x200+((u>> 8L)&0xfc))^ \
276 *(const DES_LONG *)(des_SP+0x400+((u>>16L)&0xfc))^ \
277 *(const DES_LONG *)(des_SP+0x600+((u>>24L)&0xfc))^ \
278 *(const DES_LONG *)(des_SP+0x100+((t )&0xfc))^ \
279 *(const DES_LONG *)(des_SP+0x300+((t>> 8L)&0xfc))^ \
280 *(const DES_LONG *)(des_SP+0x500+((t>>16L)&0xfc))^ \
281 *(const DES_LONG *)(des_SP+0x700+((t>>24L)&0xfc)); }
282#endif
283
284#else /* original version */
285
286#if defined(DES_RISC1) || defined(DES_RISC2)
287#ifdef DES_RISC1
288#define D_ENCRYPT(LL,R,S) {\
289 unsigned int u1,u2,u3; \
290 LOAD_DATA(R,S,u,t,E0,E1,u1); \
291 u>>=2L; \
292 t=ROTATE(t,6); \
293 u2=(int)u>>8L; \
294 u1=(int)u&0x3f; \
295 u2&=0x3f; \
296 u>>=16L; \
297 LL^=DES_SPtrans[0][u1]; \
298 LL^=DES_SPtrans[2][u2]; \
299 u3=(int)u>>8L; \
300 u1=(int)u&0x3f; \
301 u3&=0x3f; \
302 LL^=DES_SPtrans[4][u1]; \
303 LL^=DES_SPtrans[6][u3]; \
304 u2=(int)t>>8L; \
305 u1=(int)t&0x3f; \
306 u2&=0x3f; \
307 t>>=16L; \
308 LL^=DES_SPtrans[1][u1]; \
309 LL^=DES_SPtrans[3][u2]; \
310 u3=(int)t>>8L; \
311 u1=(int)t&0x3f; \
312 u3&=0x3f; \
313 LL^=DES_SPtrans[5][u1]; \
314 LL^=DES_SPtrans[7][u3]; }
315#endif
316#ifdef DES_RISC2
317#define D_ENCRYPT(LL,R,S) {\
318 unsigned int u1,u2,s1,s2; \
319 LOAD_DATA(R,S,u,t,E0,E1,u1); \
320 u>>=2L; \
321 t=ROTATE(t,6); \
322 u2=(int)u>>8L; \
323 u1=(int)u&0x3f; \
324 u2&=0x3f; \
325 LL^=DES_SPtrans[0][u1]; \
326 LL^=DES_SPtrans[2][u2]; \
327 s1=(int)u>>16L; \
328 s2=(int)u>>24L; \
329 s1&=0x3f; \
330 s2&=0x3f; \
331 LL^=DES_SPtrans[4][s1]; \
332 LL^=DES_SPtrans[6][s2]; \
333 u2=(int)t>>8L; \
334 u1=(int)t&0x3f; \
335 u2&=0x3f; \
336 LL^=DES_SPtrans[1][u1]; \
337 LL^=DES_SPtrans[3][u2]; \
338 s1=(int)t>>16; \
339 s2=(int)t>>24L; \
340 s1&=0x3f; \
341 s2&=0x3f; \
342 LL^=DES_SPtrans[5][s1]; \
343 LL^=DES_SPtrans[7][s2]; }
344#endif
345
346#else
347
348#define D_ENCRYPT(LL,R,S) {\
349 LOAD_DATA_tmp(R,S,u,t,E0,E1); \
350 t=ROTATE(t,4); \
351 LL^=\
352 DES_SPtrans[0][(u>> 2L)&0x3f]^ \
353 DES_SPtrans[2][(u>>10L)&0x3f]^ \
354 DES_SPtrans[4][(u>>18L)&0x3f]^ \
355 DES_SPtrans[6][(u>>26L)&0x3f]^ \
356 DES_SPtrans[1][(t>> 2L)&0x3f]^ \
357 DES_SPtrans[3][(t>>10L)&0x3f]^ \
358 DES_SPtrans[5][(t>>18L)&0x3f]^ \
359 DES_SPtrans[7][(t>>26L)&0x3f]; }
360#endif
361#endif
362
363 /* IP and FP
364 * The problem is more of a geometric problem that random bit fiddling.
365 0 1 2 3 4 5 6 7 62 54 46 38 30 22 14 6
366 8 9 10 11 12 13 14 15 60 52 44 36 28 20 12 4
367 16 17 18 19 20 21 22 23 58 50 42 34 26 18 10 2
368 24 25 26 27 28 29 30 31 to 56 48 40 32 24 16 8 0
369
370 32 33 34 35 36 37 38 39 63 55 47 39 31 23 15 7
371 40 41 42 43 44 45 46 47 61 53 45 37 29 21 13 5
372 48 49 50 51 52 53 54 55 59 51 43 35 27 19 11 3
373 56 57 58 59 60 61 62 63 57 49 41 33 25 17 9 1
374
375 The output has been subject to swaps of the form
376 0 1 -> 3 1 but the odd and even bits have been put into
377 2 3 2 0
378 different words. The main trick is to remember that
379 t=((l>>size)^r)&(mask);
380 r^=t;
381 l^=(t<<size);
382 can be used to swap and move bits between words.
383
384 So l = 0 1 2 3 r = 16 17 18 19
385 4 5 6 7 20 21 22 23
386 8 9 10 11 24 25 26 27
387 12 13 14 15 28 29 30 31
388 becomes (for size == 2 and mask == 0x3333)
389 t = 2^16 3^17 -- -- l = 0 1 16 17 r = 2 3 18 19
390 6^20 7^21 -- -- 4 5 20 21 6 7 22 23
391 10^24 11^25 -- -- 8 9 24 25 10 11 24 25
392 14^28 15^29 -- -- 12 13 28 29 14 15 28 29
393
394 Thanks for hints from Richard Outerbridge - he told me IP&FP
395 could be done in 15 xor, 10 shifts and 5 ands.
396 When I finally started to think of the problem in 2D
397 I first got ~42 operations without xors. When I remembered
398 how to use xors :-) I got it to its final state.
399 */
400#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
401 (b)^=(t),\
402 (a)^=((t)<<(n)))
403
404#define IP(l,r) \
405 { \
406 register DES_LONG tt; \
407 PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \
408 PERM_OP(l,r,tt,16,0x0000ffffL); \
409 PERM_OP(r,l,tt, 2,0x33333333L); \
410 PERM_OP(l,r,tt, 8,0x00ff00ffL); \
411 PERM_OP(r,l,tt, 1,0x55555555L); \
412 }
413
414#define FP(l,r) \
415 { \
416 register DES_LONG tt; \
417 PERM_OP(l,r,tt, 1,0x55555555L); \
418 PERM_OP(r,l,tt, 8,0x00ff00ffL); \
419 PERM_OP(l,r,tt, 2,0x33333333L); \
420 PERM_OP(r,l,tt,16,0x0000ffffL); \
421 PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \
422 }
423
424extern const DES_LONG DES_SPtrans[8][64];
425
426void fcrypt_body(DES_LONG *out,DES_key_schedule *ks,
427 DES_LONG Eswap0, DES_LONG Eswap1);
428
429#ifdef OPENSSL_SMALL_FOOTPRINT
430#undef DES_UNROLL
431#endif
432#endif
diff --git a/src/lib/libcrypto/des/des_old.c b/src/lib/libcrypto/des/des_old.c
deleted file mode 100644
index 7c33ed7a93..0000000000
--- a/src/lib/libcrypto/des/des_old.c
+++ /dev/null
@@ -1,273 +0,0 @@
1/* crypto/des/des_old.c -*- mode:C; c-file-style: "eay" -*- */
2
3/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4 *
5 * The function names in here are deprecated and are only present to
6 * provide an interface compatible with libdes. OpenSSL now provides
7 * functions where "des_" has been replaced with "DES_" in the names,
8 * to make it possible to make incompatible changes that are needed
9 * for C type security and other stuff.
10 *
11 * Please consider starting to use the DES_ functions rather than the
12 * des_ ones. The des_ functions will dissapear completely before
13 * OpenSSL 1.0!
14 *
15 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
16 */
17
18/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
19 * project 2001.
20 */
21/* ====================================================================
22 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
23 *
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
26 * are met:
27 *
28 * 1. Redistributions of source code must retain the above copyright
29 * notice, this list of conditions and the following disclaimer.
30 *
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in
33 * the documentation and/or other materials provided with the
34 * distribution.
35 *
36 * 3. All advertising materials mentioning features or use of this
37 * software must display the following acknowledgment:
38 * "This product includes software developed by the OpenSSL Project
39 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40 *
41 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42 * endorse or promote products derived from this software without
43 * prior written permission. For written permission, please contact
44 * openssl-core@openssl.org.
45 *
46 * 5. Products derived from this software may not be called "OpenSSL"
47 * nor may "OpenSSL" appear in their names without prior written
48 * permission of the OpenSSL Project.
49 *
50 * 6. Redistributions of any form whatsoever must retain the following
51 * acknowledgment:
52 * "This product includes software developed by the OpenSSL Project
53 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54 *
55 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66 * OF THE POSSIBILITY OF SUCH DAMAGE.
67 * ====================================================================
68 *
69 * This product includes cryptographic software written by Eric Young
70 * (eay@cryptsoft.com). This product includes software written by Tim
71 * Hudson (tjh@cryptsoft.com).
72 *
73 */
74
75#define OPENSSL_DES_LIBDES_COMPATIBILITY
76#include <openssl/des.h>
77#include <openssl/rand.h>
78
79const char *_ossl_old_des_options(void)
80 {
81 return DES_options();
82 }
83void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
84 des_key_schedule ks1,des_key_schedule ks2,
85 des_key_schedule ks3, int enc)
86 {
87 DES_ecb3_encrypt((const_DES_cblock *)input, output,
88 (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
89 (DES_key_schedule *)ks3, enc);
90 }
91DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
92 long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec)
93 {
94 return DES_cbc_cksum((unsigned char *)input, output, length,
95 (DES_key_schedule *)schedule, ivec);
96 }
97void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
98 des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc)
99 {
100 DES_cbc_encrypt((unsigned char *)input, (unsigned char *)output,
101 length, (DES_key_schedule *)schedule, ivec, enc);
102 }
103void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
104 des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc)
105 {
106 DES_ncbc_encrypt((unsigned char *)input, (unsigned char *)output,
107 length, (DES_key_schedule *)schedule, ivec, enc);
108 }
109void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
110 des_key_schedule schedule,_ossl_old_des_cblock *ivec,
111 _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc)
112 {
113 DES_xcbc_encrypt((unsigned char *)input, (unsigned char *)output,
114 length, (DES_key_schedule *)schedule, ivec, inw, outw, enc);
115 }
116void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
117 long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc)
118 {
119 DES_cfb_encrypt(in, out, numbits, length,
120 (DES_key_schedule *)schedule, ivec, enc);
121 }
122void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
123 des_key_schedule ks,int enc)
124 {
125 DES_ecb_encrypt(input, output, (DES_key_schedule *)ks, enc);
126 }
127void _ossl_old_des_encrypt(DES_LONG *data,des_key_schedule ks, int enc)
128 {
129 DES_encrypt1(data, (DES_key_schedule *)ks, enc);
130 }
131void _ossl_old_des_encrypt2(DES_LONG *data,des_key_schedule ks, int enc)
132 {
133 DES_encrypt2(data, (DES_key_schedule *)ks, enc);
134 }
135void _ossl_old_des_encrypt3(DES_LONG *data, des_key_schedule ks1,
136 des_key_schedule ks2, des_key_schedule ks3)
137 {
138 DES_encrypt3(data, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
139 (DES_key_schedule *)ks3);
140 }
141void _ossl_old_des_decrypt3(DES_LONG *data, des_key_schedule ks1,
142 des_key_schedule ks2, des_key_schedule ks3)
143 {
144 DES_decrypt3(data, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
145 (DES_key_schedule *)ks3);
146 }
147void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output,
148 long length, des_key_schedule ks1, des_key_schedule ks2,
149 des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc)
150 {
151 DES_ede3_cbc_encrypt((unsigned char *)input, (unsigned char *)output,
152 length, (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
153 (DES_key_schedule *)ks3, ivec, enc);
154 }
155void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
156 long length, des_key_schedule ks1, des_key_schedule ks2,
157 des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc)
158 {
159 DES_ede3_cfb64_encrypt(in, out, length,
160 (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
161 (DES_key_schedule *)ks3, ivec, num, enc);
162 }
163void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
164 long length, des_key_schedule ks1, des_key_schedule ks2,
165 des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num)
166 {
167 DES_ede3_ofb64_encrypt(in, out, length,
168 (DES_key_schedule *)ks1, (DES_key_schedule *)ks2,
169 (DES_key_schedule *)ks3, ivec, num);
170 }
171
172#if 0 /* broken code, preserved just in case anyone specifically looks for this */
173void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white),
174 _ossl_old_des_cblock (*out_white))
175 {
176 DES_xwhite_in2out(des_key, in_white, out_white);
177 }
178#endif
179
180int _ossl_old_des_enc_read(int fd,char *buf,int len,des_key_schedule sched,
181 _ossl_old_des_cblock *iv)
182 {
183 return DES_enc_read(fd, buf, len, (DES_key_schedule *)sched, iv);
184 }
185int _ossl_old_des_enc_write(int fd,char *buf,int len,des_key_schedule sched,
186 _ossl_old_des_cblock *iv)
187 {
188 return DES_enc_write(fd, buf, len, (DES_key_schedule *)sched, iv);
189 }
190char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret)
191 {
192 return DES_fcrypt(buf, salt, ret);
193 }
194char *_ossl_old_des_crypt(const char *buf,const char *salt)
195 {
196 return DES_crypt(buf, salt);
197 }
198char *_ossl_old_crypt(const char *buf,const char *salt)
199 {
200 return DES_crypt(buf, salt);
201 }
202void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out,
203 int numbits,long length,des_key_schedule schedule,_ossl_old_des_cblock *ivec)
204 {
205 DES_ofb_encrypt(in, out, numbits, length, (DES_key_schedule *)schedule,
206 ivec);
207 }
208void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
209 des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc)
210 {
211 DES_pcbc_encrypt((unsigned char *)input, (unsigned char *)output,
212 length, (DES_key_schedule *)schedule, ivec, enc);
213 }
214DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
215 long length,int out_count,_ossl_old_des_cblock *seed)
216 {
217 return DES_quad_cksum((unsigned char *)input, output, length,
218 out_count, seed);
219 }
220void _ossl_old_des_random_seed(_ossl_old_des_cblock key)
221 {
222 RAND_seed(key, sizeof(_ossl_old_des_cblock));
223 }
224void _ossl_old_des_random_key(_ossl_old_des_cblock ret)
225 {
226 DES_random_key((DES_cblock *)ret);
227 }
228int _ossl_old_des_read_password(_ossl_old_des_cblock *key, const char *prompt,
229 int verify)
230 {
231 return DES_read_password(key, prompt, verify);
232 }
233int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1, _ossl_old_des_cblock *key2,
234 const char *prompt, int verify)
235 {
236 return DES_read_2passwords(key1, key2, prompt, verify);
237 }
238void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key)
239 {
240 DES_set_odd_parity(key);
241 }
242int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key)
243 {
244 return DES_is_weak_key(key);
245 }
246int _ossl_old_des_set_key(_ossl_old_des_cblock *key,des_key_schedule schedule)
247 {
248 return DES_set_key(key, (DES_key_schedule *)schedule);
249 }
250int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,des_key_schedule schedule)
251 {
252 return DES_key_sched(key, (DES_key_schedule *)schedule);
253 }
254void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key)
255 {
256 DES_string_to_key(str, key);
257 }
258void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2)
259 {
260 DES_string_to_2keys(str, key1, key2);
261 }
262void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
263 des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc)
264 {
265 DES_cfb64_encrypt(in, out, length, (DES_key_schedule *)schedule,
266 ivec, num, enc);
267 }
268void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
269 des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num)
270 {
271 DES_ofb64_encrypt(in, out, length, (DES_key_schedule *)schedule,
272 ivec, num);
273 }
diff --git a/src/lib/libcrypto/des/des_old.h b/src/lib/libcrypto/des/des_old.h
deleted file mode 100644
index 8665ba4e7e..0000000000
--- a/src/lib/libcrypto/des/des_old.h
+++ /dev/null
@@ -1,446 +0,0 @@
1/* crypto/des/des_old.h -*- mode:C; c-file-style: "eay" -*- */
2
3/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4 *
5 * The function names in here are deprecated and are only present to
6 * provide an interface compatible with openssl 0.9.6 and older as
7 * well as libdes. OpenSSL now provides functions where "des_" has
8 * been replaced with "DES_" in the names, to make it possible to
9 * make incompatible changes that are needed for C type security and
10 * other stuff.
11 *
12 * This include files has two compatibility modes:
13 *
14 * - If OPENSSL_DES_LIBDES_COMPATIBILITY is defined, you get an API
15 * that is compatible with libdes and SSLeay.
16 * - If OPENSSL_DES_LIBDES_COMPATIBILITY isn't defined, you get an
17 * API that is compatible with OpenSSL 0.9.5x to 0.9.6x.
18 *
19 * Note that these modes break earlier snapshots of OpenSSL, where
20 * libdes compatibility was the only available mode or (later on) the
21 * prefered compatibility mode. However, after much consideration
22 * (and more or less violent discussions with external parties), it
23 * was concluded that OpenSSL should be compatible with earlier versions
24 * of itself before anything else. Also, in all honesty, libdes is
25 * an old beast that shouldn't really be used any more.
26 *
27 * Please consider starting to use the DES_ functions rather than the
28 * des_ ones. The des_ functions will disappear completely before
29 * OpenSSL 1.0!
30 *
31 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
32 */
33
34/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
35 * project 2001.
36 */
37/* ====================================================================
38 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
39 *
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
42 * are met:
43 *
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 *
47 * 2. Redistributions in binary form must reproduce the above copyright
48 * notice, this list of conditions and the following disclaimer in
49 * the documentation and/or other materials provided with the
50 * distribution.
51 *
52 * 3. All advertising materials mentioning features or use of this
53 * software must display the following acknowledgment:
54 * "This product includes software developed by the OpenSSL Project
55 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
56 *
57 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
58 * endorse or promote products derived from this software without
59 * prior written permission. For written permission, please contact
60 * openssl-core@openssl.org.
61 *
62 * 5. Products derived from this software may not be called "OpenSSL"
63 * nor may "OpenSSL" appear in their names without prior written
64 * permission of the OpenSSL Project.
65 *
66 * 6. Redistributions of any form whatsoever must retain the following
67 * acknowledgment:
68 * "This product includes software developed by the OpenSSL Project
69 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
70 *
71 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
72 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
73 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
74 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
75 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
76 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
77 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
78 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
79 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
80 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
81 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
82 * OF THE POSSIBILITY OF SUCH DAMAGE.
83 * ====================================================================
84 *
85 * This product includes cryptographic software written by Eric Young
86 * (eay@cryptsoft.com). This product includes software written by Tim
87 * Hudson (tjh@cryptsoft.com).
88 *
89 */
90
91#ifndef HEADER_DES_OLD_H
92#define HEADER_DES_OLD_H
93
94#include <openssl/e_os2.h> /* OPENSSL_EXTERN, OPENSSL_NO_DES, DES_LONG */
95
96#ifdef OPENSSL_NO_DES
97#error DES is disabled.
98#endif
99
100#ifndef HEADER_DES_H
101#error You must include des.h, not des_old.h directly.
102#endif
103
104#ifdef _KERBEROS_DES_H
105#error <openssl/des_old.h> replaces <kerberos/des.h>.
106#endif
107
108#include <openssl/symhacks.h>
109
110#ifdef OPENSSL_BUILD_SHLIBCRYPTO
111# undef OPENSSL_EXTERN
112# define OPENSSL_EXTERN OPENSSL_EXPORT
113#endif
114
115#ifdef __cplusplus
116extern "C" {
117#endif
118
119#ifdef _
120#undef _
121#endif
122
123typedef unsigned char _ossl_old_des_cblock[8];
124typedef struct _ossl_old_des_ks_struct
125 {
126 union {
127 _ossl_old_des_cblock _;
128 /* make sure things are correct size on machines with
129 * 8 byte longs */
130 DES_LONG pad[2];
131 } ks;
132 } _ossl_old_des_key_schedule[16];
133
134#ifndef OPENSSL_DES_LIBDES_COMPATIBILITY
135#define des_cblock DES_cblock
136#define const_des_cblock const_DES_cblock
137#define des_key_schedule DES_key_schedule
138#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\
139 DES_ecb3_encrypt((i),(o),&(k1),&(k2),&(k3),(e))
140#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\
141 DES_ede3_cbc_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(e))
142#define des_ede3_cbcm_encrypt(i,o,l,k1,k2,k3,iv1,iv2,e)\
143 DES_ede3_cbcm_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv1),(iv2),(e))
144#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\
145 DES_ede3_cfb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n),(e))
146#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\
147 DES_ede3_ofb64_encrypt((i),(o),(l),&(k1),&(k2),&(k3),(iv),(n))
148#define des_options()\
149 DES_options()
150#define des_cbc_cksum(i,o,l,k,iv)\
151 DES_cbc_cksum((i),(o),(l),&(k),(iv))
152#define des_cbc_encrypt(i,o,l,k,iv,e)\
153 DES_cbc_encrypt((i),(o),(l),&(k),(iv),(e))
154#define des_ncbc_encrypt(i,o,l,k,iv,e)\
155 DES_ncbc_encrypt((i),(o),(l),&(k),(iv),(e))
156#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\
157 DES_xcbc_encrypt((i),(o),(l),&(k),(iv),(inw),(outw),(e))
158#define des_cfb_encrypt(i,o,n,l,k,iv,e)\
159 DES_cfb_encrypt((i),(o),(n),(l),&(k),(iv),(e))
160#define des_ecb_encrypt(i,o,k,e)\
161 DES_ecb_encrypt((i),(o),&(k),(e))
162#define des_encrypt1(d,k,e)\
163 DES_encrypt1((d),&(k),(e))
164#define des_encrypt2(d,k,e)\
165 DES_encrypt2((d),&(k),(e))
166#define des_encrypt3(d,k1,k2,k3)\
167 DES_encrypt3((d),&(k1),&(k2),&(k3))
168#define des_decrypt3(d,k1,k2,k3)\
169 DES_decrypt3((d),&(k1),&(k2),&(k3))
170#define des_xwhite_in2out(k,i,o)\
171 DES_xwhite_in2out((k),(i),(o))
172#define des_enc_read(f,b,l,k,iv)\
173 DES_enc_read((f),(b),(l),&(k),(iv))
174#define des_enc_write(f,b,l,k,iv)\
175 DES_enc_write((f),(b),(l),&(k),(iv))
176#define des_fcrypt(b,s,r)\
177 DES_fcrypt((b),(s),(r))
178#if 0
179#define des_crypt(b,s)\
180 DES_crypt((b),(s))
181#if !defined(PERL5) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)
182#define crypt(b,s)\
183 DES_crypt((b),(s))
184#endif
185#endif
186#define des_ofb_encrypt(i,o,n,l,k,iv)\
187 DES_ofb_encrypt((i),(o),(n),(l),&(k),(iv))
188#define des_pcbc_encrypt(i,o,l,k,iv,e)\
189 DES_pcbc_encrypt((i),(o),(l),&(k),(iv),(e))
190#define des_quad_cksum(i,o,l,c,s)\
191 DES_quad_cksum((i),(o),(l),(c),(s))
192#define des_random_seed(k)\
193 _ossl_096_des_random_seed((k))
194#define des_random_key(r)\
195 DES_random_key((r))
196#define des_read_password(k,p,v) \
197 DES_read_password((k),(p),(v))
198#define des_read_2passwords(k1,k2,p,v) \
199 DES_read_2passwords((k1),(k2),(p),(v))
200#define des_set_odd_parity(k)\
201 DES_set_odd_parity((k))
202#define des_check_key_parity(k)\
203 DES_check_key_parity((k))
204#define des_is_weak_key(k)\
205 DES_is_weak_key((k))
206#define des_set_key(k,ks)\
207 DES_set_key((k),&(ks))
208#define des_key_sched(k,ks)\
209 DES_key_sched((k),&(ks))
210#define des_set_key_checked(k,ks)\
211 DES_set_key_checked((k),&(ks))
212#define des_set_key_unchecked(k,ks)\
213 DES_set_key_unchecked((k),&(ks))
214#define des_string_to_key(s,k)\
215 DES_string_to_key((s),(k))
216#define des_string_to_2keys(s,k1,k2)\
217 DES_string_to_2keys((s),(k1),(k2))
218#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\
219 DES_cfb64_encrypt((i),(o),(l),&(ks),(iv),(n),(e))
220#define des_ofb64_encrypt(i,o,l,ks,iv,n)\
221 DES_ofb64_encrypt((i),(o),(l),&(ks),(iv),(n))
222
223
224#define des_ecb2_encrypt(i,o,k1,k2,e) \
225 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
226
227#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
228 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
229
230#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
231 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
232
233#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
234 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
235
236#define des_check_key DES_check_key
237#define des_rw_mode DES_rw_mode
238#else /* libdes compatibility */
239/* Map all symbol names to _ossl_old_des_* form, so we avoid all
240 clashes with libdes */
241#define des_cblock _ossl_old_des_cblock
242#define des_key_schedule _ossl_old_des_key_schedule
243#define des_ecb3_encrypt(i,o,k1,k2,k3,e)\
244 _ossl_old_des_ecb3_encrypt((i),(o),(k1),(k2),(k3),(e))
245#define des_ede3_cbc_encrypt(i,o,l,k1,k2,k3,iv,e)\
246 _ossl_old_des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(e))
247#define des_ede3_cfb64_encrypt(i,o,l,k1,k2,k3,iv,n,e)\
248 _ossl_old_des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n),(e))
249#define des_ede3_ofb64_encrypt(i,o,l,k1,k2,k3,iv,n)\
250 _ossl_old_des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k3),(iv),(n))
251#define des_options()\
252 _ossl_old_des_options()
253#define des_cbc_cksum(i,o,l,k,iv)\
254 _ossl_old_des_cbc_cksum((i),(o),(l),(k),(iv))
255#define des_cbc_encrypt(i,o,l,k,iv,e)\
256 _ossl_old_des_cbc_encrypt((i),(o),(l),(k),(iv),(e))
257#define des_ncbc_encrypt(i,o,l,k,iv,e)\
258 _ossl_old_des_ncbc_encrypt((i),(o),(l),(k),(iv),(e))
259#define des_xcbc_encrypt(i,o,l,k,iv,inw,outw,e)\
260 _ossl_old_des_xcbc_encrypt((i),(o),(l),(k),(iv),(inw),(outw),(e))
261#define des_cfb_encrypt(i,o,n,l,k,iv,e)\
262 _ossl_old_des_cfb_encrypt((i),(o),(n),(l),(k),(iv),(e))
263#define des_ecb_encrypt(i,o,k,e)\
264 _ossl_old_des_ecb_encrypt((i),(o),(k),(e))
265#define des_encrypt(d,k,e)\
266 _ossl_old_des_encrypt((d),(k),(e))
267#define des_encrypt2(d,k,e)\
268 _ossl_old_des_encrypt2((d),(k),(e))
269#define des_encrypt3(d,k1,k2,k3)\
270 _ossl_old_des_encrypt3((d),(k1),(k2),(k3))
271#define des_decrypt3(d,k1,k2,k3)\
272 _ossl_old_des_decrypt3((d),(k1),(k2),(k3))
273#define des_xwhite_in2out(k,i,o)\
274 _ossl_old_des_xwhite_in2out((k),(i),(o))
275#define des_enc_read(f,b,l,k,iv)\
276 _ossl_old_des_enc_read((f),(b),(l),(k),(iv))
277#define des_enc_write(f,b,l,k,iv)\
278 _ossl_old_des_enc_write((f),(b),(l),(k),(iv))
279#define des_fcrypt(b,s,r)\
280 _ossl_old_des_fcrypt((b),(s),(r))
281#define des_crypt(b,s)\
282 _ossl_old_des_crypt((b),(s))
283#if 0
284#define crypt(b,s)\
285 _ossl_old_crypt((b),(s))
286#endif
287#define des_ofb_encrypt(i,o,n,l,k,iv)\
288 _ossl_old_des_ofb_encrypt((i),(o),(n),(l),(k),(iv))
289#define des_pcbc_encrypt(i,o,l,k,iv,e)\
290 _ossl_old_des_pcbc_encrypt((i),(o),(l),(k),(iv),(e))
291#define des_quad_cksum(i,o,l,c,s)\
292 _ossl_old_des_quad_cksum((i),(o),(l),(c),(s))
293#define des_random_seed(k)\
294 _ossl_old_des_random_seed((k))
295#define des_random_key(r)\
296 _ossl_old_des_random_key((r))
297#define des_read_password(k,p,v) \
298 _ossl_old_des_read_password((k),(p),(v))
299#define des_read_2passwords(k1,k2,p,v) \
300 _ossl_old_des_read_2passwords((k1),(k2),(p),(v))
301#define des_set_odd_parity(k)\
302 _ossl_old_des_set_odd_parity((k))
303#define des_is_weak_key(k)\
304 _ossl_old_des_is_weak_key((k))
305#define des_set_key(k,ks)\
306 _ossl_old_des_set_key((k),(ks))
307#define des_key_sched(k,ks)\
308 _ossl_old_des_key_sched((k),(ks))
309#define des_string_to_key(s,k)\
310 _ossl_old_des_string_to_key((s),(k))
311#define des_string_to_2keys(s,k1,k2)\
312 _ossl_old_des_string_to_2keys((s),(k1),(k2))
313#define des_cfb64_encrypt(i,o,l,ks,iv,n,e)\
314 _ossl_old_des_cfb64_encrypt((i),(o),(l),(ks),(iv),(n),(e))
315#define des_ofb64_encrypt(i,o,l,ks,iv,n)\
316 _ossl_old_des_ofb64_encrypt((i),(o),(l),(ks),(iv),(n))
317
318
319#define des_ecb2_encrypt(i,o,k1,k2,e) \
320 des_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e))
321
322#define des_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \
323 des_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e))
324
325#define des_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \
326 des_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e))
327
328#define des_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \
329 des_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n))
330
331#define des_check_key DES_check_key
332#define des_rw_mode DES_rw_mode
333#endif
334
335const char *_ossl_old_des_options(void);
336void _ossl_old_des_ecb3_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
337 _ossl_old_des_key_schedule ks1,_ossl_old_des_key_schedule ks2,
338 _ossl_old_des_key_schedule ks3, int enc);
339DES_LONG _ossl_old_des_cbc_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
340 long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec);
341void _ossl_old_des_cbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
342 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
343void _ossl_old_des_ncbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
344 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
345void _ossl_old_des_xcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
346 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,
347 _ossl_old_des_cblock *inw,_ossl_old_des_cblock *outw,int enc);
348void _ossl_old_des_cfb_encrypt(unsigned char *in,unsigned char *out,int numbits,
349 long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
350void _ossl_old_des_ecb_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
351 _ossl_old_des_key_schedule ks,int enc);
352void _ossl_old_des_encrypt(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc);
353void _ossl_old_des_encrypt2(DES_LONG *data,_ossl_old_des_key_schedule ks, int enc);
354void _ossl_old_des_encrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,
355 _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3);
356void _ossl_old_des_decrypt3(DES_LONG *data, _ossl_old_des_key_schedule ks1,
357 _ossl_old_des_key_schedule ks2, _ossl_old_des_key_schedule ks3);
358void _ossl_old_des_ede3_cbc_encrypt(_ossl_old_des_cblock *input, _ossl_old_des_cblock *output,
359 long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
360 _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int enc);
361void _ossl_old_des_ede3_cfb64_encrypt(unsigned char *in, unsigned char *out,
362 long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
363 _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num, int enc);
364void _ossl_old_des_ede3_ofb64_encrypt(unsigned char *in, unsigned char *out,
365 long length, _ossl_old_des_key_schedule ks1, _ossl_old_des_key_schedule ks2,
366 _ossl_old_des_key_schedule ks3, _ossl_old_des_cblock *ivec, int *num);
367#if 0
368void _ossl_old_des_xwhite_in2out(_ossl_old_des_cblock (*des_key), _ossl_old_des_cblock (*in_white),
369 _ossl_old_des_cblock (*out_white));
370#endif
371
372int _ossl_old_des_enc_read(int fd,char *buf,int len,_ossl_old_des_key_schedule sched,
373 _ossl_old_des_cblock *iv);
374int _ossl_old_des_enc_write(int fd,char *buf,int len,_ossl_old_des_key_schedule sched,
375 _ossl_old_des_cblock *iv);
376char *_ossl_old_des_fcrypt(const char *buf,const char *salt, char *ret);
377char *_ossl_old_des_crypt(const char *buf,const char *salt);
378#if !defined(PERL5) && !defined(NeXT)
379char *_ossl_old_crypt(const char *buf,const char *salt);
380#endif
381void _ossl_old_des_ofb_encrypt(unsigned char *in,unsigned char *out,
382 int numbits,long length,_ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec);
383void _ossl_old_des_pcbc_encrypt(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,long length,
384 _ossl_old_des_key_schedule schedule,_ossl_old_des_cblock *ivec,int enc);
385DES_LONG _ossl_old_des_quad_cksum(_ossl_old_des_cblock *input,_ossl_old_des_cblock *output,
386 long length,int out_count,_ossl_old_des_cblock *seed);
387void _ossl_old_des_random_seed(_ossl_old_des_cblock key);
388void _ossl_old_des_random_key(_ossl_old_des_cblock ret);
389int _ossl_old_des_read_password(_ossl_old_des_cblock *key,const char *prompt,int verify);
390int _ossl_old_des_read_2passwords(_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2,
391 const char *prompt,int verify);
392void _ossl_old_des_set_odd_parity(_ossl_old_des_cblock *key);
393int _ossl_old_des_is_weak_key(_ossl_old_des_cblock *key);
394int _ossl_old_des_set_key(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule);
395int _ossl_old_des_key_sched(_ossl_old_des_cblock *key,_ossl_old_des_key_schedule schedule);
396void _ossl_old_des_string_to_key(char *str,_ossl_old_des_cblock *key);
397void _ossl_old_des_string_to_2keys(char *str,_ossl_old_des_cblock *key1,_ossl_old_des_cblock *key2);
398void _ossl_old_des_cfb64_encrypt(unsigned char *in, unsigned char *out, long length,
399 _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num, int enc);
400void _ossl_old_des_ofb64_encrypt(unsigned char *in, unsigned char *out, long length,
401 _ossl_old_des_key_schedule schedule, _ossl_old_des_cblock *ivec, int *num);
402
403void _ossl_096_des_random_seed(des_cblock *key);
404
405/* The following definitions provide compatibility with the MIT Kerberos
406 * library. The _ossl_old_des_key_schedule structure is not binary compatible. */
407
408#define _KERBEROS_DES_H
409
410#define KRBDES_ENCRYPT DES_ENCRYPT
411#define KRBDES_DECRYPT DES_DECRYPT
412
413#ifdef KERBEROS
414# define ENCRYPT DES_ENCRYPT
415# define DECRYPT DES_DECRYPT
416#endif
417
418#ifndef NCOMPAT
419# define C_Block des_cblock
420# define Key_schedule des_key_schedule
421# define KEY_SZ DES_KEY_SZ
422# define string_to_key des_string_to_key
423# define read_pw_string des_read_pw_string
424# define random_key des_random_key
425# define pcbc_encrypt des_pcbc_encrypt
426# define set_key des_set_key
427# define key_sched des_key_sched
428# define ecb_encrypt des_ecb_encrypt
429# define cbc_encrypt des_cbc_encrypt
430# define ncbc_encrypt des_ncbc_encrypt
431# define xcbc_encrypt des_xcbc_encrypt
432# define cbc_cksum des_cbc_cksum
433# define quad_cksum des_quad_cksum
434# define check_parity des_check_key_parity
435#endif
436
437#define des_fixup_key_parity DES_fixup_key_parity
438
439#ifdef __cplusplus
440}
441#endif
442
443/* for DES_read_pw_string et al */
444#include <openssl/ui_compat.h>
445
446#endif
diff --git a/src/lib/libcrypto/des/des_old2.c b/src/lib/libcrypto/des/des_old2.c
deleted file mode 100644
index c8fa3ee135..0000000000
--- a/src/lib/libcrypto/des/des_old2.c
+++ /dev/null
@@ -1,82 +0,0 @@
1/* crypto/des/des_old.c -*- mode:C; c-file-style: "eay" -*- */
2
3/* WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
4 *
5 * The function names in here are deprecated and are only present to
6 * provide an interface compatible with OpenSSL 0.9.6c. OpenSSL now
7 * provides functions where "des_" has been replaced with "DES_" in
8 * the names, to make it possible to make incompatible changes that
9 * are needed for C type security and other stuff.
10 *
11 * Please consider starting to use the DES_ functions rather than the
12 * des_ ones. The des_ functions will dissapear completely before
13 * OpenSSL 1.0!
14 *
15 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
16 */
17
18/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
19 * project 2001.
20 */
21/* ====================================================================
22 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
23 *
24 * Redistribution and use in source and binary forms, with or without
25 * modification, are permitted provided that the following conditions
26 * are met:
27 *
28 * 1. Redistributions of source code must retain the above copyright
29 * notice, this list of conditions and the following disclaimer.
30 *
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in
33 * the documentation and/or other materials provided with the
34 * distribution.
35 *
36 * 3. All advertising materials mentioning features or use of this
37 * software must display the following acknowledgment:
38 * "This product includes software developed by the OpenSSL Project
39 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40 *
41 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42 * endorse or promote products derived from this software without
43 * prior written permission. For written permission, please contact
44 * openssl-core@openssl.org.
45 *
46 * 5. Products derived from this software may not be called "OpenSSL"
47 * nor may "OpenSSL" appear in their names without prior written
48 * permission of the OpenSSL Project.
49 *
50 * 6. Redistributions of any form whatsoever must retain the following
51 * acknowledgment:
52 * "This product includes software developed by the OpenSSL Project
53 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54 *
55 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
59 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66 * OF THE POSSIBILITY OF SUCH DAMAGE.
67 * ====================================================================
68 *
69 * This product includes cryptographic software written by Eric Young
70 * (eay@cryptsoft.com). This product includes software written by Tim
71 * Hudson (tjh@cryptsoft.com).
72 *
73 */
74
75#undef OPENSSL_DES_LIBDES_COMPATIBILITY
76#include <openssl/des.h>
77#include <openssl/rand.h>
78
79void _ossl_096_des_random_seed(DES_cblock *key)
80 {
81 RAND_seed(key, sizeof(DES_cblock));
82 }
diff --git a/src/lib/libcrypto/des/des_opts.c b/src/lib/libcrypto/des/des_opts.c
deleted file mode 100644
index 2df82962c5..0000000000
--- a/src/lib/libcrypto/des/des_opts.c
+++ /dev/null
@@ -1,608 +0,0 @@
1/* crypto/des/des_opts.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* define PART1, PART2, PART3 or PART4 to build only with a few of the options.
60 * This is for machines with 64k code segment size restrictions. */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES
64#endif
65
66#include <stdio.h>
67#ifndef OPENSSL_SYS_MSDOS
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD
70#else
71#include <io.h>
72extern void exit();
73#endif
74
75#ifndef OPENSSL_SYS_NETWARE
76#include <signal.h>
77#endif
78
79#ifndef _IRIX
80#include <time.h>
81#endif
82#ifdef TIMES
83#include <sys/types.h>
84#include <sys/times.h>
85#endif
86
87/* Depending on the VMS version, the tms structure is perhaps defined.
88 The __TMS macro will show if it was. If it wasn't defined, we should
89 undefine TIMES, since that tells the rest of the program how things
90 should be handled. -- Richard Levitte */
91#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
92#undef TIMES
93#endif
94
95#ifndef TIMES
96#include <sys/timeb.h>
97#endif
98
99
100#if defined(sun) || defined(__ultrix)
101#define _POSIX_SOURCE
102#include <limits.h>
103#include <sys/param.h>
104#endif
105
106#include <openssl/des.h>
107#include "spr.h"
108
109#define DES_DEFAULT_OPTIONS
110
111#if !defined(PART1) && !defined(PART2) && !defined(PART3) && !defined(PART4)
112#define PART1
113#define PART2
114#define PART3
115#define PART4
116#endif
117
118#ifdef PART1
119
120#undef DES_UNROLL
121#undef DES_RISC1
122#undef DES_RISC2
123#undef DES_PTR
124#undef D_ENCRYPT
125#define DES_encrypt1 des_encrypt_u4_cisc_idx
126#define DES_encrypt2 des_encrypt2_u4_cisc_idx
127#define DES_encrypt3 des_encrypt3_u4_cisc_idx
128#define DES_decrypt3 des_decrypt3_u4_cisc_idx
129#undef HEADER_DES_LOCL_H
130#include "des_enc.c"
131
132#define DES_UNROLL
133#undef DES_RISC1
134#undef DES_RISC2
135#undef DES_PTR
136#undef D_ENCRYPT
137#undef DES_encrypt1
138#undef DES_encrypt2
139#undef DES_encrypt3
140#undef DES_decrypt3
141#define DES_encrypt1 des_encrypt_u16_cisc_idx
142#define DES_encrypt2 des_encrypt2_u16_cisc_idx
143#define DES_encrypt3 des_encrypt3_u16_cisc_idx
144#define DES_decrypt3 des_decrypt3_u16_cisc_idx
145#undef HEADER_DES_LOCL_H
146#include "des_enc.c"
147
148#undef DES_UNROLL
149#define DES_RISC1
150#undef DES_RISC2
151#undef DES_PTR
152#undef D_ENCRYPT
153#undef DES_encrypt1
154#undef DES_encrypt2
155#undef DES_encrypt3
156#undef DES_decrypt3
157#define DES_encrypt1 des_encrypt_u4_risc1_idx
158#define DES_encrypt2 des_encrypt2_u4_risc1_idx
159#define DES_encrypt3 des_encrypt3_u4_risc1_idx
160#define DES_decrypt3 des_decrypt3_u4_risc1_idx
161#undef HEADER_DES_LOCL_H
162#include "des_enc.c"
163
164#endif
165
166#ifdef PART2
167
168#undef DES_UNROLL
169#undef DES_RISC1
170#define DES_RISC2
171#undef DES_PTR
172#undef D_ENCRYPT
173#undef DES_encrypt1
174#undef DES_encrypt2
175#undef DES_encrypt3
176#undef DES_decrypt3
177#define DES_encrypt1 des_encrypt_u4_risc2_idx
178#define DES_encrypt2 des_encrypt2_u4_risc2_idx
179#define DES_encrypt3 des_encrypt3_u4_risc2_idx
180#define DES_decrypt3 des_decrypt3_u4_risc2_idx
181#undef HEADER_DES_LOCL_H
182#include "des_enc.c"
183
184#define DES_UNROLL
185#define DES_RISC1
186#undef DES_RISC2
187#undef DES_PTR
188#undef D_ENCRYPT
189#undef DES_encrypt1
190#undef DES_encrypt2
191#undef DES_encrypt3
192#undef DES_decrypt3
193#define DES_encrypt1 des_encrypt_u16_risc1_idx
194#define DES_encrypt2 des_encrypt2_u16_risc1_idx
195#define DES_encrypt3 des_encrypt3_u16_risc1_idx
196#define DES_decrypt3 des_decrypt3_u16_risc1_idx
197#undef HEADER_DES_LOCL_H
198#include "des_enc.c"
199
200#define DES_UNROLL
201#undef DES_RISC1
202#define DES_RISC2
203#undef DES_PTR
204#undef D_ENCRYPT
205#undef DES_encrypt1
206#undef DES_encrypt2
207#undef DES_encrypt3
208#undef DES_decrypt3
209#define DES_encrypt1 des_encrypt_u16_risc2_idx
210#define DES_encrypt2 des_encrypt2_u16_risc2_idx
211#define DES_encrypt3 des_encrypt3_u16_risc2_idx
212#define DES_decrypt3 des_decrypt3_u16_risc2_idx
213#undef HEADER_DES_LOCL_H
214#include "des_enc.c"
215
216#endif
217
218#ifdef PART3
219
220#undef DES_UNROLL
221#undef DES_RISC1
222#undef DES_RISC2
223#define DES_PTR
224#undef D_ENCRYPT
225#undef DES_encrypt1
226#undef DES_encrypt2
227#undef DES_encrypt3
228#undef DES_decrypt3
229#define DES_encrypt1 des_encrypt_u4_cisc_ptr
230#define DES_encrypt2 des_encrypt2_u4_cisc_ptr
231#define DES_encrypt3 des_encrypt3_u4_cisc_ptr
232#define DES_decrypt3 des_decrypt3_u4_cisc_ptr
233#undef HEADER_DES_LOCL_H
234#include "des_enc.c"
235
236#define DES_UNROLL
237#undef DES_RISC1
238#undef DES_RISC2
239#define DES_PTR
240#undef D_ENCRYPT
241#undef DES_encrypt1
242#undef DES_encrypt2
243#undef DES_encrypt3
244#undef DES_decrypt3
245#define DES_encrypt1 des_encrypt_u16_cisc_ptr
246#define DES_encrypt2 des_encrypt2_u16_cisc_ptr
247#define DES_encrypt3 des_encrypt3_u16_cisc_ptr
248#define DES_decrypt3 des_decrypt3_u16_cisc_ptr
249#undef HEADER_DES_LOCL_H
250#include "des_enc.c"
251
252#undef DES_UNROLL
253#define DES_RISC1
254#undef DES_RISC2
255#define DES_PTR
256#undef D_ENCRYPT
257#undef DES_encrypt1
258#undef DES_encrypt2
259#undef DES_encrypt3
260#undef DES_decrypt3
261#define DES_encrypt1 des_encrypt_u4_risc1_ptr
262#define DES_encrypt2 des_encrypt2_u4_risc1_ptr
263#define DES_encrypt3 des_encrypt3_u4_risc1_ptr
264#define DES_decrypt3 des_decrypt3_u4_risc1_ptr
265#undef HEADER_DES_LOCL_H
266#include "des_enc.c"
267
268#endif
269
270#ifdef PART4
271
272#undef DES_UNROLL
273#undef DES_RISC1
274#define DES_RISC2
275#define DES_PTR
276#undef D_ENCRYPT
277#undef DES_encrypt1
278#undef DES_encrypt2
279#undef DES_encrypt3
280#undef DES_decrypt3
281#define DES_encrypt1 des_encrypt_u4_risc2_ptr
282#define DES_encrypt2 des_encrypt2_u4_risc2_ptr
283#define DES_encrypt3 des_encrypt3_u4_risc2_ptr
284#define DES_decrypt3 des_decrypt3_u4_risc2_ptr
285#undef HEADER_DES_LOCL_H
286#include "des_enc.c"
287
288#define DES_UNROLL
289#define DES_RISC1
290#undef DES_RISC2
291#define DES_PTR
292#undef D_ENCRYPT
293#undef DES_encrypt1
294#undef DES_encrypt2
295#undef DES_encrypt3
296#undef DES_decrypt3
297#define DES_encrypt1 des_encrypt_u16_risc1_ptr
298#define DES_encrypt2 des_encrypt2_u16_risc1_ptr
299#define DES_encrypt3 des_encrypt3_u16_risc1_ptr
300#define DES_decrypt3 des_decrypt3_u16_risc1_ptr
301#undef HEADER_DES_LOCL_H
302#include "des_enc.c"
303
304#define DES_UNROLL
305#undef DES_RISC1
306#define DES_RISC2
307#define DES_PTR
308#undef D_ENCRYPT
309#undef DES_encrypt1
310#undef DES_encrypt2
311#undef DES_encrypt3
312#undef DES_decrypt3
313#define DES_encrypt1 des_encrypt_u16_risc2_ptr
314#define DES_encrypt2 des_encrypt2_u16_risc2_ptr
315#define DES_encrypt3 des_encrypt3_u16_risc2_ptr
316#define DES_decrypt3 des_decrypt3_u16_risc2_ptr
317#undef HEADER_DES_LOCL_H
318#include "des_enc.c"
319
320#endif
321
322/* The following if from times(3) man page. It may need to be changed */
323#ifndef HZ
324# ifndef CLK_TCK
325# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
326# define HZ 100.0
327# else /* _BSD_CLK_TCK_ */
328# define HZ ((double)_BSD_CLK_TCK_)
329# endif
330# else /* CLK_TCK */
331# define HZ ((double)CLK_TCK)
332# endif
333#endif
334
335#define BUFSIZE ((long)1024)
336long run=0;
337
338double Time_F(int s);
339#ifdef SIGALRM
340#if defined(__STDC__) || defined(sgi)
341#define SIGRETTYPE void
342#else
343#define SIGRETTYPE int
344#endif
345
346SIGRETTYPE sig_done(int sig);
347SIGRETTYPE sig_done(int sig)
348 {
349 signal(SIGALRM,sig_done);
350 run=0;
351#ifdef LINT
352 sig=sig;
353#endif
354 }
355#endif
356
357#define START 0
358#define STOP 1
359
360double Time_F(int s)
361 {
362 double ret;
363#ifdef TIMES
364 static struct tms tstart,tend;
365
366 if (s == START)
367 {
368 times(&tstart);
369 return(0);
370 }
371 else
372 {
373 times(&tend);
374 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
375 return((ret == 0.0)?1e-6:ret);
376 }
377#else /* !times() */
378 static struct timeb tstart,tend;
379 long i;
380
381 if (s == START)
382 {
383 ftime(&tstart);
384 return(0);
385 }
386 else
387 {
388 ftime(&tend);
389 i=(long)tend.millitm-(long)tstart.millitm;
390 ret=((double)(tend.time-tstart.time))+((double)i)/1000.0;
391 return((ret == 0.0)?1e-6:ret);
392 }
393#endif
394 }
395
396#ifdef SIGALRM
397#define print_name(name) fprintf(stderr,"Doing %s's for 10 seconds\n",name); alarm(10);
398#else
399#define print_name(name) fprintf(stderr,"Doing %s %ld times\n",name,cb);
400#endif
401
402#define time_it(func,name,index) \
403 print_name(name); \
404 Time_F(START); \
405 for (count=0,run=1; COND(cb); count++) \
406 { \
407 unsigned long d[2]; \
408 func(d,&sch,DES_ENCRYPT); \
409 } \
410 tm[index]=Time_F(STOP); \
411 fprintf(stderr,"%ld %s's in %.2f second\n",count,name,tm[index]); \
412 tm[index]=((double)COUNT(cb))/tm[index];
413
414#define print_it(name,index) \
415 fprintf(stderr,"%s bytes per sec = %12.2f (%5.1fuS)\n",name, \
416 tm[index]*8,1.0e6/tm[index]);
417
418int main(int argc, char **argv)
419 {
420 long count;
421 static unsigned char buf[BUFSIZE];
422 static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
423 static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
424 static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
425 DES_key_schedule sch,sch2,sch3;
426 double d,tm[16],max=0;
427 int rank[16];
428 char *str[16];
429 int max_idx=0,i,num=0,j;
430#ifndef SIGALARM
431 long ca,cb,cc,cd,ce;
432#endif
433
434 for (i=0; i<12; i++)
435 {
436 tm[i]=0.0;
437 rank[i]=0;
438 }
439
440#ifndef TIMES
441 fprintf(stderr,"To get the most accurate results, try to run this\n");
442 fprintf(stderr,"program when this computer is idle.\n");
443#endif
444
445 DES_set_key_unchecked(&key,&sch);
446 DES_set_key_unchecked(&key2,&sch2);
447 DES_set_key_unchecked(&key3,&sch3);
448
449#ifndef SIGALRM
450 fprintf(stderr,"First we calculate the approximate speed ...\n");
451 DES_set_key_unchecked(&key,sch);
452 count=10;
453 do {
454 long i;
455 unsigned long data[2];
456
457 count*=2;
458 Time_F(START);
459 for (i=count; i; i--)
460 DES_encrypt1(data,&(sch[0]),DES_ENCRYPT);
461 d=Time_F(STOP);
462 } while (d < 3.0);
463 ca=count;
464 cb=count*3;
465 cc=count*3*8/BUFSIZE+1;
466 cd=count*8/BUFSIZE+1;
467
468 ce=count/20+1;
469#define COND(d) (count != (d))
470#define COUNT(d) (d)
471#else
472#define COND(c) (run)
473#define COUNT(d) (count)
474 signal(SIGALRM,sig_done);
475 alarm(10);
476#endif
477
478#ifdef PART1
479 time_it(des_encrypt_u4_cisc_idx, "des_encrypt_u4_cisc_idx ", 0);
480 time_it(des_encrypt_u16_cisc_idx, "des_encrypt_u16_cisc_idx ", 1);
481 time_it(des_encrypt_u4_risc1_idx, "des_encrypt_u4_risc1_idx ", 2);
482 num+=3;
483#endif
484#ifdef PART2
485 time_it(des_encrypt_u16_risc1_idx,"des_encrypt_u16_risc1_idx", 3);
486 time_it(des_encrypt_u4_risc2_idx, "des_encrypt_u4_risc2_idx ", 4);
487 time_it(des_encrypt_u16_risc2_idx,"des_encrypt_u16_risc2_idx", 5);
488 num+=3;
489#endif
490#ifdef PART3
491 time_it(des_encrypt_u4_cisc_ptr, "des_encrypt_u4_cisc_ptr ", 6);
492 time_it(des_encrypt_u16_cisc_ptr, "des_encrypt_u16_cisc_ptr ", 7);
493 time_it(des_encrypt_u4_risc1_ptr, "des_encrypt_u4_risc1_ptr ", 8);
494 num+=3;
495#endif
496#ifdef PART4
497 time_it(des_encrypt_u16_risc1_ptr,"des_encrypt_u16_risc1_ptr", 9);
498 time_it(des_encrypt_u4_risc2_ptr, "des_encrypt_u4_risc2_ptr ",10);
499 time_it(des_encrypt_u16_risc2_ptr,"des_encrypt_u16_risc2_ptr",11);
500 num+=3;
501#endif
502
503#ifdef PART1
504 str[0]=" 4 c i";
505 print_it("des_encrypt_u4_cisc_idx ",0);
506 max=tm[0];
507 max_idx=0;
508 str[1]="16 c i";
509 print_it("des_encrypt_u16_cisc_idx ",1);
510 if (max < tm[1]) { max=tm[1]; max_idx=1; }
511 str[2]=" 4 r1 i";
512 print_it("des_encrypt_u4_risc1_idx ",2);
513 if (max < tm[2]) { max=tm[2]; max_idx=2; }
514#endif
515#ifdef PART2
516 str[3]="16 r1 i";
517 print_it("des_encrypt_u16_risc1_idx",3);
518 if (max < tm[3]) { max=tm[3]; max_idx=3; }
519 str[4]=" 4 r2 i";
520 print_it("des_encrypt_u4_risc2_idx ",4);
521 if (max < tm[4]) { max=tm[4]; max_idx=4; }
522 str[5]="16 r2 i";
523 print_it("des_encrypt_u16_risc2_idx",5);
524 if (max < tm[5]) { max=tm[5]; max_idx=5; }
525#endif
526#ifdef PART3
527 str[6]=" 4 c p";
528 print_it("des_encrypt_u4_cisc_ptr ",6);
529 if (max < tm[6]) { max=tm[6]; max_idx=6; }
530 str[7]="16 c p";
531 print_it("des_encrypt_u16_cisc_ptr ",7);
532 if (max < tm[7]) { max=tm[7]; max_idx=7; }
533 str[8]=" 4 r1 p";
534 print_it("des_encrypt_u4_risc1_ptr ",8);
535 if (max < tm[8]) { max=tm[8]; max_idx=8; }
536#endif
537#ifdef PART4
538 str[9]="16 r1 p";
539 print_it("des_encrypt_u16_risc1_ptr",9);
540 if (max < tm[9]) { max=tm[9]; max_idx=9; }
541 str[10]=" 4 r2 p";
542 print_it("des_encrypt_u4_risc2_ptr ",10);
543 if (max < tm[10]) { max=tm[10]; max_idx=10; }
544 str[11]="16 r2 p";
545 print_it("des_encrypt_u16_risc2_ptr",11);
546 if (max < tm[11]) { max=tm[11]; max_idx=11; }
547#endif
548 printf("options des ecb/s\n");
549 printf("%s %12.2f 100.0%%\n",str[max_idx],tm[max_idx]);
550 d=tm[max_idx];
551 tm[max_idx]= -2.0;
552 max= -1.0;
553 for (;;)
554 {
555 for (i=0; i<12; i++)
556 {
557 if (max < tm[i]) { max=tm[i]; j=i; }
558 }
559 if (max < 0.0) break;
560 printf("%s %12.2f %4.1f%%\n",str[j],tm[j],tm[j]/d*100.0);
561 tm[j]= -2.0;
562 max= -1.0;
563 }
564
565 switch (max_idx)
566 {
567 case 0:
568 printf("-DDES_DEFAULT_OPTIONS\n");
569 break;
570 case 1:
571 printf("-DDES_UNROLL\n");
572 break;
573 case 2:
574 printf("-DDES_RISC1\n");
575 break;
576 case 3:
577 printf("-DDES_UNROLL -DDES_RISC1\n");
578 break;
579 case 4:
580 printf("-DDES_RISC2\n");
581 break;
582 case 5:
583 printf("-DDES_UNROLL -DDES_RISC2\n");
584 break;
585 case 6:
586 printf("-DDES_PTR\n");
587 break;
588 case 7:
589 printf("-DDES_UNROLL -DDES_PTR\n");
590 break;
591 case 8:
592 printf("-DDES_RISC1 -DDES_PTR\n");
593 break;
594 case 9:
595 printf("-DDES_UNROLL -DDES_RISC1 -DDES_PTR\n");
596 break;
597 case 10:
598 printf("-DDES_RISC2 -DDES_PTR\n");
599 break;
600 case 11:
601 printf("-DDES_UNROLL -DDES_RISC2 -DDES_PTR\n");
602 break;
603 }
604 exit(0);
605#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
606 return(0);
607#endif
608 }
diff --git a/src/lib/libcrypto/des/des_ver.h b/src/lib/libcrypto/des/des_ver.h
deleted file mode 100644
index d1ada258a6..0000000000
--- a/src/lib/libcrypto/des/des_ver.h
+++ /dev/null
@@ -1,71 +0,0 @@
1/* crypto/des/des_ver.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/e_os2.h>
60
61#ifdef OPENSSL_BUILD_SHLIBCRYPTO
62# undef OPENSSL_EXTERN
63# define OPENSSL_EXTERN OPENSSL_EXPORT
64#endif
65
66/* The following macros make sure the names are different from libdes names */
67#define DES_version OSSL_DES_version
68#define libdes_version OSSL_libdes_version
69
70OPENSSL_EXTERN const char OSSL_DES_version[]; /* SSLeay version string */
71OPENSSL_EXTERN const char OSSL_libdes_version[]; /* old libdes version string */
diff --git a/src/lib/libcrypto/des/dess.cpp b/src/lib/libcrypto/des/dess.cpp
deleted file mode 100644
index 5549bab90a..0000000000
--- a/src/lib/libcrypto/des/dess.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
1//
2// gettsc.inl
3//
4// gives access to the Pentium's (secret) cycle counter
5//
6// This software was written by Leonard Janke (janke@unixg.ubc.ca)
7// in 1996-7 and is entered, by him, into the public domain.
8
9#if defined(__WATCOMC__)
10void GetTSC(unsigned long&);
11#pragma aux GetTSC = 0x0f 0x31 "mov [edi], eax" parm [edi] modify [edx eax];
12#elif defined(__GNUC__)
13inline
14void GetTSC(unsigned long& tsc)
15{
16 asm volatile(".byte 15, 49\n\t"
17 : "=eax" (tsc)
18 :
19 : "%edx", "%eax");
20}
21#elif defined(_MSC_VER)
22inline
23void GetTSC(unsigned long& tsc)
24{
25 unsigned long a;
26 __asm _emit 0fh
27 __asm _emit 31h
28 __asm mov a, eax;
29 tsc=a;
30}
31#endif
32
33#include <stdio.h>
34#include <stdlib.h>
35#include <openssl/des.h>
36
37void main(int argc,char *argv[])
38 {
39 des_key_schedule key;
40 unsigned long s1,s2,e1,e2;
41 unsigned long data[2];
42 int i,j;
43
44 for (j=0; j<6; j++)
45 {
46 for (i=0; i<1000; i++) /**/
47 {
48 des_encrypt1(&data[0],key,1);
49 GetTSC(s1);
50 des_encrypt1(&data[0],key,1);
51 des_encrypt1(&data[0],key,1);
52 des_encrypt1(&data[0],key,1);
53 GetTSC(e1);
54 GetTSC(s2);
55 des_encrypt1(&data[0],key,1);
56 des_encrypt1(&data[0],key,1);
57 des_encrypt1(&data[0],key,1);
58 des_encrypt1(&data[0],key,1);
59 GetTSC(e2);
60 des_encrypt1(&data[0],key,1);
61 }
62
63 printf("des %d %d (%d)\n",
64 e1-s1,e2-s2,((e2-s2)-(e1-s1)));
65 }
66 }
67
diff --git a/src/lib/libcrypto/des/destest.c b/src/lib/libcrypto/des/destest.c
deleted file mode 100644
index 64b92a34fe..0000000000
--- a/src/lib/libcrypto/des/destest.c
+++ /dev/null
@@ -1,952 +0,0 @@
1/* crypto/des/destest.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <stdlib.h>
61
62#include <openssl/e_os2.h>
63#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN16) || defined(OPENSSL_SYS_WINDOWS)
64#ifndef OPENSSL_SYS_MSDOS
65#define OPENSSL_SYS_MSDOS
66#endif
67#endif
68
69#ifndef OPENSSL_SYS_MSDOS
70#if !defined(OPENSSL_SYS_VMS) || defined(OPENSSL_SYS_VMS_DECC)
71#include OPENSSL_UNISTD
72#endif
73#else
74#include <io.h>
75#endif
76#include <string.h>
77
78#ifdef OPENSSL_NO_DES
79int main(int argc, char *argv[])
80{
81 printf("No DES support\n");
82 return(0);
83}
84#else
85#include <openssl/des.h>
86
87#define crypt(c,s) (DES_crypt((c),(s)))
88
89/* tisk tisk - the test keys don't all have odd parity :-( */
90/* test data */
91#define NUM_TESTS 34
92static unsigned char key_data[NUM_TESTS][8]={
93 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
94 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
95 {0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
96 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
97 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
98 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
99 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
100 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10},
101 {0x7C,0xA1,0x10,0x45,0x4A,0x1A,0x6E,0x57},
102 {0x01,0x31,0xD9,0x61,0x9D,0xC1,0x37,0x6E},
103 {0x07,0xA1,0x13,0x3E,0x4A,0x0B,0x26,0x86},
104 {0x38,0x49,0x67,0x4C,0x26,0x02,0x31,0x9E},
105 {0x04,0xB9,0x15,0xBA,0x43,0xFE,0xB5,0xB6},
106 {0x01,0x13,0xB9,0x70,0xFD,0x34,0xF2,0xCE},
107 {0x01,0x70,0xF1,0x75,0x46,0x8F,0xB5,0xE6},
108 {0x43,0x29,0x7F,0xAD,0x38,0xE3,0x73,0xFE},
109 {0x07,0xA7,0x13,0x70,0x45,0xDA,0x2A,0x16},
110 {0x04,0x68,0x91,0x04,0xC2,0xFD,0x3B,0x2F},
111 {0x37,0xD0,0x6B,0xB5,0x16,0xCB,0x75,0x46},
112 {0x1F,0x08,0x26,0x0D,0x1A,0xC2,0x46,0x5E},
113 {0x58,0x40,0x23,0x64,0x1A,0xBA,0x61,0x76},
114 {0x02,0x58,0x16,0x16,0x46,0x29,0xB0,0x07},
115 {0x49,0x79,0x3E,0xBC,0x79,0xB3,0x25,0x8F},
116 {0x4F,0xB0,0x5E,0x15,0x15,0xAB,0x73,0xA7},
117 {0x49,0xE9,0x5D,0x6D,0x4C,0xA2,0x29,0xBF},
118 {0x01,0x83,0x10,0xDC,0x40,0x9B,0x26,0xD6},
119 {0x1C,0x58,0x7F,0x1C,0x13,0x92,0x4F,0xEF},
120 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
121 {0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E},
122 {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE},
123 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
124 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
125 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
126 {0xFE,0xDC,0xBA,0x98,0x76,0x54,0x32,0x10}};
127
128static unsigned char plain_data[NUM_TESTS][8]={
129 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
130 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
131 {0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x01},
132 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
133 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
134 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
135 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
136 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
137 {0x01,0xA1,0xD6,0xD0,0x39,0x77,0x67,0x42},
138 {0x5C,0xD5,0x4C,0xA8,0x3D,0xEF,0x57,0xDA},
139 {0x02,0x48,0xD4,0x38,0x06,0xF6,0x71,0x72},
140 {0x51,0x45,0x4B,0x58,0x2D,0xDF,0x44,0x0A},
141 {0x42,0xFD,0x44,0x30,0x59,0x57,0x7F,0xA2},
142 {0x05,0x9B,0x5E,0x08,0x51,0xCF,0x14,0x3A},
143 {0x07,0x56,0xD8,0xE0,0x77,0x47,0x61,0xD2},
144 {0x76,0x25,0x14,0xB8,0x29,0xBF,0x48,0x6A},
145 {0x3B,0xDD,0x11,0x90,0x49,0x37,0x28,0x02},
146 {0x26,0x95,0x5F,0x68,0x35,0xAF,0x60,0x9A},
147 {0x16,0x4D,0x5E,0x40,0x4F,0x27,0x52,0x32},
148 {0x6B,0x05,0x6E,0x18,0x75,0x9F,0x5C,0xCA},
149 {0x00,0x4B,0xD6,0xEF,0x09,0x17,0x60,0x62},
150 {0x48,0x0D,0x39,0x00,0x6E,0xE7,0x62,0xF2},
151 {0x43,0x75,0x40,0xC8,0x69,0x8F,0x3C,0xFA},
152 {0x07,0x2D,0x43,0xA0,0x77,0x07,0x52,0x92},
153 {0x02,0xFE,0x55,0x77,0x81,0x17,0xF1,0x2A},
154 {0x1D,0x9D,0x5C,0x50,0x18,0xF7,0x28,0xC2},
155 {0x30,0x55,0x32,0x28,0x6D,0x6F,0x29,0x5A},
156 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
157 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
158 {0x01,0x23,0x45,0x67,0x89,0xAB,0xCD,0xEF},
159 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
160 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
161 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
162 {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}};
163
164static unsigned char cipher_data[NUM_TESTS][8]={
165 {0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7},
166 {0x73,0x59,0xB2,0x16,0x3E,0x4E,0xDC,0x58},
167 {0x95,0x8E,0x6E,0x62,0x7A,0x05,0x55,0x7B},
168 {0xF4,0x03,0x79,0xAB,0x9E,0x0E,0xC5,0x33},
169 {0x17,0x66,0x8D,0xFC,0x72,0x92,0x53,0x2D},
170 {0x8A,0x5A,0xE1,0xF8,0x1A,0xB8,0xF2,0xDD},
171 {0x8C,0xA6,0x4D,0xE9,0xC1,0xB1,0x23,0xA7},
172 {0xED,0x39,0xD9,0x50,0xFA,0x74,0xBC,0xC4},
173 {0x69,0x0F,0x5B,0x0D,0x9A,0x26,0x93,0x9B},
174 {0x7A,0x38,0x9D,0x10,0x35,0x4B,0xD2,0x71},
175 {0x86,0x8E,0xBB,0x51,0xCA,0xB4,0x59,0x9A},
176 {0x71,0x78,0x87,0x6E,0x01,0xF1,0x9B,0x2A},
177 {0xAF,0x37,0xFB,0x42,0x1F,0x8C,0x40,0x95},
178 {0x86,0xA5,0x60,0xF1,0x0E,0xC6,0xD8,0x5B},
179 {0x0C,0xD3,0xDA,0x02,0x00,0x21,0xDC,0x09},
180 {0xEA,0x67,0x6B,0x2C,0xB7,0xDB,0x2B,0x7A},
181 {0xDF,0xD6,0x4A,0x81,0x5C,0xAF,0x1A,0x0F},
182 {0x5C,0x51,0x3C,0x9C,0x48,0x86,0xC0,0x88},
183 {0x0A,0x2A,0xEE,0xAE,0x3F,0xF4,0xAB,0x77},
184 {0xEF,0x1B,0xF0,0x3E,0x5D,0xFA,0x57,0x5A},
185 {0x88,0xBF,0x0D,0xB6,0xD7,0x0D,0xEE,0x56},
186 {0xA1,0xF9,0x91,0x55,0x41,0x02,0x0B,0x56},
187 {0x6F,0xBF,0x1C,0xAF,0xCF,0xFD,0x05,0x56},
188 {0x2F,0x22,0xE4,0x9B,0xAB,0x7C,0xA1,0xAC},
189 {0x5A,0x6B,0x61,0x2C,0xC2,0x6C,0xCE,0x4A},
190 {0x5F,0x4C,0x03,0x8E,0xD1,0x2B,0x2E,0x41},
191 {0x63,0xFA,0xC0,0xD0,0x34,0xD9,0xF7,0x93},
192 {0x61,0x7B,0x3A,0x0C,0xE8,0xF0,0x71,0x00},
193 {0xDB,0x95,0x86,0x05,0xF8,0xC8,0xC6,0x06},
194 {0xED,0xBF,0xD1,0xC6,0x6C,0x29,0xCC,0xC7},
195 {0x35,0x55,0x50,0xB2,0x15,0x0E,0x24,0x51},
196 {0xCA,0xAA,0xAF,0x4D,0xEA,0xF1,0xDB,0xAE},
197 {0xD5,0xD4,0x4F,0xF7,0x20,0x68,0x3D,0x0D},
198 {0x2A,0x2B,0xB0,0x08,0xDF,0x97,0xC2,0xF2}};
199
200static unsigned char cipher_ecb2[NUM_TESTS-1][8]={
201 {0x92,0x95,0xB5,0x9B,0xB3,0x84,0x73,0x6E},
202 {0x19,0x9E,0x9D,0x6D,0xF3,0x9A,0xA8,0x16},
203 {0x2A,0x4B,0x4D,0x24,0x52,0x43,0x84,0x27},
204 {0x35,0x84,0x3C,0x01,0x9D,0x18,0xC5,0xB6},
205 {0x4A,0x5B,0x2F,0x42,0xAA,0x77,0x19,0x25},
206 {0xA0,0x6B,0xA9,0xB8,0xCA,0x5B,0x17,0x8A},
207 {0xAB,0x9D,0xB7,0xFB,0xED,0x95,0xF2,0x74},
208 {0x3D,0x25,0x6C,0x23,0xA7,0x25,0x2F,0xD6},
209 {0xB7,0x6F,0xAB,0x4F,0xBD,0xBD,0xB7,0x67},
210 {0x8F,0x68,0x27,0xD6,0x9C,0xF4,0x1A,0x10},
211 {0x82,0x57,0xA1,0xD6,0x50,0x5E,0x81,0x85},
212 {0xA2,0x0F,0x0A,0xCD,0x80,0x89,0x7D,0xFA},
213 {0xCD,0x2A,0x53,0x3A,0xDB,0x0D,0x7E,0xF3},
214 {0xD2,0xC2,0xBE,0x27,0xE8,0x1B,0x68,0xE3},
215 {0xE9,0x24,0xCF,0x4F,0x89,0x3C,0x5B,0x0A},
216 {0xA7,0x18,0xC3,0x9F,0xFA,0x9F,0xD7,0x69},
217 {0x77,0x2C,0x79,0xB1,0xD2,0x31,0x7E,0xB1},
218 {0x49,0xAB,0x92,0x7F,0xD0,0x22,0x00,0xB7},
219 {0xCE,0x1C,0x6C,0x7D,0x85,0xE3,0x4A,0x6F},
220 {0xBE,0x91,0xD6,0xE1,0x27,0xB2,0xE9,0x87},
221 {0x70,0x28,0xAE,0x8F,0xD1,0xF5,0x74,0x1A},
222 {0xAA,0x37,0x80,0xBB,0xF3,0x22,0x1D,0xDE},
223 {0xA6,0xC4,0xD2,0x5E,0x28,0x93,0xAC,0xB3},
224 {0x22,0x07,0x81,0x5A,0xE4,0xB7,0x1A,0xAD},
225 {0xDC,0xCE,0x05,0xE7,0x07,0xBD,0xF5,0x84},
226 {0x26,0x1D,0x39,0x2C,0xB3,0xBA,0xA5,0x85},
227 {0xB4,0xF7,0x0F,0x72,0xFB,0x04,0xF0,0xDC},
228 {0x95,0xBA,0xA9,0x4E,0x87,0x36,0xF2,0x89},
229 {0xD4,0x07,0x3A,0xF1,0x5A,0x17,0x82,0x0E},
230 {0xEF,0x6F,0xAF,0xA7,0x66,0x1A,0x7E,0x89},
231 {0xC1,0x97,0xF5,0x58,0x74,0x8A,0x20,0xE7},
232 {0x43,0x34,0xCF,0xDA,0x22,0xC4,0x86,0xC8},
233 {0x08,0xD7,0xB4,0xFB,0x62,0x9D,0x08,0x85}};
234
235static unsigned char cbc_key [8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
236static unsigned char cbc2_key[8]={0xf1,0xe0,0xd3,0xc2,0xb5,0xa4,0x97,0x86};
237static unsigned char cbc3_key[8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
238static unsigned char cbc_iv [8]={0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
239/* Changed the following text constant to binary so it will work on ebcdic
240 * machines :-) */
241/* static char cbc_data[40]="7654321 Now is the time for \0001"; */
242static unsigned char cbc_data[40]={
243 0x37,0x36,0x35,0x34,0x33,0x32,0x31,0x20,
244 0x4E,0x6F,0x77,0x20,0x69,0x73,0x20,0x74,
245 0x68,0x65,0x20,0x74,0x69,0x6D,0x65,0x20,
246 0x66,0x6F,0x72,0x20,0x00,0x31,0x00,0x00,
247 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
248 };
249
250static unsigned char cbc_ok[32]={
251 0xcc,0xd1,0x73,0xff,0xab,0x20,0x39,0xf4,
252 0xac,0xd8,0xae,0xfd,0xdf,0xd8,0xa1,0xeb,
253 0x46,0x8e,0x91,0x15,0x78,0x88,0xba,0x68,
254 0x1d,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
255
256#ifdef SCREW_THE_PARITY
257#error "SCREW_THE_PARITY is not ment to be defined."
258#error "Original vectors are preserved for reference only."
259static unsigned char cbc2_key[8]={0xf0,0xe1,0xd2,0xc3,0xb4,0xa5,0x96,0x87};
260static unsigned char xcbc_ok[32]={
261 0x86,0x74,0x81,0x0D,0x61,0xA4,0xA5,0x48,
262 0xB9,0x93,0x03,0xE1,0xB8,0xBB,0xBD,0xBD,
263 0x64,0x30,0x0B,0xB9,0x06,0x65,0x81,0x76,
264 0x04,0x1D,0x77,0x62,0x17,0xCA,0x2B,0xD2,
265 };
266#else
267static unsigned char xcbc_ok[32]={
268 0x84,0x6B,0x29,0x14,0x85,0x1E,0x9A,0x29,
269 0x54,0x73,0x2F,0x8A,0xA0,0xA6,0x11,0xC1,
270 0x15,0xCD,0xC2,0xD7,0x95,0x1B,0x10,0x53,
271 0xA6,0x3C,0x5E,0x03,0xB2,0x1A,0xA3,0xC4,
272 };
273#endif
274
275static unsigned char cbc3_ok[32]={
276 0x3F,0xE3,0x01,0xC9,0x62,0xAC,0x01,0xD0,
277 0x22,0x13,0x76,0x3C,0x1C,0xBD,0x4C,0xDC,
278 0x79,0x96,0x57,0xC0,0x64,0xEC,0xF5,0xD4,
279 0x1C,0x67,0x38,0x12,0xCF,0xDE,0x96,0x75};
280
281static unsigned char pcbc_ok[32]={
282 0xcc,0xd1,0x73,0xff,0xab,0x20,0x39,0xf4,
283 0x6d,0xec,0xb4,0x70,0xa0,0xe5,0x6b,0x15,
284 0xae,0xa6,0xbf,0x61,0xed,0x7d,0x9c,0x9f,
285 0xf7,0x17,0x46,0x3b,0x8a,0xb3,0xcc,0x88};
286
287static unsigned char cfb_key[8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
288static unsigned char cfb_iv[8]={0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef};
289static unsigned char cfb_buf1[40],cfb_buf2[40],cfb_tmp[8];
290static unsigned char plain[24]=
291 {
292 0x4e,0x6f,0x77,0x20,0x69,0x73,
293 0x20,0x74,0x68,0x65,0x20,0x74,
294 0x69,0x6d,0x65,0x20,0x66,0x6f,
295 0x72,0x20,0x61,0x6c,0x6c,0x20
296 };
297static unsigned char cfb_cipher8[24]= {
298 0xf3,0x1f,0xda,0x07,0x01,0x14, 0x62,0xee,0x18,0x7f,0x43,0xd8,
299 0x0a,0x7c,0xd9,0xb5,0xb0,0xd2, 0x90,0xda,0x6e,0x5b,0x9a,0x87 };
300static unsigned char cfb_cipher16[24]={
301 0xF3,0x09,0x87,0x87,0x7F,0x57, 0xF7,0x3C,0x36,0xB6,0xDB,0x70,
302 0xD8,0xD5,0x34,0x19,0xD3,0x86, 0xB2,0x23,0xB7,0xB2,0xAD,0x1B };
303static unsigned char cfb_cipher32[24]={
304 0xF3,0x09,0x62,0x49,0xA4,0xDF, 0xA4,0x9F,0x33,0xDC,0x7B,0xAD,
305 0x4C,0xC8,0x9F,0x64,0xE4,0x53, 0xE5,0xEC,0x67,0x20,0xDA,0xB6 };
306static unsigned char cfb_cipher48[24]={
307 0xF3,0x09,0x62,0x49,0xC7,0xF4, 0x30,0xB5,0x15,0xEC,0xBB,0x85,
308 0x97,0x5A,0x13,0x8C,0x68,0x60, 0xE2,0x38,0x34,0x3C,0xDC,0x1F };
309static unsigned char cfb_cipher64[24]={
310 0xF3,0x09,0x62,0x49,0xC7,0xF4, 0x6E,0x51,0xA6,0x9E,0x83,0x9B,
311 0x1A,0x92,0xF7,0x84,0x03,0x46, 0x71,0x33,0x89,0x8E,0xA6,0x22 };
312
313static unsigned char ofb_key[8]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef};
314static unsigned char ofb_iv[8]={0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef};
315static unsigned char ofb_buf1[24],ofb_buf2[24],ofb_tmp[8];
316static unsigned char ofb_cipher[24]=
317 {
318 0xf3,0x09,0x62,0x49,0xc7,0xf4,0x6e,0x51,
319 0x35,0xf2,0x4a,0x24,0x2e,0xeb,0x3d,0x3f,
320 0x3d,0x6d,0x5b,0xe3,0x25,0x5a,0xf8,0xc3
321 };
322
323#if 0
324static DES_LONG cbc_cksum_ret=0xB462FEF7L;
325#else
326static DES_LONG cbc_cksum_ret=0xF7FE62B4L;
327#endif
328static unsigned char cbc_cksum_data[8]={0x1D,0x26,0x93,0x97,0xf7,0xfe,0x62,0xb4};
329
330static char *pt(unsigned char *p);
331static int cfb_test(int bits, unsigned char *cfb_cipher);
332static int cfb64_test(unsigned char *cfb_cipher);
333static int ede_cfb64_test(unsigned char *cfb_cipher);
334int main(int argc, char *argv[])
335 {
336 int j,err=0;
337 unsigned int i;
338 des_cblock in,out,outin,iv3,iv2;
339 des_key_schedule ks,ks2,ks3;
340 unsigned char cbc_in[40];
341 unsigned char cbc_out[40];
342 DES_LONG cs;
343 unsigned char cret[8];
344#ifdef _CRAY
345 struct {
346 int a:32;
347 int b:32;
348 } lqret[2];
349#else
350 DES_LONG lqret[4];
351#endif
352 int num;
353 char *str;
354
355#ifndef OPENSSL_NO_DESCBCM
356 printf("Doing cbcm\n");
357 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
358 {
359 printf("Key error %d\n",j);
360 err=1;
361 }
362 if ((j=DES_set_key_checked(&cbc2_key,&ks2)) != 0)
363 {
364 printf("Key error %d\n",j);
365 err=1;
366 }
367 if ((j=DES_set_key_checked(&cbc3_key,&ks3)) != 0)
368 {
369 printf("Key error %d\n",j);
370 err=1;
371 }
372 memset(cbc_out,0,40);
373 memset(cbc_in,0,40);
374 i=strlen((char *)cbc_data)+1;
375 /* i=((i+7)/8)*8; */
376 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
377 memset(iv2,'\0',sizeof iv2);
378
379 DES_ede3_cbcm_encrypt(cbc_data,cbc_out,16L,&ks,&ks2,&ks3,&iv3,&iv2,
380 DES_ENCRYPT);
381 DES_ede3_cbcm_encrypt(&cbc_data[16],&cbc_out[16],i-16,&ks,&ks2,&ks3,
382 &iv3,&iv2,DES_ENCRYPT);
383 /* if (memcmp(cbc_out,cbc3_ok,
384 (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
385 {
386 printf("des_ede3_cbc_encrypt encrypt error\n");
387 err=1;
388 }
389 */
390 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
391 memset(iv2,'\0',sizeof iv2);
392 DES_ede3_cbcm_encrypt(cbc_out,cbc_in,i,&ks,&ks2,&ks3,&iv3,&iv2,DES_DECRYPT);
393 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
394 {
395 unsigned int n;
396
397 printf("des_ede3_cbcm_encrypt decrypt error\n");
398 for(n=0 ; n < i ; ++n)
399 printf(" %02x",cbc_data[n]);
400 printf("\n");
401 for(n=0 ; n < i ; ++n)
402 printf(" %02x",cbc_in[n]);
403 printf("\n");
404 err=1;
405 }
406#endif
407
408 printf("Doing ecb\n");
409 for (i=0; i<NUM_TESTS; i++)
410 {
411 DES_set_key_unchecked(&key_data[i],&ks);
412 memcpy(in,plain_data[i],8);
413 memset(out,0,8);
414 memset(outin,0,8);
415 des_ecb_encrypt(&in,&out,ks,DES_ENCRYPT);
416 des_ecb_encrypt(&out,&outin,ks,DES_DECRYPT);
417
418 if (memcmp(out,cipher_data[i],8) != 0)
419 {
420 printf("Encryption error %2d\nk=%s p=%s o=%s act=%s\n",
421 i+1,pt(key_data[i]),pt(in),pt(cipher_data[i]),
422 pt(out));
423 err=1;
424 }
425 if (memcmp(in,outin,8) != 0)
426 {
427 printf("Decryption error %2d\nk=%s p=%s o=%s act=%s\n",
428 i+1,pt(key_data[i]),pt(out),pt(in),pt(outin));
429 err=1;
430 }
431 }
432
433#ifndef LIBDES_LIT
434 printf("Doing ede ecb\n");
435 for (i=0; i<(NUM_TESTS-2); i++)
436 {
437 DES_set_key_unchecked(&key_data[i],&ks);
438 DES_set_key_unchecked(&key_data[i+1],&ks2);
439 DES_set_key_unchecked(&key_data[i+2],&ks3);
440 memcpy(in,plain_data[i],8);
441 memset(out,0,8);
442 memset(outin,0,8);
443 des_ecb2_encrypt(&in,&out,ks,ks2,DES_ENCRYPT);
444 des_ecb2_encrypt(&out,&outin,ks,ks2,DES_DECRYPT);
445
446 if (memcmp(out,cipher_ecb2[i],8) != 0)
447 {
448 printf("Encryption error %2d\nk=%s p=%s o=%s act=%s\n",
449 i+1,pt(key_data[i]),pt(in),pt(cipher_ecb2[i]),
450 pt(out));
451 err=1;
452 }
453 if (memcmp(in,outin,8) != 0)
454 {
455 printf("Decryption error %2d\nk=%s p=%s o=%s act=%s\n",
456 i+1,pt(key_data[i]),pt(out),pt(in),pt(outin));
457 err=1;
458 }
459 }
460#endif
461
462 printf("Doing cbc\n");
463 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
464 {
465 printf("Key error %d\n",j);
466 err=1;
467 }
468 memset(cbc_out,0,40);
469 memset(cbc_in,0,40);
470 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
471 des_ncbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
472 &iv3,DES_ENCRYPT);
473 if (memcmp(cbc_out,cbc_ok,32) != 0)
474 {
475 printf("cbc_encrypt encrypt error\n");
476 err=1;
477 }
478
479 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
480 des_ncbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
481 &iv3,DES_DECRYPT);
482 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)) != 0)
483 {
484 printf("cbc_encrypt decrypt error\n");
485 err=1;
486 }
487
488#ifndef LIBDES_LIT
489 printf("Doing desx cbc\n");
490 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
491 {
492 printf("Key error %d\n",j);
493 err=1;
494 }
495 memset(cbc_out,0,40);
496 memset(cbc_in,0,40);
497 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
498 des_xcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
499 &iv3,&cbc2_key,&cbc3_key, DES_ENCRYPT);
500 if (memcmp(cbc_out,xcbc_ok,32) != 0)
501 {
502 printf("des_xcbc_encrypt encrypt error\n");
503 err=1;
504 }
505 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
506 des_xcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,
507 &iv3,&cbc2_key,&cbc3_key, DES_DECRYPT);
508 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
509 {
510 printf("des_xcbc_encrypt decrypt error\n");
511 err=1;
512 }
513#endif
514
515 printf("Doing ede cbc\n");
516 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
517 {
518 printf("Key error %d\n",j);
519 err=1;
520 }
521 if ((j=DES_set_key_checked(&cbc2_key,&ks2)) != 0)
522 {
523 printf("Key error %d\n",j);
524 err=1;
525 }
526 if ((j=DES_set_key_checked(&cbc3_key,&ks3)) != 0)
527 {
528 printf("Key error %d\n",j);
529 err=1;
530 }
531 memset(cbc_out,0,40);
532 memset(cbc_in,0,40);
533 i=strlen((char *)cbc_data)+1;
534 /* i=((i+7)/8)*8; */
535 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
536
537 des_ede3_cbc_encrypt(cbc_data,cbc_out,16L,ks,ks2,ks3,&iv3,
538 DES_ENCRYPT);
539 des_ede3_cbc_encrypt(&(cbc_data[16]),&(cbc_out[16]),i-16,ks,ks2,ks3,
540 &iv3,DES_ENCRYPT);
541 if (memcmp(cbc_out,cbc3_ok,
542 (unsigned int)(strlen((char *)cbc_data)+1+7)/8*8) != 0)
543 {
544 unsigned int n;
545
546 printf("des_ede3_cbc_encrypt encrypt error\n");
547 for(n=0 ; n < i ; ++n)
548 printf(" %02x",cbc_out[n]);
549 printf("\n");
550 for(n=0 ; n < i ; ++n)
551 printf(" %02x",cbc3_ok[n]);
552 printf("\n");
553 err=1;
554 }
555
556 memcpy(iv3,cbc_iv,sizeof(cbc_iv));
557 des_ede3_cbc_encrypt(cbc_out,cbc_in,i,ks,ks2,ks3,&iv3,DES_DECRYPT);
558 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
559 {
560 unsigned int n;
561
562 printf("des_ede3_cbc_encrypt decrypt error\n");
563 for(n=0 ; n < i ; ++n)
564 printf(" %02x",cbc_data[n]);
565 printf("\n");
566 for(n=0 ; n < i ; ++n)
567 printf(" %02x",cbc_in[n]);
568 printf("\n");
569 err=1;
570 }
571
572#ifndef LIBDES_LIT
573 printf("Doing pcbc\n");
574 if ((j=DES_set_key_checked(&cbc_key,&ks)) != 0)
575 {
576 printf("Key error %d\n",j);
577 err=1;
578 }
579 memset(cbc_out,0,40);
580 memset(cbc_in,0,40);
581 des_pcbc_encrypt(cbc_data,cbc_out,strlen((char *)cbc_data)+1,ks,
582 &cbc_iv,DES_ENCRYPT);
583 if (memcmp(cbc_out,pcbc_ok,32) != 0)
584 {
585 printf("pcbc_encrypt encrypt error\n");
586 err=1;
587 }
588 des_pcbc_encrypt(cbc_out,cbc_in,strlen((char *)cbc_data)+1,ks,&cbc_iv,
589 DES_DECRYPT);
590 if (memcmp(cbc_in,cbc_data,strlen((char *)cbc_data)+1) != 0)
591 {
592 printf("pcbc_encrypt decrypt error\n");
593 err=1;
594 }
595
596 printf("Doing ");
597 printf("cfb8 ");
598 err+=cfb_test(8,cfb_cipher8);
599 printf("cfb16 ");
600 err+=cfb_test(16,cfb_cipher16);
601 printf("cfb32 ");
602 err+=cfb_test(32,cfb_cipher32);
603 printf("cfb48 ");
604 err+=cfb_test(48,cfb_cipher48);
605 printf("cfb64 ");
606 err+=cfb_test(64,cfb_cipher64);
607
608 printf("cfb64() ");
609 err+=cfb64_test(cfb_cipher64);
610
611 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
612 for (i=0; i<sizeof(plain); i++)
613 des_cfb_encrypt(&(plain[i]),&(cfb_buf1[i]),
614 8,1,ks,&cfb_tmp,DES_ENCRYPT);
615 if (memcmp(cfb_cipher8,cfb_buf1,sizeof(plain)) != 0)
616 {
617 printf("cfb_encrypt small encrypt error\n");
618 err=1;
619 }
620
621 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
622 for (i=0; i<sizeof(plain); i++)
623 des_cfb_encrypt(&(cfb_buf1[i]),&(cfb_buf2[i]),
624 8,1,ks,&cfb_tmp,DES_DECRYPT);
625 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
626 {
627 printf("cfb_encrypt small decrypt error\n");
628 err=1;
629 }
630
631 printf("ede_cfb64() ");
632 err+=ede_cfb64_test(cfb_cipher64);
633
634 printf("done\n");
635
636 printf("Doing ofb\n");
637 DES_set_key_checked(&ofb_key,&ks);
638 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
639 des_ofb_encrypt(plain,ofb_buf1,64,sizeof(plain)/8,ks,&ofb_tmp);
640 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
641 {
642 printf("ofb_encrypt encrypt error\n");
643printf("%02X %02X %02X %02X %02X %02X %02X %02X\n",
644ofb_buf1[8+0], ofb_buf1[8+1], ofb_buf1[8+2], ofb_buf1[8+3],
645ofb_buf1[8+4], ofb_buf1[8+5], ofb_buf1[8+6], ofb_buf1[8+7]);
646printf("%02X %02X %02X %02X %02X %02X %02X %02X\n",
647ofb_buf1[8+0], ofb_cipher[8+1], ofb_cipher[8+2], ofb_cipher[8+3],
648ofb_buf1[8+4], ofb_cipher[8+5], ofb_cipher[8+6], ofb_cipher[8+7]);
649 err=1;
650 }
651 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
652 des_ofb_encrypt(ofb_buf1,ofb_buf2,64,sizeof(ofb_buf1)/8,ks,&ofb_tmp);
653 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
654 {
655 printf("ofb_encrypt decrypt error\n");
656printf("%02X %02X %02X %02X %02X %02X %02X %02X\n",
657ofb_buf2[8+0], ofb_buf2[8+1], ofb_buf2[8+2], ofb_buf2[8+3],
658ofb_buf2[8+4], ofb_buf2[8+5], ofb_buf2[8+6], ofb_buf2[8+7]);
659printf("%02X %02X %02X %02X %02X %02X %02X %02X\n",
660plain[8+0], plain[8+1], plain[8+2], plain[8+3],
661plain[8+4], plain[8+5], plain[8+6], plain[8+7]);
662 err=1;
663 }
664
665 printf("Doing ofb64\n");
666 DES_set_key_checked(&ofb_key,&ks);
667 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
668 memset(ofb_buf1,0,sizeof(ofb_buf1));
669 memset(ofb_buf2,0,sizeof(ofb_buf1));
670 num=0;
671 for (i=0; i<sizeof(plain); i++)
672 {
673 des_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,&ofb_tmp,
674 &num);
675 }
676 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
677 {
678 printf("ofb64_encrypt encrypt error\n");
679 err=1;
680 }
681 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
682 num=0;
683 des_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,&ofb_tmp,
684 &num);
685 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
686 {
687 printf("ofb64_encrypt decrypt error\n");
688 err=1;
689 }
690
691 printf("Doing ede_ofb64\n");
692 DES_set_key_checked(&ofb_key,&ks);
693 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
694 memset(ofb_buf1,0,sizeof(ofb_buf1));
695 memset(ofb_buf2,0,sizeof(ofb_buf1));
696 num=0;
697 for (i=0; i<sizeof(plain); i++)
698 {
699 des_ede3_ofb64_encrypt(&(plain[i]),&(ofb_buf1[i]),1,ks,ks,
700 ks,&ofb_tmp,&num);
701 }
702 if (memcmp(ofb_cipher,ofb_buf1,sizeof(ofb_buf1)) != 0)
703 {
704 printf("ede_ofb64_encrypt encrypt error\n");
705 err=1;
706 }
707 memcpy(ofb_tmp,ofb_iv,sizeof(ofb_iv));
708 num=0;
709 des_ede3_ofb64_encrypt(ofb_buf1,ofb_buf2,sizeof(ofb_buf1),ks,ks,ks,
710 &ofb_tmp,&num);
711 if (memcmp(plain,ofb_buf2,sizeof(ofb_buf2)) != 0)
712 {
713 printf("ede_ofb64_encrypt decrypt error\n");
714 err=1;
715 }
716
717 printf("Doing cbc_cksum\n");
718 DES_set_key_checked(&cbc_key,&ks);
719 cs=des_cbc_cksum(cbc_data,&cret,strlen((char *)cbc_data),ks,&cbc_iv);
720 if (cs != cbc_cksum_ret)
721 {
722 printf("bad return value (%08lX), should be %08lX\n",
723 (unsigned long)cs,(unsigned long)cbc_cksum_ret);
724 err=1;
725 }
726 if (memcmp(cret,cbc_cksum_data,8) != 0)
727 {
728 printf("bad cbc_cksum block returned\n");
729 err=1;
730 }
731
732 printf("Doing quad_cksum\n");
733 cs=des_quad_cksum(cbc_data,(des_cblock *)lqret,
734 (long)strlen((char *)cbc_data),2,(des_cblock *)cbc_iv);
735 if (cs != 0x70d7a63aL)
736 {
737 printf("quad_cksum error, ret %08lx should be 70d7a63a\n",
738 (unsigned long)cs);
739 err=1;
740 }
741#ifdef _CRAY
742 if (lqret[0].a != 0x327eba8dL)
743 {
744 printf("quad_cksum error, out[0] %08lx is not %08lx\n",
745 (unsigned long)lqret[0].a,0x327eba8dUL);
746 err=1;
747 }
748 if (lqret[0].b != 0x201a49ccL)
749 {
750 printf("quad_cksum error, out[1] %08lx is not %08lx\n",
751 (unsigned long)lqret[0].b,0x201a49ccUL);
752 err=1;
753 }
754 if (lqret[1].a != 0x70d7a63aL)
755 {
756 printf("quad_cksum error, out[2] %08lx is not %08lx\n",
757 (unsigned long)lqret[1].a,0x70d7a63aUL);
758 err=1;
759 }
760 if (lqret[1].b != 0x501c2c26L)
761 {
762 printf("quad_cksum error, out[3] %08lx is not %08lx\n",
763 (unsigned long)lqret[1].b,0x501c2c26UL);
764 err=1;
765 }
766#else
767 if (lqret[0] != 0x327eba8dL)
768 {
769 printf("quad_cksum error, out[0] %08lx is not %08lx\n",
770 (unsigned long)lqret[0],0x327eba8dUL);
771 err=1;
772 }
773 if (lqret[1] != 0x201a49ccL)
774 {
775 printf("quad_cksum error, out[1] %08lx is not %08lx\n",
776 (unsigned long)lqret[1],0x201a49ccUL);
777 err=1;
778 }
779 if (lqret[2] != 0x70d7a63aL)
780 {
781 printf("quad_cksum error, out[2] %08lx is not %08lx\n",
782 (unsigned long)lqret[2],0x70d7a63aUL);
783 err=1;
784 }
785 if (lqret[3] != 0x501c2c26L)
786 {
787 printf("quad_cksum error, out[3] %08lx is not %08lx\n",
788 (unsigned long)lqret[3],0x501c2c26UL);
789 err=1;
790 }
791#endif
792#endif
793
794 printf("input word alignment test");
795 for (i=0; i<4; i++)
796 {
797 printf(" %d",i);
798 des_ncbc_encrypt(&(cbc_out[i]),cbc_in,
799 strlen((char *)cbc_data)+1,ks,
800 &cbc_iv,DES_ENCRYPT);
801 }
802 printf("\noutput word alignment test");
803 for (i=0; i<4; i++)
804 {
805 printf(" %d",i);
806 des_ncbc_encrypt(cbc_out,&(cbc_in[i]),
807 strlen((char *)cbc_data)+1,ks,
808 &cbc_iv,DES_ENCRYPT);
809 }
810 printf("\n");
811 printf("fast crypt test ");
812 str=crypt("testing","ef");
813 if (strcmp("efGnQx2725bI2",str) != 0)
814 {
815 printf("fast crypt error, %s should be efGnQx2725bI2\n",str);
816 err=1;
817 }
818 str=crypt("bca76;23","yA");
819 if (strcmp("yA1Rp/1hZXIJk",str) != 0)
820 {
821 printf("fast crypt error, %s should be yA1Rp/1hZXIJk\n",str);
822 err=1;
823 }
824#ifdef OPENSSL_SYS_NETWARE
825 if (err) printf("ERROR: %d\n", err);
826#endif
827 printf("\n");
828 return(err);
829 }
830
831static char *pt(unsigned char *p)
832 {
833 static char bufs[10][20];
834 static int bnum=0;
835 char *ret;
836 int i;
837 static char *f="0123456789ABCDEF";
838
839 ret= &(bufs[bnum++][0]);
840 bnum%=10;
841 for (i=0; i<8; i++)
842 {
843 ret[i*2]=f[(p[i]>>4)&0xf];
844 ret[i*2+1]=f[p[i]&0xf];
845 }
846 ret[16]='\0';
847 return(ret);
848 }
849
850#ifndef LIBDES_LIT
851
852static int cfb_test(int bits, unsigned char *cfb_cipher)
853 {
854 des_key_schedule ks;
855 int i,err=0;
856
857 DES_set_key_checked(&cfb_key,&ks);
858 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
859 des_cfb_encrypt(plain,cfb_buf1,bits,sizeof(plain),ks,&cfb_tmp,
860 DES_ENCRYPT);
861 if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
862 {
863 err=1;
864 printf("cfb_encrypt encrypt error\n");
865 for (i=0; i<24; i+=8)
866 printf("%s\n",pt(&(cfb_buf1[i])));
867 }
868 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
869 des_cfb_encrypt(cfb_buf1,cfb_buf2,bits,sizeof(plain),ks,&cfb_tmp,
870 DES_DECRYPT);
871 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
872 {
873 err=1;
874 printf("cfb_encrypt decrypt error\n");
875 for (i=0; i<24; i+=8)
876 printf("%s\n",pt(&(cfb_buf1[i])));
877 }
878 return(err);
879 }
880
881static int cfb64_test(unsigned char *cfb_cipher)
882 {
883 des_key_schedule ks;
884 int err=0,i,n;
885
886 DES_set_key_checked(&cfb_key,&ks);
887 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
888 n=0;
889 des_cfb64_encrypt(plain,cfb_buf1,12,ks,&cfb_tmp,&n,DES_ENCRYPT);
890 des_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),sizeof(plain)-12,ks,
891 &cfb_tmp,&n,DES_ENCRYPT);
892 if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
893 {
894 err=1;
895 printf("cfb_encrypt encrypt error\n");
896 for (i=0; i<24; i+=8)
897 printf("%s\n",pt(&(cfb_buf1[i])));
898 }
899 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
900 n=0;
901 des_cfb64_encrypt(cfb_buf1,cfb_buf2,17,ks,&cfb_tmp,&n,DES_DECRYPT);
902 des_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
903 sizeof(plain)-17,ks,&cfb_tmp,&n,DES_DECRYPT);
904 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
905 {
906 err=1;
907 printf("cfb_encrypt decrypt error\n");
908 for (i=0; i<24; i+=8)
909 printf("%s\n",pt(&(cfb_buf2[i])));
910 }
911 return(err);
912 }
913
914static int ede_cfb64_test(unsigned char *cfb_cipher)
915 {
916 des_key_schedule ks;
917 int err=0,i,n;
918
919 DES_set_key_checked(&cfb_key,&ks);
920 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
921 n=0;
922 des_ede3_cfb64_encrypt(plain,cfb_buf1,12,ks,ks,ks,&cfb_tmp,&n,
923 DES_ENCRYPT);
924 des_ede3_cfb64_encrypt(&(plain[12]),&(cfb_buf1[12]),
925 sizeof(plain)-12,ks,ks,ks,
926 &cfb_tmp,&n,DES_ENCRYPT);
927 if (memcmp(cfb_cipher,cfb_buf1,sizeof(plain)) != 0)
928 {
929 err=1;
930 printf("ede_cfb_encrypt encrypt error\n");
931 for (i=0; i<24; i+=8)
932 printf("%s\n",pt(&(cfb_buf1[i])));
933 }
934 memcpy(cfb_tmp,cfb_iv,sizeof(cfb_iv));
935 n=0;
936 des_ede3_cfb64_encrypt(cfb_buf1,cfb_buf2,(long)17,ks,ks,ks,
937 &cfb_tmp,&n,DES_DECRYPT);
938 des_ede3_cfb64_encrypt(&(cfb_buf1[17]),&(cfb_buf2[17]),
939 sizeof(plain)-17,ks,ks,ks,
940 &cfb_tmp,&n,DES_DECRYPT);
941 if (memcmp(plain,cfb_buf2,sizeof(plain)) != 0)
942 {
943 err=1;
944 printf("ede_cfb_encrypt decrypt error\n");
945 for (i=0; i<24; i+=8)
946 printf("%s\n",pt(&(cfb_buf2[i])));
947 }
948 return(err);
949 }
950
951#endif
952#endif
diff --git a/src/lib/libcrypto/des/ecb3_enc.c b/src/lib/libcrypto/des/ecb3_enc.c
deleted file mode 100644
index c3437bc606..0000000000
--- a/src/lib/libcrypto/des/ecb3_enc.c
+++ /dev/null
@@ -1,83 +0,0 @@
1/* crypto/des/ecb3_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60
61void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output,
62 DES_key_schedule *ks1, DES_key_schedule *ks2,
63 DES_key_schedule *ks3,
64 int enc)
65 {
66 register DES_LONG l0,l1;
67 DES_LONG ll[2];
68 const unsigned char *in = &(*input)[0];
69 unsigned char *out = &(*output)[0];
70
71 c2l(in,l0);
72 c2l(in,l1);
73 ll[0]=l0;
74 ll[1]=l1;
75 if (enc)
76 DES_encrypt3(ll,ks1,ks2,ks3);
77 else
78 DES_decrypt3(ll,ks1,ks2,ks3);
79 l0=ll[0];
80 l1=ll[1];
81 l2c(l0,out);
82 l2c(l1,out);
83 }
diff --git a/src/lib/libcrypto/des/ecb_enc.c b/src/lib/libcrypto/des/ecb_enc.c
deleted file mode 100644
index 0684e769b3..0000000000
--- a/src/lib/libcrypto/des/ecb_enc.c
+++ /dev/null
@@ -1,122 +0,0 @@
1/* crypto/des/ecb_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60#include "des_ver.h"
61#include <openssl/opensslv.h>
62#include <openssl/bio.h>
63
64OPENSSL_GLOBAL const char libdes_version[]="libdes" OPENSSL_VERSION_PTEXT;
65OPENSSL_GLOBAL const char DES_version[]="DES" OPENSSL_VERSION_PTEXT;
66
67const char *DES_options(void)
68 {
69 static int init=1;
70 static char buf[32];
71
72 if (init)
73 {
74 const char *ptr,*unroll,*risc,*size;
75
76#ifdef DES_PTR
77 ptr="ptr";
78#else
79 ptr="idx";
80#endif
81#if defined(DES_RISC1) || defined(DES_RISC2)
82#ifdef DES_RISC1
83 risc="risc1";
84#endif
85#ifdef DES_RISC2
86 risc="risc2";
87#endif
88#else
89 risc="cisc";
90#endif
91#ifdef DES_UNROLL
92 unroll="16";
93#else
94 unroll="2";
95#endif
96 if (sizeof(DES_LONG) != sizeof(long))
97 size="int";
98 else
99 size="long";
100 BIO_snprintf(buf,sizeof buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,
101 size);
102 init=0;
103 }
104 return(buf);
105 }
106
107
108void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output,
109 DES_key_schedule *ks, int enc)
110 {
111 register DES_LONG l;
112 DES_LONG ll[2];
113 const unsigned char *in = &(*input)[0];
114 unsigned char *out = &(*output)[0];
115
116 c2l(in,l); ll[0]=l;
117 c2l(in,l); ll[1]=l;
118 DES_encrypt1(ll,ks,enc);
119 l=ll[0]; l2c(l,out);
120 l=ll[1]; l2c(l,out);
121 l=ll[0]=ll[1]=0;
122 }
diff --git a/src/lib/libcrypto/des/ede_cbcm_enc.c b/src/lib/libcrypto/des/ede_cbcm_enc.c
deleted file mode 100644
index adfcb75cf3..0000000000
--- a/src/lib/libcrypto/des/ede_cbcm_enc.c
+++ /dev/null
@@ -1,199 +0,0 @@
1/* ede_cbcm_enc.c */
2/* Written by Ben Laurie <ben@algroup.co.uk> for the OpenSSL
3 * project 13 Feb 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59/*
60
61This is an implementation of Triple DES Cipher Block Chaining with Output
62Feedback Masking, by Coppersmith, Johnson and Matyas, (IBM and Certicom).
63
64Note that there is a known attack on this by Biham and Knudsen but it takes
65a lot of work:
66
67http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/1998/CS/CS0928.ps.gz
68
69*/
70
71#include <openssl/opensslconf.h> /* To see if OPENSSL_NO_DESCBCM is defined */
72
73#ifndef OPENSSL_NO_DESCBCM
74#include "des_locl.h"
75
76void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out,
77 long length, DES_key_schedule *ks1, DES_key_schedule *ks2,
78 DES_key_schedule *ks3, DES_cblock *ivec1, DES_cblock *ivec2,
79 int enc)
80 {
81 register DES_LONG tin0,tin1;
82 register DES_LONG tout0,tout1,xor0,xor1,m0,m1;
83 register long l=length;
84 DES_LONG tin[2];
85 unsigned char *iv1,*iv2;
86
87 iv1 = &(*ivec1)[0];
88 iv2 = &(*ivec2)[0];
89
90 if (enc)
91 {
92 c2l(iv1,m0);
93 c2l(iv1,m1);
94 c2l(iv2,tout0);
95 c2l(iv2,tout1);
96 for (l-=8; l>=-7; l-=8)
97 {
98 tin[0]=m0;
99 tin[1]=m1;
100 DES_encrypt1(tin,ks3,1);
101 m0=tin[0];
102 m1=tin[1];
103
104 if(l < 0)
105 {
106 c2ln(in,tin0,tin1,l+8);
107 }
108 else
109 {
110 c2l(in,tin0);
111 c2l(in,tin1);
112 }
113 tin0^=tout0;
114 tin1^=tout1;
115
116 tin[0]=tin0;
117 tin[1]=tin1;
118 DES_encrypt1(tin,ks1,1);
119 tin[0]^=m0;
120 tin[1]^=m1;
121 DES_encrypt1(tin,ks2,0);
122 tin[0]^=m0;
123 tin[1]^=m1;
124 DES_encrypt1(tin,ks1,1);
125 tout0=tin[0];
126 tout1=tin[1];
127
128 l2c(tout0,out);
129 l2c(tout1,out);
130 }
131 iv1=&(*ivec1)[0];
132 l2c(m0,iv1);
133 l2c(m1,iv1);
134
135 iv2=&(*ivec2)[0];
136 l2c(tout0,iv2);
137 l2c(tout1,iv2);
138 }
139 else
140 {
141 register DES_LONG t0,t1;
142
143 c2l(iv1,m0);
144 c2l(iv1,m1);
145 c2l(iv2,xor0);
146 c2l(iv2,xor1);
147 for (l-=8; l>=-7; l-=8)
148 {
149 tin[0]=m0;
150 tin[1]=m1;
151 DES_encrypt1(tin,ks3,1);
152 m0=tin[0];
153 m1=tin[1];
154
155 c2l(in,tin0);
156 c2l(in,tin1);
157
158 t0=tin0;
159 t1=tin1;
160
161 tin[0]=tin0;
162 tin[1]=tin1;
163 DES_encrypt1(tin,ks1,0);
164 tin[0]^=m0;
165 tin[1]^=m1;
166 DES_encrypt1(tin,ks2,1);
167 tin[0]^=m0;
168 tin[1]^=m1;
169 DES_encrypt1(tin,ks1,0);
170 tout0=tin[0];
171 tout1=tin[1];
172
173 tout0^=xor0;
174 tout1^=xor1;
175 if(l < 0)
176 {
177 l2cn(tout0,tout1,out,l+8);
178 }
179 else
180 {
181 l2c(tout0,out);
182 l2c(tout1,out);
183 }
184 xor0=t0;
185 xor1=t1;
186 }
187
188 iv1=&(*ivec1)[0];
189 l2c(m0,iv1);
190 l2c(m1,iv1);
191
192 iv2=&(*ivec2)[0];
193 l2c(xor0,iv2);
194 l2c(xor1,iv2);
195 }
196 tin0=tin1=tout0=tout1=xor0=xor1=0;
197 tin[0]=tin[1]=0;
198 }
199#endif
diff --git a/src/lib/libcrypto/des/enc_read.c b/src/lib/libcrypto/des/enc_read.c
deleted file mode 100644
index edb6620d08..0000000000
--- a/src/lib/libcrypto/des/enc_read.c
+++ /dev/null
@@ -1,240 +0,0 @@
1/* crypto/des/enc_read.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <errno.h>
61#include "cryptlib.h"
62#include "des_locl.h"
63
64/* This has some uglies in it but it works - even over sockets. */
65/*extern int errno;*/
66OPENSSL_IMPLEMENT_GLOBAL(int,DES_rw_mode,DES_PCBC_MODE)
67
68
69/*
70 * WARNINGS:
71 *
72 * - The data format used by DES_enc_write() and DES_enc_read()
73 * has a cryptographic weakness: When asked to write more
74 * than MAXWRITE bytes, DES_enc_write will split the data
75 * into several chunks that are all encrypted
76 * using the same IV. So don't use these functions unless you
77 * are sure you know what you do (in which case you might
78 * not want to use them anyway).
79 *
80 * - This code cannot handle non-blocking sockets.
81 *
82 * - This function uses an internal state and thus cannot be
83 * used on multiple files.
84 */
85
86
87int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
88 DES_cblock *iv)
89 {
90#if defined(OPENSSL_NO_POSIX_IO)
91 return(0);
92#else
93 /* data to be unencrypted */
94 int net_num=0;
95 static unsigned char *net=NULL;
96 /* extra unencrypted data
97 * for when a block of 100 comes in but is des_read one byte at
98 * a time. */
99 static unsigned char *unnet=NULL;
100 static int unnet_start=0;
101 static int unnet_left=0;
102 static unsigned char *tmpbuf=NULL;
103 int i;
104 long num=0,rnum;
105 unsigned char *p;
106
107 if (tmpbuf == NULL)
108 {
109 tmpbuf=OPENSSL_malloc(BSIZE);
110 if (tmpbuf == NULL) return(-1);
111 }
112 if (net == NULL)
113 {
114 net=OPENSSL_malloc(BSIZE);
115 if (net == NULL) return(-1);
116 }
117 if (unnet == NULL)
118 {
119 unnet=OPENSSL_malloc(BSIZE);
120 if (unnet == NULL) return(-1);
121 }
122 /* left over data from last decrypt */
123 if (unnet_left != 0)
124 {
125 if (unnet_left < len)
126 {
127 /* we still still need more data but will return
128 * with the number of bytes we have - should always
129 * check the return value */
130 memcpy(buf,&(unnet[unnet_start]),
131 unnet_left);
132 /* eay 26/08/92 I had the next 2 lines
133 * reversed :-( */
134 i=unnet_left;
135 unnet_start=unnet_left=0;
136 }
137 else
138 {
139 memcpy(buf,&(unnet[unnet_start]),len);
140 unnet_start+=len;
141 unnet_left-=len;
142 i=len;
143 }
144 return(i);
145 }
146
147 /* We need to get more data. */
148 if (len > MAXWRITE) len=MAXWRITE;
149
150 /* first - get the length */
151 while (net_num < HDRSIZE)
152 {
153#ifndef OPENSSL_SYS_WIN32
154 i=read(fd,(void *)&(net[net_num]),HDRSIZE-net_num);
155#else
156 i=_read(fd,(void *)&(net[net_num]),HDRSIZE-net_num);
157#endif
158#ifdef EINTR
159 if ((i == -1) && (errno == EINTR)) continue;
160#endif
161 if (i <= 0) return(0);
162 net_num+=i;
163 }
164
165 /* we now have at net_num bytes in net */
166 p=net;
167 /* num=0; */
168 n2l(p,num);
169 /* num should be rounded up to the next group of eight
170 * we make sure that we have read a multiple of 8 bytes from the net.
171 */
172 if ((num > MAXWRITE) || (num < 0)) /* error */
173 return(-1);
174 rnum=(num < 8)?8:((num+7)/8*8);
175
176 net_num=0;
177 while (net_num < rnum)
178 {
179#ifndef OPENSSL_SYS_WIN32
180 i=read(fd,(void *)&(net[net_num]),rnum-net_num);
181#else
182 i=_read(fd,(void *)&(net[net_num]),rnum-net_num);
183#endif
184#ifdef EINTR
185 if ((i == -1) && (errno == EINTR)) continue;
186#endif
187 if (i <= 0) return(0);
188 net_num+=i;
189 }
190
191 /* Check if there will be data left over. */
192 if (len < num)
193 {
194 if (DES_rw_mode & DES_PCBC_MODE)
195 DES_pcbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT);
196 else
197 DES_cbc_encrypt(net,unnet,num,sched,iv,DES_DECRYPT);
198 memcpy(buf,unnet,len);
199 unnet_start=len;
200 unnet_left=num-len;
201
202 /* The following line is done because we return num
203 * as the number of bytes read. */
204 num=len;
205 }
206 else
207 {
208 /* >output is a multiple of 8 byes, if len < rnum
209 * >we must be careful. The user must be aware that this
210 * >routine will write more bytes than he asked for.
211 * >The length of the buffer must be correct.
212 * FIXED - Should be ok now 18-9-90 - eay */
213 if (len < rnum)
214 {
215
216 if (DES_rw_mode & DES_PCBC_MODE)
217 DES_pcbc_encrypt(net,tmpbuf,num,sched,iv,
218 DES_DECRYPT);
219 else
220 DES_cbc_encrypt(net,tmpbuf,num,sched,iv,
221 DES_DECRYPT);
222
223 /* eay 26/08/92 fix a bug that returned more
224 * bytes than you asked for (returned len bytes :-( */
225 memcpy(buf,tmpbuf,num);
226 }
227 else
228 {
229 if (DES_rw_mode & DES_PCBC_MODE)
230 DES_pcbc_encrypt(net,buf,num,sched,iv,
231 DES_DECRYPT);
232 else
233 DES_cbc_encrypt(net,buf,num,sched,iv,
234 DES_DECRYPT);
235 }
236 }
237 return num;
238#endif /* OPENSSL_NO_POSIX_IO */
239 }
240
diff --git a/src/lib/libcrypto/des/enc_writ.c b/src/lib/libcrypto/des/enc_writ.c
deleted file mode 100644
index 2353ac1e89..0000000000
--- a/src/lib/libcrypto/des/enc_writ.c
+++ /dev/null
@@ -1,179 +0,0 @@
1/* crypto/des/enc_writ.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <errno.h>
60#include <time.h>
61#include <stdio.h>
62#include "cryptlib.h"
63#include "des_locl.h"
64#include <openssl/rand.h>
65
66/*
67 * WARNINGS:
68 *
69 * - The data format used by DES_enc_write() and DES_enc_read()
70 * has a cryptographic weakness: When asked to write more
71 * than MAXWRITE bytes, DES_enc_write will split the data
72 * into several chunks that are all encrypted
73 * using the same IV. So don't use these functions unless you
74 * are sure you know what you do (in which case you might
75 * not want to use them anyway).
76 *
77 * - This code cannot handle non-blocking sockets.
78 */
79
80int DES_enc_write(int fd, const void *_buf, int len,
81 DES_key_schedule *sched, DES_cblock *iv)
82 {
83#if defined(OPENSSL_NO_POSIX_IO)
84 return (-1);
85#else
86#ifdef _LIBC
87 extern unsigned long time();
88 extern int write();
89#endif
90 const unsigned char *buf=_buf;
91 long rnum;
92 int i,j,k,outnum;
93 static unsigned char *outbuf=NULL;
94 unsigned char shortbuf[8];
95 unsigned char *p;
96 const unsigned char *cp;
97 static int start=1;
98
99 if (outbuf == NULL)
100 {
101 outbuf=OPENSSL_malloc(BSIZE+HDRSIZE);
102 if (outbuf == NULL) return(-1);
103 }
104 /* If we are sending less than 8 bytes, the same char will look
105 * the same if we don't pad it out with random bytes */
106 if (start)
107 {
108 start=0;
109 }
110
111 /* lets recurse if we want to send the data in small chunks */
112 if (len > MAXWRITE)
113 {
114 j=0;
115 for (i=0; i<len; i+=k)
116 {
117 k=DES_enc_write(fd,&(buf[i]),
118 ((len-i) > MAXWRITE)?MAXWRITE:(len-i),sched,iv);
119 if (k < 0)
120 return(k);
121 else
122 j+=k;
123 }
124 return(j);
125 }
126
127 /* write length first */
128 p=outbuf;
129 l2n(len,p);
130
131 /* pad short strings */
132 if (len < 8)
133 {
134 cp=shortbuf;
135 memcpy(shortbuf,buf,len);
136 RAND_pseudo_bytes(shortbuf+len, 8-len);
137 rnum=8;
138 }
139 else
140 {
141 cp=buf;
142 rnum=((len+7)/8*8); /* round up to nearest eight */
143 }
144
145 if (DES_rw_mode & DES_PCBC_MODE)
146 DES_pcbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv,
147 DES_ENCRYPT);
148 else
149 DES_cbc_encrypt(cp,&(outbuf[HDRSIZE]),(len<8)?8:len,sched,iv,
150 DES_ENCRYPT);
151
152 /* output */
153 outnum=rnum+HDRSIZE;
154
155 for (j=0; j<outnum; j+=i)
156 {
157 /* eay 26/08/92 I was not doing writing from where we
158 * got up to. */
159#ifndef _WIN32
160 i=write(fd,(void *)&(outbuf[j]),outnum-j);
161#else
162 i=_write(fd,(void *)&(outbuf[j]),outnum-j);
163#endif
164 if (i == -1)
165 {
166#ifdef EINTR
167 if (errno == EINTR)
168 i=0;
169 else
170#endif
171 /* This is really a bad error - very bad
172 * It will stuff-up both ends. */
173 return(-1);
174 }
175 }
176
177 return(len);
178#endif /* OPENSSL_NO_POSIX_IO */
179 }
diff --git a/src/lib/libcrypto/des/fcrypt.c b/src/lib/libcrypto/des/fcrypt.c
deleted file mode 100644
index ccbdff250f..0000000000
--- a/src/lib/libcrypto/des/fcrypt.c
+++ /dev/null
@@ -1,170 +0,0 @@
1/* NOCW */
2#include <stdio.h>
3#ifdef _OSD_POSIX
4#ifndef CHARSET_EBCDIC
5#define CHARSET_EBCDIC 1
6#endif
7#endif
8#ifdef CHARSET_EBCDIC
9#include <openssl/ebcdic.h>
10#endif
11
12/* This version of crypt has been developed from my MIT compatible
13 * DES library.
14 * Eric Young (eay@cryptsoft.com)
15 */
16
17/* Modification by Jens Kupferschmidt (Cu)
18 * I have included directive PARA for shared memory computers.
19 * I have included a directive LONGCRYPT to using this routine to cipher
20 * passwords with more then 8 bytes like HP-UX 10.x it used. The MAXPLEN
21 * definition is the maximum of length of password and can changed. I have
22 * defined 24.
23 */
24
25#include "des_locl.h"
26
27/* Added more values to handle illegal salt values the way normal
28 * crypt() implementations do. The patch was sent by
29 * Bjorn Gronvall <bg@sics.se>
30 */
31static unsigned const char con_salt[128]={
320xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,
330xDA,0xDB,0xDC,0xDD,0xDE,0xDF,0xE0,0xE1,
340xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,
350xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,
360xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,
370xFA,0xFB,0xFC,0xFD,0xFE,0xFF,0x00,0x01,
380x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,
390x0A,0x0B,0x05,0x06,0x07,0x08,0x09,0x0A,
400x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,
410x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,
420x1B,0x1C,0x1D,0x1E,0x1F,0x20,0x21,0x22,
430x23,0x24,0x25,0x20,0x21,0x22,0x23,0x24,
440x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,
450x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,
460x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,
470x3D,0x3E,0x3F,0x40,0x41,0x42,0x43,0x44,
48};
49
50static unsigned const char cov_2char[64]={
510x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,
520x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44,
530x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,
540x4D,0x4E,0x4F,0x50,0x51,0x52,0x53,0x54,
550x55,0x56,0x57,0x58,0x59,0x5A,0x61,0x62,
560x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,
570x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,
580x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A
59};
60
61char *DES_crypt(const char *buf, const char *salt)
62 {
63 static char buff[14];
64
65#ifndef CHARSET_EBCDIC
66 return(DES_fcrypt(buf,salt,buff));
67#else
68 char e_salt[2+1];
69 char e_buf[32+1]; /* replace 32 by 8 ? */
70 char *ret;
71
72 /* Copy at most 2 chars of salt */
73 if ((e_salt[0] = salt[0]) != '\0')
74 e_salt[1] = salt[1];
75
76 /* Copy at most 32 chars of password */
77 strncpy (e_buf, buf, sizeof(e_buf));
78
79 /* Make sure we have a delimiter */
80 e_salt[sizeof(e_salt)-1] = e_buf[sizeof(e_buf)-1] = '\0';
81
82 /* Convert the e_salt to ASCII, as that's what DES_fcrypt works on */
83 ebcdic2ascii(e_salt, e_salt, sizeof e_salt);
84
85 /* Convert the cleartext password to ASCII */
86 ebcdic2ascii(e_buf, e_buf, sizeof e_buf);
87
88 /* Encrypt it (from/to ASCII) */
89 ret = DES_fcrypt(e_buf,e_salt,buff);
90
91 /* Convert the result back to EBCDIC */
92 ascii2ebcdic(ret, ret, strlen(ret));
93
94 return ret;
95#endif
96 }
97
98
99char *DES_fcrypt(const char *buf, const char *salt, char *ret)
100 {
101 unsigned int i,j,x,y;
102 DES_LONG Eswap0,Eswap1;
103 DES_LONG out[2],ll;
104 DES_cblock key;
105 DES_key_schedule ks;
106 unsigned char bb[9];
107 unsigned char *b=bb;
108 unsigned char c,u;
109
110 /* eay 25/08/92
111 * If you call crypt("pwd","*") as often happens when you
112 * have * as the pwd field in /etc/passwd, the function
113 * returns *\0XXXXXXXXX
114 * The \0 makes the string look like * so the pwd "*" would
115 * crypt to "*". This was found when replacing the crypt in
116 * our shared libraries. People found that the disabled
117 * accounts effectively had no passwd :-(. */
118#ifndef CHARSET_EBCDIC
119 x=ret[0]=((salt[0] == '\0')?'A':salt[0]);
120 Eswap0=con_salt[x]<<2;
121 x=ret[1]=((salt[1] == '\0')?'A':salt[1]);
122 Eswap1=con_salt[x]<<6;
123#else
124 x=ret[0]=((salt[0] == '\0')?os_toascii['A']:salt[0]);
125 Eswap0=con_salt[x]<<2;
126 x=ret[1]=((salt[1] == '\0')?os_toascii['A']:salt[1]);
127 Eswap1=con_salt[x]<<6;
128#endif
129
130/* EAY
131r=strlen(buf);
132r=(r+7)/8;
133*/
134 for (i=0; i<8; i++)
135 {
136 c= *(buf++);
137 if (!c) break;
138 key[i]=(c<<1);
139 }
140 for (; i<8; i++)
141 key[i]=0;
142
143 DES_set_key_unchecked(&key,&ks);
144 fcrypt_body(&(out[0]),&ks,Eswap0,Eswap1);
145
146 ll=out[0]; l2c(ll,b);
147 ll=out[1]; l2c(ll,b);
148 y=0;
149 u=0x80;
150 bb[8]=0;
151 for (i=2; i<13; i++)
152 {
153 c=0;
154 for (j=0; j<6; j++)
155 {
156 c<<=1;
157 if (bb[y] & u) c|=1;
158 u>>=1;
159 if (!u)
160 {
161 y++;
162 u=0x80;
163 }
164 }
165 ret[i]=cov_2char[c];
166 }
167 ret[13]='\0';
168 return(ret);
169 }
170
diff --git a/src/lib/libcrypto/des/fcrypt_b.c b/src/lib/libcrypto/des/fcrypt_b.c
deleted file mode 100644
index 87fc71eb26..0000000000
--- a/src/lib/libcrypto/des/fcrypt_b.c
+++ /dev/null
@@ -1,146 +0,0 @@
1/* crypto/des/fcrypt_b.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60
61/* This version of crypt has been developed from my MIT compatible
62 * DES library.
63 * The library is available at pub/Crypto/DES at ftp.psy.uq.oz.au
64 * Eric Young (eay@cryptsoft.com)
65 */
66
67#define DES_FCRYPT
68#include "des_locl.h"
69#undef DES_FCRYPT
70
71#ifndef OPENBSD_DES_ASM
72
73#undef PERM_OP
74#define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
75 (b)^=(t),\
76 (a)^=((t)<<(n)))
77
78#undef HPERM_OP
79#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
80 (a)=(a)^(t)^(t>>(16-(n))))\
81
82void fcrypt_body(DES_LONG *out, DES_key_schedule *ks, DES_LONG Eswap0,
83 DES_LONG Eswap1)
84 {
85 register DES_LONG l,r,t,u;
86#ifdef DES_PTR
87 register const unsigned char *des_SP=(const unsigned char *)DES_SPtrans;
88#endif
89 register DES_LONG *s;
90 register int j;
91 register DES_LONG E0,E1;
92
93 l=0;
94 r=0;
95
96 s=(DES_LONG *)ks;
97 E0=Eswap0;
98 E1=Eswap1;
99
100 for (j=0; j<25; j++)
101 {
102#ifndef DES_UNROLL
103 register int i;
104
105 for (i=0; i<32; i+=4)
106 {
107 D_ENCRYPT(l,r,i+0); /* 1 */
108 D_ENCRYPT(r,l,i+2); /* 2 */
109 }
110#else
111 D_ENCRYPT(l,r, 0); /* 1 */
112 D_ENCRYPT(r,l, 2); /* 2 */
113 D_ENCRYPT(l,r, 4); /* 3 */
114 D_ENCRYPT(r,l, 6); /* 4 */
115 D_ENCRYPT(l,r, 8); /* 5 */
116 D_ENCRYPT(r,l,10); /* 6 */
117 D_ENCRYPT(l,r,12); /* 7 */
118 D_ENCRYPT(r,l,14); /* 8 */
119 D_ENCRYPT(l,r,16); /* 9 */
120 D_ENCRYPT(r,l,18); /* 10 */
121 D_ENCRYPT(l,r,20); /* 11 */
122 D_ENCRYPT(r,l,22); /* 12 */
123 D_ENCRYPT(l,r,24); /* 13 */
124 D_ENCRYPT(r,l,26); /* 14 */
125 D_ENCRYPT(l,r,28); /* 15 */
126 D_ENCRYPT(r,l,30); /* 16 */
127#endif
128
129 t=l;
130 l=r;
131 r=t;
132 }
133 l=ROTATE(l,3)&0xffffffffL;
134 r=ROTATE(r,3)&0xffffffffL;
135
136 PERM_OP(l,r,t, 1,0x55555555L);
137 PERM_OP(r,l,t, 8,0x00ff00ffL);
138 PERM_OP(l,r,t, 2,0x33333333L);
139 PERM_OP(r,l,t,16,0x0000ffffL);
140 PERM_OP(l,r,t, 4,0x0f0f0f0fL);
141
142 out[0]=r;
143 out[1]=l;
144 }
145
146#endif /* OPENBSD_DES_ASM */
diff --git a/src/lib/libcrypto/des/makefile.bc b/src/lib/libcrypto/des/makefile.bc
deleted file mode 100644
index 1fe6d4915a..0000000000
--- a/src/lib/libcrypto/des/makefile.bc
+++ /dev/null
@@ -1,50 +0,0 @@
1#
2# Origional BC Makefile from Teun <Teun.Nijssen@kub.nl>
3#
4#
5CC = bcc
6TLIB = tlib /0 /C
7# note: the -3 flag produces code for 386, 486, Pentium etc; omit it for 286s
8OPTIMIZE= -3 -O2
9#WINDOWS= -W
10CFLAGS = -c -ml -d $(OPTIMIZE) $(WINDOWS) -DMSDOS
11LFLAGS = -ml $(WINDOWS)
12
13.c.obj:
14 $(CC) $(CFLAGS) $*.c
15
16.obj.exe:
17 $(CC) $(LFLAGS) -e$*.exe $*.obj libdes.lib
18
19all: $(LIB) destest.exe rpw.exe des.exe speed.exe
20
21# "make clean": use a directory containing only libdes .exe and .obj files...
22clean:
23 del *.exe
24 del *.obj
25 del libdes.lib
26 del libdes.rsp
27
28OBJS= cbc_cksm.obj cbc_enc.obj ecb_enc.obj pcbc_enc.obj \
29 qud_cksm.obj rand_key.obj set_key.obj str2key.obj \
30 enc_read.obj enc_writ.obj fcrypt.obj cfb_enc.obj \
31 ecb3_enc.obj ofb_enc.obj cbc3_enc.obj read_pwd.obj\
32 cfb64enc.obj ofb64enc.obj ede_enc.obj cfb64ede.obj\
33 ofb64ede.obj supp.obj
34
35LIB= libdes.lib
36
37$(LIB): $(OBJS)
38 del $(LIB)
39 makersp "+%s &\n" &&|
40 $(OBJS)
41| >libdes.rsp
42 $(TLIB) libdes.lib @libdes.rsp,nul
43 del libdes.rsp
44
45destest.exe: destest.obj libdes.lib
46rpw.exe: rpw.obj libdes.lib
47speed.exe: speed.obj libdes.lib
48des.exe: des.obj libdes.lib
49
50
diff --git a/src/lib/libcrypto/des/ncbc_enc.c b/src/lib/libcrypto/des/ncbc_enc.c
deleted file mode 100644
index fda23d522f..0000000000
--- a/src/lib/libcrypto/des/ncbc_enc.c
+++ /dev/null
@@ -1,148 +0,0 @@
1/* crypto/des/ncbc_enc.c */
2/*
3 * #included by:
4 * cbc_enc.c (DES_cbc_encrypt)
5 * des_enc.c (DES_ncbc_encrypt)
6 */
7/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
8 * All rights reserved.
9 *
10 * This package is an SSL implementation written
11 * by Eric Young (eay@cryptsoft.com).
12 * The implementation was written so as to conform with Netscapes SSL.
13 *
14 * This library is free for commercial and non-commercial use as long as
15 * the following conditions are aheared to. The following conditions
16 * apply to all code found in this distribution, be it the RC4, RSA,
17 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
18 * included with this distribution is covered by the same copyright terms
19 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
20 *
21 * Copyright remains Eric Young's, and as such any Copyright notices in
22 * the code are not to be removed.
23 * If this package is used in a product, Eric Young should be given attribution
24 * as the author of the parts of the library used.
25 * This can be in the form of a textual message at program startup or
26 * in documentation (online or textual) provided with the package.
27 *
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions
30 * are met:
31 * 1. Redistributions of source code must retain the copyright
32 * notice, this list of conditions and the following disclaimer.
33 * 2. Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in the
35 * documentation and/or other materials provided with the distribution.
36 * 3. All advertising materials mentioning features or use of this software
37 * must display the following acknowledgement:
38 * "This product includes cryptographic software written by
39 * Eric Young (eay@cryptsoft.com)"
40 * The word 'cryptographic' can be left out if the rouines from the library
41 * being used are not cryptographic related :-).
42 * 4. If you include any Windows specific code (or a derivative thereof) from
43 * the apps directory (application code) you must include an acknowledgement:
44 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
45 *
46 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
47 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 * SUCH DAMAGE.
57 *
58 * The licence and distribution terms for any publically available version or
59 * derivative of this code cannot be changed. i.e. this code cannot simply be
60 * copied and put under another distribution licence
61 * [including the GNU Public Licence.]
62 */
63
64#include "des_locl.h"
65
66#ifdef CBC_ENC_C__DONT_UPDATE_IV
67void DES_cbc_encrypt(const unsigned char *in, unsigned char *out, long length,
68 DES_key_schedule *_schedule, DES_cblock *ivec, int enc)
69#else
70void DES_ncbc_encrypt(const unsigned char *in, unsigned char *out, long length,
71 DES_key_schedule *_schedule, DES_cblock *ivec, int enc)
72#endif
73 {
74 register DES_LONG tin0,tin1;
75 register DES_LONG tout0,tout1,xor0,xor1;
76 register long l=length;
77 DES_LONG tin[2];
78 unsigned char *iv;
79
80 iv = &(*ivec)[0];
81
82 if (enc)
83 {
84 c2l(iv,tout0);
85 c2l(iv,tout1);
86 for (l-=8; l>=0; l-=8)
87 {
88 c2l(in,tin0);
89 c2l(in,tin1);
90 tin0^=tout0; tin[0]=tin0;
91 tin1^=tout1; tin[1]=tin1;
92 DES_encrypt1((DES_LONG *)tin,_schedule,DES_ENCRYPT);
93 tout0=tin[0]; l2c(tout0,out);
94 tout1=tin[1]; l2c(tout1,out);
95 }
96 if (l != -8)
97 {
98 c2ln(in,tin0,tin1,l+8);
99 tin0^=tout0; tin[0]=tin0;
100 tin1^=tout1; tin[1]=tin1;
101 DES_encrypt1((DES_LONG *)tin,_schedule,DES_ENCRYPT);
102 tout0=tin[0]; l2c(tout0,out);
103 tout1=tin[1]; l2c(tout1,out);
104 }
105#ifndef CBC_ENC_C__DONT_UPDATE_IV
106 iv = &(*ivec)[0];
107 l2c(tout0,iv);
108 l2c(tout1,iv);
109#endif
110 }
111 else
112 {
113 c2l(iv,xor0);
114 c2l(iv,xor1);
115 for (l-=8; l>=0; l-=8)
116 {
117 c2l(in,tin0); tin[0]=tin0;
118 c2l(in,tin1); tin[1]=tin1;
119 DES_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT);
120 tout0=tin[0]^xor0;
121 tout1=tin[1]^xor1;
122 l2c(tout0,out);
123 l2c(tout1,out);
124 xor0=tin0;
125 xor1=tin1;
126 }
127 if (l != -8)
128 {
129 c2l(in,tin0); tin[0]=tin0;
130 c2l(in,tin1); tin[1]=tin1;
131 DES_encrypt1((DES_LONG *)tin,_schedule,DES_DECRYPT);
132 tout0=tin[0]^xor0;
133 tout1=tin[1]^xor1;
134 l2cn(tout0,tout1,out,l+8);
135#ifndef CBC_ENC_C__DONT_UPDATE_IV
136 xor0=tin0;
137 xor1=tin1;
138#endif
139 }
140#ifndef CBC_ENC_C__DONT_UPDATE_IV
141 iv = &(*ivec)[0];
142 l2c(xor0,iv);
143 l2c(xor1,iv);
144#endif
145 }
146 tin0=tin1=tout0=tout1=xor0=xor1=0;
147 tin[0]=tin[1]=0;
148 }
diff --git a/src/lib/libcrypto/des/ofb64ede.c b/src/lib/libcrypto/des/ofb64ede.c
deleted file mode 100644
index 26bbf9a6a7..0000000000
--- a/src/lib/libcrypto/des/ofb64ede.c
+++ /dev/null
@@ -1,125 +0,0 @@
1/* crypto/des/ofb64ede.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60
61/* The input and output encrypted as though 64bit ofb mode is being
62 * used. The extra state information to record how much of the
63 * 64bit block we have used is contained in *num;
64 */
65void DES_ede3_ofb64_encrypt(register const unsigned char *in,
66 register unsigned char *out, long length,
67 DES_key_schedule *k1, DES_key_schedule *k2,
68 DES_key_schedule *k3, DES_cblock *ivec,
69 int *num)
70 {
71 register DES_LONG v0,v1;
72 register int n= *num;
73 register long l=length;
74 DES_cblock d;
75 register char *dp;
76 DES_LONG ti[2];
77 unsigned char *iv;
78 int save=0;
79
80 iv = &(*ivec)[0];
81 c2l(iv,v0);
82 c2l(iv,v1);
83 ti[0]=v0;
84 ti[1]=v1;
85 dp=(char *)d;
86 l2c(v0,dp);
87 l2c(v1,dp);
88 while (l--)
89 {
90 if (n == 0)
91 {
92 /* ti[0]=v0; */
93 /* ti[1]=v1; */
94 DES_encrypt3(ti,k1,k2,k3);
95 v0=ti[0];
96 v1=ti[1];
97
98 dp=(char *)d;
99 l2c(v0,dp);
100 l2c(v1,dp);
101 save++;
102 }
103 *(out++)= *(in++)^d[n];
104 n=(n+1)&0x07;
105 }
106 if (save)
107 {
108/* v0=ti[0];
109 v1=ti[1];*/
110 iv = &(*ivec)[0];
111 l2c(v0,iv);
112 l2c(v1,iv);
113 }
114 v0=v1=ti[0]=ti[1]=0;
115 *num=n;
116 }
117
118#ifdef undef /* MACRO */
119void DES_ede2_ofb64_encrypt(register unsigned char *in,
120 register unsigned char *out, long length, DES_key_schedule k1,
121 DES_key_schedule k2, DES_cblock (*ivec), int *num)
122 {
123 DES_ede3_ofb64_encrypt(in, out, length, k1,k2,k1, ivec, num);
124 }
125#endif
diff --git a/src/lib/libcrypto/des/ofb64enc.c b/src/lib/libcrypto/des/ofb64enc.c
deleted file mode 100644
index 8ca3d49dea..0000000000
--- a/src/lib/libcrypto/des/ofb64enc.c
+++ /dev/null
@@ -1,110 +0,0 @@
1/* crypto/des/ofb64enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60
61/* The input and output encrypted as though 64bit ofb mode is being
62 * used. The extra state information to record how much of the
63 * 64bit block we have used is contained in *num;
64 */
65void DES_ofb64_encrypt(register const unsigned char *in,
66 register unsigned char *out, long length,
67 DES_key_schedule *schedule, DES_cblock *ivec, int *num)
68 {
69 register DES_LONG v0,v1,t;
70 register int n= *num;
71 register long l=length;
72 DES_cblock d;
73 register unsigned char *dp;
74 DES_LONG ti[2];
75 unsigned char *iv;
76 int save=0;
77
78 iv = &(*ivec)[0];
79 c2l(iv,v0);
80 c2l(iv,v1);
81 ti[0]=v0;
82 ti[1]=v1;
83 dp=d;
84 l2c(v0,dp);
85 l2c(v1,dp);
86 while (l--)
87 {
88 if (n == 0)
89 {
90 DES_encrypt1(ti,schedule,DES_ENCRYPT);
91 dp=d;
92 t=ti[0]; l2c(t,dp);
93 t=ti[1]; l2c(t,dp);
94 save++;
95 }
96 *(out++)= *(in++)^d[n];
97 n=(n+1)&0x07;
98 }
99 if (save)
100 {
101 v0=ti[0];
102 v1=ti[1];
103 iv = &(*ivec)[0];
104 l2c(v0,iv);
105 l2c(v1,iv);
106 }
107 t=v0=v1=ti[0]=ti[1]=0;
108 *num=n;
109 }
110
diff --git a/src/lib/libcrypto/des/ofb_enc.c b/src/lib/libcrypto/des/ofb_enc.c
deleted file mode 100644
index e887a3c6f4..0000000000
--- a/src/lib/libcrypto/des/ofb_enc.c
+++ /dev/null
@@ -1,135 +0,0 @@
1/* crypto/des/ofb_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60
61/* The input and output are loaded in multiples of 8 bits.
62 * What this means is that if you hame numbits=12 and length=2
63 * the first 12 bits will be retrieved from the first byte and half
64 * the second. The second 12 bits will come from the 3rd and half the 4th
65 * byte.
66 */
67void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits,
68 long length, DES_key_schedule *schedule,
69 DES_cblock *ivec)
70 {
71 register DES_LONG d0,d1,vv0,vv1,v0,v1,n=(numbits+7)/8;
72 register DES_LONG mask0,mask1;
73 register long l=length;
74 register int num=numbits;
75 DES_LONG ti[2];
76 unsigned char *iv;
77
78 if (num > 64) return;
79 if (num > 32)
80 {
81 mask0=0xffffffffL;
82 if (num >= 64)
83 mask1=mask0;
84 else
85 mask1=(1L<<(num-32))-1;
86 }
87 else
88 {
89 if (num == 32)
90 mask0=0xffffffffL;
91 else
92 mask0=(1L<<num)-1;
93 mask1=0x00000000L;
94 }
95
96 iv = &(*ivec)[0];
97 c2l(iv,v0);
98 c2l(iv,v1);
99 ti[0]=v0;
100 ti[1]=v1;
101 while (l-- > 0)
102 {
103 ti[0]=v0;
104 ti[1]=v1;
105 DES_encrypt1((DES_LONG *)ti,schedule,DES_ENCRYPT);
106 vv0=ti[0];
107 vv1=ti[1];
108 c2ln(in,d0,d1,n);
109 in+=n;
110 d0=(d0^vv0)&mask0;
111 d1=(d1^vv1)&mask1;
112 l2cn(d0,d1,out,n);
113 out+=n;
114
115 if (num == 32)
116 { v0=v1; v1=vv0; }
117 else if (num == 64)
118 { v0=vv0; v1=vv1; }
119 else if (num > 32) /* && num != 64 */
120 {
121 v0=((v1>>(num-32))|(vv0<<(64-num)))&0xffffffffL;
122 v1=((vv0>>(num-32))|(vv1<<(64-num)))&0xffffffffL;
123 }
124 else /* num < 32 */
125 {
126 v0=((v0>>num)|(v1<<(32-num)))&0xffffffffL;
127 v1=((v1>>num)|(vv0<<(32-num)))&0xffffffffL;
128 }
129 }
130 iv = &(*ivec)[0];
131 l2c(v0,iv);
132 l2c(v1,iv);
133 v0=v1=d0=d1=ti[0]=ti[1]=vv0=vv1=0;
134 }
135
diff --git a/src/lib/libcrypto/des/options.txt b/src/lib/libcrypto/des/options.txt
deleted file mode 100644
index 6e2b50f765..0000000000
--- a/src/lib/libcrypto/des/options.txt
+++ /dev/null
@@ -1,39 +0,0 @@
1Note that the UNROLL option makes the 'inner' des loop unroll all 16 rounds
2instead of the default 4.
3RISC1 and RISC2 are 2 alternatives for the inner loop and
4PTR means to use pointers arithmatic instead of arrays.
5
6FreeBSD - Pentium Pro 200mhz - gcc 2.7.2.2 - assembler 577,000 4620k/s
7IRIX 6.2 - R10000 195mhz - cc (-O3 -n32) - UNROLL RISC2 PTR 496,000 3968k/s
8solaris 2.5.1 usparc 167mhz?? - SC4.0 - UNROLL RISC1 PTR [1] 459,400 3672k/s
9FreeBSD - Pentium Pro 200mhz - gcc 2.7.2.2 - UNROLL RISC1 433,000 3468k/s
10solaris 2.5.1 usparc 167mhz?? - gcc 2.7.2 - UNROLL 380,000 3041k/s
11linux - pentium 100mhz - gcc 2.7.0 - assembler 281,000 2250k/s
12NT 4.0 - pentium 100mhz - VC 4.2 - assembler 281,000 2250k/s
13AIX 4.1? - PPC604 100mhz - cc - UNROLL 275,000 2200k/s
14IRIX 5.3 - R4400 200mhz - gcc 2.6.3 - UNROLL RISC2 PTR 235,300 1882k/s
15IRIX 5.3 - R4400 200mhz - cc - UNROLL RISC2 PTR 233,700 1869k/s
16NT 4.0 - pentium 100mhz - VC 4.2 - UNROLL RISC1 PTR 191,000 1528k/s
17DEC Alpha 165mhz?? - cc - RISC2 PTR [2] 181,000 1448k/s
18linux - pentium 100mhz - gcc 2.7.0 - UNROLL RISC1 PTR 158,500 1268k/s
19HPUX 10 - 9000/887 - cc - UNROLL [3] 148,000 1190k/s
20solaris 2.5.1 - sparc 10 50mhz - gcc 2.7.2 - UNROLL 123,600 989k/s
21IRIX 5.3 - R4000 100mhz - cc - UNROLL RISC2 PTR 101,000 808k/s
22DGUX - 88100 50mhz(?) - gcc 2.6.3 - UNROLL 81,000 648k/s
23solaris 2.4 486 50mhz - gcc 2.6.3 - assembler 65,000 522k/s
24HPUX 10 - 9000/887 - k&r cc (default compiler) - UNROLL PTR 76,000 608k/s
25solaris 2.4 486 50mhz - gcc 2.6.3 - UNROLL RISC2 43,500 344k/s
26AIX - old slow one :-) - cc - 39,000 312k/s
27
28Notes.
29[1] For the ultra sparc, SunC 4.0
30 cc -xtarget=ultra -xarch=v8plus -Xa -xO5, running 'des_opts'
31 gives a speed of 344,000 des/s while 'speed' gives 459,000 des/s.
32 I'll record the higher since it is coming from the library but it
33 is all rather weird.
34[2] Similar to the ultra sparc ([1]), 181,000 for 'des_opts' vs 175,000.
35[3] I was unable to get access to this machine when it was not heavily loaded.
36 As such, my timing program was never able to get more that %30 of the CPU.
37 This would cause the program to give much lower speed numbers because
38 it would be 'fighting' to stay in the cache with the other CPU burning
39 processes.
diff --git a/src/lib/libcrypto/des/pcbc_enc.c b/src/lib/libcrypto/des/pcbc_enc.c
deleted file mode 100644
index 17a40f9520..0000000000
--- a/src/lib/libcrypto/des/pcbc_enc.c
+++ /dev/null
@@ -1,123 +0,0 @@
1/* crypto/des/pcbc_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60
61void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output,
62 long length, DES_key_schedule *schedule,
63 DES_cblock *ivec, int enc)
64 {
65 register DES_LONG sin0,sin1,xor0,xor1,tout0,tout1;
66 DES_LONG tin[2];
67 const unsigned char *in;
68 unsigned char *out,*iv;
69
70 in=input;
71 out=output;
72 iv = &(*ivec)[0];
73
74 if (enc)
75 {
76 c2l(iv,xor0);
77 c2l(iv,xor1);
78 for (; length>0; length-=8)
79 {
80 if (length >= 8)
81 {
82 c2l(in,sin0);
83 c2l(in,sin1);
84 }
85 else
86 c2ln(in,sin0,sin1,length);
87 tin[0]=sin0^xor0;
88 tin[1]=sin1^xor1;
89 DES_encrypt1((DES_LONG *)tin,schedule,DES_ENCRYPT);
90 tout0=tin[0];
91 tout1=tin[1];
92 xor0=sin0^tout0;
93 xor1=sin1^tout1;
94 l2c(tout0,out);
95 l2c(tout1,out);
96 }
97 }
98 else
99 {
100 c2l(iv,xor0); c2l(iv,xor1);
101 for (; length>0; length-=8)
102 {
103 c2l(in,sin0);
104 c2l(in,sin1);
105 tin[0]=sin0;
106 tin[1]=sin1;
107 DES_encrypt1((DES_LONG *)tin,schedule,DES_DECRYPT);
108 tout0=tin[0]^xor0;
109 tout1=tin[1]^xor1;
110 if (length >= 8)
111 {
112 l2c(tout0,out);
113 l2c(tout1,out);
114 }
115 else
116 l2cn(tout0,tout1,out,length);
117 xor0=tout0^sin0;
118 xor1=tout1^sin1;
119 }
120 }
121 tin[0]=tin[1]=0;
122 sin0=sin1=xor0=xor1=tout0=tout1=0;
123 }
diff --git a/src/lib/libcrypto/des/qud_cksm.c b/src/lib/libcrypto/des/qud_cksm.c
deleted file mode 100644
index dac201227e..0000000000
--- a/src/lib/libcrypto/des/qud_cksm.c
+++ /dev/null
@@ -1,139 +0,0 @@
1/* crypto/des/qud_cksm.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* From "Message Authentication" R.R. Jueneman, S.M. Matyas, C.H. Meyer
60 * IEEE Communications Magazine Sept 1985 Vol. 23 No. 9 p 29-40
61 * This module in only based on the code in this paper and is
62 * almost definitely not the same as the MIT implementation.
63 */
64#include "des_locl.h"
65
66/* bug fix for dos - 7/6/91 - Larry hughes@logos.ucs.indiana.edu */
67#define Q_B0(a) (((DES_LONG)(a)))
68#define Q_B1(a) (((DES_LONG)(a))<<8)
69#define Q_B2(a) (((DES_LONG)(a))<<16)
70#define Q_B3(a) (((DES_LONG)(a))<<24)
71
72/* used to scramble things a bit */
73/* Got the value MIT uses via brute force :-) 2/10/90 eay */
74#define NOISE ((DES_LONG)83653421L)
75
76DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[],
77 long length, int out_count, DES_cblock *seed)
78 {
79 DES_LONG z0,z1,t0,t1;
80 int i;
81 long l;
82 const unsigned char *cp;
83#ifdef _CRAY
84 struct lp_st { int a:32; int b:32; } *lp;
85#else
86 DES_LONG *lp;
87#endif
88
89 if (out_count < 1) out_count=1;
90#ifdef _CRAY
91 lp = (struct lp_st *) &(output[0])[0];
92#else
93 lp = (DES_LONG *) &(output[0])[0];
94#endif
95
96 z0=Q_B0((*seed)[0])|Q_B1((*seed)[1])|Q_B2((*seed)[2])|Q_B3((*seed)[3]);
97 z1=Q_B0((*seed)[4])|Q_B1((*seed)[5])|Q_B2((*seed)[6])|Q_B3((*seed)[7]);
98
99 for (i=0; ((i<4)&&(i<out_count)); i++)
100 {
101 cp=input;
102 l=length;
103 while (l > 0)
104 {
105 if (l > 1)
106 {
107 t0= (DES_LONG)(*(cp++));
108 t0|=(DES_LONG)Q_B1(*(cp++));
109 l--;
110 }
111 else
112 t0= (DES_LONG)(*(cp++));
113 l--;
114 /* add */
115 t0+=z0;
116 t0&=0xffffffffL;
117 t1=z1;
118 /* square, well sort of square */
119 z0=((((t0*t0)&0xffffffffL)+((t1*t1)&0xffffffffL))
120 &0xffffffffL)%0x7fffffffL;
121 z1=((t0*((t1+NOISE)&0xffffffffL))&0xffffffffL)%0x7fffffffL;
122 }
123 if (lp != NULL)
124 {
125 /* The MIT library assumes that the checksum is
126 * composed of 2*out_count 32 bit ints */
127#ifdef _CRAY
128 (*lp).a = z0;
129 (*lp).b = z1;
130 lp++;
131#else
132 *lp++ = z0;
133 *lp++ = z1;
134#endif
135 }
136 }
137 return(z0);
138 }
139
diff --git a/src/lib/libcrypto/des/rand_key.c b/src/lib/libcrypto/des/rand_key.c
deleted file mode 100644
index 2398165568..0000000000
--- a/src/lib/libcrypto/des/rand_key.c
+++ /dev/null
@@ -1,68 +0,0 @@
1/* crypto/des/rand_key.c */
2/* ====================================================================
3 * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55
56#include <openssl/des.h>
57#include <openssl/rand.h>
58
59int DES_random_key(DES_cblock *ret)
60 {
61 do
62 {
63 if (RAND_bytes((unsigned char *)ret, sizeof(DES_cblock)) != 1)
64 return (0);
65 } while (DES_is_weak_key(ret));
66 DES_set_odd_parity(ret);
67 return (1);
68 }
diff --git a/src/lib/libcrypto/des/read2pwd.c b/src/lib/libcrypto/des/read2pwd.c
deleted file mode 100644
index ee6969f76e..0000000000
--- a/src/lib/libcrypto/des/read2pwd.c
+++ /dev/null
@@ -1,140 +0,0 @@
1/* crypto/des/read2pwd.c */
2/* ====================================================================
3 * Copyright (c) 2001-2002 The OpenSSL Project. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 *
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
21 *
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * openssl-core@openssl.org.
26 *
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
30 *
31 * 6. Redistributions of any form whatsoever must retain the following
32 * acknowledgment:
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
35 *
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
53 *
54 */
55/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
56 * All rights reserved.
57 *
58 * This package is an SSL implementation written
59 * by Eric Young (eay@cryptsoft.com).
60 * The implementation was written so as to conform with Netscapes SSL.
61 *
62 * This library is free for commercial and non-commercial use as long as
63 * the following conditions are aheared to. The following conditions
64 * apply to all code found in this distribution, be it the RC4, RSA,
65 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
66 * included with this distribution is covered by the same copyright terms
67 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
68 *
69 * Copyright remains Eric Young's, and as such any Copyright notices in
70 * the code are not to be removed.
71 * If this package is used in a product, Eric Young should be given attribution
72 * as the author of the parts of the library used.
73 * This can be in the form of a textual message at program startup or
74 * in documentation (online or textual) provided with the package.
75 *
76 * Redistribution and use in source and binary forms, with or without
77 * modification, are permitted provided that the following conditions
78 * are met:
79 * 1. Redistributions of source code must retain the copyright
80 * notice, this list of conditions and the following disclaimer.
81 * 2. Redistributions in binary form must reproduce the above copyright
82 * notice, this list of conditions and the following disclaimer in the
83 * documentation and/or other materials provided with the distribution.
84 * 3. All advertising materials mentioning features or use of this software
85 * must display the following acknowledgement:
86 * "This product includes cryptographic software written by
87 * Eric Young (eay@cryptsoft.com)"
88 * The word 'cryptographic' can be left out if the rouines from the library
89 * being used are not cryptographic related :-).
90 * 4. If you include any Windows specific code (or a derivative thereof) from
91 * the apps directory (application code) you must include an acknowledgement:
92 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
93 *
94 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
95 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
96 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
97 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
98 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
99 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
100 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
101 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
102 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
103 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
104 * SUCH DAMAGE.
105 *
106 * The licence and distribution terms for any publically available version or
107 * derivative of this code cannot be changed. i.e. this code cannot simply be
108 * copied and put under another distribution licence
109 * [including the GNU Public Licence.]
110 */
111
112#include <string.h>
113#include <openssl/des.h>
114#include <openssl/ui.h>
115#include <openssl/crypto.h>
116
117int DES_read_password(DES_cblock *key, const char *prompt, int verify)
118 {
119 int ok;
120 char buf[BUFSIZ],buff[BUFSIZ];
121
122 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
123 DES_string_to_key(buf,key);
124 OPENSSL_cleanse(buf,BUFSIZ);
125 OPENSSL_cleanse(buff,BUFSIZ);
126 return(ok);
127 }
128
129int DES_read_2passwords(DES_cblock *key1, DES_cblock *key2, const char *prompt,
130 int verify)
131 {
132 int ok;
133 char buf[BUFSIZ],buff[BUFSIZ];
134
135 if ((ok=UI_UTIL_read_pw(buf,buff,BUFSIZ,prompt,verify)) == 0)
136 DES_string_to_2keys(buf,key1,key2);
137 OPENSSL_cleanse(buf,BUFSIZ);
138 OPENSSL_cleanse(buff,BUFSIZ);
139 return(ok);
140 }
diff --git a/src/lib/libcrypto/des/read_pwd.c b/src/lib/libcrypto/des/read_pwd.c
deleted file mode 100644
index ce5fa00a37..0000000000
--- a/src/lib/libcrypto/des/read_pwd.c
+++ /dev/null
@@ -1,521 +0,0 @@
1/* crypto/des/read_pwd.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <openssl/e_os2.h>
60#if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WIN32)
61#ifdef OPENSSL_UNISTD
62# include OPENSSL_UNISTD
63#else
64# include <unistd.h>
65#endif
66/* If unistd.h defines _POSIX_VERSION, we conclude that we
67 * are on a POSIX system and have sigaction and termios. */
68#if defined(_POSIX_VERSION)
69
70# define SIGACTION
71# if !defined(TERMIOS) && !defined(TERMIO) && !defined(SGTTY)
72# define TERMIOS
73# endif
74
75#endif
76#endif
77
78/* #define SIGACTION */ /* Define this if you have sigaction() */
79
80#ifdef WIN16TTY
81#undef OPENSSL_SYS_WIN16
82#undef _WINDOWS
83#include <graph.h>
84#endif
85
86/* 06-Apr-92 Luke Brennan Support for VMS */
87#include "des_locl.h"
88#include "cryptlib.h"
89#include <signal.h>
90#include <stdio.h>
91#include <string.h>
92#include <setjmp.h>
93#include <errno.h>
94
95#ifdef OPENSSL_SYS_VMS /* prototypes for sys$whatever */
96#include <starlet.h>
97#ifdef __DECC
98#pragma message disable DOLLARID
99#endif
100#endif
101
102#ifdef WIN_CONSOLE_BUG
103#include <windows.h>
104#ifndef OPENSSL_SYS_WINCE
105#include <wincon.h>
106#endif
107#endif
108
109
110/* There are 5 types of terminal interface supported,
111 * TERMIO, TERMIOS, VMS, MSDOS and SGTTY
112 */
113
114#if defined(__sgi) && !defined(TERMIOS)
115#define TERMIOS
116#undef TERMIO
117#undef SGTTY
118#endif
119
120#if defined(linux) && !defined(TERMIO)
121#undef TERMIOS
122#define TERMIO
123#undef SGTTY
124#endif
125
126#ifdef _LIBC
127#undef TERMIOS
128#define TERMIO
129#undef SGTTY
130#endif
131
132#if !defined(TERMIO) && !defined(TERMIOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_MSDOS) && !defined(MAC_OS_pre_X) && !defined(MAC_OS_GUSI_SOURCE)
133#undef TERMIOS
134#undef TERMIO
135#define SGTTY
136#endif
137
138#if defined(OPENSSL_SYS_VXWORKS)
139#undef TERMIOS
140#undef TERMIO
141#undef SGTTY
142#endif
143
144#ifdef TERMIOS
145#include <termios.h>
146#define TTY_STRUCT struct termios
147#define TTY_FLAGS c_lflag
148#define TTY_get(tty,data) tcgetattr(tty,data)
149#define TTY_set(tty,data) tcsetattr(tty,TCSANOW,data)
150#endif
151
152#ifdef TERMIO
153#include <termio.h>
154#define TTY_STRUCT struct termio
155#define TTY_FLAGS c_lflag
156#define TTY_get(tty,data) ioctl(tty,TCGETA,data)
157#define TTY_set(tty,data) ioctl(tty,TCSETA,data)
158#endif
159
160#ifdef SGTTY
161#include <sgtty.h>
162#define TTY_STRUCT struct sgttyb
163#define TTY_FLAGS sg_flags
164#define TTY_get(tty,data) ioctl(tty,TIOCGETP,data)
165#define TTY_set(tty,data) ioctl(tty,TIOCSETP,data)
166#endif
167
168#if !defined(_LIBC) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(MAC_OS_pre_X)
169#include <sys/ioctl.h>
170#endif
171
172#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__) && !defined(OPENSSL_SYS_WINCE)
173#include <conio.h>
174#define fgets(a,b,c) noecho_fgets(a,b,c)
175#endif
176
177#ifdef OPENSSL_SYS_VMS
178#include <ssdef.h>
179#include <iodef.h>
180#include <ttdef.h>
181#include <descrip.h>
182struct IOSB {
183 short iosb$w_value;
184 short iosb$w_count;
185 long iosb$l_info;
186 };
187#endif
188
189#if defined(MAC_OS_pre_X) || defined(MAC_OS_GUSI_SOURCE)
190/*
191 * This one needs work. As a matter of fact the code is unoperational
192 * and this is only a trick to get it compiled.
193 * <appro@fy.chalmers.se>
194 */
195#define TTY_STRUCT int
196#endif
197
198#ifndef NX509_SIG
199#define NX509_SIG 32
200#endif
201
202static void read_till_nl(FILE *);
203static void recsig(int);
204static void pushsig(void);
205static void popsig(void);
206#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
207static int noecho_fgets(char *buf, int size, FILE *tty);
208#endif
209#ifdef SIGACTION
210 static struct sigaction savsig[NX509_SIG];
211#else
212 static void (*savsig[NX509_SIG])(int );
213#endif
214static jmp_buf save;
215
216int des_read_pw_string(char *buf, int length, const char *prompt,
217 int verify)
218 {
219 char buff[BUFSIZ];
220 int ret;
221
222 ret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
223 OPENSSL_cleanse(buff,BUFSIZ);
224 return(ret);
225 }
226
227#ifdef OPENSSL_SYS_WINCE
228
229int des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify)
230 {
231 memset(buf,0,size);
232 memset(buff,0,size);
233 return(0);
234 }
235
236#elif defined(OPENSSL_SYS_WIN16)
237
238int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
239 {
240 memset(buf,0,size);
241 memset(buff,0,size);
242 return(0);
243 }
244
245#else /* !OPENSSL_SYS_WINCE && !OPENSSL_SYS_WIN16 */
246
247static void read_till_nl(FILE *in)
248 {
249#define SIZE 4
250 char buf[SIZE+1];
251
252 do {
253 fgets(buf,SIZE,in);
254 } while (strchr(buf,'\n') == NULL);
255 }
256
257
258/* return 0 if ok, 1 (or -1) otherwise */
259int des_read_pw(char *buf, char *buff, int size, const char *prompt,
260 int verify)
261 {
262#ifdef OPENSSL_SYS_VMS
263 struct IOSB iosb;
264 $DESCRIPTOR(terminal,"TT");
265 long tty_orig[3], tty_new[3];
266 long status;
267 unsigned short channel = 0;
268#else
269#if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__)
270 TTY_STRUCT tty_orig,tty_new;
271#endif
272#endif
273 int number;
274 int ok;
275 /* statics are simply to avoid warnings about longjmp clobbering
276 things */
277 static int ps;
278 int is_a_tty;
279 static FILE *tty;
280 char *p;
281
282 if (setjmp(save))
283 {
284 ok=0;
285 goto error;
286 }
287
288 number=5;
289 ok=0;
290 ps=0;
291 is_a_tty=1;
292 tty=NULL;
293
294#ifdef OPENSSL_SYS_MSDOS
295 if ((tty=fopen("con","r")) == NULL)
296 tty=stdin;
297#elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VXWORKS)
298 tty=stdin;
299#else
300#ifndef OPENSSL_SYS_MPE
301 if ((tty=fopen("/dev/tty","r")) == NULL)
302#endif
303 tty=stdin;
304#endif
305
306#if defined(TTY_get) && !defined(OPENSSL_SYS_VMS)
307 if (TTY_get(fileno(tty),&tty_orig) == -1)
308 {
309#ifdef ENOTTY
310 if (errno == ENOTTY)
311 is_a_tty=0;
312 else
313#endif
314#ifdef EINVAL
315 /* Ariel Glenn ariel@columbia.edu reports that solaris
316 * can return EINVAL instead. This should be ok */
317 if (errno == EINVAL)
318 is_a_tty=0;
319 else
320#endif
321 return(-1);
322 }
323 memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));
324#endif
325#ifdef OPENSSL_SYS_VMS
326 status = sys$assign(&terminal,&channel,0,0);
327 if (status != SS$_NORMAL)
328 return(-1);
329 status=sys$qiow(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);
330 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
331 return(-1);
332#endif
333
334 pushsig();
335 ps=1;
336
337#ifdef TTY_FLAGS
338 tty_new.TTY_FLAGS &= ~ECHO;
339#endif
340
341#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
342 if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1))
343#ifdef OPENSSL_SYS_MPE
344 ; /* MPE lies -- echo really has been disabled */
345#else
346 return(-1);
347#endif
348#endif
349#ifdef OPENSSL_SYS_VMS
350 tty_new[0] = tty_orig[0];
351 tty_new[1] = tty_orig[1] | TT$M_NOECHO;
352 tty_new[2] = tty_orig[2];
353 status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);
354 if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
355 return(-1);
356#endif
357 ps=2;
358
359 while ((!ok) && (number--))
360 {
361 fputs(prompt,stderr);
362 fflush(stderr);
363
364 buf[0]='\0';
365 fgets(buf,size,tty);
366 if (feof(tty)) goto error;
367 if (ferror(tty)) goto error;
368 if ((p=(char *)strchr(buf,'\n')) != NULL)
369 *p='\0';
370 else read_till_nl(tty);
371 if (verify)
372 {
373 fprintf(stderr,"\nVerifying password - %s",prompt);
374 fflush(stderr);
375 buff[0]='\0';
376 fgets(buff,size,tty);
377 if (feof(tty)) goto error;
378 if ((p=(char *)strchr(buff,'\n')) != NULL)
379 *p='\0';
380 else read_till_nl(tty);
381
382 if (strcmp(buf,buff) != 0)
383 {
384 fprintf(stderr,"\nVerify failure");
385 fflush(stderr);
386 break;
387 /* continue; */
388 }
389 }
390 ok=1;
391 }
392
393error:
394 fprintf(stderr,"\n");
395#if 0
396 perror("fgets(tty)");
397#endif
398 /* What can we do if there is an error? */
399#if defined(TTY_set) && !defined(OPENSSL_SYS_VMS)
400 if (ps >= 2) TTY_set(fileno(tty),&tty_orig);
401#endif
402#ifdef OPENSSL_SYS_VMS
403 if (ps >= 2)
404 status = sys$qiow(0,channel,IO$_SETMODE,&iosb,0,0
405 ,tty_orig,12,0,0,0,0);
406#endif
407
408 if (ps >= 1) popsig();
409 if (stdin != tty) fclose(tty);
410#ifdef OPENSSL_SYS_VMS
411 status = sys$dassgn(channel);
412#endif
413 return(!ok);
414 }
415
416static void pushsig(void)
417 {
418 int i;
419#ifdef SIGACTION
420 struct sigaction sa;
421
422 memset(&sa,0,sizeof sa);
423 sa.sa_handler=recsig;
424#endif
425
426 for (i=1; i<NX509_SIG; i++)
427 {
428#ifdef SIGUSR1
429 if (i == SIGUSR1)
430 continue;
431#endif
432#ifdef SIGUSR2
433 if (i == SIGUSR2)
434 continue;
435#endif
436#ifdef SIGACTION
437 sigaction(i,&sa,&savsig[i]);
438#else
439 savsig[i]=signal(i,recsig);
440#endif
441 }
442
443#ifdef SIGWINCH
444 signal(SIGWINCH,SIG_DFL);
445#endif
446 }
447
448static void popsig(void)
449 {
450 int i;
451
452 for (i=1; i<NX509_SIG; i++)
453 {
454#ifdef SIGUSR1
455 if (i == SIGUSR1)
456 continue;
457#endif
458#ifdef SIGUSR2
459 if (i == SIGUSR2)
460 continue;
461#endif
462#ifdef SIGACTION
463 sigaction(i,&savsig[i],NULL);
464#else
465 signal(i,savsig[i]);
466#endif
467 }
468 }
469
470static void recsig(int i)
471 {
472 longjmp(save,1);
473#ifdef LINT
474 i=i;
475#endif
476 }
477
478#ifdef OPENSSL_SYS_MSDOS
479static int noecho_fgets(char *buf, int size, FILE *tty)
480 {
481 int i;
482 char *p;
483
484 p=buf;
485 for (;;)
486 {
487 if (size == 0)
488 {
489 *p='\0';
490 break;
491 }
492 size--;
493#ifdef WIN16TTY
494 i=_inchar();
495#else
496 i=getch();
497#endif
498 if (i == '\r') i='\n';
499 *(p++)=i;
500 if (i == '\n')
501 {
502 *p='\0';
503 break;
504 }
505 }
506#ifdef WIN_CONSOLE_BUG
507/* Win95 has several evil console bugs: one of these is that the
508 * last character read using getch() is passed to the next read: this is
509 * usually a CR so this can be trouble. No STDIO fix seems to work but
510 * flushing the console appears to do the trick.
511 */
512 {
513 HANDLE inh;
514 inh = GetStdHandle(STD_INPUT_HANDLE);
515 FlushConsoleInputBuffer(inh);
516 }
517#endif
518 return(strlen(buf));
519 }
520#endif
521#endif /* !OPENSSL_SYS_WINCE && !WIN16 */
diff --git a/src/lib/libcrypto/des/rpc_des.h b/src/lib/libcrypto/des/rpc_des.h
deleted file mode 100644
index 8263c512ab..0000000000
--- a/src/lib/libcrypto/des/rpc_des.h
+++ /dev/null
@@ -1,133 +0,0 @@
1/* crypto/des/rpc_des.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* @(#)des.h 2.2 88/08/10 4.0 RPCSRC; from 2.7 88/02/08 SMI */
60/*
61 * Copyright (c) 2010, Oracle America, Inc.
62 *
63 * Redistribution and use in source and binary forms, with or without
64 * modification, are permitted provided that the following conditions are
65 * met:
66 *
67 * * Redistributions of source code must retain the above copyright
68 * notice, this list of conditions and the following disclaimer.
69 * * Redistributions in binary form must reproduce the above
70 * copyright notice, this list of conditions and the following
71 * disclaimer in the documentation and/or other materials
72 * provided with the distribution.
73 * * Neither the name of the "Oracle America, Inc." nor the names of its
74 * contributors may be used to endorse or promote products derived
75 * from this software without specific prior written permission.
76 *
77 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
78 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
79 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
80 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
81 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
82 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
83 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
84 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
85 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
86 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
87 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
88 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
89 */
90
91/*
92 * Generic DES driver interface
93 * Keep this file hardware independent!
94 */
95
96#define DES_MAXLEN 65536 /* maximum # of bytes to encrypt */
97#define DES_QUICKLEN 16 /* maximum # of bytes to encrypt quickly */
98
99#ifdef HEADER_DES_H
100#undef ENCRYPT
101#undef DECRYPT
102#endif
103
104enum desdir { ENCRYPT, DECRYPT };
105enum desmode { CBC, ECB };
106
107/*
108 * parameters to ioctl call
109 */
110struct desparams {
111 unsigned char des_key[8]; /* key (with low bit parity) */
112 enum desdir des_dir; /* direction */
113 enum desmode des_mode; /* mode */
114 unsigned char des_ivec[8]; /* input vector */
115 unsigned des_len; /* number of bytes to crypt */
116 union {
117 unsigned char UDES_data[DES_QUICKLEN];
118 unsigned char *UDES_buf;
119 } UDES;
120# define des_data UDES.UDES_data /* direct data here if quick */
121# define des_buf UDES.UDES_buf /* otherwise, pointer to data */
122};
123
124/*
125 * Encrypt an arbitrary sized buffer
126 */
127#define DESIOCBLOCK _IOWR('d', 6, struct desparams)
128
129/*
130 * Encrypt of small amount of data, quickly
131 */
132#define DESIOCQUICK _IOWR('d', 7, struct desparams)
133
diff --git a/src/lib/libcrypto/des/rpc_enc.c b/src/lib/libcrypto/des/rpc_enc.c
deleted file mode 100644
index d937d08da5..0000000000
--- a/src/lib/libcrypto/des/rpc_enc.c
+++ /dev/null
@@ -1,98 +0,0 @@
1/* crypto/des/rpc_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "rpc_des.h"
60#include "des_locl.h"
61#include "des_ver.h"
62
63int _des_crypt(char *buf,int len,struct desparams *desp);
64int _des_crypt(char *buf, int len, struct desparams *desp)
65 {
66 DES_key_schedule ks;
67 int enc;
68
69 DES_set_key_unchecked(&desp->des_key,&ks);
70 enc=(desp->des_dir == ENCRYPT)?DES_ENCRYPT:DES_DECRYPT;
71
72 if (desp->des_mode == CBC)
73 DES_ecb_encrypt((const_DES_cblock *)desp->UDES.UDES_buf,
74 (DES_cblock *)desp->UDES.UDES_buf,&ks,
75 enc);
76 else
77 {
78 DES_ncbc_encrypt(desp->UDES.UDES_buf,desp->UDES.UDES_buf,
79 len,&ks,&desp->des_ivec,enc);
80#ifdef undef
81 /* len will always be %8 if called from common_crypt
82 * in secure_rpc.
83 * Libdes's cbc encrypt does not copy back the iv,
84 * so we have to do it here. */
85 /* It does now :-) eay 20/09/95 */
86
87 a=(char *)&(desp->UDES.UDES_buf[len-8]);
88 b=(char *)&(desp->des_ivec[0]);
89
90 *(a++)= *(b++); *(a++)= *(b++);
91 *(a++)= *(b++); *(a++)= *(b++);
92 *(a++)= *(b++); *(a++)= *(b++);
93 *(a++)= *(b++); *(a++)= *(b++);
94#endif
95 }
96 return(1);
97 }
98
diff --git a/src/lib/libcrypto/des/rpw.c b/src/lib/libcrypto/des/rpw.c
deleted file mode 100644
index 8a9473c4f9..0000000000
--- a/src/lib/libcrypto/des/rpw.c
+++ /dev/null
@@ -1,99 +0,0 @@
1/* crypto/des/rpw.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <openssl/des.h>
61
62int main(int argc, char *argv[])
63 {
64 DES_cblock k,k1;
65 int i;
66
67 printf("read passwd\n");
68 if ((i=des_read_password(&k,"Enter password:",0)) == 0)
69 {
70 printf("password = ");
71 for (i=0; i<8; i++)
72 printf("%02x ",k[i]);
73 }
74 else
75 printf("error %d\n",i);
76 printf("\n");
77 printf("read 2passwds and verify\n");
78 if ((i=des_read_2passwords(&k,&k1,
79 "Enter verified password:",1)) == 0)
80 {
81 printf("password1 = ");
82 for (i=0; i<8; i++)
83 printf("%02x ",k[i]);
84 printf("\n");
85 printf("password2 = ");
86 for (i=0; i<8; i++)
87 printf("%02x ",k1[i]);
88 printf("\n");
89 exit(1);
90 }
91 else
92 {
93 printf("error %d\n",i);
94 exit(0);
95 }
96#ifdef LINT
97 return(0);
98#endif
99 }
diff --git a/src/lib/libcrypto/des/set_key.c b/src/lib/libcrypto/des/set_key.c
deleted file mode 100644
index 3004cc3ab3..0000000000
--- a/src/lib/libcrypto/des/set_key.c
+++ /dev/null
@@ -1,407 +0,0 @@
1/* crypto/des/set_key.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* set_key.c v 1.4 eay 24/9/91
60 * 1.4 Speed up by 400% :-)
61 * 1.3 added register declarations.
62 * 1.2 unrolled make_key_sched a bit more
63 * 1.1 added norm_expand_bits
64 * 1.0 First working version
65 */
66#include "des_locl.h"
67
68OPENSSL_IMPLEMENT_GLOBAL(int,DES_check_key,0) /* defaults to false */
69
70static const unsigned char odd_parity[256]={
71 1, 1, 2, 2, 4, 4, 7, 7, 8, 8, 11, 11, 13, 13, 14, 14,
72 16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31,
73 32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47,
74 49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62,
75 64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79,
76 81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94,
77 97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110,
78112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127,
79128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143,
80145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158,
81161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174,
82176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191,
83193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206,
84208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223,
85224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239,
86241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254};
87
88void DES_set_odd_parity(DES_cblock *key)
89 {
90 unsigned int i;
91
92 for (i=0; i<DES_KEY_SZ; i++)
93 (*key)[i]=odd_parity[(*key)[i]];
94 }
95
96int DES_check_key_parity(const_DES_cblock *key)
97 {
98 unsigned int i;
99
100 for (i=0; i<DES_KEY_SZ; i++)
101 {
102 if ((*key)[i] != odd_parity[(*key)[i]])
103 return(0);
104 }
105 return(1);
106 }
107
108/* Weak and semi week keys as take from
109 * %A D.W. Davies
110 * %A W.L. Price
111 * %T Security for Computer Networks
112 * %I John Wiley & Sons
113 * %D 1984
114 * Many thanks to smb@ulysses.att.com (Steven Bellovin) for the reference
115 * (and actual cblock values).
116 */
117#define NUM_WEAK_KEY 16
118static const DES_cblock weak_keys[NUM_WEAK_KEY]={
119 /* weak keys */
120 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
121 {0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE},
122 {0x1F,0x1F,0x1F,0x1F,0x0E,0x0E,0x0E,0x0E},
123 {0xE0,0xE0,0xE0,0xE0,0xF1,0xF1,0xF1,0xF1},
124 /* semi-weak keys */
125 {0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE},
126 {0xFE,0x01,0xFE,0x01,0xFE,0x01,0xFE,0x01},
127 {0x1F,0xE0,0x1F,0xE0,0x0E,0xF1,0x0E,0xF1},
128 {0xE0,0x1F,0xE0,0x1F,0xF1,0x0E,0xF1,0x0E},
129 {0x01,0xE0,0x01,0xE0,0x01,0xF1,0x01,0xF1},
130 {0xE0,0x01,0xE0,0x01,0xF1,0x01,0xF1,0x01},
131 {0x1F,0xFE,0x1F,0xFE,0x0E,0xFE,0x0E,0xFE},
132 {0xFE,0x1F,0xFE,0x1F,0xFE,0x0E,0xFE,0x0E},
133 {0x01,0x1F,0x01,0x1F,0x01,0x0E,0x01,0x0E},
134 {0x1F,0x01,0x1F,0x01,0x0E,0x01,0x0E,0x01},
135 {0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE},
136 {0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}};
137
138int DES_is_weak_key(const_DES_cblock *key)
139 {
140 int i;
141
142 for (i=0; i<NUM_WEAK_KEY; i++)
143 /* Added == 0 to comparison, I obviously don't run
144 * this section very often :-(, thanks to
145 * engineering@MorningStar.Com for the fix
146 * eay 93/06/29
147 * Another problem, I was comparing only the first 4
148 * bytes, 97/03/18 */
149 if (memcmp(weak_keys[i],key,sizeof(DES_cblock)) == 0) return(1);
150 return(0);
151 }
152
153/* NOW DEFINED IN des_local.h
154 * See ecb_encrypt.c for a pseudo description of these macros.
155 * #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
156 * (b)^=(t),\
157 * (a)=((a)^((t)<<(n))))
158 */
159
160#define HPERM_OP(a,t,n,m) ((t)=((((a)<<(16-(n)))^(a))&(m)),\
161 (a)=(a)^(t)^(t>>(16-(n))))
162
163static const DES_LONG des_skb[8][64]={
164 {
165 /* for C bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
166 0x00000000L,0x00000010L,0x20000000L,0x20000010L,
167 0x00010000L,0x00010010L,0x20010000L,0x20010010L,
168 0x00000800L,0x00000810L,0x20000800L,0x20000810L,
169 0x00010800L,0x00010810L,0x20010800L,0x20010810L,
170 0x00000020L,0x00000030L,0x20000020L,0x20000030L,
171 0x00010020L,0x00010030L,0x20010020L,0x20010030L,
172 0x00000820L,0x00000830L,0x20000820L,0x20000830L,
173 0x00010820L,0x00010830L,0x20010820L,0x20010830L,
174 0x00080000L,0x00080010L,0x20080000L,0x20080010L,
175 0x00090000L,0x00090010L,0x20090000L,0x20090010L,
176 0x00080800L,0x00080810L,0x20080800L,0x20080810L,
177 0x00090800L,0x00090810L,0x20090800L,0x20090810L,
178 0x00080020L,0x00080030L,0x20080020L,0x20080030L,
179 0x00090020L,0x00090030L,0x20090020L,0x20090030L,
180 0x00080820L,0x00080830L,0x20080820L,0x20080830L,
181 0x00090820L,0x00090830L,0x20090820L,0x20090830L,
182 },{
183 /* for C bits (numbered as per FIPS 46) 7 8 10 11 12 13 */
184 0x00000000L,0x02000000L,0x00002000L,0x02002000L,
185 0x00200000L,0x02200000L,0x00202000L,0x02202000L,
186 0x00000004L,0x02000004L,0x00002004L,0x02002004L,
187 0x00200004L,0x02200004L,0x00202004L,0x02202004L,
188 0x00000400L,0x02000400L,0x00002400L,0x02002400L,
189 0x00200400L,0x02200400L,0x00202400L,0x02202400L,
190 0x00000404L,0x02000404L,0x00002404L,0x02002404L,
191 0x00200404L,0x02200404L,0x00202404L,0x02202404L,
192 0x10000000L,0x12000000L,0x10002000L,0x12002000L,
193 0x10200000L,0x12200000L,0x10202000L,0x12202000L,
194 0x10000004L,0x12000004L,0x10002004L,0x12002004L,
195 0x10200004L,0x12200004L,0x10202004L,0x12202004L,
196 0x10000400L,0x12000400L,0x10002400L,0x12002400L,
197 0x10200400L,0x12200400L,0x10202400L,0x12202400L,
198 0x10000404L,0x12000404L,0x10002404L,0x12002404L,
199 0x10200404L,0x12200404L,0x10202404L,0x12202404L,
200 },{
201 /* for C bits (numbered as per FIPS 46) 14 15 16 17 19 20 */
202 0x00000000L,0x00000001L,0x00040000L,0x00040001L,
203 0x01000000L,0x01000001L,0x01040000L,0x01040001L,
204 0x00000002L,0x00000003L,0x00040002L,0x00040003L,
205 0x01000002L,0x01000003L,0x01040002L,0x01040003L,
206 0x00000200L,0x00000201L,0x00040200L,0x00040201L,
207 0x01000200L,0x01000201L,0x01040200L,0x01040201L,
208 0x00000202L,0x00000203L,0x00040202L,0x00040203L,
209 0x01000202L,0x01000203L,0x01040202L,0x01040203L,
210 0x08000000L,0x08000001L,0x08040000L,0x08040001L,
211 0x09000000L,0x09000001L,0x09040000L,0x09040001L,
212 0x08000002L,0x08000003L,0x08040002L,0x08040003L,
213 0x09000002L,0x09000003L,0x09040002L,0x09040003L,
214 0x08000200L,0x08000201L,0x08040200L,0x08040201L,
215 0x09000200L,0x09000201L,0x09040200L,0x09040201L,
216 0x08000202L,0x08000203L,0x08040202L,0x08040203L,
217 0x09000202L,0x09000203L,0x09040202L,0x09040203L,
218 },{
219 /* for C bits (numbered as per FIPS 46) 21 23 24 26 27 28 */
220 0x00000000L,0x00100000L,0x00000100L,0x00100100L,
221 0x00000008L,0x00100008L,0x00000108L,0x00100108L,
222 0x00001000L,0x00101000L,0x00001100L,0x00101100L,
223 0x00001008L,0x00101008L,0x00001108L,0x00101108L,
224 0x04000000L,0x04100000L,0x04000100L,0x04100100L,
225 0x04000008L,0x04100008L,0x04000108L,0x04100108L,
226 0x04001000L,0x04101000L,0x04001100L,0x04101100L,
227 0x04001008L,0x04101008L,0x04001108L,0x04101108L,
228 0x00020000L,0x00120000L,0x00020100L,0x00120100L,
229 0x00020008L,0x00120008L,0x00020108L,0x00120108L,
230 0x00021000L,0x00121000L,0x00021100L,0x00121100L,
231 0x00021008L,0x00121008L,0x00021108L,0x00121108L,
232 0x04020000L,0x04120000L,0x04020100L,0x04120100L,
233 0x04020008L,0x04120008L,0x04020108L,0x04120108L,
234 0x04021000L,0x04121000L,0x04021100L,0x04121100L,
235 0x04021008L,0x04121008L,0x04021108L,0x04121108L,
236 },{
237 /* for D bits (numbered as per FIPS 46) 1 2 3 4 5 6 */
238 0x00000000L,0x10000000L,0x00010000L,0x10010000L,
239 0x00000004L,0x10000004L,0x00010004L,0x10010004L,
240 0x20000000L,0x30000000L,0x20010000L,0x30010000L,
241 0x20000004L,0x30000004L,0x20010004L,0x30010004L,
242 0x00100000L,0x10100000L,0x00110000L,0x10110000L,
243 0x00100004L,0x10100004L,0x00110004L,0x10110004L,
244 0x20100000L,0x30100000L,0x20110000L,0x30110000L,
245 0x20100004L,0x30100004L,0x20110004L,0x30110004L,
246 0x00001000L,0x10001000L,0x00011000L,0x10011000L,
247 0x00001004L,0x10001004L,0x00011004L,0x10011004L,
248 0x20001000L,0x30001000L,0x20011000L,0x30011000L,
249 0x20001004L,0x30001004L,0x20011004L,0x30011004L,
250 0x00101000L,0x10101000L,0x00111000L,0x10111000L,
251 0x00101004L,0x10101004L,0x00111004L,0x10111004L,
252 0x20101000L,0x30101000L,0x20111000L,0x30111000L,
253 0x20101004L,0x30101004L,0x20111004L,0x30111004L,
254 },{
255 /* for D bits (numbered as per FIPS 46) 8 9 11 12 13 14 */
256 0x00000000L,0x08000000L,0x00000008L,0x08000008L,
257 0x00000400L,0x08000400L,0x00000408L,0x08000408L,
258 0x00020000L,0x08020000L,0x00020008L,0x08020008L,
259 0x00020400L,0x08020400L,0x00020408L,0x08020408L,
260 0x00000001L,0x08000001L,0x00000009L,0x08000009L,
261 0x00000401L,0x08000401L,0x00000409L,0x08000409L,
262 0x00020001L,0x08020001L,0x00020009L,0x08020009L,
263 0x00020401L,0x08020401L,0x00020409L,0x08020409L,
264 0x02000000L,0x0A000000L,0x02000008L,0x0A000008L,
265 0x02000400L,0x0A000400L,0x02000408L,0x0A000408L,
266 0x02020000L,0x0A020000L,0x02020008L,0x0A020008L,
267 0x02020400L,0x0A020400L,0x02020408L,0x0A020408L,
268 0x02000001L,0x0A000001L,0x02000009L,0x0A000009L,
269 0x02000401L,0x0A000401L,0x02000409L,0x0A000409L,
270 0x02020001L,0x0A020001L,0x02020009L,0x0A020009L,
271 0x02020401L,0x0A020401L,0x02020409L,0x0A020409L,
272 },{
273 /* for D bits (numbered as per FIPS 46) 16 17 18 19 20 21 */
274 0x00000000L,0x00000100L,0x00080000L,0x00080100L,
275 0x01000000L,0x01000100L,0x01080000L,0x01080100L,
276 0x00000010L,0x00000110L,0x00080010L,0x00080110L,
277 0x01000010L,0x01000110L,0x01080010L,0x01080110L,
278 0x00200000L,0x00200100L,0x00280000L,0x00280100L,
279 0x01200000L,0x01200100L,0x01280000L,0x01280100L,
280 0x00200010L,0x00200110L,0x00280010L,0x00280110L,
281 0x01200010L,0x01200110L,0x01280010L,0x01280110L,
282 0x00000200L,0x00000300L,0x00080200L,0x00080300L,
283 0x01000200L,0x01000300L,0x01080200L,0x01080300L,
284 0x00000210L,0x00000310L,0x00080210L,0x00080310L,
285 0x01000210L,0x01000310L,0x01080210L,0x01080310L,
286 0x00200200L,0x00200300L,0x00280200L,0x00280300L,
287 0x01200200L,0x01200300L,0x01280200L,0x01280300L,
288 0x00200210L,0x00200310L,0x00280210L,0x00280310L,
289 0x01200210L,0x01200310L,0x01280210L,0x01280310L,
290 },{
291 /* for D bits (numbered as per FIPS 46) 22 23 24 25 27 28 */
292 0x00000000L,0x04000000L,0x00040000L,0x04040000L,
293 0x00000002L,0x04000002L,0x00040002L,0x04040002L,
294 0x00002000L,0x04002000L,0x00042000L,0x04042000L,
295 0x00002002L,0x04002002L,0x00042002L,0x04042002L,
296 0x00000020L,0x04000020L,0x00040020L,0x04040020L,
297 0x00000022L,0x04000022L,0x00040022L,0x04040022L,
298 0x00002020L,0x04002020L,0x00042020L,0x04042020L,
299 0x00002022L,0x04002022L,0x00042022L,0x04042022L,
300 0x00000800L,0x04000800L,0x00040800L,0x04040800L,
301 0x00000802L,0x04000802L,0x00040802L,0x04040802L,
302 0x00002800L,0x04002800L,0x00042800L,0x04042800L,
303 0x00002802L,0x04002802L,0x00042802L,0x04042802L,
304 0x00000820L,0x04000820L,0x00040820L,0x04040820L,
305 0x00000822L,0x04000822L,0x00040822L,0x04040822L,
306 0x00002820L,0x04002820L,0x00042820L,0x04042820L,
307 0x00002822L,0x04002822L,0x00042822L,0x04042822L,
308 }};
309
310int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule)
311 {
312 if (DES_check_key)
313 {
314 return DES_set_key_checked(key, schedule);
315 }
316 else
317 {
318 DES_set_key_unchecked(key, schedule);
319 return 0;
320 }
321 }
322
323/* return 0 if key parity is odd (correct),
324 * return -1 if key parity error,
325 * return -2 if illegal weak key.
326 */
327int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule)
328 {
329 if (!DES_check_key_parity(key))
330 return(-1);
331 if (DES_is_weak_key(key))
332 return(-2);
333 DES_set_key_unchecked(key, schedule);
334 return 0;
335 }
336
337void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule)
338 {
339 static const int shifts2[16]={0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0};
340 register DES_LONG c,d,t,s,t2;
341 register const unsigned char *in;
342 register DES_LONG *k;
343 register int i;
344
345#ifdef OPENBSD_DEV_CRYPTO
346 memcpy(schedule->key,key,sizeof schedule->key);
347 schedule->session=NULL;
348#endif
349 k = &schedule->ks->deslong[0];
350 in = &(*key)[0];
351
352 c2l(in,c);
353 c2l(in,d);
354
355 /* do PC1 in 47 simple operations :-)
356 * Thanks to John Fletcher (john_fletcher@lccmail.ocf.llnl.gov)
357 * for the inspiration. :-) */
358 PERM_OP (d,c,t,4,0x0f0f0f0fL);
359 HPERM_OP(c,t,-2,0xcccc0000L);
360 HPERM_OP(d,t,-2,0xcccc0000L);
361 PERM_OP (d,c,t,1,0x55555555L);
362 PERM_OP (c,d,t,8,0x00ff00ffL);
363 PERM_OP (d,c,t,1,0x55555555L);
364 d= (((d&0x000000ffL)<<16L)| (d&0x0000ff00L) |
365 ((d&0x00ff0000L)>>16L)|((c&0xf0000000L)>>4L));
366 c&=0x0fffffffL;
367
368 for (i=0; i<ITERATIONS; i++)
369 {
370 if (shifts2[i])
371 { c=((c>>2L)|(c<<26L)); d=((d>>2L)|(d<<26L)); }
372 else
373 { c=((c>>1L)|(c<<27L)); d=((d>>1L)|(d<<27L)); }
374 c&=0x0fffffffL;
375 d&=0x0fffffffL;
376 /* could be a few less shifts but I am to lazy at this
377 * point in time to investigate */
378 s= des_skb[0][ (c )&0x3f ]|
379 des_skb[1][((c>> 6L)&0x03)|((c>> 7L)&0x3c)]|
380 des_skb[2][((c>>13L)&0x0f)|((c>>14L)&0x30)]|
381 des_skb[3][((c>>20L)&0x01)|((c>>21L)&0x06) |
382 ((c>>22L)&0x38)];
383 t= des_skb[4][ (d )&0x3f ]|
384 des_skb[5][((d>> 7L)&0x03)|((d>> 8L)&0x3c)]|
385 des_skb[6][ (d>>15L)&0x3f ]|
386 des_skb[7][((d>>21L)&0x0f)|((d>>22L)&0x30)];
387
388 /* table contained 0213 4657 */
389 t2=((t<<16L)|(s&0x0000ffffL))&0xffffffffL;
390 *(k++)=ROTATE(t2,30)&0xffffffffL;
391
392 t2=((s>>16L)|(t&0xffff0000L));
393 *(k++)=ROTATE(t2,26)&0xffffffffL;
394 }
395 }
396
397int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule)
398 {
399 return(DES_set_key(key,schedule));
400 }
401/*
402#undef des_fixup_key_parity
403void des_fixup_key_parity(des_cblock *key)
404 {
405 des_set_odd_parity(key);
406 }
407*/
diff --git a/src/lib/libcrypto/des/speed.c b/src/lib/libcrypto/des/speed.c
deleted file mode 100644
index 1616f4b7c9..0000000000
--- a/src/lib/libcrypto/des/speed.c
+++ /dev/null
@@ -1,314 +0,0 @@
1/* crypto/des/speed.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59/* 11-Sep-92 Andrew Daviel Support for Silicon Graphics IRIX added */
60/* 06-Apr-92 Luke Brennan Support for VMS and add extra signal calls */
61
62#if !defined(OPENSSL_SYS_MSDOS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC)) && !defined(OPENSSL_SYS_MACOSX)
63#define TIMES
64#endif
65
66#include <stdio.h>
67
68#include <openssl/e_os2.h>
69#include OPENSSL_UNISTD_IO
70OPENSSL_DECLARE_EXIT
71
72#ifndef OPENSSL_SYS_NETWARE
73#include <signal.h>
74#define crypt(c,s) (des_crypt((c),(s)))
75#endif
76
77#ifndef _IRIX
78#include <time.h>
79#endif
80#ifdef TIMES
81#include <sys/types.h>
82#include <sys/times.h>
83#endif
84
85/* Depending on the VMS version, the tms structure is perhaps defined.
86 The __TMS macro will show if it was. If it wasn't defined, we should
87 undefine TIMES, since that tells the rest of the program how things
88 should be handled. -- Richard Levitte */
89#if defined(OPENSSL_SYS_VMS_DECC) && !defined(__TMS)
90#undef TIMES
91#endif
92
93#ifndef TIMES
94#include <sys/timeb.h>
95#endif
96
97#if defined(sun) || defined(__ultrix)
98#define _POSIX_SOURCE
99#include <limits.h>
100#include <sys/param.h>
101#endif
102
103#include <openssl/des.h>
104
105/* The following if from times(3) man page. It may need to be changed */
106#ifndef HZ
107# ifndef CLK_TCK
108# ifndef _BSD_CLK_TCK_ /* FreeBSD fix */
109# define HZ 100.0
110# else /* _BSD_CLK_TCK_ */
111# define HZ ((double)_BSD_CLK_TCK_)
112# endif
113# else /* CLK_TCK */
114# define HZ ((double)CLK_TCK)
115# endif
116#endif
117
118#define BUFSIZE ((long)1024)
119long run=0;
120
121double Time_F(int s);
122#ifdef SIGALRM
123#if defined(__STDC__) || defined(sgi) || defined(_AIX)
124#define SIGRETTYPE void
125#else
126#define SIGRETTYPE int
127#endif
128
129SIGRETTYPE sig_done(int sig);
130SIGRETTYPE sig_done(int sig)
131 {
132 signal(SIGALRM,sig_done);
133 run=0;
134#ifdef LINT
135 sig=sig;
136#endif
137 }
138#endif
139
140#define START 0
141#define STOP 1
142
143double Time_F(int s)
144 {
145 double ret;
146#ifdef TIMES
147 static struct tms tstart,tend;
148
149 if (s == START)
150 {
151 times(&tstart);
152 return(0);
153 }
154 else
155 {
156 times(&tend);
157 ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
158 return((ret == 0.0)?1e-6:ret);
159 }
160#else /* !times() */
161 static struct timeb tstart,tend;
162 long i;
163
164 if (s == START)
165 {
166 ftime(&tstart);
167 return(0);
168 }
169 else
170 {
171 ftime(&tend);
172 i=(long)tend.millitm-(long)tstart.millitm;
173 ret=((double)(tend.time-tstart.time))+((double)i)/1e3;
174 return((ret == 0.0)?1e-6:ret);
175 }
176#endif
177 }
178
179int main(int argc, char **argv)
180 {
181 long count;
182 static unsigned char buf[BUFSIZE];
183 static DES_cblock key ={0x12,0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0};
184 static DES_cblock key2={0x34,0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12};
185 static DES_cblock key3={0x56,0x78,0x9a,0xbc,0xde,0xf0,0x12,0x34};
186 DES_key_schedule sch,sch2,sch3;
187 double a,b,c,d,e;
188#ifndef SIGALRM
189 long ca,cb,cc,cd,ce;
190#endif
191
192#ifndef TIMES
193 printf("To get the most accurate results, try to run this\n");
194 printf("program when this computer is idle.\n");
195#endif
196
197 DES_set_key_unchecked(&key2,&sch2);
198 DES_set_key_unchecked(&key3,&sch3);
199
200#ifndef SIGALRM
201 printf("First we calculate the approximate speed ...\n");
202 DES_set_key_unchecked(&key,&sch);
203 count=10;
204 do {
205 long i;
206 DES_LONG data[2];
207
208 count*=2;
209 Time_F(START);
210 for (i=count; i; i--)
211 DES_encrypt1(data,&sch,DES_ENCRYPT);
212 d=Time_F(STOP);
213 } while (d < 3.0);
214 ca=count;
215 cb=count*3;
216 cc=count*3*8/BUFSIZE+1;
217 cd=count*8/BUFSIZE+1;
218 ce=count/20+1;
219 printf("Doing set_key %ld times\n",ca);
220#define COND(d) (count != (d))
221#define COUNT(d) (d)
222#else
223#define COND(c) (run)
224#define COUNT(d) (count)
225 signal(SIGALRM,sig_done);
226 printf("Doing set_key for 10 seconds\n");
227 alarm(10);
228#endif
229
230 Time_F(START);
231 for (count=0,run=1; COND(ca); count++)
232 DES_set_key_unchecked(&key,&sch);
233 d=Time_F(STOP);
234 printf("%ld set_key's in %.2f seconds\n",count,d);
235 a=((double)COUNT(ca))/d;
236
237#ifdef SIGALRM
238 printf("Doing DES_encrypt's for 10 seconds\n");
239 alarm(10);
240#else
241 printf("Doing DES_encrypt %ld times\n",cb);
242#endif
243 Time_F(START);
244 for (count=0,run=1; COND(cb); count++)
245 {
246 DES_LONG data[2];
247
248 DES_encrypt1(data,&sch,DES_ENCRYPT);
249 }
250 d=Time_F(STOP);
251 printf("%ld DES_encrypt's in %.2f second\n",count,d);
252 b=((double)COUNT(cb)*8)/d;
253
254#ifdef SIGALRM
255 printf("Doing DES_cbc_encrypt on %ld byte blocks for 10 seconds\n",
256 BUFSIZE);
257 alarm(10);
258#else
259 printf("Doing DES_cbc_encrypt %ld times on %ld byte blocks\n",cc,
260 BUFSIZE);
261#endif
262 Time_F(START);
263 for (count=0,run=1; COND(cc); count++)
264 DES_ncbc_encrypt(buf,buf,BUFSIZE,&sch,
265 &key,DES_ENCRYPT);
266 d=Time_F(STOP);
267 printf("%ld DES_cbc_encrypt's of %ld byte blocks in %.2f second\n",
268 count,BUFSIZE,d);
269 c=((double)COUNT(cc)*BUFSIZE)/d;
270
271#ifdef SIGALRM
272 printf("Doing DES_ede_cbc_encrypt on %ld byte blocks for 10 seconds\n",
273 BUFSIZE);
274 alarm(10);
275#else
276 printf("Doing DES_ede_cbc_encrypt %ld times on %ld byte blocks\n",cd,
277 BUFSIZE);
278#endif
279 Time_F(START);
280 for (count=0,run=1; COND(cd); count++)
281 DES_ede3_cbc_encrypt(buf,buf,BUFSIZE,
282 &sch,
283 &sch2,
284 &sch3,
285 &key,
286 DES_ENCRYPT);
287 d=Time_F(STOP);
288 printf("%ld DES_ede_cbc_encrypt's of %ld byte blocks in %.2f second\n",
289 count,BUFSIZE,d);
290 d=((double)COUNT(cd)*BUFSIZE)/d;
291
292#ifdef SIGALRM
293 printf("Doing crypt for 10 seconds\n");
294 alarm(10);
295#else
296 printf("Doing crypt %ld times\n",ce);
297#endif
298 Time_F(START);
299 for (count=0,run=1; COND(ce); count++)
300 crypt("testing1","ef");
301 e=Time_F(STOP);
302 printf("%ld crypts in %.2f second\n",count,e);
303 e=((double)COUNT(ce))/e;
304
305 printf("set_key per sec = %12.2f (%9.3fuS)\n",a,1.0e6/a);
306 printf("DES raw ecb bytes per sec = %12.2f (%9.3fuS)\n",b,8.0e6/b);
307 printf("DES cbc bytes per sec = %12.2f (%9.3fuS)\n",c,8.0e6/c);
308 printf("DES ede cbc bytes per sec = %12.2f (%9.3fuS)\n",d,8.0e6/d);
309 printf("crypt per sec = %12.2f (%9.3fuS)\n",e,1.0e6/e);
310 exit(0);
311#if defined(LINT) || defined(OPENSSL_SYS_MSDOS)
312 return(0);
313#endif
314 }
diff --git a/src/lib/libcrypto/des/spr.h b/src/lib/libcrypto/des/spr.h
deleted file mode 100644
index b91936a5a5..0000000000
--- a/src/lib/libcrypto/des/spr.h
+++ /dev/null
@@ -1,204 +0,0 @@
1/* crypto/des/spr.h */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59OPENSSL_GLOBAL const DES_LONG DES_SPtrans[8][64]={
60{
61/* nibble 0 */
620x02080800L, 0x00080000L, 0x02000002L, 0x02080802L,
630x02000000L, 0x00080802L, 0x00080002L, 0x02000002L,
640x00080802L, 0x02080800L, 0x02080000L, 0x00000802L,
650x02000802L, 0x02000000L, 0x00000000L, 0x00080002L,
660x00080000L, 0x00000002L, 0x02000800L, 0x00080800L,
670x02080802L, 0x02080000L, 0x00000802L, 0x02000800L,
680x00000002L, 0x00000800L, 0x00080800L, 0x02080002L,
690x00000800L, 0x02000802L, 0x02080002L, 0x00000000L,
700x00000000L, 0x02080802L, 0x02000800L, 0x00080002L,
710x02080800L, 0x00080000L, 0x00000802L, 0x02000800L,
720x02080002L, 0x00000800L, 0x00080800L, 0x02000002L,
730x00080802L, 0x00000002L, 0x02000002L, 0x02080000L,
740x02080802L, 0x00080800L, 0x02080000L, 0x02000802L,
750x02000000L, 0x00000802L, 0x00080002L, 0x00000000L,
760x00080000L, 0x02000000L, 0x02000802L, 0x02080800L,
770x00000002L, 0x02080002L, 0x00000800L, 0x00080802L,
78},{
79/* nibble 1 */
800x40108010L, 0x00000000L, 0x00108000L, 0x40100000L,
810x40000010L, 0x00008010L, 0x40008000L, 0x00108000L,
820x00008000L, 0x40100010L, 0x00000010L, 0x40008000L,
830x00100010L, 0x40108000L, 0x40100000L, 0x00000010L,
840x00100000L, 0x40008010L, 0x40100010L, 0x00008000L,
850x00108010L, 0x40000000L, 0x00000000L, 0x00100010L,
860x40008010L, 0x00108010L, 0x40108000L, 0x40000010L,
870x40000000L, 0x00100000L, 0x00008010L, 0x40108010L,
880x00100010L, 0x40108000L, 0x40008000L, 0x00108010L,
890x40108010L, 0x00100010L, 0x40000010L, 0x00000000L,
900x40000000L, 0x00008010L, 0x00100000L, 0x40100010L,
910x00008000L, 0x40000000L, 0x00108010L, 0x40008010L,
920x40108000L, 0x00008000L, 0x00000000L, 0x40000010L,
930x00000010L, 0x40108010L, 0x00108000L, 0x40100000L,
940x40100010L, 0x00100000L, 0x00008010L, 0x40008000L,
950x40008010L, 0x00000010L, 0x40100000L, 0x00108000L,
96},{
97/* nibble 2 */
980x04000001L, 0x04040100L, 0x00000100L, 0x04000101L,
990x00040001L, 0x04000000L, 0x04000101L, 0x00040100L,
1000x04000100L, 0x00040000L, 0x04040000L, 0x00000001L,
1010x04040101L, 0x00000101L, 0x00000001L, 0x04040001L,
1020x00000000L, 0x00040001L, 0x04040100L, 0x00000100L,
1030x00000101L, 0x04040101L, 0x00040000L, 0x04000001L,
1040x04040001L, 0x04000100L, 0x00040101L, 0x04040000L,
1050x00040100L, 0x00000000L, 0x04000000L, 0x00040101L,
1060x04040100L, 0x00000100L, 0x00000001L, 0x00040000L,
1070x00000101L, 0x00040001L, 0x04040000L, 0x04000101L,
1080x00000000L, 0x04040100L, 0x00040100L, 0x04040001L,
1090x00040001L, 0x04000000L, 0x04040101L, 0x00000001L,
1100x00040101L, 0x04000001L, 0x04000000L, 0x04040101L,
1110x00040000L, 0x04000100L, 0x04000101L, 0x00040100L,
1120x04000100L, 0x00000000L, 0x04040001L, 0x00000101L,
1130x04000001L, 0x00040101L, 0x00000100L, 0x04040000L,
114},{
115/* nibble 3 */
1160x00401008L, 0x10001000L, 0x00000008L, 0x10401008L,
1170x00000000L, 0x10400000L, 0x10001008L, 0x00400008L,
1180x10401000L, 0x10000008L, 0x10000000L, 0x00001008L,
1190x10000008L, 0x00401008L, 0x00400000L, 0x10000000L,
1200x10400008L, 0x00401000L, 0x00001000L, 0x00000008L,
1210x00401000L, 0x10001008L, 0x10400000L, 0x00001000L,
1220x00001008L, 0x00000000L, 0x00400008L, 0x10401000L,
1230x10001000L, 0x10400008L, 0x10401008L, 0x00400000L,
1240x10400008L, 0x00001008L, 0x00400000L, 0x10000008L,
1250x00401000L, 0x10001000L, 0x00000008L, 0x10400000L,
1260x10001008L, 0x00000000L, 0x00001000L, 0x00400008L,
1270x00000000L, 0x10400008L, 0x10401000L, 0x00001000L,
1280x10000000L, 0x10401008L, 0x00401008L, 0x00400000L,
1290x10401008L, 0x00000008L, 0x10001000L, 0x00401008L,
1300x00400008L, 0x00401000L, 0x10400000L, 0x10001008L,
1310x00001008L, 0x10000000L, 0x10000008L, 0x10401000L,
132},{
133/* nibble 4 */
1340x08000000L, 0x00010000L, 0x00000400L, 0x08010420L,
1350x08010020L, 0x08000400L, 0x00010420L, 0x08010000L,
1360x00010000L, 0x00000020L, 0x08000020L, 0x00010400L,
1370x08000420L, 0x08010020L, 0x08010400L, 0x00000000L,
1380x00010400L, 0x08000000L, 0x00010020L, 0x00000420L,
1390x08000400L, 0x00010420L, 0x00000000L, 0x08000020L,
1400x00000020L, 0x08000420L, 0x08010420L, 0x00010020L,
1410x08010000L, 0x00000400L, 0x00000420L, 0x08010400L,
1420x08010400L, 0x08000420L, 0x00010020L, 0x08010000L,
1430x00010000L, 0x00000020L, 0x08000020L, 0x08000400L,
1440x08000000L, 0x00010400L, 0x08010420L, 0x00000000L,
1450x00010420L, 0x08000000L, 0x00000400L, 0x00010020L,
1460x08000420L, 0x00000400L, 0x00000000L, 0x08010420L,
1470x08010020L, 0x08010400L, 0x00000420L, 0x00010000L,
1480x00010400L, 0x08010020L, 0x08000400L, 0x00000420L,
1490x00000020L, 0x00010420L, 0x08010000L, 0x08000020L,
150},{
151/* nibble 5 */
1520x80000040L, 0x00200040L, 0x00000000L, 0x80202000L,
1530x00200040L, 0x00002000L, 0x80002040L, 0x00200000L,
1540x00002040L, 0x80202040L, 0x00202000L, 0x80000000L,
1550x80002000L, 0x80000040L, 0x80200000L, 0x00202040L,
1560x00200000L, 0x80002040L, 0x80200040L, 0x00000000L,
1570x00002000L, 0x00000040L, 0x80202000L, 0x80200040L,
1580x80202040L, 0x80200000L, 0x80000000L, 0x00002040L,
1590x00000040L, 0x00202000L, 0x00202040L, 0x80002000L,
1600x00002040L, 0x80000000L, 0x80002000L, 0x00202040L,
1610x80202000L, 0x00200040L, 0x00000000L, 0x80002000L,
1620x80000000L, 0x00002000L, 0x80200040L, 0x00200000L,
1630x00200040L, 0x80202040L, 0x00202000L, 0x00000040L,
1640x80202040L, 0x00202000L, 0x00200000L, 0x80002040L,
1650x80000040L, 0x80200000L, 0x00202040L, 0x00000000L,
1660x00002000L, 0x80000040L, 0x80002040L, 0x80202000L,
1670x80200000L, 0x00002040L, 0x00000040L, 0x80200040L,
168},{
169/* nibble 6 */
1700x00004000L, 0x00000200L, 0x01000200L, 0x01000004L,
1710x01004204L, 0x00004004L, 0x00004200L, 0x00000000L,
1720x01000000L, 0x01000204L, 0x00000204L, 0x01004000L,
1730x00000004L, 0x01004200L, 0x01004000L, 0x00000204L,
1740x01000204L, 0x00004000L, 0x00004004L, 0x01004204L,
1750x00000000L, 0x01000200L, 0x01000004L, 0x00004200L,
1760x01004004L, 0x00004204L, 0x01004200L, 0x00000004L,
1770x00004204L, 0x01004004L, 0x00000200L, 0x01000000L,
1780x00004204L, 0x01004000L, 0x01004004L, 0x00000204L,
1790x00004000L, 0x00000200L, 0x01000000L, 0x01004004L,
1800x01000204L, 0x00004204L, 0x00004200L, 0x00000000L,
1810x00000200L, 0x01000004L, 0x00000004L, 0x01000200L,
1820x00000000L, 0x01000204L, 0x01000200L, 0x00004200L,
1830x00000204L, 0x00004000L, 0x01004204L, 0x01000000L,
1840x01004200L, 0x00000004L, 0x00004004L, 0x01004204L,
1850x01000004L, 0x01004200L, 0x01004000L, 0x00004004L,
186},{
187/* nibble 7 */
1880x20800080L, 0x20820000L, 0x00020080L, 0x00000000L,
1890x20020000L, 0x00800080L, 0x20800000L, 0x20820080L,
1900x00000080L, 0x20000000L, 0x00820000L, 0x00020080L,
1910x00820080L, 0x20020080L, 0x20000080L, 0x20800000L,
1920x00020000L, 0x00820080L, 0x00800080L, 0x20020000L,
1930x20820080L, 0x20000080L, 0x00000000L, 0x00820000L,
1940x20000000L, 0x00800000L, 0x20020080L, 0x20800080L,
1950x00800000L, 0x00020000L, 0x20820000L, 0x00000080L,
1960x00800000L, 0x00020000L, 0x20000080L, 0x20820080L,
1970x00020080L, 0x20000000L, 0x00000000L, 0x00820000L,
1980x20800080L, 0x20020080L, 0x20020000L, 0x00800080L,
1990x20820000L, 0x00000080L, 0x00800080L, 0x20020000L,
2000x20820080L, 0x00800000L, 0x20800000L, 0x20000080L,
2010x00820000L, 0x00020080L, 0x20020080L, 0x20800000L,
2020x00000080L, 0x20820000L, 0x00820080L, 0x00000000L,
2030x20000000L, 0x20800080L, 0x00020000L, 0x00820080L,
204}};
diff --git a/src/lib/libcrypto/des/str2key.c b/src/lib/libcrypto/des/str2key.c
deleted file mode 100644
index 9c2054bda6..0000000000
--- a/src/lib/libcrypto/des/str2key.c
+++ /dev/null
@@ -1,174 +0,0 @@
1/* crypto/des/str2key.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60#include <openssl/crypto.h>
61
62void DES_string_to_key(const char *str, DES_cblock *key)
63 {
64 DES_key_schedule ks;
65 int i,length;
66 register unsigned char j;
67
68 memset(key,0,8);
69 length=strlen(str);
70#ifdef OLD_STR_TO_KEY
71 for (i=0; i<length; i++)
72 (*key)[i%8]^=(str[i]<<1);
73#else /* MIT COMPATIBLE */
74 for (i=0; i<length; i++)
75 {
76 j=str[i];
77 if ((i%16) < 8)
78 (*key)[i%8]^=(j<<1);
79 else
80 {
81 /* Reverse the bit order 05/05/92 eay */
82 j=((j<<4)&0xf0)|((j>>4)&0x0f);
83 j=((j<<2)&0xcc)|((j>>2)&0x33);
84 j=((j<<1)&0xaa)|((j>>1)&0x55);
85 (*key)[7-(i%8)]^=j;
86 }
87 }
88#endif
89 DES_set_odd_parity(key);
90#ifdef EXPERIMENTAL_STR_TO_STRONG_KEY
91 if(DES_is_weak_key(key))
92 (*key)[7] ^= 0xF0;
93 DES_set_key(key,&ks);
94#else
95 DES_set_key_unchecked(key,&ks);
96#endif
97 DES_cbc_cksum((const unsigned char*)str,key,length,&ks,key);
98 OPENSSL_cleanse(&ks,sizeof(ks));
99 DES_set_odd_parity(key);
100 }
101
102void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2)
103 {
104 DES_key_schedule ks;
105 int i,length;
106 register unsigned char j;
107
108 memset(key1,0,8);
109 memset(key2,0,8);
110 length=strlen(str);
111#ifdef OLD_STR_TO_KEY
112 if (length <= 8)
113 {
114 for (i=0; i<length; i++)
115 {
116 (*key2)[i]=(*key1)[i]=(str[i]<<1);
117 }
118 }
119 else
120 {
121 for (i=0; i<length; i++)
122 {
123 if ((i/8)&1)
124 (*key2)[i%8]^=(str[i]<<1);
125 else
126 (*key1)[i%8]^=(str[i]<<1);
127 }
128 }
129#else /* MIT COMPATIBLE */
130 for (i=0; i<length; i++)
131 {
132 j=str[i];
133 if ((i%32) < 16)
134 {
135 if ((i%16) < 8)
136 (*key1)[i%8]^=(j<<1);
137 else
138 (*key2)[i%8]^=(j<<1);
139 }
140 else
141 {
142 j=((j<<4)&0xf0)|((j>>4)&0x0f);
143 j=((j<<2)&0xcc)|((j>>2)&0x33);
144 j=((j<<1)&0xaa)|((j>>1)&0x55);
145 if ((i%16) < 8)
146 (*key1)[7-(i%8)]^=j;
147 else
148 (*key2)[7-(i%8)]^=j;
149 }
150 }
151 if (length <= 8) memcpy(key2,key1,8);
152#endif
153 DES_set_odd_parity(key1);
154 DES_set_odd_parity(key2);
155#ifdef EXPERIMENTAL_STR_TO_STRONG_KEY
156 if(DES_is_weak_key(key1))
157 (*key1)[7] ^= 0xF0;
158 DES_set_key(key1,&ks);
159#else
160 DES_set_key_unchecked(key1,&ks);
161#endif
162 DES_cbc_cksum((const unsigned char*)str,key1,length,&ks,key1);
163#ifdef EXPERIMENTAL_STR_TO_STRONG_KEY
164 if(DES_is_weak_key(key2))
165 (*key2)[7] ^= 0xF0;
166 DES_set_key(key2,&ks);
167#else
168 DES_set_key_unchecked(key2,&ks);
169#endif
170 DES_cbc_cksum((const unsigned char*)str,key2,length,&ks,key2);
171 OPENSSL_cleanse(&ks,sizeof(ks));
172 DES_set_odd_parity(key1);
173 DES_set_odd_parity(key2);
174 }
diff --git a/src/lib/libcrypto/des/t/test b/src/lib/libcrypto/des/t/test
deleted file mode 100644
index 97acd0552e..0000000000
--- a/src/lib/libcrypto/des/t/test
+++ /dev/null
@@ -1,27 +0,0 @@
1#!./perl
2
3BEGIN { push(@INC, qw(../../../lib ../../lib ../lib lib)); }
4
5use DES;
6
7$key='00000000';
8$ks=DES::set_key($key);
9@a=split(//,$ks);
10foreach (@a) { printf "%02x-",ord($_); }
11print "\n";
12
13
14$key=DES::random_key();
15print "($_)\n";
16@a=split(//,$key);
17foreach (@a) { printf "%02x-",ord($_); }
18print "\n";
19$str="this is and again into the breach";
20($k1,$k2)=DES::string_to_2keys($str);
21@a=split(//,$k1);
22foreach (@a) { printf "%02x-",ord($_); }
23print "\n";
24@a=split(//,$k2);
25foreach (@a) { printf "%02x-",ord($_); }
26print "\n";
27
diff --git a/src/lib/libcrypto/des/times/486-50.sol b/src/lib/libcrypto/des/times/486-50.sol
deleted file mode 100644
index 0de62d6db3..0000000000
--- a/src/lib/libcrypto/des/times/486-50.sol
+++ /dev/null
@@ -1,16 +0,0 @@
1Solaris 2.4, 486 50mhz, gcc 2.6.3
2options des ecb/s
316 r2 i 43552.51 100.0%
416 r1 i 43487.45 99.9%
516 c p 43003.23 98.7%
616 r2 p 42339.00 97.2%
716 c i 41900.91 96.2%
816 r1 p 41360.64 95.0%
9 4 c i 38728.48 88.9%
10 4 c p 38225.63 87.8%
11 4 r1 i 38085.79 87.4%
12 4 r2 i 37825.64 86.9%
13 4 r2 p 34611.00 79.5%
14 4 r1 p 31802.00 73.0%
15-DDES_UNROLL -DDES_RISC2
16
diff --git a/src/lib/libcrypto/des/times/586-100.lnx b/src/lib/libcrypto/des/times/586-100.lnx
deleted file mode 100644
index 4323914a11..0000000000
--- a/src/lib/libcrypto/des/times/586-100.lnx
+++ /dev/null
@@ -1,20 +0,0 @@
1Pentium 100
2Linux 2 kernel
3gcc 2.7.0 -O3 -fomit-frame-pointer
4No X server running, just a console, it makes the top speed jump from 151,000
5to 158,000 :-).
6options des ecb/s
7assember 281000.00 177.1%
816 r1 p 158667.40 100.0%
916 r1 i 148471.70 93.6%
1016 r2 p 143961.80 90.7%
1116 r2 i 141689.20 89.3%
12 4 r1 i 140100.00 88.3%
13 4 r2 i 134049.40 84.5%
1416 c i 124145.20 78.2%
1516 c p 121584.20 76.6%
16 4 c i 118116.00 74.4%
17 4 r2 p 117977.90 74.4%
18 4 c p 114971.40 72.5%
19 4 r1 p 114578.40 72.2%
20-DDES_UNROLL -DDES_RISC1 -DDES_PTR
diff --git a/src/lib/libcrypto/des/times/686-200.fre b/src/lib/libcrypto/des/times/686-200.fre
deleted file mode 100644
index 7d83f6adee..0000000000
--- a/src/lib/libcrypto/des/times/686-200.fre
+++ /dev/null
@@ -1,18 +0,0 @@
1Pentium 100
2Free BSD 2.1.5 kernel
3gcc 2.7.2.2 -O3 -fomit-frame-pointer
4options des ecb/s
5assember 578000.00 133.1%
616 r2 i 434454.80 100.0%
716 r1 i 433621.43 99.8%
816 r2 p 431375.69 99.3%
9 4 r1 i 423722.30 97.5%
10 4 r2 i 422399.40 97.2%
1116 r1 p 421739.40 97.1%
1216 c i 399027.94 91.8%
1316 c p 372251.70 85.7%
14 4 c i 365118.35 84.0%
15 4 c p 352880.51 81.2%
16 4 r2 p 255104.90 58.7%
17 4 r1 p 251289.18 57.8%
18-DDES_UNROLL -DDES_RISC2
diff --git a/src/lib/libcrypto/des/times/aix.cc b/src/lib/libcrypto/des/times/aix.cc
deleted file mode 100644
index d96b74e2ce..0000000000
--- a/src/lib/libcrypto/des/times/aix.cc
+++ /dev/null
@@ -1,26 +0,0 @@
1From: Paco Garcia <pgarcia@cam.es>
2
3This machine is a Bull Estrella Minitower Model MT604-100
4Processor : PPC604
5P.Speed : 100Mhz
6Data/Instr Cache : 16 K
7L2 Cache : 256 K
8PCI BUS Speed : 33 Mhz
9TransfRate PCI : 132 MB/s
10Memory : 96 MB
11
12options des ecb/s
13 4 c p 275118.61 100.0%
14 4 c i 273545.07 99.4%
15 4 r2 p 270441.02 98.3%
16 4 r1 p 253052.15 92.0%
17 4 r2 i 240842.97 87.5%
18 4 r1 i 240556.66 87.4%
1916 c i 224603.99 81.6%
2016 c p 224483.98 81.6%
2116 r2 p 215691.19 78.4%
2216 r1 p 208332.83 75.7%
2316 r1 i 199206.50 72.4%
2416 r2 i 198963.70 72.3%
25-DDES_PTR
26
diff --git a/src/lib/libcrypto/des/times/alpha.cc b/src/lib/libcrypto/des/times/alpha.cc
deleted file mode 100644
index 95c17efae7..0000000000
--- a/src/lib/libcrypto/des/times/alpha.cc
+++ /dev/null
@@ -1,18 +0,0 @@
1cc -O2
2DES_LONG is 'unsigned int'
3
4options des ecb/s
5 4 r2 p 181146.14 100.0%
616 r2 p 172102.94 95.0%
7 4 r2 i 165424.11 91.3%
816 c p 160468.64 88.6%
9 4 c p 156653.59 86.5%
10 4 c i 155245.18 85.7%
11 4 r1 p 154729.68 85.4%
1216 r2 i 154137.69 85.1%
1316 r1 p 152357.96 84.1%
1416 c i 148743.91 82.1%
15 4 r1 i 146695.59 81.0%
1616 r1 i 144961.00 80.0%
17-DDES_RISC2 -DDES_PTR
18
diff --git a/src/lib/libcrypto/des/times/hpux.cc b/src/lib/libcrypto/des/times/hpux.cc
deleted file mode 100644
index 3de856ddac..0000000000
--- a/src/lib/libcrypto/des/times/hpux.cc
+++ /dev/null
@@ -1,17 +0,0 @@
1HPUX 10 - 9000/887 - cc -D_HPUX_SOURCE -Aa +ESlit +O2 -Wl,-a,archive
2
3options des ecb/s
416 c i 149448.90 100.0%
5 4 c i 145861.79 97.6%
616 r2 i 141710.96 94.8%
716 r1 i 139455.33 93.3%
8 4 r2 i 138800.00 92.9%
9 4 r1 i 136692.65 91.5%
1016 r2 p 110228.17 73.8%
1116 r1 p 109397.07 73.2%
1216 c p 109209.89 73.1%
13 4 c p 108014.71 72.3%
14 4 r2 p 107873.88 72.2%
15 4 r1 p 107685.83 72.1%
16-DDES_UNROLL
17
diff --git a/src/lib/libcrypto/des/times/sparc.gcc b/src/lib/libcrypto/des/times/sparc.gcc
deleted file mode 100644
index 8eaa042104..0000000000
--- a/src/lib/libcrypto/des/times/sparc.gcc
+++ /dev/null
@@ -1,17 +0,0 @@
1solaris 2.5.1 - sparc 10 50mhz - gcc 2.7.2
2
3options des ecb/s
416 c i 124382.70 100.0%
5 4 c i 118884.68 95.6%
616 c p 112261.20 90.3%
716 r2 i 111777.10 89.9%
816 r2 p 108896.30 87.5%
916 r1 p 108791.59 87.5%
10 4 c p 107290.10 86.3%
11 4 r1 p 104583.80 84.1%
1216 r1 i 104206.20 83.8%
13 4 r2 p 103709.80 83.4%
14 4 r2 i 98306.43 79.0%
15 4 r1 i 91525.80 73.6%
16-DDES_UNROLL
17
diff --git a/src/lib/libcrypto/des/times/usparc.cc b/src/lib/libcrypto/des/times/usparc.cc
deleted file mode 100644
index 0864285ef6..0000000000
--- a/src/lib/libcrypto/des/times/usparc.cc
+++ /dev/null
@@ -1,31 +0,0 @@
1solaris 2.5.1 usparc 167mhz?? - SC4.0 cc -fast -Xa -xO5
2
3For the ultra sparc, SunC 4.0 cc -fast -Xa -xO5, running 'des_opts'
4gives a speed of 475,000 des/s while 'speed' gives 417,000 des/s.
5I believe the difference is tied up in optimisation that the compiler
6is able to perform when the code is 'inlined'. For 'speed', the DES
7routines are being linked from a library. I'll record the higher
8speed since if performance is everything, you can always inline
9'des_enc.c'.
10
11[ 16-Jan-06 - I've been playing with the
12 '-xtarget=ultra -xarch=v8plus -Xa -xO5 -Xa'
13 and while it makes the des_opts numbers much slower, it makes the
14 actual 'speed' numbers look better which is a realistic version of
15 using the libraries. ]
16
17options des ecb/s
1816 r1 p 475516.90 100.0%
1916 r2 p 439388.10 92.4%
2016 c i 427001.40 89.8%
2116 c p 419516.50 88.2%
22 4 r2 p 409491.70 86.1%
23 4 r1 p 404266.90 85.0%
24 4 c p 398121.00 83.7%
25 4 c i 370588.40 77.9%
26 4 r1 i 362742.20 76.3%
2716 r2 i 331275.50 69.7%
2816 r1 i 324730.60 68.3%
29 4 r2 i 63535.10 13.4% <-- very very weird, must be cache problems.
30-DDES_UNROLL -DDES_RISC1 -DDES_PTR
31
diff --git a/src/lib/libcrypto/des/typemap b/src/lib/libcrypto/des/typemap
deleted file mode 100644
index a524f53634..0000000000
--- a/src/lib/libcrypto/des/typemap
+++ /dev/null
@@ -1,34 +0,0 @@
1#
2# DES SECTION
3#
4deschar * T_DESCHARP
5des_cblock * T_CBLOCK
6des_cblock T_CBLOCK
7des_key_schedule T_SCHEDULE
8des_key_schedule * T_SCHEDULE
9
10INPUT
11T_CBLOCK
12 $var=(des_cblock *)SvPV($arg,len);
13 if (len < DES_KEY_SZ)
14 {
15 croak(\"$var needs to be at least %u bytes long\",DES_KEY_SZ);
16 }
17
18T_SCHEDULE
19 $var=(des_key_schedule *)SvPV($arg,len);
20 if (len < DES_SCHEDULE_SZ)
21 {
22 croak(\"$var needs to be at least %u bytes long\",
23 DES_SCHEDULE_SZ);
24 }
25
26OUTPUT
27T_CBLOCK
28 sv_setpvn($arg,(char *)$var,DES_KEY_SZ);
29
30T_SCHEDULE
31 sv_setpvn($arg,(char *)$var,DES_SCHEDULE_SZ);
32
33T_DESCHARP
34 sv_setpvn($arg,(char *)$var,len);
diff --git a/src/lib/libcrypto/des/xcbc_enc.c b/src/lib/libcrypto/des/xcbc_enc.c
deleted file mode 100644
index 058cab6bce..0000000000
--- a/src/lib/libcrypto/des/xcbc_enc.c
+++ /dev/null
@@ -1,197 +0,0 @@
1/* crypto/des/xcbc_enc.c */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include "des_locl.h"
60
61/* RSA's DESX */
62
63#if 0 /* broken code, preserved just in case anyone specifically looks for this */
64static const unsigned char desx_white_in2out[256]={
650xBD,0x56,0xEA,0xF2,0xA2,0xF1,0xAC,0x2A,0xB0,0x93,0xD1,0x9C,0x1B,0x33,0xFD,0xD0,
660x30,0x04,0xB6,0xDC,0x7D,0xDF,0x32,0x4B,0xF7,0xCB,0x45,0x9B,0x31,0xBB,0x21,0x5A,
670x41,0x9F,0xE1,0xD9,0x4A,0x4D,0x9E,0xDA,0xA0,0x68,0x2C,0xC3,0x27,0x5F,0x80,0x36,
680x3E,0xEE,0xFB,0x95,0x1A,0xFE,0xCE,0xA8,0x34,0xA9,0x13,0xF0,0xA6,0x3F,0xD8,0x0C,
690x78,0x24,0xAF,0x23,0x52,0xC1,0x67,0x17,0xF5,0x66,0x90,0xE7,0xE8,0x07,0xB8,0x60,
700x48,0xE6,0x1E,0x53,0xF3,0x92,0xA4,0x72,0x8C,0x08,0x15,0x6E,0x86,0x00,0x84,0xFA,
710xF4,0x7F,0x8A,0x42,0x19,0xF6,0xDB,0xCD,0x14,0x8D,0x50,0x12,0xBA,0x3C,0x06,0x4E,
720xEC,0xB3,0x35,0x11,0xA1,0x88,0x8E,0x2B,0x94,0x99,0xB7,0x71,0x74,0xD3,0xE4,0xBF,
730x3A,0xDE,0x96,0x0E,0xBC,0x0A,0xED,0x77,0xFC,0x37,0x6B,0x03,0x79,0x89,0x62,0xC6,
740xD7,0xC0,0xD2,0x7C,0x6A,0x8B,0x22,0xA3,0x5B,0x05,0x5D,0x02,0x75,0xD5,0x61,0xE3,
750x18,0x8F,0x55,0x51,0xAD,0x1F,0x0B,0x5E,0x85,0xE5,0xC2,0x57,0x63,0xCA,0x3D,0x6C,
760xB4,0xC5,0xCC,0x70,0xB2,0x91,0x59,0x0D,0x47,0x20,0xC8,0x4F,0x58,0xE0,0x01,0xE2,
770x16,0x38,0xC4,0x6F,0x3B,0x0F,0x65,0x46,0xBE,0x7E,0x2D,0x7B,0x82,0xF9,0x40,0xB5,
780x1D,0x73,0xF8,0xEB,0x26,0xC7,0x87,0x97,0x25,0x54,0xB1,0x28,0xAA,0x98,0x9D,0xA5,
790x64,0x6D,0x7A,0xD4,0x10,0x81,0x44,0xEF,0x49,0xD6,0xAE,0x2E,0xDD,0x76,0x5C,0x2F,
800xA7,0x1C,0xC9,0x09,0x69,0x9A,0x83,0xCF,0x29,0x39,0xB9,0xE9,0x4C,0xFF,0x43,0xAB,
81 };
82
83void DES_xwhite_in2out(const_DES_cblock *des_key, const_DES_cblock *in_white,
84 DES_cblock *out_white)
85 {
86 int out0,out1;
87 int i;
88 const unsigned char *key = &(*des_key)[0];
89 const unsigned char *in = &(*in_white)[0];
90 unsigned char *out = &(*out_white)[0];
91
92 out[0]=out[1]=out[2]=out[3]=out[4]=out[5]=out[6]=out[7]=0;
93 out0=out1=0;
94 for (i=0; i<8; i++)
95 {
96 out[i]=key[i]^desx_white_in2out[out0^out1];
97 out0=out1;
98 out1=(int)out[i&0x07];
99 }
100
101 out0=out[0];
102 out1=out[i]; /* BUG: out-of-bounds read */
103 for (i=0; i<8; i++)
104 {
105 out[i]=in[i]^desx_white_in2out[out0^out1];
106 out0=out1;
107 out1=(int)out[i&0x07];
108 }
109 }
110#endif
111
112void DES_xcbc_encrypt(const unsigned char *in, unsigned char *out,
113 long length, DES_key_schedule *schedule,
114 DES_cblock *ivec, const_DES_cblock *inw,
115 const_DES_cblock *outw, int enc)
116 {
117 register DES_LONG tin0,tin1;
118 register DES_LONG tout0,tout1,xor0,xor1;
119 register DES_LONG inW0,inW1,outW0,outW1;
120 register const unsigned char *in2;
121 register long l=length;
122 DES_LONG tin[2];
123 unsigned char *iv;
124
125 in2 = &(*inw)[0];
126 c2l(in2,inW0);
127 c2l(in2,inW1);
128 in2 = &(*outw)[0];
129 c2l(in2,outW0);
130 c2l(in2,outW1);
131
132 iv = &(*ivec)[0];
133
134 if (enc)
135 {
136 c2l(iv,tout0);
137 c2l(iv,tout1);
138 for (l-=8; l>=0; l-=8)
139 {
140 c2l(in,tin0);
141 c2l(in,tin1);
142 tin0^=tout0^inW0; tin[0]=tin0;
143 tin1^=tout1^inW1; tin[1]=tin1;
144 DES_encrypt1(tin,schedule,DES_ENCRYPT);
145 tout0=tin[0]^outW0; l2c(tout0,out);
146 tout1=tin[1]^outW1; l2c(tout1,out);
147 }
148 if (l != -8)
149 {
150 c2ln(in,tin0,tin1,l+8);
151 tin0^=tout0^inW0; tin[0]=tin0;
152 tin1^=tout1^inW1; tin[1]=tin1;
153 DES_encrypt1(tin,schedule,DES_ENCRYPT);
154 tout0=tin[0]^outW0; l2c(tout0,out);
155 tout1=tin[1]^outW1; l2c(tout1,out);
156 }
157 iv = &(*ivec)[0];
158 l2c(tout0,iv);
159 l2c(tout1,iv);
160 }
161 else
162 {
163 c2l(iv,xor0);
164 c2l(iv,xor1);
165 for (l-=8; l>0; l-=8)
166 {
167 c2l(in,tin0); tin[0]=tin0^outW0;
168 c2l(in,tin1); tin[1]=tin1^outW1;
169 DES_encrypt1(tin,schedule,DES_DECRYPT);
170 tout0=tin[0]^xor0^inW0;
171 tout1=tin[1]^xor1^inW1;
172 l2c(tout0,out);
173 l2c(tout1,out);
174 xor0=tin0;
175 xor1=tin1;
176 }
177 if (l != -8)
178 {
179 c2l(in,tin0); tin[0]=tin0^outW0;
180 c2l(in,tin1); tin[1]=tin1^outW1;
181 DES_encrypt1(tin,schedule,DES_DECRYPT);
182 tout0=tin[0]^xor0^inW0;
183 tout1=tin[1]^xor1^inW1;
184 l2cn(tout0,tout1,out,l+8);
185 xor0=tin0;
186 xor1=tin1;
187 }
188
189 iv = &(*ivec)[0];
190 l2c(xor0,iv);
191 l2c(xor1,iv);
192 }
193 tin0=tin1=tout0=tout1=xor0=xor1=0;
194 inW0=inW1=outW0=outW1=0;
195 tin[0]=tin[1]=0;
196 }
197