summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2023-07-08 06:50:38 +0000
committerjsing <>2023-07-08 06:50:38 +0000
commit63a2086678725b7f197526a51d1bbda827c60a2c (patch)
tree38d4a18f40cc8bf51e36e621a03e9cf488bbc14a /src
parent30e39e11e8d9fc4a5f72bfac9f4f25cc2ac28e92 (diff)
downloadopenbsd-63a2086678725b7f197526a51d1bbda827c60a2c.tar.gz
openbsd-63a2086678725b7f197526a51d1bbda827c60a2c.tar.bz2
openbsd-63a2086678725b7f197526a51d1bbda827c60a2c.zip
Hit md5 with the style(9) stick.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/md5/md5.h27
-rw-r--r--src/lib/libcrypto/md5/md5_dgst.c234
-rw-r--r--src/lib/libcrypto/md5/md5_one.c32
3 files changed, 163 insertions, 130 deletions
diff --git a/src/lib/libcrypto/md5/md5.h b/src/lib/libcrypto/md5/md5.h
index e2c511c7c5..d248c93a85 100644
--- a/src/lib/libcrypto/md5/md5.h
+++ b/src/lib/libcrypto/md5/md5.h
@@ -1,25 +1,25 @@
1/* $OpenBSD: md5.h,v 1.20 2014/10/20 13:06:54 bcook Exp $ */ 1/* $OpenBSD: md5.h,v 1.21 2023/07/08 06:50:38 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA, 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 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 13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 * 15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in 16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed. 17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution 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. 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 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. 21 * in documentation (online or textual) provided with the package.
22 * 22 *
23 * Redistribution and use in source and binary forms, with or without 23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions 24 * modification, are permitted provided that the following conditions
25 * are met: 25 * are met:
@@ -34,10 +34,10 @@
34 * Eric Young (eay@cryptsoft.com)" 34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library 35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-). 36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from 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: 38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 * 40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 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 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE. 51 * SUCH DAMAGE.
52 * 52 *
53 * The licence and distribution terms for any publically available version or 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 54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
@@ -86,20 +86,19 @@ extern "C" {
86#define MD5_LBLOCK (MD5_CBLOCK/4) 86#define MD5_LBLOCK (MD5_CBLOCK/4)
87#define MD5_DIGEST_LENGTH 16 87#define MD5_DIGEST_LENGTH 16
88 88
89typedef struct MD5state_st 89typedef struct MD5state_st {
90 { 90 MD5_LONG A, B,C, D;
91 MD5_LONG A,B,C,D; 91 MD5_LONG Nl, Nh;
92 MD5_LONG Nl,Nh;
93 MD5_LONG data[MD5_LBLOCK]; 92 MD5_LONG data[MD5_LBLOCK];
94 unsigned int num; 93 unsigned int num;
95 } MD5_CTX; 94} MD5_CTX;
96 95
97int MD5_Init(MD5_CTX *c); 96int MD5_Init(MD5_CTX *c);
98int MD5_Update(MD5_CTX *c, const void *data, size_t len) 97int MD5_Update(MD5_CTX *c, const void *data, size_t len)
99 __attribute__ ((__bounded__(__buffer__,2,3))); 98 __attribute__ ((__bounded__(__buffer__, 2, 3)));
100int MD5_Final(unsigned char *md, MD5_CTX *c); 99int MD5_Final(unsigned char *md, MD5_CTX *c);
101unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md) 100unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md)
102 __attribute__ ((__bounded__(__buffer__,1,2))); 101 __attribute__ ((__bounded__(__buffer__, 1, 2)));
103void MD5_Transform(MD5_CTX *c, const unsigned char *b); 102void MD5_Transform(MD5_CTX *c, const unsigned char *b);
104#ifdef __cplusplus 103#ifdef __cplusplus
105} 104}
diff --git a/src/lib/libcrypto/md5/md5_dgst.c b/src/lib/libcrypto/md5/md5_dgst.c
index 5c08493d53..19a2b01e17 100644
--- a/src/lib/libcrypto/md5/md5_dgst.c
+++ b/src/lib/libcrypto/md5/md5_dgst.c
@@ -1,25 +1,25 @@
1/* $OpenBSD: md5_dgst.c,v 1.16 2023/07/08 06:41:45 jsing Exp $ */ 1/* $OpenBSD: md5_dgst.c,v 1.17 2023/07/08 06:50:38 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA, 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 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 13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 * 15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in 16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed. 17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution 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. 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 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. 21 * in documentation (online or textual) provided with the package.
22 * 22 *
23 * Redistribution and use in source and binary forms, with or without 23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions 24 * modification, are permitted provided that the following conditions
25 * are met: 25 * are met:
@@ -34,10 +34,10 @@
34 * Eric Young (eay@cryptsoft.com)" 34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library 35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-). 36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from 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: 38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 * 40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 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 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE. 51 * SUCH DAMAGE.
52 * 52 *
53 * The licence and distribution terms for any publically available version or 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 54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
@@ -78,7 +78,7 @@
78 78
79__BEGIN_HIDDEN_DECLS 79__BEGIN_HIDDEN_DECLS
80 80
81void md5_block_data_order (MD5_CTX *c, const void *p,size_t num); 81void md5_block_data_order (MD5_CTX *c, const void *p, size_t num);
82 82
83__END_HIDDEN_DECLS 83__END_HIDDEN_DECLS
84 84
@@ -143,115 +143,147 @@ __END_HIDDEN_DECLS
143#define INIT_DATA_C (unsigned long)0x98badcfeL 143#define INIT_DATA_C (unsigned long)0x98badcfeL
144#define INIT_DATA_D (unsigned long)0x10325476L 144#define INIT_DATA_D (unsigned long)0x10325476L
145 145
146int MD5_Init(MD5_CTX *c) 146int
147 { 147MD5_Init(MD5_CTX *c)
148 memset (c,0,sizeof(*c)); 148{
149 c->A=INIT_DATA_A; 149 memset (c, 0, sizeof(*c));
150 c->B=INIT_DATA_B; 150 c->A = INIT_DATA_A;
151 c->C=INIT_DATA_C; 151 c->B = INIT_DATA_B;
152 c->D=INIT_DATA_D; 152 c->C = INIT_DATA_C;
153 c->D = INIT_DATA_D;
153 return 1; 154 return 1;
154 } 155}
155 156
156#ifndef md5_block_data_order 157#ifndef md5_block_data_order
157#ifdef X 158#ifdef X
158#undef X 159#undef X
159#endif 160#endif
160void md5_block_data_order (MD5_CTX *c, const void *data_, size_t num) 161void
161 { 162md5_block_data_order(MD5_CTX *c, const void *data_, size_t num)
162 const unsigned char *data=data_; 163{
163 unsigned MD32_REG_T A,B,C,D,l; 164 const unsigned char *data = data_;
165 unsigned MD32_REG_T A, B,C, D, l;
164#ifndef MD32_XARRAY 166#ifndef MD32_XARRAY
165 /* See comment in crypto/sha/sha_locl.h for details. */ 167 /* See comment in crypto/sha/sha_locl.h for details. */
166 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 168 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
167 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 169 XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15;
168# define X(i) XX##i 170# define X(i) XX##i
169#else 171#else
170 MD5_LONG XX[MD5_LBLOCK]; 172 MD5_LONG XX[MD5_LBLOCK];
171# define X(i) XX[i] 173# define X(i) XX[i]
172#endif 174#endif
173 175
174 A=c->A; 176 A = c->A;
175 B=c->B; 177 B = c->B;
176 C=c->C; 178 C = c->C;
177 D=c->D; 179 D = c->D;
178 180
179 for (;num--;) 181 for (; num--; ) {
180 { 182 HOST_c2l(data, l);
181 HOST_c2l(data,l); X( 0)=l; HOST_c2l(data,l); X( 1)=l; 183 X( 0) = l;
182 /* Round 0 */ 184 HOST_c2l(data, l);
183 R0(A,B,C,D,X( 0), 7,0xd76aa478L); HOST_c2l(data,l); X( 2)=l; 185 X( 1) = l;
184 R0(D,A,B,C,X( 1),12,0xe8c7b756L); HOST_c2l(data,l); X( 3)=l; 186 /* Round 0 */
185 R0(C,D,A,B,X( 2),17,0x242070dbL); HOST_c2l(data,l); X( 4)=l; 187 R0(A, B,C, D,X( 0), 7, 0xd76aa478L);
186 R0(B,C,D,A,X( 3),22,0xc1bdceeeL); HOST_c2l(data,l); X( 5)=l; 188 HOST_c2l(data, l);
187 R0(A,B,C,D,X( 4), 7,0xf57c0fafL); HOST_c2l(data,l); X( 6)=l; 189 X( 2) = l;
188 R0(D,A,B,C,X( 5),12,0x4787c62aL); HOST_c2l(data,l); X( 7)=l; 190 R0(D, A,B, C,X( 1), 12, 0xe8c7b756L);
189 R0(C,D,A,B,X( 6),17,0xa8304613L); HOST_c2l(data,l); X( 8)=l; 191 HOST_c2l(data, l);
190 R0(B,C,D,A,X( 7),22,0xfd469501L); HOST_c2l(data,l); X( 9)=l; 192 X( 3) = l;
191 R0(A,B,C,D,X( 8), 7,0x698098d8L); HOST_c2l(data,l); X(10)=l; 193 R0(C, D,A, B,X( 2), 17, 0x242070dbL);
192 R0(D,A,B,C,X( 9),12,0x8b44f7afL); HOST_c2l(data,l); X(11)=l; 194 HOST_c2l(data, l);
193 R0(C,D,A,B,X(10),17,0xffff5bb1L); HOST_c2l(data,l); X(12)=l; 195 X( 4) = l;
194 R0(B,C,D,A,X(11),22,0x895cd7beL); HOST_c2l(data,l); X(13)=l; 196 R0(B, C,D, A,X( 3), 22, 0xc1bdceeeL);
195 R0(A,B,C,D,X(12), 7,0x6b901122L); HOST_c2l(data,l); X(14)=l; 197 HOST_c2l(data, l);
196 R0(D,A,B,C,X(13),12,0xfd987193L); HOST_c2l(data,l); X(15)=l; 198 X( 5) = l;
197 R0(C,D,A,B,X(14),17,0xa679438eL); 199 R0(A, B,C, D,X( 4), 7, 0xf57c0fafL);
198 R0(B,C,D,A,X(15),22,0x49b40821L); 200 HOST_c2l(data, l);
199 /* Round 1 */ 201 X( 6) = l;
200 R1(A,B,C,D,X( 1), 5,0xf61e2562L); 202 R0(D, A,B, C,X( 5), 12, 0x4787c62aL);
201 R1(D,A,B,C,X( 6), 9,0xc040b340L); 203 HOST_c2l(data, l);
202 R1(C,D,A,B,X(11),14,0x265e5a51L); 204 X( 7) = l;
203 R1(B,C,D,A,X( 0),20,0xe9b6c7aaL); 205 R0(C, D,A, B,X( 6), 17, 0xa8304613L);
204 R1(A,B,C,D,X( 5), 5,0xd62f105dL); 206 HOST_c2l(data, l);
205 R1(D,A,B,C,X(10), 9,0x02441453L); 207 X( 8) = l;
206 R1(C,D,A,B,X(15),14,0xd8a1e681L); 208 R0(B, C,D, A,X( 7), 22, 0xfd469501L);
207 R1(B,C,D,A,X( 4),20,0xe7d3fbc8L); 209 HOST_c2l(data, l);
208 R1(A,B,C,D,X( 9), 5,0x21e1cde6L); 210 X( 9) = l;
209 R1(D,A,B,C,X(14), 9,0xc33707d6L); 211 R0(A, B,C, D,X( 8), 7, 0x698098d8L);
210 R1(C,D,A,B,X( 3),14,0xf4d50d87L); 212 HOST_c2l(data, l);
211 R1(B,C,D,A,X( 8),20,0x455a14edL); 213 X(10) = l;
212 R1(A,B,C,D,X(13), 5,0xa9e3e905L); 214 R0(D, A,B, C,X( 9), 12, 0x8b44f7afL);
213 R1(D,A,B,C,X( 2), 9,0xfcefa3f8L); 215 HOST_c2l(data, l);
214 R1(C,D,A,B,X( 7),14,0x676f02d9L); 216 X(11) = l;
215 R1(B,C,D,A,X(12),20,0x8d2a4c8aL); 217 R0(C, D,A, B,X(10), 17, 0xffff5bb1L);
216 /* Round 2 */ 218 HOST_c2l(data, l);
217 R2(A,B,C,D,X( 5), 4,0xfffa3942L); 219 X(12) = l;
218 R2(D,A,B,C,X( 8),11,0x8771f681L); 220 R0(B, C,D, A,X(11), 22, 0x895cd7beL);
219 R2(C,D,A,B,X(11),16,0x6d9d6122L); 221 HOST_c2l(data, l);
220 R2(B,C,D,A,X(14),23,0xfde5380cL); 222 X(13) = l;
221 R2(A,B,C,D,X( 1), 4,0xa4beea44L); 223 R0(A, B,C, D,X(12), 7, 0x6b901122L);
222 R2(D,A,B,C,X( 4),11,0x4bdecfa9L); 224 HOST_c2l(data, l);
223 R2(C,D,A,B,X( 7),16,0xf6bb4b60L); 225 X(14) = l;
224 R2(B,C,D,A,X(10),23,0xbebfbc70L); 226 R0(D, A,B, C,X(13), 12, 0xfd987193L);
225 R2(A,B,C,D,X(13), 4,0x289b7ec6L); 227 HOST_c2l(data, l);
226 R2(D,A,B,C,X( 0),11,0xeaa127faL); 228 X(15) = l;
227 R2(C,D,A,B,X( 3),16,0xd4ef3085L); 229 R0(C, D,A, B,X(14), 17, 0xa679438eL);
228 R2(B,C,D,A,X( 6),23,0x04881d05L); 230 R0(B, C,D, A,X(15), 22, 0x49b40821L);
229 R2(A,B,C,D,X( 9), 4,0xd9d4d039L); 231 /* Round 1 */
230 R2(D,A,B,C,X(12),11,0xe6db99e5L); 232 R1(A, B,C, D,X( 1), 5, 0xf61e2562L);
231 R2(C,D,A,B,X(15),16,0x1fa27cf8L); 233 R1(D, A,B, C,X( 6), 9, 0xc040b340L);
232 R2(B,C,D,A,X( 2),23,0xc4ac5665L); 234 R1(C, D,A, B,X(11), 14, 0x265e5a51L);
233 /* Round 3 */ 235 R1(B, C,D, A,X( 0), 20, 0xe9b6c7aaL);
234 R3(A,B,C,D,X( 0), 6,0xf4292244L); 236 R1(A, B,C, D,X( 5), 5, 0xd62f105dL);
235 R3(D,A,B,C,X( 7),10,0x432aff97L); 237 R1(D, A,B, C,X(10), 9, 0x02441453L);
236 R3(C,D,A,B,X(14),15,0xab9423a7L); 238 R1(C, D,A, B,X(15), 14, 0xd8a1e681L);
237 R3(B,C,D,A,X( 5),21,0xfc93a039L); 239 R1(B, C,D, A,X( 4), 20, 0xe7d3fbc8L);
238 R3(A,B,C,D,X(12), 6,0x655b59c3L); 240 R1(A, B,C, D,X( 9), 5, 0x21e1cde6L);
239 R3(D,A,B,C,X( 3),10,0x8f0ccc92L); 241 R1(D, A,B, C,X(14), 9, 0xc33707d6L);
240 R3(C,D,A,B,X(10),15,0xffeff47dL); 242 R1(C, D,A, B,X( 3), 14, 0xf4d50d87L);
241 R3(B,C,D,A,X( 1),21,0x85845dd1L); 243 R1(B, C,D, A,X( 8), 20, 0x455a14edL);
242 R3(A,B,C,D,X( 8), 6,0x6fa87e4fL); 244 R1(A, B,C, D,X(13), 5, 0xa9e3e905L);
243 R3(D,A,B,C,X(15),10,0xfe2ce6e0L); 245 R1(D, A,B, C,X( 2), 9, 0xfcefa3f8L);
244 R3(C,D,A,B,X( 6),15,0xa3014314L); 246 R1(C, D,A, B,X( 7), 14, 0x676f02d9L);
245 R3(B,C,D,A,X(13),21,0x4e0811a1L); 247 R1(B, C,D, A,X(12), 20, 0x8d2a4c8aL);
246 R3(A,B,C,D,X( 4), 6,0xf7537e82L); 248 /* Round 2 */
247 R3(D,A,B,C,X(11),10,0xbd3af235L); 249 R2(A, B,C, D,X( 5), 4, 0xfffa3942L);
248 R3(C,D,A,B,X( 2),15,0x2ad7d2bbL); 250 R2(D, A,B, C,X( 8), 11, 0x8771f681L);
249 R3(B,C,D,A,X( 9),21,0xeb86d391L); 251 R2(C, D,A, B,X(11), 16, 0x6d9d6122L);
252 R2(B, C,D, A,X(14), 23, 0xfde5380cL);
253 R2(A, B,C, D,X( 1), 4, 0xa4beea44L);
254 R2(D, A,B, C,X( 4), 11, 0x4bdecfa9L);
255 R2(C, D,A, B,X( 7), 16, 0xf6bb4b60L);
256 R2(B, C,D, A,X(10), 23, 0xbebfbc70L);
257 R2(A, B,C, D,X(13), 4, 0x289b7ec6L);
258 R2(D, A,B, C,X( 0), 11, 0xeaa127faL);
259 R2(C, D,A, B,X( 3), 16, 0xd4ef3085L);
260 R2(B, C,D, A,X( 6), 23, 0x04881d05L);
261 R2(A, B,C, D,X( 9), 4, 0xd9d4d039L);
262 R2(D, A,B, C,X(12), 11, 0xe6db99e5L);
263 R2(C, D,A, B,X(15), 16, 0x1fa27cf8L);
264 R2(B, C,D, A,X( 2), 23, 0xc4ac5665L);
265 /* Round 3 */
266 R3(A, B,C, D,X( 0), 6, 0xf4292244L);
267 R3(D, A,B, C,X( 7), 10, 0x432aff97L);
268 R3(C, D,A, B,X(14), 15, 0xab9423a7L);
269 R3(B, C,D, A,X( 5), 21, 0xfc93a039L);
270 R3(A, B,C, D,X(12), 6, 0x655b59c3L);
271 R3(D, A,B, C,X( 3), 10, 0x8f0ccc92L);
272 R3(C, D,A, B,X(10), 15, 0xffeff47dL);
273 R3(B, C,D, A,X( 1), 21, 0x85845dd1L);
274 R3(A, B,C, D,X( 8), 6, 0x6fa87e4fL);
275 R3(D, A,B, C,X(15), 10, 0xfe2ce6e0L);
276 R3(C, D,A, B,X( 6), 15, 0xa3014314L);
277 R3(B, C,D, A,X(13), 21, 0x4e0811a1L);
278 R3(A, B,C, D,X( 4), 6, 0xf7537e82L);
279 R3(D, A,B, C,X(11), 10, 0xbd3af235L);
280 R3(C, D,A, B,X( 2), 15, 0x2ad7d2bbL);
281 R3(B, C,D, A,X( 9), 21, 0xeb86d391L);
250 282
251 A = c->A += A; 283 A = c->A += A;
252 B = c->B += B; 284 B = c->B += B;
253 C = c->C += C; 285 C = c->C += C;
254 D = c->D += D; 286 D = c->D += D;
255 }
256 } 287 }
288}
257#endif 289#endif
diff --git a/src/lib/libcrypto/md5/md5_one.c b/src/lib/libcrypto/md5/md5_one.c
index 3fb05de30c..6e894de7fe 100644
--- a/src/lib/libcrypto/md5/md5_one.c
+++ b/src/lib/libcrypto/md5/md5_one.c
@@ -1,25 +1,25 @@
1/* $OpenBSD: md5_one.c,v 1.10 2015/09/10 15:56:25 jsing Exp $ */ 1/* $OpenBSD: md5_one.c,v 1.11 2023/07/08 06:50:38 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This package is an SSL implementation written 5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com). 6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL. 7 * The implementation was written so as to conform with Netscapes SSL.
8 * 8 *
9 * This library is free for commercial and non-commercial use as long as 9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions 10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA, 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 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 13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 * 15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in 16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed. 17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution 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. 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 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. 21 * in documentation (online or textual) provided with the package.
22 * 22 *
23 * Redistribution and use in source and binary forms, with or without 23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions 24 * modification, are permitted provided that the following conditions
25 * are met: 25 * are met:
@@ -34,10 +34,10 @@
34 * Eric Young (eay@cryptsoft.com)" 34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library 35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-). 36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from 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: 38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 * 40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,7 +49,7 @@
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 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 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE. 51 * SUCH DAMAGE.
52 * 52 *
53 * The licence and distribution terms for any publically available version or 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 54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence 55 * copied and put under another distribution licence
@@ -61,17 +61,19 @@
61#include <openssl/md5.h> 61#include <openssl/md5.h>
62#include <openssl/crypto.h> 62#include <openssl/crypto.h>
63 63
64unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md) 64unsigned char *
65 { 65MD5(const unsigned char *d, size_t n, unsigned char *md)
66{
66 MD5_CTX c; 67 MD5_CTX c;
67 static unsigned char m[MD5_DIGEST_LENGTH]; 68 static unsigned char m[MD5_DIGEST_LENGTH];
68 69
69 if (md == NULL) md=m; 70 if (md == NULL)
71 md = m;
70 if (!MD5_Init(&c)) 72 if (!MD5_Init(&c))
71 return NULL; 73 return NULL;
72 MD5_Update(&c,d,n); 74 MD5_Update(&c, d, n);
73 MD5_Final(md,&c); 75 MD5_Final(md, &c);
74 explicit_bzero(&c,sizeof(c)); 76 explicit_bzero(&c, sizeof(c));
75 return(md); 77 return (md);
76 } 78}
77 79