Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/s390/crypto/sha.h
29521 views
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 ([email protected])
9
*/
10
#ifndef _CRYPTO_ARCH_S390_SHA_H
11
#define _CRYPTO_ARCH_S390_SHA_H
12
13
#include <crypto/hash.h>
14
#include <crypto/sha2.h>
15
#include <crypto/sha3.h>
16
#include <linux/build_bug.h>
17
#include <linux/types.h>
18
19
/* must be big enough for the largest SHA variant */
20
#define CPACF_MAX_PARMBLOCK_SIZE SHA3_STATE_SIZE
21
#define SHA_MAX_BLOCK_SIZE SHA3_224_BLOCK_SIZE
22
23
struct s390_sha_ctx {
24
u64 count; /* message length in bytes */
25
union {
26
u32 state[CPACF_MAX_PARMBLOCK_SIZE / sizeof(u32)];
27
struct {
28
u64 state[SHA512_DIGEST_SIZE / sizeof(u64)];
29
u64 count_hi;
30
} sha512;
31
struct {
32
__le64 state[SHA3_STATE_SIZE / sizeof(u64)];
33
} sha3;
34
};
35
int func; /* KIMD function to use */
36
bool first_message_part;
37
};
38
39
struct shash_desc;
40
41
int s390_sha_update_blocks(struct shash_desc *desc, const u8 *data,
42
unsigned int len);
43
int s390_sha_finup(struct shash_desc *desc, const u8 *src, unsigned int len,
44
u8 *out);
45
46
static inline void __check_s390_sha_ctx_size(void)
47
{
48
BUILD_BUG_ON(S390_SHA_CTX_SIZE != sizeof(struct s390_sha_ctx));
49
}
50
51
#endif
52
53