summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/md5
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/md5')
-rw-r--r--src/lib/libcrypto/md5/Makefile128
-rw-r--r--src/lib/libcrypto/md5/Makefile.ssl127
-rw-r--r--src/lib/libcrypto/md5/asm/md5-sparcv9.S1031
-rw-r--r--src/lib/libcrypto/md5/md5.c127
-rw-r--r--src/lib/libcrypto/md5/md5.h3
-rw-r--r--src/lib/libcrypto/md5/md5_dgst.c2
-rw-r--r--src/lib/libcrypto/md5/md5s.cpp78
-rw-r--r--src/lib/libcrypto/md5/md5test.c136
8 files changed, 1628 insertions, 4 deletions
diff --git a/src/lib/libcrypto/md5/Makefile b/src/lib/libcrypto/md5/Makefile
new file mode 100644
index 0000000000..832446fff2
--- /dev/null
+++ b/src/lib/libcrypto/md5/Makefile
@@ -0,0 +1,128 @@
1#
2# SSLeay/crypto/md5/Makefile
3#
4
5DIR= md5
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=-I.. -I$(TOP) -I../../include
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKEDEPPROG= makedepend
15MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
16MAKEFILE= Makefile
17AR= ar r
18
19MD5_ASM_OBJ=
20
21CFLAGS= $(INCLUDES) $(CFLAG)
22ASFLAGS= $(INCLUDES) $(ASFLAG)
23
24GENERAL=Makefile
25TEST=md5test.c
26APPS=
27
28LIB=$(TOP)/libcrypto.a
29LIBSRC=md5_dgst.c md5_one.c
30LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
31
32SRC= $(LIBSRC)
33
34EXHEADER= md5.h
35HEADER= md5_locl.h $(EXHEADER)
36
37ALL= $(GENERAL) $(SRC) $(HEADER)
38
39top:
40 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
41
42all: lib
43
44lib: $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ)
46 $(RANLIB) $(LIB) || echo Never mind.
47 @touch lib
48
49# elf
50asm/mx86-elf.s: asm/md5-586.pl ../perlasm/x86asm.pl
51 (cd asm; $(PERL) md5-586.pl elf $(CFLAGS) > mx86-elf.s)
52
53# a.out
54asm/mx86-out.o: asm/mx86unix.cpp
55 $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o
56
57# bsdi
58asm/mx86bsdi.o: asm/mx86unix.cpp
59 $(CPP) -DBSDI asm/mx86unix.cpp | sed 's/ :/:/' | as -o asm/mx86bsdi.o
60
61asm/mx86unix.cpp: asm/md5-586.pl ../perlasm/x86asm.pl
62 (cd asm; $(PERL) md5-586.pl cpp >mx86unix.cpp)
63
64asm/md5-sparcv8plus.o: asm/md5-sparcv9.S
65 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
66 -o asm/md5-sparcv8plus.o asm/md5-sparcv9.S
67
68# Old GNU assembler doesn't understand V9 instructions, so we
69# hire /usr/ccs/bin/as to do the job. Note that option is called
70# *-gcc27, but even gcc 2>=8 users may experience similar problem
71# if they didn't bother to upgrade GNU assembler. Such users should
72# not choose this option, but be adviced to *remove* GNU assembler
73# or upgrade it.
74asm/md5-sparcv8plus-gcc27.o: asm/md5-sparcv9.S
75 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -E asm/md5-sparcv9.S | \
76 /usr/ccs/bin/as -xarch=v8plus - -o asm/md5-sparcv8plus-gcc27.o
77
78asm/md5-sparcv9.o: asm/md5-sparcv9.S
79 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
80 -o asm/md5-sparcv9.o asm/md5-sparcv9.S
81
82files:
83 $(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO
84
85links:
86 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
87 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
88 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
89
90install:
91 @headerlist="$(EXHEADER)"; for i in $$headerlist ; \
92 do \
93 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
94 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
95 done;
96
97tags:
98 ctags $(SRC)
99
100tests:
101
102lint:
103 lint -DLINT $(INCLUDES) $(SRC)>fluff
104
105depend:
106 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
107
108dclean:
109 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
110 mv -f Makefile.new $(MAKEFILE)
111
112clean:
113 rm -f asm/mx86unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
114
115# DO NOT DELETE THIS LINE -- make depend depends on it.
116
117md5_dgst.o: ../../include/openssl/bio.h ../../include/openssl/crypto.h
118md5_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/err.h
119md5_dgst.o: ../../include/openssl/fips.h ../../include/openssl/lhash.h
120md5_dgst.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
121md5_dgst.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
122md5_dgst.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
123md5_dgst.o: ../md32_common.h md5_dgst.c md5_locl.h
124md5_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
125md5_one.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
126md5_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
127md5_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
128md5_one.o: md5_one.c
diff --git a/src/lib/libcrypto/md5/Makefile.ssl b/src/lib/libcrypto/md5/Makefile.ssl
new file mode 100644
index 0000000000..2361775a2d
--- /dev/null
+++ b/src/lib/libcrypto/md5/Makefile.ssl
@@ -0,0 +1,127 @@
1#
2# SSLeay/crypto/md5/Makefile
3#
4
5DIR= md5
6TOP= ../..
7CC= cc
8CPP= $(CC) -E
9INCLUDES=-I.. -I$(TOP) -I../../include
10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
13INSTALLTOP=/usr/local/ssl
14MAKE= make -f Makefile.ssl
15MAKEDEPPROG= makedepend
16MAKEDEPEND= $(TOP)/util/domd $(TOP) -MD $(MAKEDEPPROG)
17MAKEFILE= Makefile.ssl
18AR= ar r
19
20MD5_ASM_OBJ=
21
22CFLAGS= $(INCLUDES) $(CFLAG)
23ASFLAGS= $(INCLUDES) $(ASFLAG)
24
25GENERAL=Makefile
26TEST=md5test.c
27APPS=
28
29LIB=$(TOP)/libcrypto.a
30LIBSRC=md5_dgst.c md5_one.c
31LIBOBJ=md5_dgst.o md5_one.o $(MD5_ASM_OBJ)
32
33SRC= $(LIBSRC)
34
35EXHEADER= md5.h
36HEADER= md5_locl.h $(EXHEADER)
37
38ALL= $(GENERAL) $(SRC) $(HEADER)
39
40top:
41 (cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)
42
43all: lib
44
45lib: $(LIBOBJ)
46 $(AR) $(LIB) $(LIBOBJ)
47 $(RANLIB) $(LIB) || echo Never mind.
48 @touch lib
49
50# elf
51asm/mx86-elf.s: asm/md5-586.pl ../perlasm/x86asm.pl
52 (cd asm; $(PERL) md5-586.pl elf $(CFLAGS) > mx86-elf.s)
53
54# a.out
55asm/mx86-out.o: asm/mx86unix.cpp
56 $(CPP) -DOUT asm/mx86unix.cpp | as -o asm/mx86-out.o
57
58# bsdi
59asm/mx86bsdi.o: asm/mx86unix.cpp
60 $(CPP) -DBSDI asm/mx86unix.cpp | sed 's/ :/:/' | as -o asm/mx86bsdi.o
61
62asm/mx86unix.cpp: asm/md5-586.pl ../perlasm/x86asm.pl
63 (cd asm; $(PERL) md5-586.pl cpp >mx86unix.cpp)
64
65asm/md5-sparcv8plus.o: asm/md5-sparcv9.S
66 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
67 -o asm/md5-sparcv8plus.o asm/md5-sparcv9.S
68
69# Old GNU assembler doesn't understand V9 instructions, so we
70# hire /usr/ccs/bin/as to do the job. Note that option is called
71# *-gcc27, but even gcc 2>=8 users may experience similar problem
72# if they didn't bother to upgrade GNU assembler. Such users should
73# not choose this option, but be adviced to *remove* GNU assembler
74# or upgrade it.
75asm/md5-sparcv8plus-gcc27.o: asm/md5-sparcv9.S
76 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -E asm/md5-sparcv9.S | \
77 /usr/ccs/bin/as -xarch=v8plus - -o asm/md5-sparcv8plus-gcc27.o
78
79asm/md5-sparcv9.o: asm/md5-sparcv9.S
80 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
81 -o asm/md5-sparcv9.o asm/md5-sparcv9.S
82
83files:
84 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
85
86links:
87 @sh $(TOP)/util/point.sh Makefile.ssl Makefile
88 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
89 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
90 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
91
92install:
93 @for i in $(EXHEADER) ; \
94 do \
95 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
96 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
97 done;
98
99tags:
100 ctags $(SRC)
101
102tests:
103
104lint:
105 lint -DLINT $(INCLUDES) $(SRC)>fluff
106
107depend:
108 $(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)
109
110dclean:
111 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
112 mv -f Makefile.new $(MAKEFILE)
113
114clean:
115 rm -f asm/mx86unix.cpp asm/*-elf.* *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
116
117# DO NOT DELETE THIS LINE -- make depend depends on it.
118
119md5_dgst.o: ../../include/openssl/e_os2.h ../../include/openssl/md5.h
120md5_dgst.o: ../../include/openssl/opensslconf.h
121md5_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md5_dgst.c
122md5_dgst.o: md5_locl.h
123md5_one.o: ../../include/openssl/crypto.h ../../include/openssl/e_os2.h
124md5_one.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
125md5_one.o: ../../include/openssl/opensslv.h ../../include/openssl/safestack.h
126md5_one.o: ../../include/openssl/stack.h ../../include/openssl/symhacks.h
127md5_one.o: md5_one.c
diff --git a/src/lib/libcrypto/md5/asm/md5-sparcv9.S b/src/lib/libcrypto/md5/asm/md5-sparcv9.S
new file mode 100644
index 0000000000..db45aa4c97
--- /dev/null
+++ b/src/lib/libcrypto/md5/asm/md5-sparcv9.S
@@ -0,0 +1,1031 @@
1.ident "md5-sparcv9.S, Version 1.0"
2.ident "SPARC V9 ISA artwork by Andy Polyakov <appro@fy.chalmers.se>"
3.file "md5-sparcv9.S"
4
5/*
6 * ====================================================================
7 * Copyright (c) 1999 Andy Polyakov <appro@fy.chalmers.se>.
8 *
9 * Rights for redistribution and usage in source and binary forms are
10 * granted as long as above copyright notices are retained. Warranty
11 * of any kind is (of course:-) disclaimed.
12 * ====================================================================
13 */
14
15/*
16 * This is my modest contribution to OpenSSL project (see
17 * http://www.openssl.org/ for more information about it) and is an
18 * assembler implementation of MD5 block hash function. I've hand-coded
19 * this for the sole reason to reach UltraSPARC-specific "load in
20 * little-endian byte order" instruction. This gives up to 15%
21 * performance improvement for cases when input message is aligned at
22 * 32 bits boundary. The module was tested under both 32 *and* 64 bit
23 * kernels. For updates see http://fy.chalmers.se/~appro/hpe/.
24 *
25 * To compile with SC4.x/SC5.x:
26 *
27 * cc -xarch=v[9|8plus] -DOPENSSL_SYSNAME_ULTRASPARC -DMD5_BLOCK_DATA_ORDER \
28 * -c md5-sparcv9.S
29 *
30 * and with gcc:
31 *
32 * gcc -mcpu=ultrasparc -DOPENSSL_SYSNAME_ULTRASPARC -DMD5_BLOCK_DATA_ORDER \
33 * -c md5-sparcv9.S
34 *
35 * or if above fails (it does if you have gas):
36 *
37 * gcc -E -DOPENSSL_SYSNAMEULTRASPARC -DMD5_BLOCK_DATA_ORDER md5_block.sparc.S | \
38 * as -xarch=v8plus /dev/fd/0 -o md5-sparcv9.o
39 */
40
41#include <openssl/e_os2.h>
42
43#define A %o0
44#define B %o1
45#define C %o2
46#define D %o3
47#define T1 %o4
48#define T2 %o5
49
50#define R0 %l0
51#define R1 %l1
52#define R2 %l2
53#define R3 %l3
54#define R4 %l4
55#define R5 %l5
56#define R6 %l6
57#define R7 %l7
58#define R8 %i3
59#define R9 %i4
60#define R10 %i5
61#define R11 %g1
62#define R12 %g2
63#define R13 %g3
64#define RX %g4
65
66#define Aptr %i0+0
67#define Bptr %i0+4
68#define Cptr %i0+8
69#define Dptr %i0+12
70
71#define Aval R5 /* those not used at the end of the last round */
72#define Bval R6
73#define Cval R7
74#define Dval R8
75
76#if defined(MD5_BLOCK_DATA_ORDER)
77# if defined(OPENSSL_SYSNAME_ULTRASPARC)
78# define LOAD lda
79# define X(i) [%i1+i*4]%asi
80# define md5_block md5_block_asm_data_order_aligned
81# define ASI_PRIMARY_LITTLE 0x88
82# else
83# error "MD5_BLOCK_DATA_ORDER is supported only on UltraSPARC!"
84# endif
85#else
86# define LOAD ld
87# define X(i) [%i1+i*4]
88# define md5_block md5_block_asm_host_order
89#endif
90
91.section ".text",#alloc,#execinstr
92
93#if defined(__SUNPRO_C) && defined(__sparcv9)
94 /* They've said -xarch=v9 at command line */
95 .register %g2,#scratch
96 .register %g3,#scratch
97# define FRAME -192
98#elif defined(__GNUC__) && defined(__arch64__)
99 /* They've said -m64 at command line */
100 .register %g2,#scratch
101 .register %g3,#scratch
102# define FRAME -192
103#else
104# define FRAME -96
105#endif
106
107.align 32
108
109.global md5_block
110md5_block:
111 save %sp,FRAME,%sp
112
113 ld [Dptr],D
114 ld [Cptr],C
115 ld [Bptr],B
116 ld [Aptr],A
117#ifdef ASI_PRIMARY_LITTLE
118 rd %asi,%o7 ! How dare I? Well, I just do:-)
119 wr %g0,ASI_PRIMARY_LITTLE,%asi
120#endif
121 LOAD X(0),R0
122
123.Lmd5_block_loop:
124
125!!!!!!!!Round 0
126
127 xor C,D,T1
128 sethi %hi(0xd76aa478),T2
129 and T1,B,T1
130 or T2,%lo(0xd76aa478),T2 !=
131 xor T1,D,T1
132 add T1,R0,T1
133 LOAD X(1),R1
134 add T1,T2,T1 !=
135 add A,T1,A
136 sll A,7,T2
137 srl A,32-7,A
138 or A,T2,A !=
139 xor B,C,T1
140 add A,B,A
141
142 sethi %hi(0xe8c7b756),T2
143 and T1,A,T1 !=
144 or T2,%lo(0xe8c7b756),T2
145 xor T1,C,T1
146 LOAD X(2),R2
147 add T1,R1,T1 !=
148 add T1,T2,T1
149 add D,T1,D
150 sll D,12,T2
151 srl D,32-12,D !=
152 or D,T2,D
153 xor A,B,T1
154 add D,A,D
155
156 sethi %hi(0x242070db),T2 !=
157 and T1,D,T1
158 or T2,%lo(0x242070db),T2
159 xor T1,B,T1
160 add T1,R2,T1 !=
161 LOAD X(3),R3
162 add T1,T2,T1
163 add C,T1,C
164 sll C,17,T2 !=
165 srl C,32-17,C
166 or C,T2,C
167 xor D,A,T1
168 add C,D,C !=
169
170 sethi %hi(0xc1bdceee),T2
171 and T1,C,T1
172 or T2,%lo(0xc1bdceee),T2
173 xor T1,A,T1 !=
174 add T1,R3,T1
175 LOAD X(4),R4
176 add T1,T2,T1
177 add B,T1,B !=
178 sll B,22,T2
179 srl B,32-22,B
180 or B,T2,B
181 xor C,D,T1 !=
182 add B,C,B
183
184 sethi %hi(0xf57c0faf),T2
185 and T1,B,T1
186 or T2,%lo(0xf57c0faf),T2 !=
187 xor T1,D,T1
188 add T1,R4,T1
189 LOAD X(5),R5
190 add T1,T2,T1 !=
191 add A,T1,A
192 sll A,7,T2
193 srl A,32-7,A
194 or A,T2,A !=
195 xor B,C,T1
196 add A,B,A
197
198 sethi %hi(0x4787c62a),T2
199 and T1,A,T1 !=
200 or T2,%lo(0x4787c62a),T2
201 xor T1,C,T1
202 LOAD X(6),R6
203 add T1,R5,T1 !=
204 add T1,T2,T1
205 add D,T1,D
206 sll D,12,T2
207 srl D,32-12,D !=
208 or D,T2,D
209 xor A,B,T1
210 add D,A,D
211
212 sethi %hi(0xa8304613),T2 !=
213 and T1,D,T1
214 or T2,%lo(0xa8304613),T2
215 xor T1,B,T1
216 add T1,R6,T1 !=
217 LOAD X(7),R7
218 add T1,T2,T1
219 add C,T1,C
220 sll C,17,T2 !=
221 srl C,32-17,C
222 or C,T2,C
223 xor D,A,T1
224 add C,D,C !=
225
226 sethi %hi(0xfd469501),T2
227 and T1,C,T1
228 or T2,%lo(0xfd469501),T2
229 xor T1,A,T1 !=
230 add T1,R7,T1
231 LOAD X(8),R8
232 add T1,T2,T1
233 add B,T1,B !=
234 sll B,22,T2
235 srl B,32-22,B
236 or B,T2,B
237 xor C,D,T1 !=
238 add B,C,B
239
240 sethi %hi(0x698098d8),T2
241 and T1,B,T1
242 or T2,%lo(0x698098d8),T2 !=
243 xor T1,D,T1
244 add T1,R8,T1
245 LOAD X(9),R9
246 add T1,T2,T1 !=
247 add A,T1,A
248 sll A,7,T2
249 srl A,32-7,A
250 or A,T2,A !=
251 xor B,C,T1
252 add A,B,A
253
254 sethi %hi(0x8b44f7af),T2
255 and T1,A,T1 !=
256 or T2,%lo(0x8b44f7af),T2
257 xor T1,C,T1
258 LOAD X(10),R10
259 add T1,R9,T1 !=
260 add T1,T2,T1
261 add D,T1,D
262 sll D,12,T2
263 srl D,32-12,D !=
264 or D,T2,D
265 xor A,B,T1
266 add D,A,D
267
268 sethi %hi(0xffff5bb1),T2 !=
269 and T1,D,T1
270 or T2,%lo(0xffff5bb1),T2
271 xor T1,B,T1
272 add T1,R10,T1 !=
273 LOAD X(11),R11
274 add T1,T2,T1
275 add C,T1,C
276 sll C,17,T2 !=
277 srl C,32-17,C
278 or C,T2,C
279 xor D,A,T1
280 add C,D,C !=
281
282 sethi %hi(0x895cd7be),T2
283 and T1,C,T1
284 or T2,%lo(0x895cd7be),T2
285 xor T1,A,T1 !=
286 add T1,R11,T1
287 LOAD X(12),R12
288 add T1,T2,T1
289 add B,T1,B !=
290 sll B,22,T2
291 srl B,32-22,B
292 or B,T2,B
293 xor C,D,T1 !=
294 add B,C,B
295
296 sethi %hi(0x6b901122),T2
297 and T1,B,T1
298 or T2,%lo(0x6b901122),T2 !=
299 xor T1,D,T1
300 add T1,R12,T1
301 LOAD X(13),R13
302 add T1,T2,T1 !=
303 add A,T1,A
304 sll A,7,T2
305 srl A,32-7,A
306 or A,T2,A !=
307 xor B,C,T1
308 add A,B,A
309
310 sethi %hi(0xfd987193),T2
311 and T1,A,T1 !=
312 or T2,%lo(0xfd987193),T2
313 xor T1,C,T1
314 LOAD X(14),RX
315 add T1,R13,T1 !=
316 add T1,T2,T1
317 add D,T1,D
318 sll D,12,T2
319 srl D,32-12,D !=
320 or D,T2,D
321 xor A,B,T1
322 add D,A,D
323
324 sethi %hi(0xa679438e),T2 !=
325 and T1,D,T1
326 or T2,%lo(0xa679438e),T2
327 xor T1,B,T1
328 add T1,RX,T1 !=
329 LOAD X(15),RX
330 add T1,T2,T1
331 add C,T1,C
332 sll C,17,T2 !=
333 srl C,32-17,C
334 or C,T2,C
335 xor D,A,T1
336 add C,D,C !=
337
338 sethi %hi(0x49b40821),T2
339 and T1,C,T1
340 or T2,%lo(0x49b40821),T2
341 xor T1,A,T1 !=
342 add T1,RX,T1
343 !pre-LOADed X(1),R1
344 add T1,T2,T1
345 add B,T1,B
346 sll B,22,T2 !=
347 srl B,32-22,B
348 or B,T2,B
349 add B,C,B
350
351!!!!!!!!Round 1
352
353 xor B,C,T1 !=
354 sethi %hi(0xf61e2562),T2
355 and T1,D,T1
356 or T2,%lo(0xf61e2562),T2
357 xor T1,C,T1 !=
358 add T1,R1,T1
359 !pre-LOADed X(6),R6
360 add T1,T2,T1
361 add A,T1,A
362 sll A,5,T2 !=
363 srl A,32-5,A
364 or A,T2,A
365 add A,B,A
366
367 xor A,B,T1 !=
368 sethi %hi(0xc040b340),T2
369 and T1,C,T1
370 or T2,%lo(0xc040b340),T2
371 xor T1,B,T1 !=
372 add T1,R6,T1
373 !pre-LOADed X(11),R11
374 add T1,T2,T1
375 add D,T1,D
376 sll D,9,T2 !=
377 srl D,32-9,D
378 or D,T2,D
379 add D,A,D
380
381 xor D,A,T1 !=
382 sethi %hi(0x265e5a51),T2
383 and T1,B,T1
384 or T2,%lo(0x265e5a51),T2
385 xor T1,A,T1 !=
386 add T1,R11,T1
387 !pre-LOADed X(0),R0
388 add T1,T2,T1
389 add C,T1,C
390 sll C,14,T2 !=
391 srl C,32-14,C
392 or C,T2,C
393 add C,D,C
394
395 xor C,D,T1 !=
396 sethi %hi(0xe9b6c7aa),T2
397 and T1,A,T1
398 or T2,%lo(0xe9b6c7aa),T2
399 xor T1,D,T1 !=
400 add T1,R0,T1
401 !pre-LOADed X(5),R5
402 add T1,T2,T1
403 add B,T1,B
404 sll B,20,T2 !=
405 srl B,32-20,B
406 or B,T2,B
407 add B,C,B
408
409 xor B,C,T1 !=
410 sethi %hi(0xd62f105d),T2
411 and T1,D,T1
412 or T2,%lo(0xd62f105d),T2
413 xor T1,C,T1 !=
414 add T1,R5,T1
415 !pre-LOADed X(10),R10
416 add T1,T2,T1
417 add A,T1,A
418 sll A,5,T2 !=
419 srl A,32-5,A
420 or A,T2,A
421 add A,B,A
422
423 xor A,B,T1 !=
424 sethi %hi(0x02441453),T2
425 and T1,C,T1
426 or T2,%lo(0x02441453),T2
427 xor T1,B,T1 !=
428 add T1,R10,T1
429 LOAD X(15),RX
430 add T1,T2,T1
431 add D,T1,D !=
432 sll D,9,T2
433 srl D,32-9,D
434 or D,T2,D
435 add D,A,D !=
436
437 xor D,A,T1
438 sethi %hi(0xd8a1e681),T2
439 and T1,B,T1
440 or T2,%lo(0xd8a1e681),T2 !=
441 xor T1,A,T1
442 add T1,RX,T1
443 !pre-LOADed X(4),R4
444 add T1,T2,T1
445 add C,T1,C !=
446 sll C,14,T2
447 srl C,32-14,C
448 or C,T2,C
449 add C,D,C !=
450
451 xor C,D,T1
452 sethi %hi(0xe7d3fbc8),T2
453 and T1,A,T1
454 or T2,%lo(0xe7d3fbc8),T2 !=
455 xor T1,D,T1
456 add T1,R4,T1
457 !pre-LOADed X(9),R9
458 add T1,T2,T1
459 add B,T1,B !=
460 sll B,20,T2
461 srl B,32-20,B
462 or B,T2,B
463 add B,C,B !=
464
465 xor B,C,T1
466 sethi %hi(0x21e1cde6),T2
467 and T1,D,T1
468 or T2,%lo(0x21e1cde6),T2 !=
469 xor T1,C,T1
470 add T1,R9,T1
471 LOAD X(14),RX
472 add T1,T2,T1 !=
473 add A,T1,A
474 sll A,5,T2
475 srl A,32-5,A
476 or A,T2,A !=
477 add A,B,A
478
479 xor A,B,T1
480 sethi %hi(0xc33707d6),T2
481 and T1,C,T1 !=
482 or T2,%lo(0xc33707d6),T2
483 xor T1,B,T1
484 add T1,RX,T1
485 !pre-LOADed X(3),R3
486 add T1,T2,T1 !=
487 add D,T1,D
488 sll D,9,T2
489 srl D,32-9,D
490 or D,T2,D !=
491 add D,A,D
492
493 xor D,A,T1
494 sethi %hi(0xf4d50d87),T2
495 and T1,B,T1 !=
496 or T2,%lo(0xf4d50d87),T2
497 xor T1,A,T1
498 add T1,R3,T1
499 !pre-LOADed X(8),R8
500 add T1,T2,T1 !=
501 add C,T1,C
502 sll C,14,T2
503 srl C,32-14,C
504 or C,T2,C !=
505 add C,D,C
506
507 xor C,D,T1
508 sethi %hi(0x455a14ed),T2
509 and T1,A,T1 !=
510 or T2,%lo(0x455a14ed),T2
511 xor T1,D,T1
512 add T1,R8,T1
513 !pre-LOADed X(13),R13
514 add T1,T2,T1 !=
515 add B,T1,B
516 sll B,20,T2
517 srl B,32-20,B
518 or B,T2,B !=
519 add B,C,B
520
521 xor B,C,T1
522 sethi %hi(0xa9e3e905),T2
523 and T1,D,T1 !=
524 or T2,%lo(0xa9e3e905),T2
525 xor T1,C,T1
526 add T1,R13,T1
527 !pre-LOADed X(2),R2
528 add T1,T2,T1 !=
529 add A,T1,A
530 sll A,5,T2
531 srl A,32-5,A
532 or A,T2,A !=
533 add A,B,A
534
535 xor A,B,T1
536 sethi %hi(0xfcefa3f8),T2
537 and T1,C,T1 !=
538 or T2,%lo(0xfcefa3f8),T2
539 xor T1,B,T1
540 add T1,R2,T1
541 !pre-LOADed X(7),R7
542 add T1,T2,T1 !=
543 add D,T1,D
544 sll D,9,T2
545 srl D,32-9,D
546 or D,T2,D !=
547 add D,A,D
548
549 xor D,A,T1
550 sethi %hi(0x676f02d9),T2
551 and T1,B,T1 !=
552 or T2,%lo(0x676f02d9),T2
553 xor T1,A,T1
554 add T1,R7,T1
555 !pre-LOADed X(12),R12
556 add T1,T2,T1 !=
557 add C,T1,C
558 sll C,14,T2
559 srl C,32-14,C
560 or C,T2,C !=
561 add C,D,C
562
563 xor C,D,T1
564 sethi %hi(0x8d2a4c8a),T2
565 and T1,A,T1 !=
566 or T2,%lo(0x8d2a4c8a),T2
567 xor T1,D,T1
568 add T1,R12,T1
569 !pre-LOADed X(5),R5
570 add T1,T2,T1 !=
571 add B,T1,B
572 sll B,20,T2
573 srl B,32-20,B
574 or B,T2,B !=
575 add B,C,B
576
577!!!!!!!!Round 2
578
579 xor B,C,T1
580 sethi %hi(0xfffa3942),T2
581 xor T1,D,T1 !=
582 or T2,%lo(0xfffa3942),T2
583 add T1,R5,T1
584 !pre-LOADed X(8),R8
585 add T1,T2,T1
586 add A,T1,A !=
587 sll A,4,T2
588 srl A,32-4,A
589 or A,T2,A
590 add A,B,A !=
591
592 xor A,B,T1
593 sethi %hi(0x8771f681),T2
594 xor T1,C,T1
595 or T2,%lo(0x8771f681),T2 !=
596 add T1,R8,T1
597 !pre-LOADed X(11),R11
598 add T1,T2,T1
599 add D,T1,D
600 sll D,11,T2 !=
601 srl D,32-11,D
602 or D,T2,D
603 add D,A,D
604
605 xor D,A,T1 !=
606 sethi %hi(0x6d9d6122),T2
607 xor T1,B,T1
608 or T2,%lo(0x6d9d6122),T2
609 add T1,R11,T1 !=
610 LOAD X(14),RX
611 add T1,T2,T1
612 add C,T1,C
613 sll C,16,T2 !=
614 srl C,32-16,C
615 or C,T2,C
616 add C,D,C
617
618 xor C,D,T1 !=
619 sethi %hi(0xfde5380c),T2
620 xor T1,A,T1
621 or T2,%lo(0xfde5380c),T2
622 add T1,RX,T1 !=
623 !pre-LOADed X(1),R1
624 add T1,T2,T1
625 add B,T1,B
626 sll B,23,T2
627 srl B,32-23,B !=
628 or B,T2,B
629 add B,C,B
630
631 xor B,C,T1
632 sethi %hi(0xa4beea44),T2 !=
633 xor T1,D,T1
634 or T2,%lo(0xa4beea44),T2
635 add T1,R1,T1
636 !pre-LOADed X(4),R4
637 add T1,T2,T1 !=
638 add A,T1,A
639 sll A,4,T2
640 srl A,32-4,A
641 or A,T2,A !=
642 add A,B,A
643
644 xor A,B,T1
645 sethi %hi(0x4bdecfa9),T2
646 xor T1,C,T1 !=
647 or T2,%lo(0x4bdecfa9),T2
648 add T1,R4,T1
649 !pre-LOADed X(7),R7
650 add T1,T2,T1
651 add D,T1,D !=
652 sll D,11,T2
653 srl D,32-11,D
654 or D,T2,D
655 add D,A,D !=
656
657 xor D,A,T1
658 sethi %hi(0xf6bb4b60),T2
659 xor T1,B,T1
660 or T2,%lo(0xf6bb4b60),T2 !=
661 add T1,R7,T1
662 !pre-LOADed X(10),R10
663 add T1,T2,T1
664 add C,T1,C
665 sll C,16,T2 !=
666 srl C,32-16,C
667 or C,T2,C
668 add C,D,C
669
670 xor C,D,T1 !=
671 sethi %hi(0xbebfbc70),T2
672 xor T1,A,T1
673 or T2,%lo(0xbebfbc70),T2
674 add T1,R10,T1 !=
675 !pre-LOADed X(13),R13
676 add T1,T2,T1
677 add B,T1,B
678 sll B,23,T2
679 srl B,32-23,B !=
680 or B,T2,B
681 add B,C,B
682
683 xor B,C,T1
684 sethi %hi(0x289b7ec6),T2 !=
685 xor T1,D,T1
686 or T2,%lo(0x289b7ec6),T2
687 add T1,R13,T1
688 !pre-LOADed X(0),R0
689 add T1,T2,T1 !=
690 add A,T1,A
691 sll A,4,T2
692 srl A,32-4,A
693 or A,T2,A !=
694 add A,B,A
695
696 xor A,B,T1
697 sethi %hi(0xeaa127fa),T2
698 xor T1,C,T1 !=
699 or T2,%lo(0xeaa127fa),T2
700 add T1,R0,T1
701 !pre-LOADed X(3),R3
702 add T1,T2,T1
703 add D,T1,D !=
704 sll D,11,T2
705 srl D,32-11,D
706 or D,T2,D
707 add D,A,D !=
708
709 xor D,A,T1
710 sethi %hi(0xd4ef3085),T2
711 xor T1,B,T1
712 or T2,%lo(0xd4ef3085),T2 !=
713 add T1,R3,T1
714 !pre-LOADed X(6),R6
715 add T1,T2,T1
716 add C,T1,C
717 sll C,16,T2 !=
718 srl C,32-16,C
719 or C,T2,C
720 add C,D,C
721
722 xor C,D,T1 !=
723 sethi %hi(0x04881d05),T2
724 xor T1,A,T1
725 or T2,%lo(0x04881d05),T2
726 add T1,R6,T1 !=
727 !pre-LOADed X(9),R9
728 add T1,T2,T1
729 add B,T1,B
730 sll B,23,T2
731 srl B,32-23,B !=
732 or B,T2,B
733 add B,C,B
734
735 xor B,C,T1
736 sethi %hi(0xd9d4d039),T2 !=
737 xor T1,D,T1
738 or T2,%lo(0xd9d4d039),T2
739 add T1,R9,T1
740 !pre-LOADed X(12),R12
741 add T1,T2,T1 !=
742 add A,T1,A
743 sll A,4,T2
744 srl A,32-4,A
745 or A,T2,A !=
746 add A,B,A
747
748 xor A,B,T1
749 sethi %hi(0xe6db99e5),T2
750 xor T1,C,T1 !=
751 or T2,%lo(0xe6db99e5),T2
752 add T1,R12,T1
753 LOAD X(15),RX
754 add T1,T2,T1 !=
755 add D,T1,D
756 sll D,11,T2
757 srl D,32-11,D
758 or D,T2,D !=
759 add D,A,D
760
761 xor D,A,T1
762 sethi %hi(0x1fa27cf8),T2
763 xor T1,B,T1 !=
764 or T2,%lo(0x1fa27cf8),T2
765 add T1,RX,T1
766 !pre-LOADed X(2),R2
767 add T1,T2,T1
768 add C,T1,C !=
769 sll C,16,T2
770 srl C,32-16,C
771 or C,T2,C
772 add C,D,C !=
773
774 xor C,D,T1
775 sethi %hi(0xc4ac5665),T2
776 xor T1,A,T1
777 or T2,%lo(0xc4ac5665),T2 !=
778 add T1,R2,T1
779 !pre-LOADed X(0),R0
780 add T1,T2,T1
781 add B,T1,B
782 sll B,23,T2 !=
783 srl B,32-23,B
784 or B,T2,B
785 add B,C,B
786
787!!!!!!!!Round 3
788
789 orn B,D,T1 !=
790 sethi %hi(0xf4292244),T2
791 xor T1,C,T1
792 or T2,%lo(0xf4292244),T2
793 add T1,R0,T1 !=
794 !pre-LOADed X(7),R7
795 add T1,T2,T1
796 add A,T1,A
797 sll A,6,T2
798 srl A,32-6,A !=
799 or A,T2,A
800 add A,B,A
801
802 orn A,C,T1
803 sethi %hi(0x432aff97),T2 !=
804 xor T1,B,T1
805 or T2,%lo(0x432aff97),T2
806 LOAD X(14),RX
807 add T1,R7,T1 !=
808 add T1,T2,T1
809 add D,T1,D
810 sll D,10,T2
811 srl D,32-10,D !=
812 or D,T2,D
813 add D,A,D
814
815 orn D,B,T1
816 sethi %hi(0xab9423a7),T2 !=
817 xor T1,A,T1
818 or T2,%lo(0xab9423a7),T2
819 add T1,RX,T1
820 !pre-LOADed X(5),R5
821 add T1,T2,T1 !=
822 add C,T1,C
823 sll C,15,T2
824 srl C,32-15,C
825 or C,T2,C !=
826 add C,D,C
827
828 orn C,A,T1
829 sethi %hi(0xfc93a039),T2
830 xor T1,D,T1 !=
831 or T2,%lo(0xfc93a039),T2
832 add T1,R5,T1
833 !pre-LOADed X(12),R12
834 add T1,T2,T1
835 add B,T1,B !=
836 sll B,21,T2
837 srl B,32-21,B
838 or B,T2,B
839 add B,C,B !=
840
841 orn B,D,T1
842 sethi %hi(0x655b59c3),T2
843 xor T1,C,T1
844 or T2,%lo(0x655b59c3),T2 !=
845 add T1,R12,T1
846 !pre-LOADed X(3),R3
847 add T1,T2,T1
848 add A,T1,A
849 sll A,6,T2 !=
850 srl A,32-6,A
851 or A,T2,A
852 add A,B,A
853
854 orn A,C,T1 !=
855 sethi %hi(0x8f0ccc92),T2
856 xor T1,B,T1
857 or T2,%lo(0x8f0ccc92),T2
858 add T1,R3,T1 !=
859 !pre-LOADed X(10),R10
860 add T1,T2,T1
861 add D,T1,D
862 sll D,10,T2
863 srl D,32-10,D !=
864 or D,T2,D
865 add D,A,D
866
867 orn D,B,T1
868 sethi %hi(0xffeff47d),T2 !=
869 xor T1,A,T1
870 or T2,%lo(0xffeff47d),T2
871 add T1,R10,T1
872 !pre-LOADed X(1),R1
873 add T1,T2,T1 !=
874 add C,T1,C
875 sll C,15,T2
876 srl C,32-15,C
877 or C,T2,C !=
878 add C,D,C
879
880 orn C,A,T1
881 sethi %hi(0x85845dd1),T2
882 xor T1,D,T1 !=
883 or T2,%lo(0x85845dd1),T2
884 add T1,R1,T1
885 !pre-LOADed X(8),R8
886 add T1,T2,T1
887 add B,T1,B !=
888 sll B,21,T2
889 srl B,32-21,B
890 or B,T2,B
891 add B,C,B !=
892
893 orn B,D,T1
894 sethi %hi(0x6fa87e4f),T2
895 xor T1,C,T1
896 or T2,%lo(0x6fa87e4f),T2 !=
897 add T1,R8,T1
898 LOAD X(15),RX
899 add T1,T2,T1
900 add A,T1,A !=
901 sll A,6,T2
902 srl A,32-6,A
903 or A,T2,A
904 add A,B,A !=
905
906 orn A,C,T1
907 sethi %hi(0xfe2ce6e0),T2
908 xor T1,B,T1
909 or T2,%lo(0xfe2ce6e0),T2 !=
910 add T1,RX,T1
911 !pre-LOADed X(6),R6
912 add T1,T2,T1
913 add D,T1,D
914 sll D,10,T2 !=
915 srl D,32-10,D
916 or D,T2,D
917 add D,A,D
918
919 orn D,B,T1 !=
920 sethi %hi(0xa3014314),T2
921 xor T1,A,T1
922 or T2,%lo(0xa3014314),T2
923 add T1,R6,T1 !=
924 !pre-LOADed X(13),R13
925 add T1,T2,T1
926 add C,T1,C
927 sll C,15,T2
928 srl C,32-15,C !=
929 or C,T2,C
930 add C,D,C
931
932 orn C,A,T1
933 sethi %hi(0x4e0811a1),T2 !=
934 xor T1,D,T1
935 or T2,%lo(0x4e0811a1),T2
936 !pre-LOADed X(4),R4
937 ld [Aptr],Aval
938 add T1,R13,T1 !=
939 add T1,T2,T1
940 add B,T1,B
941 sll B,21,T2
942 srl B,32-21,B !=
943 or B,T2,B
944 add B,C,B
945
946 orn B,D,T1
947 sethi %hi(0xf7537e82),T2 !=
948 xor T1,C,T1
949 or T2,%lo(0xf7537e82),T2
950 !pre-LOADed X(11),R11
951 ld [Dptr],Dval
952 add T1,R4,T1 !=
953 add T1,T2,T1
954 add A,T1,A
955 sll A,6,T2
956 srl A,32-6,A !=
957 or A,T2,A
958 add A,B,A
959
960 orn A,C,T1
961 sethi %hi(0xbd3af235),T2 !=
962 xor T1,B,T1
963 or T2,%lo(0xbd3af235),T2
964 !pre-LOADed X(2),R2
965 ld [Cptr],Cval
966 add T1,R11,T1 !=
967 add T1,T2,T1
968 add D,T1,D
969 sll D,10,T2
970 srl D,32-10,D !=
971 or D,T2,D
972 add D,A,D
973
974 orn D,B,T1
975 sethi %hi(0x2ad7d2bb),T2 !=
976 xor T1,A,T1
977 or T2,%lo(0x2ad7d2bb),T2
978 !pre-LOADed X(9),R9
979 ld [Bptr],Bval
980 add T1,R2,T1 !=
981 add Aval,A,Aval
982 add T1,T2,T1
983 st Aval,[Aptr]
984 add C,T1,C !=
985 sll C,15,T2
986 add Dval,D,Dval
987 srl C,32-15,C
988 or C,T2,C !=
989 st Dval,[Dptr]
990 add C,D,C
991
992 orn C,A,T1
993 sethi %hi(0xeb86d391),T2 !=
994 xor T1,D,T1
995 or T2,%lo(0xeb86d391),T2
996 add T1,R9,T1
997 !pre-LOADed X(0),R0
998 mov Aval,A !=
999 add T1,T2,T1
1000 mov Dval,D
1001 add B,T1,B
1002 sll B,21,T2 !=
1003 add Cval,C,Cval
1004 srl B,32-21,B
1005 st Cval,[Cptr]
1006 or B,T2,B !=
1007 add B,C,B
1008
1009 deccc %i2
1010 mov Cval,C
1011 add B,Bval,B !=
1012 inc 64,%i1
1013 nop
1014 st B,[Bptr]
1015 nop !=
1016
1017#ifdef OPENSSL_SYSNAME_ULTRASPARC
1018 bg,a,pt %icc,.Lmd5_block_loop
1019#else
1020 bg,a .Lmd5_block_loop
1021#endif
1022 LOAD X(0),R0
1023
1024#ifdef ASI_PRIMARY_LITTLE
1025 wr %g0,%o7,%asi
1026#endif
1027 ret
1028 restore %g0,0,%o0
1029
1030.type md5_block,#function
1031.size md5_block,(.-md5_block)
diff --git a/src/lib/libcrypto/md5/md5.c b/src/lib/libcrypto/md5/md5.c
new file mode 100644
index 0000000000..563733abc5
--- /dev/null
+++ b/src/lib/libcrypto/md5/md5.c
@@ -0,0 +1,127 @@
1/* crypto/md5/md5.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 <openssl/md5.h>
62
63#define BUFSIZE 1024*16
64
65void do_fp(FILE *f);
66void pt(unsigned char *md);
67#if !defined(_OSD_POSIX) && !defined(__DJGPP__)
68int read(int, void *, unsigned int);
69#endif
70
71int main(int argc, char **argv)
72 {
73 int i,err=0;
74 FILE *IN;
75
76 if (argc == 1)
77 {
78 do_fp(stdin);
79 }
80 else
81 {
82 for (i=1; i<argc; i++)
83 {
84 IN=fopen(argv[i],"r");
85 if (IN == NULL)
86 {
87 perror(argv[i]);
88 err++;
89 continue;
90 }
91 printf("MD5(%s)= ",argv[i]);
92 do_fp(IN);
93 fclose(IN);
94 }
95 }
96 exit(err);
97 }
98
99void do_fp(FILE *f)
100 {
101 MD5_CTX c;
102 unsigned char md[MD5_DIGEST_LENGTH];
103 int fd;
104 int i;
105 static unsigned char buf[BUFSIZE];
106
107 fd=fileno(f);
108 MD5_Init(&c);
109 for (;;)
110 {
111 i=read(fd,buf,BUFSIZE);
112 if (i <= 0) break;
113 MD5_Update(&c,buf,(unsigned long)i);
114 }
115 MD5_Final(&(md[0]),&c);
116 pt(md);
117 }
118
119void pt(unsigned char *md)
120 {
121 int i;
122
123 for (i=0; i<MD5_DIGEST_LENGTH; i++)
124 printf("%02x",md[i]);
125 printf("\n");
126 }
127
diff --git a/src/lib/libcrypto/md5/md5.h b/src/lib/libcrypto/md5/md5.h
index c663dd1816..a252e02115 100644
--- a/src/lib/libcrypto/md5/md5.h
+++ b/src/lib/libcrypto/md5/md5.h
@@ -104,9 +104,6 @@ typedef struct MD5state_st
104 int num; 104 int num;
105 } MD5_CTX; 105 } MD5_CTX;
106 106
107#ifdef OPENSSL_FIPS
108int private_MD5_Init(MD5_CTX *c);
109#endif
110int MD5_Init(MD5_CTX *c); 107int MD5_Init(MD5_CTX *c);
111int MD5_Update(MD5_CTX *c, const void *data, unsigned long len); 108int MD5_Update(MD5_CTX *c, const void *data, unsigned long len);
112int MD5_Final(unsigned char *md, MD5_CTX *c); 109int MD5_Final(unsigned char *md, MD5_CTX *c);
diff --git a/src/lib/libcrypto/md5/md5_dgst.c b/src/lib/libcrypto/md5/md5_dgst.c
index 54b33c6509..9c7abc3697 100644
--- a/src/lib/libcrypto/md5/md5_dgst.c
+++ b/src/lib/libcrypto/md5/md5_dgst.c
@@ -70,7 +70,7 @@ const char *MD5_version="MD5" OPENSSL_VERSION_PTEXT;
70#define INIT_DATA_C (unsigned long)0x98badcfeL 70#define INIT_DATA_C (unsigned long)0x98badcfeL
71#define INIT_DATA_D (unsigned long)0x10325476L 71#define INIT_DATA_D (unsigned long)0x10325476L
72 72
73FIPS_NON_FIPS_MD_Init(MD5) 73int MD5_Init(MD5_CTX *c)
74 { 74 {
75 c->A=INIT_DATA_A; 75 c->A=INIT_DATA_A;
76 c->B=INIT_DATA_B; 76 c->B=INIT_DATA_B;
diff --git a/src/lib/libcrypto/md5/md5s.cpp b/src/lib/libcrypto/md5/md5s.cpp
new file mode 100644
index 0000000000..dd343fd4e6
--- /dev/null
+++ b/src/lib/libcrypto/md5/md5s.cpp
@@ -0,0 +1,78 @@
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/md5.h>
36
37extern "C" {
38void md5_block_x86(MD5_CTX *ctx, unsigned char *buffer,int num);
39}
40
41void main(int argc,char *argv[])
42 {
43 unsigned char buffer[64*256];
44 MD5_CTX ctx;
45 unsigned long s1,s2,e1,e2;
46 unsigned char k[16];
47 unsigned long data[2];
48 unsigned char iv[8];
49 int i,num=0,numm;
50 int j=0;
51
52 if (argc >= 2)
53 num=atoi(argv[1]);
54
55 if (num == 0) num=16;
56 if (num > 250) num=16;
57 numm=num+2;
58 num*=64;
59 numm*=64;
60
61 for (j=0; j<6; j++)
62 {
63 for (i=0; i<10; i++) /**/
64 {
65 md5_block_x86(&ctx,buffer,numm);
66 GetTSC(s1);
67 md5_block_x86(&ctx,buffer,numm);
68 GetTSC(e1);
69 GetTSC(s2);
70 md5_block_x86(&ctx,buffer,num);
71 GetTSC(e2);
72 md5_block_x86(&ctx,buffer,num);
73 }
74 printf("md5 (%d bytes) %d %d (%.2f)\n",num,
75 e1-s1,e2-s2,(double)((e1-s1)-(e2-s2))/2);
76 }
77 }
78
diff --git a/src/lib/libcrypto/md5/md5test.c b/src/lib/libcrypto/md5/md5test.c
new file mode 100644
index 0000000000..bfd62629ed
--- /dev/null
+++ b/src/lib/libcrypto/md5/md5test.c
@@ -0,0 +1,136 @@
1/* crypto/md5/md5test.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 <string.h>
61#include <stdlib.h>
62
63#include "../e_os.h"
64
65#ifdef OPENSSL_NO_MD5
66int main(int argc, char *argv[])
67{
68 printf("No MD5 support\n");
69 return(0);
70}
71#else
72#include <openssl/evp.h>
73#include <openssl/md5.h>
74
75static char *test[]={
76 "",
77 "a",
78 "abc",
79 "message digest",
80 "abcdefghijklmnopqrstuvwxyz",
81 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
82 "12345678901234567890123456789012345678901234567890123456789012345678901234567890",
83 NULL,
84 };
85
86static char *ret[]={
87 "d41d8cd98f00b204e9800998ecf8427e",
88 "0cc175b9c0f1b6a831c399e269772661",
89 "900150983cd24fb0d6963f7d28e17f72",
90 "f96b697d7cb7938d525a2f31aaf161d0",
91 "c3fcd3d76192e4007dfb496cca67e13b",
92 "d174ab98d277d9f5a5611c2c9f419d9f",
93 "57edf4a22be3c955ac49da2e2107b67a",
94 };
95
96static char *pt(unsigned char *md);
97int main(int argc, char *argv[])
98 {
99 int i,err=0;
100 unsigned char **P,**R;
101 char *p;
102 unsigned char md[MD5_DIGEST_LENGTH];
103
104 P=(unsigned char **)test;
105 R=(unsigned char **)ret;
106 i=1;
107 while (*P != NULL)
108 {
109 EVP_Digest(&(P[0][0]),(unsigned long)strlen((char *)*P),md,NULL,EVP_md5(), NULL);
110 p=pt(md);
111 if (strcmp(p,(char *)*R) != 0)
112 {
113 printf("error calculating MD5 on '%s'\n",*P);
114 printf("got %s instead of %s\n",p,*R);
115 err++;
116 }
117 else
118 printf("test %d ok\n",i);
119 i++;
120 R++;
121 P++;
122 }
123 EXIT(err);
124 return(0);
125 }
126
127static char *pt(unsigned char *md)
128 {
129 int i;
130 static char buf[80];
131
132 for (i=0; i<MD5_DIGEST_LENGTH; i++)
133 sprintf(&(buf[i*2]),"%02x",md[i]);
134 return(buf);
135 }
136#endif