mirror of
https://github.com/torvalds/linux.git
synced 2026-03-14 02:06:15 +01:00
crypto: padlock-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
f1440a9046
commit
34f442a3a0
1 changed files with 11 additions and 3 deletions
|
|
@ -206,8 +206,14 @@ static int padlock_init_tfm(struct crypto_shash *hash)
|
|||
return PTR_ERR(fallback_tfm);
|
||||
}
|
||||
|
||||
if (crypto_shash_descsize(hash) < sizeof(struct padlock_sha_desc) +
|
||||
crypto_shash_descsize(fallback_tfm)) {
|
||||
crypto_free_shash(fallback_tfm);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx->fallback = fallback_tfm;
|
||||
hash->descsize += crypto_shash_descsize(fallback_tfm);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -228,7 +234,8 @@ static struct shash_alg sha1_alg = {
|
|||
.import = padlock_sha_import,
|
||||
.init_tfm = padlock_init_tfm,
|
||||
.exit_tfm = padlock_exit_tfm,
|
||||
.descsize = sizeof(struct padlock_sha_desc),
|
||||
.descsize = sizeof(struct padlock_sha_desc) +
|
||||
sizeof(struct sha1_state),
|
||||
.statesize = sizeof(struct sha1_state),
|
||||
.base = {
|
||||
.cra_name = "sha1",
|
||||
|
|
@ -251,7 +258,8 @@ static struct shash_alg sha256_alg = {
|
|||
.import = padlock_sha_import,
|
||||
.init_tfm = padlock_init_tfm,
|
||||
.exit_tfm = padlock_exit_tfm,
|
||||
.descsize = sizeof(struct padlock_sha_desc),
|
||||
.descsize = sizeof(struct padlock_sha_desc) +
|
||||
sizeof(struct sha256_state),
|
||||
.statesize = sizeof(struct sha256_state),
|
||||
.base = {
|
||||
.cra_name = "sha256",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue