crypto: hash - introduce crypto_shash_tfm_digest()
authorEric Biggers <ebiggers@google.com>
Sat, 2 May 2020 05:31:03 +0000 (22:31 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 8 May 2020 05:32:12 +0000 (15:32 +1000)
commit822a98b862d5b511826765d64ddf18192fc5b694
tree292c80ad704e481f41ad14cedf96abe8d918012f
parent13855fd8ce641e567c1b972048b5fd1451984e88
crypto: hash - introduce crypto_shash_tfm_digest()

Currently the simplest use of the shash API is to use
crypto_shash_digest() to digest a whole buffer.  However, this still
requires allocating a hash descriptor (struct shash_desc).  Many users
don't really want to preallocate one and instead just use a one-off
descriptor on the stack like the following:

{
SHASH_DESC_ON_STACK(desc, tfm);
int err;

desc->tfm = tfm;

err = crypto_shash_digest(desc, data, len, out);

shash_desc_zero(desc);
}

Wrap this in a new helper function crypto_shash_tfm_digest() that can be
used instead of the above.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/shash.c
include/crypto/hash.h