Linux Async Crypto APIs for hash
Hi,
I'm new to crypto APIs and have some questions about Async hash APIs since I need to write a HW crypto driver.
When use crypto_ahash_digest(request), I understand that request includes everything needed to finish the hash. But we can also use following sequence of calls instead of one step and in this case I don't know how to interpret request in each call:
crypto_ahash_init(request); crypto_ahash_update(request);
... (Multiple updates allowed?)
crypto_ahash_final(request);
And each request contains:
struct ahash_request {
struct crypto_async_request base;
unsigned int nbytes;
struct scatterlist *src;
u8 *result;
/* This field may only be used by the ahash API code. */
void *priv;
void *__ctx[] CRYPTO_MINALIGN_ATTR;
};
From test_hash() in crypto/testmgr.c, I saw the same request was passed to crypto_ahash_init(), crypto_ahash_update() and crypto_ahash_final(), which makes me confused.
Even more complicated, there is crypto_ahash_finup() and I don't know the use case of it.
Can somebody explain the right way to use the APIs and how the driver is expected to interpret each field of ahash_request data structure in crypto_ahash_xxx() call?
Many thanks,
Bin
|