Rate This Document
Findability
Accuracy
Completeness
Readability

Creating a Digest Context

When creating a digest context, you need to provide the memory and related management functions to fill in setup.ops. You can provide the third-party memory or use the BLK memory pool interface provided by the WD to create the digest context. The following describes how to create a digest context based on test_mempool applied by wd_queue. To perform HMAC operations, you need to set the authentication key by invoking wd_set_digest_key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
struct wcrypto_digest_ctx_setup setup;
void *ctx = NULL,*pool = NULL;
int block_size = TEST_BLOCK_SIZE;
int block_num = TEST_BLOCK_NUM;

pool = test_mempool_create(&q, block_size, block_num);
memset((void *)&setup, 0, sizeof(setup));
setup.ops.alloc = test_alloc_buf;
setup.ops.free = test_free_buf;
setup.ops.dma_map = test_ dma_map;
setup.ops.dma_unmap = test_ dma_unmap;
setup.ops.usr = pool;
setup.alg = WD_SM3;
setup.mode = WD_DIGEST_NORMAL;
ctx = wcrypto_create_digest_ctx(&q, &setup);