2 * hash - one-way hash routines
4 * Copyright (C) 1999-2007 Landon Curt Noll
6 * Calc is open software; you can redistribute it and/or modify it under
7 * the terms of the version 2.1 of the GNU Lesser General Public License
8 * as published by the Free Software Foundation.
10 * Calc is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
13 * Public License for more details.
15 * A copy of version 2.1 of the GNU Lesser General Public License is
16 * distributed with calc under the filename COPYING-LGPL. You should have
17 * received a copy with calc; if not, write to Free Software Foundation, Inc.
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * @(#) $Revision: 30.3 $
21 * @(#) $Id: hash.c,v 30.3 2013/08/11 08:41:38 chongo Exp $
22 * @(#) $Source: /usr/local/src/bin/calc/RCS/hash.c,v $
24 * Under source code control: 1995/11/23 05:13:11
25 * File existed as early as: 1995
27 * chongo <was here> /\oo/\ http://www.isthe.com/chongo/
28 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
34 #include <sys/types.h>
44 * external hash_setup functions
46 E_FUNC
void shs_init_state(HASH
*);
47 E_FUNC
void sha1_init_state(HASH
*);
48 E_FUNC
void MD5_init_state(HASH
*);
52 * hash_long can deal with BOOL's, int's, FLAGS's and LEN's
54 #define hash_bool(type, val, state) (hash_long((type), (long)(val), (state)))
55 #define hash_int(type, val, state) (hash_long((type), (long)(val), (state)))
56 #define hash_flag(type, val, state) (hash_long((type), (long)(val), (state)))
57 #define hash_len(type, val, state) (hash_long((type), (long)(val), (state)))
61 * hash_setup - setup the hash state for a given hash
63 STATIC
struct hash_setup
{
64 int type
; /* hash type (see XYZ_HASH_TYPE below) */
65 void (*init_state
)(HASH
*); /* initialize a hash state */
67 { SHA1_HASH_TYPE
, sha1_init_state
}, /* SHA-1 / SHA-1 */
68 { -1, NULL
} /* must be last */
73 * hash_init - initialize a hash state
76 * type - hash type (see hash.h)
77 * state - the state to initialize, or NULL to malloc it
83 hash_init(int type
, HASH
*state
)
91 state
= (HASH
*)malloc(sizeof(HASH
));
93 math_error("hash_init: cannot malloc HASH");
101 memset((void*)state
, 0, sizeof(HASH
));
105 * search for the hash_setup function
107 for (i
=0; htbl
[i
].init_state
!= NULL
; ++i
) {
109 /* if we found the state that we were looking for */
110 if (type
== htbl
[i
].type
) {
112 /* initialize state and return */
113 (htbl
[i
].init_state
)(state
);
115 /* firewall - MAX_CHUNKSIZE must be >= chunksize */
116 if (state
->chunksize
> MAX_CHUNKSIZE
) {
118 "internal error: MAX_CHUNKSIZE is too small");
128 math_error("internal error: hash type not found in htbl[]");
134 * hash_free - free the hash state
137 hash_free(HASH
*state
)
140 * do nothing if state is NULL
147 * free main state and return
155 * hash_copy - copy a hash state
158 * state - the state to copy
161 * pointer to copy of state
164 hash_copy(HASH
*state
)
166 HASH
*hnew
; /* copy of state */
171 hnew
= (HASH
*)malloc(sizeof(HASH
));
173 math_error("hash_init: cannot malloc HASH");
180 memcpy((void *)hnew
, (void *)state
, sizeof(HASH
));
186 * hash_cmp - compare hash values
190 * b second hash state
193 * TRUE => hash states are different
194 * FALSE => hash states are the same
197 hash_cmp(HASH
*a
, HASH
*b
)
200 * firewall and quick check
203 /* pointers to the same object */
206 if (a
== NULL
|| b
== NULL
) {
207 /* one pointer is NULL, so they differ */
210 if (a
->cmp
== NULL
|| b
->cmp
== NULL
) {
211 /* one cmp function is NULL, so they differ */
218 if (a
->hashtype
!= b
->hashtype
) {
219 /* different hash types are different */
224 * perform the hash specific comparison
226 return ((a
->cmp
)(a
,b
));
231 * hash_print - print the name and value of a hash
234 * state the hash state to print name and value of
237 hash_print(HASH
*state
)
240 (state
->print
)(state
);
246 * hash_final - finalize the state of a hash and return a ZVALUE
249 * state the hash state to finalize
252 * hash state as a ZVALUE
255 hash_final(HASH
*state
)
257 /* return the finalized the hash value */
258 return (state
->final
)(state
);
263 * hash_long - note a long value
266 * type - hash type (see hash.h)
267 * longval - a long value
268 * state - the state to hash
273 * This function will hash a long value as if it were a 64 bit value.
274 * The input is a long. If a long is smaller than 64 bits, we will
275 * hash a final 32 bits of zeros.
277 * This function is OK to hash BOOL's, unslogned long's, unsigned int's
278 * signed int's as well as FLAG's and LEN's.
281 hash_long(int type
, long longval
, HASH
*state
)
283 long lval
[64/LONG_BITS
]; /* 64 bits of longs */
286 * initialize if state is NULL
289 state
= hash_init(type
, NULL
);
293 * setup for the hash_long
295 (state
->chkpt
)(state
);
296 state
->bytes
= FALSE
; /* data to be read as words */
299 * catch the zero numeric value special case
302 /* note a zero numeric value and return */
303 (state
->note
)(HASH_ZERO(state
->base
), state
);
308 * prep for a long value hash
310 (state
->note
)(state
->base
, state
);
313 * hash as if we have a 64 bit value
315 memset((char *)lval
, 0, sizeof(lval
));
317 (state
->update
)(state
, (USB8
*)lval
, sizeof(lval
));
327 * hash_zvalue - hash a ZVALUE
330 * type - hash type (see hash.h)
332 * state - the state to hash or NULL
338 hash_zvalue(int type
, ZVALUE zval
, HASH
*state
)
341 #if CALC_BYTE_ORDER == BIG_ENDIAN && BASEB == 16
342 int full_lim
; /* HALFs in whole chunks in zval */
343 int chunkhalf
; /* size of half buffer in HALFs */
348 HALF half
[MAX_CHUNKSIZE
]; /* For endian reversal */
352 * initialize if state is NULL
355 state
= hash_init(type
, NULL
);
359 * setup for the ZVALUE hash
361 (state
->chkpt
)(state
);
362 state
->bytes
= FALSE
; /* data to be read as words */
365 * catch the zero numeric value special case
368 /* note a zero numeric value and return */
369 (state
->note
)(HASH_ZERO(state
->base
), state
);
374 * prep for a ZVALUE hash
376 (state
->note
)(HASH_ZVALUE(state
->base
), state
);
377 /* note if we have a negative value */
379 (state
->note
)(HASH_NEG(state
->base
), state
);
382 #if CALC_BYTE_ORDER == BIG_ENDIAN && BASEB == 16
387 * We need to convert the array of HALFs into canonical architectural
388 * independent form -- 32 bit arrays. Because we have 16 bit values
389 * in Big Endian form, we need to swap 16 bit values so that they
390 * appear as 32 bit Big Endian values.
392 chunkhalf
= state
->chunksize
/sizeof(HALF
);
393 full_lim
= (zval
.len
/ chunkhalf
) * chunkhalf
;
394 for (i
=0; i
< full_lim
; i
+= chunkhalf
) {
395 /* HALF swap copy a chunk into a data buffer */
396 for (j
=0; j
< chunkhalf
; j
+= 2) {
397 half
[j
] = zval
.v
[i
+j
+1];
398 half
[j
+1] = zval
.v
[i
+j
];
400 (state
->update
)(state
, (USB8
*) half
, state
->chunksize
);
404 * hash the final partial chunk (if any)
406 * We need to convert the array of HALFs into canonical architectural
407 * independent form -- 32 bit arrays. Because we have 16 bit values
408 * in Big Endian form, we need to swap 16 bit values so that they
409 * appear as 32 bit Big Endian values.
411 if (zval
.len
> full_lim
) {
412 for (j
=0; j
< zval
.len
-full_lim
-1; j
+= 2) {
413 half
[j
] = zval
.v
[full_lim
+j
+1];
414 half
[j
+1] = zval
.v
[full_lim
+j
];
416 if (j
< zval
.len
-full_lim
) {
418 half
[j
+1] = zval
.v
[zval
.len
-1];
421 (state
->update
)(state
, (USB8
*) half
,
422 (zval
.len
-full_lim
)*sizeof(HALF
));
428 * hash the array of HALFs
430 * The array of HALFs is equivalent to the canonical architectural
431 * independent form. We either have 32 bit HALFs (in which case
432 * we do not case the byte order) or we have 16 bit HALFs in Little
433 * Endian order (which happens to be laid out in the same order as
436 (state
->update
)(state
, (USB8
*)zval
.v
, zval
.len
*sizeof(HALF
));
439 if (zval
.len
& 1) { /* padding to complete word */
441 (state
->update
)(state
, (USB8
*) half
, 2);
455 * hash_number - hash a NUMBER
458 * type - hash type (see hash.h)
460 * state - the state to hash or NULL
466 hash_number(int type
, void *n
, HASH
*state
)
468 NUMBER
*number
= (NUMBER
*)n
; /* n as a NUMBER pointer */
469 BOOL sign
; /* sign of the denominator */
472 * initialize if state is NULL
475 state
= hash_init(type
, NULL
);
479 * setup for the NUMBER hash
481 (state
->chkpt
)(state
);
482 state
->bytes
= FALSE
;
485 * process the numerator
487 state
= hash_zvalue(type
, number
->num
, state
);
490 * if the NUMBER is not an integer, process the denominator
492 if (qisfrac(number
)) {
494 /* note the division */
495 (state
->note
)(HASH_DIV(state
->base
), state
);
497 /* hash denominator as positive -- just in case */
498 sign
= number
->den
.sign
;
499 number
->den
.sign
= 0;
501 /* hash the denominator */
502 state
= hash_zvalue(type
, number
->den
, state
);
504 /* restore the sign */
505 number
->den
.sign
= sign
;
516 * hash_complex - hash a COMPLEX
519 * type - hash type (see hash.h)
521 * state - the state to hash or NULL
527 hash_complex(int type
, void *c
, HASH
*state
)
529 COMPLEX
*complex = (COMPLEX
*)c
; /* c as a COMPLEX pointer */
532 * initialize if state is NULL
535 state
= hash_init(type
, NULL
);
539 * setup for the COMPLEX hash
541 (state
->chkpt
)(state
);
542 state
->bytes
= FALSE
;
545 * catch the zero special case
547 if (ciszero(complex)) {
548 /* note a zero numeric value and return */
549 (state
->note
)(HASH_ZERO(state
->base
), state
);
554 * process the real value if not pure imaginary
556 * We will ignore the real part if the value is of the form 0+xi.
558 if (!qiszero(complex->real
)) {
559 state
= hash_number(type
, complex->real
, state
);
563 * if the NUMBER is not real, process the imaginary value
565 * We will ignore the imaginary part of the value is of the form x+0i.
567 if (!cisreal(complex)) {
569 /* note the sqrt(-1) */
570 (state
->note
)(HASH_COMPLEX(state
->base
), state
);
572 /* hash the imaginary value */
573 state
= hash_number(type
, complex->imag
, state
);
584 * hash_str - hash a null-terminated string
587 * type - hash type (see hash.h)
589 * state - the state to hash or NULL
595 hash_str(int type
, char *str
, HASH
*state
)
597 size_t len
; /* string length */
600 * initialize if state is NULL
603 state
= hash_init(type
, NULL
);
607 * setup for the string hash
610 (state
->chkpt
)(state
);
619 (state
->update
)(state
, (USB8
*)str
, len
);
629 * hash_STR - hash a STRING
632 * type - hash type (see hash.h)
634 * state - the state to hash or NULL
640 hash_STR(int type
, STRING
*str
, HASH
*state
)
643 * initialize if state is NULL
646 state
= hash_init(type
, NULL
);
650 * setup for the string hash
653 (state
->chkpt
)(state
);
660 (state
->update
)(state
, (USB8
*) str
->s_str
, (USB32
) str
->s_len
);
670 * hash_usb8 - hash an array of USB8s
673 * type - hash type (see hash.h)
674 * byte - pointer to an array of USB8s
675 * len - number of USB8s to hash
676 * state - the state to hash or NULL
682 hash_usb8(int type
, USB8
*byte
, int len
, HASH
*state
)
685 * initialize if state is NULL
688 state
= hash_init(type
, NULL
);
692 * setup for the string hash
695 (state
->chkpt
)(state
);
700 * hash the array of octets
702 (state
->update
)(state
, byte
, (USB32
)len
);
712 * hash_value - hash a value
715 * type - hash type (see hash.h)
717 * state - the state to hash or NULL
723 hash_value(int type
, void *v
, HASH
*state
)
725 LISTELEM
*ep
; /* list element pointer */
726 ASSOCELEM
**assochead
; /* association chain head */
727 ASSOCELEM
*aep
; /* current association value */
728 ASSOCELEM
*nextaep
; /* next association value */
729 VALUE
*value
= (VALUE
*)v
; /* v cast to a VALUE */
730 VALUE
*vp
; /* pointer to next OBJ table value */
731 ZVALUE fileval
; /* size, position, dev, inode of a file */
735 * initialize if state is NULL
738 state
= hash_init(type
, NULL
);
742 * process the value type
744 switch (value
->v_type
) {
746 (state
->chkpt
)(state
);
751 /* setup for the this value type */
752 (state
->chkpt
)(state
);
753 (state
->type
)(value
->v_type
, state
);
755 /* hash as if we have a 64 bit value */
756 state
= hash_int(type
, value
->v_int
, state
);
761 state
= hash_number(type
, value
->v_num
, state
);
765 /* setup for the this value type */
766 (state
->chkpt
)(state
);
767 (state
->type
)(value
->v_type
, state
);
770 state
= hash_complex(type
, value
->v_com
, state
);
774 /* there is nothing to setup, simply hash what we point at */
775 state
= hash_value(type
, value
->v_addr
, state
);
779 /* strings have no setup */
782 state
= hash_STR(type
, value
->v_str
, state
);
786 /* setup for the this value type */
787 (state
->chkpt
)(state
);
788 (state
->type
)(value
->v_type
, state
);
791 /* hash all the elements of the matrix */
792 for (i
=0; i
< value
->v_mat
->m_size
; ++i
) {
794 /* hash the next matrix value */
795 state
= hash_value(type
,
796 value
->v_mat
->m_table
+i
, state
);
797 state
->bytes
= FALSE
; /* as if reading words */
802 /* setup for the this value type */
803 (state
->chkpt
)(state
);
804 (state
->type
)(value
->v_type
, state
);
806 /* hash all the elements of the list */
807 for (i
=0, ep
= value
->v_list
->l_first
;
808 ep
!= NULL
&& i
< value
->v_list
->l_count
;
809 ++i
, ep
= ep
->e_next
) {
811 /* hash the next list value */
812 state
= hash_value(type
, &ep
->e_value
, state
);
813 state
->bytes
= FALSE
; /* as if reading words */
818 /* setup for the this value type */
819 (state
->chkpt
)(state
);
820 (state
->type
)(value
->v_type
, state
);
823 /* hash the association */
824 assochead
= value
->v_assoc
->a_table
;
825 for (i
= 0; i
< value
->v_assoc
->a_size
; i
++) {
826 nextaep
= *assochead
;
829 nextaep
= aep
->e_next
;
831 /* hash the next association value */
832 state
= hash_value(type
, &aep
->e_value
, state
);
833 state
->bytes
= FALSE
; /* as if reading words */
840 /* setup for the this value type */
841 (state
->chkpt
)(state
);
842 (state
->type
)(value
->v_type
, state
);
843 state
->bytes
= TRUE
; /* reading bytes */
845 /* hash the object name and then the element values */
847 state
= hash_str(type
, objtypename(
848 value
->v_obj
->o_actions
->oa_index
), state
);
849 (state
->chkpt
)(state
);
851 for (i
=value
->v_obj
->o_actions
->oa_count
,
852 vp
=value
->v_obj
->o_table
;
856 /* hash the next object value */
857 state
= hash_value(type
, vp
, state
);
858 state
->bytes
= FALSE
; /* as if reading words */
863 /* setup for the this value type */
864 (state
->chkpt
)(state
);
865 (state
->type
)(value
->v_type
, state
);
867 /* hash file length if possible */
868 if (getsize(value
->v_file
, &fileval
) == 0) {
869 state
= hash_zvalue(type
, fileval
, state
);
872 /* hash -1 for invalid length */
873 state
= hash_long(type
, (long)-1, state
);
875 /* hash the file position if possible */
876 if (getloc(value
->v_file
, &fileval
) == 0) {
877 state
= hash_zvalue(type
, fileval
, state
);
880 /* hash -1 for invalid location */
881 state
= hash_long(type
, (long)-1, state
);
883 /* hash the file device if possible */
884 if (get_device(value
->v_file
, &fileval
) == 0) {
885 state
= hash_zvalue(type
, fileval
, state
);
888 /* hash -1 for invalid device */
889 state
= hash_long(type
, (long)-1, state
);
891 /* hash the file inode if possible */
892 if (get_inode(value
->v_file
, &fileval
) == 0) {
893 state
= hash_zvalue(type
, fileval
, state
);
896 /* hash -1 for invalid inode */
897 state
= hash_long(type
, (long)-1, state
);
902 /* setup for the this value type */
903 (state
->chkpt
)(state
);
904 (state
->type
)(value
->v_type
, state
);
906 /* hash the RAND state */
907 state
= hash_int(type
, value
->v_rand
->seeded
, state
);
908 state
= hash_int(type
, value
->v_rand
->bits
, state
);
909 (state
->update
)(state
,
910 (USB8
*)value
->v_rand
->buffer
, SLEN
*FULL_BITS
/8);
911 state
= hash_int(type
, value
->v_rand
->j
, state
);
912 state
= hash_int(type
, value
->v_rand
->k
, state
);
913 state
= hash_int(type
, value
->v_rand
->need_to_skip
, state
);
914 (state
->update
)(state
,
915 (USB8
*)value
->v_rand
->slot
, SCNT
*FULL_BITS
/8);
916 (state
->update
)(state
,
917 (USB8
*)value
->v_rand
->shuf
, SHUFLEN
*FULL_BITS
/8);
918 state
->bytes
= FALSE
; /* as if reading words */
922 /* setup for the this value type */
923 (state
->chkpt
)(state
);
924 (state
->type
)(value
->v_type
, state
);
926 /* hash the RANDOM state */
927 state
= hash_int(type
, value
->v_random
->seeded
, state
);
928 state
= hash_int(type
, value
->v_random
->bits
, state
);
929 (state
->update
)(state
,
930 (USB8
*)&(value
->v_random
->buffer
), BASEB
/8);
931 state
= hash_zvalue(type
, value
->v_random
->r
, state
);
932 state
= hash_zvalue(type
, value
->v_random
->n
, state
);
933 state
->bytes
= FALSE
; /* as if reading words */
937 /* setup for the this value type */
938 (state
->chkpt
)(state
);
939 (state
->type
)(value
->v_type
, state
);
941 /* hash the CONFIG state */
942 state
= hash_int(type
, value
->v_config
->outmode
, state
);
943 state
= hash_int(type
, value
->v_config
->outmode2
, state
);
944 state
= hash_long(type
,(long)value
->v_config
->outdigits
, state
);
945 state
= hash_number(type
, value
->v_config
->epsilon
, state
);
946 state
= hash_long(type
,
947 (long)value
->v_config
->epsilonprec
, state
);
948 state
= hash_flag(type
, value
->v_config
->traceflags
, state
);
949 state
= hash_long(type
, (long)value
->v_config
->maxprint
, state
);
950 state
= hash_len(type
, value
->v_config
->mul2
, state
);
951 state
= hash_len(type
, value
->v_config
->sq2
, state
);
952 state
= hash_len(type
, value
->v_config
->pow2
, state
);
953 state
= hash_len(type
, value
->v_config
->redc2
, state
);
954 state
= hash_bool(type
, value
->v_config
->tilde_ok
, state
);
955 state
= hash_bool(type
, value
->v_config
->tab_ok
, state
);
956 state
= hash_long(type
, (long)value
->v_config
->quomod
, state
);
957 state
= hash_long(type
, (long)value
->v_config
->quo
, state
);
958 state
= hash_long(type
, (long)value
->v_config
->mod
, state
);
959 state
= hash_long(type
, (long)value
->v_config
->sqrt
, state
);
960 state
= hash_long(type
, (long)value
->v_config
->appr
, state
);
961 state
= hash_long(type
, (long)value
->v_config
->cfappr
, state
);
962 state
= hash_long(type
, (long)value
->v_config
->cfsim
, state
);
963 state
= hash_long(type
, (long)value
->v_config
->outround
, state
);
964 state
= hash_long(type
, (long)value
->v_config
->round
, state
);
965 state
= hash_bool(type
, value
->v_config
->leadzero
, state
);
966 state
= hash_bool(type
, value
->v_config
->fullzero
, state
);
967 state
= hash_long(type
,
968 (long)value
->v_config
->maxscancount
, state
);
969 state
= hash_str(type
, value
->v_config
->prompt1
, state
);
970 state
->bytes
= FALSE
; /* as if just read words */
971 state
= hash_str(type
, value
->v_config
->prompt2
, state
);
972 state
->bytes
= FALSE
; /* as if just read words */
973 state
= hash_int(type
, value
->v_config
->blkmaxprint
, state
);
974 state
= hash_bool(type
, value
->v_config
->blkverbose
, state
);
975 state
= hash_int(type
, value
->v_config
->blkbase
, state
);
976 state
= hash_int(type
, value
->v_config
->blkfmt
, state
);
977 state
= hash_long(type
,
978 (long)value
->v_config
->resource_debug
, state
);
979 state
= hash_long(type
,
980 (long)value
->v_config
->calc_debug
, state
);
981 state
= hash_long(type
,
982 (long)value
->v_config
->user_debug
, state
);
983 state
= hash_bool(type
, value
->v_config
->verbose_quit
, state
);
984 state
= hash_int(type
, value
->v_config
->ctrl_d
, state
);
985 state
= hash_str(type
, value
->v_config
->program
, state
);
986 state
= hash_str(type
, value
->v_config
->base_name
, state
);
987 state
= hash_bool(type
, value
->v_config
->windows
, state
);
988 state
= hash_bool(type
, value
->v_config
->cygwin
, state
);
989 state
= hash_bool(type
, value
->v_config
->compile_custom
, state
);
990 if (value
->v_config
->allow_custom
!= NULL
&&
991 *(value
->v_config
->allow_custom
)) {
992 state
= hash_bool(type
, TRUE
, state
);
994 state
= hash_bool(type
, FALSE
, state
);
996 state
= hash_str(type
, value
->v_config
->version
, state
);
997 state
= hash_int(type
, value
->v_config
->baseb
, state
);
998 state
= hash_bool(type
, value
->v_config
->redecl_warn
, state
);
999 state
= hash_bool(type
, value
->v_config
->dupvar_warn
, state
);
1003 /* setup for the this value type */
1004 (state
->chkpt
)(state
);
1005 (state
->type
)(value
->v_type
, state
);
1007 /* hash the HASH state */
1008 state
= hash_int(type
, value
->v_hash
->type
, state
);
1009 state
= hash_bool(type
, value
->v_hash
->bytes
,state
);
1010 state
= hash_int(type
, value
->v_hash
->base
, state
);
1011 state
= hash_int(type
, value
->v_hash
->chunksize
, state
);
1012 state
= hash_int(type
, value
->v_hash
->unionsize
, state
);
1013 (state
->update
)(state
,
1014 value
->v_hash
->h_union
.data
, state
->unionsize
);
1015 state
->bytes
= FALSE
; /* as if reading words */
1019 /* there is no setup for a BLOCK */
1021 /* hash the octets in the BLOCK */
1022 if (value
->v_block
->datalen
> 0) {
1023 state
= hash_usb8(type
, value
->v_block
->data
,
1024 value
->v_block
->datalen
, state
);
1029 /* there is no setup for an OCTET */
1031 /* hash the OCTET */
1032 state
= hash_usb8(type
, value
->v_octet
, 1, state
);
1036 /* there is no setup for a NBLOCK */
1038 /* hash the octets in the NBLOCK */
1039 if (value
->v_nblock
->blk
->datalen
> 0) {
1040 state
= hash_usb8(type
, value
->v_nblock
->blk
->data
,
1041 value
->v_nblock
->blk
->datalen
,
1047 math_error("hashing an unknown value");