summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2023-07-08 06:47:26 +0000
committerjsing <>2023-07-08 06:47:26 +0000
commit30e39e11e8d9fc4a5f72bfac9f4f25cc2ac28e92 (patch)
treeeb12fba9c2744577f37bad2ca05d4ff3252b1cfb /src
parent57ebe81e0a656148b6b3b2d7b0f2856a1a76f6f1 (diff)
downloadopenbsd-30e39e11e8d9fc4a5f72bfac9f4f25cc2ac28e92.tar.gz
openbsd-30e39e11e8d9fc4a5f72bfac9f4f25cc2ac28e92.tar.bz2
openbsd-30e39e11e8d9fc4a5f72bfac9f4f25cc2ac28e92.zip
Hit md4 with the style(9) stick.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/md4/md4.h23
-rw-r--r--src/lib/libcrypto/md4/md4_dgst.c205
-rw-r--r--src/lib/libcrypto/md4/md4_one.c32
3 files changed, 146 insertions, 114 deletions
diff --git a/src/lib/libcrypto/md4/md4.h b/src/lib/libcrypto/md4/md4.h
index 04aacc9801..cb4f3cb6e9 100644
--- a/src/lib/libcrypto/md4/md4.h
+++ b/src/lib/libcrypto/md4/md4.h
@@ -1,25 +1,25 @@
1/* $OpenBSD: md4.h,v 1.16 2015/09/14 01:45:03 doug Exp $ */ 1/* $OpenBSD: md4.h,v 1.17 2023/07/08 06:47:26 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
@@ -83,13 +83,12 @@ extern "C" {
83#define MD4_LBLOCK (MD4_CBLOCK/4) 83#define MD4_LBLOCK (MD4_CBLOCK/4)
84#define MD4_DIGEST_LENGTH 16 84#define MD4_DIGEST_LENGTH 16
85 85
86typedef struct MD4state_st 86typedef struct MD4state_st {
87 { 87 MD4_LONG A, B,C, D;
88 MD4_LONG A,B,C,D; 88 MD4_LONG Nl, Nh;
89 MD4_LONG Nl,Nh;
90 MD4_LONG data[MD4_LBLOCK]; 89 MD4_LONG data[MD4_LBLOCK];
91 unsigned int num; 90 unsigned int num;
92 } MD4_CTX; 91} MD4_CTX;
93 92
94int MD4_Init(MD4_CTX *c); 93int MD4_Init(MD4_CTX *c);
95int MD4_Update(MD4_CTX *c, const void *data, size_t len); 94int MD4_Update(MD4_CTX *c, const void *data, size_t len);
diff --git a/src/lib/libcrypto/md4/md4_dgst.c b/src/lib/libcrypto/md4/md4_dgst.c
index 7ff258d8bd..dedb5902cd 100644
--- a/src/lib/libcrypto/md4/md4_dgst.c
+++ b/src/lib/libcrypto/md4/md4_dgst.c
@@ -1,25 +1,25 @@
1/* $OpenBSD: md4_dgst.c,v 1.18 2023/07/08 06:39:19 jsing Exp $ */ 1/* $OpenBSD: md4_dgst.c,v 1.19 2023/07/08 06:47:26 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
@@ -67,7 +67,7 @@
67 67
68__BEGIN_HIDDEN_DECLS 68__BEGIN_HIDDEN_DECLS
69 69
70void md4_block_data_order (MD4_CTX *c, const void *p,size_t num); 70void md4_block_data_order (MD4_CTX *c, const void *p, size_t num);
71 71
72__END_HIDDEN_DECLS 72__END_HIDDEN_DECLS
73 73
@@ -123,99 +123,130 @@ __END_HIDDEN_DECLS
123#define INIT_DATA_C (unsigned long)0x98badcfeL 123#define INIT_DATA_C (unsigned long)0x98badcfeL
124#define INIT_DATA_D (unsigned long)0x10325476L 124#define INIT_DATA_D (unsigned long)0x10325476L
125 125
126int MD4_Init(MD4_CTX *c) 126int
127 { 127MD4_Init(MD4_CTX *c)
128 memset (c,0,sizeof(*c)); 128{
129 c->A=INIT_DATA_A; 129 memset (c, 0, sizeof(*c));
130 c->B=INIT_DATA_B; 130 c->A = INIT_DATA_A;
131 c->C=INIT_DATA_C; 131 c->B = INIT_DATA_B;
132 c->D=INIT_DATA_D; 132 c->C = INIT_DATA_C;
133 c->D = INIT_DATA_D;
133 return 1; 134 return 1;
134 } 135}
135 136
136#ifndef md4_block_data_order 137#ifndef md4_block_data_order
137#ifdef X 138#ifdef X
138#undef X 139#undef X
139#endif 140#endif
140void md4_block_data_order (MD4_CTX *c, const void *data_, size_t num) 141void
141 { 142md4_block_data_order(MD4_CTX *c, const void *data_, size_t num)
142 const unsigned char *data=data_; 143{
143 unsigned MD32_REG_T A,B,C,D,l; 144 const unsigned char *data = data_;
145 unsigned MD32_REG_T A, B,C, D, l;
144#ifndef MD32_XARRAY 146#ifndef MD32_XARRAY
145 /* See comment in crypto/sha/sha_locl.h for details. */ 147 /* See comment in crypto/sha/sha_locl.h for details. */
146 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7, 148 unsigned MD32_REG_T XX0, XX1, XX2, XX3, XX4, XX5, XX6, XX7,
147 XX8, XX9,XX10,XX11,XX12,XX13,XX14,XX15; 149 XX8, XX9, XX10, XX11, XX12, XX13, XX14, XX15;
148# define X(i) XX##i 150# define X(i) XX##i
149#else 151#else
150 MD4_LONG XX[MD4_LBLOCK]; 152 MD4_LONG XX[MD4_LBLOCK];
151# define X(i) XX[i] 153# define X(i) XX[i]
152#endif 154#endif
153 155
154 A=c->A; 156 A = c->A;
155 B=c->B; 157 B = c->B;
156 C=c->C; 158 C = c->C;
157 D=c->D; 159 D = c->D;
158 160
159 for (;num--;) 161 for (; num--; ) {
160 { 162 HOST_c2l(data, l);
161 HOST_c2l(data,l); X( 0)=l; 163 X( 0) = l;
162 HOST_c2l(data,l); X( 1)=l; 164 HOST_c2l(data, l);
163 /* Round 0 */ 165 X( 1) = l;
164 R0(A,B,C,D,X( 0), 3,0); HOST_c2l(data,l); X( 2)=l; 166 /* Round 0 */
165 R0(D,A,B,C,X( 1), 7,0); HOST_c2l(data,l); X( 3)=l; 167 R0(A, B,C, D,X( 0), 3, 0);
166 R0(C,D,A,B,X( 2),11,0); HOST_c2l(data,l); X( 4)=l; 168 HOST_c2l(data, l);
167 R0(B,C,D,A,X( 3),19,0); HOST_c2l(data,l); X( 5)=l; 169 X( 2) = l;
168 R0(A,B,C,D,X( 4), 3,0); HOST_c2l(data,l); X( 6)=l; 170 R0(D, A,B, C,X( 1), 7, 0);
169 R0(D,A,B,C,X( 5), 7,0); HOST_c2l(data,l); X( 7)=l; 171 HOST_c2l(data, l);
170 R0(C,D,A,B,X( 6),11,0); HOST_c2l(data,l); X( 8)=l; 172 X( 3) = l;
171 R0(B,C,D,A,X( 7),19,0); HOST_c2l(data,l); X( 9)=l; 173 R0(C, D,A, B,X( 2), 11, 0);
172 R0(A,B,C,D,X( 8), 3,0); HOST_c2l(data,l); X(10)=l; 174 HOST_c2l(data, l);
173 R0(D,A,B,C,X( 9), 7,0); HOST_c2l(data,l); X(11)=l; 175 X( 4) = l;
174 R0(C,D,A,B,X(10),11,0); HOST_c2l(data,l); X(12)=l; 176 R0(B, C,D, A,X( 3), 19, 0);
175 R0(B,C,D,A,X(11),19,0); HOST_c2l(data,l); X(13)=l; 177 HOST_c2l(data, l);
176 R0(A,B,C,D,X(12), 3,0); HOST_c2l(data,l); X(14)=l; 178 X( 5) = l;
177 R0(D,A,B,C,X(13), 7,0); HOST_c2l(data,l); X(15)=l; 179 R0(A, B,C, D,X( 4), 3, 0);
178 R0(C,D,A,B,X(14),11,0); 180 HOST_c2l(data, l);
179 R0(B,C,D,A,X(15),19,0); 181 X( 6) = l;
180 /* Round 1 */ 182 R0(D, A,B, C,X( 5), 7, 0);
181 R1(A,B,C,D,X( 0), 3,0x5A827999L); 183 HOST_c2l(data, l);
182 R1(D,A,B,C,X( 4), 5,0x5A827999L); 184 X( 7) = l;
183 R1(C,D,A,B,X( 8), 9,0x5A827999L); 185 R0(C, D,A, B,X( 6), 11, 0);
184 R1(B,C,D,A,X(12),13,0x5A827999L); 186 HOST_c2l(data, l);
185 R1(A,B,C,D,X( 1), 3,0x5A827999L); 187 X( 8) = l;
186 R1(D,A,B,C,X( 5), 5,0x5A827999L); 188 R0(B, C,D, A,X( 7), 19, 0);
187 R1(C,D,A,B,X( 9), 9,0x5A827999L); 189 HOST_c2l(data, l);
188 R1(B,C,D,A,X(13),13,0x5A827999L); 190 X( 9) = l;
189 R1(A,B,C,D,X( 2), 3,0x5A827999L); 191 R0(A, B,C, D,X( 8), 3, 0);
190 R1(D,A,B,C,X( 6), 5,0x5A827999L); 192 HOST_c2l(data, l);
191 R1(C,D,A,B,X(10), 9,0x5A827999L); 193 X(10) = l;
192 R1(B,C,D,A,X(14),13,0x5A827999L); 194 R0(D, A,B, C,X( 9), 7, 0);
193 R1(A,B,C,D,X( 3), 3,0x5A827999L); 195 HOST_c2l(data, l);
194 R1(D,A,B,C,X( 7), 5,0x5A827999L); 196 X(11) = l;
195 R1(C,D,A,B,X(11), 9,0x5A827999L); 197 R0(C, D,A, B,X(10), 11, 0);
196 R1(B,C,D,A,X(15),13,0x5A827999L); 198 HOST_c2l(data, l);
197 /* Round 2 */ 199 X(12) = l;
198 R2(A,B,C,D,X( 0), 3,0x6ED9EBA1L); 200 R0(B, C,D, A,X(11), 19, 0);
199 R2(D,A,B,C,X( 8), 9,0x6ED9EBA1L); 201 HOST_c2l(data, l);
200 R2(C,D,A,B,X( 4),11,0x6ED9EBA1L); 202 X(13) = l;
201 R2(B,C,D,A,X(12),15,0x6ED9EBA1L); 203 R0(A, B,C, D,X(12), 3, 0);
202 R2(A,B,C,D,X( 2), 3,0x6ED9EBA1L); 204 HOST_c2l(data, l);
203 R2(D,A,B,C,X(10), 9,0x6ED9EBA1L); 205 X(14) = l;
204 R2(C,D,A,B,X( 6),11,0x6ED9EBA1L); 206 R0(D, A,B, C,X(13), 7, 0);
205 R2(B,C,D,A,X(14),15,0x6ED9EBA1L); 207 HOST_c2l(data, l);
206 R2(A,B,C,D,X( 1), 3,0x6ED9EBA1L); 208 X(15) = l;
207 R2(D,A,B,C,X( 9), 9,0x6ED9EBA1L); 209 R0(C, D,A, B,X(14), 11, 0);
208 R2(C,D,A,B,X( 5),11,0x6ED9EBA1L); 210 R0(B, C,D, A,X(15), 19, 0);
209 R2(B,C,D,A,X(13),15,0x6ED9EBA1L); 211 /* Round 1 */
210 R2(A,B,C,D,X( 3), 3,0x6ED9EBA1L); 212 R1(A, B,C, D,X( 0), 3, 0x5A827999L);
211 R2(D,A,B,C,X(11), 9,0x6ED9EBA1L); 213 R1(D, A,B, C,X( 4), 5, 0x5A827999L);
212 R2(C,D,A,B,X( 7),11,0x6ED9EBA1L); 214 R1(C, D,A, B,X( 8), 9, 0x5A827999L);
213 R2(B,C,D,A,X(15),15,0x6ED9EBA1L); 215 R1(B, C,D, A,X(12), 13, 0x5A827999L);
214 216 R1(A, B,C, D,X( 1), 3, 0x5A827999L);
215 A = c->A += A; 217 R1(D, A,B, C,X( 5), 5, 0x5A827999L);
216 B = c->B += B; 218 R1(C, D,A, B,X( 9), 9, 0x5A827999L);
217 C = c->C += C; 219 R1(B, C,D, A,X(13), 13, 0x5A827999L);
218 D = c->D += D; 220 R1(A, B,C, D,X( 2), 3, 0x5A827999L);
219 } 221 R1(D, A,B, C,X( 6), 5, 0x5A827999L);
222 R1(C, D,A, B,X(10), 9, 0x5A827999L);
223 R1(B, C,D, A,X(14), 13, 0x5A827999L);
224 R1(A, B,C, D,X( 3), 3, 0x5A827999L);
225 R1(D, A,B, C,X( 7), 5, 0x5A827999L);
226 R1(C, D,A, B,X(11), 9, 0x5A827999L);
227 R1(B, C,D, A,X(15), 13, 0x5A827999L);
228 /* Round 2 */
229 R2(A, B,C, D,X( 0), 3, 0x6ED9EBA1L);
230 R2(D, A,B, C,X( 8), 9, 0x6ED9EBA1L);
231 R2(C, D,A, B,X( 4), 11, 0x6ED9EBA1L);
232 R2(B, C,D, A,X(12), 15, 0x6ED9EBA1L);
233 R2(A, B,C, D,X( 2), 3, 0x6ED9EBA1L);
234 R2(D, A,B, C,X(10), 9, 0x6ED9EBA1L);
235 R2(C, D,A, B,X( 6), 11, 0x6ED9EBA1L);
236 R2(B, C,D, A,X(14), 15, 0x6ED9EBA1L);
237 R2(A, B,C, D,X( 1), 3, 0x6ED9EBA1L);
238 R2(D, A,B, C,X( 9), 9, 0x6ED9EBA1L);
239 R2(C, D,A, B,X( 5), 11, 0x6ED9EBA1L);
240 R2(B, C,D, A,X(13), 15, 0x6ED9EBA1L);
241 R2(A, B,C, D,X( 3), 3, 0x6ED9EBA1L);
242 R2(D, A,B, C,X(11), 9, 0x6ED9EBA1L);
243 R2(C, D,A, B,X( 7), 11, 0x6ED9EBA1L);
244 R2(B, C,D, A,X(15), 15, 0x6ED9EBA1L);
245
246 A = c->A += A;
247 B = c->B += B;
248 C = c->C += C;
249 D = c->D += D;
220 } 250 }
251}
221#endif 252#endif
diff --git a/src/lib/libcrypto/md4/md4_one.c b/src/lib/libcrypto/md4/md4_one.c
index c1fd6f3e52..63c8a09940 100644
--- a/src/lib/libcrypto/md4/md4_one.c
+++ b/src/lib/libcrypto/md4/md4_one.c
@@ -1,25 +1,25 @@
1/* $OpenBSD: md4_one.c,v 1.10 2015/09/14 01:45:03 doug Exp $ */ 1/* $OpenBSD: md4_one.c,v 1.11 2023/07/08 06:47:26 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/md4.h> 61#include <openssl/md4.h>
62#include <openssl/crypto.h> 62#include <openssl/crypto.h>
63 63
64unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md) 64unsigned char *
65 { 65MD4(const unsigned char *d, size_t n, unsigned char *md)
66{
66 MD4_CTX c; 67 MD4_CTX c;
67 static unsigned char m[MD4_DIGEST_LENGTH]; 68 static unsigned char m[MD4_DIGEST_LENGTH];
68 69
69 if (md == NULL) md=m; 70 if (md == NULL)
71 md = m;
70 if (!MD4_Init(&c)) 72 if (!MD4_Init(&c))
71 return NULL; 73 return NULL;
72 MD4_Update(&c,d,n); 74 MD4_Update(&c, d, n);
73 MD4_Final(md,&c); 75 MD4_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