summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/md4/md4_dgst.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/md4/md4_dgst.c')
-rw-r--r--src/lib/libcrypto/md4/md4_dgst.c249
1 files changed, 0 insertions, 249 deletions
diff --git a/src/lib/libcrypto/md4/md4_dgst.c b/src/lib/libcrypto/md4/md4_dgst.c
deleted file mode 100644
index 33a1cd777e..0000000000
--- a/src/lib/libcrypto/md4/md4_dgst.c
+++ /dev/null
@@ -1,249 +0,0 @@
1/* $OpenBSD: md4_dgst.c,v 1.21 2023/07/15 15:30:43 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
4 *
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15 *
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40 *
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
52 *
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
57 */
58
59#include <stdio.h>
60#include <openssl/opensslv.h>
61#include <openssl/crypto.h>
62
63#include <stdlib.h>
64#include <string.h>
65#include <openssl/opensslconf.h>
66#include <openssl/md4.h>
67
68__BEGIN_HIDDEN_DECLS
69
70void md4_block_data_order (MD4_CTX *c, const void *p, size_t num);
71
72__END_HIDDEN_DECLS
73
74#define DATA_ORDER_IS_LITTLE_ENDIAN
75
76#define HASH_LONG MD4_LONG
77#define HASH_CTX MD4_CTX
78#define HASH_CBLOCK MD4_CBLOCK
79#define HASH_UPDATE MD4_Update
80#define HASH_TRANSFORM MD4_Transform
81#define HASH_FINAL MD4_Final
82#define HASH_MAKE_STRING(c,s) do { \
83 unsigned long ll; \
84 ll=(c)->A; HOST_l2c(ll,(s)); \
85 ll=(c)->B; HOST_l2c(ll,(s)); \
86 ll=(c)->C; HOST_l2c(ll,(s)); \
87 ll=(c)->D; HOST_l2c(ll,(s)); \
88 } while (0)
89#define HASH_BLOCK_DATA_ORDER md4_block_data_order
90
91#include "md32_common.h"
92LCRYPTO_ALIAS(MD4_Update);
93LCRYPTO_ALIAS(MD4_Final);
94LCRYPTO_ALIAS(MD4_Transform);
95
96/*
97#define F(x,y,z) (((x) & (y)) | ((~(x)) & (z)))
98#define G(x,y,z) (((x) & (y)) | ((x) & ((z))) | ((y) & ((z))))
99*/
100
101/* As pointed out by Wei Dai <weidai@eskimo.com>, the above can be
102 * simplified to the code below. Wei attributes these optimizations
103 * to Peter Gutmann's SHS code, and he attributes it to Rich Schroeppel.
104 */
105#define F(b,c,d) ((((c) ^ (d)) & (b)) ^ (d))
106#define G(b,c,d) (((b) & (c)) | ((b) & (d)) | ((c) & (d)))
107#define H(b,c,d) ((b) ^ (c) ^ (d))
108
109#define R0(a,b,c,d,k,s,t) { \
110 a+=((k)+(t)+F((b),(c),(d))); \
111 a=ROTATE(a,s); };
112
113#define R1(a,b,c,d,k,s,t) { \
114 a+=((k)+(t)+G((b),(c),(d))); \
115 a=ROTATE(a,s); };\
116
117#define R2(a,b,c,d,k,s,t) { \
118 a+=((k)+(t)+H((b),(c),(d))); \
119 a=ROTATE(a,s); };
120
121/* Implemented from RFC1186 The MD4 Message-Digest Algorithm
122 */
123
124#define INIT_DATA_A (unsigned long)0x67452301L
125#define INIT_DATA_B (unsigned long)0xefcdab89L
126#define INIT_DATA_C (unsigned long)0x98badcfeL
127#define INIT_DATA_D (unsigned long)0x10325476L
128
129int
130MD4_Init(MD4_CTX *c)
131{
132 memset (c, 0, sizeof(*c));
133 c->A = INIT_DATA_A;
134 c->B = INIT_DATA_B;
135 c->C = INIT_DATA_C;
136 c->D = INIT_DATA_D;
137 return 1;
138}
139LCRYPTO_ALIAS(MD4_Init);
140
141#ifndef md4_block_data_order
142#ifdef X
143#undef X
144#endif
145void
146md4_block_data_order(MD4_CTX *c, const void *data_, size_t num)
147{
148 const unsigned char *data = data_;
149 unsigned MD32_REG_T A, B, C, D, l;
150 unsigned MD32_REG_T X0, X1, X2, X3, X4, X5, X6, X7,
151 X8, X9, X10, X11, X12, X13, X14, X15;
152
153 A = c->A;
154 B = c->B;
155 C = c->C;
156 D = c->D;
157
158 for (; num--; ) {
159 HOST_c2l(data, l);
160 X0 = l;
161 HOST_c2l(data, l);
162 X1 = l;
163 /* Round 0 */
164 R0(A, B, C, D, X0, 3, 0);
165 HOST_c2l(data, l);
166 X2 = l;
167 R0(D, A, B, C, X1, 7, 0);
168 HOST_c2l(data, l);
169 X3 = l;
170 R0(C, D, A, B, X2, 11, 0);
171 HOST_c2l(data, l);
172 X4 = l;
173 R0(B, C, D, A, X3, 19, 0);
174 HOST_c2l(data, l);
175 X5 = l;
176 R0(A, B, C, D, X4, 3, 0);
177 HOST_c2l(data, l);
178 X6 = l;
179 R0(D, A, B, C, X5, 7, 0);
180 HOST_c2l(data, l);
181 X7 = l;
182 R0(C, D, A, B, X6, 11, 0);
183 HOST_c2l(data, l);
184 X8 = l;
185 R0(B, C, D, A, X7, 19, 0);
186 HOST_c2l(data, l);
187 X9 = l;
188 R0(A, B, C, D, X8, 3, 0);
189 HOST_c2l(data, l);
190 X10 = l;
191 R0(D, A,B, C,X9, 7, 0);
192 HOST_c2l(data, l);
193 X11 = l;
194 R0(C, D,A, B,X10, 11, 0);
195 HOST_c2l(data, l);
196 X12 = l;
197 R0(B, C,D, A,X11, 19, 0);
198 HOST_c2l(data, l);
199 X13 = l;
200 R0(A, B,C, D,X12, 3, 0);
201 HOST_c2l(data, l);
202 X14 = l;
203 R0(D, A,B, C,X13, 7, 0);
204 HOST_c2l(data, l);
205 X15 = l;
206 R0(C, D,A, B,X14, 11, 0);
207 R0(B, C,D, A,X15, 19, 0);
208 /* Round 1 */
209 R1(A, B, C, D, X0, 3, 0x5A827999L);
210 R1(D, A, B, C, X4, 5, 0x5A827999L);
211 R1(C, D, A, B, X8, 9, 0x5A827999L);
212 R1(B, C, D, A, X12, 13, 0x5A827999L);
213 R1(A, B, C, D, X1, 3, 0x5A827999L);
214 R1(D, A, B, C, X5, 5, 0x5A827999L);
215 R1(C, D, A, B, X9, 9, 0x5A827999L);
216 R1(B, C, D, A, X13, 13, 0x5A827999L);
217 R1(A, B, C, D, X2, 3, 0x5A827999L);
218 R1(D, A, B, C, X6, 5, 0x5A827999L);
219 R1(C, D, A, B, X10, 9, 0x5A827999L);
220 R1(B, C, D, A, X14, 13, 0x5A827999L);
221 R1(A, B, C, D, X3, 3, 0x5A827999L);
222 R1(D, A, B, C, X7, 5, 0x5A827999L);
223 R1(C, D, A, B, X11, 9, 0x5A827999L);
224 R1(B, C, D, A, X15, 13, 0x5A827999L);
225 /* Round 2 */
226 R2(A, B, C, D, X0, 3, 0x6ED9EBA1L);
227 R2(D, A, B, C, X8, 9, 0x6ED9EBA1L);
228 R2(C, D, A, B, X4, 11, 0x6ED9EBA1L);
229 R2(B, C, D, A, X12, 15, 0x6ED9EBA1L);
230 R2(A, B, C, D, X2, 3, 0x6ED9EBA1L);
231 R2(D, A, B, C, X10, 9, 0x6ED9EBA1L);
232 R2(C, D, A, B, X6, 11, 0x6ED9EBA1L);
233 R2(B, C, D, A, X14, 15, 0x6ED9EBA1L);
234 R2(A, B, C, D, X1, 3, 0x6ED9EBA1L);
235 R2(D, A, B, C, X9, 9, 0x6ED9EBA1L);
236 R2(C, D, A, B, X5, 11, 0x6ED9EBA1L);
237 R2(B, C, D, A, X13, 15, 0x6ED9EBA1L);
238 R2(A, B, C, D, X3, 3, 0x6ED9EBA1L);
239 R2(D, A, B, C, X11, 9, 0x6ED9EBA1L);
240 R2(C, D, A, B, X7, 11, 0x6ED9EBA1L);
241 R2(B, C, D, A, X15, 15, 0x6ED9EBA1L);
242
243 A = c->A += A;
244 B = c->B += B;
245 C = c->C += C;
246 D = c->D += D;
247 }
248}
249#endif