19363efb4SThara Gopinath /* SPDX-License-Identifier: GPL-2.0-only */ 29363efb4SThara Gopinath /* 39363efb4SThara Gopinath * Copyright (c) 2021, Linaro Limited. All rights reserved. 49363efb4SThara Gopinath */ 59363efb4SThara Gopinath 69363efb4SThara Gopinath #ifndef _AEAD_H_ 79363efb4SThara Gopinath #define _AEAD_H_ 89363efb4SThara Gopinath 99363efb4SThara Gopinath #include "common.h" 109363efb4SThara Gopinath #include "core.h" 119363efb4SThara Gopinath 129363efb4SThara Gopinath #define QCE_MAX_KEY_SIZE 64 139363efb4SThara Gopinath #define QCE_CCM4309_SALT_SIZE 3 149363efb4SThara Gopinath 159363efb4SThara Gopinath struct qce_aead_ctx { 169363efb4SThara Gopinath u8 enc_key[QCE_MAX_KEY_SIZE]; 179363efb4SThara Gopinath u8 auth_key[QCE_MAX_KEY_SIZE]; 189363efb4SThara Gopinath u8 ccm4309_salt[QCE_CCM4309_SALT_SIZE]; 199363efb4SThara Gopinath unsigned int enc_keylen; 209363efb4SThara Gopinath unsigned int auth_keylen; 219363efb4SThara Gopinath unsigned int authsize; 22*b51dcf05SThara Gopinath bool need_fallback; 23*b51dcf05SThara Gopinath struct crypto_aead *fallback; 249363efb4SThara Gopinath }; 259363efb4SThara Gopinath 269363efb4SThara Gopinath struct qce_aead_reqctx { 279363efb4SThara Gopinath unsigned long flags; 289363efb4SThara Gopinath u8 *iv; 299363efb4SThara Gopinath unsigned int ivsize; 309363efb4SThara Gopinath int src_nents; 319363efb4SThara Gopinath int dst_nents; 329363efb4SThara Gopinath struct scatterlist result_sg; 339363efb4SThara Gopinath struct scatterlist adata_sg; 349363efb4SThara Gopinath struct sg_table dst_tbl; 359363efb4SThara Gopinath struct sg_table src_tbl; 369363efb4SThara Gopinath struct scatterlist *dst_sg; 379363efb4SThara Gopinath struct scatterlist *src_sg; 389363efb4SThara Gopinath unsigned int cryptlen; 399363efb4SThara Gopinath unsigned int assoclen; 409363efb4SThara Gopinath unsigned char *adata; 419363efb4SThara Gopinath u8 ccm_nonce[QCE_MAX_NONCE]; 429363efb4SThara Gopinath u8 ccmresult_buf[QCE_BAM_BURST_SIZE]; 439363efb4SThara Gopinath u8 ccm_rfc4309_iv[QCE_MAX_IV_SIZE]; 44*b51dcf05SThara Gopinath struct aead_request fallback_req; 459363efb4SThara Gopinath }; 469363efb4SThara Gopinath to_aead_tmpl(struct crypto_aead * tfm)479363efb4SThara Gopinathstatic inline struct qce_alg_template *to_aead_tmpl(struct crypto_aead *tfm) 489363efb4SThara Gopinath { 499363efb4SThara Gopinath struct aead_alg *alg = crypto_aead_alg(tfm); 509363efb4SThara Gopinath 519363efb4SThara Gopinath return container_of(alg, struct qce_alg_template, alg.aead); 529363efb4SThara Gopinath } 539363efb4SThara Gopinath 549363efb4SThara Gopinath extern const struct qce_algo_ops aead_ops; 559363efb4SThara Gopinath 569363efb4SThara Gopinath #endif /* _AEAD_H_ */ 57