xref: /linux/arch/s390/crypto/sha.h (revision 746680ec6696585e30db3e18c93a63df9cbec39c)
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 		struct {
31 			__le64 state[SHA3_STATE_SIZE / sizeof(u64)];
32 		} sha3;
33 	};
34 	int func;		/* KIMD function to use */
35 	bool first_message_part;
36 };
37 
38 struct shash_desc;
39 
40 int s390_sha_update_blocks(struct shash_desc *desc, const u8 *data,
41 			   unsigned int len);
42 int s390_sha_finup(struct shash_desc *desc, const u8 *src, unsigned int len,
43 		   u8 *out);
44 
45 #endif
46