18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Shared descriptors for aead, skcipher algorithms
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright 2016 NXP
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _CAAMALG_DESC_H_
98c2ecf20Sopenharmony_ci#define _CAAMALG_DESC_H_
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/* length of descriptors text */
128c2ecf20Sopenharmony_ci#define DESC_AEAD_BASE			(4 * CAAM_CMD_SZ)
138c2ecf20Sopenharmony_ci#define DESC_AEAD_ENC_LEN		(DESC_AEAD_BASE + 11 * CAAM_CMD_SZ)
148c2ecf20Sopenharmony_ci#define DESC_AEAD_DEC_LEN		(DESC_AEAD_BASE + 15 * CAAM_CMD_SZ)
158c2ecf20Sopenharmony_ci#define DESC_AEAD_GIVENC_LEN		(DESC_AEAD_ENC_LEN + 8 * CAAM_CMD_SZ)
168c2ecf20Sopenharmony_ci#define DESC_QI_AEAD_ENC_LEN		(DESC_AEAD_ENC_LEN + 3 * CAAM_CMD_SZ)
178c2ecf20Sopenharmony_ci#define DESC_QI_AEAD_DEC_LEN		(DESC_AEAD_DEC_LEN + 3 * CAAM_CMD_SZ)
188c2ecf20Sopenharmony_ci#define DESC_QI_AEAD_GIVENC_LEN		(DESC_AEAD_GIVENC_LEN + 3 * CAAM_CMD_SZ)
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* Note: Nonce is counted in cdata.keylen */
218c2ecf20Sopenharmony_ci#define DESC_AEAD_CTR_RFC3686_LEN	(4 * CAAM_CMD_SZ)
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define DESC_AEAD_NULL_BASE		(3 * CAAM_CMD_SZ)
248c2ecf20Sopenharmony_ci#define DESC_AEAD_NULL_ENC_LEN		(DESC_AEAD_NULL_BASE + 11 * CAAM_CMD_SZ)
258c2ecf20Sopenharmony_ci#define DESC_AEAD_NULL_DEC_LEN		(DESC_AEAD_NULL_BASE + 13 * CAAM_CMD_SZ)
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#define DESC_GCM_BASE			(3 * CAAM_CMD_SZ)
288c2ecf20Sopenharmony_ci#define DESC_GCM_ENC_LEN		(DESC_GCM_BASE + 16 * CAAM_CMD_SZ)
298c2ecf20Sopenharmony_ci#define DESC_GCM_DEC_LEN		(DESC_GCM_BASE + 12 * CAAM_CMD_SZ)
308c2ecf20Sopenharmony_ci#define DESC_QI_GCM_ENC_LEN		(DESC_GCM_ENC_LEN + 6 * CAAM_CMD_SZ)
318c2ecf20Sopenharmony_ci#define DESC_QI_GCM_DEC_LEN		(DESC_GCM_DEC_LEN + 3 * CAAM_CMD_SZ)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define DESC_RFC4106_BASE		(3 * CAAM_CMD_SZ)
348c2ecf20Sopenharmony_ci#define DESC_RFC4106_ENC_LEN		(DESC_RFC4106_BASE + 16 * CAAM_CMD_SZ)
358c2ecf20Sopenharmony_ci#define DESC_RFC4106_DEC_LEN		(DESC_RFC4106_BASE + 13 * CAAM_CMD_SZ)
368c2ecf20Sopenharmony_ci#define DESC_QI_RFC4106_ENC_LEN		(DESC_RFC4106_ENC_LEN + 5 * CAAM_CMD_SZ)
378c2ecf20Sopenharmony_ci#define DESC_QI_RFC4106_DEC_LEN		(DESC_RFC4106_DEC_LEN + 5 * CAAM_CMD_SZ)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define DESC_RFC4543_BASE		(3 * CAAM_CMD_SZ)
408c2ecf20Sopenharmony_ci#define DESC_RFC4543_ENC_LEN		(DESC_RFC4543_BASE + 11 * CAAM_CMD_SZ)
418c2ecf20Sopenharmony_ci#define DESC_RFC4543_DEC_LEN		(DESC_RFC4543_BASE + 12 * CAAM_CMD_SZ)
428c2ecf20Sopenharmony_ci#define DESC_QI_RFC4543_ENC_LEN		(DESC_RFC4543_ENC_LEN + 4 * CAAM_CMD_SZ)
438c2ecf20Sopenharmony_ci#define DESC_QI_RFC4543_DEC_LEN		(DESC_RFC4543_DEC_LEN + 4 * CAAM_CMD_SZ)
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define DESC_SKCIPHER_BASE		(3 * CAAM_CMD_SZ)
468c2ecf20Sopenharmony_ci#define DESC_SKCIPHER_ENC_LEN		(DESC_SKCIPHER_BASE + \
478c2ecf20Sopenharmony_ci					 21 * CAAM_CMD_SZ)
488c2ecf20Sopenharmony_ci#define DESC_SKCIPHER_DEC_LEN		(DESC_SKCIPHER_BASE + \
498c2ecf20Sopenharmony_ci					 16 * CAAM_CMD_SZ)
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_civoid cnstr_shdsc_aead_null_encap(u32 * const desc, struct alginfo *adata,
528c2ecf20Sopenharmony_ci				 unsigned int icvsize, int era);
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_civoid cnstr_shdsc_aead_null_decap(u32 * const desc, struct alginfo *adata,
558c2ecf20Sopenharmony_ci				 unsigned int icvsize, int era);
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_civoid cnstr_shdsc_aead_encap(u32 * const desc, struct alginfo *cdata,
588c2ecf20Sopenharmony_ci			    struct alginfo *adata, unsigned int ivsize,
598c2ecf20Sopenharmony_ci			    unsigned int icvsize, const bool is_rfc3686,
608c2ecf20Sopenharmony_ci			    u32 *nonce, const u32 ctx1_iv_off,
618c2ecf20Sopenharmony_ci			    const bool is_qi, int era);
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_civoid cnstr_shdsc_aead_decap(u32 * const desc, struct alginfo *cdata,
648c2ecf20Sopenharmony_ci			    struct alginfo *adata, unsigned int ivsize,
658c2ecf20Sopenharmony_ci			    unsigned int icvsize, const bool geniv,
668c2ecf20Sopenharmony_ci			    const bool is_rfc3686, u32 *nonce,
678c2ecf20Sopenharmony_ci			    const u32 ctx1_iv_off, const bool is_qi, int era);
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_civoid cnstr_shdsc_aead_givencap(u32 * const desc, struct alginfo *cdata,
708c2ecf20Sopenharmony_ci			       struct alginfo *adata, unsigned int ivsize,
718c2ecf20Sopenharmony_ci			       unsigned int icvsize, const bool is_rfc3686,
728c2ecf20Sopenharmony_ci			       u32 *nonce, const u32 ctx1_iv_off,
738c2ecf20Sopenharmony_ci			       const bool is_qi, int era);
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_civoid cnstr_shdsc_gcm_encap(u32 * const desc, struct alginfo *cdata,
768c2ecf20Sopenharmony_ci			   unsigned int ivsize, unsigned int icvsize,
778c2ecf20Sopenharmony_ci			   const bool is_qi);
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_civoid cnstr_shdsc_gcm_decap(u32 * const desc, struct alginfo *cdata,
808c2ecf20Sopenharmony_ci			   unsigned int ivsize, unsigned int icvsize,
818c2ecf20Sopenharmony_ci			   const bool is_qi);
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_civoid cnstr_shdsc_rfc4106_encap(u32 * const desc, struct alginfo *cdata,
848c2ecf20Sopenharmony_ci			       unsigned int ivsize, unsigned int icvsize,
858c2ecf20Sopenharmony_ci			       const bool is_qi);
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_civoid cnstr_shdsc_rfc4106_decap(u32 * const desc, struct alginfo *cdata,
888c2ecf20Sopenharmony_ci			       unsigned int ivsize, unsigned int icvsize,
898c2ecf20Sopenharmony_ci			       const bool is_qi);
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_civoid cnstr_shdsc_rfc4543_encap(u32 * const desc, struct alginfo *cdata,
928c2ecf20Sopenharmony_ci			       unsigned int ivsize, unsigned int icvsize,
938c2ecf20Sopenharmony_ci			       const bool is_qi);
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_civoid cnstr_shdsc_rfc4543_decap(u32 * const desc, struct alginfo *cdata,
968c2ecf20Sopenharmony_ci			       unsigned int ivsize, unsigned int icvsize,
978c2ecf20Sopenharmony_ci			       const bool is_qi);
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_civoid cnstr_shdsc_chachapoly(u32 * const desc, struct alginfo *cdata,
1008c2ecf20Sopenharmony_ci			    struct alginfo *adata, unsigned int ivsize,
1018c2ecf20Sopenharmony_ci			    unsigned int icvsize, const bool encap,
1028c2ecf20Sopenharmony_ci			    const bool is_qi);
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_civoid cnstr_shdsc_skcipher_encap(u32 * const desc, struct alginfo *cdata,
1058c2ecf20Sopenharmony_ci				unsigned int ivsize, const bool is_rfc3686,
1068c2ecf20Sopenharmony_ci				const u32 ctx1_iv_off);
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_civoid cnstr_shdsc_skcipher_decap(u32 * const desc, struct alginfo *cdata,
1098c2ecf20Sopenharmony_ci				unsigned int ivsize, const bool is_rfc3686,
1108c2ecf20Sopenharmony_ci				const u32 ctx1_iv_off);
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_civoid cnstr_shdsc_xts_skcipher_encap(u32 * const desc, struct alginfo *cdata);
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_civoid cnstr_shdsc_xts_skcipher_decap(u32 * const desc, struct alginfo *cdata);
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci#endif /* _CAAMALG_DESC_H_ */
117