blob: 8154e1e1350026c07271e08d6ef2864cc29e0fd6 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: LGPL-2.1
Heiko Schocher633e03a2007-06-22 19:11:54 +02002/*
3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
4 * based on:
5 * FIPS-180-1 compliant SHA-1 implementation
6 *
7 * Copyright (C) 2003-2006 Christophe Devine
Heiko Schocher633e03a2007-06-22 19:11:54 +02008 */
9/*
10 * The SHA-1 standard was published by NIST in 1993.
11 *
12 * http://www.itl.nist.gov/fipspubs/fip180-1.htm
13 */
14
15#ifndef _CRT_SECURE_NO_DEPRECATE
16#define _CRT_SECURE_NO_DEPRECATE 1
17#endif
18
Bartlomiej Sieka222e2ca2008-04-25 13:54:02 +020019#ifndef USE_HOSTCC
20#include <common.h>
Andy Fleming21264822008-06-11 18:10:20 -050021#include <linux/string.h>
Wolfgang Denka1ef0572008-06-06 14:28:14 +020022#else
23#include <string.h>
Bartlomiej Sieka222e2ca2008-04-25 13:54:02 +020024#endif /* USE_HOSTCC */
25#include <watchdog.h>
Jeroen Hofsteebfe88fe2014-06-12 22:27:12 +020026#include <u-boot/sha1.h>
Heiko Schocher633e03a2007-06-22 19:11:54 +020027
Andrew Duda3db9ff02016-11-08 18:53:40 +000028const uint8_t sha1_der_prefix[SHA1_DER_LEN] = {
29 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
30 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14
31};
32
Heiko Schocher633e03a2007-06-22 19:11:54 +020033/*
34 * 32-bit integer manipulation macros (big endian)
35 */
36#ifndef GET_UINT32_BE
Wolfgang Denka0453aa2007-07-10 00:01:28 +020037#define GET_UINT32_BE(n,b,i) { \
38 (n) = ( (unsigned long) (b)[(i) ] << 24 ) \
39 | ( (unsigned long) (b)[(i) + 1] << 16 ) \
40 | ( (unsigned long) (b)[(i) + 2] << 8 ) \
41 | ( (unsigned long) (b)[(i) + 3] ); \
Heiko Schocher633e03a2007-06-22 19:11:54 +020042}
43#endif
44#ifndef PUT_UINT32_BE
Wolfgang Denka0453aa2007-07-10 00:01:28 +020045#define PUT_UINT32_BE(n,b,i) { \
46 (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
47 (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
48 (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
49 (b)[(i) + 3] = (unsigned char) ( (n) ); \
Heiko Schocher633e03a2007-06-22 19:11:54 +020050}
51#endif
52
53/*
54 * SHA-1 context setup
55 */
Wolfgang Denka0453aa2007-07-10 00:01:28 +020056void sha1_starts (sha1_context * ctx)
Heiko Schocher633e03a2007-06-22 19:11:54 +020057{
Wolfgang Denka0453aa2007-07-10 00:01:28 +020058 ctx->total[0] = 0;
59 ctx->total[1] = 0;
Heiko Schocher633e03a2007-06-22 19:11:54 +020060
Wolfgang Denka0453aa2007-07-10 00:01:28 +020061 ctx->state[0] = 0x67452301;
62 ctx->state[1] = 0xEFCDAB89;
63 ctx->state[2] = 0x98BADCFE;
64 ctx->state[3] = 0x10325476;
65 ctx->state[4] = 0xC3D2E1F0;
Heiko Schocher633e03a2007-06-22 19:11:54 +020066}
67
Simon Glass5f60fa22012-12-05 14:46:33 +000068static void sha1_process(sha1_context *ctx, const unsigned char data[64])
Heiko Schocher633e03a2007-06-22 19:11:54 +020069{
Wolfgang Denka0453aa2007-07-10 00:01:28 +020070 unsigned long temp, W[16], A, B, C, D, E;
Heiko Schocher633e03a2007-06-22 19:11:54 +020071
Wolfgang Denka0453aa2007-07-10 00:01:28 +020072 GET_UINT32_BE (W[0], data, 0);
73 GET_UINT32_BE (W[1], data, 4);
74 GET_UINT32_BE (W[2], data, 8);
75 GET_UINT32_BE (W[3], data, 12);
76 GET_UINT32_BE (W[4], data, 16);
77 GET_UINT32_BE (W[5], data, 20);
78 GET_UINT32_BE (W[6], data, 24);
79 GET_UINT32_BE (W[7], data, 28);
80 GET_UINT32_BE (W[8], data, 32);
81 GET_UINT32_BE (W[9], data, 36);
82 GET_UINT32_BE (W[10], data, 40);
83 GET_UINT32_BE (W[11], data, 44);
84 GET_UINT32_BE (W[12], data, 48);
85 GET_UINT32_BE (W[13], data, 52);
86 GET_UINT32_BE (W[14], data, 56);
87 GET_UINT32_BE (W[15], data, 60);
Heiko Schocher633e03a2007-06-22 19:11:54 +020088
Wolfgang Denka0453aa2007-07-10 00:01:28 +020089#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
Heiko Schocher633e03a2007-06-22 19:11:54 +020090
Wolfgang Denka0453aa2007-07-10 00:01:28 +020091#define R(t) ( \
92 temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ \
93 W[(t - 14) & 0x0F] ^ W[ t & 0x0F], \
94 ( W[t & 0x0F] = S(temp,1) ) \
Heiko Schocher633e03a2007-06-22 19:11:54 +020095)
96
Wolfgang Denka0453aa2007-07-10 00:01:28 +020097#define P(a,b,c,d,e,x) { \
98 e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \
Heiko Schocher633e03a2007-06-22 19:11:54 +020099}
100
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200101 A = ctx->state[0];
102 B = ctx->state[1];
103 C = ctx->state[2];
104 D = ctx->state[3];
105 E = ctx->state[4];
Heiko Schocher633e03a2007-06-22 19:11:54 +0200106
107#define F(x,y,z) (z ^ (x & (y ^ z)))
108#define K 0x5A827999
109
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200110 P (A, B, C, D, E, W[0]);
111 P (E, A, B, C, D, W[1]);
112 P (D, E, A, B, C, W[2]);
113 P (C, D, E, A, B, W[3]);
114 P (B, C, D, E, A, W[4]);
115 P (A, B, C, D, E, W[5]);
116 P (E, A, B, C, D, W[6]);
117 P (D, E, A, B, C, W[7]);
118 P (C, D, E, A, B, W[8]);
119 P (B, C, D, E, A, W[9]);
120 P (A, B, C, D, E, W[10]);
121 P (E, A, B, C, D, W[11]);
122 P (D, E, A, B, C, W[12]);
123 P (C, D, E, A, B, W[13]);
124 P (B, C, D, E, A, W[14]);
125 P (A, B, C, D, E, W[15]);
126 P (E, A, B, C, D, R (16));
127 P (D, E, A, B, C, R (17));
128 P (C, D, E, A, B, R (18));
129 P (B, C, D, E, A, R (19));
Heiko Schocher633e03a2007-06-22 19:11:54 +0200130
131#undef K
132#undef F
133
134#define F(x,y,z) (x ^ y ^ z)
135#define K 0x6ED9EBA1
136
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200137 P (A, B, C, D, E, R (20));
138 P (E, A, B, C, D, R (21));
139 P (D, E, A, B, C, R (22));
140 P (C, D, E, A, B, R (23));
141 P (B, C, D, E, A, R (24));
142 P (A, B, C, D, E, R (25));
143 P (E, A, B, C, D, R (26));
144 P (D, E, A, B, C, R (27));
145 P (C, D, E, A, B, R (28));
146 P (B, C, D, E, A, R (29));
147 P (A, B, C, D, E, R (30));
148 P (E, A, B, C, D, R (31));
149 P (D, E, A, B, C, R (32));
150 P (C, D, E, A, B, R (33));
151 P (B, C, D, E, A, R (34));
152 P (A, B, C, D, E, R (35));
153 P (E, A, B, C, D, R (36));
154 P (D, E, A, B, C, R (37));
155 P (C, D, E, A, B, R (38));
156 P (B, C, D, E, A, R (39));
Heiko Schocher633e03a2007-06-22 19:11:54 +0200157
158#undef K
159#undef F
160
161#define F(x,y,z) ((x & y) | (z & (x | y)))
162#define K 0x8F1BBCDC
163
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200164 P (A, B, C, D, E, R (40));
165 P (E, A, B, C, D, R (41));
166 P (D, E, A, B, C, R (42));
167 P (C, D, E, A, B, R (43));
168 P (B, C, D, E, A, R (44));
169 P (A, B, C, D, E, R (45));
170 P (E, A, B, C, D, R (46));
171 P (D, E, A, B, C, R (47));
172 P (C, D, E, A, B, R (48));
173 P (B, C, D, E, A, R (49));
174 P (A, B, C, D, E, R (50));
175 P (E, A, B, C, D, R (51));
176 P (D, E, A, B, C, R (52));
177 P (C, D, E, A, B, R (53));
178 P (B, C, D, E, A, R (54));
179 P (A, B, C, D, E, R (55));
180 P (E, A, B, C, D, R (56));
181 P (D, E, A, B, C, R (57));
182 P (C, D, E, A, B, R (58));
183 P (B, C, D, E, A, R (59));
Heiko Schocher633e03a2007-06-22 19:11:54 +0200184
185#undef K
186#undef F
187
188#define F(x,y,z) (x ^ y ^ z)
189#define K 0xCA62C1D6
190
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200191 P (A, B, C, D, E, R (60));
192 P (E, A, B, C, D, R (61));
193 P (D, E, A, B, C, R (62));
194 P (C, D, E, A, B, R (63));
195 P (B, C, D, E, A, R (64));
196 P (A, B, C, D, E, R (65));
197 P (E, A, B, C, D, R (66));
198 P (D, E, A, B, C, R (67));
199 P (C, D, E, A, B, R (68));
200 P (B, C, D, E, A, R (69));
201 P (A, B, C, D, E, R (70));
202 P (E, A, B, C, D, R (71));
203 P (D, E, A, B, C, R (72));
204 P (C, D, E, A, B, R (73));
205 P (B, C, D, E, A, R (74));
206 P (A, B, C, D, E, R (75));
207 P (E, A, B, C, D, R (76));
208 P (D, E, A, B, C, R (77));
209 P (C, D, E, A, B, R (78));
210 P (B, C, D, E, A, R (79));
Heiko Schocher633e03a2007-06-22 19:11:54 +0200211
212#undef K
213#undef F
214
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200215 ctx->state[0] += A;
216 ctx->state[1] += B;
217 ctx->state[2] += C;
218 ctx->state[3] += D;
219 ctx->state[4] += E;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200220}
221
222/*
223 * SHA-1 process buffer
224 */
Simon Glass5f60fa22012-12-05 14:46:33 +0000225void sha1_update(sha1_context *ctx, const unsigned char *input,
226 unsigned int ilen)
Heiko Schocher633e03a2007-06-22 19:11:54 +0200227{
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200228 int fill;
229 unsigned long left;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200230
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200231 if (ilen <= 0)
232 return;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200233
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200234 left = ctx->total[0] & 0x3F;
235 fill = 64 - left;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200236
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200237 ctx->total[0] += ilen;
238 ctx->total[0] &= 0xFFFFFFFF;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200239
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200240 if (ctx->total[0] < (unsigned long) ilen)
241 ctx->total[1]++;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200242
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200243 if (left && ilen >= fill) {
244 memcpy ((void *) (ctx->buffer + left), (void *) input, fill);
245 sha1_process (ctx, ctx->buffer);
246 input += fill;
247 ilen -= fill;
248 left = 0;
249 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200250
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200251 while (ilen >= 64) {
252 sha1_process (ctx, input);
253 input += 64;
254 ilen -= 64;
255 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200256
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200257 if (ilen > 0) {
258 memcpy ((void *) (ctx->buffer + left), (void *) input, ilen);
259 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200260}
261
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200262static const unsigned char sha1_padding[64] = {
263 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
264 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Heiko Schocher633e03a2007-06-22 19:11:54 +0200267};
268
269/*
270 * SHA-1 final digest
271 */
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200272void sha1_finish (sha1_context * ctx, unsigned char output[20])
Heiko Schocher633e03a2007-06-22 19:11:54 +0200273{
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200274 unsigned long last, padn;
275 unsigned long high, low;
276 unsigned char msglen[8];
Heiko Schocher633e03a2007-06-22 19:11:54 +0200277
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200278 high = (ctx->total[0] >> 29)
279 | (ctx->total[1] << 3);
280 low = (ctx->total[0] << 3);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200281
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200282 PUT_UINT32_BE (high, msglen, 0);
283 PUT_UINT32_BE (low, msglen, 4);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200284
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200285 last = ctx->total[0] & 0x3F;
286 padn = (last < 56) ? (56 - last) : (120 - last);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200287
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200288 sha1_update (ctx, (unsigned char *) sha1_padding, padn);
289 sha1_update (ctx, msglen, 8);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200290
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200291 PUT_UINT32_BE (ctx->state[0], output, 0);
292 PUT_UINT32_BE (ctx->state[1], output, 4);
293 PUT_UINT32_BE (ctx->state[2], output, 8);
294 PUT_UINT32_BE (ctx->state[3], output, 12);
295 PUT_UINT32_BE (ctx->state[4], output, 16);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200296}
297
298/*
299 * Output = SHA-1( input buffer )
300 */
Simon Glass5f60fa22012-12-05 14:46:33 +0000301void sha1_csum(const unsigned char *input, unsigned int ilen,
302 unsigned char *output)
Heiko Schocher633e03a2007-06-22 19:11:54 +0200303{
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200304 sha1_context ctx;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200305
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200306 sha1_starts (&ctx);
307 sha1_update (&ctx, input, ilen);
308 sha1_finish (&ctx, output);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200309}
310
311/*
Bartlomiej Siekada5045d2008-04-22 12:27:56 +0200312 * Output = SHA-1( input buffer ). Trigger the watchdog every 'chunk_sz'
313 * bytes of input processed.
314 */
Simon Glass5f60fa22012-12-05 14:46:33 +0000315void sha1_csum_wd(const unsigned char *input, unsigned int ilen,
316 unsigned char *output, unsigned int chunk_sz)
Bartlomiej Siekada5045d2008-04-22 12:27:56 +0200317{
318 sha1_context ctx;
319#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
Simon Glass5f60fa22012-12-05 14:46:33 +0000320 const unsigned char *end, *curr;
Bartlomiej Siekada5045d2008-04-22 12:27:56 +0200321 int chunk;
322#endif
323
324 sha1_starts (&ctx);
325
326#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
327 curr = input;
328 end = input + ilen;
329 while (curr < end) {
330 chunk = end - curr;
331 if (chunk > chunk_sz)
332 chunk = chunk_sz;
333 sha1_update (&ctx, curr, chunk);
334 curr += chunk;
335 WATCHDOG_RESET ();
336 }
337#else
338 sha1_update (&ctx, input, ilen);
339#endif
340
341 sha1_finish (&ctx, output);
342}
343
344/*
Heiko Schocher633e03a2007-06-22 19:11:54 +0200345 * Output = HMAC-SHA-1( input buffer, hmac key )
346 */
Simon Glass5f60fa22012-12-05 14:46:33 +0000347void sha1_hmac(const unsigned char *key, int keylen,
348 const unsigned char *input, unsigned int ilen,
349 unsigned char *output)
Heiko Schocher633e03a2007-06-22 19:11:54 +0200350{
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200351 int i;
352 sha1_context ctx;
353 unsigned char k_ipad[64];
354 unsigned char k_opad[64];
355 unsigned char tmpbuf[20];
Heiko Schocher633e03a2007-06-22 19:11:54 +0200356
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200357 memset (k_ipad, 0x36, 64);
358 memset (k_opad, 0x5C, 64);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200359
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200360 for (i = 0; i < keylen; i++) {
361 if (i >= 64)
362 break;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200363
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200364 k_ipad[i] ^= key[i];
365 k_opad[i] ^= key[i];
366 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200367
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200368 sha1_starts (&ctx);
369 sha1_update (&ctx, k_ipad, 64);
370 sha1_update (&ctx, input, ilen);
371 sha1_finish (&ctx, tmpbuf);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200372
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200373 sha1_starts (&ctx);
374 sha1_update (&ctx, k_opad, 64);
375 sha1_update (&ctx, tmpbuf, 20);
376 sha1_finish (&ctx, output);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200377
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200378 memset (k_ipad, 0, 64);
379 memset (k_opad, 0, 64);
380 memset (tmpbuf, 0, 20);
381 memset (&ctx, 0, sizeof (sha1_context));
Heiko Schocher633e03a2007-06-22 19:11:54 +0200382}
383
Heiko Schocher633e03a2007-06-22 19:11:54 +0200384#ifdef SELF_TEST
385/*
386 * FIPS-180-1 test vectors
387 */
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200388static const char sha1_test_str[3][57] = {
389 {"abc"},
390 {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"},
391 {""}
Heiko Schocher633e03a2007-06-22 19:11:54 +0200392};
393
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200394static const unsigned char sha1_test_sum[3][20] = {
395 {0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E,
396 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D},
397 {0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE,
398 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1},
399 {0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E,
400 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F}
Heiko Schocher633e03a2007-06-22 19:11:54 +0200401};
402
403/*
404 * Checkup routine
405 */
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200406int sha1_self_test (void)
Heiko Schocher633e03a2007-06-22 19:11:54 +0200407{
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200408 int i, j;
409 unsigned char buf[1000];
410 unsigned char sha1sum[20];
411 sha1_context ctx;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200412
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200413 for (i = 0; i < 3; i++) {
414 printf (" SHA-1 test #%d: ", i + 1);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200415
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200416 sha1_starts (&ctx);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200417
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200418 if (i < 2)
419 sha1_update (&ctx, (unsigned char *) sha1_test_str[i],
420 strlen (sha1_test_str[i]));
421 else {
422 memset (buf, 'a', 1000);
423 for (j = 0; j < 1000; j++)
424 sha1_update (&ctx, buf, 1000);
425 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200426
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200427 sha1_finish (&ctx, sha1sum);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200428
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200429 if (memcmp (sha1sum, sha1_test_sum[i], 20) != 0) {
430 printf ("failed\n");
431 return (1);
432 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200433
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200434 printf ("passed\n");
435 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200436
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200437 printf ("\n");
438 return (0);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200439}
440#else
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200441int sha1_self_test (void)
Heiko Schocher633e03a2007-06-22 19:11:54 +0200442{
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200443 return (0);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200444}
445#endif