xref: /linux/arch/s390/crypto/sha.h (revision fb7399cf2d0b33825b8039f95c45395c7deba25c)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Cryptographic API.
4  *
5  * s390 generic implementation of the SHA Secure Hash Algorithms.
6  *
7  * Copyright IBM Corp. 2007
8  * Author(s): Jan Glauber (jang@de.ibm.com)
9  */
10 #ifndef _CRYPTO_ARCH_S390_SHA_H
11 #define _CRYPTO_ARCH_S390_SHA_H
12 
13 #include <crypto/sha2.h>
14 #include <crypto/sha3.h>
15 #include <linux/types.h>
16 
17 /* must be big enough for the largest SHA variant */
18 #define CPACF_MAX_PARMBLOCK_SIZE	SHA3_STATE_SIZE
19 #define SHA_MAX_BLOCK_SIZE		SHA3_224_BLOCK_SIZE
20 #define S390_SHA_CTX_SIZE		sizeof(struct s390_sha_ctx)
21 
22 struct s390_sha_ctx {
23 	u64 count;		/* message length in bytes */
24 	union {
25 		u32 state[CPACF_MAX_PARMBLOCK_SIZE / sizeof(u32)];
26 		struct {
27 			u64 state[SHA512_DIGEST_SIZE / sizeof(u64)];
28 			u64 count_hi;
29 		} sha512;
30 	};
31 	int func;		/* KIMD function to use */
32 	bool first_message_part;
33 };
34 
35 struct shash_desc;
36 
37 int s390_sha_update_blocks(struct shash_desc *desc, const u8 *data,
38 			   unsigned int len);
39 int s390_sha_finup(struct shash_desc *desc, const u8 *src, unsigned int len,
40 		   u8 *out);
41 
42 #endif
43