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