^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #ifndef _CIPHER_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) #define _CIPHER_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include "common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "core.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define QCE_MAX_KEY_SIZE	64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct qce_cipher_ctx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	u8 enc_key[QCE_MAX_KEY_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	unsigned int enc_keylen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	struct crypto_skcipher *fallback;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  * struct qce_cipher_reqctx - holds private cipher objects per request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  * @flags: operation flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)  * @iv: pointer to the IV
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)  * @ivsize: IV size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)  * @src_nents: source entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)  * @dst_nents: destination entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)  * @result_sg: scatterlist used for result buffer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)  * @dst_tbl: destination sg table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)  * @dst_sg: destination sg pointer table beginning
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)  * @src_tbl: source sg table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)  * @src_sg: source sg pointer table beginning;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)  * @cryptlen: crypto length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct qce_cipher_reqctx {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	u8 *iv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	unsigned int ivsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	int src_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	int dst_nents;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	struct scatterlist result_sg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	struct sg_table dst_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	struct scatterlist *dst_sg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	struct sg_table src_tbl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	struct scatterlist *src_sg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	unsigned int cryptlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	struct skcipher_request fallback_req;	// keep at the end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static inline struct qce_alg_template *to_cipher_tmpl(struct crypto_skcipher *tfm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	struct skcipher_alg *alg = crypto_skcipher_alg(tfm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	return container_of(alg, struct qce_alg_template, alg.skcipher);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) extern const struct qce_algo_ops skcipher_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #endif /* _CIPHER_H_ */