mirror of
https://github.com/torvalds/linux.git
synced 2026-03-14 00:56:20 +01:00
crypto: zynqmp-sha - Make descsize an algorithm attribute
Rather than setting descsize in init_tfm, set it statically and double-check it in init_tfm. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
34f442a3a0
commit
c1dd353d18
1 changed files with 9 additions and 2 deletions
|
|
@ -60,8 +60,14 @@ static int zynqmp_sha_init_tfm(struct crypto_shash *hash)
|
|||
if (IS_ERR(fallback_tfm))
|
||||
return PTR_ERR(fallback_tfm);
|
||||
|
||||
if (crypto_shash_descsize(hash) <
|
||||
sizeof(struct zynqmp_sha_desc_ctx) +
|
||||
crypto_shash_descsize(tfm_ctx->fbk_tfm)) {
|
||||
crypto_free_shash(fallback_tfm);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tfm_ctx->fbk_tfm = fallback_tfm;
|
||||
hash->descsize += crypto_shash_descsize(tfm_ctx->fbk_tfm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -170,7 +176,8 @@ static struct zynqmp_sha_drv_ctx sha3_drv_ctx = {
|
|||
.import = zynqmp_sha_import,
|
||||
.init_tfm = zynqmp_sha_init_tfm,
|
||||
.exit_tfm = zynqmp_sha_exit_tfm,
|
||||
.descsize = sizeof(struct zynqmp_sha_desc_ctx),
|
||||
.descsize = sizeof(struct zynqmp_sha_desc_ctx) +
|
||||
sizeof(struct sha3_state),
|
||||
.statesize = sizeof(struct sha3_state),
|
||||
.digestsize = SHA3_384_DIGEST_SIZE,
|
||||
.base = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue