xref: /linux/drivers/crypto/qce/aead.h (revision 9363efb4181c5e0fbf86bdfa759262aa29f0eb50)
1*9363efb4SThara Gopinath /* SPDX-License-Identifier: GPL-2.0-only */
2*9363efb4SThara Gopinath /*
3*9363efb4SThara Gopinath  * Copyright (c) 2021, Linaro Limited. All rights reserved.
4*9363efb4SThara Gopinath  */
5*9363efb4SThara Gopinath 
6*9363efb4SThara Gopinath #ifndef _AEAD_H_
7*9363efb4SThara Gopinath #define _AEAD_H_
8*9363efb4SThara Gopinath 
9*9363efb4SThara Gopinath #include "common.h"
10*9363efb4SThara Gopinath #include "core.h"
11*9363efb4SThara Gopinath 
12*9363efb4SThara Gopinath #define QCE_MAX_KEY_SIZE		64
13*9363efb4SThara Gopinath #define QCE_CCM4309_SALT_SIZE		3
14*9363efb4SThara Gopinath 
15*9363efb4SThara Gopinath struct qce_aead_ctx {
16*9363efb4SThara Gopinath 	u8 enc_key[QCE_MAX_KEY_SIZE];
17*9363efb4SThara Gopinath 	u8 auth_key[QCE_MAX_KEY_SIZE];
18*9363efb4SThara Gopinath 	u8 ccm4309_salt[QCE_CCM4309_SALT_SIZE];
19*9363efb4SThara Gopinath 	unsigned int enc_keylen;
20*9363efb4SThara Gopinath 	unsigned int auth_keylen;
21*9363efb4SThara Gopinath 	unsigned int authsize;
22*9363efb4SThara Gopinath };
23*9363efb4SThara Gopinath 
24*9363efb4SThara Gopinath struct qce_aead_reqctx {
25*9363efb4SThara Gopinath 	unsigned long flags;
26*9363efb4SThara Gopinath 	u8 *iv;
27*9363efb4SThara Gopinath 	unsigned int ivsize;
28*9363efb4SThara Gopinath 	int src_nents;
29*9363efb4SThara Gopinath 	int dst_nents;
30*9363efb4SThara Gopinath 	struct scatterlist result_sg;
31*9363efb4SThara Gopinath 	struct scatterlist adata_sg;
32*9363efb4SThara Gopinath 	struct sg_table dst_tbl;
33*9363efb4SThara Gopinath 	struct sg_table src_tbl;
34*9363efb4SThara Gopinath 	struct scatterlist *dst_sg;
35*9363efb4SThara Gopinath 	struct scatterlist *src_sg;
36*9363efb4SThara Gopinath 	unsigned int cryptlen;
37*9363efb4SThara Gopinath 	unsigned int assoclen;
38*9363efb4SThara Gopinath 	unsigned char *adata;
39*9363efb4SThara Gopinath 	u8 ccm_nonce[QCE_MAX_NONCE];
40*9363efb4SThara Gopinath 	u8 ccmresult_buf[QCE_BAM_BURST_SIZE];
41*9363efb4SThara Gopinath 	u8 ccm_rfc4309_iv[QCE_MAX_IV_SIZE];
42*9363efb4SThara Gopinath };
43*9363efb4SThara Gopinath 
44*9363efb4SThara Gopinath static inline struct qce_alg_template *to_aead_tmpl(struct crypto_aead *tfm)
45*9363efb4SThara Gopinath {
46*9363efb4SThara Gopinath 	struct aead_alg *alg = crypto_aead_alg(tfm);
47*9363efb4SThara Gopinath 
48*9363efb4SThara Gopinath 	return container_of(alg, struct qce_alg_template, alg.aead);
49*9363efb4SThara Gopinath }
50*9363efb4SThara Gopinath 
51*9363efb4SThara Gopinath extern const struct qce_algo_ops aead_ops;
52*9363efb4SThara Gopinath 
53*9363efb4SThara Gopinath #endif /* _AEAD_H_ */
54