Commit | Line | Data |
---|---|---|
2874c5fd | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
2589ad84 CL |
2 | /* |
3 | * Crypto engine API | |
4 | * | |
5 | * Copyright (c) 2016 Baolin Wang <baolin.wang@linaro.org> | |
2589ad84 CL |
6 | */ |
7 | #ifndef _CRYPTO_ENGINE_H | |
8 | #define _CRYPTO_ENGINE_H | |
9 | ||
e5e7eb02 HX |
10 | #include <crypto/aead.h> |
11 | #include <crypto/akcipher.h> | |
12 | #include <crypto/hash.h> | |
13 | #include <crypto/kpp.h> | |
14 | #include <crypto/skcipher.h> | |
244d22ff AS |
15 | #include <linux/types.h> |
16 | ||
c1091e2b | 17 | struct crypto_engine; |
244d22ff AS |
18 | struct device; |
19 | ||
218d1cc1 CL |
20 | /* |
21 | * struct crypto_engine_op - crypto hardware engine operations | |
218d1cc1 CL |
22 | * @do_one_request: do encryption for current request |
23 | */ | |
24 | struct crypto_engine_op { | |
218d1cc1 CL |
25 | int (*do_one_request)(struct crypto_engine *engine, |
26 | void *areq); | |
27 | }; | |
28 | ||
e5e7eb02 HX |
29 | struct aead_engine_alg { |
30 | struct aead_alg base; | |
31 | struct crypto_engine_op op; | |
32 | }; | |
33 | ||
34 | struct ahash_engine_alg { | |
35 | struct ahash_alg base; | |
36 | struct crypto_engine_op op; | |
37 | }; | |
38 | ||
39 | struct akcipher_engine_alg { | |
40 | struct akcipher_alg base; | |
41 | struct crypto_engine_op op; | |
42 | }; | |
43 | ||
44 | struct kpp_engine_alg { | |
45 | struct kpp_alg base; | |
46 | struct crypto_engine_op op; | |
47 | }; | |
48 | ||
49 | struct skcipher_engine_alg { | |
50 | struct skcipher_alg base; | |
51 | struct crypto_engine_op op; | |
52 | }; | |
53 | ||
218d1cc1 CL |
54 | int crypto_transfer_aead_request_to_engine(struct crypto_engine *engine, |
55 | struct aead_request *req); | |
56 | int crypto_transfer_akcipher_request_to_engine(struct crypto_engine *engine, | |
57 | struct akcipher_request *req); | |
4cba7cf0 | 58 | int crypto_transfer_hash_request_to_engine(struct crypto_engine *engine, |
218d1cc1 | 59 | struct ahash_request *req); |
1730c5aa PK |
60 | int crypto_transfer_kpp_request_to_engine(struct crypto_engine *engine, |
61 | struct kpp_request *req); | |
218d1cc1 CL |
62 | int crypto_transfer_skcipher_request_to_engine(struct crypto_engine *engine, |
63 | struct skcipher_request *req); | |
218d1cc1 CL |
64 | void crypto_finalize_aead_request(struct crypto_engine *engine, |
65 | struct aead_request *req, int err); | |
66 | void crypto_finalize_akcipher_request(struct crypto_engine *engine, | |
67 | struct akcipher_request *req, int err); | |
4cba7cf0 CL |
68 | void crypto_finalize_hash_request(struct crypto_engine *engine, |
69 | struct ahash_request *req, int err); | |
1730c5aa PK |
70 | void crypto_finalize_kpp_request(struct crypto_engine *engine, |
71 | struct kpp_request *req, int err); | |
218d1cc1 CL |
72 | void crypto_finalize_skcipher_request(struct crypto_engine *engine, |
73 | struct skcipher_request *req, int err); | |
2589ad84 CL |
74 | int crypto_engine_start(struct crypto_engine *engine); |
75 | int crypto_engine_stop(struct crypto_engine *engine); | |
76 | struct crypto_engine *crypto_engine_alloc_init(struct device *dev, bool rt); | |
6a89f492 IP |
77 | struct crypto_engine *crypto_engine_alloc_init_and_set(struct device *dev, |
78 | bool retry_support, | |
8d908226 | 79 | int (*cbk_do_batch)(struct crypto_engine *engine), |
6a89f492 | 80 | bool rt, int qlen); |
5ec12f1c | 81 | void crypto_engine_exit(struct crypto_engine *engine); |
2589ad84 | 82 | |
e5e7eb02 HX |
83 | int crypto_engine_register_aead(struct aead_engine_alg *alg); |
84 | void crypto_engine_unregister_aead(struct aead_engine_alg *alg); | |
85 | int crypto_engine_register_aeads(struct aead_engine_alg *algs, int count); | |
86 | void crypto_engine_unregister_aeads(struct aead_engine_alg *algs, int count); | |
87 | ||
88 | int crypto_engine_register_ahash(struct ahash_engine_alg *alg); | |
89 | void crypto_engine_unregister_ahash(struct ahash_engine_alg *alg); | |
90 | int crypto_engine_register_ahashes(struct ahash_engine_alg *algs, int count); | |
91 | void crypto_engine_unregister_ahashes(struct ahash_engine_alg *algs, | |
92 | int count); | |
93 | ||
94 | int crypto_engine_register_akcipher(struct akcipher_engine_alg *alg); | |
95 | void crypto_engine_unregister_akcipher(struct akcipher_engine_alg *alg); | |
96 | ||
97 | int crypto_engine_register_kpp(struct kpp_engine_alg *alg); | |
98 | void crypto_engine_unregister_kpp(struct kpp_engine_alg *alg); | |
99 | ||
100 | int crypto_engine_register_skcipher(struct skcipher_engine_alg *alg); | |
101 | void crypto_engine_unregister_skcipher(struct skcipher_engine_alg *alg); | |
102 | int crypto_engine_register_skciphers(struct skcipher_engine_alg *algs, | |
103 | int count); | |
104 | void crypto_engine_unregister_skciphers(struct skcipher_engine_alg *algs, | |
105 | int count); | |
106 | ||
2589ad84 | 107 | #endif /* _CRYPTO_ENGINE_H */ |