Linux-libre 4.13.7-gnu
[librecmc/linux-libre.git] / drivers / staging / ccree / ssi_cipher.h
1 /*
2  * Copyright (C) 2012-2017 ARM Limited or its affiliates.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see <http://www.gnu.org/licenses/>.
15  */
16
17 /* \file ssi_cipher.h
18  * ARM CryptoCell Cipher Crypto API
19  */
20
21 #ifndef __SSI_CIPHER_H__
22 #define __SSI_CIPHER_H__
23
24 #include <linux/kernel.h>
25 #include <crypto/algapi.h>
26 #include "ssi_driver.h"
27 #include "ssi_buffer_mgr.h"
28
29 /* Crypto cipher flags */
30 #define CC_CRYPTO_CIPHER_KEY_KFDE0    (1 << 0)
31 #define CC_CRYPTO_CIPHER_KEY_KFDE1    (1 << 1)
32 #define CC_CRYPTO_CIPHER_KEY_KFDE2    (1 << 2)
33 #define CC_CRYPTO_CIPHER_KEY_KFDE3    (1 << 3)
34 #define CC_CRYPTO_CIPHER_DU_SIZE_512B (1 << 4)
35
36 #define CC_CRYPTO_CIPHER_KEY_KFDE_MASK (CC_CRYPTO_CIPHER_KEY_KFDE0 | CC_CRYPTO_CIPHER_KEY_KFDE1 | CC_CRYPTO_CIPHER_KEY_KFDE2 | CC_CRYPTO_CIPHER_KEY_KFDE3)
37
38 struct blkcipher_req_ctx {
39         struct async_gen_req_ctx gen_ctx;
40         enum ssi_req_dma_buf_type dma_buf_type;
41         u32 in_nents;
42         u32 in_mlli_nents;
43         u32 out_nents;
44         u32 out_mlli_nents;
45         u8 *backup_info; /*store iv for generated IV flow*/
46         bool is_giv;
47         struct mlli_params mlli_params;
48 };
49
50 int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata);
51
52 int ssi_ablkcipher_free(struct ssi_drvdata *drvdata);
53
54 #ifndef CRYPTO_ALG_BULK_MASK
55
56 #define CRYPTO_ALG_BULK_DU_512  0x00002000
57 #define CRYPTO_ALG_BULK_DU_4096 0x00004000
58 #define CRYPTO_ALG_BULK_MASK    (CRYPTO_ALG_BULK_DU_512 |\
59                                 CRYPTO_ALG_BULK_DU_4096)
60 #endif /* CRYPTO_ALG_BULK_MASK */
61
62 #ifdef CRYPTO_TFM_REQ_HW_KEY
63
64 static inline bool ssi_is_hw_key(struct crypto_tfm *tfm)
65 {
66         return (crypto_tfm_get_flags(tfm) & CRYPTO_TFM_REQ_HW_KEY);
67 }
68
69 #else
70
71 struct arm_hw_key_info {
72         int hw_key1;
73         int hw_key2;
74 };
75
76 static inline bool ssi_is_hw_key(struct crypto_tfm *tfm)
77 {
78         return 0;
79 }
80
81 #endif /* CRYPTO_TFM_REQ_HW_KEY */
82
83 #endif /*__SSI_CIPHER_H__*/