xref: /OK3568_Linux_fs/u-boot/include/rockchip/crypto_hash_cache.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier:     GPL-2.0+ */
2 /*
3  * (C) Copyright 2020 Rockchip Electronics Co., Ltd
4  */
5 
6 #ifndef _CRYPTO_HASH_CACHE_H_
7 #define _CRYPTO_HASH_CACHE_H_
8 
9 #define	HASH_CACHE_SIZE		8192
10 #define	CIPHER_CACHE_SIZE	8192
11 
12 typedef int (*crypto_hash_calc)(void *hw_data, const u8 *data, u32 data_len,
13 				u8 *started_flag, u8 is_last);
14 
15 struct crypto_hash_cache {
16 	crypto_hash_calc	direct_calc;	/* hardware hash callback*/
17 	void			*user_data;
18 	void			*cache;		/* virt addr for hash src data*/
19 	u32			cache_size;	/* data in cached size */
20 	u32			data_align;
21 	u32			len_align;
22 	u32			left_len;	/* left data to calc */
23 	u8			is_started;	/* start or restart */
24 	u8			use_cache;	/* is use cache or not*/
25 	u8			reserved[2];
26 };
27 
28 struct crypto_hash_cache *crypto_hash_cache_alloc(crypto_hash_calc direct_calc,
29 						  void *user_data, u32 total,
30 						  u32 data_align,
31 						  u32 len_align);
32 void crypto_hash_cache_free(struct crypto_hash_cache *hash_cache);
33 int crypto_hash_update_with_cache(struct crypto_hash_cache *hash_cache,
34 				  const u8 *data, u32 data_len);
35 void crypto_flush_cacheline(ulong addr, ulong size);
36 
37 #endif
38