mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-27 06:50:37 +00:00

The sha3 partial hash on s390 is in little-endian just like the
final hash. However the generic implementation produces native
or big-endian partial hashes.
Make s390 sha3 conform to that by doing the byte-swap on export
and import.
Reported-by: Ingo Franzki <ifranzki@linux.ibm.com>
Fixes: 6f90ba7065
("crypto: s390/sha3 - Use API partial block handling")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
/*
|
|
* Cryptographic API.
|
|
*
|
|
* s390 generic implementation of the SHA Secure Hash Algorithms.
|
|
*
|
|
* Copyright IBM Corp. 2007
|
|
* Author(s): Jan Glauber (jang@de.ibm.com)
|
|
*/
|
|
#ifndef _CRYPTO_ARCH_S390_SHA_H
|
|
#define _CRYPTO_ARCH_S390_SHA_H
|
|
|
|
#include <crypto/sha2.h>
|
|
#include <crypto/sha3.h>
|
|
#include <linux/types.h>
|
|
|
|
/* must be big enough for the largest SHA variant */
|
|
#define CPACF_MAX_PARMBLOCK_SIZE SHA3_STATE_SIZE
|
|
#define SHA_MAX_BLOCK_SIZE SHA3_224_BLOCK_SIZE
|
|
#define S390_SHA_CTX_SIZE sizeof(struct s390_sha_ctx)
|
|
|
|
struct s390_sha_ctx {
|
|
u64 count; /* message length in bytes */
|
|
union {
|
|
u32 state[CPACF_MAX_PARMBLOCK_SIZE / sizeof(u32)];
|
|
struct {
|
|
u64 state[SHA512_DIGEST_SIZE / sizeof(u64)];
|
|
u64 count_hi;
|
|
} sha512;
|
|
struct {
|
|
__le64 state[SHA3_STATE_SIZE / sizeof(u64)];
|
|
} sha3;
|
|
};
|
|
int func; /* KIMD function to use */
|
|
bool first_message_part;
|
|
};
|
|
|
|
struct shash_desc;
|
|
|
|
int s390_sha_update_blocks(struct shash_desc *desc, const u8 *data,
|
|
unsigned int len);
|
|
int s390_sha_finup(struct shash_desc *desc, const u8 *src, unsigned int len,
|
|
u8 *out);
|
|
|
|
#endif
|