diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2025-02-16 11:07:24 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2025-02-22 16:09:05 +0800 |
commit | 9e01aaa1033d6e40f8d7cf4f20931a61ce9e3f04 (patch) | |
tree | cf1d96bae4fe86b79b29c1ca63be7d106d9efd03 /crypto | |
parent | 439963cdc3aa447dfd3b5abc05fcd25cef4d22dc (diff) |
crypto: ahash - Set default reqsize from ahash_alg
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>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ahash.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/crypto/ahash.c b/crypto/ahash.c index 208aa4c8d725..9c26175c21a8 100644 --- a/crypto/ahash.c +++ b/crypto/ahash.c @@ -879,6 +879,7 @@ static int crypto_ahash_init_tfm(struct crypto_tfm *tfm) struct ahash_alg *alg = crypto_ahash_alg(hash); crypto_ahash_set_statesize(hash, alg->halg.statesize); + crypto_ahash_set_reqsize(hash, alg->reqsize); if (tfm->__crt_alg->cra_type == &crypto_shash_type) return crypto_init_ahash_using_shash(tfm); @@ -1044,6 +1045,9 @@ static int ahash_prepare_alg(struct ahash_alg *alg) if (alg->halg.statesize == 0) return -EINVAL; + if (alg->reqsize && alg->reqsize < alg->halg.statesize) + return -EINVAL; + err = hash_prepare_alg(&alg->halg); if (err) return err; |