Skip to content

Commit 2f072d7

Browse files
zaiboxuherbertx
authored andcommitted
crypto: hisilicon - Add aead support on SEC2
authenc(hmac(sha1),cbc(aes)), authenc(hmac(sha256),cbc(aes)), and authenc(hmac(sha512),cbc(aes)) support are added for SEC v2. Signed-off-by: Zaibo Xu <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 473a0f9 commit 2f072d7

File tree

4 files changed

+620
-24
lines changed

4 files changed

+620
-24
lines changed

drivers/crypto/hisilicon/Kconfig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ config CRYPTO_DEV_HISI_SEC2
2020
select CRYPTO_ALGAPI
2121
select CRYPTO_LIB_DES
2222
select CRYPTO_DEV_HISI_QM
23+
select CRYPTO_AEAD
24+
select CRYPTO_AUTHENC
25+
select CRYPTO_HMAC
26+
select CRYPTO_SHA1
27+
select CRYPTO_SHA256
28+
select CRYPTO_SHA512
2329
depends on PCI && PCI_MSI
2430
depends on ARM64 || (COMPILE_TEST && 64BIT)
2531
help
2632
Support for HiSilicon SEC Engine of version 2 in crypto subsystem.
2733
It provides AES, SM4, and 3DES algorithms with ECB
28-
CBC, and XTS cipher mode.
34+
CBC, and XTS cipher mode, and AEAD algorithms.
2935

3036
To compile this as a module, choose M here: the module
3137
will be called hisi_sec2.

drivers/crypto/hisilicon/sec2/sec.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
struct sec_alg_res {
1414
u8 *c_ivin;
1515
dma_addr_t c_ivin_dma;
16+
u8 *out_mac;
17+
dma_addr_t out_mac_dma;
1618
};
1719

1820
/* Cipher request of SEC private */
@@ -26,14 +28,21 @@ struct sec_cipher_req {
2628
bool encrypt;
2729
};
2830

31+
struct sec_aead_req {
32+
u8 *out_mac;
33+
dma_addr_t out_mac_dma;
34+
struct aead_request *aead_req;
35+
};
36+
2937
/* SEC request of Crypto */
3038
struct sec_req {
3139
struct sec_sqe sec_sqe;
3240
struct sec_ctx *ctx;
3341
struct sec_qp_ctx *qp_ctx;
3442

35-
/* Cipher supported only at present */
3643
struct sec_cipher_req c_req;
44+
struct sec_aead_req aead_req;
45+
3746
int err_type;
3847
int req_id;
3948

@@ -60,6 +69,16 @@ struct sec_req_op {
6069
int (*process)(struct sec_ctx *ctx, struct sec_req *req);
6170
};
6271

72+
/* SEC auth context */
73+
struct sec_auth_ctx {
74+
dma_addr_t a_key_dma;
75+
u8 *a_key;
76+
u8 a_key_len;
77+
u8 mac_len;
78+
u8 a_alg;
79+
struct crypto_shash *hash_tfm;
80+
};
81+
6382
/* SEC cipher context which cipher's relatives */
6483
struct sec_cipher_ctx {
6584
u8 *c_key;
@@ -85,6 +104,11 @@ struct sec_qp_ctx {
85104
atomic_t pending_reqs;
86105
};
87106

107+
enum sec_alg_type {
108+
SEC_SKCIPHER,
109+
SEC_AEAD
110+
};
111+
88112
/* SEC Crypto TFM context which defines queue and cipher .etc relatives */
89113
struct sec_ctx {
90114
struct sec_qp_ctx *qp_ctx;
@@ -102,7 +126,10 @@ struct sec_ctx {
102126

103127
/* Currrent cyclic index to select a queue for decipher */
104128
atomic_t dec_qcyclic;
129+
130+
enum sec_alg_type alg_type;
105131
struct sec_cipher_ctx c_ctx;
132+
struct sec_auth_ctx a_ctx;
106133
};
107134

108135
enum sec_endian {

0 commit comments

Comments
 (0)