mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
crypto: hash - Add import/export interface
It is often useful to save the partial state of a hash function so that it can be used as a base for two or more computations. The most prominent example is HMAC where all hashes start from a base determined by the key. Having an import/export interface means that we only have to compute that base once rather than for each message. Signed-off-by: Herbert Xu <[email protected]>
This commit is contained in:
parent
3b2f6df082
commit
dec8b78606
5 changed files with 50 additions and 5 deletions
|
|
@ -146,6 +146,20 @@ static int ahash_setkey(struct crypto_ahash *tfm, const u8 *key,
|
|||
return ahash->setkey(tfm, key, keylen);
|
||||
}
|
||||
|
||||
int crypto_ahash_import(struct ahash_request *req, const u8 *in)
|
||||
{
|
||||
struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
|
||||
struct ahash_alg *alg = crypto_ahash_alg(tfm);
|
||||
|
||||
memcpy(ahash_request_ctx(req), in, crypto_ahash_reqsize(tfm));
|
||||
|
||||
if (alg->reinit)
|
||||
alg->reinit(req);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(crypto_ahash_import);
|
||||
|
||||
static unsigned int crypto_ahash_ctxsize(struct crypto_alg *alg, u32 type,
|
||||
u32 mask)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue