crypto: s390/sha512 - Fix sha512 state size
The sha512 state size in s390_sha_ctx is out by a factor of 8,
fix it so that it stays below HASH_MAX_DESCSIZE. Also fix the
state init function which was writing garbage to the state. Luckily
this is not actually used for anything other than export.
Reported-by: Harald Freudenberger <freude@linux.ibm.com>
Fixes: 572b5c4682 ("crypto: s390/sha512 - Use API partial block handling")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
pull/1250/head
parent
2dfc7cd74a
commit
5b39aa368b
|
|
@ -24,7 +24,7 @@ struct s390_sha_ctx {
|
|||
union {
|
||||
u32 state[CPACF_MAX_PARMBLOCK_SIZE / sizeof(u32)];
|
||||
struct {
|
||||
u64 state[SHA512_DIGEST_SIZE];
|
||||
u64 state[SHA512_DIGEST_SIZE / sizeof(u64)];
|
||||
u64 count_hi;
|
||||
} sha512;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ static int sha512_init(struct shash_desc *desc)
|
|||
struct s390_sha_ctx *ctx = shash_desc_ctx(desc);
|
||||
|
||||
ctx->sha512.state[0] = SHA512_H0;
|
||||
ctx->sha512.state[2] = SHA512_H1;
|
||||
ctx->sha512.state[4] = SHA512_H2;
|
||||
ctx->sha512.state[6] = SHA512_H3;
|
||||
ctx->sha512.state[8] = SHA512_H4;
|
||||
ctx->sha512.state[10] = SHA512_H5;
|
||||
ctx->sha512.state[12] = SHA512_H6;
|
||||
ctx->sha512.state[14] = SHA512_H7;
|
||||
ctx->sha512.state[1] = SHA512_H1;
|
||||
ctx->sha512.state[2] = SHA512_H2;
|
||||
ctx->sha512.state[3] = SHA512_H3;
|
||||
ctx->sha512.state[4] = SHA512_H4;
|
||||
ctx->sha512.state[5] = SHA512_H5;
|
||||
ctx->sha512.state[6] = SHA512_H6;
|
||||
ctx->sha512.state[7] = SHA512_H7;
|
||||
ctx->count = 0;
|
||||
ctx->sha512.count_hi = 0;
|
||||
ctx->func = CPACF_KIMD_SHA_512;
|
||||
|
|
|
|||
Loading…
Reference in New Issue