?? md6.h
字號:
/* remaining (d mod 8) bits (if any) appearing in */
/* high-order bit positions of hashval[1+floor(d/8)]. */
unsigned char hexhashval[(md6_c*(md6_w/8))+1];
/* e.g. unsigned char hexhashval[129]; */
/* zero-terminated string representing hex value of hashval */
int initialized; /* zero, then one after md6_init called */
uint64_t bits_processed; /* bits processed so far */
uint64_t compression_calls; /* compression function calls made*/
int finalized; /* zero, then one after md6_final called */
md6_word K[ md6_k ];
/* k-word (8 word) key (aka "salt") for this instance of md6 */
int keylen;
/* number of bytes in key K. 0<=keylen<=k*(w/8) */
int L;
/* md6 mode specification parameter. 0 <= L <= 255 */
/* L == 0 means purely sequential (Merkle-Damgaard) */
/* L >= 29 means purely tree-based */
/* Default is md6_default_L = 64 (hierarchical) */
int r;
/* Number of rounds. 0 <= r <= 255 */
int top;
/* index of block corresponding to top of stack */
md6_word B[ md6_max_stack_height ][ md6_b ];
/* md6_word B[29][64] */
/* stack of 29 64-word partial blocks waiting to be */
/* completed and compressed. */
/* B[1] is for compressing text data (input); */
/* B[ell] corresponds to node at level ell in the tree. */
unsigned int bits[ md6_max_stack_height ];
/* bits[ell] = */
/* number of bits already placed in B[ell] */
/* for 1 <= ell < max_stack_height */
/* 0 <= bits[ell] <= b*w */
uint64_t i_for_level[ md6_max_stack_height ];
/* i_for_level[ell] = */
/* index of the node B[ ell ] on this level (0,1,...) */
/* when it is output */
} md6_state;
/* MD6 main interface routines
**
** These routines are defined in md6_mode.c
*/
/* The next routines are used according to the pattern:
** md6_init (or md6_full_init if you use additional parameters)
** md6_update (once for each portion of the data to be hashed)
** md6_final (to finish up hash computation)
** Note: md6_final can return the hash value to a desired location, but
** hash value also remains available inside the md6_state, in both binary
** and hex formats (st->hashval and st->hexhashval).
*/
extern int md6_init( md6_state *st, /* state to initialize */
int d /* hash bit length */
);
extern int md6_full_init( md6_state *st, /* state to initialize */
int d, /* hash bit length */
unsigned char *key, /* OK to give NULL */
int keylen, /* (in bytes) OK to give 0 */
int L, /* mode; OK to give md6_default_L */
int r /* number of rounds */
);
extern int md6_update( md6_state *st, /* initialized state */
unsigned char *data, /* data portion */
uint64_t databitlen /* its length in bits */
);
extern int md6_final( md6_state *st, /* initialized/updated */
unsigned char *hashval /* output; NULL OK */
);
/* MD6 main interface routines
**
** These routines are defined in md6_mode.c
**
** These routines compute a hash for a message given all at once.
** The resulting hash value is returned to a specified location.
** Only one call is needed. Use md6_hash for the standard md6 hash,
** and md6_full_hash if you want to specify additional parameters.
*/
extern int md6_hash( int d, /* hash bit length */
unsigned char *data, /* complete data to hash */
uint64_t databitlen, /* its length in bits */
unsigned char *hashval /* output */
);
extern int md6_full_hash( int d, /* hash bit length */
unsigned char *data,/* complete data to hash */
uint64_t databitlen, /* its length in bits */
unsigned char *key, /* OK to give NULL */
int keylen, /* (in bytes) OK to give 0 */
int L, /* mode; OK to give md6_default_L */
int r, /* number of rounds */
unsigned char *hashval /* output */
);
/* MD6 return codes.
**
** The interface routines defined in md6_mode.c always return a
** "return code": an integer giving the status of the call.
** The codes
** SUCCESS, FAIL, and BADHASHLEN same as for NIST API
*/
/* SUCCESS: */
#define MD6_SUCCESS 0
/* ERROR CODES: */
#define MD6_FAIL 1 /* some other problem */
#define MD6_BADHASHLEN 2 /* hashbitlen<1 or >512 bits */
#define MD6_NULLSTATE 3 /* null state passed to MD6 */
#define MD6_BADKEYLEN 4 /* key length is <0 or >512 bits */
#define MD6_STATENOTINIT 5 /* state was never initialized */
#define MD6_STACKUNDERFLOW 6 /* MD6 stack underflows (shouldn't happen)*/
#define MD6_STACKOVERFLOW 7 /* MD6 stack overflow (message too long) */
#define MD6_NULLDATA 8 /* null data pointer */
#define MD6_NULL_N 9 /* compress: N is null */
#define MD6_NULL_B 10 /* standard compress: null B pointer */
#define MD6_BAD_ELL 11 /* standard compress: ell not in {0,255} */
#define MD6_BAD_p 12 /* standard compress: p<0 or p>b*w */
#define MD6_NULL_K 13 /* standard compress: K is null */
#define MD6_NULL_Q 14 /* standard compress: Q is null */
#define MD6_NULL_C 15 /* standard compress: C is null */
#define MD6_BAD_L 16 /* standard compress: L <0 or > 255 */
/* md6_init: L<0 or L>255 */
#define MD6_BAD_r 17 /* compress: r<0 or r>255 */
/* md6_init: r<0 or r>255 */
#define MD6_OUT_OF_MEMORY 18 /* compress: storage allocation failed */
/* The following code confirms that the defined MD6 constants satisfy
** some expected properties. These tests should never fail; consider
** these tests to be documentation. Failure of these tests would cause
** compilation to fail.
*/
#if ( (md6_w!=8) && (md6_w!=16) && (md6_w!=32) && (md6_w!=64) )
#error "md6.h Fatal error: md6_w must be one of 8,16,32, or 64."
#elif ( md6_n<=0 )
#error "md6.h Fatal error: md6_n must be positive."
#elif ( md6_b<=0 )
#error "md6.h Fatal error: md6_b must be positive."
#elif ( md6_c<=0 )
#error "md6.h Fatal error: md6_c must be positive."
#elif ( md6_v<0 )
#error "md6.h Fatal error: md6_v must be nonnegative."
#elif ( md6_u<0 )
#error "md6.h Fatal error: md6_u must be nonnegative."
#elif ( md6_k<0 )
#error "md6.h Fatal error: md6_k must be nonnegative."
#elif ( md6_q<0 )
#error "md6.h Fatal error: md6_q must be nonnegative."
#elif ( md6_b>=md6_n )
#error "md6.h Fatal error: md6_b must be smaller than md6_n."
#elif ( md6_c>=md6_b )
#error "md6.h Fatal error: md6_c must be smaller than md6_b."
#elif ( (md6_b%md6_c)!=0 )
#error "md6.h Fatal error: md6_b must be a multiple of md6_c."
#elif ( md6_n != md6_b + md6_v + md6_u + md6_k + md6_q )
#error "md6.h Fatal error: md6_n must = md6_b + md6_v + md6_u + md6_k + md6_q."
#elif ( md6_max_stack_height < 3 )
#error "md6.h Fatal error: md6_max_stack_height must be at least 3."
#elif ( md6_r * md6_c + md6_n >= 5000 )
/* since md6_standard_compress allocates fixed-size array A[5000] */
#error "md6.h Fatal error: r*c+n must be < 5000."
#if 0
/* "sizeof" doesn't work in preprocessor, these checks don't work */
#elif ( (md6_v != 0) && (md6_v != (sizeof(md6_control_word)/(md6_w/8))) )
#error "md6.h Fatal error: md6_v must be 0 or match md6_control_word size."
#elif ( (md6_u != 0) && (md6_u != (sizeof(md6_nodeID)/(md6_w/8))) )
#error "md6.h Fatal error: md6_u must be 0 or match md6_nodeID size."
#endif
#endif
/* Debugging and testing.
*/
/* compression hook, if defined, points to a function that is
** called after each compression operation.
**
** compression hook must be set *after* md6_init or md6_full_init
** is called.
*/
void (* compression_hook)(md6_word *C,
const md6_word *Q,
md6_word *K,
int ell,
int i,
int r,
int L,
int z,
int p,
int keylen,
int d,
md6_word *N
);
/* end of #ifndef MD6_H_INCLUDED for multiple inclusion protection
*/
#endif
/* end of md6.h */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -