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 */ }; |
函数原型 |
void * wcrypto_create_digest_ctx (struct wd_queue *q, struct wcrypto_digest_ctx_setup *setup); |
---|---|
函数功能 |
基于Warpdrive queue创建消息摘要算法context |
输入说明 |
q:warpdrive queue setup:用户对于context的创建输入参数 |
输出说明 |
无 |
返回值说明 |
Context地址 NULL:失 非NULL:成功 |
使用说明 |
支持多线程 |
注意事项 |
函数原型 |
int wcrypto_set_digest_key (void *ctx, __u8 *key, __u16 key_len); |
---|---|
函数功能 |
设置HMAC需要的认证key信息到摘要算法context |
输入说明 |
ctx:消息摘要算法context key:输入key的指针地址 key_len:输入key的长度 |
输出说明 |
无 |
返回值说明 |
0:成功 否则失败(错误码含义请参考WD消息错误码接口定义) |
使用说明 |
|
注意事项 |
函数原型 |
int wcrypto_do_digest (void *ctx, struct wcrypto_digest_op_data *opdata, void *tag); |
---|---|
函数功能 |
基于digest context的消息摘要算法操作。 |
输入说明 |
ctx:消息摘要context opdata:摘要算法操作参数,包括输入输出以及操作类型等 tag:用户回调表示,为NULL时,为同步接口,否则为异步接口 |
输出说明 |
无 |
返回值说明 |
0:成功 否则失败 |
使用说明 |
同一个ctx仅支持单线程 |
注意事项 |
函数原型 |
int wcrypto_digest_poll (struct wd_queue *q, unsigned int num); |
---|---|
函数功能 |
基于warpdrive queue的摘要算法poll操作 |
输入说明 |
q:Warpdrive queue num:0---表示将队列q中所有回应消息全部收上来,非0---表示将队列中num个回应消息收上来 |
输出说明 |
无 |
返回值说明 |
大于0:成功收到对应个数的回应消息 0:没有收到任何回应 负值:poll发生错误 |
使用说明 |
同一个q仅支持单线程 |
注意事项 |
函数原型 |
void wcrypto_del_digest_ctx (void *ctx); |
---|---|
函数功能 |
删除一个Digest的context |
输入说明 |
ctx:需要删除的Digest context |
输出说明 |
无 |
返回值说明 |
无 |
使用说明 |
|
注意事项 |