Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/drivers/crypto/inside-secure/eip93/eip93-hash.h
26285 views
1
/* SPDX-License-Identifier: GPL-2.0
2
*
3
* Copyright (C) 2019 - 2021
4
*
5
* Richard van Schagen <[email protected]>
6
* Christian Marangi <[email protected]
7
*/
8
#ifndef _EIP93_HASH_H_
9
#define _EIP93_HASH_H_
10
11
#include <crypto/sha2.h>
12
13
#include "eip93-main.h"
14
#include "eip93-regs.h"
15
16
struct eip93_hash_ctx {
17
struct eip93_device *eip93;
18
u32 flags;
19
20
u8 ipad[SHA256_BLOCK_SIZE] __aligned(sizeof(u32));
21
u8 opad[SHA256_DIGEST_SIZE] __aligned(sizeof(u32));
22
};
23
24
struct eip93_hash_reqctx {
25
/* Placement is important for DMA align */
26
struct {
27
struct sa_record sa_record;
28
struct sa_record sa_record_hmac;
29
struct sa_state sa_state;
30
} __aligned(CRYPTO_DMA_ALIGN);
31
32
dma_addr_t sa_record_base;
33
dma_addr_t sa_record_hmac_base;
34
dma_addr_t sa_state_base;
35
36
/* Don't enable HASH_FINALIZE when last block is sent */
37
bool partial_hash;
38
39
/* Set to signal interrupt is for final packet */
40
bool finalize;
41
42
/*
43
* EIP93 requires data to be accumulated in block of 64 bytes
44
* for intermediate hash calculation.
45
*/
46
u64 len;
47
u32 data_used;
48
49
u8 data[SHA256_BLOCK_SIZE] __aligned(sizeof(u32));
50
dma_addr_t data_dma;
51
52
struct list_head blocks;
53
};
54
55
struct mkt_hash_block {
56
struct list_head list;
57
u8 data[SHA256_BLOCK_SIZE] __aligned(sizeof(u32));
58
dma_addr_t data_dma;
59
};
60
61
struct eip93_hash_export_state {
62
u64 len;
63
u32 data_used;
64
65
u32 state_len[2];
66
u8 state_hash[SHA256_DIGEST_SIZE] __aligned(sizeof(u32));
67
68
u8 data[SHA256_BLOCK_SIZE] __aligned(sizeof(u32));
69
};
70
71
void eip93_hash_handle_result(struct crypto_async_request *async, int err);
72
73
extern struct eip93_alg_template eip93_alg_md5;
74
extern struct eip93_alg_template eip93_alg_sha1;
75
extern struct eip93_alg_template eip93_alg_sha224;
76
extern struct eip93_alg_template eip93_alg_sha256;
77
extern struct eip93_alg_template eip93_alg_hmac_md5;
78
extern struct eip93_alg_template eip93_alg_hmac_sha1;
79
extern struct eip93_alg_template eip93_alg_hmac_sha224;
80
extern struct eip93_alg_template eip93_alg_hmac_sha256;
81
82
#endif /* _EIP93_HASH_H_ */
83
84