Commit 5b39aa36 authored by Herbert Xu's avatar Herbert Xu
Browse files

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: default avatarHarald Freudenberger <freude@linux.ibm.com>
Fixes: 572b5c46 ("crypto: s390/sha512 - Use API partial block handling")
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 2dfc7cd7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
	};
+7 −7
Original line number Diff line number Diff line
@@ -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;