crypto: ahash - Set default reqsize from ahash_alg
[ Upstream commit 9e01aaa1033d6e40f8d7cf4f20931a61ce9e3f04 ] Add a reqsize field to struct ahash_alg and use it to set the default reqsize so that algorithms with a static reqsize are not forced to create an init_tfm function. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
b1d1b09698
commit
3a0c8429ab
@@ -427,6 +427,7 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm)
|
|||||||
hash->setkey = ahash_nosetkey;
|
hash->setkey = ahash_nosetkey;
|
||||||
|
|
||||||
crypto_ahash_set_statesize(hash, alg->halg.statesize);
|
crypto_ahash_set_statesize(hash, alg->halg.statesize);
|
||||||
|
crypto_ahash_set_reqsize(hash, alg->reqsize);
|
||||||
|
|
||||||
if (tfm->__crt_alg->cra_type != &crypto_ahash_type)
|
if (tfm->__crt_alg->cra_type != &crypto_ahash_type)
|
||||||
return crypto_init_shash_ops_async(tfm);
|
return crypto_init_shash_ops_async(tfm);
|
||||||
@@ -599,6 +600,9 @@ static int ahash_prepare_alg(struct ahash_alg *alg)
|
|||||||
if (alg->halg.statesize == 0)
|
if (alg->halg.statesize == 0)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (alg->reqsize && alg->reqsize < alg->halg.statesize)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
err = hash_prepare_alg(&alg->halg);
|
err = hash_prepare_alg(&alg->halg);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
@@ -153,6 +153,7 @@ struct ahash_request {
|
|||||||
* This is a counterpart to @init_tfm, used to remove
|
* This is a counterpart to @init_tfm, used to remove
|
||||||
* various changes set in @init_tfm.
|
* various changes set in @init_tfm.
|
||||||
* @clone_tfm: Copy transform into new object, may allocate memory.
|
* @clone_tfm: Copy transform into new object, may allocate memory.
|
||||||
|
* @reqsize: Size of the request context.
|
||||||
* @halg: see struct hash_alg_common
|
* @halg: see struct hash_alg_common
|
||||||
*/
|
*/
|
||||||
struct ahash_alg {
|
struct ahash_alg {
|
||||||
@@ -169,6 +170,8 @@ struct ahash_alg {
|
|||||||
void (*exit_tfm)(struct crypto_ahash *tfm);
|
void (*exit_tfm)(struct crypto_ahash *tfm);
|
||||||
int (*clone_tfm)(struct crypto_ahash *dst, struct crypto_ahash *src);
|
int (*clone_tfm)(struct crypto_ahash *dst, struct crypto_ahash *src);
|
||||||
|
|
||||||
|
unsigned int reqsize;
|
||||||
|
|
||||||
struct hash_alg_common halg;
|
struct hash_alg_common halg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user