summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch
diff options
context:
space:
mode:
authorChunrong Guo <chunrong.guo@nxp.com>2017-04-18 15:11:50 +0800
committerOtavio Salvador <otavio@ossystems.com.br>2017-05-02 17:54:58 -0300
commite756964ac2595d880304f227dec7bdb424d7d974 (patch)
tree28c067a5652216278a92e39144d48ac95f0e8f12 /recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch
parentcfb3ddaaaa78204ef5281c8627eed08f4f7e3f09 (diff)
downloadmeta-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/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch')
-rw-r--r--recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch147
1 files changed, 147 insertions, 0 deletions
diff --git a/recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch b/recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch
new file mode 100644
index 00000000..fcf2a3ee
--- /dev/null
+++ b/recipes-kernel/cryptodev/sdk_patches/0093-Fix-ablkcipher-algorithms-usage-in-v4.8-kernels.patch
@@ -0,0 +1,147 @@
1From 871ecc5c5ebfbb9c6e1b17a7ff7a531ed1fab644 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Horia=20Geant=C4=83?= <horia.geanta@nxp.com>
3Date: Wed, 16 Nov 2016 15:38:39 +0200
4Subject: [PATCH 093/104] Fix ablkcipher algorithms usage in v4.8+ kernels
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9ablkcipher API is not completely removed from kernels <= v4.9.
10Thus it's still valid to use ablkcipher algorithms.
11
12Fix the case when implementers register ablkcipher algorithms
13and cryptodev casts them to skcipher without checking their type.
14
15Note: alg returned by crypto_ablkcipher_alg() is no longer checked
16to be non-NULL. This is guaranteed by the fact that ablkcipher_tfm
17(out->async.s) is valid.
18
19Fixes: cb186f682679 ("Support skcipher in addition to ablkcipher API")
20Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
21---
22 cipherapi.h | 4 ----
23 cryptlib.c | 56 ++++++++++++++++++++++++++++++++++++++++++++------------
24 2 files changed, 44 insertions(+), 16 deletions(-)
25
26diff --git a/cipherapi.h b/cipherapi.h
27index 07d9923..b6ed6c2 100644
28--- a/cipherapi.h
29+++ b/cipherapi.h
30@@ -6,12 +6,10 @@
31 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0))
32 # include <linux/crypto.h>
33
34-typedef struct ablkcipher_alg cryptodev_blkcipher_alg_t;
35 typedef struct crypto_ablkcipher cryptodev_crypto_blkcipher_t;
36 typedef struct ablkcipher_request cryptodev_blkcipher_request_t;
37
38 # define cryptodev_crypto_alloc_blkcipher crypto_alloc_ablkcipher
39-# define cryptodev_crypto_blkcipher_alg crypto_ablkcipher_alg
40 # define cryptodev_crypto_blkcipher_blocksize crypto_ablkcipher_blocksize
41 # define cryptodev_crypto_blkcipher_ivsize crypto_ablkcipher_ivsize
42 # define cryptodev_crypto_blkcipher_alignmask crypto_ablkcipher_alignmask
43@@ -37,12 +35,10 @@ static inline void cryptodev_blkcipher_request_free(cryptodev_blkcipher_request_
44 #else
45 #include <crypto/skcipher.h>
46
47-typedef struct skcipher_alg cryptodev_blkcipher_alg_t;
48 typedef struct crypto_skcipher cryptodev_crypto_blkcipher_t;
49 typedef struct skcipher_request cryptodev_blkcipher_request_t;
50
51 # define cryptodev_crypto_alloc_blkcipher crypto_alloc_skcipher
52-# define cryptodev_crypto_blkcipher_alg crypto_skcipher_alg
53 # define cryptodev_crypto_blkcipher_blocksize crypto_skcipher_blocksize
54 # define cryptodev_crypto_blkcipher_ivsize crypto_skcipher_ivsize
55 # define cryptodev_crypto_blkcipher_alignmask crypto_skcipher_alignmask
56diff --git a/cryptlib.c b/cryptlib.c
57index 558d4b8..dcac3ec 100644
58--- a/cryptlib.c
59+++ b/cryptlib.c
60@@ -39,6 +39,7 @@
61 #include "cryptodev_int.h"
62 #include "cipherapi.h"
63
64+extern const struct crypto_type crypto_givcipher_type;
65
66 static void cryptodev_complete(struct crypto_async_request *req, int err)
67 {
68@@ -122,6 +123,19 @@ error:
69 return ret;
70 }
71
72+/* Was correct key length supplied? */
73+static int check_key_size(size_t keylen, const char *alg_name,
74+ unsigned int min_keysize, unsigned int max_keysize)
75+{
76+ if (max_keysize > 0 && unlikely((keylen < min_keysize) ||
77+ (keylen > max_keysize))) {
78+ ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.",
79+ keylen, alg_name, min_keysize, max_keysize);
80+ return -EINVAL;
81+ }
82+
83+ return 0;
84+}
85
86 int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
87 uint8_t *keyp, size_t keylen, int stream, int aead)
88@@ -129,7 +143,12 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
89 int ret;
90
91 if (aead == 0) {
92- cryptodev_blkcipher_alg_t *alg;
93+ unsigned int min_keysize, max_keysize;
94+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0))
95+ struct crypto_tfm *tfm;
96+#else
97+ struct ablkcipher_alg *alg;
98+#endif
99
100 out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0);
101 if (unlikely(IS_ERR(out->async.s))) {
102@@ -137,18 +156,31 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name,
103 return -EINVAL;
104 }
105
106- alg = cryptodev_crypto_blkcipher_alg(out->async.s);
107- if (alg != NULL) {
108- /* Was correct key length supplied? */
109- if (alg->max_keysize > 0 &&
110- unlikely((keylen < alg->min_keysize) ||
111- (keylen > alg->max_keysize))) {
112- ddebug(1, "Wrong keylen '%zu' for algorithm '%s'. Use %u to %u.",
113- keylen, alg_name, alg->min_keysize, alg->max_keysize);
114- ret = -EINVAL;
115- goto error;
116- }
117+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0))
118+ tfm = crypto_skcipher_tfm(out->async.s);
119+ if ((tfm->__crt_alg->cra_type == &crypto_ablkcipher_type) ||
120+ (tfm->__crt_alg->cra_type == &crypto_givcipher_type)) {
121+ struct ablkcipher_alg *alg;
122+
123+ alg = &tfm->__crt_alg->cra_ablkcipher;
124+ min_keysize = alg->min_keysize;
125+ max_keysize = alg->max_keysize;
126+ } else {
127+ struct skcipher_alg *alg;
128+
129+ alg = crypto_skcipher_alg(out->async.s);
130+ min_keysize = alg->min_keysize;
131+ max_keysize = alg->max_keysize;
132 }
133+#else
134+ alg = crypto_ablkcipher_alg(out->async.s);
135+ min_keysize = alg->min_keysize;
136+ max_keysize = alg->max_keysize;
137+#endif
138+ ret = check_key_size(keylen, alg_name, min_keysize,
139+ max_keysize);
140+ if (ret)
141+ goto error;
142
143 out->blocksize = cryptodev_crypto_blkcipher_blocksize(out->async.s);
144 out->ivsize = cryptodev_crypto_blkcipher_ivsize(out->async.s);
145--
1462.10.2
147