📄 tomcrypt_hash.h
字号:
/* ---- HASH FUNCTIONS ---- */#ifdef SHA512struct sha512_state { ulong64 length, state[8]; unsigned long curlen; unsigned char buf[128];};#endif#ifdef SHA256struct sha256_state { ulong64 length; ulong32 state[8], curlen; unsigned char buf[64];};#endif#ifdef SHA1struct sha1_state { ulong64 length; ulong32 state[5], curlen; unsigned char buf[64];};#endif#ifdef MD5struct md5_state { ulong64 length; ulong32 state[4], curlen; unsigned char buf[64];};#endif#ifdef MD4struct md4_state { ulong64 length; ulong32 state[4], curlen; unsigned char buf[64];};#endif#ifdef TIGERstruct tiger_state { ulong64 state[3], length; unsigned long curlen; unsigned char buf[64];};#endif#ifdef MD2struct md2_state { unsigned char chksum[16], X[48], buf[16]; unsigned long curlen;};#endif#ifdef RIPEMD128struct rmd128_state { ulong64 length; unsigned char buf[64]; ulong32 curlen, state[4];};#endif#ifdef RIPEMD160struct rmd160_state { ulong64 length; unsigned char buf[64]; ulong32 curlen, state[5];};#endif#ifdef WHIRLPOOLstruct whirlpool_state { ulong64 length, state[8]; unsigned char buf[64]; ulong32 curlen;};#endif#ifdef CHC_HASHstruct chc_state { ulong64 length; unsigned char state[MAXBLOCKSIZE], buf[MAXBLOCKSIZE]; ulong32 curlen;};#endiftypedef union Hash_state {#ifdef CHC_HASH struct chc_state chc;#endif#ifdef WHIRLPOOL struct whirlpool_state whirlpool;#endif#ifdef SHA512 struct sha512_state sha512;#endif#ifdef SHA256 struct sha256_state sha256;#endif#ifdef SHA1 struct sha1_state sha1;#endif#ifdef MD5 struct md5_state md5;#endif#ifdef MD4 struct md4_state md4;#endif#ifdef MD2 struct md2_state md2;#endif#ifdef TIGER struct tiger_state tiger;#endif#ifdef RIPEMD128 struct rmd128_state rmd128;#endif#ifdef RIPEMD160 struct rmd160_state rmd160;#endif} hash_state;extern struct ltc_hash_descriptor { /** name of hash */ char *name; /** internal ID */ unsigned char ID; /** Size of digest in octets */ unsigned long hashsize; /** Input block size in octets */ unsigned long blocksize; /** ASN.1 DER identifier */ unsigned char DER[64]; /** Length of DER encoding */ unsigned long DERlen; /** Init a hash state @param hash The hash to initialize @return CRYPT_OK if successful */ int (*init)(hash_state *hash); /** Process a block of data @param hash The hash state @param in The data to hash @param inlen The length of the data (octets) @return CRYPT_OK if successful */ int (*process)(hash_state *hash, const unsigned char *in, unsigned long inlen); /** Produce the digest and store it @param hash The hash state @param out [out] The destination of the digest @return CRYPT_OK if successful */ int (*done)(hash_state *hash, unsigned char *out); /** Self-test @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled */ int (*test)(void);} hash_descriptor[];#ifdef CHC_HASHint chc_register(int cipher);int chc_init(hash_state * md);int chc_process(hash_state * md, const unsigned char *in, unsigned long inlen);int chc_done(hash_state * md, unsigned char *hash);int chc_test(void);extern const struct ltc_hash_descriptor chc_desc;#endif#ifdef WHIRLPOOLint whirlpool_init(hash_state * md);int whirlpool_process(hash_state * md, const unsigned char *in, unsigned long inlen);int whirlpool_done(hash_state * md, unsigned char *hash);int whirlpool_test(void);extern const struct ltc_hash_descriptor whirlpool_desc;#endif#ifdef SHA512int sha512_init(hash_state * md);int sha512_process(hash_state * md, const unsigned char *in, unsigned long inlen);int sha512_done(hash_state * md, unsigned char *hash);int sha512_test(void);extern const struct ltc_hash_descriptor sha512_desc;#endif#ifdef SHA384#ifndef SHA512 #error SHA512 is required for SHA384#endifint sha384_init(hash_state * md);#define sha384_process sha512_processint sha384_done(hash_state * md, unsigned char *hash);int sha384_test(void);extern const struct ltc_hash_descriptor sha384_desc;#endif#ifdef SHA256int sha256_init(hash_state * md);int sha256_process(hash_state * md, const unsigned char *in, unsigned long inlen);int sha256_done(hash_state * md, unsigned char *hash);int sha256_test(void);extern const struct ltc_hash_descriptor sha256_desc;#ifdef SHA224#ifndef SHA256 #error SHA256 is required for SHA224#endifint sha224_init(hash_state * md);#define sha224_process sha256_processint sha224_done(hash_state * md, unsigned char *hash);int sha224_test(void);extern const struct ltc_hash_descriptor sha224_desc;#endif#endif#ifdef SHA1int sha1_init(hash_state * md);int sha1_process(hash_state * md, const unsigned char *in, unsigned long inlen);int sha1_done(hash_state * md, unsigned char *hash);int sha1_test(void);extern const struct ltc_hash_descriptor sha1_desc;#endif#ifdef MD5int md5_init(hash_state * md);int md5_process(hash_state * md, const unsigned char *in, unsigned long inlen);int md5_done(hash_state * md, unsigned char *hash);int md5_test(void);extern const struct ltc_hash_descriptor md5_desc;#endif#ifdef MD4int md4_init(hash_state * md);int md4_process(hash_state * md, const unsigned char *in, unsigned long inlen);int md4_done(hash_state * md, unsigned char *hash);int md4_test(void);extern const struct ltc_hash_descriptor md4_desc;#endif#ifdef MD2int md2_init(hash_state * md);int md2_process(hash_state * md, const unsigned char *in, unsigned long inlen);int md2_done(hash_state * md, unsigned char *hash);int md2_test(void);extern const struct ltc_hash_descriptor md2_desc;#endif#ifdef TIGERint tiger_init(hash_state * md);int tiger_process(hash_state * md, const unsigned char *in, unsigned long inlen);int tiger_done(hash_state * md, unsigned char *hash);int tiger_test(void);extern const struct ltc_hash_descriptor tiger_desc;#endif#ifdef RIPEMD128int rmd128_init(hash_state * md);int rmd128_process(hash_state * md, const unsigned char *in, unsigned long inlen);int rmd128_done(hash_state * md, unsigned char *hash);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -