blob: 19021122719177a99fb9d4696d2130ccf5221ad2 [file] [log] [blame]
#ifndef _ASR_HASH_H_
#define _ASR_HASH_H_
#define ROUND_UP_TO_WORD_CNT(x) ((x + 0x3) >> 2)
#define HASH_ALIGN_BUF_SIZE 4096
#define BLOCK_ALGIN_SIZE 64
typedef enum {
HASH_INIT = 0x1,
HASH_UPDATE = 0x2,
HASH_FINAL = 0x3,
} HASH_OP_MODE_T;
typedef enum {
HASH_LEN_SHA1 = 20,
HASH_LEN_SHA256 = 32,
HASH_LEN_SHA224 = 28,
HASH_LEN_MD5 = 16,
HASH_LEN_SHA512 = 64,
HASH_LEN_SHA384 = 48,
} HASH_LEN_T;
typedef enum {
HASH_SIMPLE = 0,
HASH_HMAC,
} HASH_MODE_T;
typedef enum {
HASH_SHA1 = 0x0,
HASH_SHA256 = 0x1,
HASH_SHA224 = 0X2,
HASH_MD5 = 0x3,
HASH_SHA512 = 0x4,
HASH_SHA384 = 0X5,
} HASH_ALGO_T;
struct sha512_state {
unsigned int state[16];
};
struct sha256_state {
unsigned int state[8];
};
struct sha1_state {
unsigned int state[5];
};
struct md5_state {
unsigned int state[4];
};
typedef struct {
uint64_t length;
unsigned int curlen;
unsigned char buf[BLOCK_ALGIN_SIZE] __attribute__((aligned(4)));
uint32_t block_size;
struct sha512_state sha512;
struct sha256_state sha256;
struct sha1_state sha1;
struct md5_state md5;
} hash_state;
#endif