Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: s390/sha512 - Initialise upper counter to zero for sha384

Initialise the high bit counter to zero in sha384_init.

Also change the state initialisation to use ctx->sha512.state
instead of ctx->state for consistency.

Fixes: 572b5c4682c7 ("crypto: s390/sha512 - Use API partial block handling")
Reported-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reported-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Herbert Xu 64745a9c 870c1f0d

+9 -8
+9 -8
arch/s390/crypto/sha512_s390.c
··· 86 86 { 87 87 struct s390_sha_ctx *ctx = shash_desc_ctx(desc); 88 88 89 - *(__u64 *)&ctx->state[0] = SHA384_H0; 90 - *(__u64 *)&ctx->state[2] = SHA384_H1; 91 - *(__u64 *)&ctx->state[4] = SHA384_H2; 92 - *(__u64 *)&ctx->state[6] = SHA384_H3; 93 - *(__u64 *)&ctx->state[8] = SHA384_H4; 94 - *(__u64 *)&ctx->state[10] = SHA384_H5; 95 - *(__u64 *)&ctx->state[12] = SHA384_H6; 96 - *(__u64 *)&ctx->state[14] = SHA384_H7; 89 + ctx->sha512.state[0] = SHA384_H0; 90 + ctx->sha512.state[1] = SHA384_H1; 91 + ctx->sha512.state[2] = SHA384_H2; 92 + ctx->sha512.state[3] = SHA384_H3; 93 + ctx->sha512.state[4] = SHA384_H4; 94 + ctx->sha512.state[5] = SHA384_H5; 95 + ctx->sha512.state[6] = SHA384_H6; 96 + ctx->sha512.state[7] = SHA384_H7; 97 97 ctx->count = 0; 98 + ctx->sha512.count_hi = 0; 98 99 ctx->func = CPACF_KIMD_SHA_512; 99 100 100 101 return 0;