xref: /linux/drivers/crypto/ccree/cc_cipher.h (revision 2359ccddc1c3f4752f43cc19b3db189710b15791)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2012-2018 ARM Limited or its affiliates. */
3 
4 /* \file cc_cipher.h
5  * ARM CryptoCell Cipher Crypto API
6  */
7 
8 #ifndef __CC_CIPHER_H__
9 #define __CC_CIPHER_H__
10 
11 #include <linux/kernel.h>
12 #include <crypto/algapi.h>
13 #include "cc_driver.h"
14 #include "cc_buffer_mgr.h"
15 
16 /* Crypto cipher flags */
17 #define CC_CRYPTO_CIPHER_KEY_KFDE0	BIT(0)
18 #define CC_CRYPTO_CIPHER_KEY_KFDE1	BIT(1)
19 #define CC_CRYPTO_CIPHER_KEY_KFDE2	BIT(2)
20 #define CC_CRYPTO_CIPHER_KEY_KFDE3	BIT(3)
21 #define CC_CRYPTO_CIPHER_DU_SIZE_512B	BIT(4)
22 
23 #define CC_CRYPTO_CIPHER_KEY_KFDE_MASK (CC_CRYPTO_CIPHER_KEY_KFDE0 | \
24 					CC_CRYPTO_CIPHER_KEY_KFDE1 | \
25 					CC_CRYPTO_CIPHER_KEY_KFDE2 | \
26 					CC_CRYPTO_CIPHER_KEY_KFDE3)
27 
28 struct cipher_req_ctx {
29 	struct async_gen_req_ctx gen_ctx;
30 	enum cc_req_dma_buf_type dma_buf_type;
31 	u32 in_nents;
32 	u32 in_mlli_nents;
33 	u32 out_nents;
34 	u32 out_mlli_nents;
35 	u8 *backup_info; /*store iv for generated IV flow*/
36 	u8 *iv;
37 	bool is_giv;
38 	struct mlli_params mlli_params;
39 };
40 
41 int cc_cipher_alloc(struct cc_drvdata *drvdata);
42 
43 int cc_cipher_free(struct cc_drvdata *drvdata);
44 
45 struct arm_hw_key_info {
46 	int hw_key1;
47 	int hw_key2;
48 };
49 
50 /*
51  * This is a stub function that will replaced when we
52  * implement secure keys
53  */
54 static inline bool cc_is_hw_key(struct crypto_tfm *tfm)
55 {
56 	return false;
57 }
58 
59 #endif /*__CC_CIPHER_H__*/
60