Interfaces Related to Hash
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | /* Digest message format of Warpdrive */ struct wcrypto_digest_msg { __u8 alg_type;/* Denoted by enum wcrypto_type */ __u8 alg:4;/* Denoted by enum wcrypto_digest_alg */ __u8 has_next:1;/* denote whether there is next associated data */ __u8 mode:3;/* Denoted by enum wcrypto_digest_mode */ __u8 data_fmt;/* Data format, denoted by enum wd_buff_type */ __u8 result;/* Data format, denoted by WD error code */ __u16 key_bytes;/* Key size */ __u16 iv_bytes;/* IV size */ __u8 *key;/* Input key VA pointer, should be DMA buffer */ __u8 *iv;/* Input IV VA pointer, should be DMA buffer */ __u8 *in;/* Input data VA pointer, should be DMA buffer */ __u8 *out;/* Output data VA pointer, should be DMA buffer */ __u32 in_bytes;/* Input data bytes */ __u32 out_bytes;/* Output data bytes */ __u64 usr_data;/* user identifier: for example, can be struct wcrypto_cb_tag */ }; enum wcrypto_digest_alg { WCRYPTO_SM3, WCRYPTO_MD5, WCRYPTO_SHA1, WCRYPTO_SHA256, WCRYPTO_SHA224, WCRYPTO_SHA384, WCRYPTO_SHA512, WCRYPTO_SHA512_224, WCRYPTO_SHA512_256, WCRYPTO_MAX_DIGEST_TYPE, }; enum wcrypto_digest_mode { WCRYPTO_DIGEST_NORMAL, WCRYPTO_DIGEST_HMAC, }; struct wcrypto_digest_ctx_setup { wcrypto_cb cb;/* call back function from user */ enum wcrypto_digest_alg alg;/* digest algorithm type */ enum wcrypto_digest_mode mode;/* digest algorithm mode */ struct wcrypto_mm_ops ops;/* memory operations from user */ __u16 data_fmt;/* data format denoted by enum wd_buff_type */ }; struct wcrypto_digest_op_data { void *in;/* digest operation input address, should be dma buffer */ void *out;/* digest operation output address, shoud be dma buffer */ __u32 in_bytes;/* digest operation input bytes */ __u32 out_bytes;/* digest operation output bytes */ void *priv;/* private information should be dma buffer */ int status;/* digest operation status */ bool has_next;/* denote whether there is next associated data */ }; |
Prototype |
void * wcrypto_create_digest_ctx (struct wd_queue *q, struct wcrypto_digest_ctx_setup *setup); |
|---|---|
Function |
Create a message digest context based on the WD queue. |
Input Description |
q: WD queue setup: context creation input parameter |
Output Description |
None |
Return Value Description |
Context address. NULL: failure A non-NULL value: success |
Usage Instruction |
Multiple threads are supported. |
Precautions |
Prototype |
int wcrypto_set_digest_key (void *ctx, __u8 *key, __u16 key_len); |
|---|---|
Function |
Set the HMAC authentication key information to the message digest context. |
Input Description |
ctx: message digest context key: input key pointer address key_len: length of the input key |
Output Description |
None |
Return Value Description |
0: success Others: failure (For details about error codes, see WD Message Error Code Interface.) |
Usage Instruction |
|
Precautions |
Prototype |
int wcrypto_do_digest (void *ctx, struct wcrypto_digest_op_data *opdata, void *tag); |
|---|---|
Function |
Perform message digest operations based on the digest context. |
Input Description |
ctx: message digest context opdata: message digest operation parameters, including the input, output, and operation types tag: user callback. If the value is NULL, the interface is a synchronous interface. Otherwise, the interface is an asynchronous interface. |
Output Description |
None |
Return Value Description |
0: success Others: failure |
Usage Instruction |
One ctx supports only one thread. |
Precautions |
Prototype |
int wcrypto_digest_poll (struct wd_queue *q, unsigned int num); |
|---|---|
Function |
Perform message digest poll operations based on the WD queue. |
Input Description |
q: WD queue num: 0 indicates that all response messages in queue q are received. A non-0 value indicates the number of response messages received in queue q. |
Output Description |
None |
Return Value Description |
A value greater than 0: number of the received response messages 0: No response message is received. A negative value: poll error |
Usage Instruction |
One q supports only one thread. |
Precautions |
Prototype |
void wcrypto_del_digest_ctx (void *ctx); |
|---|---|
Function |
Delete a digest context. |
Input Description |
ctx: digest context to be deleted |
Output Description |
None |
Return Value Description |
None |
Usage Instruction |
|
Precautions |