diff options
author | Chunrong Guo <chunrong.guo@nxp.com> | 2017-04-18 15:11:50 +0800 |
---|---|---|
committer | Otavio Salvador <otavio@ossystems.com.br> | 2017-05-02 17:54:58 -0300 |
commit | e756964ac2595d880304f227dec7bdb424d7d974 (patch) | |
tree | 28c067a5652216278a92e39144d48ac95f0e8f12 /recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch | |
parent | cfb3ddaaaa78204ef5281c8627eed08f4f7e3f09 (diff) | |
download | meta-freescale-e756964ac2595d880304f227dec7bdb424d7d974.tar.gz |
cryptodev: update to 6c2b61c
**include the following changes
6c2b61c - update copyright notes
f79d523 - fix: reset finish condition before test start
e8f7a91 - Merge remote-tracking branch 'upstream/master'
6818263 - Fix ablkcipher algorithms usage in v4.8+ kernels
26e167f - zc: Use the power of #elif
e49fe25 - adjust to API changes in kernel >=4.10
2b29be8 - adjust to API changes in kernel >=4.10
c3afb40 - add support for rsa speed tests
c9b7a80 - close the session after every test
ba49470 - add support for authenc(hmac(sha1), cbc(aes)) speed tests
690cd62 - Merge branch 'master' into hpe2016
5adf04e - Merge remote-tracking branch 'upstream/master'
840c7ba - remove not used variable
2dbbb23 - do more strict code checking to avoid maintenance issues
88223e4 - avoid implicit conversion between signed and unsigned char
8db6905 - use buf_align macro to reduce code duplication
b6d0e0f - rename header file to clarify purpose
1fd6062 - fix warnings of "implicit declaration of function" in async_speed
ff3c8ab - remove not used local variables
25a1276 - fix incorrect return code in case of error from openssl_cioccrypt
e7ef4ea - Merge pull request #17 from michaelweiser/gup_flags
99c6d21 - fix ignored SIGALRM signals on some platforms
71975fa - setting KERNEL_DIR is not necessary to build tests
a96ff97 - fix issues with install target
07748d3 - Merge branch 'master' into hpe2016
cc89148 - Fix ablkcipher algorithms usage in v4.8+ kernels
4d6e4fb - Merge remote-tracking branch 'upstream/master'
f126e48 - Adjust to another change in the user page API
4257fce - add -async option to run_crypto_tests.sh
f953164 - merge sync and async benchmarks into a single program
e7af57b - add % to cpu idle for convenience
1883c95 - add a wrapper script for running all tests
998b66b - add notes about configured limits in SEC driver
b1a35f3 - fix ignored SIGALRM signals on some platforms
b754517 - use the same algorithm names in sync_speed as in async_speed
8baefa4 - force LC_TIME value to avoid mpstat not using ISO8601 format
d0978b5 - add sync speed tests with the same format as async ones
15d890b - graceful exit if cryptodev is not built with ASYNC flags
9a595bf - fix typo, use consistent spacing
9461878 - remove output line because it does not add clarity to the results
b09c17f - the C standard used by cryptodev is C90 with GNU extensions
447808d - exit early if cryptodev tests are not installed
493afd3 - fix incorrect handling of error cases...
e0d2c88 - make default output tabular
abc007a - really fix (again...) the mpstat issue
2696cd5 - use $(...) instead of `...` for consistency
e8fb004 - fix the scale of the runtime value
119151b - remove old results to avoid incorrect reports
71ac3d5 - fix the reported unit
8c47a0c - setting KERNEL_DIR is not necessary to build tests
182b307 - fix issues with install target
5021828 - do more strict code checking to avoid maintenance issues
ab239d7 - return error code of the test if there is one
b5228f2 - remove not used local variables
90d67ce - avoid implicit conversion between signed and unsigned char
4b442ca - fix build warnings on implicit function declarations
2821b92 - add a little space in the output for clarity
9d0ef05 - more precision in running mpstat
0180e2b - fix some issues with parsing mpstat output
4257fce - add -async option to run_crypto_tests.sh
f953164 - merge sync and async benchmarks into a single program
e7af57b - add % to cpu idle for convenience
7d7a733 - sanity check on /dev/crypto availability
137c0c4 - gracefull stop for async speed tests
600eb70 - fix: set min value when allocating alligned memory buffers
18408c9 - add multithreaded wrapper for async speed test
854cc84 - rename algorithm names for clarity
216f235 - honor the -m flag in async_speed
1023ede - add flag to report in a machine friendly format
219a8b4 - enable async code by default
9def784 - Merge remote-tracking branch 'radualexe/new_tests`
149dc1c - add basic optargs support for async_speed test
9595499 - add support for crc32c hash sync speed test
83e3840 - add support for aes-256-xts sync speed test
fff72ae - add support for sha2-256 hash async speed test
b961800 - add support for sha1 hash async speed test
fea5006 - add support for crc32c hash async speed test
8768fad - add aes-256-xts support for async speed test
Signed-off-by: Chunrong Guo <B40290@freescale.com>
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Diffstat (limited to 'recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch')
-rw-r--r-- | recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch | 281 |
1 files changed, 281 insertions, 0 deletions
diff --git a/recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch b/recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch new file mode 100644 index 00000000..4a82955e --- /dev/null +++ b/recipes-kernel/cryptodev/sdk_patches/0092-Support-skcipher-in-addition-to-ablkcipher-API.patch | |||
@@ -0,0 +1,281 @@ | |||
1 | From e41e73551c886366d741b5e401a3c4c661aa3020 Mon Sep 17 00:00:00 2001 | ||
2 | From: Michael Weiser <michael.weiser@gmx.de> | ||
3 | Date: Fri, 5 Aug 2016 17:26:27 +0200 | ||
4 | Subject: [PATCH 092/104] Support skcipher in addition to ablkcipher API | ||
5 | |||
6 | The ablkcipher API is being phased out[1]. The unified skcipher API | ||
7 | seems to have made its entry with 4.3.[3, 4] By what can be seen from | ||
8 | migration patches[1.ff.], it's a drop-in replacement. | ||
9 | |||
10 | Also, deallocators such as crypto_free_skcipher() are NULL-safe now[2]. | ||
11 | |||
12 | Add a new header cipherapi.h to aid migration from ablkcipher to skcipher and | ||
13 | retain support for old kernels. Make it decide which API to use and provide | ||
14 | appropriate function calls and type definitions. Since the ablkcipher and | ||
15 | skcipher APIs are so similar, those are mainly defines for corresponding | ||
16 | pseudo-functions in namespace cryptodev_ derived directly from their API | ||
17 | counterparts. | ||
18 | |||
19 | Compiles and works (i.e. checks pass) with Debian testing 4.6.4 kernel | ||
20 | as well as 4.8-rc2+ Linus git tree as of today. (Both require a fix for | ||
21 | changed 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 | |||
36 | diff --git a/cipherapi.h b/cipherapi.h | ||
37 | new file mode 100644 | ||
38 | index 0000000..07d9923 | ||
39 | --- /dev/null | ||
40 | +++ b/cipherapi.h | ||
41 | @@ -0,0 +1,60 @@ | ||
42 | +#ifndef CIPHERAPI_H | ||
43 | +# define CIPHERAPI_H | ||
44 | + | ||
45 | +#include <linux/version.h> | ||
46 | + | ||
47 | +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) | ||
48 | +# include <linux/crypto.h> | ||
49 | + | ||
50 | +typedef struct ablkcipher_alg cryptodev_blkcipher_alg_t; | ||
51 | +typedef struct crypto_ablkcipher cryptodev_crypto_blkcipher_t; | ||
52 | +typedef struct ablkcipher_request cryptodev_blkcipher_request_t; | ||
53 | + | ||
54 | +# define cryptodev_crypto_alloc_blkcipher crypto_alloc_ablkcipher | ||
55 | +# define cryptodev_crypto_blkcipher_alg crypto_ablkcipher_alg | ||
56 | +# define cryptodev_crypto_blkcipher_blocksize crypto_ablkcipher_blocksize | ||
57 | +# define cryptodev_crypto_blkcipher_ivsize crypto_ablkcipher_ivsize | ||
58 | +# define cryptodev_crypto_blkcipher_alignmask crypto_ablkcipher_alignmask | ||
59 | +# define cryptodev_crypto_blkcipher_setkey crypto_ablkcipher_setkey | ||
60 | + | ||
61 | +static inline void cryptodev_crypto_free_blkcipher(cryptodev_crypto_blkcipher_t *c) { | ||
62 | + if (c) | ||
63 | + crypto_free_ablkcipher(c); | ||
64 | +} | ||
65 | + | ||
66 | +# define cryptodev_blkcipher_request_alloc ablkcipher_request_alloc | ||
67 | +# define cryptodev_blkcipher_request_set_callback ablkcipher_request_set_callback | ||
68 | + | ||
69 | +static inline void cryptodev_blkcipher_request_free(cryptodev_blkcipher_request_t *r) { | ||
70 | + if (r) | ||
71 | + ablkcipher_request_free(r); | ||
72 | +} | ||
73 | + | ||
74 | +# define cryptodev_blkcipher_request_set_crypt ablkcipher_request_set_crypt | ||
75 | +# define cryptodev_crypto_blkcipher_encrypt crypto_ablkcipher_encrypt | ||
76 | +# define cryptodev_crypto_blkcipher_decrypt crypto_ablkcipher_decrypt | ||
77 | +# define cryptodev_crypto_blkcipher_tfm crypto_ablkcipher_tfm | ||
78 | +#else | ||
79 | +#include <crypto/skcipher.h> | ||
80 | + | ||
81 | +typedef struct skcipher_alg cryptodev_blkcipher_alg_t; | ||
82 | +typedef struct crypto_skcipher cryptodev_crypto_blkcipher_t; | ||
83 | +typedef struct skcipher_request cryptodev_blkcipher_request_t; | ||
84 | + | ||
85 | +# define cryptodev_crypto_alloc_blkcipher crypto_alloc_skcipher | ||
86 | +# define cryptodev_crypto_blkcipher_alg crypto_skcipher_alg | ||
87 | +# define cryptodev_crypto_blkcipher_blocksize crypto_skcipher_blocksize | ||
88 | +# define cryptodev_crypto_blkcipher_ivsize crypto_skcipher_ivsize | ||
89 | +# define cryptodev_crypto_blkcipher_alignmask crypto_skcipher_alignmask | ||
90 | +# define cryptodev_crypto_blkcipher_setkey crypto_skcipher_setkey | ||
91 | +# define cryptodev_crypto_free_blkcipher crypto_free_skcipher | ||
92 | +# define cryptodev_blkcipher_request_alloc skcipher_request_alloc | ||
93 | +# define cryptodev_blkcipher_request_set_callback skcipher_request_set_callback | ||
94 | +# define cryptodev_blkcipher_request_free skcipher_request_free | ||
95 | +# define cryptodev_blkcipher_request_set_crypt skcipher_request_set_crypt | ||
96 | +# define cryptodev_crypto_blkcipher_encrypt crypto_skcipher_encrypt | ||
97 | +# define cryptodev_crypto_blkcipher_decrypt crypto_skcipher_decrypt | ||
98 | +# define cryptodev_crypto_blkcipher_tfm crypto_skcipher_tfm | ||
99 | +#endif | ||
100 | + | ||
101 | +#endif | ||
102 | diff --git a/cryptlib.c b/cryptlib.c | ||
103 | index 5d1a5a9..558d4b8 100644 | ||
104 | --- a/cryptlib.c | ||
105 | +++ b/cryptlib.c | ||
106 | @@ -24,7 +24,6 @@ | ||
107 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
108 | */ | ||
109 | |||
110 | -#include <linux/crypto.h> | ||
111 | #include <linux/mm.h> | ||
112 | #include <linux/highmem.h> | ||
113 | #include <linux/ioctl.h> | ||
114 | @@ -38,6 +37,7 @@ | ||
115 | #include <linux/rtnetlink.h> | ||
116 | #include <crypto/authenc.h> | ||
117 | #include "cryptodev_int.h" | ||
118 | +#include "cipherapi.h" | ||
119 | |||
120 | |||
121 | static void cryptodev_complete(struct crypto_async_request *req, int err) | ||
122 | @@ -129,15 +129,15 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
123 | int ret; | ||
124 | |||
125 | if (aead == 0) { | ||
126 | - struct ablkcipher_alg *alg; | ||
127 | + cryptodev_blkcipher_alg_t *alg; | ||
128 | |||
129 | - out->async.s = crypto_alloc_ablkcipher(alg_name, 0, 0); | ||
130 | + out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0); | ||
131 | if (unlikely(IS_ERR(out->async.s))) { | ||
132 | ddebug(1, "Failed to load cipher %s", alg_name); | ||
133 | return -EINVAL; | ||
134 | } | ||
135 | |||
136 | - alg = crypto_ablkcipher_alg(out->async.s); | ||
137 | + alg = cryptodev_crypto_blkcipher_alg(out->async.s); | ||
138 | if (alg != NULL) { | ||
139 | /* Was correct key length supplied? */ | ||
140 | if (alg->max_keysize > 0 && | ||
141 | @@ -150,11 +150,11 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
142 | } | ||
143 | } | ||
144 | |||
145 | - out->blocksize = crypto_ablkcipher_blocksize(out->async.s); | ||
146 | - out->ivsize = crypto_ablkcipher_ivsize(out->async.s); | ||
147 | - out->alignmask = crypto_ablkcipher_alignmask(out->async.s); | ||
148 | + out->blocksize = cryptodev_crypto_blkcipher_blocksize(out->async.s); | ||
149 | + out->ivsize = cryptodev_crypto_blkcipher_ivsize(out->async.s); | ||
150 | + out->alignmask = cryptodev_crypto_blkcipher_alignmask(out->async.s); | ||
151 | |||
152 | - ret = crypto_ablkcipher_setkey(out->async.s, keyp, keylen); | ||
153 | + ret = cryptodev_crypto_blkcipher_setkey(out->async.s, keyp, keylen); | ||
154 | } else { | ||
155 | out->async.as = crypto_alloc_aead(alg_name, 0, 0); | ||
156 | if (unlikely(IS_ERR(out->async.as))) { | ||
157 | @@ -181,14 +181,14 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
158 | init_completion(&out->async.result.completion); | ||
159 | |||
160 | if (aead == 0) { | ||
161 | - out->async.request = ablkcipher_request_alloc(out->async.s, GFP_KERNEL); | ||
162 | + out->async.request = cryptodev_blkcipher_request_alloc(out->async.s, GFP_KERNEL); | ||
163 | if (unlikely(!out->async.request)) { | ||
164 | derr(1, "error allocating async crypto request"); | ||
165 | ret = -ENOMEM; | ||
166 | goto error; | ||
167 | } | ||
168 | |||
169 | - ablkcipher_request_set_callback(out->async.request, 0, | ||
170 | + cryptodev_blkcipher_request_set_callback(out->async.request, 0, | ||
171 | cryptodev_complete, &out->async.result); | ||
172 | } else { | ||
173 | out->async.arequest = aead_request_alloc(out->async.as, GFP_KERNEL); | ||
174 | @@ -206,10 +206,8 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
175 | return 0; | ||
176 | error: | ||
177 | if (aead == 0) { | ||
178 | - if (out->async.request) | ||
179 | - ablkcipher_request_free(out->async.request); | ||
180 | - if (out->async.s) | ||
181 | - crypto_free_ablkcipher(out->async.s); | ||
182 | + cryptodev_blkcipher_request_free(out->async.request); | ||
183 | + cryptodev_crypto_free_blkcipher(out->async.s); | ||
184 | } else { | ||
185 | if (out->async.arequest) | ||
186 | aead_request_free(out->async.arequest); | ||
187 | @@ -224,10 +222,8 @@ void cryptodev_cipher_deinit(struct cipher_data *cdata) | ||
188 | { | ||
189 | if (cdata->init) { | ||
190 | if (cdata->aead == 0) { | ||
191 | - if (cdata->async.request) | ||
192 | - ablkcipher_request_free(cdata->async.request); | ||
193 | - if (cdata->async.s) | ||
194 | - crypto_free_ablkcipher(cdata->async.s); | ||
195 | + cryptodev_blkcipher_request_free(cdata->async.request); | ||
196 | + cryptodev_crypto_free_blkcipher(cdata->async.s); | ||
197 | } else { | ||
198 | if (cdata->async.arequest) | ||
199 | aead_request_free(cdata->async.arequest); | ||
200 | @@ -274,10 +270,10 @@ ssize_t cryptodev_cipher_encrypt(struct cipher_data *cdata, | ||
201 | reinit_completion(&cdata->async.result.completion); | ||
202 | |||
203 | if (cdata->aead == 0) { | ||
204 | - ablkcipher_request_set_crypt(cdata->async.request, | ||
205 | + cryptodev_blkcipher_request_set_crypt(cdata->async.request, | ||
206 | (struct scatterlist *)src, dst, | ||
207 | len, cdata->async.iv); | ||
208 | - ret = crypto_ablkcipher_encrypt(cdata->async.request); | ||
209 | + ret = cryptodev_crypto_blkcipher_encrypt(cdata->async.request); | ||
210 | } else { | ||
211 | aead_request_set_crypt(cdata->async.arequest, | ||
212 | (struct scatterlist *)src, dst, | ||
213 | @@ -296,10 +292,10 @@ ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, | ||
214 | |||
215 | reinit_completion(&cdata->async.result.completion); | ||
216 | if (cdata->aead == 0) { | ||
217 | - ablkcipher_request_set_crypt(cdata->async.request, | ||
218 | + cryptodev_blkcipher_request_set_crypt(cdata->async.request, | ||
219 | (struct scatterlist *)src, dst, | ||
220 | len, cdata->async.iv); | ||
221 | - ret = crypto_ablkcipher_decrypt(cdata->async.request); | ||
222 | + ret = cryptodev_crypto_blkcipher_decrypt(cdata->async.request); | ||
223 | } else { | ||
224 | aead_request_set_crypt(cdata->async.arequest, | ||
225 | (struct scatterlist *)src, dst, | ||
226 | diff --git a/cryptlib.h b/cryptlib.h | ||
227 | index d8e8046..8200a1d 100644 | ||
228 | --- a/cryptlib.h | ||
229 | +++ b/cryptlib.h | ||
230 | @@ -11,6 +11,8 @@ struct cryptodev_result { | ||
231 | int err; | ||
232 | }; | ||
233 | |||
234 | +#include "cipherapi.h" | ||
235 | + | ||
236 | struct cipher_data { | ||
237 | int init; /* 0 uninitialized */ | ||
238 | int blocksize; | ||
239 | @@ -20,8 +22,8 @@ struct cipher_data { | ||
240 | int alignmask; | ||
241 | struct { | ||
242 | /* block ciphers */ | ||
243 | - struct crypto_ablkcipher *s; | ||
244 | - struct ablkcipher_request *request; | ||
245 | + cryptodev_crypto_blkcipher_t *s; | ||
246 | + cryptodev_blkcipher_request_t *request; | ||
247 | |||
248 | /* AEAD ciphers */ | ||
249 | struct crypto_aead *as; | ||
250 | diff --git a/ioctl.c b/ioctl.c | ||
251 | index 2e2bdeb..e3b8af1 100644 | ||
252 | --- a/ioctl.c | ||
253 | +++ b/ioctl.c | ||
254 | @@ -35,7 +35,6 @@ | ||
255 | */ | ||
256 | |||
257 | #include <crypto/hash.h> | ||
258 | -#include <linux/crypto.h> | ||
259 | #include <linux/mm.h> | ||
260 | #include <linux/highmem.h> | ||
261 | #include <linux/ioctl.h> | ||
262 | @@ -54,6 +53,7 @@ | ||
263 | #include "cryptodev_int.h" | ||
264 | #include "zc.h" | ||
265 | #include "version.h" | ||
266 | +#include "cipherapi.h" | ||
267 | |||
268 | MODULE_AUTHOR("Nikos Mavrogiannopoulos <nmav@gnutls.org>"); | ||
269 | MODULE_DESCRIPTION("CryptoDev driver"); | ||
270 | @@ -1052,7 +1052,7 @@ static int get_session_info(struct fcrypt *fcr, struct session_info_op *siop) | ||
271 | |||
272 | if (ses_ptr->cdata.init) { | ||
273 | if (ses_ptr->cdata.aead == 0) | ||
274 | - tfm = crypto_ablkcipher_tfm(ses_ptr->cdata.async.s); | ||
275 | + tfm = cryptodev_crypto_blkcipher_tfm(ses_ptr->cdata.async.s); | ||
276 | else | ||
277 | tfm = crypto_aead_tfm(ses_ptr->cdata.async.as); | ||
278 | tfm_info_to_alg_info(&siop->cipher_info, tfm); | ||
279 | -- | ||
280 | 2.10.2 | ||
281 | |||