diff options
author | Eric Biggers <ebiggers@google.com> | 2018-02-20 02:48:28 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2018-03-02 11:03:38 -0500 |
commit | 0e145b477dea594ee5b588feb7cb0f531e2d263d (patch) | |
tree | 02c7bad8ce9889430310556e8faf5cf3e0c16899 | |
parent | 75d8a5532fc6db34e5aa712ec8117c9f9cb83088 (diff) |
crypto: ablk_helper - remove ablk_helper
All users of ablk_helper have been converted over to crypto_simd, so
remove ablk_helper.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r-- | crypto/Kconfig | 4 | ||||
-rw-r--r-- | crypto/Makefile | 1 | ||||
-rw-r--r-- | crypto/ablk_helper.c | 150 | ||||
-rw-r--r-- | include/crypto/ablk_helper.h | 32 |
4 files changed, 0 insertions, 187 deletions
diff --git a/crypto/Kconfig b/crypto/Kconfig index 8783dcf20fc3..de693e0451b8 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig | |||
@@ -245,10 +245,6 @@ config CRYPTO_TEST | |||
245 | help | 245 | help |
246 | Quick & dirty crypto test module. | 246 | Quick & dirty crypto test module. |
247 | 247 | ||
248 | config CRYPTO_ABLK_HELPER | ||
249 | tristate | ||
250 | select CRYPTO_CRYPTD | ||
251 | |||
252 | config CRYPTO_SIMD | 248 | config CRYPTO_SIMD |
253 | tristate | 249 | tristate |
254 | select CRYPTO_CRYPTD | 250 | select CRYPTO_CRYPTD |
diff --git a/crypto/Makefile b/crypto/Makefile index ba6019471447..04517b29d839 100644 --- a/crypto/Makefile +++ b/crypto/Makefile | |||
@@ -150,6 +150,5 @@ obj-$(CONFIG_XOR_BLOCKS) += xor.o | |||
150 | obj-$(CONFIG_ASYNC_CORE) += async_tx/ | 150 | obj-$(CONFIG_ASYNC_CORE) += async_tx/ |
151 | obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys/ | 151 | obj-$(CONFIG_ASYMMETRIC_KEY_TYPE) += asymmetric_keys/ |
152 | obj-$(CONFIG_CRYPTO_HASH_INFO) += hash_info.o | 152 | obj-$(CONFIG_CRYPTO_HASH_INFO) += hash_info.o |
153 | obj-$(CONFIG_CRYPTO_ABLK_HELPER) += ablk_helper.o | ||
154 | crypto_simd-y := simd.o | 153 | crypto_simd-y := simd.o |
155 | obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o | 154 | obj-$(CONFIG_CRYPTO_SIMD) += crypto_simd.o |
diff --git a/crypto/ablk_helper.c b/crypto/ablk_helper.c deleted file mode 100644 index 09776bb1360e..000000000000 --- a/crypto/ablk_helper.c +++ /dev/null | |||
@@ -1,150 +0,0 @@ | |||
1 | /* | ||
2 | * Shared async block cipher helpers | ||
3 | * | ||
4 | * Copyright (c) 2012 Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | ||
5 | * | ||
6 | * Based on aesni-intel_glue.c by: | ||
7 | * Copyright (C) 2008, Intel Corp. | ||
8 | * Author: Huang Ying <ying.huang@intel.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/crypto.h> | ||
27 | #include <linux/init.h> | ||
28 | #include <linux/module.h> | ||
29 | #include <crypto/algapi.h> | ||
30 | #include <crypto/cryptd.h> | ||
31 | #include <crypto/ablk_helper.h> | ||
32 | #include <asm/simd.h> | ||
33 | |||
34 | int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key, | ||
35 | unsigned int key_len) | ||
36 | { | ||
37 | struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm); | ||
38 | struct crypto_ablkcipher *child = &ctx->cryptd_tfm->base; | ||
39 | int err; | ||
40 | |||
41 | crypto_ablkcipher_clear_flags(child, CRYPTO_TFM_REQ_MASK); | ||
42 | crypto_ablkcipher_set_flags(child, crypto_ablkcipher_get_flags(tfm) | ||
43 | & CRYPTO_TFM_REQ_MASK); | ||
44 | err = crypto_ablkcipher_setkey(child, key, key_len); | ||
45 | crypto_ablkcipher_set_flags(tfm, crypto_ablkcipher_get_flags(child) | ||
46 | & CRYPTO_TFM_RES_MASK); | ||
47 | return err; | ||
48 | } | ||
49 | EXPORT_SYMBOL_GPL(ablk_set_key); | ||
50 | |||
51 | int __ablk_encrypt(struct ablkcipher_request *req) | ||
52 | { | ||
53 | struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req); | ||
54 | struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm); | ||
55 | struct blkcipher_desc desc; | ||
56 | |||
57 | desc.tfm = cryptd_ablkcipher_child(ctx->cryptd_tfm); | ||
58 | desc.info = req->info; | ||
59 | desc.flags = 0; | ||
60 | |||
61 | return crypto_blkcipher_crt(desc.tfm)->encrypt( | ||
62 | &desc, req->dst, req->src, req->nbytes); | ||
63 | } | ||
64 | EXPORT_SYMBOL_GPL(__ablk_encrypt); | ||
65 | |||
66 | int ablk_encrypt(struct ablkcipher_request *req) | ||
67 | { | ||
68 | struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req); | ||
69 | struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm); | ||
70 | |||
71 | if (!may_use_simd() || | ||
72 | (in_atomic() && cryptd_ablkcipher_queued(ctx->cryptd_tfm))) { | ||
73 | struct ablkcipher_request *cryptd_req = | ||
74 | ablkcipher_request_ctx(req); | ||
75 | |||
76 | *cryptd_req = *req; | ||
77 | ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base); | ||
78 | |||
79 | return crypto_ablkcipher_encrypt(cryptd_req); | ||
80 | } else { | ||
81 | return __ablk_encrypt(req); | ||
82 | } | ||
83 | } | ||
84 | EXPORT_SYMBOL_GPL(ablk_encrypt); | ||
85 | |||
86 | int ablk_decrypt(struct ablkcipher_request *req) | ||
87 | { | ||
88 | struct crypto_ablkcipher *tfm = crypto_ablkcipher_reqtfm(req); | ||
89 | struct async_helper_ctx *ctx = crypto_ablkcipher_ctx(tfm); | ||
90 | |||
91 | if (!may_use_simd() || | ||
92 | (in_atomic() && cryptd_ablkcipher_queued(ctx->cryptd_tfm))) { | ||
93 | struct ablkcipher_request *cryptd_req = | ||
94 | ablkcipher_request_ctx(req); | ||
95 | |||
96 | *cryptd_req = *req; | ||
97 | ablkcipher_request_set_tfm(cryptd_req, &ctx->cryptd_tfm->base); | ||
98 | |||
99 | return crypto_ablkcipher_decrypt(cryptd_req); | ||
100 | } else { | ||
101 | struct blkcipher_desc desc; | ||
102 | |||
103 | desc.tfm = cryptd_ablkcipher_child(ctx->cryptd_tfm); | ||
104 | desc.info = req->info; | ||
105 | desc.flags = 0; | ||
106 | |||
107 | return crypto_blkcipher_crt(desc.tfm)->decrypt( | ||
108 | &desc, req->dst, req->src, req->nbytes); | ||
109 | } | ||
110 | } | ||
111 | EXPORT_SYMBOL_GPL(ablk_decrypt); | ||
112 | |||
113 | void ablk_exit(struct crypto_tfm *tfm) | ||
114 | { | ||
115 | struct async_helper_ctx *ctx = crypto_tfm_ctx(tfm); | ||
116 | |||
117 | cryptd_free_ablkcipher(ctx->cryptd_tfm); | ||
118 | } | ||
119 | EXPORT_SYMBOL_GPL(ablk_exit); | ||
120 | |||
121 | int ablk_init_common(struct crypto_tfm *tfm, const char *drv_name) | ||
122 | { | ||
123 | struct async_helper_ctx *ctx = crypto_tfm_ctx(tfm); | ||
124 | struct cryptd_ablkcipher *cryptd_tfm; | ||
125 | |||
126 | cryptd_tfm = cryptd_alloc_ablkcipher(drv_name, CRYPTO_ALG_INTERNAL, | ||
127 | CRYPTO_ALG_INTERNAL); | ||
128 | if (IS_ERR(cryptd_tfm)) | ||
129 | return PTR_ERR(cryptd_tfm); | ||
130 | |||
131 | ctx->cryptd_tfm = cryptd_tfm; | ||
132 | tfm->crt_ablkcipher.reqsize = sizeof(struct ablkcipher_request) + | ||
133 | crypto_ablkcipher_reqsize(&cryptd_tfm->base); | ||
134 | |||
135 | return 0; | ||
136 | } | ||
137 | EXPORT_SYMBOL_GPL(ablk_init_common); | ||
138 | |||
139 | int ablk_init(struct crypto_tfm *tfm) | ||
140 | { | ||
141 | char drv_name[CRYPTO_MAX_ALG_NAME]; | ||
142 | |||
143 | snprintf(drv_name, sizeof(drv_name), "__driver-%s", | ||
144 | crypto_tfm_alg_driver_name(tfm)); | ||
145 | |||
146 | return ablk_init_common(tfm, drv_name); | ||
147 | } | ||
148 | EXPORT_SYMBOL_GPL(ablk_init); | ||
149 | |||
150 | MODULE_LICENSE("GPL"); | ||
diff --git a/include/crypto/ablk_helper.h b/include/crypto/ablk_helper.h deleted file mode 100644 index 4e655c2a4e15..000000000000 --- a/include/crypto/ablk_helper.h +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | /* | ||
3 | * Shared async block cipher helpers | ||
4 | */ | ||
5 | |||
6 | #ifndef _CRYPTO_ABLK_HELPER_H | ||
7 | #define _CRYPTO_ABLK_HELPER_H | ||
8 | |||
9 | #include <linux/crypto.h> | ||
10 | #include <linux/kernel.h> | ||
11 | #include <crypto/cryptd.h> | ||
12 | |||
13 | struct async_helper_ctx { | ||
14 | struct cryptd_ablkcipher *cryptd_tfm; | ||
15 | }; | ||
16 | |||
17 | extern int ablk_set_key(struct crypto_ablkcipher *tfm, const u8 *key, | ||
18 | unsigned int key_len); | ||
19 | |||
20 | extern int __ablk_encrypt(struct ablkcipher_request *req); | ||
21 | |||
22 | extern int ablk_encrypt(struct ablkcipher_request *req); | ||
23 | |||
24 | extern int ablk_decrypt(struct ablkcipher_request *req); | ||
25 | |||
26 | extern void ablk_exit(struct crypto_tfm *tfm); | ||
27 | |||
28 | extern int ablk_init_common(struct crypto_tfm *tfm, const char *drv_name); | ||
29 | |||
30 | extern int ablk_init(struct crypto_tfm *tfm); | ||
31 | |||
32 | #endif /* _CRYPTO_ABLK_HELPER_H */ | ||