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/Makefile.ssl58
-rw-r--r--src/lib/libcrypto/md5/Makefile.uni3
-rw-r--r--src/lib/libcrypto/md5/asm/m5-win32.asm55
-rw-r--r--src/lib/libcrypto/md5/asm/md5-586.pl40
-rw-r--r--src/lib/libcrypto/md5/asm/md5-sparcv9.S1029
-rw-r--r--src/lib/libcrypto/md5/asm/mx86unix.cpp730
-rw-r--r--src/lib/libcrypto/md5/md5.c18
-rw-r--r--src/lib/libcrypto/md5/md5.h51
-rw-r--r--src/lib/libcrypto/md5/md5_dgst.c395
-rw-r--r--src/lib/libcrypto/md5/md5_locl.h160
-rw-r--r--src/lib/libcrypto/md5/md5_one.c28
-rw-r--r--src/lib/libcrypto/md5/md5s.cpp2
-rw-r--r--src/lib/libcrypto/md5/md5test.c23
13 files changed, 1397 insertions, 1195 deletions
diff --git a/src/lib/libcrypto/md5/Makefile.ssl b/src/lib/libcrypto/md5/Makefile.ssl
index 47e1ce05ca..29ae1b7458 100644
--- a/src/lib/libcrypto/md5/Makefile.ssl
+++ b/src/lib/libcrypto/md5/Makefile.ssl
@@ -8,15 +8,18 @@ CC= cc
8CPP= $(CC) -E 8CPP= $(CC) -E
9INCLUDES= 9INCLUDES=
10CFLAG=-g 10CFLAG=-g
11INSTALL_PREFIX=
12OPENSSLDIR= /usr/local/ssl
11INSTALLTOP=/usr/local/ssl 13INSTALLTOP=/usr/local/ssl
12MAKE= make -f Makefile.ssl 14MAKE= make -f Makefile.ssl
13MAKEDEPEND= makedepend -f Makefile.ssl 15MAKEDEPEND= $(TOP)/util/domd $(TOP)
14MAKEFILE= Makefile.ssl 16MAKEFILE= Makefile.ssl
15AR= ar r 17AR= ar r
16 18
17MD5_ASM_OBJ= 19MD5_ASM_OBJ=
18 20
19CFLAGS= $(INCLUDES) $(CFLAG) 21CFLAGS= $(INCLUDES) $(CFLAG)
22ASFLAGS=$(CFLAGS)
20 23
21GENERAL=Makefile 24GENERAL=Makefile
22TEST=md5test.c 25TEST=md5test.c
@@ -40,7 +43,7 @@ all: lib
40 43
41lib: $(LIBOBJ) 44lib: $(LIBOBJ)
42 $(AR) $(LIB) $(LIBOBJ) 45 $(AR) $(LIB) $(LIBOBJ)
43 sh $(TOP)/util/ranlib.sh $(LIB) 46 $(RANLIB) $(LIB)
44 @touch lib 47 @touch lib
45 48
46# elf 49# elf
@@ -59,26 +62,43 @@ asm/mx86-out.o: asm/mx86unix.cpp
59 62
60# bsdi 63# bsdi
61asm/mx86bsdi.o: asm/mx86unix.cpp 64asm/mx86bsdi.o: asm/mx86unix.cpp
62 $(CPP) -DBSDI asm/mx86unix.cpp | as -o asm/mx86bsdi.o 65 $(CPP) -DBSDI asm/mx86unix.cpp | sed 's/ :/:/' | as -o asm/mx86bsdi.o
63 66
64asm/mx86unix.cpp: 67asm/mx86unix.cpp: asm/md5-586.pl
65 (cd asm; perl md5-586.pl cpp >mx86unix.cpp) 68 (cd asm; $(PERL) md5-586.pl cpp >mx86unix.cpp)
69
70asm/md5-sparcv8plus.o: asm/md5-sparcv9.S
71 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
72 -o asm/md5-sparcv8plus.o asm/md5-sparcv9.S
73
74# Old GNU assembler doesn't understand V9 instructions, so we
75# hire /usr/ccs/bin/as to do the job. Note that option is called
76# *-gcc27, but even gcc 2>=8 users may experience similar problem
77# if they didn't bother to upgrade GNU assembler. Such users should
78# not choose this option, but be adviced to *remove* GNU assembler
79# or upgrade it.
80sm/md5-sparcv8plus-gcc27.o: asm/md5-sparcv9.S
81 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -E asm/md5-sparcv9.S | \
82 /usr/ccs/bin/as -xarch=v8plus - -o asm/md5-sparcv8plus-gcc27.o
83
84asm/md5-sparcv9.o: asm/md5-sparcv9.S
85 $(CC) $(ASFLAGS) -DMD5_BLOCK_DATA_ORDER -c \
86 -o asm/md5-sparcv9.o asm/md5-sparcv9.S
66 87
67files: 88files:
68 perl $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO 89 $(PERL) $(TOP)/util/files.pl Makefile.ssl >> $(TOP)/MINFO
69 90
70links: 91links:
71 /bin/rm -f Makefile 92 @$(TOP)/util/point.sh Makefile.ssl Makefile
72 $(TOP)/util/point.sh Makefile.ssl Makefile ; 93 @$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
73 $(TOP)/util/mklink.sh ../../include $(EXHEADER) 94 @$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
74 $(TOP)/util/mklink.sh ../../test $(TEST) 95 @$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)
75 $(TOP)/util/mklink.sh ../../apps $(APPS)
76 96
77install: 97install:
78 @for i in $(EXHEADER) ; \ 98 @for i in $(EXHEADER) ; \
79 do \ 99 do \
80 (cp $$i $(INSTALLTOP)/include/$$i; \ 100 (cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
81 chmod 644 $(INSTALLTOP)/include/$$i ); \ 101 chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
82 done; 102 done;
83 103
84tags: 104tags:
@@ -90,15 +110,17 @@ lint:
90 lint -DLINT $(INCLUDES) $(SRC)>fluff 110 lint -DLINT $(INCLUDES) $(SRC)>fluff
91 111
92depend: 112depend:
93 $(MAKEDEPEND) $(INCLUDES) $(PROGS) $(LIBSRC) 113 $(MAKEDEPEND) $(INCLUDES) $(DEPFLAG) $(PROGS) $(LIBSRC)
94 114
95dclean: 115dclean:
96 perl -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new 116 $(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
97 mv -f Makefile.new $(MAKEFILE) 117 mv -f Makefile.new $(MAKEFILE)
98 118
99clean: 119clean:
100 /bin/rm -f *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff 120 rm -f asm/mx86unix.cpp *.o asm/*.o *.obj lib tags core .pure .nfs* *.old *.bak fluff
101
102errors:
103 121
104# DO NOT DELETE THIS LINE -- make depend depends on it. 122# DO NOT DELETE THIS LINE -- make depend depends on it.
123
124md5_dgst.o: ../../include/openssl/md5.h ../../include/openssl/opensslconf.h
125md5_dgst.o: ../../include/openssl/opensslv.h ../md32_common.h md5_locl.h
126md5_one.o: ../../include/openssl/md5.h
diff --git a/src/lib/libcrypto/md5/Makefile.uni b/src/lib/libcrypto/md5/Makefile.uni
index 54685712db..d21c72f3ea 100644
--- a/src/lib/libcrypto/md5/Makefile.uni
+++ b/src/lib/libcrypto/md5/Makefile.uni
@@ -19,6 +19,7 @@ MAKE= make
19MAKEDEPEND= makedepend 19MAKEDEPEND= makedepend
20MAKEFILE= Makefile.uni 20MAKEFILE= Makefile.uni
21AR= ar r 21AR= ar r
22RANLIB= ranlib
22 23
23MD5_ASM_OBJ= 24MD5_ASM_OBJ=
24 25
@@ -43,7 +44,7 @@ all: $(LIB) $(TEST) $(APPS)
43 44
44$(LIB): $(LIBOBJ) 45$(LIB): $(LIBOBJ)
45 $(AR) $(LIB) $(LIBOBJ) 46 $(AR) $(LIB) $(LIBOBJ)
46 sh $(TOP)/ranlib.sh $(LIB) 47 $(RANLIB) $(LIB)
47 48
48# elf 49# elf
49asm/mx86-elf.o: asm/mx86unix.cpp 50asm/mx86-elf.o: asm/mx86unix.cpp
diff --git a/src/lib/libcrypto/md5/asm/m5-win32.asm b/src/lib/libcrypto/md5/asm/m5-win32.asm
index c2081da746..51f5f17ca3 100644
--- a/src/lib/libcrypto/md5/asm/m5-win32.asm
+++ b/src/lib/libcrypto/md5/asm/m5-win32.asm
@@ -8,15 +8,16 @@
8 .386 8 .386
9.model FLAT 9.model FLAT
10_TEXT SEGMENT 10_TEXT SEGMENT
11PUBLIC _md5_block_x86 11PUBLIC _md5_block_asm_host_order
12 12
13_md5_block_x86 PROC NEAR 13_md5_block_asm_host_order PROC NEAR
14 push esi 14 push esi
15 push edi 15 push edi
16 mov edi, DWORD PTR 12[esp] 16 mov edi, DWORD PTR 12[esp]
17 mov esi, DWORD PTR 16[esp] 17 mov esi, DWORD PTR 16[esp]
18 mov ecx, DWORD PTR 20[esp] 18 mov ecx, DWORD PTR 20[esp]
19 push ebp 19 push ebp
20 shl ecx, 6
20 push ebx 21 push ebx
21 add ecx, esi 22 add ecx, esi
22 sub ecx, 64 23 sub ecx, 64
@@ -34,161 +35,161 @@ L000start:
34 xor edi, edx 35 xor edi, edx
35 and edi, ebx 36 and edi, ebx
36 lea eax, DWORD PTR 3614090360[ebp*1+eax] 37 lea eax, DWORD PTR 3614090360[ebp*1+eax]
37 mov ebp, DWORD PTR 4[esi]
38 xor edi, edx 38 xor edi, edx
39 add eax, edi 39 add eax, edi
40 mov edi, ebx 40 mov edi, ebx
41 rol eax, 7 41 rol eax, 7
42 mov ebp, DWORD PTR 4[esi]
42 add eax, ebx 43 add eax, ebx
43 ; R0 1 44 ; R0 1
44 xor edi, ecx 45 xor edi, ecx
45 and edi, eax 46 and edi, eax
46 lea edx, DWORD PTR 3905402710[ebp*1+edx] 47 lea edx, DWORD PTR 3905402710[ebp*1+edx]
47 mov ebp, DWORD PTR 8[esi]
48 xor edi, ecx 48 xor edi, ecx
49 add edx, edi 49 add edx, edi
50 mov edi, eax 50 mov edi, eax
51 rol edx, 12 51 rol edx, 12
52 mov ebp, DWORD PTR 8[esi]
52 add edx, eax 53 add edx, eax
53 ; R0 2 54 ; R0 2
54 xor edi, ebx 55 xor edi, ebx
55 and edi, edx 56 and edi, edx
56 lea ecx, DWORD PTR 606105819[ebp*1+ecx] 57 lea ecx, DWORD PTR 606105819[ebp*1+ecx]
57 mov ebp, DWORD PTR 12[esi]
58 xor edi, ebx 58 xor edi, ebx
59 add ecx, edi 59 add ecx, edi
60 mov edi, edx 60 mov edi, edx
61 rol ecx, 17 61 rol ecx, 17
62 mov ebp, DWORD PTR 12[esi]
62 add ecx, edx 63 add ecx, edx
63 ; R0 3 64 ; R0 3
64 xor edi, eax 65 xor edi, eax
65 and edi, ecx 66 and edi, ecx
66 lea ebx, DWORD PTR 3250441966[ebp*1+ebx] 67 lea ebx, DWORD PTR 3250441966[ebp*1+ebx]
67 mov ebp, DWORD PTR 16[esi]
68 xor edi, eax 68 xor edi, eax
69 add ebx, edi 69 add ebx, edi
70 mov edi, ecx 70 mov edi, ecx
71 rol ebx, 22 71 rol ebx, 22
72 mov ebp, DWORD PTR 16[esi]
72 add ebx, ecx 73 add ebx, ecx
73 ; R0 4 74 ; R0 4
74 xor edi, edx 75 xor edi, edx
75 and edi, ebx 76 and edi, ebx
76 lea eax, DWORD PTR 4118548399[ebp*1+eax] 77 lea eax, DWORD PTR 4118548399[ebp*1+eax]
77 mov ebp, DWORD PTR 20[esi]
78 xor edi, edx 78 xor edi, edx
79 add eax, edi 79 add eax, edi
80 mov edi, ebx 80 mov edi, ebx
81 rol eax, 7 81 rol eax, 7
82 mov ebp, DWORD PTR 20[esi]
82 add eax, ebx 83 add eax, ebx
83 ; R0 5 84 ; R0 5
84 xor edi, ecx 85 xor edi, ecx
85 and edi, eax 86 and edi, eax
86 lea edx, DWORD PTR 1200080426[ebp*1+edx] 87 lea edx, DWORD PTR 1200080426[ebp*1+edx]
87 mov ebp, DWORD PTR 24[esi]
88 xor edi, ecx 88 xor edi, ecx
89 add edx, edi 89 add edx, edi
90 mov edi, eax 90 mov edi, eax
91 rol edx, 12 91 rol edx, 12
92 mov ebp, DWORD PTR 24[esi]
92 add edx, eax 93 add edx, eax
93 ; R0 6 94 ; R0 6
94 xor edi, ebx 95 xor edi, ebx
95 and edi, edx 96 and edi, edx
96 lea ecx, DWORD PTR 2821735955[ebp*1+ecx] 97 lea ecx, DWORD PTR 2821735955[ebp*1+ecx]
97 mov ebp, DWORD PTR 28[esi]
98 xor edi, ebx 98 xor edi, ebx
99 add ecx, edi 99 add ecx, edi
100 mov edi, edx 100 mov edi, edx
101 rol ecx, 17 101 rol ecx, 17
102 mov ebp, DWORD PTR 28[esi]
102 add ecx, edx 103 add ecx, edx
103 ; R0 7 104 ; R0 7
104 xor edi, eax 105 xor edi, eax
105 and edi, ecx 106 and edi, ecx
106 lea ebx, DWORD PTR 4249261313[ebp*1+ebx] 107 lea ebx, DWORD PTR 4249261313[ebp*1+ebx]
107 mov ebp, DWORD PTR 32[esi]
108 xor edi, eax 108 xor edi, eax
109 add ebx, edi 109 add ebx, edi
110 mov edi, ecx 110 mov edi, ecx
111 rol ebx, 22 111 rol ebx, 22
112 mov ebp, DWORD PTR 32[esi]
112 add ebx, ecx 113 add ebx, ecx
113 ; R0 8 114 ; R0 8
114 xor edi, edx 115 xor edi, edx
115 and edi, ebx 116 and edi, ebx
116 lea eax, DWORD PTR 1770035416[ebp*1+eax] 117 lea eax, DWORD PTR 1770035416[ebp*1+eax]
117 mov ebp, DWORD PTR 36[esi]
118 xor edi, edx 118 xor edi, edx
119 add eax, edi 119 add eax, edi
120 mov edi, ebx 120 mov edi, ebx
121 rol eax, 7 121 rol eax, 7
122 mov ebp, DWORD PTR 36[esi]
122 add eax, ebx 123 add eax, ebx
123 ; R0 9 124 ; R0 9
124 xor edi, ecx 125 xor edi, ecx
125 and edi, eax 126 and edi, eax
126 lea edx, DWORD PTR 2336552879[ebp*1+edx] 127 lea edx, DWORD PTR 2336552879[ebp*1+edx]
127 mov ebp, DWORD PTR 40[esi]
128 xor edi, ecx 128 xor edi, ecx
129 add edx, edi 129 add edx, edi
130 mov edi, eax 130 mov edi, eax
131 rol edx, 12 131 rol edx, 12
132 mov ebp, DWORD PTR 40[esi]
132 add edx, eax 133 add edx, eax
133 ; R0 10 134 ; R0 10
134 xor edi, ebx 135 xor edi, ebx
135 and edi, edx 136 and edi, edx
136 lea ecx, DWORD PTR 4294925233[ebp*1+ecx] 137 lea ecx, DWORD PTR 4294925233[ebp*1+ecx]
137 mov ebp, DWORD PTR 44[esi]
138 xor edi, ebx 138 xor edi, ebx
139 add ecx, edi 139 add ecx, edi
140 mov edi, edx 140 mov edi, edx
141 rol ecx, 17 141 rol ecx, 17
142 mov ebp, DWORD PTR 44[esi]
142 add ecx, edx 143 add ecx, edx
143 ; R0 11 144 ; R0 11
144 xor edi, eax 145 xor edi, eax
145 and edi, ecx 146 and edi, ecx
146 lea ebx, DWORD PTR 2304563134[ebp*1+ebx] 147 lea ebx, DWORD PTR 2304563134[ebp*1+ebx]
147 mov ebp, DWORD PTR 48[esi]
148 xor edi, eax 148 xor edi, eax
149 add ebx, edi 149 add ebx, edi
150 mov edi, ecx 150 mov edi, ecx
151 rol ebx, 22 151 rol ebx, 22
152 mov ebp, DWORD PTR 48[esi]
152 add ebx, ecx 153 add ebx, ecx
153 ; R0 12 154 ; R0 12
154 xor edi, edx 155 xor edi, edx
155 and edi, ebx 156 and edi, ebx
156 lea eax, DWORD PTR 1804603682[ebp*1+eax] 157 lea eax, DWORD PTR 1804603682[ebp*1+eax]
157 mov ebp, DWORD PTR 52[esi]
158 xor edi, edx 158 xor edi, edx
159 add eax, edi 159 add eax, edi
160 mov edi, ebx 160 mov edi, ebx
161 rol eax, 7 161 rol eax, 7
162 mov ebp, DWORD PTR 52[esi]
162 add eax, ebx 163 add eax, ebx
163 ; R0 13 164 ; R0 13
164 xor edi, ecx 165 xor edi, ecx
165 and edi, eax 166 and edi, eax
166 lea edx, DWORD PTR 4254626195[ebp*1+edx] 167 lea edx, DWORD PTR 4254626195[ebp*1+edx]
167 mov ebp, DWORD PTR 56[esi]
168 xor edi, ecx 168 xor edi, ecx
169 add edx, edi 169 add edx, edi
170 mov edi, eax 170 mov edi, eax
171 rol edx, 12 171 rol edx, 12
172 mov ebp, DWORD PTR 56[esi]
172 add edx, eax 173 add edx, eax
173 ; R0 14 174 ; R0 14
174 xor edi, ebx 175 xor edi, ebx
175 and edi, edx 176 and edi, edx
176 lea ecx, DWORD PTR 2792965006[ebp*1+ecx] 177 lea ecx, DWORD PTR 2792965006[ebp*1+ecx]
177 mov ebp, DWORD PTR 60[esi]
178 xor edi, ebx 178 xor edi, ebx
179 add ecx, edi 179 add ecx, edi
180 mov edi, edx 180 mov edi, edx
181 rol ecx, 17 181 rol ecx, 17
182 mov ebp, DWORD PTR 60[esi]
182 add ecx, edx 183 add ecx, edx
183 ; R0 15 184 ; R0 15
184 xor edi, eax 185 xor edi, eax
185 and edi, ecx 186 and edi, ecx
186 lea ebx, DWORD PTR 1236535329[ebp*1+ebx] 187 lea ebx, DWORD PTR 1236535329[ebp*1+ebx]
187 mov ebp, DWORD PTR 4[esi]
188 xor edi, eax 188 xor edi, eax
189 add ebx, edi 189 add ebx, edi
190 mov edi, ecx 190 mov edi, ecx
191 rol ebx, 22 191 rol ebx, 22
192 mov ebp, DWORD PTR 4[esi]
192 add ebx, ecx 193 add ebx, ecx
193 ; 194 ;
194 ; R1 section 195 ; R1 section
@@ -359,8 +360,8 @@ L000start:
359 xor edi, ebx 360 xor edi, ebx
360 lea eax, DWORD PTR 4294588738[ebp*1+eax] 361 lea eax, DWORD PTR 4294588738[ebp*1+eax]
361 add eax, edi 362 add eax, edi
362 mov ebp, DWORD PTR 32[esi]
363 rol eax, 4 363 rol eax, 4
364 mov ebp, DWORD PTR 32[esi]
364 mov edi, ebx 365 mov edi, ebx
365 ; R2 33 366 ; R2 33
366 lea edx, DWORD PTR 2272392833[ebp*1+edx] 367 lea edx, DWORD PTR 2272392833[ebp*1+edx]
@@ -377,8 +378,8 @@ L000start:
377 xor edi, edx 378 xor edi, edx
378 lea ecx, DWORD PTR 1839030562[ebp*1+ecx] 379 lea ecx, DWORD PTR 1839030562[ebp*1+ecx]
379 add ecx, edi 380 add ecx, edi
380 mov ebp, DWORD PTR 56[esi]
381 rol ecx, 16 381 rol ecx, 16
382 mov ebp, DWORD PTR 56[esi]
382 mov edi, edx 383 mov edi, edx
383 ; R2 35 384 ; R2 35
384 lea ebx, DWORD PTR 4259657740[ebp*1+ebx] 385 lea ebx, DWORD PTR 4259657740[ebp*1+ebx]
@@ -395,8 +396,8 @@ L000start:
395 xor edi, ebx 396 xor edi, ebx
396 lea eax, DWORD PTR 2763975236[ebp*1+eax] 397 lea eax, DWORD PTR 2763975236[ebp*1+eax]
397 add eax, edi 398 add eax, edi
398 mov ebp, DWORD PTR 16[esi]
399 rol eax, 4 399 rol eax, 4
400 mov ebp, DWORD PTR 16[esi]
400 mov edi, ebx 401 mov edi, ebx
401 ; R2 37 402 ; R2 37
402 lea edx, DWORD PTR 1272893353[ebp*1+edx] 403 lea edx, DWORD PTR 1272893353[ebp*1+edx]
@@ -413,8 +414,8 @@ L000start:
413 xor edi, edx 414 xor edi, edx
414 lea ecx, DWORD PTR 4139469664[ebp*1+ecx] 415 lea ecx, DWORD PTR 4139469664[ebp*1+ecx]
415 add ecx, edi 416 add ecx, edi
416 mov ebp, DWORD PTR 40[esi]
417 rol ecx, 16 417 rol ecx, 16
418 mov ebp, DWORD PTR 40[esi]
418 mov edi, edx 419 mov edi, edx
419 ; R2 39 420 ; R2 39
420 lea ebx, DWORD PTR 3200236656[ebp*1+ebx] 421 lea ebx, DWORD PTR 3200236656[ebp*1+ebx]
@@ -431,8 +432,8 @@ L000start:
431 xor edi, ebx 432 xor edi, ebx
432 lea eax, DWORD PTR 681279174[ebp*1+eax] 433 lea eax, DWORD PTR 681279174[ebp*1+eax]
433 add eax, edi 434 add eax, edi
434 mov ebp, DWORD PTR [esi]
435 rol eax, 4 435 rol eax, 4
436 mov ebp, DWORD PTR [esi]
436 mov edi, ebx 437 mov edi, ebx
437 ; R2 41 438 ; R2 41
438 lea edx, DWORD PTR 3936430074[ebp*1+edx] 439 lea edx, DWORD PTR 3936430074[ebp*1+edx]
@@ -449,8 +450,8 @@ L000start:
449 xor edi, edx 450 xor edi, edx
450 lea ecx, DWORD PTR 3572445317[ebp*1+ecx] 451 lea ecx, DWORD PTR 3572445317[ebp*1+ecx]
451 add ecx, edi 452 add ecx, edi
452 mov ebp, DWORD PTR 24[esi]
453 rol ecx, 16 453 rol ecx, 16
454 mov ebp, DWORD PTR 24[esi]
454 mov edi, edx 455 mov edi, edx
455 ; R2 43 456 ; R2 43
456 lea ebx, DWORD PTR 76029189[ebp*1+ebx] 457 lea ebx, DWORD PTR 76029189[ebp*1+ebx]
@@ -467,8 +468,8 @@ L000start:
467 xor edi, ebx 468 xor edi, ebx
468 lea eax, DWORD PTR 3654602809[ebp*1+eax] 469 lea eax, DWORD PTR 3654602809[ebp*1+eax]
469 add eax, edi 470 add eax, edi
470 mov ebp, DWORD PTR 48[esi]
471 rol eax, 4 471 rol eax, 4
472 mov ebp, DWORD PTR 48[esi]
472 mov edi, ebx 473 mov edi, ebx
473 ; R2 45 474 ; R2 45
474 lea edx, DWORD PTR 3873151461[ebp*1+edx] 475 lea edx, DWORD PTR 3873151461[ebp*1+edx]
@@ -485,8 +486,8 @@ L000start:
485 xor edi, edx 486 xor edi, edx
486 lea ecx, DWORD PTR 530742520[ebp*1+ecx] 487 lea ecx, DWORD PTR 530742520[ebp*1+ecx]
487 add ecx, edi 488 add ecx, edi
488 mov ebp, DWORD PTR 8[esi]
489 rol ecx, 16 489 rol ecx, 16
490 mov ebp, DWORD PTR 8[esi]
490 mov edi, edx 491 mov edi, edx
491 ; R2 47 492 ; R2 47
492 lea ebx, DWORD PTR 3299628645[ebp*1+ebx] 493 lea ebx, DWORD PTR 3299628645[ebp*1+ebx]
@@ -681,6 +682,6 @@ L000start:
681 pop edi 682 pop edi
682 pop esi 683 pop esi
683 ret 684 ret
684_md5_block_x86 ENDP 685_md5_block_asm_host_order ENDP
685_TEXT ENDS 686_TEXT ENDS
686END 687END
diff --git a/src/lib/libcrypto/md5/asm/md5-586.pl b/src/lib/libcrypto/md5/asm/md5-586.pl
index 2c7fb7dd98..5fc6a205ce 100644
--- a/src/lib/libcrypto/md5/asm/md5-586.pl
+++ b/src/lib/libcrypto/md5/asm/md5-586.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2 2
3# Normal is the 3# Normal is the
4# md5_block_x86(MD5_CTX *c, ULONG *X); 4# md5_block_x86(MD5_CTX *c, ULONG *X);
@@ -29,7 +29,7 @@ $X="esi";
29 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9, # R3 29 0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9, # R3
30 ); 30 );
31 31
32&md5_block("md5_block_x86"); 32&md5_block("md5_block_asm_host_order");
33&asm_finish(); 33&asm_finish();
34 34
35sub Np 35sub Np
@@ -44,7 +44,7 @@ sub R0
44 local($pos,$a,$b,$c,$d,$K,$ki,$s,$t)=@_; 44 local($pos,$a,$b,$c,$d,$K,$ki,$s,$t)=@_;
45 45
46 &mov($tmp1,$C) if $pos < 0; 46 &mov($tmp1,$C) if $pos < 0;
47 &mov($tmp2,&DWP($xo[$ki]*4,$K,"",0)) if $pos < 0; # very first one 47 &mov($tmp2,&DWP($xo[$ki]*4,$K,"",0)) if $pos < 0; # very first one
48 48
49 # body proper 49 # body proper
50 50
@@ -54,7 +54,6 @@ sub R0
54 &and($tmp1,$b); # F function - part 3 54 &and($tmp1,$b); # F function - part 3
55 &lea($a,&DWP($t,$a,$tmp2,1)); 55 &lea($a,&DWP($t,$a,$tmp2,1));
56 56
57 &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
58 &xor($tmp1,$d); # F function - part 4 57 &xor($tmp1,$d); # F function - part 4
59 58
60 &add($a,$tmp1); 59 &add($a,$tmp1);
@@ -62,8 +61,10 @@ sub R0
62 &mov($tmp1,&Np($c)) if $pos == 1; # next tmp1 for R1 61 &mov($tmp1,&Np($c)) if $pos == 1; # next tmp1 for R1
63 62
64 &rotl($a,$s); 63 &rotl($a,$s);
65 &add($a,$b);
66 64
65 &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
66
67 &add($a,$b);
67 } 68 }
68 69
69sub R1 70sub R1
@@ -100,16 +101,16 @@ if (($n & 1) == 0)
100 # make sure to do 'D' first, not 'B', else we clash with 101 # make sure to do 'D' first, not 'B', else we clash with
101 # the last add from the previous round. 102 # the last add from the previous round.
102 103
103 &xor($tmp1,$d); # H function - part 2 104 &xor($tmp1,$d); # H function - part 2
104 105
105 &xor($tmp1,$b); # H function - part 3 106 &xor($tmp1,$b); # H function - part 3
106 &lea($a,&DWP($t,$a,$tmp2,1)); 107 &lea($a,&DWP($t,$a,$tmp2,1));
107 108
108 &add($a,$tmp1); 109 &add($a,$tmp1);
109 &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0));
110 110
111 &rotl($a,$s); 111 &rotl($a,$s);
112 112
113 &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0));
113 &mov($tmp1,&Np($c)); 114 &mov($tmp1,&Np($c));
114 } 115 }
115else 116else
@@ -118,17 +119,17 @@ else
118 # make sure to do 'D' first, not 'B', else we clash with 119 # make sure to do 'D' first, not 'B', else we clash with
119 # the last add from the previous round. 120 # the last add from the previous round.
120 121
121 &lea($a,&DWP($t,$a,$tmp2,1)); 122 &lea($a,&DWP($t,$a,$tmp2,1));
122 123
123 &add($b,$c); # MOVED FORWARD 124 &add($b,$c); # MOVED FORWARD
124 &xor($tmp1,$d); # H function - part 2 125 &xor($tmp1,$d); # H function - part 2
125 126
126 &xor($tmp1,$b); # H function - part 3 127 &xor($tmp1,$b); # H function - part 3
127 &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2); 128 &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if ($pos != 2);
128 129
129 &add($a,$tmp1); 130 &add($a,$tmp1);
130 &mov($tmp1,&Np($c)) if $pos < 1; # H function - part 1 131 &mov($tmp1,&Np($c)) if $pos < 1; # H function - part 1
131 &mov($tmp1,-1) if $pos == 1; # I function - part 1 132 &mov($tmp1,-1) if $pos == 1; # I function - part 1
132 133
133 &rotl($a,$s); 134 &rotl($a,$s);
134 135
@@ -146,21 +147,21 @@ sub R3
146 &xor($tmp1,$d) if $pos < 0; # I function - part 2 147 &xor($tmp1,$d) if $pos < 0; # I function - part 2
147 148
148 &or($tmp1,$b); # I function - part 3 149 &or($tmp1,$b); # I function - part 3
149 &lea($a,&DWP($t,$a,$tmp2,1)); 150 &lea($a,&DWP($t,$a,$tmp2,1));
150 151
151 &xor($tmp1,$c); # I function - part 4 152 &xor($tmp1,$c); # I function - part 4
152 &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if $pos != 2; # load X/k value 153 &mov($tmp2,&DWP($xo[$ki+1]*4,$K,"",0)) if $pos != 2; # load X/k value
153 &mov($tmp2,&wparam(0)) if $pos == 2; 154 &mov($tmp2,&wparam(0)) if $pos == 2;
154 155
155 &add($a,$tmp1); 156 &add($a,$tmp1);
156 &mov($tmp1,-1) if $pos < 1; # H function - part 1 157 &mov($tmp1,-1) if $pos < 1; # H function - part 1
157 &add($K,64) if $pos >=1 && !$normal; 158 &add($K,64) if $pos >=1 && !$normal;
158 159
159 &rotl($a,$s); 160 &rotl($a,$s);
160 161
161 &xor($tmp1,&Np($d)) if $pos <= 0; # I function - part = first time 162 &xor($tmp1,&Np($d)) if $pos <= 0; # I function - part = first time
162 &mov($tmp1,&DWP( 0,$tmp2,"",0)) if $pos > 0; 163 &mov($tmp1,&DWP( 0,$tmp2,"",0)) if $pos > 0;
163 &add($a,$b); 164 &add($a,$b);
164 } 165 }
165 166
166 167
@@ -182,6 +183,7 @@ sub md5_block
182 &mov($X, &wparam(1)); # esi 183 &mov($X, &wparam(1)); # esi
183 &mov($C, &wparam(2)); 184 &mov($C, &wparam(2));
184 &push("ebp"); 185 &push("ebp");
186 &shl($C, 6);
185 &push("ebx"); 187 &push("ebx");
186 &add($C, $X); # offset we end at 188 &add($C, $X); # offset we end at
187 &sub($C, 64); 189 &sub($C, 64);
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..ca4257f134
--- /dev/null
+++ b/src/lib/libcrypto/md5/asm/md5-sparcv9.S
@@ -0,0 +1,1029 @@
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] -DULTRASPARC -DMD5_BLOCK_DATA_ORDER \
28 * -c md5-sparcv9.S
29 *
30 * and with gcc:
31 *
32 * gcc -mcpu=ultrasparc -DULTRASPARC -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 -DULTRASPARC -DMD5_BLOCK_DATA_ORDER md5_block.sparc.S | \
38 * as -xarch=v8plus /dev/fd/0 -o md5-sparcv9.o
39 */
40
41#define A %o0
42#define B %o1
43#define C %o2
44#define D %o3
45#define T1 %o4
46#define T2 %o5
47
48#define R0 %l0
49#define R1 %l1
50#define R2 %l2
51#define R3 %l3
52#define R4 %l4
53#define R5 %l5
54#define R6 %l6
55#define R7 %l7
56#define R8 %i3
57#define R9 %i4
58#define R10 %i5
59#define R11 %g1
60#define R12 %g2
61#define R13 %g3
62#define RX %g4
63
64#define Aptr %i0+0
65#define Bptr %i0+4
66#define Cptr %i0+8
67#define Dptr %i0+12
68
69#define Aval R5 /* those not used at the end of the last round */
70#define Bval R6
71#define Cval R7
72#define Dval R8
73
74#if defined(MD5_BLOCK_DATA_ORDER)
75# if defined(ULTRASPARC)
76# define LOAD lda
77# define X(i) [%i1+i*4]%asi
78# define md5_block md5_block_asm_data_order_aligned
79# define ASI_PRIMARY_LITTLE 0x88
80# else
81# error "MD5_BLOCK_DATA_ORDER is supported only on UltraSPARC!"
82# endif
83#else
84# define LOAD ld
85# define X(i) [%i1+i*4]
86# define md5_block md5_block_asm_host_order
87#endif
88
89.section ".text",#alloc,#execinstr
90
91#if defined(__SUNPRO_C) && defined(__sparcv9)
92 /* They've said -xarch=v9 at command line */
93 .register %g2,#scratch
94 .register %g3,#scratch
95# define FRAME -192
96#elif defined(__GNUC__) && defined(__arch64__)
97 /* They've said -m64 at command line */
98 .register %g2,#scratch
99 .register %g3,#scratch
100# define FRAME -192
101#else
102# define FRAME -96
103#endif
104
105.align 32
106
107.global md5_block
108md5_block:
109 save %sp,FRAME,%sp
110
111 ld [Dptr],D
112 ld [Cptr],C
113 ld [Bptr],B
114 ld [Aptr],A
115#ifdef ASI_PRIMARY_LITTLE
116 rd %asi,%o7 ! How dare I? Well, I just do:-)
117 wr %g0,ASI_PRIMARY_LITTLE,%asi
118#endif
119 LOAD X(0),R0
120
121.Lmd5_block_loop:
122
123!!!!!!!!Round 0
124
125 xor C,D,T1
126 sethi %hi(0xd76aa478),T2
127 and T1,B,T1
128 or T2,%lo(0xd76aa478),T2 !=
129 xor T1,D,T1
130 add T1,R0,T1
131 LOAD X(1),R1
132 add T1,T2,T1 !=
133 add A,T1,A
134 sll A,7,T2
135 srl A,32-7,A
136 or A,T2,A !=
137 xor B,C,T1
138 add A,B,A
139
140 sethi %hi(0xe8c7b756),T2
141 and T1,A,T1 !=
142 or T2,%lo(0xe8c7b756),T2
143 xor T1,C,T1
144 LOAD X(2),R2
145 add T1,R1,T1 !=
146 add T1,T2,T1
147 add D,T1,D
148 sll D,12,T2
149 srl D,32-12,D !=
150 or D,T2,D
151 xor A,B,T1
152 add D,A,D
153
154 sethi %hi(0x242070db),T2 !=
155 and T1,D,T1
156 or T2,%lo(0x242070db),T2
157 xor T1,B,T1
158 add T1,R2,T1 !=
159 LOAD X(3),R3
160 add T1,T2,T1
161 add C,T1,C
162 sll C,17,T2 !=
163 srl C,32-17,C
164 or C,T2,C
165 xor D,A,T1
166 add C,D,C !=
167
168 sethi %hi(0xc1bdceee),T2
169 and T1,C,T1
170 or T2,%lo(0xc1bdceee),T2
171 xor T1,A,T1 !=
172 add T1,R3,T1
173 LOAD X(4),R4
174 add T1,T2,T1
175 add B,T1,B !=
176 sll B,22,T2
177 srl B,32-22,B
178 or B,T2,B
179 xor C,D,T1 !=
180 add B,C,B
181
182 sethi %hi(0xf57c0faf),T2
183 and T1,B,T1
184 or T2,%lo(0xf57c0faf),T2 !=
185 xor T1,D,T1
186 add T1,R4,T1
187 LOAD X(5),R5
188 add T1,T2,T1 !=
189 add A,T1,A
190 sll A,7,T2
191 srl A,32-7,A
192 or A,T2,A !=
193 xor B,C,T1
194 add A,B,A
195
196 sethi %hi(0x4787c62a),T2
197 and T1,A,T1 !=
198 or T2,%lo(0x4787c62a),T2
199 xor T1,C,T1
200 LOAD X(6),R6
201 add T1,R5,T1 !=
202 add T1,T2,T1
203 add D,T1,D
204 sll D,12,T2
205 srl D,32-12,D !=
206 or D,T2,D
207 xor A,B,T1
208 add D,A,D
209
210 sethi %hi(0xa8304613),T2 !=
211 and T1,D,T1
212 or T2,%lo(0xa8304613),T2
213 xor T1,B,T1
214 add T1,R6,T1 !=
215 LOAD X(7),R7
216 add T1,T2,T1
217 add C,T1,C
218 sll C,17,T2 !=
219 srl C,32-17,C
220 or C,T2,C
221 xor D,A,T1
222 add C,D,C !=
223
224 sethi %hi(0xfd469501),T2
225 and T1,C,T1
226 or T2,%lo(0xfd469501),T2
227 xor T1,A,T1 !=
228 add T1,R7,T1
229 LOAD X(8),R8
230 add T1,T2,T1
231 add B,T1,B !=
232 sll B,22,T2
233 srl B,32-22,B
234 or B,T2,B
235 xor C,D,T1 !=
236 add B,C,B
237
238 sethi %hi(0x698098d8),T2
239 and T1,B,T1
240 or T2,%lo(0x698098d8),T2 !=
241 xor T1,D,T1
242 add T1,R8,T1
243 LOAD X(9),R9
244 add T1,T2,T1 !=
245 add A,T1,A
246 sll A,7,T2
247 srl A,32-7,A
248 or A,T2,A !=
249 xor B,C,T1
250 add A,B,A
251
252 sethi %hi(0x8b44f7af),T2
253 and T1,A,T1 !=
254 or T2,%lo(0x8b44f7af),T2
255 xor T1,C,T1
256 LOAD X(10),R10
257 add T1,R9,T1 !=
258 add T1,T2,T1
259 add D,T1,D
260 sll D,12,T2
261 srl D,32-12,D !=
262 or D,T2,D
263 xor A,B,T1
264 add D,A,D
265
266 sethi %hi(0xffff5bb1),T2 !=
267 and T1,D,T1
268 or T2,%lo(0xffff5bb1),T2
269 xor T1,B,T1
270 add T1,R10,T1 !=
271 LOAD X(11),R11
272 add T1,T2,T1
273 add C,T1,C
274 sll C,17,T2 !=
275 srl C,32-17,C
276 or C,T2,C
277 xor D,A,T1
278 add C,D,C !=
279
280 sethi %hi(0x895cd7be),T2
281 and T1,C,T1
282 or T2,%lo(0x895cd7be),T2
283 xor T1,A,T1 !=
284 add T1,R11,T1
285 LOAD X(12),R12
286 add T1,T2,T1
287 add B,T1,B !=
288 sll B,22,T2
289 srl B,32-22,B
290 or B,T2,B
291 xor C,D,T1 !=
292 add B,C,B
293
294 sethi %hi(0x6b901122),T2
295 and T1,B,T1
296 or T2,%lo(0x6b901122),T2 !=
297 xor T1,D,T1
298 add T1,R12,T1
299 LOAD X(13),R13
300 add T1,T2,T1 !=
301 add A,T1,A
302 sll A,7,T2
303 srl A,32-7,A
304 or A,T2,A !=
305 xor B,C,T1
306 add A,B,A
307
308 sethi %hi(0xfd987193),T2
309 and T1,A,T1 !=
310 or T2,%lo(0xfd987193),T2
311 xor T1,C,T1
312 LOAD X(14),RX
313 add T1,R13,T1 !=
314 add T1,T2,T1
315 add D,T1,D
316 sll D,12,T2
317 srl D,32-12,D !=
318 or D,T2,D
319 xor A,B,T1
320 add D,A,D
321
322 sethi %hi(0xa679438e),T2 !=
323 and T1,D,T1
324 or T2,%lo(0xa679438e),T2
325 xor T1,B,T1
326 add T1,RX,T1 !=
327 LOAD X(15),RX
328 add T1,T2,T1
329 add C,T1,C
330 sll C,17,T2 !=
331 srl C,32-17,C
332 or C,T2,C
333 xor D,A,T1
334 add C,D,C !=
335
336 sethi %hi(0x49b40821),T2
337 and T1,C,T1
338 or T2,%lo(0x49b40821),T2
339 xor T1,A,T1 !=
340 add T1,RX,T1
341 !pre-LOADed X(1),R1
342 add T1,T2,T1
343 add B,T1,B
344 sll B,22,T2 !=
345 srl B,32-22,B
346 or B,T2,B
347 add B,C,B
348
349!!!!!!!!Round 1
350
351 xor B,C,T1 !=
352 sethi %hi(0xf61e2562),T2
353 and T1,D,T1
354 or T2,%lo(0xf61e2562),T2
355 xor T1,C,T1 !=
356 add T1,R1,T1
357 !pre-LOADed X(6),R6
358 add T1,T2,T1
359 add A,T1,A
360 sll A,5,T2 !=
361 srl A,32-5,A
362 or A,T2,A
363 add A,B,A
364
365 xor A,B,T1 !=
366 sethi %hi(0xc040b340),T2
367 and T1,C,T1
368 or T2,%lo(0xc040b340),T2
369 xor T1,B,T1 !=
370 add T1,R6,T1
371 !pre-LOADed X(11),R11
372 add T1,T2,T1
373 add D,T1,D
374 sll D,9,T2 !=
375 srl D,32-9,D
376 or D,T2,D
377 add D,A,D
378
379 xor D,A,T1 !=
380 sethi %hi(0x265e5a51),T2
381 and T1,B,T1
382 or T2,%lo(0x265e5a51),T2
383 xor T1,A,T1 !=
384 add T1,R11,T1
385 !pre-LOADed X(0),R0
386 add T1,T2,T1
387 add C,T1,C
388 sll C,14,T2 !=
389 srl C,32-14,C
390 or C,T2,C
391 add C,D,C
392
393 xor C,D,T1 !=
394 sethi %hi(0xe9b6c7aa),T2
395 and T1,A,T1
396 or T2,%lo(0xe9b6c7aa),T2
397 xor T1,D,T1 !=
398 add T1,R0,T1
399 !pre-LOADed X(5),R5
400 add T1,T2,T1
401 add B,T1,B
402 sll B,20,T2 !=
403 srl B,32-20,B
404 or B,T2,B
405 add B,C,B
406
407 xor B,C,T1 !=
408 sethi %hi(0xd62f105d),T2
409 and T1,D,T1
410 or T2,%lo(0xd62f105d),T2
411 xor T1,C,T1 !=
412 add T1,R5,T1
413 !pre-LOADed X(10),R10
414 add T1,T2,T1
415 add A,T1,A
416 sll A,5,T2 !=
417 srl A,32-5,A
418 or A,T2,A
419 add A,B,A
420
421 xor A,B,T1 !=
422 sethi %hi(0x02441453),T2
423 and T1,C,T1
424 or T2,%lo(0x02441453),T2
425 xor T1,B,T1 !=
426 add T1,R10,T1
427 LOAD X(15),RX
428 add T1,T2,T1
429 add D,T1,D !=
430 sll D,9,T2
431 srl D,32-9,D
432 or D,T2,D
433 add D,A,D !=
434
435 xor D,A,T1
436 sethi %hi(0xd8a1e681),T2
437 and T1,B,T1
438 or T2,%lo(0xd8a1e681),T2 !=
439 xor T1,A,T1
440 add T1,RX,T1
441 !pre-LOADed X(4),R4
442 add T1,T2,T1
443 add C,T1,C !=
444 sll C,14,T2
445 srl C,32-14,C
446 or C,T2,C
447 add C,D,C !=
448
449 xor C,D,T1
450 sethi %hi(0xe7d3fbc8),T2
451 and T1,A,T1
452 or T2,%lo(0xe7d3fbc8),T2 !=
453 xor T1,D,T1
454 add T1,R4,T1
455 !pre-LOADed X(9),R9
456 add T1,T2,T1
457 add B,T1,B !=
458 sll B,20,T2
459 srl B,32-20,B
460 or B,T2,B
461 add B,C,B !=
462
463 xor B,C,T1
464 sethi %hi(0x21e1cde6),T2
465 and T1,D,T1
466 or T2,%lo(0x21e1cde6),T2 !=
467 xor T1,C,T1
468 add T1,R9,T1
469 LOAD X(14),RX
470 add T1,T2,T1 !=
471 add A,T1,A
472 sll A,5,T2
473 srl A,32-5,A
474 or A,T2,A !=
475 add A,B,A
476
477 xor A,B,T1
478 sethi %hi(0xc33707d6),T2
479 and T1,C,T1 !=
480 or T2,%lo(0xc33707d6),T2
481 xor T1,B,T1
482 add T1,RX,T1
483 !pre-LOADed X(3),R3
484 add T1,T2,T1 !=
485 add D,T1,D
486 sll D,9,T2
487 srl D,32-9,D
488 or D,T2,D !=
489 add D,A,D
490
491 xor D,A,T1
492 sethi %hi(0xf4d50d87),T2
493 and T1,B,T1 !=
494 or T2,%lo(0xf4d50d87),T2
495 xor T1,A,T1
496 add T1,R3,T1
497 !pre-LOADed X(8),R8
498 add T1,T2,T1 !=
499 add C,T1,C
500 sll C,14,T2
501 srl C,32-14,C
502 or C,T2,C !=
503 add C,D,C
504
505 xor C,D,T1
506 sethi %hi(0x455a14ed),T2
507 and T1,A,T1 !=
508 or T2,%lo(0x455a14ed),T2
509 xor T1,D,T1
510 add T1,R8,T1
511 !pre-LOADed X(13),R13
512 add T1,T2,T1 !=
513 add B,T1,B
514 sll B,20,T2
515 srl B,32-20,B
516 or B,T2,B !=
517 add B,C,B
518
519 xor B,C,T1
520 sethi %hi(0xa9e3e905),T2
521 and T1,D,T1 !=
522 or T2,%lo(0xa9e3e905),T2
523 xor T1,C,T1
524 add T1,R13,T1
525 !pre-LOADed X(2),R2
526 add T1,T2,T1 !=
527 add A,T1,A
528 sll A,5,T2
529 srl A,32-5,A
530 or A,T2,A !=
531 add A,B,A
532
533 xor A,B,T1
534 sethi %hi(0xfcefa3f8),T2
535 and T1,C,T1 !=
536 or T2,%lo(0xfcefa3f8),T2
537 xor T1,B,T1
538 add T1,R2,T1
539 !pre-LOADed X(7),R7
540 add T1,T2,T1 !=
541 add D,T1,D
542 sll D,9,T2
543 srl D,32-9,D
544 or D,T2,D !=
545 add D,A,D
546
547 xor D,A,T1
548 sethi %hi(0x676f02d9),T2
549 and T1,B,T1 !=
550 or T2,%lo(0x676f02d9),T2
551 xor T1,A,T1
552 add T1,R7,T1
553 !pre-LOADed X(12),R12
554 add T1,T2,T1 !=
555 add C,T1,C
556 sll C,14,T2
557 srl C,32-14,C
558 or C,T2,C !=
559 add C,D,C
560
561 xor C,D,T1
562 sethi %hi(0x8d2a4c8a),T2
563 and T1,A,T1 !=
564 or T2,%lo(0x8d2a4c8a),T2
565 xor T1,D,T1
566 add T1,R12,T1
567 !pre-LOADed X(5),R5
568 add T1,T2,T1 !=
569 add B,T1,B
570 sll B,20,T2
571 srl B,32-20,B
572 or B,T2,B !=
573 add B,C,B
574
575!!!!!!!!Round 2
576
577 xor B,C,T1
578 sethi %hi(0xfffa3942),T2
579 xor T1,D,T1 !=
580 or T2,%lo(0xfffa3942),T2
581 add T1,R5,T1
582 !pre-LOADed X(8),R8
583 add T1,T2,T1
584 add A,T1,A !=
585 sll A,4,T2
586 srl A,32-4,A
587 or A,T2,A
588 add A,B,A !=
589
590 xor A,B,T1
591 sethi %hi(0x8771f681),T2
592 xor T1,C,T1
593 or T2,%lo(0x8771f681),T2 !=
594 add T1,R8,T1
595 !pre-LOADed X(11),R11
596 add T1,T2,T1
597 add D,T1,D
598 sll D,11,T2 !=
599 srl D,32-11,D
600 or D,T2,D
601 add D,A,D
602
603 xor D,A,T1 !=
604 sethi %hi(0x6d9d6122),T2
605 xor T1,B,T1
606 or T2,%lo(0x6d9d6122),T2
607 add T1,R11,T1 !=
608 LOAD X(14),RX
609 add T1,T2,T1
610 add C,T1,C
611 sll C,16,T2 !=
612 srl C,32-16,C
613 or C,T2,C
614 add C,D,C
615
616 xor C,D,T1 !=
617 sethi %hi(0xfde5380c),T2
618 xor T1,A,T1
619 or T2,%lo(0xfde5380c),T2
620 add T1,RX,T1 !=
621 !pre-LOADed X(1),R1
622 add T1,T2,T1
623 add B,T1,B
624 sll B,23,T2
625 srl B,32-23,B !=
626 or B,T2,B
627 add B,C,B
628
629 xor B,C,T1
630 sethi %hi(0xa4beea44),T2 !=
631 xor T1,D,T1
632 or T2,%lo(0xa4beea44),T2
633 add T1,R1,T1
634 !pre-LOADed X(4),R4
635 add T1,T2,T1 !=
636 add A,T1,A
637 sll A,4,T2
638 srl A,32-4,A
639 or A,T2,A !=
640 add A,B,A
641
642 xor A,B,T1
643 sethi %hi(0x4bdecfa9),T2
644 xor T1,C,T1 !=
645 or T2,%lo(0x4bdecfa9),T2
646 add T1,R4,T1
647 !pre-LOADed X(7),R7
648 add T1,T2,T1
649 add D,T1,D !=
650 sll D,11,T2
651 srl D,32-11,D
652 or D,T2,D
653 add D,A,D !=
654
655 xor D,A,T1
656 sethi %hi(0xf6bb4b60),T2
657 xor T1,B,T1
658 or T2,%lo(0xf6bb4b60),T2 !=
659 add T1,R7,T1
660 !pre-LOADed X(10),R10
661 add T1,T2,T1
662 add C,T1,C
663 sll C,16,T2 !=
664 srl C,32-16,C
665 or C,T2,C
666 add C,D,C
667
668 xor C,D,T1 !=
669 sethi %hi(0xbebfbc70),T2
670 xor T1,A,T1
671 or T2,%lo(0xbebfbc70),T2
672 add T1,R10,T1 !=
673 !pre-LOADed X(13),R13
674 add T1,T2,T1
675 add B,T1,B
676 sll B,23,T2
677 srl B,32-23,B !=
678 or B,T2,B
679 add B,C,B
680
681 xor B,C,T1
682 sethi %hi(0x289b7ec6),T2 !=
683 xor T1,D,T1
684 or T2,%lo(0x289b7ec6),T2
685 add T1,R13,T1
686 !pre-LOADed X(0),R0
687 add T1,T2,T1 !=
688 add A,T1,A
689 sll A,4,T2
690 srl A,32-4,A
691 or A,T2,A !=
692 add A,B,A
693
694 xor A,B,T1
695 sethi %hi(0xeaa127fa),T2
696 xor T1,C,T1 !=
697 or T2,%lo(0xeaa127fa),T2
698 add T1,R0,T1
699 !pre-LOADed X(3),R3
700 add T1,T2,T1
701 add D,T1,D !=
702 sll D,11,T2
703 srl D,32-11,D
704 or D,T2,D
705 add D,A,D !=
706
707 xor D,A,T1
708 sethi %hi(0xd4ef3085),T2
709 xor T1,B,T1
710 or T2,%lo(0xd4ef3085),T2 !=
711 add T1,R3,T1
712 !pre-LOADed X(6),R6
713 add T1,T2,T1
714 add C,T1,C
715 sll C,16,T2 !=
716 srl C,32-16,C
717 or C,T2,C
718 add C,D,C
719
720 xor C,D,T1 !=
721 sethi %hi(0x04881d05),T2
722 xor T1,A,T1
723 or T2,%lo(0x04881d05),T2
724 add T1,R6,T1 !=
725 !pre-LOADed X(9),R9
726 add T1,T2,T1
727 add B,T1,B
728 sll B,23,T2
729 srl B,32-23,B !=
730 or B,T2,B
731 add B,C,B
732
733 xor B,C,T1
734 sethi %hi(0xd9d4d039),T2 !=
735 xor T1,D,T1
736 or T2,%lo(0xd9d4d039),T2
737 add T1,R9,T1
738 !pre-LOADed X(12),R12
739 add T1,T2,T1 !=
740 add A,T1,A
741 sll A,4,T2
742 srl A,32-4,A
743 or A,T2,A !=
744 add A,B,A
745
746 xor A,B,T1
747 sethi %hi(0xe6db99e5),T2
748 xor T1,C,T1 !=
749 or T2,%lo(0xe6db99e5),T2
750 add T1,R12,T1
751 LOAD X(15),RX
752 add T1,T2,T1 !=
753 add D,T1,D
754 sll D,11,T2
755 srl D,32-11,D
756 or D,T2,D !=
757 add D,A,D
758
759 xor D,A,T1
760 sethi %hi(0x1fa27cf8),T2
761 xor T1,B,T1 !=
762 or T2,%lo(0x1fa27cf8),T2
763 add T1,RX,T1
764 !pre-LOADed X(2),R2
765 add T1,T2,T1
766 add C,T1,C !=
767 sll C,16,T2
768 srl C,32-16,C
769 or C,T2,C
770 add C,D,C !=
771
772 xor C,D,T1
773 sethi %hi(0xc4ac5665),T2
774 xor T1,A,T1
775 or T2,%lo(0xc4ac5665),T2 !=
776 add T1,R2,T1
777 !pre-LOADed X(0),R0
778 add T1,T2,T1
779 add B,T1,B
780 sll B,23,T2 !=
781 srl B,32-23,B
782 or B,T2,B
783 add B,C,B
784
785!!!!!!!!Round 3
786
787 orn B,D,T1 !=
788 sethi %hi(0xf4292244),T2
789 xor T1,C,T1
790 or T2,%lo(0xf4292244),T2
791 add T1,R0,T1 !=
792 !pre-LOADed X(7),R7
793 add T1,T2,T1
794 add A,T1,A
795 sll A,6,T2
796 srl A,32-6,A !=
797 or A,T2,A
798 add A,B,A
799
800 orn A,C,T1
801 sethi %hi(0x432aff97),T2 !=
802 xor T1,B,T1
803 or T2,%lo(0x432aff97),T2
804 LOAD X(14),RX
805 add T1,R7,T1 !=
806 add T1,T2,T1
807 add D,T1,D
808 sll D,10,T2
809 srl D,32-10,D !=
810 or D,T2,D
811 add D,A,D
812
813 orn D,B,T1
814 sethi %hi(0xab9423a7),T2 !=
815 xor T1,A,T1
816 or T2,%lo(0xab9423a7),T2
817 add T1,RX,T1
818 !pre-LOADed X(5),R5
819 add T1,T2,T1 !=
820 add C,T1,C
821 sll C,15,T2
822 srl C,32-15,C
823 or C,T2,C !=
824 add C,D,C
825
826 orn C,A,T1
827 sethi %hi(0xfc93a039),T2
828 xor T1,D,T1 !=
829 or T2,%lo(0xfc93a039),T2
830 add T1,R5,T1
831 !pre-LOADed X(12),R12
832 add T1,T2,T1
833 add B,T1,B !=
834 sll B,21,T2
835 srl B,32-21,B
836 or B,T2,B
837 add B,C,B !=
838
839 orn B,D,T1
840 sethi %hi(0x655b59c3),T2
841 xor T1,C,T1
842 or T2,%lo(0x655b59c3),T2 !=
843 add T1,R12,T1
844 !pre-LOADed X(3),R3
845 add T1,T2,T1
846 add A,T1,A
847 sll A,6,T2 !=
848 srl A,32-6,A
849 or A,T2,A
850 add A,B,A
851
852 orn A,C,T1 !=
853 sethi %hi(0x8f0ccc92),T2
854 xor T1,B,T1
855 or T2,%lo(0x8f0ccc92),T2
856 add T1,R3,T1 !=
857 !pre-LOADed X(10),R10
858 add T1,T2,T1
859 add D,T1,D
860 sll D,10,T2
861 srl D,32-10,D !=
862 or D,T2,D
863 add D,A,D
864
865 orn D,B,T1
866 sethi %hi(0xffeff47d),T2 !=
867 xor T1,A,T1
868 or T2,%lo(0xffeff47d),T2
869 add T1,R10,T1
870 !pre-LOADed X(1),R1
871 add T1,T2,T1 !=
872 add C,T1,C
873 sll C,15,T2
874 srl C,32-15,C
875 or C,T2,C !=
876 add C,D,C
877
878 orn C,A,T1
879 sethi %hi(0x85845dd1),T2
880 xor T1,D,T1 !=
881 or T2,%lo(0x85845dd1),T2
882 add T1,R1,T1
883 !pre-LOADed X(8),R8
884 add T1,T2,T1
885 add B,T1,B !=
886 sll B,21,T2
887 srl B,32-21,B
888 or B,T2,B
889 add B,C,B !=
890
891 orn B,D,T1
892 sethi %hi(0x6fa87e4f),T2
893 xor T1,C,T1
894 or T2,%lo(0x6fa87e4f),T2 !=
895 add T1,R8,T1
896 LOAD X(15),RX
897 add T1,T2,T1
898 add A,T1,A !=
899 sll A,6,T2
900 srl A,32-6,A
901 or A,T2,A
902 add A,B,A !=
903
904 orn A,C,T1
905 sethi %hi(0xfe2ce6e0),T2
906 xor T1,B,T1
907 or T2,%lo(0xfe2ce6e0),T2 !=
908 add T1,RX,T1
909 !pre-LOADed X(6),R6
910 add T1,T2,T1
911 add D,T1,D
912 sll D,10,T2 !=
913 srl D,32-10,D
914 or D,T2,D
915 add D,A,D
916
917 orn D,B,T1 !=
918 sethi %hi(0xa3014314),T2
919 xor T1,A,T1
920 or T2,%lo(0xa3014314),T2
921 add T1,R6,T1 !=
922 !pre-LOADed X(13),R13
923 add T1,T2,T1
924 add C,T1,C
925 sll C,15,T2
926 srl C,32-15,C !=
927 or C,T2,C
928 add C,D,C
929
930 orn C,A,T1
931 sethi %hi(0x4e0811a1),T2 !=
932 xor T1,D,T1
933 or T2,%lo(0x4e0811a1),T2
934 !pre-LOADed X(4),R4
935 ld [Aptr],Aval
936 add T1,R13,T1 !=
937 add T1,T2,T1
938 add B,T1,B
939 sll B,21,T2
940 srl B,32-21,B !=
941 or B,T2,B
942 add B,C,B
943
944 orn B,D,T1
945 sethi %hi(0xf7537e82),T2 !=
946 xor T1,C,T1
947 or T2,%lo(0xf7537e82),T2
948 !pre-LOADed X(11),R11
949 ld [Dptr],Dval
950 add T1,R4,T1 !=
951 add T1,T2,T1
952 add A,T1,A
953 sll A,6,T2
954 srl A,32-6,A !=
955 or A,T2,A
956 add A,B,A
957
958 orn A,C,T1
959 sethi %hi(0xbd3af235),T2 !=
960 xor T1,B,T1
961 or T2,%lo(0xbd3af235),T2
962 !pre-LOADed X(2),R2
963 ld [Cptr],Cval
964 add T1,R11,T1 !=
965 add T1,T2,T1
966 add D,T1,D
967 sll D,10,T2
968 srl D,32-10,D !=
969 or D,T2,D
970 add D,A,D
971
972 orn D,B,T1
973 sethi %hi(0x2ad7d2bb),T2 !=
974 xor T1,A,T1
975 or T2,%lo(0x2ad7d2bb),T2
976 !pre-LOADed X(9),R9
977 ld [Bptr],Bval
978 add T1,R2,T1 !=
979 add Aval,A,Aval
980 add T1,T2,T1
981 st Aval,[Aptr]
982 add C,T1,C !=
983 sll C,15,T2
984 add Dval,D,Dval
985 srl C,32-15,C
986 or C,T2,C !=
987 st Dval,[Dptr]
988 add C,D,C
989
990 orn C,A,T1
991 sethi %hi(0xeb86d391),T2 !=
992 xor T1,D,T1
993 or T2,%lo(0xeb86d391),T2
994 add T1,R9,T1
995 !pre-LOADed X(0),R0
996 mov Aval,A !=
997 add T1,T2,T1
998 mov Dval,D
999 add B,T1,B
1000 sll B,21,T2 !=
1001 add Cval,C,Cval
1002 srl B,32-21,B
1003 st Cval,[Cptr]
1004 or B,T2,B !=
1005 add B,C,B
1006
1007 deccc %i2
1008 mov Cval,C
1009 add B,Bval,B !=
1010 inc 64,%i1
1011 nop
1012 st B,[Bptr]
1013 nop !=
1014
1015#ifdef ULTRASPARC
1016 bg,a,pt %icc,.Lmd5_block_loop
1017#else
1018 bg,a .Lmd5_block_loop
1019#endif
1020 LOAD X(0),R0
1021
1022#ifdef ASI_PRIMARY_LITTLE
1023 wr %g0,%o7,%asi
1024#endif
1025 ret
1026 restore %g0,0,%o0
1027
1028.type md5_block,#function
1029.size md5_block,(.-md5_block)
diff --git a/src/lib/libcrypto/md5/asm/mx86unix.cpp b/src/lib/libcrypto/md5/asm/mx86unix.cpp
deleted file mode 100644
index 5d399122b6..0000000000
--- a/src/lib/libcrypto/md5/asm/mx86unix.cpp
+++ /dev/null
@@ -1,730 +0,0 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define md5_block_x86 _md5_block_x86
13
14#endif
15
16#ifdef OUT
17#define OK 1
18#define ALIGN 4
19#endif
20
21#ifdef BSDI
22#define OK 1
23#define ALIGN 4
24#undef SIZE
25#undef TYPE
26#define SIZE(a,b)
27#define TYPE(a,b)
28#endif
29
30#if defined(ELF) || defined(SOL)
31#define OK 1
32#define ALIGN 16
33#endif
34
35#ifndef OK
36You need to define one of
37ELF - elf systems - linux-elf, NetBSD and DG-UX
38OUT - a.out systems - linux-a.out and FreeBSD
39SOL - solaris systems, which are elf with strange comment lines
40BSDI - a.out with a very primative version of as.
41#endif
42
43/* Let the Assembler begin :-) */
44 /* Don't even think of reading this code */
45 /* It was automatically generated by md5-586.pl */
46 /* Which is a perl program used to generate the x86 assember for */
47 /* any of elf, a.out, BSDI,Win32, or Solaris */
48 /* eric <eay@cryptsoft.com> */
49
50 .file "md5-586.s"
51 .version "01.01"
52gcc2_compiled.:
53.text
54 .align ALIGN
55.globl md5_block_x86
56 TYPE(md5_block_x86,@function)
57md5_block_x86:
58 pushl %esi
59 pushl %edi
60 movl 12(%esp), %edi
61 movl 16(%esp), %esi
62 movl 20(%esp), %ecx
63 pushl %ebp
64 pushl %ebx
65 addl %esi, %ecx
66 subl $64, %ecx
67 movl (%edi), %eax
68 pushl %ecx
69 movl 4(%edi), %ebx
70 movl 8(%edi), %ecx
71 movl 12(%edi), %edx
72.L000start:
73
74 /* R0 section */
75 movl %ecx, %edi
76 movl (%esi), %ebp
77 /* R0 0 */
78 xorl %edx, %edi
79 andl %ebx, %edi
80 leal 3614090360(%eax,%ebp,1),%eax
81 movl 4(%esi), %ebp
82 xorl %edx, %edi
83 addl %edi, %eax
84 movl %ebx, %edi
85 roll $7, %eax
86 addl %ebx, %eax
87 /* R0 1 */
88 xorl %ecx, %edi
89 andl %eax, %edi
90 leal 3905402710(%edx,%ebp,1),%edx
91 movl 8(%esi), %ebp
92 xorl %ecx, %edi
93 addl %edi, %edx
94 movl %eax, %edi
95 roll $12, %edx
96 addl %eax, %edx
97 /* R0 2 */
98 xorl %ebx, %edi
99 andl %edx, %edi
100 leal 606105819(%ecx,%ebp,1),%ecx
101 movl 12(%esi), %ebp
102 xorl %ebx, %edi
103 addl %edi, %ecx
104 movl %edx, %edi
105 roll $17, %ecx
106 addl %edx, %ecx
107 /* R0 3 */
108 xorl %eax, %edi
109 andl %ecx, %edi
110 leal 3250441966(%ebx,%ebp,1),%ebx
111 movl 16(%esi), %ebp
112 xorl %eax, %edi
113 addl %edi, %ebx
114 movl %ecx, %edi
115 roll $22, %ebx
116 addl %ecx, %ebx
117 /* R0 4 */
118 xorl %edx, %edi
119 andl %ebx, %edi
120 leal 4118548399(%eax,%ebp,1),%eax
121 movl 20(%esi), %ebp
122 xorl %edx, %edi
123 addl %edi, %eax
124 movl %ebx, %edi
125 roll $7, %eax
126 addl %ebx, %eax
127 /* R0 5 */
128 xorl %ecx, %edi
129 andl %eax, %edi
130 leal 1200080426(%edx,%ebp,1),%edx
131 movl 24(%esi), %ebp
132 xorl %ecx, %edi
133 addl %edi, %edx
134 movl %eax, %edi
135 roll $12, %edx
136 addl %eax, %edx
137 /* R0 6 */
138 xorl %ebx, %edi
139 andl %edx, %edi
140 leal 2821735955(%ecx,%ebp,1),%ecx
141 movl 28(%esi), %ebp
142 xorl %ebx, %edi
143 addl %edi, %ecx
144 movl %edx, %edi
145 roll $17, %ecx
146 addl %edx, %ecx
147 /* R0 7 */
148 xorl %eax, %edi
149 andl %ecx, %edi
150 leal 4249261313(%ebx,%ebp,1),%ebx
151 movl 32(%esi), %ebp
152 xorl %eax, %edi
153 addl %edi, %ebx
154 movl %ecx, %edi
155 roll $22, %ebx
156 addl %ecx, %ebx
157 /* R0 8 */
158 xorl %edx, %edi
159 andl %ebx, %edi
160 leal 1770035416(%eax,%ebp,1),%eax
161 movl 36(%esi), %ebp
162 xorl %edx, %edi
163 addl %edi, %eax
164 movl %ebx, %edi
165 roll $7, %eax
166 addl %ebx, %eax
167 /* R0 9 */
168 xorl %ecx, %edi
169 andl %eax, %edi
170 leal 2336552879(%edx,%ebp,1),%edx
171 movl 40(%esi), %ebp
172 xorl %ecx, %edi
173 addl %edi, %edx
174 movl %eax, %edi
175 roll $12, %edx
176 addl %eax, %edx
177 /* R0 10 */
178 xorl %ebx, %edi
179 andl %edx, %edi
180 leal 4294925233(%ecx,%ebp,1),%ecx
181 movl 44(%esi), %ebp
182 xorl %ebx, %edi
183 addl %edi, %ecx
184 movl %edx, %edi
185 roll $17, %ecx
186 addl %edx, %ecx
187 /* R0 11 */
188 xorl %eax, %edi
189 andl %ecx, %edi
190 leal 2304563134(%ebx,%ebp,1),%ebx
191 movl 48(%esi), %ebp
192 xorl %eax, %edi
193 addl %edi, %ebx
194 movl %ecx, %edi
195 roll $22, %ebx
196 addl %ecx, %ebx
197 /* R0 12 */
198 xorl %edx, %edi
199 andl %ebx, %edi
200 leal 1804603682(%eax,%ebp,1),%eax
201 movl 52(%esi), %ebp
202 xorl %edx, %edi
203 addl %edi, %eax
204 movl %ebx, %edi
205 roll $7, %eax
206 addl %ebx, %eax
207 /* R0 13 */
208 xorl %ecx, %edi
209 andl %eax, %edi
210 leal 4254626195(%edx,%ebp,1),%edx
211 movl 56(%esi), %ebp
212 xorl %ecx, %edi
213 addl %edi, %edx
214 movl %eax, %edi
215 roll $12, %edx
216 addl %eax, %edx
217 /* R0 14 */
218 xorl %ebx, %edi
219 andl %edx, %edi
220 leal 2792965006(%ecx,%ebp,1),%ecx
221 movl 60(%esi), %ebp
222 xorl %ebx, %edi
223 addl %edi, %ecx
224 movl %edx, %edi
225 roll $17, %ecx
226 addl %edx, %ecx
227 /* R0 15 */
228 xorl %eax, %edi
229 andl %ecx, %edi
230 leal 1236535329(%ebx,%ebp,1),%ebx
231 movl 4(%esi), %ebp
232 xorl %eax, %edi
233 addl %edi, %ebx
234 movl %ecx, %edi
235 roll $22, %ebx
236 addl %ecx, %ebx
237
238 /* R1 section */
239 /* R1 16 */
240 leal 4129170786(%eax,%ebp,1),%eax
241 xorl %ebx, %edi
242 andl %edx, %edi
243 movl 24(%esi), %ebp
244 xorl %ecx, %edi
245 addl %edi, %eax
246 movl %ebx, %edi
247 roll $5, %eax
248 addl %ebx, %eax
249 /* R1 17 */
250 leal 3225465664(%edx,%ebp,1),%edx
251 xorl %eax, %edi
252 andl %ecx, %edi
253 movl 44(%esi), %ebp
254 xorl %ebx, %edi
255 addl %edi, %edx
256 movl %eax, %edi
257 roll $9, %edx
258 addl %eax, %edx
259 /* R1 18 */
260 leal 643717713(%ecx,%ebp,1),%ecx
261 xorl %edx, %edi
262 andl %ebx, %edi
263 movl (%esi), %ebp
264 xorl %eax, %edi
265 addl %edi, %ecx
266 movl %edx, %edi
267 roll $14, %ecx
268 addl %edx, %ecx
269 /* R1 19 */
270 leal 3921069994(%ebx,%ebp,1),%ebx
271 xorl %ecx, %edi
272 andl %eax, %edi
273 movl 20(%esi), %ebp
274 xorl %edx, %edi
275 addl %edi, %ebx
276 movl %ecx, %edi
277 roll $20, %ebx
278 addl %ecx, %ebx
279 /* R1 20 */
280 leal 3593408605(%eax,%ebp,1),%eax
281 xorl %ebx, %edi
282 andl %edx, %edi
283 movl 40(%esi), %ebp
284 xorl %ecx, %edi
285 addl %edi, %eax
286 movl %ebx, %edi
287 roll $5, %eax
288 addl %ebx, %eax
289 /* R1 21 */
290 leal 38016083(%edx,%ebp,1),%edx
291 xorl %eax, %edi
292 andl %ecx, %edi
293 movl 60(%esi), %ebp
294 xorl %ebx, %edi
295 addl %edi, %edx
296 movl %eax, %edi
297 roll $9, %edx
298 addl %eax, %edx
299 /* R1 22 */
300 leal 3634488961(%ecx,%ebp,1),%ecx
301 xorl %edx, %edi
302 andl %ebx, %edi
303 movl 16(%esi), %ebp
304 xorl %eax, %edi
305 addl %edi, %ecx
306 movl %edx, %edi
307 roll $14, %ecx
308 addl %edx, %ecx
309 /* R1 23 */
310 leal 3889429448(%ebx,%ebp,1),%ebx
311 xorl %ecx, %edi
312 andl %eax, %edi
313 movl 36(%esi), %ebp
314 xorl %edx, %edi
315 addl %edi, %ebx
316 movl %ecx, %edi
317 roll $20, %ebx
318 addl %ecx, %ebx
319 /* R1 24 */
320 leal 568446438(%eax,%ebp,1),%eax
321 xorl %ebx, %edi
322 andl %edx, %edi
323 movl 56(%esi), %ebp
324 xorl %ecx, %edi
325 addl %edi, %eax
326 movl %ebx, %edi
327 roll $5, %eax
328 addl %ebx, %eax
329 /* R1 25 */
330 leal 3275163606(%edx,%ebp,1),%edx
331 xorl %eax, %edi
332 andl %ecx, %edi
333 movl 12(%esi), %ebp
334 xorl %ebx, %edi
335 addl %edi, %edx
336 movl %eax, %edi
337 roll $9, %edx
338 addl %eax, %edx
339 /* R1 26 */
340 leal 4107603335(%ecx,%ebp,1),%ecx
341 xorl %edx, %edi
342 andl %ebx, %edi
343 movl 32(%esi), %ebp
344 xorl %eax, %edi
345 addl %edi, %ecx
346 movl %edx, %edi
347 roll $14, %ecx
348 addl %edx, %ecx
349 /* R1 27 */
350 leal 1163531501(%ebx,%ebp,1),%ebx
351 xorl %ecx, %edi
352 andl %eax, %edi
353 movl 52(%esi), %ebp
354 xorl %edx, %edi
355 addl %edi, %ebx
356 movl %ecx, %edi
357 roll $20, %ebx
358 addl %ecx, %ebx
359 /* R1 28 */
360 leal 2850285829(%eax,%ebp,1),%eax
361 xorl %ebx, %edi
362 andl %edx, %edi
363 movl 8(%esi), %ebp
364 xorl %ecx, %edi
365 addl %edi, %eax
366 movl %ebx, %edi
367 roll $5, %eax
368 addl %ebx, %eax
369 /* R1 29 */
370 leal 4243563512(%edx,%ebp,1),%edx
371 xorl %eax, %edi
372 andl %ecx, %edi
373 movl 28(%esi), %ebp
374 xorl %ebx, %edi
375 addl %edi, %edx
376 movl %eax, %edi
377 roll $9, %edx
378 addl %eax, %edx
379 /* R1 30 */
380 leal 1735328473(%ecx,%ebp,1),%ecx
381 xorl %edx, %edi
382 andl %ebx, %edi
383 movl 48(%esi), %ebp
384 xorl %eax, %edi
385 addl %edi, %ecx
386 movl %edx, %edi
387 roll $14, %ecx
388 addl %edx, %ecx
389 /* R1 31 */
390 leal 2368359562(%ebx,%ebp,1),%ebx
391 xorl %ecx, %edi
392 andl %eax, %edi
393 movl 20(%esi), %ebp
394 xorl %edx, %edi
395 addl %edi, %ebx
396 movl %ecx, %edi
397 roll $20, %ebx
398 addl %ecx, %ebx
399
400 /* R2 section */
401 /* R2 32 */
402 xorl %edx, %edi
403 xorl %ebx, %edi
404 leal 4294588738(%eax,%ebp,1),%eax
405 addl %edi, %eax
406 movl 32(%esi), %ebp
407 roll $4, %eax
408 movl %ebx, %edi
409 /* R2 33 */
410 leal 2272392833(%edx,%ebp,1),%edx
411 addl %ebx, %eax
412 xorl %ecx, %edi
413 xorl %eax, %edi
414 movl 44(%esi), %ebp
415 addl %edi, %edx
416 movl %eax, %edi
417 roll $11, %edx
418 addl %eax, %edx
419 /* R2 34 */
420 xorl %ebx, %edi
421 xorl %edx, %edi
422 leal 1839030562(%ecx,%ebp,1),%ecx
423 addl %edi, %ecx
424 movl 56(%esi), %ebp
425 roll $16, %ecx
426 movl %edx, %edi
427 /* R2 35 */
428 leal 4259657740(%ebx,%ebp,1),%ebx
429 addl %edx, %ecx
430 xorl %eax, %edi
431 xorl %ecx, %edi
432 movl 4(%esi), %ebp
433 addl %edi, %ebx
434 movl %ecx, %edi
435 roll $23, %ebx
436 addl %ecx, %ebx
437 /* R2 36 */
438 xorl %edx, %edi
439 xorl %ebx, %edi
440 leal 2763975236(%eax,%ebp,1),%eax
441 addl %edi, %eax
442 movl 16(%esi), %ebp
443 roll $4, %eax
444 movl %ebx, %edi
445 /* R2 37 */
446 leal 1272893353(%edx,%ebp,1),%edx
447 addl %ebx, %eax
448 xorl %ecx, %edi
449 xorl %eax, %edi
450 movl 28(%esi), %ebp
451 addl %edi, %edx
452 movl %eax, %edi
453 roll $11, %edx
454 addl %eax, %edx
455 /* R2 38 */
456 xorl %ebx, %edi
457 xorl %edx, %edi
458 leal 4139469664(%ecx,%ebp,1),%ecx
459 addl %edi, %ecx
460 movl 40(%esi), %ebp
461 roll $16, %ecx
462 movl %edx, %edi
463 /* R2 39 */
464 leal 3200236656(%ebx,%ebp,1),%ebx
465 addl %edx, %ecx
466 xorl %eax, %edi
467 xorl %ecx, %edi
468 movl 52(%esi), %ebp
469 addl %edi, %ebx
470 movl %ecx, %edi
471 roll $23, %ebx
472 addl %ecx, %ebx
473 /* R2 40 */
474 xorl %edx, %edi
475 xorl %ebx, %edi
476 leal 681279174(%eax,%ebp,1),%eax
477 addl %edi, %eax
478 movl (%esi), %ebp
479 roll $4, %eax
480 movl %ebx, %edi
481 /* R2 41 */
482 leal 3936430074(%edx,%ebp,1),%edx
483 addl %ebx, %eax
484 xorl %ecx, %edi
485 xorl %eax, %edi
486 movl 12(%esi), %ebp
487 addl %edi, %edx
488 movl %eax, %edi
489 roll $11, %edx
490 addl %eax, %edx
491 /* R2 42 */
492 xorl %ebx, %edi
493 xorl %edx, %edi
494 leal 3572445317(%ecx,%ebp,1),%ecx
495 addl %edi, %ecx
496 movl 24(%esi), %ebp
497 roll $16, %ecx
498 movl %edx, %edi
499 /* R2 43 */
500 leal 76029189(%ebx,%ebp,1),%ebx
501 addl %edx, %ecx
502 xorl %eax, %edi
503 xorl %ecx, %edi
504 movl 36(%esi), %ebp
505 addl %edi, %ebx
506 movl %ecx, %edi
507 roll $23, %ebx
508 addl %ecx, %ebx
509 /* R2 44 */
510 xorl %edx, %edi
511 xorl %ebx, %edi
512 leal 3654602809(%eax,%ebp,1),%eax
513 addl %edi, %eax
514 movl 48(%esi), %ebp
515 roll $4, %eax
516 movl %ebx, %edi
517 /* R2 45 */
518 leal 3873151461(%edx,%ebp,1),%edx
519 addl %ebx, %eax
520 xorl %ecx, %edi
521 xorl %eax, %edi
522 movl 60(%esi), %ebp
523 addl %edi, %edx
524 movl %eax, %edi
525 roll $11, %edx
526 addl %eax, %edx
527 /* R2 46 */
528 xorl %ebx, %edi
529 xorl %edx, %edi
530 leal 530742520(%ecx,%ebp,1),%ecx
531 addl %edi, %ecx
532 movl 8(%esi), %ebp
533 roll $16, %ecx
534 movl %edx, %edi
535 /* R2 47 */
536 leal 3299628645(%ebx,%ebp,1),%ebx
537 addl %edx, %ecx
538 xorl %eax, %edi
539 xorl %ecx, %edi
540 movl (%esi), %ebp
541 addl %edi, %ebx
542 movl $-1, %edi
543 roll $23, %ebx
544 addl %ecx, %ebx
545
546 /* R3 section */
547 /* R3 48 */
548 xorl %edx, %edi
549 orl %ebx, %edi
550 leal 4096336452(%eax,%ebp,1),%eax
551 xorl %ecx, %edi
552 movl 28(%esi), %ebp
553 addl %edi, %eax
554 movl $-1, %edi
555 roll $6, %eax
556 xorl %ecx, %edi
557 addl %ebx, %eax
558 /* R3 49 */
559 orl %eax, %edi
560 leal 1126891415(%edx,%ebp,1),%edx
561 xorl %ebx, %edi
562 movl 56(%esi), %ebp
563 addl %edi, %edx
564 movl $-1, %edi
565 roll $10, %edx
566 xorl %ebx, %edi
567 addl %eax, %edx
568 /* R3 50 */
569 orl %edx, %edi
570 leal 2878612391(%ecx,%ebp,1),%ecx
571 xorl %eax, %edi
572 movl 20(%esi), %ebp
573 addl %edi, %ecx
574 movl $-1, %edi
575 roll $15, %ecx
576 xorl %eax, %edi
577 addl %edx, %ecx
578 /* R3 51 */
579 orl %ecx, %edi
580 leal 4237533241(%ebx,%ebp,1),%ebx
581 xorl %edx, %edi
582 movl 48(%esi), %ebp
583 addl %edi, %ebx
584 movl $-1, %edi
585 roll $21, %ebx
586 xorl %edx, %edi
587 addl %ecx, %ebx
588 /* R3 52 */
589 orl %ebx, %edi
590 leal 1700485571(%eax,%ebp,1),%eax
591 xorl %ecx, %edi
592 movl 12(%esi), %ebp
593 addl %edi, %eax
594 movl $-1, %edi
595 roll $6, %eax
596 xorl %ecx, %edi
597 addl %ebx, %eax
598 /* R3 53 */
599 orl %eax, %edi
600 leal 2399980690(%edx,%ebp,1),%edx
601 xorl %ebx, %edi
602 movl 40(%esi), %ebp
603 addl %edi, %edx
604 movl $-1, %edi
605 roll $10, %edx
606 xorl %ebx, %edi
607 addl %eax, %edx
608 /* R3 54 */
609 orl %edx, %edi
610 leal 4293915773(%ecx,%ebp,1),%ecx
611 xorl %eax, %edi
612 movl 4(%esi), %ebp
613 addl %edi, %ecx
614 movl $-1, %edi
615 roll $15, %ecx
616 xorl %eax, %edi
617 addl %edx, %ecx
618 /* R3 55 */
619 orl %ecx, %edi
620 leal 2240044497(%ebx,%ebp,1),%ebx
621 xorl %edx, %edi
622 movl 32(%esi), %ebp
623 addl %edi, %ebx
624 movl $-1, %edi
625 roll $21, %ebx
626 xorl %edx, %edi
627 addl %ecx, %ebx
628 /* R3 56 */
629 orl %ebx, %edi
630 leal 1873313359(%eax,%ebp,1),%eax
631 xorl %ecx, %edi
632 movl 60(%esi), %ebp
633 addl %edi, %eax
634 movl $-1, %edi
635 roll $6, %eax
636 xorl %ecx, %edi
637 addl %ebx, %eax
638 /* R3 57 */
639 orl %eax, %edi
640 leal 4264355552(%edx,%ebp,1),%edx
641 xorl %ebx, %edi
642 movl 24(%esi), %ebp
643 addl %edi, %edx
644 movl $-1, %edi
645 roll $10, %edx
646 xorl %ebx, %edi
647 addl %eax, %edx
648 /* R3 58 */
649 orl %edx, %edi
650 leal 2734768916(%ecx,%ebp,1),%ecx
651 xorl %eax, %edi
652 movl 52(%esi), %ebp
653 addl %edi, %ecx
654 movl $-1, %edi
655 roll $15, %ecx
656 xorl %eax, %edi
657 addl %edx, %ecx
658 /* R3 59 */
659 orl %ecx, %edi
660 leal 1309151649(%ebx,%ebp,1),%ebx
661 xorl %edx, %edi
662 movl 16(%esi), %ebp
663 addl %edi, %ebx
664 movl $-1, %edi
665 roll $21, %ebx
666 xorl %edx, %edi
667 addl %ecx, %ebx
668 /* R3 60 */
669 orl %ebx, %edi
670 leal 4149444226(%eax,%ebp,1),%eax
671 xorl %ecx, %edi
672 movl 44(%esi), %ebp
673 addl %edi, %eax
674 movl $-1, %edi
675 roll $6, %eax
676 xorl %ecx, %edi
677 addl %ebx, %eax
678 /* R3 61 */
679 orl %eax, %edi
680 leal 3174756917(%edx,%ebp,1),%edx
681 xorl %ebx, %edi
682 movl 8(%esi), %ebp
683 addl %edi, %edx
684 movl $-1, %edi
685 roll $10, %edx
686 xorl %ebx, %edi
687 addl %eax, %edx
688 /* R3 62 */
689 orl %edx, %edi
690 leal 718787259(%ecx,%ebp,1),%ecx
691 xorl %eax, %edi
692 movl 36(%esi), %ebp
693 addl %edi, %ecx
694 movl $-1, %edi
695 roll $15, %ecx
696 xorl %eax, %edi
697 addl %edx, %ecx
698 /* R3 63 */
699 orl %ecx, %edi
700 leal 3951481745(%ebx,%ebp,1),%ebx
701 xorl %edx, %edi
702 movl 24(%esp), %ebp
703 addl %edi, %ebx
704 addl $64, %esi
705 roll $21, %ebx
706 movl (%ebp), %edi
707 addl %ecx, %ebx
708 addl %edi, %eax
709 movl 4(%ebp), %edi
710 addl %edi, %ebx
711 movl 8(%ebp), %edi
712 addl %edi, %ecx
713 movl 12(%ebp), %edi
714 addl %edi, %edx
715 movl %eax, (%ebp)
716 movl %ebx, 4(%ebp)
717 movl (%esp), %edi
718 movl %ecx, 8(%ebp)
719 movl %edx, 12(%ebp)
720 cmpl %esi, %edi
721 jge .L000start
722 popl %eax
723 popl %ebx
724 popl %ebp
725 popl %edi
726 popl %esi
727 ret
728.md5_block_x86_end:
729 SIZE(md5_block_x86,.md5_block_x86_end-md5_block_x86)
730.ident "desasm.pl"
diff --git a/src/lib/libcrypto/md5/md5.c b/src/lib/libcrypto/md5/md5.c
index 9d6f5a6003..7ed0024ae1 100644
--- a/src/lib/libcrypto/md5/md5.c
+++ b/src/lib/libcrypto/md5/md5.c
@@ -58,23 +58,17 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include <stdlib.h> 60#include <stdlib.h>
61#include "md5.h" 61#include <openssl/md5.h>
62 62
63#define BUFSIZE 1024*16 63#define BUFSIZE 1024*16
64 64
65#ifndef NOPROTO
66void do_fp(FILE *f); 65void do_fp(FILE *f);
67void pt(unsigned char *md); 66void pt(unsigned char *md);
67#ifndef _OSD_POSIX
68int read(int, void *, unsigned int); 68int read(int, void *, unsigned int);
69#else
70void do_fp();
71void pt();
72int read();
73#endif 69#endif
74 70
75int main(argc, argv) 71int main(int argc, char **argv)
76int argc;
77char **argv;
78 { 72 {
79 int i,err=0; 73 int i,err=0;
80 FILE *IN; 74 FILE *IN;
@@ -102,8 +96,7 @@ char **argv;
102 exit(err); 96 exit(err);
103 } 97 }
104 98
105void do_fp(f) 99void do_fp(FILE *f)
106FILE *f;
107 { 100 {
108 MD5_CTX c; 101 MD5_CTX c;
109 unsigned char md[MD5_DIGEST_LENGTH]; 102 unsigned char md[MD5_DIGEST_LENGTH];
@@ -123,8 +116,7 @@ FILE *f;
123 pt(md); 116 pt(md);
124 } 117 }
125 118
126void pt(md) 119void pt(unsigned char *md)
127unsigned char *md;
128 { 120 {
129 int i; 121 int i;
130 122
diff --git a/src/lib/libcrypto/md5/md5.h b/src/lib/libcrypto/md5/md5.h
index 357c6c625d..bdab6d45e8 100644
--- a/src/lib/libcrypto/md5/md5.h
+++ b/src/lib/libcrypto/md5/md5.h
@@ -63,35 +63,50 @@
63extern "C" { 63extern "C" {
64#endif 64#endif
65 65
66#ifdef NO_MD5
67#error MD5 is disabled.
68#endif
69
70/*
71 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
72 * ! MD5_LONG has to be at least 32 bits wide. If it's wider, then !
73 * ! MD5_LONG_LOG2 has to be defined along. !
74 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
75 */
76
77#if defined(WIN16) || defined(__LP32__)
78#define MD5_LONG unsigned long
79#elif defined(_CRAY) || defined(__ILP64__)
80#define MD5_LONG unsigned long
81#define MD5_LONG_LOG2 3
82/*
83 * _CRAY note. I could declare short, but I have no idea what impact
84 * does it have on performance on none-T3E machines. I could declare
85 * int, but at least on C90 sizeof(int) can be chosen at compile time.
86 * So I've chosen long...
87 * <appro@fy.chalmers.se>
88 */
89#else
90#define MD5_LONG unsigned int
91#endif
92
66#define MD5_CBLOCK 64 93#define MD5_CBLOCK 64
67#define MD5_LBLOCK 16 94#define MD5_LBLOCK (MD5_CBLOCK/4)
68#define MD5_BLOCK 16
69#define MD5_LAST_BLOCK 56
70#define MD5_LENGTH_BLOCK 8
71#define MD5_DIGEST_LENGTH 16 95#define MD5_DIGEST_LENGTH 16
72 96
73typedef struct MD5state_st 97typedef struct MD5state_st
74 { 98 {
75 unsigned long A,B,C,D; 99 MD5_LONG A,B,C,D;
76 unsigned long Nl,Nh; 100 MD5_LONG Nl,Nh;
77 unsigned long data[MD5_LBLOCK]; 101 MD5_LONG data[MD5_LBLOCK];
78 int num; 102 int num;
79 } MD5_CTX; 103 } MD5_CTX;
80 104
81#ifndef NOPROTO
82void MD5_Init(MD5_CTX *c); 105void MD5_Init(MD5_CTX *c);
83void MD5_Update(MD5_CTX *c, unsigned char *data, unsigned long len); 106void MD5_Update(MD5_CTX *c, const unsigned char *data, unsigned long len);
84void MD5_Final(unsigned char *md, MD5_CTX *c); 107void MD5_Final(unsigned char *md, MD5_CTX *c);
85unsigned char *MD5(unsigned char *d, unsigned long n, unsigned char *md); 108unsigned char *MD5(unsigned char *d, unsigned long n, unsigned char *md);
86void MD5_Transform(MD5_CTX *c, unsigned char *b); 109void MD5_Transform(MD5_CTX *c, const unsigned char *b);
87#else
88void MD5_Init();
89void MD5_Update();
90void MD5_Final();
91unsigned char *MD5();
92void MD5_Transform();
93#endif
94
95#ifdef __cplusplus 110#ifdef __cplusplus
96} 111}
97#endif 112#endif
diff --git a/src/lib/libcrypto/md5/md5_dgst.c b/src/lib/libcrypto/md5/md5_dgst.c
index 43b3498d92..ba0115ae79 100644
--- a/src/lib/libcrypto/md5/md5_dgst.c
+++ b/src/lib/libcrypto/md5/md5_dgst.c
@@ -58,8 +58,9 @@
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "md5_locl.h" 60#include "md5_locl.h"
61#include <openssl/opensslv.h>
61 62
62char *MD5_version="MD5 part of SSLeay 0.9.0b 29-Jun-1998"; 63char *MD5_version="MD5" OPENSSL_VERSION_PTEXT;
63 64
64/* Implemented from RFC1321 The MD5 Message-Digest Algorithm 65/* Implemented from RFC1321 The MD5 Message-Digest Algorithm
65 */ 66 */
@@ -69,24 +70,7 @@ char *MD5_version="MD5 part of SSLeay 0.9.0b 29-Jun-1998";
69#define INIT_DATA_C (unsigned long)0x98badcfeL 70#define INIT_DATA_C (unsigned long)0x98badcfeL
70#define INIT_DATA_D (unsigned long)0x10325476L 71#define INIT_DATA_D (unsigned long)0x10325476L
71 72
72#ifndef NOPROTO 73void MD5_Init(MD5_CTX *c)
73# ifdef MD5_ASM
74 void md5_block_x86(MD5_CTX *c, unsigned long *p,int num);
75# define md5_block md5_block_x86
76# else
77 static void md5_block(MD5_CTX *c, unsigned long *p,int num);
78# endif
79#else
80# ifdef MD5_ASM
81 void md5_block_x86();
82# define md5_block md5_block_x86
83# else
84 static void md5_block();
85# endif
86#endif
87
88void MD5_Init(c)
89MD5_CTX *c;
90 { 74 {
91 c->A=INIT_DATA_A; 75 c->A=INIT_DATA_A;
92 c->B=INIT_DATA_B; 76 c->B=INIT_DATA_B;
@@ -97,190 +81,32 @@ MD5_CTX *c;
97 c->num=0; 81 c->num=0;
98 } 82 }
99 83
100void MD5_Update(c, data, len) 84#ifndef md5_block_host_order
101MD5_CTX *c; 85void md5_block_host_order (MD5_CTX *c, const void *data, int num)
102register unsigned char *data;
103unsigned long len;
104 {
105 register ULONG *p;
106 int sw,sc;
107 ULONG l;
108
109 if (len == 0) return;
110
111 l=(c->Nl+(len<<3))&0xffffffffL;
112 /* 95-05-24 eay Fixed a bug with the overflow handling, thanks to
113 * Wei Dai <weidai@eskimo.com> for pointing it out. */
114 if (l < c->Nl) /* overflow */
115 c->Nh++;
116 c->Nh+=(len>>29);
117 c->Nl=l;
118
119 if (c->num != 0)
120 {
121 p=c->data;
122 sw=c->num>>2;
123 sc=c->num&0x03;
124
125 if ((c->num+len) >= MD5_CBLOCK)
126 {
127 l= p[sw];
128 p_c2l(data,l,sc);
129 p[sw++]=l;
130 for (; sw<MD5_LBLOCK; sw++)
131 {
132 c2l(data,l);
133 p[sw]=l;
134 }
135 len-=(MD5_CBLOCK-c->num);
136
137 md5_block(c,p,64);
138 c->num=0;
139 /* drop through and do the rest */
140 }
141 else
142 {
143 int ew,ec;
144
145 c->num+=(int)len;
146 if ((sc+len) < 4) /* ugly, add char's to a word */
147 {
148 l= p[sw];
149 p_c2l_p(data,l,sc,len);
150 p[sw]=l;
151 }
152 else
153 {
154 ew=(c->num>>2);
155 ec=(c->num&0x03);
156 l= p[sw];
157 p_c2l(data,l,sc);
158 p[sw++]=l;
159 for (; sw < ew; sw++)
160 { c2l(data,l); p[sw]=l; }
161 if (ec)
162 {
163 c2l_p(data,l,ec);
164 p[sw]=l;
165 }
166 }
167 return;
168 }
169 }
170 /* we now can process the input data in blocks of MD5_CBLOCK
171 * chars and save the leftovers to c->data. */
172#ifdef L_ENDIAN
173 if ((((unsigned long)data)%sizeof(ULONG)) == 0)
174 {
175 sw=(int)len/MD5_CBLOCK;
176 if (sw > 0)
177 {
178 sw*=MD5_CBLOCK;
179 md5_block(c,(ULONG *)data,sw);
180 data+=sw;
181 len-=sw;
182 }
183 }
184#endif
185 p=c->data;
186 while (len >= MD5_CBLOCK)
187 {
188#if defined(L_ENDIAN) || defined(B_ENDIAN)
189 if (p != (unsigned long *)data)
190 memcpy(p,data,MD5_CBLOCK);
191 data+=MD5_CBLOCK;
192#ifdef B_ENDIAN
193 for (sw=(MD5_LBLOCK/4); sw; sw--)
194 {
195 Endian_Reverse32(p[0]);
196 Endian_Reverse32(p[1]);
197 Endian_Reverse32(p[2]);
198 Endian_Reverse32(p[3]);
199 p+=4;
200 }
201#endif
202#else
203 for (sw=(MD5_LBLOCK/4); sw; sw--)
204 {
205 c2l(data,l); *(p++)=l;
206 c2l(data,l); *(p++)=l;
207 c2l(data,l); *(p++)=l;
208 c2l(data,l); *(p++)=l;
209 }
210#endif
211 p=c->data;
212 md5_block(c,p,64);
213 len-=MD5_CBLOCK;
214 }
215 sc=(int)len;
216 c->num=sc;
217 if (sc)
218 {
219 sw=sc>>2; /* words to copy */
220#ifdef L_ENDIAN
221 p[sw]=0;
222 memcpy(p,data,sc);
223#else
224 sc&=0x03;
225 for ( ; sw; sw--)
226 { c2l(data,l); *(p++)=l; }
227 c2l_p(data,l,sc);
228 *p=l;
229#endif
230 }
231 }
232
233void MD5_Transform(c,b)
234MD5_CTX *c;
235unsigned char *b;
236 { 86 {
237 ULONG p[16]; 87 const MD5_LONG *X=data;
238#if !defined(L_ENDIAN) 88 register unsigned long A,B,C,D;
239 ULONG *q; 89 /*
240 int i; 90 * In case you wonder why A-D are declared as long and not
241#endif 91 * as MD5_LONG. Doing so results in slight performance
242 92 * boost on LP64 architectures. The catch is we don't
243#if defined(B_ENDIAN) || defined(L_ENDIAN) 93 * really care if 32 MSBs of a 64-bit register get polluted
244 memcpy(p,b,64); 94 * with eventual overflows as we *save* only 32 LSBs in
245#ifdef B_ENDIAN 95 * *either* case. Now declaring 'em long excuses the compiler
246 q=p; 96 * from keeping 32 MSBs zeroed resulting in 13% performance
247 for (i=(MD5_LBLOCK/4); i; i--) 97 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
248 { 98 * Well, to be honest it should say that this *prevents*
249 Endian_Reverse32(q[0]); 99 * performance degradation.
250 Endian_Reverse32(q[1]); 100 *
251 Endian_Reverse32(q[2]); 101 * <appro@fy.chalmers.se>
252 Endian_Reverse32(q[3]); 102 */
253 q+=4;
254 }
255#endif
256#else
257 q=p;
258 for (i=(MD5_LBLOCK/4); i; i--)
259 {
260 ULONG l;
261 c2l(b,l); *(q++)=l;
262 c2l(b,l); *(q++)=l;
263 c2l(b,l); *(q++)=l;
264 c2l(b,l); *(q++)=l;
265 }
266#endif
267 md5_block(c,p,64);
268 }
269
270#ifndef MD5_ASM
271
272static void md5_block(c, X, num)
273MD5_CTX *c;
274register ULONG *X;
275int num;
276 {
277 register ULONG A,B,C,D;
278 103
279 A=c->A; 104 A=c->A;
280 B=c->B; 105 B=c->B;
281 C=c->C; 106 C=c->C;
282 D=c->D; 107 D=c->D;
283 for (;;) 108
109 for (;num--;X+=HASH_LBLOCK)
284 { 110 {
285 /* Round 0 */ 111 /* Round 0 */
286 R0(A,B,C,D,X[ 0], 7,0xd76aa478L); 112 R0(A,B,C,D,X[ 0], 7,0xd76aa478L);
@@ -351,80 +177,131 @@ int num;
351 R3(C,D,A,B,X[ 2],15,0x2ad7d2bbL); 177 R3(C,D,A,B,X[ 2],15,0x2ad7d2bbL);
352 R3(B,C,D,A,X[ 9],21,0xeb86d391L); 178 R3(B,C,D,A,X[ 9],21,0xeb86d391L);
353 179
354 A+=c->A&0xffffffffL; 180 A = c->A += A;
355 B+=c->B&0xffffffffL; 181 B = c->B += B;
356 c->A=A; 182 C = c->C += C;
357 c->B=B; 183 D = c->D += D;
358 C+=c->C&0xffffffffL;
359 D+=c->D&0xffffffffL;
360 c->C=C;
361 c->D=D;
362 X+=16;
363 num-=64;
364 if (num <= 0) break;
365 } 184 }
366 } 185 }
367#endif 186#endif
368 187
369void MD5_Final(md, c) 188#ifndef md5_block_data_order
370unsigned char *md; 189void md5_block_data_order (MD5_CTX *c, const void *data_, int num)
371MD5_CTX *c;
372 { 190 {
373 register int i,j; 191 const unsigned char *data=data_;
374 register ULONG l; 192 register unsigned long A,B,C,D,l;
375 register ULONG *p; 193 /*
376 static unsigned char end[4]={0x80,0x00,0x00,0x00}; 194 * In case you wonder why A-D are declared as long and not
377 unsigned char *cp=end; 195 * as MD5_LONG. Doing so results in slight performance
196 * boost on LP64 architectures. The catch is we don't
197 * really care if 32 MSBs of a 64-bit register get polluted
198 * with eventual overflows as we *save* only 32 LSBs in
199 * *either* case. Now declaring 'em long excuses the compiler
200 * from keeping 32 MSBs zeroed resulting in 13% performance
201 * improvement under SPARC Solaris7/64 and 5% under AlphaLinux.
202 * Well, to be honest it should say that this *prevents*
203 * performance degradation.
204 *
205 * <appro@fy.chalmers.se>
206 */
207 MD5_LONG X[MD5_LBLOCK];
208 /*
209 * In case you wonder why don't I use c->data for this.
210 * RISCs usually have a handful of registers and if X is
211 * declared as automatic array good optimizing compiler
212 * shall accomodate at least part of it in register bank
213 * instead of memory.
214 *
215 * <appro@fy.chalmers.se>
216 */
378 217
379 /* c->num should definitly have room for at least one more byte. */ 218 A=c->A;
380 p=c->data; 219 B=c->B;
381 j=c->num; 220 C=c->C;
382 i=j>>2; 221 D=c->D;
383 222
384 /* purify often complains about the following line as an 223 for (;num--;)
385 * Uninitialized Memory Read. While this can be true, the
386 * following p_c2l macro will reset l when that case is true.
387 * This is because j&0x03 contains the number of 'valid' bytes
388 * already in p[i]. If and only if j&0x03 == 0, the UMR will
389 * occur but this is also the only time p_c2l will do
390 * l= *(cp++) instead of l|= *(cp++)
391 * Many thanks to Alex Tang <altitude@cic.net> for pickup this
392 * 'potential bug' */
393#ifdef PURIFY
394 if ((j&0x03) == 0) p[i]=0;
395#endif
396 l=p[i];
397 p_c2l(cp,l,j&0x03);
398 p[i]=l;
399 i++;
400 /* i is the next 'undefined word' */
401 if (c->num >= MD5_LAST_BLOCK)
402 { 224 {
403 for (; i<MD5_LBLOCK; i++) 225 HOST_c2l(data,l); X[ 0]=l; HOST_c2l(data,l); X[ 1]=l;
404 p[i]=0; 226 /* Round 0 */
405 md5_block(c,p,64); 227 R0(A,B,C,D,X[ 0], 7,0xd76aa478L); HOST_c2l(data,l); X[ 2]=l;
406 i=0; 228 R0(D,A,B,C,X[ 1],12,0xe8c7b756L); HOST_c2l(data,l); X[ 3]=l;
407 } 229 R0(C,D,A,B,X[ 2],17,0x242070dbL); HOST_c2l(data,l); X[ 4]=l;
408 for (; i<(MD5_LBLOCK-2); i++) 230 R0(B,C,D,A,X[ 3],22,0xc1bdceeeL); HOST_c2l(data,l); X[ 5]=l;
409 p[i]=0; 231 R0(A,B,C,D,X[ 4], 7,0xf57c0fafL); HOST_c2l(data,l); X[ 6]=l;
410 p[MD5_LBLOCK-2]=c->Nl; 232 R0(D,A,B,C,X[ 5],12,0x4787c62aL); HOST_c2l(data,l); X[ 7]=l;
411 p[MD5_LBLOCK-1]=c->Nh; 233 R0(C,D,A,B,X[ 6],17,0xa8304613L); HOST_c2l(data,l); X[ 8]=l;
412 md5_block(c,p,64); 234 R0(B,C,D,A,X[ 7],22,0xfd469501L); HOST_c2l(data,l); X[ 9]=l;
413 cp=md; 235 R0(A,B,C,D,X[ 8], 7,0x698098d8L); HOST_c2l(data,l); X[10]=l;
414 l=c->A; l2c(l,cp); 236 R0(D,A,B,C,X[ 9],12,0x8b44f7afL); HOST_c2l(data,l); X[11]=l;
415 l=c->B; l2c(l,cp); 237 R0(C,D,A,B,X[10],17,0xffff5bb1L); HOST_c2l(data,l); X[12]=l;
416 l=c->C; l2c(l,cp); 238 R0(B,C,D,A,X[11],22,0x895cd7beL); HOST_c2l(data,l); X[13]=l;
417 l=c->D; l2c(l,cp); 239 R0(A,B,C,D,X[12], 7,0x6b901122L); HOST_c2l(data,l); X[14]=l;
240 R0(D,A,B,C,X[13],12,0xfd987193L); HOST_c2l(data,l); X[15]=l;
241 R0(C,D,A,B,X[14],17,0xa679438eL);
242 R0(B,C,D,A,X[15],22,0x49b40821L);
243 /* Round 1 */
244 R1(A,B,C,D,X[ 1], 5,0xf61e2562L);
245 R1(D,A,B,C,X[ 6], 9,0xc040b340L);
246 R1(C,D,A,B,X[11],14,0x265e5a51L);
247 R1(B,C,D,A,X[ 0],20,0xe9b6c7aaL);
248 R1(A,B,C,D,X[ 5], 5,0xd62f105dL);
249 R1(D,A,B,C,X[10], 9,0x02441453L);
250 R1(C,D,A,B,X[15],14,0xd8a1e681L);
251 R1(B,C,D,A,X[ 4],20,0xe7d3fbc8L);
252 R1(A,B,C,D,X[ 9], 5,0x21e1cde6L);
253 R1(D,A,B,C,X[14], 9,0xc33707d6L);
254 R1(C,D,A,B,X[ 3],14,0xf4d50d87L);
255 R1(B,C,D,A,X[ 8],20,0x455a14edL);
256 R1(A,B,C,D,X[13], 5,0xa9e3e905L);
257 R1(D,A,B,C,X[ 2], 9,0xfcefa3f8L);
258 R1(C,D,A,B,X[ 7],14,0x676f02d9L);
259 R1(B,C,D,A,X[12],20,0x8d2a4c8aL);
260 /* Round 2 */
261 R2(A,B,C,D,X[ 5], 4,0xfffa3942L);
262 R2(D,A,B,C,X[ 8],11,0x8771f681L);
263 R2(C,D,A,B,X[11],16,0x6d9d6122L);
264 R2(B,C,D,A,X[14],23,0xfde5380cL);
265 R2(A,B,C,D,X[ 1], 4,0xa4beea44L);
266 R2(D,A,B,C,X[ 4],11,0x4bdecfa9L);
267 R2(C,D,A,B,X[ 7],16,0xf6bb4b60L);
268 R2(B,C,D,A,X[10],23,0xbebfbc70L);
269 R2(A,B,C,D,X[13], 4,0x289b7ec6L);
270 R2(D,A,B,C,X[ 0],11,0xeaa127faL);
271 R2(C,D,A,B,X[ 3],16,0xd4ef3085L);
272 R2(B,C,D,A,X[ 6],23,0x04881d05L);
273 R2(A,B,C,D,X[ 9], 4,0xd9d4d039L);
274 R2(D,A,B,C,X[12],11,0xe6db99e5L);
275 R2(C,D,A,B,X[15],16,0x1fa27cf8L);
276 R2(B,C,D,A,X[ 2],23,0xc4ac5665L);
277 /* Round 3 */
278 R3(A,B,C,D,X[ 0], 6,0xf4292244L);
279 R3(D,A,B,C,X[ 7],10,0x432aff97L);
280 R3(C,D,A,B,X[14],15,0xab9423a7L);
281 R3(B,C,D,A,X[ 5],21,0xfc93a039L);
282 R3(A,B,C,D,X[12], 6,0x655b59c3L);
283 R3(D,A,B,C,X[ 3],10,0x8f0ccc92L);
284 R3(C,D,A,B,X[10],15,0xffeff47dL);
285 R3(B,C,D,A,X[ 1],21,0x85845dd1L);
286 R3(A,B,C,D,X[ 8], 6,0x6fa87e4fL);
287 R3(D,A,B,C,X[15],10,0xfe2ce6e0L);
288 R3(C,D,A,B,X[ 6],15,0xa3014314L);
289 R3(B,C,D,A,X[13],21,0x4e0811a1L);
290 R3(A,B,C,D,X[ 4], 6,0xf7537e82L);
291 R3(D,A,B,C,X[11],10,0xbd3af235L);
292 R3(C,D,A,B,X[ 2],15,0x2ad7d2bbL);
293 R3(B,C,D,A,X[ 9],21,0xeb86d391L);
418 294
419 /* clear stuff, md5_block may be leaving some stuff on the stack 295 A = c->A += A;
420 * but I'm not worried :-) */ 296 B = c->B += B;
421 c->num=0; 297 C = c->C += C;
422/* memset((char *)&c,0,sizeof(c));*/ 298 D = c->D += D;
299 }
423 } 300 }
301#endif
424 302
425#ifdef undef 303#ifdef undef
426int printit(l) 304int printit(unsigned long *l)
427unsigned long *l;
428 { 305 {
429 int i,ii; 306 int i,ii;
430 307
diff --git a/src/lib/libcrypto/md5/md5_locl.h b/src/lib/libcrypto/md5/md5_locl.h
index dbbe1b71ca..9d04696dbd 100644
--- a/src/lib/libcrypto/md5/md5_locl.h
+++ b/src/lib/libcrypto/md5/md5_locl.h
@@ -56,102 +56,84 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59/* On sparc, this actually slows things down :-( */
60#if defined(sun)
61#undef B_ENDIAN
62#endif
63
64#include <stdlib.h> 59#include <stdlib.h>
65#include <string.h> 60#include <string.h>
66#include "md5.h" 61#include <openssl/opensslconf.h>
67 62#include <openssl/md5.h>
68#define ULONG unsigned long
69#define UCHAR unsigned char
70#define UINT unsigned int
71 63
72#if defined(NOCONST) 64#ifndef MD5_LONG_LOG2
73#define const 65#define MD5_LONG_LOG2 2 /* default to 32 bits */
74#endif 66#endif
75 67
76#undef c2l 68#ifdef MD5_ASM
77#define c2l(c,l) (l = ((unsigned long)(*((c)++))) , \ 69# if defined(__i386) || defined(_M_IX86)
78 l|=(((unsigned long)(*((c)++)))<< 8), \ 70# define md5_block_host_order md5_block_asm_host_order
79 l|=(((unsigned long)(*((c)++)))<<16), \ 71# elif defined(__sparc) && defined(ULTRASPARC)
80 l|=(((unsigned long)(*((c)++)))<<24)) 72 void md5_block_asm_data_order_aligned (MD5_CTX *c, const MD5_LONG *p,int num);
81 73# define HASH_BLOCK_DATA_ORDER_ALIGNED md5_block_asm_data_order_aligned
82#undef p_c2l 74# endif
83#define p_c2l(c,l,n) { \ 75#endif
84 switch (n) { \
85 case 0: l =((unsigned long)(*((c)++))); \
86 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
87 case 2: l|=((unsigned long)(*((c)++)))<<16; \
88 case 3: l|=((unsigned long)(*((c)++)))<<24; \
89 } \
90 }
91
92/* NOTE the pointer is not incremented at the end of this */
93#undef c2l_p
94#define c2l_p(c,l,n) { \
95 l=0; \
96 (c)+=n; \
97 switch (n) { \
98 case 3: l =((unsigned long)(*(--(c))))<<16; \
99 case 2: l|=((unsigned long)(*(--(c))))<< 8; \
100 case 1: l|=((unsigned long)(*(--(c)))) ; \
101 } \
102 }
103 76
104#undef p_c2l_p 77void md5_block_host_order (MD5_CTX *c, const void *p,int num);
105#define p_c2l_p(c,l,sc,len) { \ 78void md5_block_data_order (MD5_CTX *c, const void *p,int num);
106 switch (sc) \
107 { \
108 case 0: l =((unsigned long)(*((c)++))); \
109 if (--len == 0) break; \
110 case 1: l|=((unsigned long)(*((c)++)))<< 8; \
111 if (--len == 0) break; \
112 case 2: l|=((unsigned long)(*((c)++)))<<16; \
113 } \
114 }
115 79
116#undef l2c 80#if defined(__i386) || defined(_M_IX86)
117#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ 81/*
118 *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ 82 * *_block_host_order is expected to handle aligned data while
119 *((c)++)=(unsigned char)(((l)>>16)&0xff), \ 83 * *_block_data_order - unaligned. As algorithm and host (x86)
120 *((c)++)=(unsigned char)(((l)>>24)&0xff)) 84 * are in this case of the same "endianess" these two are
85 * otherwise indistinguishable. But normally you don't want to
86 * call the same function because unaligned access in places
87 * where alignment is expected is usually a "Bad Thing". Indeed,
88 * on RISCs you get punished with BUS ERROR signal or *severe*
89 * performance degradation. Intel CPUs are in turn perfectly
90 * capable of loading unaligned data without such drastic side
91 * effect. Yes, they say it's slower than aligned load, but no
92 * exception is generated and therefore performance degradation
93 * is *incomparable* with RISCs. What we should weight here is
94 * costs of unaligned access against costs of aligning data.
95 * According to my measurements allowing unaligned access results
96 * in ~9% performance improvement on Pentium II operating at
97 * 266MHz. I won't be surprised if the difference will be higher
98 * on faster systems:-)
99 *
100 * <appro@fy.chalmers.se>
101 */
102#define md5_block_data_order md5_block_host_order
103#endif
121 104
122/* NOTE - c is not incremented as per l2c */ 105#define DATA_ORDER_IS_LITTLE_ENDIAN
123#undef l2cn 106
124#define l2cn(l1,l2,c,n) { \ 107#define HASH_LONG MD5_LONG
125 c+=n; \ 108#define HASH_LONG_LOG2 MD5_LONG_LOG2
126 switch (n) { \ 109#define HASH_CTX MD5_CTX
127 case 8: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \ 110#define HASH_CBLOCK MD5_CBLOCK
128 case 7: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \ 111#define HASH_LBLOCK MD5_LBLOCK
129 case 6: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \ 112#define HASH_UPDATE MD5_Update
130 case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \ 113#define HASH_TRANSFORM MD5_Transform
131 case 4: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \ 114#define HASH_FINAL MD5_Final
132 case 3: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \ 115#define HASH_BLOCK_HOST_ORDER md5_block_host_order
133 case 2: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \ 116#if !defined(L_ENDIAN) || defined(md5_block_data_order)
134 case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \ 117#define HASH_BLOCK_DATA_ORDER md5_block_data_order
135 } \ 118/*
136 } 119 * Little-endians (Intel and Alpha) feel better without this.
120 * It looks like memcpy does better job than generic
121 * md5_block_data_order on copying-n-aligning input data.
122 * But franlky speaking I didn't expect such result on Alpha.
123 * On the other hand I've got this with egcs-1.0.2 and if
124 * program is compiled with another (better?) compiler it
125 * might turn out other way around.
126 *
127 * <appro@fy.chalmers.se>
128 */
129#endif
137 130
138/* A nice byte order reversal from Wei Dai <weidai@eskimo.com> */ 131#ifndef FLAT_INC
139#if defined(WIN32) 132#include "../md32_common.h"
140/* 5 instructions with rotate instruction, else 9 */
141#define Endian_Reverse32(a) \
142 { \
143 unsigned long l=(a); \
144 (a)=((ROTATE(l,8)&0x00FF00FF)|(ROTATE(l,24)&0xFF00FF00)); \
145 }
146#else 133#else
147/* 6 instructions with rotate instruction, else 8 */ 134#include "md32_common.h"
148#define Endian_Reverse32(a) \
149 { \
150 unsigned long l=(a); \
151 l=(((l&0xFF00FF00)>>8L)|((l&0x00FF00FF)<<8L)); \
152 (a)=ROTATE(l,16L); \
153 }
154#endif 135#endif
136
155/* 137/*
156#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z))) 138#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
157#define G(x,y,z) (((x) & (z)) | ((y) & (~(z)))) 139#define G(x,y,z) (((x) & (z)) | ((y) & (~(z))))
@@ -166,14 +148,6 @@
166#define H(b,c,d) ((b) ^ (c) ^ (d)) 148#define H(b,c,d) ((b) ^ (c) ^ (d))
167#define I(b,c,d) (((~(d)) | (b)) ^ (c)) 149#define I(b,c,d) (((~(d)) | (b)) ^ (c))
168 150
169#undef ROTATE
170#if defined(WIN32)
171#define ROTATE(a,n) _lrotl(a,n)
172#else
173#define ROTATE(a,n) (((a)<<(n))|(((a)&0xffffffff)>>(32-(n))))
174#endif
175
176
177#define R0(a,b,c,d,k,s,t) { \ 151#define R0(a,b,c,d,k,s,t) { \
178 a+=((k)+(t)+F((b),(c),(d))); \ 152 a+=((k)+(t)+F((b),(c),(d))); \
179 a=ROTATE(a,s); \ 153 a=ROTATE(a,s); \
diff --git a/src/lib/libcrypto/md5/md5_one.c b/src/lib/libcrypto/md5/md5_one.c
index ab6bb435f9..4b10e7f940 100644
--- a/src/lib/libcrypto/md5/md5_one.c
+++ b/src/lib/libcrypto/md5/md5_one.c
@@ -57,19 +57,37 @@
57 */ 57 */
58 58
59#include <stdio.h> 59#include <stdio.h>
60#include "md5_locl.h" 60#include <string.h>
61#include <openssl/md5.h>
61 62
62unsigned char *MD5(d, n, md) 63#ifdef CHARSET_EBCDIC
63unsigned char *d; 64#include <openssl/ebcdic.h>
64unsigned long n; 65#endif
65unsigned char *md; 66
67unsigned char *MD5(unsigned char *d, unsigned long n, unsigned char *md)
66 { 68 {
67 MD5_CTX c; 69 MD5_CTX c;
68 static unsigned char m[MD5_DIGEST_LENGTH]; 70 static unsigned char m[MD5_DIGEST_LENGTH];
69 71
70 if (md == NULL) md=m; 72 if (md == NULL) md=m;
71 MD5_Init(&c); 73 MD5_Init(&c);
74#ifndef CHARSET_EBCDIC
72 MD5_Update(&c,d,n); 75 MD5_Update(&c,d,n);
76#else
77 {
78 char temp[1024];
79 unsigned long chunk;
80
81 while (n > 0)
82 {
83 chunk = (n > sizeof(temp)) ? sizeof(temp) : n;
84 ebcdic2ascii(temp, d, chunk);
85 MD5_Update(&c,temp,chunk);
86 n -= chunk;
87 d += chunk;
88 }
89 }
90#endif
73 MD5_Final(md,&c); 91 MD5_Final(md,&c);
74 memset(&c,0,sizeof(c)); /* security consideration */ 92 memset(&c,0,sizeof(c)); /* security consideration */
75 return(md); 93 return(md);
diff --git a/src/lib/libcrypto/md5/md5s.cpp b/src/lib/libcrypto/md5/md5s.cpp
index ef8e175df0..dd343fd4e6 100644
--- a/src/lib/libcrypto/md5/md5s.cpp
+++ b/src/lib/libcrypto/md5/md5s.cpp
@@ -32,7 +32,7 @@ void GetTSC(unsigned long& tsc)
32 32
33#include <stdio.h> 33#include <stdio.h>
34#include <stdlib.h> 34#include <stdlib.h>
35#include "md5.h" 35#include <openssl/md5.h>
36 36
37extern "C" { 37extern "C" {
38void md5_block_x86(MD5_CTX *ctx, unsigned char *buffer,int num); 38void md5_block_x86(MD5_CTX *ctx, unsigned char *buffer,int num);
diff --git a/src/lib/libcrypto/md5/md5test.c b/src/lib/libcrypto/md5/md5test.c
index 74b84bc67f..a192a62bb3 100644
--- a/src/lib/libcrypto/md5/md5test.c
+++ b/src/lib/libcrypto/md5/md5test.c
@@ -59,7 +59,15 @@
59#include <stdio.h> 59#include <stdio.h>
60#include <string.h> 60#include <string.h>
61#include <stdlib.h> 61#include <stdlib.h>
62#include "md5.h" 62
63#ifdef NO_MD5
64int main(int argc, char *argv[])
65{
66 printf("No MD5 support\n");
67 return(0);
68}
69#else
70#include <openssl/md5.h>
63 71
64char *test[]={ 72char *test[]={
65 "", 73 "",
@@ -82,15 +90,8 @@ char *ret[]={
82 "57edf4a22be3c955ac49da2e2107b67a", 90 "57edf4a22be3c955ac49da2e2107b67a",
83 }; 91 };
84 92
85#ifndef NOPROTO
86static char *pt(unsigned char *md); 93static char *pt(unsigned char *md);
87#else 94int main(int argc, char *argv[])
88static char *pt();
89#endif
90
91int main(argc,argv)
92int argc;
93char *argv[];
94 { 95 {
95 int i,err=0; 96 int i,err=0;
96 unsigned char **P,**R; 97 unsigned char **P,**R;
@@ -118,8 +119,7 @@ char *argv[];
118 return(0); 119 return(0);
119 } 120 }
120 121
121static char *pt(md) 122static char *pt(unsigned char *md)
122unsigned char *md;
123 { 123 {
124 int i; 124 int i;
125 static char buf[80]; 125 static char buf[80];
@@ -128,3 +128,4 @@ unsigned char *md;
128 sprintf(&(buf[i*2]),"%02x",md[i]); 128 sprintf(&(buf[i*2]),"%02x",md[i]);
129 return(buf); 129 return(buf);
130 } 130 }
131#endif