summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/cryptodev/files/cb186f682679383e8b5806240927903730ce85d9.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-kernel/cryptodev/files/cb186f682679383e8b5806240927903730ce85d9.patch')
-rw-r--r--meta/recipes-kernel/cryptodev/files/cb186f682679383e8b5806240927903730ce85d9.patch279
1 files changed, 0 insertions, 279 deletions
diff --git a/meta/recipes-kernel/cryptodev/files/cb186f682679383e8b5806240927903730ce85d9.patch b/meta/recipes-kernel/cryptodev/files/cb186f682679383e8b5806240927903730ce85d9.patch
deleted file mode 100644
index eb0eab63bd..0000000000
--- a/meta/recipes-kernel/cryptodev/files/cb186f682679383e8b5806240927903730ce85d9.patch
+++ /dev/null
@@ -1,279 +0,0 @@
1From cb186f682679383e8b5806240927903730ce85d9 Mon Sep 17 00:00:00 2001
2From: Michael Weiser <michael.weiser@gmx.de>
3Date: Fri, 5 Aug 2016 17:26:27 +0200
4Subject: [PATCH] Support skcipher in addition to ablkcipher API
5
6The ablkcipher API is being phased out[1]. The unified skcipher API
7seems to have made its entry with 4.3.[3, 4] By what can be seen from
8migration patches[1.ff.], it's a drop-in replacement.
9
10Also, deallocators such as crypto_free_skcipher() are NULL-safe now[2].
11
12Add a new header cipherapi.h to aid migration from ablkcipher to skcipher and
13retain support for old kernels. Make it decide which API to use and provide
14appropriate function calls and type definitions. Since the ablkcipher and
15skcipher APIs are so similar, those are mainly defines for corresponding
16pseudo-functions in namespace cryptodev_ derived directly from their API
17counterparts.
18
19Compiles and works (i.e. checks pass) with Debian testing 4.6.4 kernel
20as well as 4.8-rc2+ Linus git tree as of today. (Both require a fix for
21changed page access API[5].)
22
23[1] https://www.spinics.net/lists/linux-crypto/msg18133.html
24[2] https://www.spinics.net/lists/linux-crypto/msg18154.html, line 120
25[3] https://www.spinics.net/lists/linux-crypto/msg16373.html
26[4] https://www.spinics.net/lists/linux-crypto/msg16294.html
27[5] https://github.com/cryptodev-linux/cryptodev-linux/pull/14
28---
29 cipherapi.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 cryptlib.c | 40 ++++++++++++++++++----------------------
31 cryptlib.h | 6 ++++--
32 ioctl.c | 4 ++--
33 4 files changed, 84 insertions(+), 26 deletions(-)
34 create mode 100644 cipherapi.h
35
36Upstream-Status: Backport [from master for 4.8 kernels]
37
38Index: cryptodev-linux-1.8/cipherapi.h
39===================================================================
40--- /dev/null
41+++ cryptodev-linux-1.8/cipherapi.h
42@@ -0,0 +1,60 @@
43+#ifndef CIPHERAPI_H
44+# define CIPHERAPI_H
45+
46+#include <linux/version.h>
47+
48+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0))
49+# include <linux/crypto.h>
50+
51+typedef struct ablkcipher_alg cryptodev_blkcipher_alg_t;
52+typedef struct crypto_ablkcipher cryptodev_crypto_blkcipher_t;
53+typedef struct ablkcipher_request cryptodev_blkcipher_request_t;
54+
55+# define cryptodev_crypto_alloc_blkcipher crypto_alloc_ablkcipher
56+# define cryptodev_crypto_blkcipher_alg crypto_ablkcipher_alg
57+# define cryptodev_crypto_blkcipher_blocksize crypto_ablkcipher_blocksize
58+# define cryptodev_crypto_blkcipher_ivsize crypto_ablkcipher_ivsize
59+# define cryptodev_crypto_blkcipher_alignmask crypto_ablkcipher_alignmask
60+# define cryptodev_crypto_blkcipher_setkey crypto_ablkcipher_setkey
61+
62+static inline void cryptodev_crypto_free_blkcipher(cryptodev_crypto_blkcipher_t *c) {
63+ if (c)
64+ crypto_free_ablkcipher(c);
65+}
66+
67+# define cryptodev_blkcipher_request_alloc ablkcipher_request_alloc
68+# define cryptodev_blkcipher_request_set_callback ablkcipher_request_set_callback
69+
70+static inline void cryptodev_blkcipher_request_free(cryptodev_blkcipher_request_t *r) {
71+ if (r)
72+ ablkcipher_request_free(r);
73+}
74+
75+# define cryptodev_blkcipher_request_set_crypt ablkcipher_request_set_crypt
76+# define cryptodev_crypto_blkcipher_encrypt crypto_ablkcipher_encrypt
77+# define cryptodev_crypto_blkcipher_decrypt crypto_ablkcipher_decrypt
78+# define cryptodev_crypto_blkcipher_tfm crypto_ablkcipher_tfm
79+#else
80+#include <crypto/skcipher.h>
81+
82+typedef struct skcipher_alg cryptodev_blkcipher_alg_t;
83+typedef struct crypto_skcipher cryptodev_crypto_blkcipher_t;
84+typedef struct skcipher_request cryptodev_blkcipher_request_t;
85+
86+# define cryptodev_crypto_alloc_blkcipher crypto_alloc_skcipher
87+# define cryptodev_crypto_blkcipher_alg crypto_skcipher_alg
88+# define cryptodev_crypto_blkcipher_blocksize crypto_skcipher_blocksize
89+# define cryptodev_crypto_blkcipher_ivsize crypto_skcipher_ivsize
90+# define cryptodev_crypto_blkcipher_alignmask crypto_skcipher_alignmask
91+# define cryptodev_crypto_blkcipher_setkey crypto_skcipher_setkey
92+# define cryptodev_crypto_free_blkcipher crypto_free_skcipher
93+# define cryptodev_blkcipher_request_alloc skcipher_request_alloc
94+# define cryptodev_blkcipher_request_set_callback skcipher_request_set_callback
95+# define cryptodev_blkcipher_request_free skcipher_request_free
96+# define cryptodev_blkcipher_request_set_crypt skcipher_request_set_crypt
97+# define cryptodev_crypto_blkcipher_encrypt crypto_skcipher_encrypt
98+# define cryptodev_crypto_blkcipher_decrypt crypto_skcipher_decrypt
99+# define cryptodev_crypto_blkcipher_tfm crypto_skcipher_tfm
100+#endif
101+
102+#endif
103Index: cryptodev-linux-1.8/cryptlib.c
104===================================================================
105--- cryptodev-linux-1.8.orig/cryptlib.c
106+++ cryptodev-linux-1.8/cryptlib.c
107@@ -23,7 +23,6 @@
108 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
109 */
110
111-#include <linux/crypto.h>
112 #include <linux/mm.h>
113 #include <linux/highmem.h>
114 #include <linux/ioctl.h>
115@@ -37,6 +36,7 @@
116 #include <linux/rtnetlink.h>
117 #include <crypto/authenc.h>
118 #include "cryptodev_int.h"
119+#include "cipherapi.h"
120
121
122 struct cryptodev_result {
123@@ -133,15 +133,15 @@ int cryptodev_cipher_init(struct cipher_
124 int ret;
125
126 if (aead == 0) {
127- struct ablkcipher_alg *alg;
128+ cryptodev_blkcipher_alg_t *alg;
129
130- out->async.s = crypto_alloc_ablkcipher(alg_name, 0, 0);
131+ out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0);
132 if (unlikely(IS_ERR(out->async.s))) {
133 ddebug(1, "Failed to load cipher %s", alg_name);
134 return -EINVAL;
135 }
136
137- alg = crypto_ablkcipher_alg(out->async.s);
138+ alg = cryptodev_crypto_blkcipher_alg(out->async.s);
139 if (alg != NULL) {
140 /* Was correct key length supplied? */
141 if (alg->max_keysize > 0 &&
142@@ -154,11 +154,11 @@ int cryptodev_cipher_init(struct cipher_
143 }
144 }
145
146- out->blocksize = crypto_ablkcipher_blocksize(out->async.s);
147- out->ivsize = crypto_ablkcipher_ivsize(out->async.s);
148- out->alignmask = crypto_ablkcipher_alignmask(out->async.s);
149+ out->blocksize = cryptodev_crypto_blkcipher_blocksize(out->async.s);
150+ out->ivsize = cryptodev_crypto_blkcipher_ivsize(out->async.s);
151+ out->alignmask = cryptodev_crypto_blkcipher_alignmask(out->async.s);
152
153- ret = crypto_ablkcipher_setkey(out->async.s, keyp, keylen);
154+ ret = cryptodev_crypto_blkcipher_setkey(out->async.s, keyp, keylen);
155 } else {
156 out->async.as = crypto_alloc_aead(alg_name, 0, 0);
157 if (unlikely(IS_ERR(out->async.as))) {
158@@ -191,14 +191,14 @@ int cryptodev_cipher_init(struct cipher_
159 init_completion(&out->async.result->completion);
160
161 if (aead == 0) {
162- out->async.request = ablkcipher_request_alloc(out->async.s, GFP_KERNEL);
163+ out->async.request = cryptodev_blkcipher_request_alloc(out->async.s, GFP_KERNEL);
164 if (unlikely(!out->async.request)) {
165 derr(1, "error allocating async crypto request");
166 ret = -ENOMEM;
167 goto error;
168 }
169
170- ablkcipher_request_set_callback(out->async.request,
171+ cryptodev_blkcipher_request_set_callback(out->async.request,
172 CRYPTO_TFM_REQ_MAY_BACKLOG,
173 cryptodev_complete, out->async.result);
174 } else {
175@@ -218,10 +218,8 @@ int cryptodev_cipher_init(struct cipher_
176 return 0;
177 error:
178 if (aead == 0) {
179- if (out->async.request)
180- ablkcipher_request_free(out->async.request);
181- if (out->async.s)
182- crypto_free_ablkcipher(out->async.s);
183+ cryptodev_blkcipher_request_free(out->async.request);
184+ cryptodev_crypto_free_blkcipher(out->async.s);
185 } else {
186 if (out->async.arequest)
187 aead_request_free(out->async.arequest);
188@@ -237,10 +235,8 @@ void cryptodev_cipher_deinit(struct ciph
189 {
190 if (cdata->init) {
191 if (cdata->aead == 0) {
192- if (cdata->async.request)
193- ablkcipher_request_free(cdata->async.request);
194- if (cdata->async.s)
195- crypto_free_ablkcipher(cdata->async.s);
196+ cryptodev_blkcipher_request_free(cdata->async.request);
197+ cryptodev_crypto_free_blkcipher(cdata->async.s);
198 } else {
199 if (cdata->async.arequest)
200 aead_request_free(cdata->async.arequest);
201@@ -289,10 +285,10 @@ ssize_t cryptodev_cipher_encrypt(struct
202 reinit_completion(&cdata->async.result->completion);
203
204 if (cdata->aead == 0) {
205- ablkcipher_request_set_crypt(cdata->async.request,
206+ cryptodev_blkcipher_request_set_crypt(cdata->async.request,
207 (struct scatterlist *)src, dst,
208 len, cdata->async.iv);
209- ret = crypto_ablkcipher_encrypt(cdata->async.request);
210+ ret = cryptodev_crypto_blkcipher_encrypt(cdata->async.request);
211 } else {
212 aead_request_set_crypt(cdata->async.arequest,
213 (struct scatterlist *)src, dst,
214@@ -311,10 +307,10 @@ ssize_t cryptodev_cipher_decrypt(struct
215
216 reinit_completion(&cdata->async.result->completion);
217 if (cdata->aead == 0) {
218- ablkcipher_request_set_crypt(cdata->async.request,
219+ cryptodev_blkcipher_request_set_crypt(cdata->async.request,
220 (struct scatterlist *)src, dst,
221 len, cdata->async.iv);
222- ret = crypto_ablkcipher_decrypt(cdata->async.request);
223+ ret = cryptodev_crypto_blkcipher_decrypt(cdata->async.request);
224 } else {
225 aead_request_set_crypt(cdata->async.arequest,
226 (struct scatterlist *)src, dst,
227Index: cryptodev-linux-1.8/cryptlib.h
228===================================================================
229--- cryptodev-linux-1.8.orig/cryptlib.h
230+++ cryptodev-linux-1.8/cryptlib.h
231@@ -3,6 +3,8 @@
232
233 #include <linux/version.h>
234
235+#include "cipherapi.h"
236+
237 struct cipher_data {
238 int init; /* 0 uninitialized */
239 int blocksize;
240@@ -12,8 +14,8 @@ struct cipher_data {
241 int alignmask;
242 struct {
243 /* block ciphers */
244- struct crypto_ablkcipher *s;
245- struct ablkcipher_request *request;
246+ cryptodev_crypto_blkcipher_t *s;
247+ cryptodev_blkcipher_request_t *request;
248
249 /* AEAD ciphers */
250 struct crypto_aead *as;
251Index: cryptodev-linux-1.8/ioctl.c
252===================================================================
253--- cryptodev-linux-1.8.orig/ioctl.c
254+++ cryptodev-linux-1.8/ioctl.c
255@@ -34,7 +34,6 @@
256 */
257
258 #include <crypto/hash.h>
259-#include <linux/crypto.h>
260 #include <linux/mm.h>
261 #include <linux/highmem.h>
262 #include <linux/ioctl.h>
263@@ -53,6 +52,7 @@
264 #include "cryptodev_int.h"
265 #include "zc.h"
266 #include "version.h"
267+#include "cipherapi.h"
268
269 MODULE_AUTHOR("Nikos Mavrogiannopoulos <nmav@gnutls.org>");
270 MODULE_DESCRIPTION("CryptoDev driver");
271@@ -765,7 +765,7 @@ static int get_session_info(struct fcryp
272
273 if (ses_ptr->cdata.init) {
274 if (ses_ptr->cdata.aead == 0)
275- tfm = crypto_ablkcipher_tfm(ses_ptr->cdata.async.s);
276+ tfm = cryptodev_crypto_blkcipher_tfm(ses_ptr->cdata.async.s);
277 else
278 tfm = crypto_aead_tfm(ses_ptr->cdata.async.as);
279 tfm_info_to_alg_info(&siop->cipher_info, tfm);