limit fstBC to 30bp in Python3 ver.
[GalaxyCodeBases.git] / c_cpp / etc / calc / sha1.c
blobd61ffb5ee83eccc1482bd65384db4a9ebbb9baec
1 /*
2 * sha1 - implements new NIST Secure Hash Standard-1 (SHA1)
4 * Written 2 September 1992, Peter C. Gutmann.
6 * This file has been extensively modified by:
8 * Landon Curt Noll
9 * http://www.isthe.com/chongo/
11 * chongo <was here> /\../\
13 * This code has been placed in the public domain. Please do not
14 * copyright this code.
16 * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO
17 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
18 * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT
19 * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
21 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
22 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
23 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * @(#) $Revision: 30.4 $
26 * @(#) $Id: sha1.c,v 30.4 2013/08/11 01:08:32 chongo Exp $
27 * @(#) $Source: /usr/local/src/cmd/calc/RCS/sha1.c,v $
29 * This file is not covered under version 2.1 of the GNU LGPL.
33 #include <stdio.h>
34 #include "longbits.h"
35 #include "align32.h"
36 #include "endian_calc.h"
37 #include "value.h"
38 #include "hash.h"
39 #include "sha1.h"
43 * The SHA1 f()-functions. The f1 and f3 functions can be optimized
44 * to save one boolean operation each - thanks to Rich Schroeppel,
45 * rcs@cs.arizona.edu for discovering this.
47 * f1: ((x&y) | (~x&z)) == (z ^ (x&(y^z)))
48 * f3: ((x&y) | (x&z) | (y&z)) == ((x&y) | (z&(x|y)))
50 #define f1(x,y,z) (z ^ (x&(y^z))) /* Rounds 0-19 */
51 #define f2(x,y,z) (x^y^z) /* Rounds 20-39 */
52 #define f3(x,y,z) ((x&y) | (z&(x|y))) /* Rounds 40-59 */
53 #define f4(x,y,z) (x^y^z) /* Rounds 60-79 */
55 /* The SHA1 Mysterious Constants */
56 #define K1 0x5A827999L /* Rounds 0-19 */
57 #define K2 0x6ED9EBA1L /* Rounds 20-39 */
58 #define K3 0x8F1BBCDCL /* Rounds 40-59 */
59 #define K4 0xCA62C1D6L /* Rounds 60-79 */
61 /* SHA1 initial values */
62 #define h0init 0x67452301L
63 #define h1init 0xEFCDAB89L
64 #define h2init 0x98BADCFEL
65 #define h3init 0x10325476L
66 #define h4init 0xC3D2E1F0L
68 /* 32-bit rotate left - kludged with shifts */
69 #define LEFT_ROT(X,n) (((X)<<(n)) | ((X)>>(32-(n))))
73 * The initial expanding function. The hash function is defined over an
74 * 80-word expanded input array W, where the first 16 are copies of the input
75 * data, and the remaining 64 are defined by
77 * W[i] = LEFT_ROT(W[i-16] ^ W[i-14] ^ W[i-8] ^ W[i-3], 1)
79 * NOTE: The expanding function used in rounds 16 to 79 was changed from the
80 * original SHA (in FIPS Pub 180) to one that also left circular shifted
81 * by one bit for Secure Hash Algorithm-1 (FIPS Pub 180-1).
83 #define exor(W,i,t) \
84 (t = (W[i&15] ^ W[(i-14)&15] ^ W[(i-8)&15] ^ W[(i-3)&15]), \
85 W[i&15] = LEFT_ROT(t, 1))
88 * The prototype SHA1 sub-round. The fundamental sub-round is:
90 * a' = e + LEFT_ROT(a,5) + f(b,c,d) + k + data;
91 * b' = a;
92 * c' = LEFT_ROT(b,30);
93 * d' = c;
94 * e' = d;
96 * but this is implemented by unrolling the loop 5 times and renaming the
97 * variables ( e, a, b, c, d ) = ( a', b', c', d', e' ) each iteration.
98 * This code is then replicated 20 times for each of the 4 functions, using
99 * the next 20 values from the W[] array each time.
101 #define subRound(a, b, c, d, e, f, k, data) \
102 (e += LEFT_ROT(a,5) + f(b,c,d) + k + data, b = LEFT_ROT(b,30))
104 /* forward declarations */
105 S_FUNC void sha1Init(HASH*);
106 S_FUNC void sha1Transform(USB32*, USB32*);
107 S_FUNC void sha1Update(HASH*, USB8*, USB32);
108 S_FUNC void sha1Final(HASH*);
109 S_FUNC void sha1_chkpt(HASH*);
110 S_FUNC void sha1_note(int, HASH*);
111 S_FUNC void sha1_type(int, HASH*);
112 void sha1_init_state(HASH*);
113 S_FUNC ZVALUE sha1_final_state(HASH*);
114 S_FUNC int sha1_cmp(HASH*, HASH*);
115 S_FUNC void sha1_print(HASH*);
119 * sha1Init - initialize the SHA1 state
121 S_FUNC void
122 sha1Init(HASH *state)
124 SHA1_INFO *dig = &state->h_union.h_sha1; /* digest state */
126 /* Set the h-vars to their initial values */
127 dig->digest[0] = h0init;
128 dig->digest[1] = h1init;
129 dig->digest[2] = h2init;
130 dig->digest[3] = h3init;
131 dig->digest[4] = h4init;
133 /* Initialise bit count */
134 dig->countLo = 0;
135 dig->countHi = 0;
136 dig->datalen = 0;
141 * sha1Transform - perform the SHA1 transformatio
143 * Note that this code, like MD5, seems to break some optimizing compilers.
144 * It may be necessary to split it into sections, eg based on the four
145 * subrounds. One may also want to roll each subround into a loop.
147 S_FUNC void
148 sha1Transform(USB32 *digest, USB32 *W)
150 USB32 A, B, C, D, E; /* Local vars */
151 USB32 t; /* temp storage for exor() */
153 /* Set up first buffer and local data buffer */
154 A = digest[0];
155 B = digest[1];
156 C = digest[2];
157 D = digest[3];
158 E = digest[4];
160 /* Heavy mangling, in 4 sub-rounds of 20 interations each. */
161 subRound(A, B, C, D, E, f1, K1, W[ 0]);
162 subRound(E, A, B, C, D, f1, K1, W[ 1]);
163 subRound(D, E, A, B, C, f1, K1, W[ 2]);
164 subRound(C, D, E, A, B, f1, K1, W[ 3]);
165 subRound(B, C, D, E, A, f1, K1, W[ 4]);
166 subRound(A, B, C, D, E, f1, K1, W[ 5]);
167 subRound(E, A, B, C, D, f1, K1, W[ 6]);
168 subRound(D, E, A, B, C, f1, K1, W[ 7]);
169 subRound(C, D, E, A, B, f1, K1, W[ 8]);
170 subRound(B, C, D, E, A, f1, K1, W[ 9]);
171 subRound(A, B, C, D, E, f1, K1, W[10]);
172 subRound(E, A, B, C, D, f1, K1, W[11]);
173 subRound(D, E, A, B, C, f1, K1, W[12]);
174 subRound(C, D, E, A, B, f1, K1, W[13]);
175 subRound(B, C, D, E, A, f1, K1, W[14]);
176 subRound(A, B, C, D, E, f1, K1, W[15]);
177 subRound(E, A, B, C, D, f1, K1, exor(W,16,t));
178 subRound(D, E, A, B, C, f1, K1, exor(W,17,t));
179 subRound(C, D, E, A, B, f1, K1, exor(W,18,t));
180 subRound(B, C, D, E, A, f1, K1, exor(W,19,t));
182 subRound(A, B, C, D, E, f2, K2, exor(W,20,t));
183 subRound(E, A, B, C, D, f2, K2, exor(W,21,t));
184 subRound(D, E, A, B, C, f2, K2, exor(W,22,t));
185 subRound(C, D, E, A, B, f2, K2, exor(W,23,t));
186 subRound(B, C, D, E, A, f2, K2, exor(W,24,t));
187 subRound(A, B, C, D, E, f2, K2, exor(W,25,t));
188 subRound(E, A, B, C, D, f2, K2, exor(W,26,t));
189 subRound(D, E, A, B, C, f2, K2, exor(W,27,t));
190 subRound(C, D, E, A, B, f2, K2, exor(W,28,t));
191 subRound(B, C, D, E, A, f2, K2, exor(W,29,t));
192 subRound(A, B, C, D, E, f2, K2, exor(W,30,t));
193 subRound(E, A, B, C, D, f2, K2, exor(W,31,t));
194 subRound(D, E, A, B, C, f2, K2, exor(W,32,t));
195 subRound(C, D, E, A, B, f2, K2, exor(W,33,t));
196 subRound(B, C, D, E, A, f2, K2, exor(W,34,t));
197 subRound(A, B, C, D, E, f2, K2, exor(W,35,t));
198 subRound(E, A, B, C, D, f2, K2, exor(W,36,t));
199 subRound(D, E, A, B, C, f2, K2, exor(W,37,t));
200 subRound(C, D, E, A, B, f2, K2, exor(W,38,t));
201 subRound(B, C, D, E, A, f2, K2, exor(W,39,t));
203 subRound(A, B, C, D, E, f3, K3, exor(W,40,t));
204 subRound(E, A, B, C, D, f3, K3, exor(W,41,t));
205 subRound(D, E, A, B, C, f3, K3, exor(W,42,t));
206 subRound(C, D, E, A, B, f3, K3, exor(W,43,t));
207 subRound(B, C, D, E, A, f3, K3, exor(W,44,t));
208 subRound(A, B, C, D, E, f3, K3, exor(W,45,t));
209 subRound(E, A, B, C, D, f3, K3, exor(W,46,t));
210 subRound(D, E, A, B, C, f3, K3, exor(W,47,t));
211 subRound(C, D, E, A, B, f3, K3, exor(W,48,t));
212 subRound(B, C, D, E, A, f3, K3, exor(W,49,t));
213 subRound(A, B, C, D, E, f3, K3, exor(W,50,t));
214 subRound(E, A, B, C, D, f3, K3, exor(W,51,t));
215 subRound(D, E, A, B, C, f3, K3, exor(W,52,t));
216 subRound(C, D, E, A, B, f3, K3, exor(W,53,t));
217 subRound(B, C, D, E, A, f3, K3, exor(W,54,t));
218 subRound(A, B, C, D, E, f3, K3, exor(W,55,t));
219 subRound(E, A, B, C, D, f3, K3, exor(W,56,t));
220 subRound(D, E, A, B, C, f3, K3, exor(W,57,t));
221 subRound(C, D, E, A, B, f3, K3, exor(W,58,t));
222 subRound(B, C, D, E, A, f3, K3, exor(W,59,t));
224 subRound(A, B, C, D, E, f4, K4, exor(W,60,t));
225 subRound(E, A, B, C, D, f4, K4, exor(W,61,t));
226 subRound(D, E, A, B, C, f4, K4, exor(W,62,t));
227 subRound(C, D, E, A, B, f4, K4, exor(W,63,t));
228 subRound(B, C, D, E, A, f4, K4, exor(W,64,t));
229 subRound(A, B, C, D, E, f4, K4, exor(W,65,t));
230 subRound(E, A, B, C, D, f4, K4, exor(W,66,t));
231 subRound(D, E, A, B, C, f4, K4, exor(W,67,t));
232 subRound(C, D, E, A, B, f4, K4, exor(W,68,t));
233 subRound(B, C, D, E, A, f4, K4, exor(W,69,t));
234 subRound(A, B, C, D, E, f4, K4, exor(W,70,t));
235 subRound(E, A, B, C, D, f4, K4, exor(W,71,t));
236 subRound(D, E, A, B, C, f4, K4, exor(W,72,t));
237 subRound(C, D, E, A, B, f4, K4, exor(W,73,t));
238 subRound(B, C, D, E, A, f4, K4, exor(W,74,t));
239 subRound(A, B, C, D, E, f4, K4, exor(W,75,t));
240 subRound(E, A, B, C, D, f4, K4, exor(W,76,t));
241 subRound(D, E, A, B, C, f4, K4, exor(W,77,t));
242 subRound(C, D, E, A, B, f4, K4, exor(W,78,t));
243 subRound(B, C, D, E, A, f4, K4, exor(W,79,t));
245 /* Build message digest */
246 digest[0] += A;
247 digest[1] += B;
248 digest[2] += C;
249 digest[3] += D;
250 digest[4] += E;
255 * sha1Update - update SHA1 with arbitrary length data
257 void
258 sha1Update(HASH *state, USB8 *buffer, USB32 count)
260 SHA1_INFO *dig = &state->h_union.h_sha1; /* digest state */
261 USB32 datalen = dig->datalen;
262 USB32 cpylen;
263 #if CALC_BYTE_ORDER == LITTLE_ENDIAN
264 unsigned int i;
265 #endif
268 * Update the full count, even if some of it is buffered for later
270 SHA1COUNT(dig, count);
273 /* determine the size we need to copy */
274 cpylen = SHA1_CHUNKSIZE - datalen;
276 /* case: new data will not fill the buffer */
277 if (cpylen > count) {
278 memcpy((char *)dig->data+datalen,
279 (char *)buffer, count);
280 dig->datalen = datalen+count;
281 return;
284 /* case: buffer will be filled */
285 memcpy((char *)dig->data + datalen, (char *)buffer, cpylen);
288 * Process data in SHA1_CHUNKSIZE chunks
290 for (;;) {
291 #if CALC_BYTE_ORDER == LITTLE_ENDIAN
292 if (state->bytes) {
293 for (i=0; i < SHA1_CHUNKWORDS; ++i) {
294 SWAP_B8_IN_B32(dig->data+i, dig->data+i);
297 #endif
298 sha1Transform(dig->digest, dig->data);
299 buffer += cpylen;
300 count -= cpylen;
301 if (count < SHA1_CHUNKSIZE)
302 break;
303 cpylen = SHA1_CHUNKSIZE;
304 memcpy(dig->data, buffer, cpylen);
308 * Handle any remaining bytes of data.
309 * This should only happen once on the final lot of data
311 if (count > 0) {
312 memcpy((char *)dig->data, (char *)buffer, count);
314 dig->datalen = count;
319 * sha1Final - perform final SHA1 transforms
321 * At this point we have less than a full chunk of data remaining
322 * (and possibly no data) in the sha1 state data buffer.
324 * First we append a final 0x80 byte.
326 * Next if we have more than 56 bytes, we will zero fill the remainder
327 * of the chunk, transform and then zero fill the first 56 bytes.
328 * If we have 56 or fewer bytes, we will zero fill out to the 56th
329 * chunk byte. Regardless, we wind up with 56 bytes data.
331 * Finally we append the 64 bit length on to the 56 bytes of data
332 * remaining. This final chunk is transformed.
335 void
336 sha1Final(HASH *state)
338 SHA1_INFO *dig = &state->h_union.h_sha1; /* digest state */
339 long count = (long)(dig->datalen);
340 USB32 lowBitcount;
341 USB32 highBitcount;
342 USB8 *data = (USB8 *) dig->data;
343 #if CALC_BYTE_ORDER == LITTLE_ENDIAN
344 unsigned int i;
345 #endif
347 /* Pad to end of chunk */
349 memset(data + count, 0, SHA1_CHUNKSIZE - count);
352 * If processing bytes, set the first byte of padding to 0x80.
353 * if processing words: on a big-endian machine set the first
354 * byte of padding to 0x80, on a little-endian machine set
355 * the first four bytes to 0x00000080
356 * This is safe since there is always at least one byte or word free
359 memset(data + count, 0, SHA1_CHUNKSIZE - count);
361 #if CALC_BYTE_ORDER == LITTLE_ENDIAN
362 if (state->bytes) {
363 data[count] = 0x80;
364 for (i=0; i < SHA1_CHUNKWORDS; ++i) {
365 SWAP_B8_IN_B32(dig->data+i, dig->data+i);
367 } else {
368 if (count % 4) {
369 math_error("This should not happen in sha1Final");
370 /*NOTREACHED*/
372 data[count + 3] = 0x80;
374 #else
375 data[count] = 0x80;
376 #endif
378 if (count >= SHA1_CHUNKSIZE-8) {
379 sha1Transform(dig->digest, dig->data);
381 /* Now load another chunk with 56 bytes of padding */
382 memset(data, 0, SHA1_CHUNKSIZE-8);
386 * Append length in bits and transform
388 * We assume that bit count is a multiple of 8 because we have
389 * only processed full bytes.
391 highBitcount = dig->countHi;
392 lowBitcount = dig->countLo;
393 dig->data[SHA1_HIGH] = (highBitcount << 3) | (lowBitcount >> 29);
394 dig->data[SHA1_LOW] = (lowBitcount << 3);
395 sha1Transform(dig->digest, dig->data);
396 dig->datalen = 0;
401 * sha1_chkpt - checkpoint a SHA1 state
403 * given:
404 * state the state to checkpoint
406 * This function will ensure that the hash chunk buffer is empty.
407 * Any partially hashed data will be padded out with 0's and hashed.
409 S_FUNC void
410 sha1_chkpt(HASH *state)
412 SHA1_INFO *dig = &state->h_union.h_sha1; /* digest state */
413 #if CALC_BYTE_ORDER == LITTLE_ENDIAN
414 unsigned int i;
415 #endif
418 * checkpoint if partial buffer exists
420 if (dig->datalen > 0) {
422 /* pad to the end of the chunk */
423 memset((USB8 *)dig->data + dig->datalen, 0,
424 SHA1_CHUNKSIZE-dig->datalen);
425 #if CALC_BYTE_ORDER == LITTLE_ENDIAN
426 if (state->bytes) {
427 for (i=0; i < SHA1_CHUNKWORDS; ++i) {
428 SWAP_B8_IN_B32(dig->data+i, dig->data+i);
431 #endif
432 /* transform padded chunk */
433 sha1Transform(dig->digest, dig->data);
434 SHA1COUNT(dig, SHA1_CHUNKSIZE-dig->datalen);
436 /* empty buffer */
437 dig->datalen = 0;
439 return;
444 * sha1_note - note a special value
446 * given:
447 * state the state to hash
448 * special a special value (SHA1_HASH_XYZ) to note
450 * This function will note that a special value is about to be hashed.
451 * Types include negative values, complex values, division, zero numeric
452 * and array of HALFs.
454 S_FUNC void
455 sha1_note(int special, HASH *state)
457 SHA1_INFO *dig = &state->h_union.h_sha1; /* digest state */
458 unsigned int i;
461 * change state to reflect a special value
463 dig->digest[0] ^= special;
464 for (i=1; i < SHA1_DIGESTWORDS; ++i) {
465 dig->digest[i] ^= (special + dig->digest[i-1] + i);
467 return;
472 * sha1_type - note a VALUE type
474 * given:
475 * state the state to hash
476 * type the VALUE type to note
478 * This function will note that a type of value is about to be hashed.
479 * The type of a VALUE will be noted. For purposes of hash comparison,
480 * we will do nothing with V_NUM and V_COM so that the other functions
481 * can hash to the same value regardless of if sha1_value() is called
482 * or not. We also do nothing with V_STR so that a hash of a string
483 * will produce the same value as the standard hash function.
485 S_FUNC void
486 sha1_type(int type, HASH *state)
488 SHA1_INFO *dig = &state->h_union.h_sha1; /* digest state */
489 unsigned int i;
492 * ignore NUMBER and COMPLEX
494 if (type == V_NUM || type == V_COM || type == V_STR) {
495 return;
499 * change state to reflect a VALUE type
501 dig->digest[0] += type;
502 for (i=1; i < SHA1_DIGESTWORDS; ++i) {
503 dig->digest[i] += ((type+i) ^ dig->digest[i-1]);
505 return;
510 * sha1_init_state - initialize a hash state structure for this hash
512 * given:
513 * state - pointer to the hfunction element to initialize
515 void
516 sha1_init_state(HASH *state)
519 * initalize state
521 state->hashtype = SHA1_HASH_TYPE;
522 state->bytes = TRUE;
523 state->update = sha1Update;
524 state->chkpt = sha1_chkpt;
525 state->note = sha1_note;
526 state->type = sha1_type;
527 state->final = sha1_final_state;
528 state->cmp = sha1_cmp;
529 state->print = sha1_print;
530 state->base = SHA1_BASE;
531 state->chunksize = SHA1_CHUNKSIZE;
532 state->unionsize = sizeof(SHA1_INFO);
535 * perform the internal init function
537 memset((void *)&(state->h_union.h_sha1), 0, sizeof(SHA1_INFO));
538 sha1Init(state);
539 return;
544 * sha1_final_state - complete hash state and return a ZVALUE
546 * given:
547 * state the state to complete and convert
549 * returns:
550 * a ZVALUE representing the state
552 S_FUNC ZVALUE
553 sha1_final_state(HASH *state)
555 SHA1_INFO *dig = &state->h_union.h_sha1; /* digest state */
556 ZVALUE ret; /* return ZVALUE of completed hash state */
557 int i;
560 * malloc and initialize if state is NULL
562 if (state == NULL) {
563 state = (HASH *)malloc(sizeof(HASH));
564 if (state == NULL) {
565 math_error("cannot malloc HASH");
566 /*NOTREACHED*/
568 sha1_init_state(state);
572 * complete the hash state
574 sha1Final(state);
577 * allocate storage for ZVALUE
579 ret.len = SHA1_DIGESTSIZE/sizeof(HALF);
580 ret.sign = 0;
581 ret.v = alloc(ret.len);
584 * load ZVALUE
586 #if BASEB == 16 && CALC_BYTE_ORDER == LITTLE_ENDIAN
587 for (i=0; i < ret.len; i+=2) {
588 ret.v[ret.len-i-1] = ((HALF*)dig->digest)[i+1];
589 ret.v[ret.len-i-2] = ((HALF*)dig->digest)[i];
591 #else
592 for (i=0; i < ret.len; ++i) {
593 ret.v[ret.len-i-1] = ((HALF*)dig->digest)[i];
595 #endif
596 ztrim(&ret);
599 * return ZVALUE
601 return ret;
606 * sha1_cmp - compare two hash states
608 * given:
609 * a first hash state
610 * b second hash state
612 * returns:
613 * TRUE => hash states are different
614 * FALSE => hash states are the same
616 S_FUNC int
617 sha1_cmp(HASH *a, HASH *b)
620 * firewall and quick check
622 if (a == b) {
623 /* pointers to the same object */
624 return FALSE;
626 if (a == NULL || b == NULL) {
627 /* one is NULL, so they differ */
628 return TRUE;
632 * compare data-reading modes
634 if (a->bytes != b->bytes)
635 return TRUE;
638 * compare bit counts
640 if (a->h_union.h_sha1.countLo != b->h_union.h_sha1.countLo ||
641 a->h_union.h_sha1.countHi != b->h_union.h_sha1.countHi) {
642 /* counts differ */
643 return TRUE;
647 * compare pending buffers
649 if (a->h_union.h_sha1.datalen != b->h_union.h_sha1.datalen) {
650 /* buffer lengths differ */
651 return TRUE;
653 if (memcmp((USB8*)a->h_union.h_sha1.data,
654 (USB8*)b->h_union.h_sha1.data,
655 a->h_union.h_sha1.datalen) != 0) {
656 /* buffer contents differ */
657 return TRUE;
661 * compare digest
663 return (memcmp((USB8*)(a->h_union.h_sha1.digest),
664 (USB8*)(b->h_union.h_sha1.digest),
665 SHA1_DIGESTSIZE) != 0);
670 * sha1_print - print a hash state
672 * given:
673 * state the hash state to print
675 S_FUNC void
676 sha1_print(HASH *state)
679 * form the hash value
681 if (conf->calc_debug & CALCDBG_HASH_STATE) {
682 char buf[DEBUG_SIZE+1]; /* hash value buffer */
685 * print numeric debug value
687 * NOTE: This value represents only the hash value as of
688 * the last full update or finalization. Thus it
689 * may NOT be the actual hash value.
691 sprintf(buf,
692 "sha1: 0x%08x%08x%08x%08x%08x data: %d octets",
693 (int)state->h_union.h_sha1.digest[0],
694 (int)state->h_union.h_sha1.digest[1],
695 (int)state->h_union.h_sha1.digest[2],
696 (int)state->h_union.h_sha1.digest[3],
697 (int)state->h_union.h_sha1.digest[4],
698 (int)state->h_union.h_sha1.datalen);
699 math_str(buf);
700 } else {
701 math_str("sha1 hash state");
703 return;