xref: /linux-6.15/include/crypto/engine.h (revision c1091e2b)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Crypto engine API
4  *
5  * Copyright (c) 2016 Baolin Wang <[email protected]>
6  */
7 #ifndef _CRYPTO_ENGINE_H
8 #define _CRYPTO_ENGINE_H
9 
10 #include <linux/types.h>
11 
12 struct aead_request;
13 struct ahash_request;
14 struct akcipher_request;
15 struct crypto_engine;
16 struct device;
17 struct kpp_request;
18 struct skcipher_request;
19 
20 /*
21  * struct crypto_engine_op - crypto hardware engine operations
22  * @do_one_request: do encryption for current request
23  */
24 struct crypto_engine_op {
25 	int (*do_one_request)(struct crypto_engine *engine,
26 			      void *areq);
27 };
28 
29 struct crypto_engine_ctx {
30 	struct crypto_engine_op op;
31 };
32 
33 int crypto_transfer_aead_request_to_engine(struct crypto_engine *engine,
34 					   struct aead_request *req);
35 int crypto_transfer_akcipher_request_to_engine(struct crypto_engine *engine,
36 					       struct akcipher_request *req);
37 int crypto_transfer_hash_request_to_engine(struct crypto_engine *engine,
38 					       struct ahash_request *req);
39 int crypto_transfer_kpp_request_to_engine(struct crypto_engine *engine,
40 					  struct kpp_request *req);
41 int crypto_transfer_skcipher_request_to_engine(struct crypto_engine *engine,
42 					       struct skcipher_request *req);
43 void crypto_finalize_aead_request(struct crypto_engine *engine,
44 				  struct aead_request *req, int err);
45 void crypto_finalize_akcipher_request(struct crypto_engine *engine,
46 				      struct akcipher_request *req, int err);
47 void crypto_finalize_hash_request(struct crypto_engine *engine,
48 				  struct ahash_request *req, int err);
49 void crypto_finalize_kpp_request(struct crypto_engine *engine,
50 				 struct kpp_request *req, int err);
51 void crypto_finalize_skcipher_request(struct crypto_engine *engine,
52 				      struct skcipher_request *req, int err);
53 int crypto_engine_start(struct crypto_engine *engine);
54 int crypto_engine_stop(struct crypto_engine *engine);
55 struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt);
56 struct crypto_engine *crypto_engine_alloc_init_and_set(struct device *dev,
57 						       bool retry_support,
58 						       int (*cbk_do_batch)(struct crypto_engine *engine),
59 						       bool rt, int qlen);
60 int crypto_engine_exit(struct crypto_engine *engine);
61 
62 #endif /* _CRYPTO_ENGINE_H */
63