blob: f54bb5be98195ad6493dab14e64fb9b86cde3b96 [file] [log] [blame]
Heiko Schocher633e03a2007-06-22 19:11:54 +02001/*
2 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
3 * based on:
4 * FIPS-180-1 compliant SHA-1 implementation
5 *
6 * Copyright (C) 2003-2006 Christophe Devine
7 *
Tom Rinie2378802016-01-14 22:05:13 -05008 * SPDX-License-Identifier: LGPL-2.1
Heiko Schocher633e03a2007-06-22 19:11:54 +02009 */
10/*
11 * The SHA-1 standard was published by NIST in 1993.
12 *
13 * http://www.itl.nist.gov/fipspubs/fip180-1.htm
14 */
15
16#ifndef _CRT_SECURE_NO_DEPRECATE
17#define _CRT_SECURE_NO_DEPRECATE 1
18#endif
19
Bartlomiej Sieka222e2ca2008-04-25 13:54:02 +020020#ifndef USE_HOSTCC
21#include <common.h>
Andy Fleming21264822008-06-11 18:10:20 -050022#include <linux/string.h>
Wolfgang Denka1ef0572008-06-06 14:28:14 +020023#else
24#include <string.h>
Bartlomiej Sieka222e2ca2008-04-25 13:54:02 +020025#endif /* USE_HOSTCC */
26#include <watchdog.h>
Jeroen Hofsteebfe88fe2014-06-12 22:27:12 +020027#include <u-boot/sha1.h>
Heiko Schocher633e03a2007-06-22 19:11:54 +020028
Andrew Duda3db9ff02016-11-08 18:53:40 +000029const uint8_t sha1_der_prefix[SHA1_DER_LEN] = {
30 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
31 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14
32};
33
Heiko Schocher633e03a2007-06-22 19:11:54 +020034/*
35 * 32-bit integer manipulation macros (big endian)
36 */
37#ifndef GET_UINT32_BE
Wolfgang Denka0453aa2007-07-10 00:01:28 +020038#define GET_UINT32_BE(n,b,i) { \
39 (n) = ( (unsigned long) (b)[(i) ] << 24 ) \
40 | ( (unsigned long) (b)[(i) + 1] << 16 ) \
41 | ( (unsigned long) (b)[(i) + 2] << 8 ) \
42 | ( (unsigned long) (b)[(i) + 3] ); \
Heiko Schocher633e03a2007-06-22 19:11:54 +020043}
44#endif
45#ifndef PUT_UINT32_BE
Wolfgang Denka0453aa2007-07-10 00:01:28 +020046#define PUT_UINT32_BE(n,b,i) { \
47 (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
48 (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
49 (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
50 (b)[(i) + 3] = (unsigned char) ( (n) ); \
Heiko Schocher633e03a2007-06-22 19:11:54 +020051}
52#endif
53
54/*
55 * SHA-1 context setup
56 */
Wolfgang Denka0453aa2007-07-10 00:01:28 +020057void sha1_starts (sha1_context * ctx)
Heiko Schocher633e03a2007-06-22 19:11:54 +020058{
Wolfgang Denka0453aa2007-07-10 00:01:28 +020059 ctx->total[0] = 0;
60 ctx->total[1] = 0;
Heiko Schocher633e03a2007-06-22 19:11:54 +020061
Wolfgang Denka0453aa2007-07-10 00:01:28 +020062 ctx->state[0] = 0x67452301;
63 ctx->state[1] = 0xEFCDAB89;
64 ctx->state[2] = 0x98BADCFE;
65 ctx->state[3] = 0x10325476;
66 ctx->state[4] = 0xC3D2E1F0;
Heiko Schocher633e03a2007-06-22 19:11:54 +020067}
68
Simon Glass5f60fa22012-12-05 14:46:33 +000069static void sha1_process(sha1_context *ctx, const unsigned char data[64])
Heiko Schocher633e03a2007-06-22 19:11:54 +020070{
Wolfgang Denka0453aa2007-07-10 00:01:28 +020071 unsigned long temp, W[16], A, B, C, D, E;
Heiko Schocher633e03a2007-06-22 19:11:54 +020072
Wolfgang Denka0453aa2007-07-10 00:01:28 +020073 GET_UINT32_BE (W[0], data, 0);
74 GET_UINT32_BE (W[1], data, 4);
75 GET_UINT32_BE (W[2], data, 8);
76 GET_UINT32_BE (W[3], data, 12);
77 GET_UINT32_BE (W[4], data, 16);
78 GET_UINT32_BE (W[5], data, 20);
79 GET_UINT32_BE (W[6], data, 24);
80 GET_UINT32_BE (W[7], data, 28);
81 GET_UINT32_BE (W[8], data, 32);
82 GET_UINT32_BE (W[9], data, 36);
83 GET_UINT32_BE (W[10], data, 40);
84 GET_UINT32_BE (W[11], data, 44);
85 GET_UINT32_BE (W[12], data, 48);
86 GET_UINT32_BE (W[13], data, 52);
87 GET_UINT32_BE (W[14], data, 56);
88 GET_UINT32_BE (W[15], data, 60);
Heiko Schocher633e03a2007-06-22 19:11:54 +020089
Wolfgang Denka0453aa2007-07-10 00:01:28 +020090#define S(x,n) ((x << n) | ((x & 0xFFFFFFFF) >> (32 - n)))
Heiko Schocher633e03a2007-06-22 19:11:54 +020091
Wolfgang Denka0453aa2007-07-10 00:01:28 +020092#define R(t) ( \
93 temp = W[(t - 3) & 0x0F] ^ W[(t - 8) & 0x0F] ^ \
94 W[(t - 14) & 0x0F] ^ W[ t & 0x0F], \
95 ( W[t & 0x0F] = S(temp,1) ) \
Heiko Schocher633e03a2007-06-22 19:11:54 +020096)
97
Wolfgang Denka0453aa2007-07-10 00:01:28 +020098#define P(a,b,c,d,e,x) { \
99 e += S(a,5) + F(b,c,d) + K + x; b = S(b,30); \
Heiko Schocher633e03a2007-06-22 19:11:54 +0200100}
101
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200102 A = ctx->state[0];
103 B = ctx->state[1];
104 C = ctx->state[2];
105 D = ctx->state[3];
106 E = ctx->state[4];
Heiko Schocher633e03a2007-06-22 19:11:54 +0200107
108#define F(x,y,z) (z ^ (x & (y ^ z)))
109#define K 0x5A827999
110
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200111 P (A, B, C, D, E, W[0]);
112 P (E, A, B, C, D, W[1]);
113 P (D, E, A, B, C, W[2]);
114 P (C, D, E, A, B, W[3]);
115 P (B, C, D, E, A, W[4]);
116 P (A, B, C, D, E, W[5]);
117 P (E, A, B, C, D, W[6]);
118 P (D, E, A, B, C, W[7]);
119 P (C, D, E, A, B, W[8]);
120 P (B, C, D, E, A, W[9]);
121 P (A, B, C, D, E, W[10]);
122 P (E, A, B, C, D, W[11]);
123 P (D, E, A, B, C, W[12]);
124 P (C, D, E, A, B, W[13]);
125 P (B, C, D, E, A, W[14]);
126 P (A, B, C, D, E, W[15]);
127 P (E, A, B, C, D, R (16));
128 P (D, E, A, B, C, R (17));
129 P (C, D, E, A, B, R (18));
130 P (B, C, D, E, A, R (19));
Heiko Schocher633e03a2007-06-22 19:11:54 +0200131
132#undef K
133#undef F
134
135#define F(x,y,z) (x ^ y ^ z)
136#define K 0x6ED9EBA1
137
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200138 P (A, B, C, D, E, R (20));
139 P (E, A, B, C, D, R (21));
140 P (D, E, A, B, C, R (22));
141 P (C, D, E, A, B, R (23));
142 P (B, C, D, E, A, R (24));
143 P (A, B, C, D, E, R (25));
144 P (E, A, B, C, D, R (26));
145 P (D, E, A, B, C, R (27));
146 P (C, D, E, A, B, R (28));
147 P (B, C, D, E, A, R (29));
148 P (A, B, C, D, E, R (30));
149 P (E, A, B, C, D, R (31));
150 P (D, E, A, B, C, R (32));
151 P (C, D, E, A, B, R (33));
152 P (B, C, D, E, A, R (34));
153 P (A, B, C, D, E, R (35));
154 P (E, A, B, C, D, R (36));
155 P (D, E, A, B, C, R (37));
156 P (C, D, E, A, B, R (38));
157 P (B, C, D, E, A, R (39));
Heiko Schocher633e03a2007-06-22 19:11:54 +0200158
159#undef K
160#undef F
161
162#define F(x,y,z) ((x & y) | (z & (x | y)))
163#define K 0x8F1BBCDC
164
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200165 P (A, B, C, D, E, R (40));
166 P (E, A, B, C, D, R (41));
167 P (D, E, A, B, C, R (42));
168 P (C, D, E, A, B, R (43));
169 P (B, C, D, E, A, R (44));
170 P (A, B, C, D, E, R (45));
171 P (E, A, B, C, D, R (46));
172 P (D, E, A, B, C, R (47));
173 P (C, D, E, A, B, R (48));
174 P (B, C, D, E, A, R (49));
175 P (A, B, C, D, E, R (50));
176 P (E, A, B, C, D, R (51));
177 P (D, E, A, B, C, R (52));
178 P (C, D, E, A, B, R (53));
179 P (B, C, D, E, A, R (54));
180 P (A, B, C, D, E, R (55));
181 P (E, A, B, C, D, R (56));
182 P (D, E, A, B, C, R (57));
183 P (C, D, E, A, B, R (58));
184 P (B, C, D, E, A, R (59));
Heiko Schocher633e03a2007-06-22 19:11:54 +0200185
186#undef K
187#undef F
188
189#define F(x,y,z) (x ^ y ^ z)
190#define K 0xCA62C1D6
191
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200192 P (A, B, C, D, E, R (60));
193 P (E, A, B, C, D, R (61));
194 P (D, E, A, B, C, R (62));
195 P (C, D, E, A, B, R (63));
196 P (B, C, D, E, A, R (64));
197 P (A, B, C, D, E, R (65));
198 P (E, A, B, C, D, R (66));
199 P (D, E, A, B, C, R (67));
200 P (C, D, E, A, B, R (68));
201 P (B, C, D, E, A, R (69));
202 P (A, B, C, D, E, R (70));
203 P (E, A, B, C, D, R (71));
204 P (D, E, A, B, C, R (72));
205 P (C, D, E, A, B, R (73));
206 P (B, C, D, E, A, R (74));
207 P (A, B, C, D, E, R (75));
208 P (E, A, B, C, D, R (76));
209 P (D, E, A, B, C, R (77));
210 P (C, D, E, A, B, R (78));
211 P (B, C, D, E, A, R (79));
Heiko Schocher633e03a2007-06-22 19:11:54 +0200212
213#undef K
214#undef F
215
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200216 ctx->state[0] += A;
217 ctx->state[1] += B;
218 ctx->state[2] += C;
219 ctx->state[3] += D;
220 ctx->state[4] += E;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200221}
222
223/*
224 * SHA-1 process buffer
225 */
Simon Glass5f60fa22012-12-05 14:46:33 +0000226void sha1_update(sha1_context *ctx, const unsigned char *input,
227 unsigned int ilen)
Heiko Schocher633e03a2007-06-22 19:11:54 +0200228{
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200229 int fill;
230 unsigned long left;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200231
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200232 if (ilen <= 0)
233 return;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200234
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200235 left = ctx->total[0] & 0x3F;
236 fill = 64 - left;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200237
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200238 ctx->total[0] += ilen;
239 ctx->total[0] &= 0xFFFFFFFF;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200240
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200241 if (ctx->total[0] < (unsigned long) ilen)
242 ctx->total[1]++;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200243
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200244 if (left && ilen >= fill) {
245 memcpy ((void *) (ctx->buffer + left), (void *) input, fill);
246 sha1_process (ctx, ctx->buffer);
247 input += fill;
248 ilen -= fill;
249 left = 0;
250 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200251
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200252 while (ilen >= 64) {
253 sha1_process (ctx, input);
254 input += 64;
255 ilen -= 64;
256 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200257
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200258 if (ilen > 0) {
259 memcpy ((void *) (ctx->buffer + left), (void *) input, ilen);
260 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200261}
262
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200263static const unsigned char sha1_padding[64] = {
264 0x80, 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,
267 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Heiko Schocher633e03a2007-06-22 19:11:54 +0200268};
269
270/*
271 * SHA-1 final digest
272 */
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200273void sha1_finish (sha1_context * ctx, unsigned char output[20])
Heiko Schocher633e03a2007-06-22 19:11:54 +0200274{
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200275 unsigned long last, padn;
276 unsigned long high, low;
277 unsigned char msglen[8];
Heiko Schocher633e03a2007-06-22 19:11:54 +0200278
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200279 high = (ctx->total[0] >> 29)
280 | (ctx->total[1] << 3);
281 low = (ctx->total[0] << 3);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200282
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200283 PUT_UINT32_BE (high, msglen, 0);
284 PUT_UINT32_BE (low, msglen, 4);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200285
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200286 last = ctx->total[0] & 0x3F;
287 padn = (last < 56) ? (56 - last) : (120 - last);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200288
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200289 sha1_update (ctx, (unsigned char *) sha1_padding, padn);
290 sha1_update (ctx, msglen, 8);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200291
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200292 PUT_UINT32_BE (ctx->state[0], output, 0);
293 PUT_UINT32_BE (ctx->state[1], output, 4);
294 PUT_UINT32_BE (ctx->state[2], output, 8);
295 PUT_UINT32_BE (ctx->state[3], output, 12);
296 PUT_UINT32_BE (ctx->state[4], output, 16);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200297}
298
299/*
300 * Output = SHA-1( input buffer )
301 */
Simon Glass5f60fa22012-12-05 14:46:33 +0000302void sha1_csum(const unsigned char *input, unsigned int ilen,
303 unsigned char *output)
Heiko Schocher633e03a2007-06-22 19:11:54 +0200304{
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200305 sha1_context ctx;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200306
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200307 sha1_starts (&ctx);
308 sha1_update (&ctx, input, ilen);
309 sha1_finish (&ctx, output);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200310}
311
312/*
Bartlomiej Siekada5045d2008-04-22 12:27:56 +0200313 * Output = SHA-1( input buffer ). Trigger the watchdog every 'chunk_sz'
314 * bytes of input processed.
315 */
Simon Glass5f60fa22012-12-05 14:46:33 +0000316void sha1_csum_wd(const unsigned char *input, unsigned int ilen,
317 unsigned char *output, unsigned int chunk_sz)
Bartlomiej Siekada5045d2008-04-22 12:27:56 +0200318{
319 sha1_context ctx;
320#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
Simon Glass5f60fa22012-12-05 14:46:33 +0000321 const unsigned char *end, *curr;
Bartlomiej Siekada5045d2008-04-22 12:27:56 +0200322 int chunk;
323#endif
324
325 sha1_starts (&ctx);
326
327#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
328 curr = input;
329 end = input + ilen;
330 while (curr < end) {
331 chunk = end - curr;
332 if (chunk > chunk_sz)
333 chunk = chunk_sz;
334 sha1_update (&ctx, curr, chunk);
335 curr += chunk;
336 WATCHDOG_RESET ();
337 }
338#else
339 sha1_update (&ctx, input, ilen);
340#endif
341
342 sha1_finish (&ctx, output);
343}
344
345/*
Heiko Schocher633e03a2007-06-22 19:11:54 +0200346 * Output = HMAC-SHA-1( input buffer, hmac key )
347 */
Simon Glass5f60fa22012-12-05 14:46:33 +0000348void sha1_hmac(const unsigned char *key, int keylen,
349 const unsigned char *input, unsigned int ilen,
350 unsigned char *output)
Heiko Schocher633e03a2007-06-22 19:11:54 +0200351{
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200352 int i;
353 sha1_context ctx;
354 unsigned char k_ipad[64];
355 unsigned char k_opad[64];
356 unsigned char tmpbuf[20];
Heiko Schocher633e03a2007-06-22 19:11:54 +0200357
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200358 memset (k_ipad, 0x36, 64);
359 memset (k_opad, 0x5C, 64);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200360
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200361 for (i = 0; i < keylen; i++) {
362 if (i >= 64)
363 break;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200364
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200365 k_ipad[i] ^= key[i];
366 k_opad[i] ^= key[i];
367 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200368
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200369 sha1_starts (&ctx);
370 sha1_update (&ctx, k_ipad, 64);
371 sha1_update (&ctx, input, ilen);
372 sha1_finish (&ctx, tmpbuf);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200373
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200374 sha1_starts (&ctx);
375 sha1_update (&ctx, k_opad, 64);
376 sha1_update (&ctx, tmpbuf, 20);
377 sha1_finish (&ctx, output);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200378
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200379 memset (k_ipad, 0, 64);
380 memset (k_opad, 0, 64);
381 memset (tmpbuf, 0, 20);
382 memset (&ctx, 0, sizeof (sha1_context));
Heiko Schocher633e03a2007-06-22 19:11:54 +0200383}
384
Heiko Schocher633e03a2007-06-22 19:11:54 +0200385#ifdef SELF_TEST
386/*
387 * FIPS-180-1 test vectors
388 */
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200389static const char sha1_test_str[3][57] = {
390 {"abc"},
391 {"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"},
392 {""}
Heiko Schocher633e03a2007-06-22 19:11:54 +0200393};
394
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200395static const unsigned char sha1_test_sum[3][20] = {
396 {0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E,
397 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D},
398 {0x84, 0x98, 0x3E, 0x44, 0x1C, 0x3B, 0xD2, 0x6E, 0xBA, 0xAE,
399 0x4A, 0xA1, 0xF9, 0x51, 0x29, 0xE5, 0xE5, 0x46, 0x70, 0xF1},
400 {0x34, 0xAA, 0x97, 0x3C, 0xD4, 0xC4, 0xDA, 0xA4, 0xF6, 0x1E,
401 0xEB, 0x2B, 0xDB, 0xAD, 0x27, 0x31, 0x65, 0x34, 0x01, 0x6F}
Heiko Schocher633e03a2007-06-22 19:11:54 +0200402};
403
404/*
405 * Checkup routine
406 */
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200407int sha1_self_test (void)
Heiko Schocher633e03a2007-06-22 19:11:54 +0200408{
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200409 int i, j;
410 unsigned char buf[1000];
411 unsigned char sha1sum[20];
412 sha1_context ctx;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200413
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200414 for (i = 0; i < 3; i++) {
415 printf (" SHA-1 test #%d: ", i + 1);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200416
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200417 sha1_starts (&ctx);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200418
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200419 if (i < 2)
420 sha1_update (&ctx, (unsigned char *) sha1_test_str[i],
421 strlen (sha1_test_str[i]));
422 else {
423 memset (buf, 'a', 1000);
424 for (j = 0; j < 1000; j++)
425 sha1_update (&ctx, buf, 1000);
426 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200427
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200428 sha1_finish (&ctx, sha1sum);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200429
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200430 if (memcmp (sha1sum, sha1_test_sum[i], 20) != 0) {
431 printf ("failed\n");
432 return (1);
433 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200434
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200435 printf ("passed\n");
436 }
Heiko Schocher633e03a2007-06-22 19:11:54 +0200437
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200438 printf ("\n");
439 return (0);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200440}
441#else
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200442int sha1_self_test (void)
Heiko Schocher633e03a2007-06-22 19:11:54 +0200443{
Wolfgang Denka0453aa2007-07-10 00:01:28 +0200444 return (0);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200445}
446#endif