9#ifndef CRYPTO_HASH_STRUCT_H
10#define CRYPTO_HASH_STRUCT_H
37#define compat_hash_type(is_hmac, alg, mode, max_message_length, block_size, result_size) \
38 ((((is_hmac) & 0xF) << 28) | (((alg) & 0xF) << 24) | (((mode) & 0xF) << 20) | \
39 (((max_message_length) & 0xF) << 16) | (((block_size) & 0xF) << 12) | ((result_size) & 0xFFF))
41#define CRYPTO_HASH_TYPE 0
42#define CRYPTO_HMAC_TYPE 1
43#define CRYPTO_IS_HMAC_MASK 0xF0000000
44#define CRYPTO_IS_HMAC_SHIFT 28
46#define CRYPTO_HASH_ALG_SHA1 0
47#define CRYPTO_HASH_ALG_SHA2 1
48#define CRYPTO_HASH_ALG_SM3 2
49#define CRYPTO_HASH_ALG_MASK 0x0F000000
50#define CRYPTO_HASH_ALG_SHIFT 24
52#define CRYPTO_HASH_MODE_224 0
53#define CRYPTO_HASH_MODE_256 1
54#define CRYPTO_HASH_MODE_384 2
55#define CRYPTO_HASH_MODE_512 3
56#define CRYPTO_HASH_MODE_UNDEF 0xf
57#define CRYPTO_HASH_MODE_MASK 0x00F00000
58#define CRYPTO_HASH_MODE_SHIFT 20
60#define CRYPTO_HASH_MAX_MESSAGE_LEN_64BIT 0x6
61#define CRYPTO_HASH_MAX_MESSAGE_LEN_128BIT 0x7
62#define CRYPTO_HASH_MAX_MESSAGE_LEN_MASK 0x000F0000
63#define CRYPTO_HASH_MAX_MESSAGE_LEN_SHIFT 16
65#define CRYPTO_HASH_BLOCK_SIZE_512BIT 0x9
66#define CRYPTO_HASH_BLOCK_SIZE_1024BIT 0xa
67#define CRYPTO_HASH_BLOCK_SIZE_MASK 0x0000F000
68#define CRYPTO_HASH_BLOCK_SIZE_SHIFT 12
70#define CRYPTO_HASH_RESULT_SIZE_160BIT 0xa0
71#define CRYPTO_HASH_RESULT_SIZE_224BIT 0xe0
72#define CRYPTO_HASH_RESULT_SIZE_256BIT 0x100
73#define CRYPTO_HASH_RESULT_SIZE_384BIT 0x180
74#define CRYPTO_HASH_RESULT_SIZE_512BIT 0x200
75#define CRYPTO_HASH_RESULT_SIZE_MASK 0x00000FFF
76#define CRYPTO_HASH_RESULT_SIZE_SHIFT 0
78#define CRYPTO_HASH_BLOCK_SIZE_20BYTE 0x14
79#define CRYPTO_HASH_BLOCK_SIZE_32BYTE 0x20
80#define CRYPTO_HASH_BLOCK_SIZE_64BYTE 0x40
82#define crypto_hash_get_attr(value, mask, shift) (((td_u32)(value) & (td_u32)(mask)) >> (shift))
83#define crypto_hash_macth(value, mask, target, shift) (crypto_hash_get_attr(value, mask, shift) == (target))
85#define crypto_hash_get_alg(hash_type) \
86 crypto_hash_get_attr(hash_type, CRYPTO_HASH_ALG_MASK, CRYPTO_HASH_ALG_SHIFT)
87#define crypto_hash_get_mode(hash_type) \
88 crypto_hash_get_attr(hash_type, CRYPTO_HASH_MODE_MASK, CRYPTO_HASH_MODE_SHIFT)
89#define crypto_hash_is_hmac(hash_type) \
90 crypto_hash_macth(hash_type, CRYPTO_IS_HMAC_MASK, CRYPTO_HMAC_TYPE, CRYPTO_IS_HMAC_SHIFT)
91#define crypto_hash_get_message_len(hash_type) \
92 (1 << crypto_hash_get_attr(hash_type, CRYPTO_HASH_MAX_MESSAGE_LEN_MASK, CRYPTO_HASH_MAX_MESSAGE_LEN_SHIFT))
93#define crypto_hash_get_block_size(hash_type) \
94 (1 << crypto_hash_get_attr(hash_type, CRYPTO_HASH_BLOCK_SIZE_MASK, CRYPTO_HASH_BLOCK_SIZE_SHIFT))
95#define crypto_hash_get_result_size(hash_type) \
96 crypto_hash_get_attr(hash_type, CRYPTO_HASH_RESULT_SIZE_MASK, CRYPTO_HASH_RESULT_SIZE_SHIFT)
164#define CRYPTO_HASH_RESULT_SIZE_MAX 64
165#define CRYPTO_HASH_RESULT_SIZE_MAX_IN_WORD 16
166#define CRYPTO_HASH_BLOCK_SIZE_MAX 128
173#if defined(CRYPTO_SOFT_HMAC_SUPPORT)
#define CRYPTO_HASH_RESULT_SIZE_512BIT
Definition crypto_hash_struct.h:74
#define CRYPTO_HASH_BLOCK_SIZE_512BIT
Definition crypto_hash_struct.h:65
#define CRYPTO_HMAC_TYPE
Definition crypto_hash_struct.h:42
#define CRYPTO_HASH_BLOCK_SIZE_1024BIT
Definition crypto_hash_struct.h:66
#define CRYPTO_HASH_RESULT_SIZE_384BIT
Definition crypto_hash_struct.h:73
#define CRYPTO_HASH_MODE_224
Definition crypto_hash_struct.h:52
#define CRYPTO_HASH_ALG_SM3
Definition crypto_hash_struct.h:48
#define CRYPTO_HASH_ALG_SHA1
Definition crypto_hash_struct.h:46
#define CRYPTO_HASH_MODE_512
Definition crypto_hash_struct.h:55
#define CRYPTO_HASH_RESULT_SIZE_MAX_IN_WORD
Definition crypto_hash_struct.h:165
#define CRYPTO_HASH_MODE_UNDEF
Definition crypto_hash_struct.h:56
#define CRYPTO_HASH_TYPE
Definition crypto_hash_struct.h:41
#define CRYPTO_HASH_RESULT_SIZE_224BIT
Definition crypto_hash_struct.h:71
#define CRYPTO_HASH_MAX_MESSAGE_LEN_64BIT
Definition crypto_hash_struct.h:60
#define CRYPTO_HASH_RESULT_SIZE_256BIT
Definition crypto_hash_struct.h:72
#define CRYPTO_HASH_MODE_384
Definition crypto_hash_struct.h:54
crypto_hash_type
Definition crypto_hash_struct.h:98
@ CRYPTO_HASH_TYPE_HMAC_SHA224
Definition crypto_hash_struct.h:130
@ CRYPTO_HASH_TYPE_HMAC_SHA256
Definition crypto_hash_struct.h:134
@ CRYPTO_HASH_TYPE_HMAC_SHA512
Definition crypto_hash_struct.h:142
@ CRYPTO_HASH_TYPE_SHA1
Definition crypto_hash_struct.h:100
@ CRYPTO_HASH_TYPE_SHA256
Definition crypto_hash_struct.h:108
@ CRYPTO_HASH_TYPE_HMAC_SHA384
Definition crypto_hash_struct.h:138
@ CRYPTO_HASH_TYPE_HMAC_SM3
Definition crypto_hash_struct.h:146
@ CRYPTO_HASH_TYPE_SHA384
Definition crypto_hash_struct.h:112
@ CRYPTO_HASH_TYPE_INVALID
Definition crypto_hash_struct.h:151
@ CRYPTO_HASH_TYPE_SHA224
Definition crypto_hash_struct.h:104
@ CRYPTO_HASH_TYPE_HMAC_SHA1
Definition crypto_hash_struct.h:126
@ CRYPTO_HASH_TYPE_SM3
Definition crypto_hash_struct.h:120
@ CRYPTO_HASH_TYPE_SHA512
Definition crypto_hash_struct.h:116
#define compat_hash_type(is_hmac, alg, mode, max_message_length, block_size, result_size)
Definition crypto_hash_struct.h:37
#define CRYPTO_HASH_ALG_SHA2
Definition crypto_hash_struct.h:47
#define CRYPTO_HASH_MODE_256
Definition crypto_hash_struct.h:53
#define CRYPTO_HASH_BLOCK_SIZE_MAX
Definition crypto_hash_struct.h:166
#define CRYPTO_HASH_MAX_MESSAGE_LEN_128BIT
Definition crypto_hash_struct.h:61
#define CRYPTO_HASH_RESULT_SIZE_160BIT
Definition crypto_hash_struct.h:70
Definition crypto_hash_struct.h:154
td_u32 key_len
Definition crypto_hash_struct.h:156
td_handle drv_keyslot_handle
Definition crypto_hash_struct.h:157
td_bool is_keyslot
Definition crypto_hash_struct.h:159
td_bool is_long_term
Definition crypto_hash_struct.h:160
td_u8 * key
Definition crypto_hash_struct.h:155
crypto_hash_type hash_type
Definition crypto_hash_struct.h:158
Definition crypto_hash_struct.h:168
td_u32 tail_len
Definition crypto_hash_struct.h:171
crypto_hash_type hash_type
Definition crypto_hash_struct.h:172
Definition crypto_hash_struct.h:188
td_u32 prk_length
Definition crypto_hash_struct.h:191
td_u32 info_length
Definition crypto_hash_struct.h:193
crypto_hash_type hmac_type
Definition crypto_hash_struct.h:189
td_u8 * info
Definition crypto_hash_struct.h:192
td_u8 * prk
Definition crypto_hash_struct.h:190
Definition crypto_hash_struct.h:196
td_u8 * ikm
Definition crypto_hash_struct.h:200
td_u8 * salt
Definition crypto_hash_struct.h:198
td_u32 ikm_length
Definition crypto_hash_struct.h:201
td_u8 * info
Definition crypto_hash_struct.h:202
td_u32 salt_length
Definition crypto_hash_struct.h:199
crypto_hash_type hmac_type
Definition crypto_hash_struct.h:197
td_u32 info_length
Definition crypto_hash_struct.h:203
td_u32 td_handle
Definition td_type.h:51
unsigned char td_u8
Definition td_type.h:36
td_u8 td_bool
Definition td_type.h:50
unsigned int td_u32
Definition td_type.h:38