diff options
Diffstat (limited to 'meta-fsl-ppc/recipes-kernel')
17 files changed, 210 insertions, 791 deletions
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl.inc b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl.inc index 70544e26..e32e3502 100644 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl.inc +++ b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl.inc | |||
@@ -1,24 +1,17 @@ | |||
1 | FILESEXTRAPATHS_prepend := "${THISDIR}/cryptodev-fsl:" | 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/cryptodev-fsl:" |
2 | 2 | ||
3 | SRC_URI_qoriq-ppc = "git://github.com/nmav/cryptodev-linux.git \ | 3 | SRC_URI_qoriq-ppc = "git://github.com/cryptodev-linux/cryptodev-linux.git \ |
4 | file://0001-add-support-for-composite-TLS-SHA1-AES-algorithm-off.patch \ | 4 | file://0001-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch \ |
5 | file://0002-use-function-local-storage-for-cipher-and-hmac-keys.patch \ | 5 | file://0002-add-support-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch \ |
6 | file://0003-Add-support-for-aead-keys-for-composite-algorithms.patch \ | 6 | file://0003-PKC-support-added-in-cryptodev-module.patch \ |
7 | file://0004-fix-scatterlist-size-for-in-place-operations.patch \ | 7 | file://0004-Compat-versions-of-PKC-IOCTLs.patch \ |
8 | file://0005-add-dst_len-parameter-to-be-provided-by-the-user.patch \ | 8 | file://0005-Asynchronous-interface-changes-in-cryptodev.patch \ |
9 | file://0006-fix-build-error-on-some-targets.patch \ | 9 | file://0006-ECC_KEYGEN-and-DLC_KEYGEN-supported-in-cryptodev-mod.patch \ |
10 | file://0007-add-support-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch \ | 10 | file://0007-RCU-stall-fixed-in-PKC-asynchronous-interface.patch \ |
11 | file://0008-fix-cipher-algorithm-memleaks.patch \ | 11 | file://0008-Add-RSA-Key-generation-offloading.patch \ |
12 | file://0009-PKC-support-added-in-cryptodev-module.patch \ | 12 | file://0009-Fixed-compilation-error-of-openssl-with-fsl-cryptode.patch \ |
13 | file://0010-Compat-versions-of-PKC-IOCTLs.patch \ | ||
14 | file://0011-Asynchronous-interface-changes-in-cryptodev.patch \ | ||
15 | file://0012-ECC_KEYGEN-and-DLC_KEYGEN-supported-in-cryptodev-mod.patch \ | ||
16 | file://0013-RCU-stall-fixed-in-PKC-asynchronous-interface.patch \ | ||
17 | file://0014-use-static-allocation-for-keys-copied-from-userspace.patch \ | ||
18 | file://0015-Add-RSA-Key-generation-offloading.patch \ | ||
19 | file://0016-Fixed-compilation-error-of-openssl-with-fsl-cryptode.patch \ | ||
20 | " | 13 | " |
21 | SRCREV_qoriq-ppc = "e8609a408d40c83ae8fc11bbe9a7b3847612669b" | 14 | SRCREV_qoriq-ppc = "6aa62a2c320b04f55fdfe0ed015c3d9b48997239" |
22 | 15 | ||
23 | S_qoriq-ppc = "${WORKDIR}/git" | 16 | S_qoriq-ppc = "${WORKDIR}/git" |
24 | 17 | ||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0001-add-support-for-composite-TLS-SHA1-AES-algorithm-off.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0001-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch index 094fb0b5..796e5484 100644 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0001-add-support-for-composite-TLS-SHA1-AES-algorithm-off.patch +++ b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0001-add-support-for-composite-TLS10-SHA1-AES-algorithm-o.patch | |||
@@ -1,23 +1,22 @@ | |||
1 | From 434790a1bbafa371c0c6647238234573db98d017 Mon Sep 17 00:00:00 2001 | 1 | From 715ade8236f40cf811c39f9538dfd60803967fcd Mon Sep 17 00:00:00 2001 |
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | 2 | From: Cristian Stoica <cristian.stoica@freescale.com> |
3 | Date: Thu, 29 Aug 2013 16:52:30 +0300 | 3 | Date: Thu, 29 Aug 2013 16:52:30 +0300 |
4 | Subject: [[Patch][fsl 01/16] add support for composite TLS(SHA1,AES) | 4 | Subject: [PATCH 1/9] add support for composite TLS10(SHA1,AES) algorithm |
5 | algorithm offload | 5 | offload |
6 | 6 | ||
7 | Upstream-status: Pending | 7 | This adds support for composite algorithm offload as a primitive |
8 | crypto (cipher + hmac) operation. | ||
8 | 9 | ||
9 | This adds support for composite algorithm offload in a single crypto | 10 | It requires kernel support for tls10(hmac(sha1),cbc(aes)) algorithm |
10 | (cipher + hmac) operation. | 11 | provided either in software or accelerated by hardware such as |
11 | 12 | Freescale B*, P* and T* platforms. | |
12 | It requires either software or hardware TLS support in the Linux kernel | ||
13 | and can be used with Freescale B*, P* and T* platforms that have support | ||
14 | for hardware TLS acceleration. | ||
15 | 13 | ||
14 | Change-Id: Ia1c605da3860e91e681295dfc8df7c09eb4006cf | ||
16 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | 15 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> |
17 | Tested-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> | 16 | Reviewed-on: http://git.am.freescale.net:8181/17218 |
18 | --- | 17 | --- |
19 | crypto/cryptodev.h | 1 + | 18 | crypto/cryptodev.h | 1 + |
20 | ioctl.c | 5 +++++ | 19 | ioctl.c | 5 +++++ |
21 | 2 files changed, 6 insertions(+) | 20 | 2 files changed, 6 insertions(+) |
22 | 21 | ||
23 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | 22 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h |
@@ -33,10 +32,10 @@ index 7fb9c7d..c0e8cd4 100644 | |||
33 | }; | 32 | }; |
34 | 33 | ||
35 | diff --git a/ioctl.c b/ioctl.c | 34 | diff --git a/ioctl.c b/ioctl.c |
36 | index d4e83f4..a0f1db1 100644 | 35 | index 5a55a76..f9b9b2e 100644 |
37 | --- a/ioctl.c | 36 | --- a/ioctl.c |
38 | +++ b/ioctl.c | 37 | +++ b/ioctl.c |
39 | @@ -146,6 +146,11 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | 38 | @@ -159,6 +159,11 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) |
40 | stream = 1; | 39 | stream = 1; |
41 | aead = 1; | 40 | aead = 1; |
42 | break; | 41 | break; |
@@ -49,5 +48,5 @@ index d4e83f4..a0f1db1 100644 | |||
49 | alg_name = "ecb(cipher_null)"; | 48 | alg_name = "ecb(cipher_null)"; |
50 | stream = 1; | 49 | stream = 1; |
51 | -- | 50 | -- |
52 | 1.7.9.7 | 51 | 1.8.3.1 |
53 | 52 | ||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0007-add-support-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0002-add-support-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch index b796f160..086a97f8 100644 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0007-add-support-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch +++ b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0002-add-support-for-COMPAT_CIOCAUTHCRYPT-ioctl.patch | |||
@@ -1,25 +1,26 @@ | |||
1 | From 75e26bf18997488518228cb851585bf8e4c3120f Mon Sep 17 00:00:00 2001 | 1 | From 4b766c93e4ee19248dd66bbebb61fb5cc9c8a012 Mon Sep 17 00:00:00 2001 |
2 | From: Horia Geanta <horia.geanta@freescale.com> | 2 | From: Horia Geanta <horia.geanta@freescale.com> |
3 | Date: Wed, 4 Dec 2013 15:43:41 +0200 | 3 | Date: Wed, 4 Dec 2013 15:43:41 +0200 |
4 | Subject: [[Patch][fsl 07/16] add support for COMPAT_CIOCAUTHCRYPT ioctl() | 4 | Subject: [PATCH 2/9] add support for COMPAT_CIOCAUTHCRYPT ioctl() |
5 | 5 | ||
6 | Upstream-status: Pending | 6 | Upstream-status: Pending |
7 | 7 | ||
8 | Needed for 64b kernel with 32b user space. | 8 | Needed for 64b kernel with 32b user space. |
9 | 9 | ||
10 | Change-Id: I44a999a4164e7ae7122dee6ed0716b2f25cadbc1 | ||
10 | Signed-off-by: Horia Geanta <horia.geanta@freescale.com> | 11 | Signed-off-by: Horia Geanta <horia.geanta@freescale.com> |
11 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> | 12 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> |
12 | --- | 13 | --- |
13 | authenc.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 14 | authenc.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
14 | cryptodev_int.h | 41 ++++++++++++++++++++++++++++ | 15 | cryptodev_int.h | 40 +++++++++++++++++++++++++++++ |
15 | ioctl.c | 16 +++++++++++ | 16 | ioctl.c | 16 ++++++++++++ |
16 | 3 files changed, 137 insertions(+) | 17 | 3 files changed, 134 insertions(+) |
17 | 18 | ||
18 | diff --git a/authenc.c b/authenc.c | 19 | diff --git a/authenc.c b/authenc.c |
19 | index 5235973..259a225 100644 | 20 | index 1bd7377..ef0d3db 100644 |
20 | --- a/authenc.c | 21 | --- a/authenc.c |
21 | +++ b/authenc.c | 22 | +++ b/authenc.c |
22 | @@ -241,6 +241,86 @@ static int fill_caop_from_kcaop(struct kernel_crypt_auth_op *kcaop, struct fcryp | 23 | @@ -272,6 +272,84 @@ static int fill_caop_from_kcaop(struct kernel_crypt_auth_op *kcaop, struct fcryp |
23 | return 0; | 24 | return 0; |
24 | } | 25 | } |
25 | 26 | ||
@@ -34,7 +35,6 @@ index 5235973..259a225 100644 | |||
34 | + caop->op = compat->op; | 35 | + caop->op = compat->op; |
35 | + caop->flags = compat->flags; | 36 | + caop->flags = compat->flags; |
36 | + caop->len = compat->len; | 37 | + caop->len = compat->len; |
37 | + caop->dst_len = compat->dst_len; | ||
38 | + caop->auth_len = compat->auth_len; | 38 | + caop->auth_len = compat->auth_len; |
39 | + caop->tag_len = compat->tag_len; | 39 | + caop->tag_len = compat->tag_len; |
40 | + caop->iv_len = compat->iv_len; | 40 | + caop->iv_len = compat->iv_len; |
@@ -54,7 +54,6 @@ index 5235973..259a225 100644 | |||
54 | + compat->op = caop->op; | 54 | + compat->op = caop->op; |
55 | + compat->flags = caop->flags; | 55 | + compat->flags = caop->flags; |
56 | + compat->len = caop->len; | 56 | + compat->len = caop->len; |
57 | + compat->dst_len = caop->dst_len; | ||
58 | + compat->auth_len = caop->auth_len; | 57 | + compat->auth_len = caop->auth_len; |
59 | + compat->tag_len = caop->tag_len; | 58 | + compat->tag_len = caop->tag_len; |
60 | + compat->iv_len = caop->iv_len; | 59 | + compat->iv_len = caop->iv_len; |
@@ -107,10 +106,10 @@ index 5235973..259a225 100644 | |||
107 | int kcaop_from_user(struct kernel_crypt_auth_op *kcaop, | 106 | int kcaop_from_user(struct kernel_crypt_auth_op *kcaop, |
108 | struct fcrypt *fcr, void __user *arg) | 107 | struct fcrypt *fcr, void __user *arg) |
109 | diff --git a/cryptodev_int.h b/cryptodev_int.h | 108 | diff --git a/cryptodev_int.h b/cryptodev_int.h |
110 | index d7660fa..8d206c9 100644 | 109 | index d7660fa..8e687e7 100644 |
111 | --- a/cryptodev_int.h | 110 | --- a/cryptodev_int.h |
112 | +++ b/cryptodev_int.h | 111 | +++ b/cryptodev_int.h |
113 | @@ -73,11 +73,43 @@ struct compat_crypt_op { | 112 | @@ -73,11 +73,42 @@ struct compat_crypt_op { |
114 | compat_uptr_t iv;/* initialization vector for encryption operations */ | 113 | compat_uptr_t iv;/* initialization vector for encryption operations */ |
115 | }; | 114 | }; |
116 | 115 | ||
@@ -120,7 +119,6 @@ index d7660fa..8d206c9 100644 | |||
120 | + uint16_t op; /* COP_ENCRYPT or COP_DECRYPT */ | 119 | + uint16_t op; /* COP_ENCRYPT or COP_DECRYPT */ |
121 | + uint16_t flags; /* see COP_FLAG_AEAD_* */ | 120 | + uint16_t flags; /* see COP_FLAG_AEAD_* */ |
122 | + uint32_t len; /* length of source data */ | 121 | + uint32_t len; /* length of source data */ |
123 | + uint32_t dst_len; /* length of result data */ | ||
124 | + uint32_t auth_len; /* length of auth data */ | 122 | + uint32_t auth_len; /* length of auth data */ |
125 | + compat_uptr_t auth_src; /* authenticated-only data */ | 123 | + compat_uptr_t auth_src; /* authenticated-only data */ |
126 | + | 124 | + |
@@ -154,7 +152,7 @@ index d7660fa..8d206c9 100644 | |||
154 | 152 | ||
155 | #endif /* CONFIG_COMPAT */ | 153 | #endif /* CONFIG_COMPAT */ |
156 | 154 | ||
157 | @@ -108,6 +140,15 @@ struct kernel_crypt_auth_op { | 155 | @@ -108,6 +139,15 @@ struct kernel_crypt_auth_op { |
158 | 156 | ||
159 | /* auth */ | 157 | /* auth */ |
160 | 158 | ||
@@ -171,10 +169,10 @@ index d7660fa..8d206c9 100644 | |||
171 | struct fcrypt *fcr, void __user *arg); | 169 | struct fcrypt *fcr, void __user *arg); |
172 | int kcaop_to_user(struct kernel_crypt_auth_op *kcaop, | 170 | int kcaop_to_user(struct kernel_crypt_auth_op *kcaop, |
173 | diff --git a/ioctl.c b/ioctl.c | 171 | diff --git a/ioctl.c b/ioctl.c |
174 | index 3baf195..18874d3 100644 | 172 | index f9b9b2e..1563c75 100644 |
175 | --- a/ioctl.c | 173 | --- a/ioctl.c |
176 | +++ b/ioctl.c | 174 | +++ b/ioctl.c |
177 | @@ -991,6 +991,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | 175 | @@ -998,6 +998,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) |
178 | struct session_op sop; | 176 | struct session_op sop; |
179 | struct compat_session_op compat_sop; | 177 | struct compat_session_op compat_sop; |
180 | struct kernel_crypt_op kcop; | 178 | struct kernel_crypt_op kcop; |
@@ -182,7 +180,7 @@ index 3baf195..18874d3 100644 | |||
182 | int ret; | 180 | int ret; |
183 | 181 | ||
184 | if (unlikely(!pcr)) | 182 | if (unlikely(!pcr)) |
185 | @@ -1033,6 +1034,21 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | 183 | @@ -1040,6 +1041,21 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) |
186 | return ret; | 184 | return ret; |
187 | 185 | ||
188 | return compat_kcop_to_user(&kcop, fcr, arg); | 186 | return compat_kcop_to_user(&kcop, fcr, arg); |
@@ -205,5 +203,5 @@ index 3baf195..18874d3 100644 | |||
205 | case COMPAT_CIOCASYNCCRYPT: | 203 | case COMPAT_CIOCASYNCCRYPT: |
206 | if (unlikely(ret = compat_kcop_from_user(&kcop, fcr, arg))) | 204 | if (unlikely(ret = compat_kcop_from_user(&kcop, fcr, arg))) |
207 | -- | 205 | -- |
208 | 1.7.9.7 | 206 | 1.8.3.1 |
209 | 207 | ||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0002-use-function-local-storage-for-cipher-and-hmac-keys.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0002-use-function-local-storage-for-cipher-and-hmac-keys.patch deleted file mode 100644 index 4702fd4f..00000000 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0002-use-function-local-storage-for-cipher-and-hmac-keys.patch +++ /dev/null | |||
@@ -1,87 +0,0 @@ | |||
1 | From cc65307405a21c3b709ca6f2a6f64ff0c67c0eed Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Wed, 18 Sep 2013 13:42:31 +0300 | ||
4 | Subject: [[Patch][fsl 02/16] use function-local storage for cipher and hmac | ||
5 | keys | ||
6 | |||
7 | Upstream-status: Pending | ||
8 | |||
9 | This refactorization is necessary for next patches that add support for | ||
10 | aead composite ciphers where the aead key is the sum of cipher and hmac | ||
11 | keys. | ||
12 | |||
13 | Without this patch, the hmac and cipher keys can't be combined in the | ||
14 | same ioctl. | ||
15 | |||
16 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
17 | Tested-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> | ||
18 | --- | ||
19 | ioctl.c | 14 ++++++-------- | ||
20 | 1 file changed, 6 insertions(+), 8 deletions(-) | ||
21 | |||
22 | diff --git a/ioctl.c b/ioctl.c | ||
23 | index a0f1db1..c614373 100644 | ||
24 | --- a/ioctl.c | ||
25 | +++ b/ioctl.c | ||
26 | @@ -109,6 +109,8 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
27 | const char *alg_name = NULL; | ||
28 | const char *hash_name = NULL; | ||
29 | int hmac_mode = 1, stream = 0, aead = 0; | ||
30 | + uint8_t enckey[CRYPTO_CIPHER_MAX_KEY_LEN]; | ||
31 | + uint8_t mackey[CRYPTO_HMAC_MAX_KEY_LEN]; | ||
32 | |||
33 | /* Does the request make sense? */ | ||
34 | if (unlikely(!sop->cipher && !sop->mac)) { | ||
35 | @@ -227,8 +229,6 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
36 | |||
37 | /* Set-up crypto transform. */ | ||
38 | if (alg_name) { | ||
39 | - uint8_t keyp[CRYPTO_CIPHER_MAX_KEY_LEN]; | ||
40 | - | ||
41 | if (unlikely(sop->keylen > CRYPTO_CIPHER_MAX_KEY_LEN)) { | ||
42 | ddebug(1, "Setting key failed for %s-%zu.", | ||
43 | alg_name, (size_t)sop->keylen*8); | ||
44 | @@ -236,12 +236,12 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
45 | goto error_cipher; | ||
46 | } | ||
47 | |||
48 | - if (unlikely(copy_from_user(keyp, sop->key, sop->keylen))) { | ||
49 | + if (unlikely(copy_from_user(enckey, sop->key, sop->keylen))) { | ||
50 | ret = -EFAULT; | ||
51 | goto error_cipher; | ||
52 | } | ||
53 | |||
54 | - ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, keyp, | ||
55 | + ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, enckey, | ||
56 | sop->keylen, stream, aead); | ||
57 | if (ret < 0) { | ||
58 | ddebug(1, "Failed to load cipher for %s", alg_name); | ||
59 | @@ -251,8 +251,6 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
60 | } | ||
61 | |||
62 | if (hash_name && aead == 0) { | ||
63 | - uint8_t keyp[CRYPTO_HMAC_MAX_KEY_LEN]; | ||
64 | - | ||
65 | if (unlikely(sop->mackeylen > CRYPTO_HMAC_MAX_KEY_LEN)) { | ||
66 | ddebug(1, "Setting key failed for %s-%zu.", | ||
67 | hash_name, (size_t)sop->mackeylen*8); | ||
68 | @@ -260,14 +258,14 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
69 | goto error_hash; | ||
70 | } | ||
71 | |||
72 | - if (sop->mackey && unlikely(copy_from_user(keyp, sop->mackey, | ||
73 | + if (sop->mackey && unlikely(copy_from_user(mackey, sop->mackey, | ||
74 | sop->mackeylen))) { | ||
75 | ret = -EFAULT; | ||
76 | goto error_hash; | ||
77 | } | ||
78 | |||
79 | ret = cryptodev_hash_init(&ses_new->hdata, hash_name, hmac_mode, | ||
80 | - keyp, sop->mackeylen); | ||
81 | + mackey, sop->mackeylen); | ||
82 | if (ret != 0) { | ||
83 | ddebug(1, "Failed to load hash for %s", hash_name); | ||
84 | ret = -EINVAL; | ||
85 | -- | ||
86 | 1.7.9.7 | ||
87 | |||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0003-Add-support-for-aead-keys-for-composite-algorithms.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0003-Add-support-for-aead-keys-for-composite-algorithms.patch deleted file mode 100644 index 033552a3..00000000 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0003-Add-support-for-aead-keys-for-composite-algorithms.patch +++ /dev/null | |||
@@ -1,170 +0,0 @@ | |||
1 | From 8cabaedb69acc5b44c7a9cf058045908130a6af7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Wed, 23 Oct 2013 16:57:22 +0300 | ||
4 | Subject: [[Patch][fsl 03/16] Add support for aead keys for composite | ||
5 | algorithms | ||
6 | |||
7 | Upstream-status: Pending | ||
8 | |||
9 | Composite aead algorithms (e.g. AES-CBC + HMAC-SHA1) need two keys to | ||
10 | operate. The two keys are wrapped in a single buffer in the form | ||
11 | used also by crypto/authenc.c | ||
12 | Blockcipher and non-composite aead algorithms (e.g. AES-GCM) use a | ||
13 | single key which is simply copied from user-space. | ||
14 | |||
15 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
16 | Tested-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> | ||
17 | --- | ||
18 | cryptlib.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
19 | cryptlib.h | 3 +++ | ||
20 | ioctl.c | 24 ++++++++++++++---------- | ||
21 | 3 files changed, 76 insertions(+), 10 deletions(-) | ||
22 | |||
23 | diff --git a/cryptlib.c b/cryptlib.c | ||
24 | index a7fbff4..2986d09 100644 | ||
25 | --- a/cryptlib.c | ||
26 | +++ b/cryptlib.c | ||
27 | @@ -34,6 +34,8 @@ | ||
28 | #include <crypto/hash.h> | ||
29 | #include <crypto/cryptodev.h> | ||
30 | #include <crypto/aead.h> | ||
31 | +#include <linux/rtnetlink.h> | ||
32 | +#include <crypto/authenc.h> | ||
33 | #include "cryptodev_int.h" | ||
34 | |||
35 | |||
36 | @@ -53,6 +55,63 @@ static void cryptodev_complete(struct crypto_async_request *req, int err) | ||
37 | complete(&res->completion); | ||
38 | } | ||
39 | |||
40 | +int cryptodev_get_cipher_keylen(unsigned int *keylen, struct session_op *sop, | ||
41 | + int aead) | ||
42 | +{ | ||
43 | + unsigned int klen = sop->keylen; | ||
44 | + | ||
45 | + if (unlikely(sop->keylen > CRYPTO_CIPHER_MAX_KEY_LEN)) | ||
46 | + return -EINVAL; | ||
47 | + | ||
48 | + if (aead && sop->mackeylen) { | ||
49 | + if (unlikely(sop->mackeylen > CRYPTO_HMAC_MAX_KEY_LEN)) | ||
50 | + return -EINVAL; | ||
51 | + klen += sop->mackeylen; | ||
52 | + klen += RTA_SPACE(sizeof(struct crypto_authenc_key_param)); | ||
53 | + } | ||
54 | + | ||
55 | + *keylen = klen; | ||
56 | + return 0; | ||
57 | +} | ||
58 | + | ||
59 | +int cryptodev_get_cipher_key(uint8_t *key, struct session_op *sop, int aead) | ||
60 | +{ | ||
61 | + /* Get algorithm key from user-space. For composite aead algorithms, | ||
62 | + * the key representation is in the format used by linux kernel in | ||
63 | + * crypto/authenc.c | ||
64 | + */ | ||
65 | + struct crypto_authenc_key_param *param; | ||
66 | + struct rtattr *rta; | ||
67 | + int ret = 0; | ||
68 | + | ||
69 | + if (aead && sop->mackeylen) { | ||
70 | + /* the key header type and header length */ | ||
71 | + rta = (void *)key; | ||
72 | + rta->rta_type = CRYPTO_AUTHENC_KEYA_PARAM; | ||
73 | + rta->rta_len = RTA_LENGTH(sizeof(*param)); | ||
74 | + | ||
75 | + /* the key parameter is the length of the encryption key */ | ||
76 | + param = RTA_DATA(rta); | ||
77 | + param->enckeylen = cpu_to_be32(sop->keylen); | ||
78 | + | ||
79 | + /* copy the hash key */ | ||
80 | + key += RTA_SPACE(sizeof(*param)); | ||
81 | + if (unlikely(copy_from_user(key, sop->mackey, sop->mackeylen))) { | ||
82 | + ret = -EFAULT; | ||
83 | + goto error; | ||
84 | + } | ||
85 | + /* get the pointer ready for the encryption key */ | ||
86 | + key += sop->mackeylen; | ||
87 | + } | ||
88 | + /* blockcipher algorithms have the key ready to use */ | ||
89 | + if (unlikely(copy_from_user(key, sop->key, sop->keylen))) | ||
90 | + ret = -EFAULT; | ||
91 | + | ||
92 | +error: | ||
93 | + return ret; | ||
94 | +} | ||
95 | + | ||
96 | + | ||
97 | int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
98 | uint8_t *keyp, size_t keylen, int stream, int aead) | ||
99 | { | ||
100 | diff --git a/cryptlib.h b/cryptlib.h | ||
101 | index 0744284..a0a8a63 100644 | ||
102 | --- a/cryptlib.h | ||
103 | +++ b/cryptlib.h | ||
104 | @@ -25,6 +25,9 @@ struct cipher_data { | ||
105 | int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
106 | uint8_t *key, size_t keylen, int stream, int aead); | ||
107 | void cryptodev_cipher_deinit(struct cipher_data *cdata); | ||
108 | +int cryptodev_get_cipher_key(uint8_t *key, struct session_op *sop, int aead); | ||
109 | +int cryptodev_get_cipher_keylen(unsigned int *keylen, struct session_op *sop, | ||
110 | + int aead); | ||
111 | ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, | ||
112 | const struct scatterlist *sg1, | ||
113 | struct scatterlist *sg2, size_t len); | ||
114 | diff --git a/ioctl.c b/ioctl.c | ||
115 | index c614373..3baf195 100644 | ||
116 | --- a/ioctl.c | ||
117 | +++ b/ioctl.c | ||
118 | @@ -109,7 +109,8 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
119 | const char *alg_name = NULL; | ||
120 | const char *hash_name = NULL; | ||
121 | int hmac_mode = 1, stream = 0, aead = 0; | ||
122 | - uint8_t enckey[CRYPTO_CIPHER_MAX_KEY_LEN]; | ||
123 | + uint8_t *key = NULL; | ||
124 | + unsigned int keylen; | ||
125 | uint8_t mackey[CRYPTO_HMAC_MAX_KEY_LEN]; | ||
126 | |||
127 | /* Does the request make sense? */ | ||
128 | @@ -229,20 +230,22 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
129 | |||
130 | /* Set-up crypto transform. */ | ||
131 | if (alg_name) { | ||
132 | - if (unlikely(sop->keylen > CRYPTO_CIPHER_MAX_KEY_LEN)) { | ||
133 | - ddebug(1, "Setting key failed for %s-%zu.", | ||
134 | - alg_name, (size_t)sop->keylen*8); | ||
135 | - ret = -EINVAL; | ||
136 | + ret = cryptodev_get_cipher_keylen(&keylen, sop, aead); | ||
137 | + if (unlikely(ret < 0)) | ||
138 | goto error_cipher; | ||
139 | - } | ||
140 | |||
141 | - if (unlikely(copy_from_user(enckey, sop->key, sop->keylen))) { | ||
142 | - ret = -EFAULT; | ||
143 | + key = kmalloc(keylen, GFP_KERNEL); | ||
144 | + if (unlikely(!key)) { | ||
145 | + ret = -ENOMEM; | ||
146 | goto error_cipher; | ||
147 | } | ||
148 | |||
149 | - ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, enckey, | ||
150 | - sop->keylen, stream, aead); | ||
151 | + ret = cryptodev_get_cipher_key(key, sop, aead); | ||
152 | + if (unlikely(ret < 0)) | ||
153 | + goto error_cipher; | ||
154 | + | ||
155 | + ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, key, keylen, | ||
156 | + stream, aead); | ||
157 | if (ret < 0) { | ||
158 | ddebug(1, "Failed to load cipher for %s", alg_name); | ||
159 | ret = -EINVAL; | ||
160 | @@ -318,6 +321,7 @@ error_hash: | ||
161 | kfree(ses_new->sg); | ||
162 | kfree(ses_new->pages); | ||
163 | error_cipher: | ||
164 | + kfree(key); | ||
165 | kfree(ses_new); | ||
166 | |||
167 | return ret; | ||
168 | -- | ||
169 | 1.7.9.7 | ||
170 | |||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0009-PKC-support-added-in-cryptodev-module.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0003-PKC-support-added-in-cryptodev-module.patch index b403731a..a4f7816b 100644 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0009-PKC-support-added-in-cryptodev-module.patch +++ b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0003-PKC-support-added-in-cryptodev-module.patch | |||
@@ -1,22 +1,22 @@ | |||
1 | From 55be37e9e308990b2eeeef7f974dfbfbb1120266 Mon Sep 17 00:00:00 2001 | 1 | From 5b57fc2124cef0acc3c7e8de376ebd9aa4f1fdd3 Mon Sep 17 00:00:00 2001 |
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | 2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> |
3 | Date: Fri, 7 Mar 2014 06:16:09 +0545 | 3 | Date: Fri, 7 Mar 2014 06:16:09 +0545 |
4 | Subject: [[Patch][fsl 09/16] PKC support added in cryptodev module | 4 | Subject: [PATCH 3/9] PKC support added in cryptodev module |
5 | 5 | ||
6 | Upstream-status: Pending | 6 | Upstream-status: Pending |
7 | 7 | ||
8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | 8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> |
9 | --- | 9 | --- |
10 | cryptlib.c | 66 ++++++++- | 10 | cryptlib.c | 66 +++++++++- |
11 | cryptlib.h | 28 ++++ | 11 | cryptlib.h | 28 ++++ |
12 | crypto/cryptodev.h | 15 ++- | 12 | crypto/cryptodev.h | 15 ++- |
13 | cryptodev_int.h | 20 ++- | 13 | cryptodev_int.h | 20 ++- |
14 | ioctl.c | 196 +++++++++++++++++++++++++-- | 14 | ioctl.c | 196 +++++++++++++++++++++++++-- |
15 | main.c | 378 ++++++++++++++++++++++++++++++++++++++++++++++++++++ | 15 | main.c | 378 +++++++++++++++++++++++++++++++++++++++++++++++++++++ |
16 | 6 files changed, 685 insertions(+), 18 deletions(-) | 16 | 6 files changed, 685 insertions(+), 18 deletions(-) |
17 | 17 | ||
18 | diff --git a/cryptlib.c b/cryptlib.c | 18 | diff --git a/cryptlib.c b/cryptlib.c |
19 | index 3576f39..fa0b63f 100644 | 19 | index 44ce763..6900028 100644 |
20 | --- a/cryptlib.c | 20 | --- a/cryptlib.c |
21 | +++ b/cryptlib.c | 21 | +++ b/cryptlib.c |
22 | @@ -5,6 +5,8 @@ | 22 | @@ -5,6 +5,8 @@ |
@@ -40,7 +40,7 @@ index 3576f39..fa0b63f 100644 | |||
40 | static void cryptodev_complete(struct crypto_async_request *req, int err) | 40 | static void cryptodev_complete(struct crypto_async_request *req, int err) |
41 | { | 41 | { |
42 | struct cryptodev_result *res = req->data; | 42 | struct cryptodev_result *res = req->data; |
43 | @@ -244,7 +241,6 @@ static inline int waitfor(struct cryptodev_result *cr, ssize_t ret) | 43 | @@ -259,7 +256,6 @@ static inline int waitfor(struct cryptodev_result *cr, ssize_t ret) |
44 | case 0: | 44 | case 0: |
45 | break; | 45 | break; |
46 | case -EINPROGRESS: | 46 | case -EINPROGRESS: |
@@ -48,7 +48,7 @@ index 3576f39..fa0b63f 100644 | |||
48 | wait_for_completion(&cr->completion); | 48 | wait_for_completion(&cr->completion); |
49 | /* At this point we known for sure the request has finished, | 49 | /* At this point we known for sure the request has finished, |
50 | * because wait_for_completion above was not interruptible. | 50 | * because wait_for_completion above was not interruptible. |
51 | @@ -424,3 +420,61 @@ int cryptodev_hash_final(struct hash_data *hdata, void *output) | 51 | @@ -439,3 +435,61 @@ int cryptodev_hash_final(struct hash_data *hdata, void *output) |
52 | return waitfor(hdata->async.result, ret); | 52 | return waitfor(hdata->async.result, ret); |
53 | } | 53 | } |
54 | 54 | ||
@@ -111,7 +111,7 @@ index 3576f39..fa0b63f 100644 | |||
111 | + return ret; | 111 | + return ret; |
112 | +} | 112 | +} |
113 | diff --git a/cryptlib.h b/cryptlib.h | 113 | diff --git a/cryptlib.h b/cryptlib.h |
114 | index 4cb66ad..e77edc5 100644 | 114 | index a0a8a63..56d325a 100644 |
115 | --- a/cryptlib.h | 115 | --- a/cryptlib.h |
116 | +++ b/cryptlib.h | 116 | +++ b/cryptlib.h |
117 | @@ -1,3 +1,6 @@ | 117 | @@ -1,3 +1,6 @@ |
@@ -123,7 +123,7 @@ index 4cb66ad..e77edc5 100644 | |||
123 | 123 | ||
124 | @@ -89,5 +92,30 @@ void cryptodev_hash_deinit(struct hash_data *hdata); | 124 | @@ -89,5 +92,30 @@ void cryptodev_hash_deinit(struct hash_data *hdata); |
125 | int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, | 125 | int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, |
126 | int hmac_mode, void *mackey, unsigned int mackeylen); | 126 | int hmac_mode, void *mackey, size_t mackeylen); |
127 | 127 | ||
128 | +/* Operation Type */ | 128 | +/* Operation Type */ |
129 | +enum offload_type { | 129 | +enum offload_type { |
@@ -153,7 +153,7 @@ index 4cb66ad..e77edc5 100644 | |||
153 | +int cryptodev_pkc_offload(struct cryptodev_pkc *); | 153 | +int cryptodev_pkc_offload(struct cryptodev_pkc *); |
154 | #endif | 154 | #endif |
155 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | 155 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h |
156 | index 3ea3d35..575ce63 100644 | 156 | index c0e8cd4..96675fe 100644 |
157 | --- a/crypto/cryptodev.h | 157 | --- a/crypto/cryptodev.h |
158 | +++ b/crypto/cryptodev.h | 158 | +++ b/crypto/cryptodev.h |
159 | @@ -1,6 +1,10 @@ | 159 | @@ -1,6 +1,10 @@ |
@@ -169,7 +169,7 @@ index 3ea3d35..575ce63 100644 | |||
169 | 169 | ||
170 | #ifndef L_CRYPTODEV_H | 170 | #ifndef L_CRYPTODEV_H |
171 | #define L_CRYPTODEV_H | 171 | #define L_CRYPTODEV_H |
172 | @@ -246,6 +250,9 @@ struct crypt_kop { | 172 | @@ -245,6 +249,9 @@ struct crypt_kop { |
173 | __u16 crk_oparams; | 173 | __u16 crk_oparams; |
174 | __u32 crk_pad1; | 174 | __u32 crk_pad1; |
175 | struct crparam crk_param[CRK_MAXPARAM]; | 175 | struct crparam crk_param[CRK_MAXPARAM]; |
@@ -179,7 +179,7 @@ index 3ea3d35..575ce63 100644 | |||
179 | }; | 179 | }; |
180 | 180 | ||
181 | enum cryptodev_crk_op_t { | 181 | enum cryptodev_crk_op_t { |
182 | @@ -290,5 +297,7 @@ enum cryptodev_crk_op_t { | 182 | @@ -289,5 +296,7 @@ enum cryptodev_crk_op_t { |
183 | */ | 183 | */ |
184 | #define CIOCASYNCCRYPT _IOW('c', 110, struct crypt_op) | 184 | #define CIOCASYNCCRYPT _IOW('c', 110, struct crypt_op) |
185 | #define CIOCASYNCFETCH _IOR('c', 111, struct crypt_op) | 185 | #define CIOCASYNCFETCH _IOR('c', 111, struct crypt_op) |
@@ -189,7 +189,7 @@ index 3ea3d35..575ce63 100644 | |||
189 | +#define CIOCASYMASYNFETCH _IOR('c', 113, struct crypt_kop) | 189 | +#define CIOCASYMASYNFETCH _IOR('c', 113, struct crypt_kop) |
190 | #endif /* L_CRYPTODEV_H */ | 190 | #endif /* L_CRYPTODEV_H */ |
191 | diff --git a/cryptodev_int.h b/cryptodev_int.h | 191 | diff --git a/cryptodev_int.h b/cryptodev_int.h |
192 | index 8891837..b08c253 100644 | 192 | index 8e687e7..fdbcc61 100644 |
193 | --- a/cryptodev_int.h | 193 | --- a/cryptodev_int.h |
194 | +++ b/cryptodev_int.h | 194 | +++ b/cryptodev_int.h |
195 | @@ -1,4 +1,6 @@ | 195 | @@ -1,4 +1,6 @@ |
@@ -200,7 +200,7 @@ index 8891837..b08c253 100644 | |||
200 | #ifndef CRYPTODEV_INT_H | 200 | #ifndef CRYPTODEV_INT_H |
201 | # define CRYPTODEV_INT_H | 201 | # define CRYPTODEV_INT_H |
202 | 202 | ||
203 | @@ -113,6 +115,14 @@ struct compat_crypt_auth_op { | 203 | @@ -112,6 +114,14 @@ struct compat_crypt_auth_op { |
204 | 204 | ||
205 | #endif /* CONFIG_COMPAT */ | 205 | #endif /* CONFIG_COMPAT */ |
206 | 206 | ||
@@ -215,7 +215,7 @@ index 8891837..b08c253 100644 | |||
215 | /* kernel-internal extension to struct crypt_op */ | 215 | /* kernel-internal extension to struct crypt_op */ |
216 | struct kernel_crypt_op { | 216 | struct kernel_crypt_op { |
217 | struct crypt_op cop; | 217 | struct crypt_op cop; |
218 | @@ -158,6 +168,14 @@ int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop); | 218 | @@ -157,6 +167,14 @@ int crypto_run(struct fcrypt *fcr, struct kernel_crypt_op *kcop); |
219 | 219 | ||
220 | #include <cryptlib.h> | 220 | #include <cryptlib.h> |
221 | 221 | ||
@@ -231,7 +231,7 @@ index 8891837..b08c253 100644 | |||
231 | struct csession { | 231 | struct csession { |
232 | struct list_head entry; | 232 | struct list_head entry; |
233 | diff --git a/ioctl.c b/ioctl.c | 233 | diff --git a/ioctl.c b/ioctl.c |
234 | index 63467e0..44070e1 100644 | 234 | index 1563c75..782d7fe 100644 |
235 | --- a/ioctl.c | 235 | --- a/ioctl.c |
236 | +++ b/ioctl.c | 236 | +++ b/ioctl.c |
237 | @@ -4,6 +4,7 @@ | 237 | @@ -4,6 +4,7 @@ |
@@ -242,7 +242,7 @@ index 63467e0..44070e1 100644 | |||
242 | * | 242 | * |
243 | * This file is part of linux cryptodev. | 243 | * This file is part of linux cryptodev. |
244 | * | 244 | * |
245 | @@ -87,8 +88,37 @@ struct crypt_priv { | 245 | @@ -89,8 +90,37 @@ struct crypt_priv { |
246 | int itemcount; | 246 | int itemcount; |
247 | struct work_struct cryptask; | 247 | struct work_struct cryptask; |
248 | wait_queue_head_t user_waiter; | 248 | wait_queue_head_t user_waiter; |
@@ -280,7 +280,7 @@ index 63467e0..44070e1 100644 | |||
280 | #define FILL_SG(sg, ptr, len) \ | 280 | #define FILL_SG(sg, ptr, len) \ |
281 | do { \ | 281 | do { \ |
282 | (sg)->page = virt_to_page(ptr); \ | 282 | (sg)->page = virt_to_page(ptr); \ |
283 | @@ -467,7 +497,8 @@ cryptodev_open(struct inode *inode, struct file *filp) | 283 | @@ -472,7 +502,8 @@ cryptodev_open(struct inode *inode, struct file *filp) |
284 | INIT_LIST_HEAD(&pcr->free.list); | 284 | INIT_LIST_HEAD(&pcr->free.list); |
285 | INIT_LIST_HEAD(&pcr->todo.list); | 285 | INIT_LIST_HEAD(&pcr->todo.list); |
286 | INIT_LIST_HEAD(&pcr->done.list); | 286 | INIT_LIST_HEAD(&pcr->done.list); |
@@ -290,7 +290,7 @@ index 63467e0..44070e1 100644 | |||
290 | INIT_WORK(&pcr->cryptask, cryptask_routine); | 290 | INIT_WORK(&pcr->cryptask, cryptask_routine); |
291 | 291 | ||
292 | init_waitqueue_head(&pcr->user_waiter); | 292 | init_waitqueue_head(&pcr->user_waiter); |
293 | @@ -634,6 +665,79 @@ static int crypto_async_fetch(struct crypt_priv *pcr, | 293 | @@ -639,6 +670,79 @@ static int crypto_async_fetch(struct crypt_priv *pcr, |
294 | } | 294 | } |
295 | #endif | 295 | #endif |
296 | 296 | ||
@@ -370,7 +370,7 @@ index 63467e0..44070e1 100644 | |||
370 | /* this function has to be called from process context */ | 370 | /* this function has to be called from process context */ |
371 | static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) | 371 | static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) |
372 | { | 372 | { |
373 | @@ -657,11 +761,8 @@ static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) | 373 | @@ -662,11 +766,8 @@ static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) |
374 | 374 | ||
375 | if (cop->iv) { | 375 | if (cop->iv) { |
376 | rc = copy_from_user(kcop->iv, cop->iv, kcop->ivlen); | 376 | rc = copy_from_user(kcop->iv, cop->iv, kcop->ivlen); |
@@ -383,7 +383,7 @@ index 63467e0..44070e1 100644 | |||
383 | } | 383 | } |
384 | 384 | ||
385 | return 0; | 385 | return 0; |
386 | @@ -687,6 +788,25 @@ static int fill_cop_from_kcop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) | 386 | @@ -692,6 +793,25 @@ static int fill_cop_from_kcop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) |
387 | return 0; | 387 | return 0; |
388 | } | 388 | } |
389 | 389 | ||
@@ -409,7 +409,7 @@ index 63467e0..44070e1 100644 | |||
409 | static int kcop_from_user(struct kernel_crypt_op *kcop, | 409 | static int kcop_from_user(struct kernel_crypt_op *kcop, |
410 | struct fcrypt *fcr, void __user *arg) | 410 | struct fcrypt *fcr, void __user *arg) |
411 | { | 411 | { |
412 | @@ -816,7 +936,8 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 412 | @@ -821,7 +941,8 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
413 | 413 | ||
414 | switch (cmd) { | 414 | switch (cmd) { |
415 | case CIOCASYMFEAT: | 415 | case CIOCASYMFEAT: |
@@ -419,7 +419,7 @@ index 63467e0..44070e1 100644 | |||
419 | case CRIOGET: | 419 | case CRIOGET: |
420 | fd = clonefd(filp); | 420 | fd = clonefd(filp); |
421 | ret = put_user(fd, p); | 421 | ret = put_user(fd, p); |
422 | @@ -852,6 +973,24 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 422 | @@ -857,6 +978,24 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
423 | if (unlikely(ret)) | 423 | if (unlikely(ret)) |
424 | return ret; | 424 | return ret; |
425 | return copy_to_user(arg, &siop, sizeof(siop)); | 425 | return copy_to_user(arg, &siop, sizeof(siop)); |
@@ -444,7 +444,7 @@ index 63467e0..44070e1 100644 | |||
444 | case CIOCCRYPT: | 444 | case CIOCCRYPT: |
445 | if (unlikely(ret = kcop_from_user(&kcop, fcr, arg))) { | 445 | if (unlikely(ret = kcop_from_user(&kcop, fcr, arg))) { |
446 | dwarning(1, "Error copying from user"); | 446 | dwarning(1, "Error copying from user"); |
447 | @@ -890,6 +1029,45 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 447 | @@ -895,6 +1034,45 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
448 | 448 | ||
449 | return kcop_to_user(&kcop, fcr, arg); | 449 | return kcop_to_user(&kcop, fcr, arg); |
450 | #endif | 450 | #endif |
@@ -490,7 +490,7 @@ index 63467e0..44070e1 100644 | |||
490 | default: | 490 | default: |
491 | return -EINVAL; | 491 | return -EINVAL; |
492 | } | 492 | } |
493 | @@ -1078,9 +1256,11 @@ static unsigned int cryptodev_poll(struct file *file, poll_table *wait) | 493 | @@ -1083,9 +1261,11 @@ static unsigned int cryptodev_poll(struct file *file, poll_table *wait) |
494 | 494 | ||
495 | poll_wait(file, &pcr->user_waiter, wait); | 495 | poll_wait(file, &pcr->user_waiter, wait); |
496 | 496 | ||
@@ -894,5 +894,5 @@ index 57e5c38..0b7951e 100644 | |||
894 | { | 894 | { |
895 | struct csession *ses_ptr; | 895 | struct csession *ses_ptr; |
896 | -- | 896 | -- |
897 | 1.7.9.7 | 897 | 1.8.3.1 |
898 | 898 | ||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0010-Compat-versions-of-PKC-IOCTLs.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0004-Compat-versions-of-PKC-IOCTLs.patch index 03204625..2eedcc72 100644 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0010-Compat-versions-of-PKC-IOCTLs.patch +++ b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0004-Compat-versions-of-PKC-IOCTLs.patch | |||
@@ -1,18 +1,18 @@ | |||
1 | From f6550035fe2c0e66798ace17d31d1d880beacc14 Mon Sep 17 00:00:00 2001 | 1 | From 5435dfd329cd90837ce36c6dadc26166c7906cab Mon Sep 17 00:00:00 2001 |
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | 2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> |
3 | Date: Fri, 7 Mar 2014 06:52:13 +0545 | 3 | Date: Fri, 7 Mar 2014 06:52:13 +0545 |
4 | Subject: [[Patch][fsl 10/16] Compat versions of PKC IOCTLs | 4 | Subject: [PATCH 4/9] Compat versions of PKC IOCTLs |
5 | 5 | ||
6 | Upstream-status: Pending | 6 | Upstream-status: Pending |
7 | 7 | ||
8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | 8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> |
9 | --- | 9 | --- |
10 | cryptodev_int.h | 20 ++++++++++ | 10 | cryptodev_int.h | 20 ++++++++++ |
11 | ioctl.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ | 11 | ioctl.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
12 | 2 files changed, 140 insertions(+) | 12 | 2 files changed, 140 insertions(+) |
13 | 13 | ||
14 | diff --git a/cryptodev_int.h b/cryptodev_int.h | 14 | diff --git a/cryptodev_int.h b/cryptodev_int.h |
15 | index b08c253..229fcd0 100644 | 15 | index fdbcc61..cf54dac 100644 |
16 | --- a/cryptodev_int.h | 16 | --- a/cryptodev_int.h |
17 | +++ b/cryptodev_int.h | 17 | +++ b/cryptodev_int.h |
18 | @@ -75,6 +75,24 @@ struct compat_crypt_op { | 18 | @@ -75,6 +75,24 @@ struct compat_crypt_op { |
@@ -40,7 +40,7 @@ index b08c253..229fcd0 100644 | |||
40 | /* input of CIOCAUTHCRYPT */ | 40 | /* input of CIOCAUTHCRYPT */ |
41 | struct compat_crypt_auth_op { | 41 | struct compat_crypt_auth_op { |
42 | uint32_t ses; /* session identifier */ | 42 | uint32_t ses; /* session identifier */ |
43 | @@ -112,6 +130,8 @@ struct compat_crypt_auth_op { | 43 | @@ -111,6 +129,8 @@ struct compat_crypt_auth_op { |
44 | #define COMPAT_CIOCASYNCCRYPT _IOW('c', 107, struct compat_crypt_op) | 44 | #define COMPAT_CIOCASYNCCRYPT _IOW('c', 107, struct compat_crypt_op) |
45 | #define COMPAT_CIOCASYNCFETCH _IOR('c', 108, struct compat_crypt_op) | 45 | #define COMPAT_CIOCASYNCFETCH _IOR('c', 108, struct compat_crypt_op) |
46 | #define COMPAT_CIOCAUTHCRYPT _IOWR('c', 109, struct compat_crypt_auth_op) | 46 | #define COMPAT_CIOCAUTHCRYPT _IOWR('c', 109, struct compat_crypt_auth_op) |
@@ -50,10 +50,10 @@ index b08c253..229fcd0 100644 | |||
50 | #endif /* CONFIG_COMPAT */ | 50 | #endif /* CONFIG_COMPAT */ |
51 | 51 | ||
52 | diff --git a/ioctl.c b/ioctl.c | 52 | diff --git a/ioctl.c b/ioctl.c |
53 | index 44070e1..ec82c69 100644 | 53 | index 782d7fe..3baf3e6 100644 |
54 | --- a/ioctl.c | 54 | --- a/ioctl.c |
55 | +++ b/ioctl.c | 55 | +++ b/ioctl.c |
56 | @@ -1076,6 +1076,68 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 56 | @@ -1081,6 +1081,68 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
57 | /* compatibility code for 32bit userlands */ | 57 | /* compatibility code for 32bit userlands */ |
58 | #ifdef CONFIG_COMPAT | 58 | #ifdef CONFIG_COMPAT |
59 | 59 | ||
@@ -122,7 +122,7 @@ index 44070e1..ec82c69 100644 | |||
122 | static inline void | 122 | static inline void |
123 | compat_to_session_op(struct compat_session_op *compat, struct session_op *sop) | 123 | compat_to_session_op(struct compat_session_op *compat, struct session_op *sop) |
124 | { | 124 | { |
125 | @@ -1203,7 +1265,26 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | 125 | @@ -1208,7 +1270,26 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) |
126 | return -EFAULT; | 126 | return -EFAULT; |
127 | } | 127 | } |
128 | return ret; | 128 | return ret; |
@@ -149,7 +149,7 @@ index 44070e1..ec82c69 100644 | |||
149 | case COMPAT_CIOCCRYPT: | 149 | case COMPAT_CIOCCRYPT: |
150 | ret = compat_kcop_from_user(&kcop, fcr, arg); | 150 | ret = compat_kcop_from_user(&kcop, fcr, arg); |
151 | if (unlikely(ret)) | 151 | if (unlikely(ret)) |
152 | @@ -1242,6 +1323,45 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | 152 | @@ -1247,6 +1328,45 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) |
153 | 153 | ||
154 | return compat_kcop_to_user(&kcop, fcr, arg); | 154 | return compat_kcop_to_user(&kcop, fcr, arg); |
155 | #endif | 155 | #endif |
@@ -196,5 +196,5 @@ index 44070e1..ec82c69 100644 | |||
196 | return -EINVAL; | 196 | return -EINVAL; |
197 | } | 197 | } |
198 | -- | 198 | -- |
199 | 1.7.9.7 | 199 | 1.8.3.1 |
200 | 200 | ||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0004-fix-scatterlist-size-for-in-place-operations.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0004-fix-scatterlist-size-for-in-place-operations.patch deleted file mode 100644 index c8086062..00000000 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0004-fix-scatterlist-size-for-in-place-operations.patch +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
1 | From 5a6cd042d3cee9e3bbf3b0125a89e64d75dffdc7 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Thu, 31 Oct 2013 13:13:51 +0200 | ||
4 | Subject: [[Patch][fsl 04/16] fix scatterlist size for in-place operations | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | For in-place operations, the scatterlist must be big enough to allow for | ||
9 | either the source or destination data: | ||
10 | - for block ciphers, the destination will be bigger than the source if | ||
11 | the source is not multiple of blocksize | ||
12 | - for aead ciphers, the additional data and padding guarantees the | ||
13 | destination to be bigger than the source. | ||
14 | |||
15 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
16 | Tested-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> | ||
17 | --- | ||
18 | zc.c | 5 +++-- | ||
19 | 1 file changed, 3 insertions(+), 2 deletions(-) | ||
20 | |||
21 | diff --git a/zc.c b/zc.c | ||
22 | index 809a36d..8855083 100644 | ||
23 | --- a/zc.c | ||
24 | +++ b/zc.c | ||
25 | @@ -162,8 +162,9 @@ int get_userbuf(struct csession *ses, | ||
26 | } | ||
27 | |||
28 | if (src == dst) { /* inplace operation */ | ||
29 | - rc = __get_userbuf(src, src_len, 1, ses->used_pages, | ||
30 | - ses->pages, ses->sg, task, mm); | ||
31 | + rc = __get_userbuf(src, max(src_len, dst_len), 1, ses->used_pages, | ||
32 | + ses->pages, ses->sg, task, mm); | ||
33 | + | ||
34 | if (unlikely(rc)) { | ||
35 | derr(1, "failed to get user pages for data IO"); | ||
36 | return rc; | ||
37 | -- | ||
38 | 1.7.9.7 | ||
39 | |||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0011-Asynchronous-interface-changes-in-cryptodev.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0005-Asynchronous-interface-changes-in-cryptodev.patch index 5331abc6..2f88eda3 100644 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0011-Asynchronous-interface-changes-in-cryptodev.patch +++ b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0005-Asynchronous-interface-changes-in-cryptodev.patch | |||
@@ -1,20 +1,20 @@ | |||
1 | From ffa8fd090afaf3631e6abd0ab8daa6780be7c31c Mon Sep 17 00:00:00 2001 | 1 | From ddc4179a454cea79c8385fd6756d20cbf3c6dcb5 Mon Sep 17 00:00:00 2001 |
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | 2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> |
3 | Date: Fri, 7 Mar 2014 07:24:00 +0545 | 3 | Date: Fri, 7 Mar 2014 07:24:00 +0545 |
4 | Subject: [[Patch][fsl 11/16] Asynchronous interface changes in cryptodev | 4 | Subject: [PATCH 5/9] Asynchronous interface changes in cryptodev |
5 | 5 | ||
6 | Upstream-status: Pending | 6 | Upstream-status: Pending |
7 | 7 | ||
8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | 8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> |
9 | --- | 9 | --- |
10 | cryptlib.h | 7 ++++- | 10 | cryptlib.h | 7 ++++- |
11 | crypto/cryptodev.h | 10 ++++++- | 11 | crypto/cryptodev.h | 10 ++++++- |
12 | cryptodev_int.h | 10 ++++++- | 12 | cryptodev_int.h | 10 ++++++- |
13 | ioctl.c | 76 +++++++++++++++++++++++++++++++++++----------------- | 13 | ioctl.c | 76 +++++++++++++++++++++++++++++++++++++----------------- |
14 | 4 files changed, 76 insertions(+), 27 deletions(-) | 14 | 4 files changed, 76 insertions(+), 27 deletions(-) |
15 | 15 | ||
16 | diff --git a/cryptlib.h b/cryptlib.h | 16 | diff --git a/cryptlib.h b/cryptlib.h |
17 | index e77edc5..947d845 100644 | 17 | index 56d325a..7ffa54c 100644 |
18 | --- a/cryptlib.h | 18 | --- a/cryptlib.h |
19 | +++ b/cryptlib.h | 19 | +++ b/cryptlib.h |
20 | @@ -113,7 +113,12 @@ struct cryptodev_pkc { | 20 | @@ -113,7 +113,12 @@ struct cryptodev_pkc { |
@@ -32,10 +32,10 @@ index e77edc5..947d845 100644 | |||
32 | }; | 32 | }; |
33 | 33 | ||
34 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | 34 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h |
35 | index 575ce63..0d65899 100644 | 35 | index 96675fe..4436fbf 100644 |
36 | --- a/crypto/cryptodev.h | 36 | --- a/crypto/cryptodev.h |
37 | +++ b/crypto/cryptodev.h | 37 | +++ b/crypto/cryptodev.h |
38 | @@ -255,6 +255,14 @@ struct crypt_kop { | 38 | @@ -254,6 +254,14 @@ struct crypt_kop { |
39 | void *cookie; | 39 | void *cookie; |
40 | }; | 40 | }; |
41 | 41 | ||
@@ -50,7 +50,7 @@ index 575ce63..0d65899 100644 | |||
50 | enum cryptodev_crk_op_t { | 50 | enum cryptodev_crk_op_t { |
51 | CRK_MOD_EXP = 0, | 51 | CRK_MOD_EXP = 0, |
52 | CRK_MOD_EXP_CRT = 1, | 52 | CRK_MOD_EXP_CRT = 1, |
53 | @@ -299,5 +307,5 @@ enum cryptodev_crk_op_t { | 53 | @@ -298,5 +306,5 @@ enum cryptodev_crk_op_t { |
54 | #define CIOCASYNCFETCH _IOR('c', 111, struct crypt_op) | 54 | #define CIOCASYNCFETCH _IOR('c', 111, struct crypt_op) |
55 | /* additional ioctls for asynchronous operation for asymmetric ciphers*/ | 55 | /* additional ioctls for asynchronous operation for asymmetric ciphers*/ |
56 | #define CIOCASYMASYNCRYPT _IOW('c', 112, struct crypt_kop) | 56 | #define CIOCASYMASYNCRYPT _IOW('c', 112, struct crypt_kop) |
@@ -58,7 +58,7 @@ index 575ce63..0d65899 100644 | |||
58 | +#define CIOCASYMFETCHCOOKIE _IOR('c', 113, struct pkc_cookie_list_s) | 58 | +#define CIOCASYMFETCHCOOKIE _IOR('c', 113, struct pkc_cookie_list_s) |
59 | #endif /* L_CRYPTODEV_H */ | 59 | #endif /* L_CRYPTODEV_H */ |
60 | diff --git a/cryptodev_int.h b/cryptodev_int.h | 60 | diff --git a/cryptodev_int.h b/cryptodev_int.h |
61 | index 229fcd0..8beeef0 100644 | 61 | index cf54dac..5347cae 100644 |
62 | --- a/cryptodev_int.h | 62 | --- a/cryptodev_int.h |
63 | +++ b/cryptodev_int.h | 63 | +++ b/cryptodev_int.h |
64 | @@ -93,6 +93,12 @@ struct compat_crypt_kop { | 64 | @@ -93,6 +93,12 @@ struct compat_crypt_kop { |
@@ -74,7 +74,7 @@ index 229fcd0..8beeef0 100644 | |||
74 | /* input of CIOCAUTHCRYPT */ | 74 | /* input of CIOCAUTHCRYPT */ |
75 | struct compat_crypt_auth_op { | 75 | struct compat_crypt_auth_op { |
76 | uint32_t ses; /* session identifier */ | 76 | uint32_t ses; /* session identifier */ |
77 | @@ -127,11 +133,13 @@ struct compat_crypt_auth_op { | 77 | @@ -126,11 +132,13 @@ struct compat_crypt_auth_op { |
78 | /* compat ioctls, defined for the above structs */ | 78 | /* compat ioctls, defined for the above structs */ |
79 | #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op) | 79 | #define COMPAT_CIOCGSESSION _IOWR('c', 102, struct compat_session_op) |
80 | #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op) | 80 | #define COMPAT_CIOCCRYPT _IOWR('c', 104, struct compat_crypt_op) |
@@ -90,10 +90,10 @@ index 229fcd0..8beeef0 100644 | |||
90 | #endif /* CONFIG_COMPAT */ | 90 | #endif /* CONFIG_COMPAT */ |
91 | 91 | ||
92 | diff --git a/ioctl.c b/ioctl.c | 92 | diff --git a/ioctl.c b/ioctl.c |
93 | index ec82c69..9f57d46 100644 | 93 | index 3baf3e6..2eb7f03 100644 |
94 | --- a/ioctl.c | 94 | --- a/ioctl.c |
95 | +++ b/ioctl.c | 95 | +++ b/ioctl.c |
96 | @@ -103,8 +103,6 @@ void cryptodev_complete_asym(struct crypto_async_request *req, int err) | 96 | @@ -105,8 +105,6 @@ void cryptodev_complete_asym(struct crypto_async_request *req, int err) |
97 | crypto_free_pkc(pkc->s); | 97 | crypto_free_pkc(pkc->s); |
98 | res->err = err; | 98 | res->err = err; |
99 | if (pkc->type == SYNCHRONOUS) { | 99 | if (pkc->type == SYNCHRONOUS) { |
@@ -102,7 +102,7 @@ index ec82c69..9f57d46 100644 | |||
102 | complete(&res->completion); | 102 | complete(&res->completion); |
103 | } else { | 103 | } else { |
104 | struct crypt_priv *pcr = pkc->priv; | 104 | struct crypt_priv *pcr = pkc->priv; |
105 | @@ -1046,26 +1044,41 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 105 | @@ -1051,26 +1049,41 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
106 | ret = 0; | 106 | ret = 0; |
107 | } | 107 | } |
108 | return ret; | 108 | return ret; |
@@ -155,7 +155,7 @@ index ec82c69..9f57d46 100644 | |||
155 | } | 155 | } |
156 | return ret; | 156 | return ret; |
157 | default: | 157 | default: |
158 | @@ -1340,26 +1353,41 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | 158 | @@ -1345,26 +1358,41 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) |
159 | ret = 0; | 159 | ret = 0; |
160 | } | 160 | } |
161 | return ret; | 161 | return ret; |
@@ -209,5 +209,5 @@ index ec82c69..9f57d46 100644 | |||
209 | return ret; | 209 | return ret; |
210 | default: | 210 | default: |
211 | -- | 211 | -- |
212 | 1.7.9.7 | 212 | 1.8.3.1 |
213 | 213 | ||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0005-add-dst_len-parameter-to-be-provided-by-the-user.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0005-add-dst_len-parameter-to-be-provided-by-the-user.patch deleted file mode 100644 index 480d2a93..00000000 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0005-add-dst_len-parameter-to-be-provided-by-the-user.patch +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | From e673e6ec09770b624d524bcd82f911e4fe2e2075 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Thu, 31 Oct 2013 13:27:28 +0200 | ||
4 | Subject: [[Patch][fsl 05/16] add dst_len parameter to be provided by the user | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | This allows the user to set the result length and relieves cryptodev | ||
9 | from making assumptions about it. | ||
10 | |||
11 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
12 | Tested-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> | ||
13 | --- | ||
14 | authenc.c | 13 +++---------- | ||
15 | crypto/cryptodev.h | 1 + | ||
16 | 2 files changed, 4 insertions(+), 10 deletions(-) | ||
17 | |||
18 | diff --git a/authenc.c b/authenc.c | ||
19 | index a183820..5235973 100644 | ||
20 | --- a/authenc.c | ||
21 | +++ b/authenc.c | ||
22 | @@ -199,7 +199,7 @@ static int fill_kcaop_from_caop(struct kernel_crypt_auth_op *kcaop, struct fcryp | ||
23 | kcaop->ivlen = caop->iv ? ses_ptr->cdata.ivsize : 0; | ||
24 | |||
25 | if (caop->flags & COP_FLAG_AEAD_TLS_TYPE) | ||
26 | - kcaop->dst_len = caop->len + ses_ptr->cdata.blocksize /* pad */ + caop->tag_len; | ||
27 | + kcaop->dst_len = caop->dst_len; | ||
28 | else | ||
29 | kcaop->dst_len = caop->len; | ||
30 | |||
31 | @@ -645,8 +645,6 @@ __crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcao | ||
32 | ret = tls_auth_n_crypt(ses_ptr, kcaop, auth_sg, caop->auth_len, | ||
33 | dst_sg, caop->len); | ||
34 | } else { | ||
35 | - int dst_len; | ||
36 | - | ||
37 | if (unlikely(ses_ptr->cdata.init == 0 || | ||
38 | (ses_ptr->cdata.stream == 0 && | ||
39 | ses_ptr->cdata.aead == 0))) { | ||
40 | @@ -655,13 +653,8 @@ __crypto_auth_run_zc(struct csession *ses_ptr, struct kernel_crypt_auth_op *kcao | ||
41 | goto free_auth_buf; | ||
42 | } | ||
43 | |||
44 | - if (caop->op == COP_ENCRYPT) | ||
45 | - dst_len = caop->len + cryptodev_cipher_get_tag_size(&ses_ptr->cdata); | ||
46 | - else | ||
47 | - dst_len = caop->len; | ||
48 | - | ||
49 | - ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, dst_len, | ||
50 | - kcaop->task, kcaop->mm, &src_sg, &dst_sg); | ||
51 | + ret = get_userbuf(ses_ptr, caop->src, caop->len, caop->dst, | ||
52 | + caop->dst_len, kcaop->task, kcaop->mm, &src_sg, &dst_sg); | ||
53 | if (unlikely(ret)) { | ||
54 | derr(1, "get_userbuf(): Error getting user pages."); | ||
55 | goto free_auth_buf; | ||
56 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | ||
57 | index c0e8cd4..3ea3d35 100644 | ||
58 | --- a/crypto/cryptodev.h | ||
59 | +++ b/crypto/cryptodev.h | ||
60 | @@ -137,6 +137,7 @@ struct crypt_auth_op { | ||
61 | __u16 op; /* COP_ENCRYPT or COP_DECRYPT */ | ||
62 | __u16 flags; /* see COP_FLAG_AEAD_* */ | ||
63 | __u32 len; /* length of source data */ | ||
64 | + __u32 dst_len; /* length of result data */ | ||
65 | __u32 auth_len; /* length of auth data */ | ||
66 | __u8 __user *auth_src; /* authenticated-only data */ | ||
67 | |||
68 | -- | ||
69 | 1.7.9.7 | ||
70 | |||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0012-ECC_KEYGEN-and-DLC_KEYGEN-supported-in-cryptodev-mod.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0006-ECC_KEYGEN-and-DLC_KEYGEN-supported-in-cryptodev-mod.patch index acb5bea7..e70a057b 100644 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0012-ECC_KEYGEN-and-DLC_KEYGEN-supported-in-cryptodev-mod.patch +++ b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0006-ECC_KEYGEN-and-DLC_KEYGEN-supported-in-cryptodev-mod.patch | |||
@@ -1,24 +1,23 @@ | |||
1 | From bda8dd5839da7a8e731b60b64b9fcb531c334b99 Mon Sep 17 00:00:00 2001 | 1 | From 30fc86a09109f169815befc2cd8bbfcae79fe7e0 Mon Sep 17 00:00:00 2001 |
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | 2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> |
3 | Date: Fri, 7 Mar 2014 07:53:53 +0545 | 3 | Date: Fri, 7 Mar 2014 07:53:53 +0545 |
4 | Subject: [[Patch][fsl 12/16] ECC_KEYGEN and DLC_KEYGEN supported in cryptodev | 4 | Subject: [PATCH 6/9] ECC_KEYGEN and DLC_KEYGEN supported in cryptodev module |
5 | module | ||
6 | 5 | ||
7 | Upstream-status: Pending | 6 | Upstream-status: Pending |
8 | 7 | ||
9 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | 8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> |
10 | --- | 9 | --- |
11 | cryptlib.c | 2 ++ | 10 | cryptlib.c | 2 ++ |
12 | crypto/cryptodev.h | 5 +++- | 11 | crypto/cryptodev.h | 5 +++- |
13 | ioctl.c | 29 ++++++++++++++++-- | 12 | ioctl.c | 29 +++++++++++++++++-- |
14 | main.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++ | 13 | main.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
15 | 4 files changed, 118 insertions(+), 3 deletions(-) | 14 | 4 files changed, 118 insertions(+), 3 deletions(-) |
16 | 15 | ||
17 | diff --git a/cryptlib.c b/cryptlib.c | 16 | diff --git a/cryptlib.c b/cryptlib.c |
18 | index fa0b63f..41acb2c 100644 | 17 | index 6900028..47cd568 100644 |
19 | --- a/cryptlib.c | 18 | --- a/cryptlib.c |
20 | +++ b/cryptlib.c | 19 | +++ b/cryptlib.c |
21 | @@ -437,6 +437,8 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | 20 | @@ -452,6 +452,8 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) |
22 | case DSA_VERIFY: | 21 | case DSA_VERIFY: |
23 | case ECDSA_SIGN: | 22 | case ECDSA_SIGN: |
24 | case ECDSA_VERIFY: | 23 | case ECDSA_VERIFY: |
@@ -28,10 +27,10 @@ index fa0b63f..41acb2c 100644 | |||
28 | CRYPTO_ALG_TYPE_PKC_DSA, 0); | 27 | CRYPTO_ALG_TYPE_PKC_DSA, 0); |
29 | break; | 28 | break; |
30 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | 29 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h |
31 | index 0d65899..33cca2e 100644 | 30 | index 4436fbf..275a55c 100644 |
32 | --- a/crypto/cryptodev.h | 31 | --- a/crypto/cryptodev.h |
33 | +++ b/crypto/cryptodev.h | 32 | +++ b/crypto/cryptodev.h |
34 | @@ -269,6 +269,8 @@ enum cryptodev_crk_op_t { | 33 | @@ -268,6 +268,8 @@ enum cryptodev_crk_op_t { |
35 | CRK_DSA_SIGN = 2, | 34 | CRK_DSA_SIGN = 2, |
36 | CRK_DSA_VERIFY = 3, | 35 | CRK_DSA_VERIFY = 3, |
37 | CRK_DH_COMPUTE_KEY = 4, | 36 | CRK_DH_COMPUTE_KEY = 4, |
@@ -40,7 +39,7 @@ index 0d65899..33cca2e 100644 | |||
40 | CRK_ALGORITHM_ALL | 39 | CRK_ALGORITHM_ALL |
41 | }; | 40 | }; |
42 | 41 | ||
43 | @@ -281,7 +283,8 @@ enum cryptodev_crk_op_t { | 42 | @@ -280,7 +282,8 @@ enum cryptodev_crk_op_t { |
44 | #define CRF_DSA_SIGN (1 << CRK_DSA_SIGN) | 43 | #define CRF_DSA_SIGN (1 << CRK_DSA_SIGN) |
45 | #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY) | 44 | #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY) |
46 | #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY) | 45 | #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY) |
@@ -51,10 +50,10 @@ index 0d65899..33cca2e 100644 | |||
51 | /* ioctl's. Compatible with old linux cryptodev.h | 50 | /* ioctl's. Compatible with old linux cryptodev.h |
52 | */ | 51 | */ |
53 | diff --git a/ioctl.c b/ioctl.c | 52 | diff --git a/ioctl.c b/ioctl.c |
54 | index 9f57d46..cc1a2a9 100644 | 53 | index 2eb7f03..c813c8c 100644 |
55 | --- a/ioctl.c | 54 | --- a/ioctl.c |
56 | +++ b/ioctl.c | 55 | +++ b/ioctl.c |
57 | @@ -721,6 +721,23 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | 56 | @@ -726,6 +726,23 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) |
58 | dh_req->z, dh_req->z_len); | 57 | dh_req->z, dh_req->z_len); |
59 | } | 58 | } |
60 | break; | 59 | break; |
@@ -78,7 +77,7 @@ index 9f57d46..cc1a2a9 100644 | |||
78 | default: | 77 | default: |
79 | ret = -EINVAL; | 78 | ret = -EINVAL; |
80 | } | 79 | } |
81 | @@ -934,8 +951,9 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 80 | @@ -939,8 +956,9 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
82 | 81 | ||
83 | switch (cmd) { | 82 | switch (cmd) { |
84 | case CIOCASYMFEAT: | 83 | case CIOCASYMFEAT: |
@@ -90,7 +89,7 @@ index 9f57d46..cc1a2a9 100644 | |||
90 | case CRIOGET: | 89 | case CRIOGET: |
91 | fd = clonefd(filp); | 90 | fd = clonefd(filp); |
92 | ret = put_user(fd, p); | 91 | ret = put_user(fd, p); |
93 | @@ -1079,7 +1097,14 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 92 | @@ -1084,7 +1102,14 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
94 | if (cookie_list.cookie_available) | 93 | if (cookie_list.cookie_available) |
95 | copy_to_user(arg, &cookie_list, | 94 | copy_to_user(arg, &cookie_list, |
96 | sizeof(struct pkc_cookie_list_s)); | 95 | sizeof(struct pkc_cookie_list_s)); |
@@ -209,5 +208,5 @@ index 0b7951e..c901bc7 100644 | |||
209 | err: | 208 | err: |
210 | return ret; | 209 | return ret; |
211 | -- | 210 | -- |
212 | 1.7.9.7 | 211 | 1.8.3.1 |
213 | 212 | ||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0006-fix-build-error-on-some-targets.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0006-fix-build-error-on-some-targets.patch deleted file mode 100644 index 510dee09..00000000 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0006-fix-build-error-on-some-targets.patch +++ /dev/null | |||
@@ -1,64 +0,0 @@ | |||
1 | From 69e00f8c1633dfe6da20ccd0cf363a481c99fc97 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Wed, 20 Nov 2013 11:29:50 +0200 | ||
4 | Subject: [[Patch][fsl 06/16] fix build error on some targets | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | This updates incomplete patch f681e2e5fd1088bfe0aafd1ae2560c1dc9d04778 | ||
9 | and allows building main.o | ||
10 | |||
11 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
12 | Tested-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> | ||
13 | --- | ||
14 | cryptlib.c | 4 ++-- | ||
15 | cryptlib.h | 4 ++-- | ||
16 | 2 files changed, 4 insertions(+), 4 deletions(-) | ||
17 | |||
18 | diff --git a/cryptlib.c b/cryptlib.c | ||
19 | index 2986d09..3576f39 100644 | ||
20 | --- a/cryptlib.c | ||
21 | +++ b/cryptlib.c | ||
22 | @@ -113,7 +113,7 @@ error: | ||
23 | |||
24 | |||
25 | int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
26 | - uint8_t *keyp, size_t keylen, int stream, int aead) | ||
27 | + uint8_t *keyp, unsigned int keylen, int stream, int aead) | ||
28 | { | ||
29 | int ret; | ||
30 | |||
31 | @@ -313,7 +313,7 @@ ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, | ||
32 | /* Hash functions */ | ||
33 | |||
34 | int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, | ||
35 | - int hmac_mode, void *mackey, size_t mackeylen) | ||
36 | + int hmac_mode, void *mackey, unsigned int mackeylen) | ||
37 | { | ||
38 | int ret; | ||
39 | |||
40 | diff --git a/cryptlib.h b/cryptlib.h | ||
41 | index a0a8a63..4cb66ad 100644 | ||
42 | --- a/cryptlib.h | ||
43 | +++ b/cryptlib.h | ||
44 | @@ -23,7 +23,7 @@ struct cipher_data { | ||
45 | }; | ||
46 | |||
47 | int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
48 | - uint8_t *key, size_t keylen, int stream, int aead); | ||
49 | + uint8_t *key, unsigned int keylen, int stream, int aead); | ||
50 | void cryptodev_cipher_deinit(struct cipher_data *cdata); | ||
51 | int cryptodev_get_cipher_key(uint8_t *key, struct session_op *sop, int aead); | ||
52 | int cryptodev_get_cipher_keylen(unsigned int *keylen, struct session_op *sop, | ||
53 | @@ -87,7 +87,7 @@ ssize_t cryptodev_hash_update(struct hash_data *hdata, | ||
54 | int cryptodev_hash_reset(struct hash_data *hdata); | ||
55 | void cryptodev_hash_deinit(struct hash_data *hdata); | ||
56 | int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, | ||
57 | - int hmac_mode, void *mackey, size_t mackeylen); | ||
58 | + int hmac_mode, void *mackey, unsigned int mackeylen); | ||
59 | |||
60 | |||
61 | #endif | ||
62 | -- | ||
63 | 1.7.9.7 | ||
64 | |||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0013-RCU-stall-fixed-in-PKC-asynchronous-interface.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0007-RCU-stall-fixed-in-PKC-asynchronous-interface.patch index 26c01689..93a2248c 100644 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0013-RCU-stall-fixed-in-PKC-asynchronous-interface.patch +++ b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0007-RCU-stall-fixed-in-PKC-asynchronous-interface.patch | |||
@@ -1,21 +1,21 @@ | |||
1 | From 211a494a4f8ee6d5d31a1db938b771958ea32c6b Mon Sep 17 00:00:00 2001 | 1 | From d60b9dbf53d63092fd292c00bb03c250c26703cf Mon Sep 17 00:00:00 2001 |
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | 2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> |
3 | Date: Fri, 7 Mar 2014 08:49:15 +0545 | 3 | Date: Fri, 7 Mar 2014 08:49:15 +0545 |
4 | Subject: [[Patch][fsl 13/16] RCU stall fixed in PKC asynchronous interface | 4 | Subject: [PATCH 7/9] RCU stall fixed in PKC asynchronous interface |
5 | 5 | ||
6 | Upstream-status: Pending | 6 | Upstream-status: Pending |
7 | 7 | ||
8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | 8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> |
9 | --- | 9 | --- |
10 | ioctl.c | 23 +++++++++++------------ | 10 | ioctl.c | 23 +++++++++++------------ |
11 | main.c | 43 +++++++++++++++++++++++++++---------------- | 11 | main.c | 43 +++++++++++++++++++++++++++---------------- |
12 | 2 files changed, 38 insertions(+), 28 deletions(-) | 12 | 2 files changed, 38 insertions(+), 28 deletions(-) |
13 | 13 | ||
14 | diff --git a/ioctl.c b/ioctl.c | 14 | diff --git a/ioctl.c b/ioctl.c |
15 | index cc1a2a9..1752880 100644 | 15 | index c813c8c..7e4c671 100644 |
16 | --- a/ioctl.c | 16 | --- a/ioctl.c |
17 | +++ b/ioctl.c | 17 | +++ b/ioctl.c |
18 | @@ -106,10 +106,9 @@ void cryptodev_complete_asym(struct crypto_async_request *req, int err) | 18 | @@ -108,10 +108,9 @@ void cryptodev_complete_asym(struct crypto_async_request *req, int err) |
19 | complete(&res->completion); | 19 | complete(&res->completion); |
20 | } else { | 20 | } else { |
21 | struct crypt_priv *pcr = pkc->priv; | 21 | struct crypt_priv *pcr = pkc->priv; |
@@ -28,7 +28,7 @@ index cc1a2a9..1752880 100644 | |||
28 | /* wake for POLLIN */ | 28 | /* wake for POLLIN */ |
29 | wake_up_interruptible(&pcr->user_waiter); | 29 | wake_up_interruptible(&pcr->user_waiter); |
30 | } | 30 | } |
31 | @@ -953,7 +952,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 31 | @@ -958,7 +957,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
32 | case CIOCASYMFEAT: | 32 | case CIOCASYMFEAT: |
33 | return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_DSA_SIGN | | 33 | return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_DSA_SIGN | |
34 | CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY | | 34 | CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY | |
@@ -37,7 +37,7 @@ index cc1a2a9..1752880 100644 | |||
37 | case CRIOGET: | 37 | case CRIOGET: |
38 | fd = clonefd(filp); | 38 | fd = clonefd(filp); |
39 | ret = put_user(fd, p); | 39 | ret = put_user(fd, p); |
40 | @@ -992,7 +991,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 40 | @@ -997,7 +996,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
41 | case CIOCKEY: | 41 | case CIOCKEY: |
42 | { | 42 | { |
43 | struct cryptodev_pkc *pkc = | 43 | struct cryptodev_pkc *pkc = |
@@ -46,7 +46,7 @@ index cc1a2a9..1752880 100644 | |||
46 | 46 | ||
47 | if (!pkc) | 47 | if (!pkc) |
48 | return -ENOMEM; | 48 | return -ENOMEM; |
49 | @@ -1048,7 +1047,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 49 | @@ -1053,7 +1052,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
50 | case CIOCASYMASYNCRYPT: | 50 | case CIOCASYMASYNCRYPT: |
51 | { | 51 | { |
52 | struct cryptodev_pkc *pkc = | 52 | struct cryptodev_pkc *pkc = |
@@ -55,7 +55,7 @@ index cc1a2a9..1752880 100644 | |||
55 | ret = kop_from_user(&pkc->kop, arg); | 55 | ret = kop_from_user(&pkc->kop, arg); |
56 | 56 | ||
57 | if (unlikely(ret)) | 57 | if (unlikely(ret)) |
58 | @@ -1065,13 +1064,12 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 58 | @@ -1070,13 +1069,12 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
59 | case CIOCASYMFETCHCOOKIE: | 59 | case CIOCASYMFETCHCOOKIE: |
60 | { | 60 | { |
61 | struct cryptodev_pkc *pkc; | 61 | struct cryptodev_pkc *pkc; |
@@ -70,7 +70,7 @@ index cc1a2a9..1752880 100644 | |||
70 | if (!list_empty(&pcr->asym_completed_list)) { | 70 | if (!list_empty(&pcr->asym_completed_list)) { |
71 | /* Run a loop in the list for upto elements | 71 | /* Run a loop in the list for upto elements |
72 | and copy their response back */ | 72 | and copy their response back */ |
73 | @@ -1079,6 +1077,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 73 | @@ -1084,6 +1082,7 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
74 | list_first_entry(&pcr->asym_completed_list, | 74 | list_first_entry(&pcr->asym_completed_list, |
75 | struct cryptodev_pkc, list); | 75 | struct cryptodev_pkc, list); |
76 | list_del(&pkc->list); | 76 | list_del(&pkc->list); |
@@ -78,7 +78,7 @@ index cc1a2a9..1752880 100644 | |||
78 | ret = crypto_async_fetch_asym(pkc); | 78 | ret = crypto_async_fetch_asym(pkc); |
79 | if (!ret) { | 79 | if (!ret) { |
80 | cookie_list.cookie_available++; | 80 | cookie_list.cookie_available++; |
81 | @@ -1088,10 +1087,10 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 81 | @@ -1093,10 +1092,10 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
82 | } | 82 | } |
83 | kfree(pkc); | 83 | kfree(pkc); |
84 | } else { | 84 | } else { |
@@ -90,7 +90,7 @@ index cc1a2a9..1752880 100644 | |||
90 | 90 | ||
91 | /* Reflect the updated request to user-space */ | 91 | /* Reflect the updated request to user-space */ |
92 | if (cookie_list.cookie_available) | 92 | if (cookie_list.cookie_available) |
93 | @@ -1381,14 +1380,13 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | 93 | @@ -1386,14 +1385,13 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) |
94 | case COMPAT_CIOCASYMFETCHCOOKIE: | 94 | case COMPAT_CIOCASYMFETCHCOOKIE: |
95 | { | 95 | { |
96 | struct cryptodev_pkc *pkc; | 96 | struct cryptodev_pkc *pkc; |
@@ -106,7 +106,7 @@ index cc1a2a9..1752880 100644 | |||
106 | if (!list_empty(&pcr->asym_completed_list)) { | 106 | if (!list_empty(&pcr->asym_completed_list)) { |
107 | /* Run a loop in the list for upto elements | 107 | /* Run a loop in the list for upto elements |
108 | and copy their response back */ | 108 | and copy their response back */ |
109 | @@ -1396,6 +1394,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | 109 | @@ -1401,6 +1399,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) |
110 | list_first_entry(&pcr->asym_completed_list, | 110 | list_first_entry(&pcr->asym_completed_list, |
111 | struct cryptodev_pkc, list); | 111 | struct cryptodev_pkc, list); |
112 | list_del(&pkc->list); | 112 | list_del(&pkc->list); |
@@ -114,7 +114,7 @@ index cc1a2a9..1752880 100644 | |||
114 | ret = crypto_async_fetch_asym(pkc); | 114 | ret = crypto_async_fetch_asym(pkc); |
115 | if (!ret) { | 115 | if (!ret) { |
116 | cookie_list.cookie_available++; | 116 | cookie_list.cookie_available++; |
117 | @@ -1404,10 +1403,10 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) | 117 | @@ -1409,10 +1408,10 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) |
118 | } | 118 | } |
119 | kfree(pkc); | 119 | kfree(pkc); |
120 | } else { | 120 | } else { |
@@ -234,5 +234,5 @@ index c901bc7..2747706 100644 | |||
234 | if (!buf) | 234 | if (!buf) |
235 | return -ENOMEM; | 235 | return -ENOMEM; |
236 | -- | 236 | -- |
237 | 1.7.9.7 | 237 | 1.8.3.1 |
238 | 238 | ||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0015-Add-RSA-Key-generation-offloading.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0008-Add-RSA-Key-generation-offloading.patch index a419b58a..affb2e72 100644 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0015-Add-RSA-Key-generation-offloading.patch +++ b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0008-Add-RSA-Key-generation-offloading.patch | |||
@@ -1,24 +1,24 @@ | |||
1 | From 1d9c8084a9addaa071ca3e6c14167ebdb2673725 Mon Sep 17 00:00:00 2001 | 1 | From af5e4289f60c38ab17adab14c82d6204d155f25f Mon Sep 17 00:00:00 2001 |
2 | From: Hou Zhiqiang <B48286@freescale.com> | 2 | From: Hou Zhiqiang <B48286@freescale.com> |
3 | Date: Wed, 19 Mar 2014 14:02:46 +0800 | 3 | Date: Wed, 19 Mar 2014 14:02:46 +0800 |
4 | Subject: [[Patch][fsl 15/16] Add RSA Key generation offloading | 4 | Subject: [PATCH 8/9] Add RSA Key generation offloading |
5 | 5 | ||
6 | Upstream-status: Pending | 6 | Upstream-status: Pending |
7 | 7 | ||
8 | Signed-off-by: Hou Zhiqiang <B48286@freescale.com> | 8 | Signed-off-by: Hou Zhiqiang <B48286@freescale.com> |
9 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> | 9 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> |
10 | --- | 10 | --- |
11 | cryptlib.c | 1 + | 11 | cryptlib.c | 1 + |
12 | crypto/cryptodev.h | 2 ++ | 12 | crypto/cryptodev.h | 2 ++ |
13 | ioctl.c | 3 +- | 13 | ioctl.c | 3 +- |
14 | main.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++- | 14 | main.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++- |
15 | 4 files changed, 84 insertions(+), 2 deletions(-) | 15 | 4 files changed, 84 insertions(+), 2 deletions(-) |
16 | 16 | ||
17 | diff --git a/cryptlib.c b/cryptlib.c | 17 | diff --git a/cryptlib.c b/cryptlib.c |
18 | index 41acb2c..89af77a 100644 | 18 | index 47cd568..4dd1847 100644 |
19 | --- a/cryptlib.c | 19 | --- a/cryptlib.c |
20 | +++ b/cryptlib.c | 20 | +++ b/cryptlib.c |
21 | @@ -426,6 +426,7 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | 21 | @@ -441,6 +441,7 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) |
22 | struct pkc_request *pkc_req = &pkc->req, *pkc_requested; | 22 | struct pkc_request *pkc_req = &pkc->req, *pkc_requested; |
23 | 23 | ||
24 | switch (pkc_req->type) { | 24 | switch (pkc_req->type) { |
@@ -27,10 +27,10 @@ index 41acb2c..89af77a 100644 | |||
27 | case RSA_PRIV_FORM1: | 27 | case RSA_PRIV_FORM1: |
28 | case RSA_PRIV_FORM2: | 28 | case RSA_PRIV_FORM2: |
29 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | 29 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h |
30 | index 33cca2e..7990f27 100644 | 30 | index 275a55c..d0cc542 100644 |
31 | --- a/crypto/cryptodev.h | 31 | --- a/crypto/cryptodev.h |
32 | +++ b/crypto/cryptodev.h | 32 | +++ b/crypto/cryptodev.h |
33 | @@ -271,6 +271,7 @@ enum cryptodev_crk_op_t { | 33 | @@ -270,6 +270,7 @@ enum cryptodev_crk_op_t { |
34 | CRK_DH_COMPUTE_KEY = 4, | 34 | CRK_DH_COMPUTE_KEY = 4, |
35 | CRK_DSA_GENERATE_KEY = 5, | 35 | CRK_DSA_GENERATE_KEY = 5, |
36 | CRK_DH_GENERATE_KEY = 6, | 36 | CRK_DH_GENERATE_KEY = 6, |
@@ -38,7 +38,7 @@ index 33cca2e..7990f27 100644 | |||
38 | CRK_ALGORITHM_ALL | 38 | CRK_ALGORITHM_ALL |
39 | }; | 39 | }; |
40 | 40 | ||
41 | @@ -280,6 +281,7 @@ enum cryptodev_crk_op_t { | 41 | @@ -279,6 +280,7 @@ enum cryptodev_crk_op_t { |
42 | */ | 42 | */ |
43 | #define CRF_MOD_EXP (1 << CRK_MOD_EXP) | 43 | #define CRF_MOD_EXP (1 << CRK_MOD_EXP) |
44 | #define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT) | 44 | #define CRF_MOD_EXP_CRT (1 << CRK_MOD_EXP_CRT) |
@@ -47,10 +47,10 @@ index 33cca2e..7990f27 100644 | |||
47 | #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY) | 47 | #define CRF_DSA_VERIFY (1 << CRK_DSA_VERIFY) |
48 | #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY) | 48 | #define CRF_DH_COMPUTE_KEY (1 << CRK_DH_COMPUTE_KEY) |
49 | diff --git a/ioctl.c b/ioctl.c | 49 | diff --git a/ioctl.c b/ioctl.c |
50 | index 16ce72c..0344c0c 100644 | 50 | index 7e4c671..14888d6 100644 |
51 | --- a/ioctl.c | 51 | --- a/ioctl.c |
52 | +++ b/ioctl.c | 52 | +++ b/ioctl.c |
53 | @@ -954,7 +954,8 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | 53 | @@ -957,7 +957,8 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) |
54 | case CIOCASYMFEAT: | 54 | case CIOCASYMFEAT: |
55 | return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_DSA_SIGN | | 55 | return put_user(CRF_MOD_EXP_CRT | CRF_MOD_EXP | CRF_DSA_SIGN | |
56 | CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY | | 56 | CRF_DSA_VERIFY | CRF_DH_COMPUTE_KEY | |
@@ -166,5 +166,5 @@ index 2747706..14dcf40 100644 | |||
166 | err: | 166 | err: |
167 | return ret; | 167 | return ret; |
168 | -- | 168 | -- |
169 | 1.7.9.7 | 169 | 1.8.3.1 |
170 | 170 | ||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0008-fix-cipher-algorithm-memleaks.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0008-fix-cipher-algorithm-memleaks.patch deleted file mode 100644 index 995fbed4..00000000 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0008-fix-cipher-algorithm-memleaks.patch +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | From 9675e358fe73b33029a470aa5cf47527848f4054 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Tue, 26 Nov 2013 16:36:37 +0200 | ||
4 | Subject: [[Patch][fsl 08/16] fix cipher algorithm memleaks | ||
5 | |||
6 | Upstream-status: Pending | ||
7 | |||
8 | Patch 67e743aef130d107c1b41e0aace7677f9ff53bd1 allocates memory for | ||
9 | cipher algorithm key without freeing it when session terminates. This | ||
10 | patch addresses the deallocation issue. | ||
11 | |||
12 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
13 | Tested-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> | ||
14 | --- | ||
15 | cryptodev_int.h | 1 + | ||
16 | ioctl.c | 2 ++ | ||
17 | 2 files changed, 3 insertions(+) | ||
18 | |||
19 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
20 | index 8d206c9..8891837 100644 | ||
21 | --- a/cryptodev_int.h | ||
22 | +++ b/cryptodev_int.h | ||
23 | @@ -166,6 +166,7 @@ struct csession { | ||
24 | struct hash_data hdata; | ||
25 | uint32_t sid; | ||
26 | uint32_t alignmask; | ||
27 | + uint8_t *key; | ||
28 | |||
29 | unsigned int array_size; | ||
30 | unsigned int used_pages; /* the number of pages that are used */ | ||
31 | diff --git a/ioctl.c b/ioctl.c | ||
32 | index 18874d3..63467e0 100644 | ||
33 | --- a/ioctl.c | ||
34 | +++ b/ioctl.c | ||
35 | @@ -235,6 +235,7 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
36 | goto error_cipher; | ||
37 | |||
38 | key = kmalloc(keylen, GFP_KERNEL); | ||
39 | + ses_new->key = key; | ||
40 | if (unlikely(!key)) { | ||
41 | ret = -ENOMEM; | ||
42 | goto error_cipher; | ||
43 | @@ -342,6 +343,7 @@ crypto_destroy_session(struct csession *ses_ptr) | ||
44 | ddebug(2, "freeing space for %d user pages", ses_ptr->array_size); | ||
45 | kfree(ses_ptr->pages); | ||
46 | kfree(ses_ptr->sg); | ||
47 | + kfree(ses_ptr->key); | ||
48 | mutex_unlock(&ses_ptr->sem); | ||
49 | mutex_destroy(&ses_ptr->sem); | ||
50 | kfree(ses_ptr); | ||
51 | -- | ||
52 | 1.7.9.7 | ||
53 | |||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0016-Fixed-compilation-error-of-openssl-with-fsl-cryptode.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0009-Fixed-compilation-error-of-openssl-with-fsl-cryptode.patch index d5cc7f04..32757ca9 100644 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0016-Fixed-compilation-error-of-openssl-with-fsl-cryptode.patch +++ b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0009-Fixed-compilation-error-of-openssl-with-fsl-cryptode.patch | |||
@@ -1,25 +1,48 @@ | |||
1 | From 2215332bff6034d0e22e92e8fda0993f2579a740 Mon Sep 17 00:00:00 2001 | 1 | From e791b55b03d295ee11476382a7bd93ab131e2e52 Mon Sep 17 00:00:00 2001 |
2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> | 2 | From: Yashpal Dutta <yashpal.dutta@freescale.com> |
3 | Date: Thu, 17 Apr 2014 07:08:47 +0545 | 3 | Date: Thu, 17 Apr 2014 07:08:47 +0545 |
4 | Subject: [[Patch][fsl 16/16] Fixed compilation error of openssl with fsl | 4 | Subject: [PATCH 9/9] Fixed compilation error of openssl with fsl cryptodev |
5 | cryptodev | ||
6 | 5 | ||
7 | Upstream-status: Pending | 6 | Upstream-status: Pending |
8 | 7 | ||
9 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> | 8 | Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com> |
10 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> | 9 | Tested-by: Cristian Stoica <cristian.stoica@freescale.com> |
11 | --- | 10 | --- |
12 | cryptlib.c | 6 +++--- | 11 | authenc.c | 1 + |
13 | crypto/cryptodev.h | 9 ++++++++- | 12 | cryptlib.c | 9 ++++----- |
14 | cryptodev_int.h | 2 +- | 13 | crypto/cryptodev.h | 9 ++++++++- |
15 | ioctl.c | 6 +++++- | 14 | cryptodev_int.h | 2 +- |
16 | 4 files changed, 17 insertions(+), 6 deletions(-) | 15 | ioctl.c | 8 ++++++-- |
16 | main.c | 1 + | ||
17 | 6 files changed, 21 insertions(+), 9 deletions(-) | ||
17 | 18 | ||
19 | diff --git a/authenc.c b/authenc.c | ||
20 | index ef0d3db..2aa4d38 100644 | ||
21 | --- a/authenc.c | ||
22 | +++ b/authenc.c | ||
23 | @@ -2,6 +2,7 @@ | ||
24 | * Driver for /dev/crypto device (aka CryptoDev) | ||
25 | * | ||
26 | * Copyright (c) 2011, 2012 OpenSSL Software Foundation, Inc. | ||
27 | + * Copyright (c) 2014 Freescale Semiconductor, Inc. | ||
28 | * | ||
29 | * Author: Nikos Mavrogiannopoulos | ||
30 | * | ||
18 | diff --git a/cryptlib.c b/cryptlib.c | 31 | diff --git a/cryptlib.c b/cryptlib.c |
19 | index 89af77a..1fc03e5 100644 | 32 | index 4dd1847..ec6693e 100644 |
20 | --- a/cryptlib.c | 33 | --- a/cryptlib.c |
21 | +++ b/cryptlib.c | 34 | +++ b/cryptlib.c |
22 | @@ -129,7 +129,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | 35 | @@ -4,8 +4,7 @@ |
36 | * Copyright (c) 2010,2011 Nikos Mavrogiannopoulos <nmav@gnutls.org> | ||
37 | * Portions Copyright (c) 2010 Michael Weiser | ||
38 | * Portions Copyright (c) 2010 Phil Sutter | ||
39 | - * | ||
40 | - * Copyright 2012 Freescale Semiconductor, Inc. | ||
41 | + * Copyright 2012-2014 Freescale Semiconductor, Inc. | ||
42 | * | ||
43 | * This file is part of linux cryptodev. | ||
44 | * | ||
45 | @@ -144,7 +143,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | ||
23 | if (alg->max_keysize > 0 && | 46 | if (alg->max_keysize > 0 && |
24 | unlikely((keylen < alg->min_keysize) || | 47 | unlikely((keylen < alg->min_keysize) || |
25 | (keylen > alg->max_keysize))) { | 48 | (keylen > alg->max_keysize))) { |
@@ -28,7 +51,7 @@ index 89af77a..1fc03e5 100644 | |||
28 | keylen, alg_name, alg->min_keysize, alg->max_keysize); | 51 | keylen, alg_name, alg->min_keysize, alg->max_keysize); |
29 | ret = -EINVAL; | 52 | ret = -EINVAL; |
30 | goto error; | 53 | goto error; |
31 | @@ -156,7 +156,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, | 54 | @@ -171,7 +170,7 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, |
32 | } | 55 | } |
33 | 56 | ||
34 | if (unlikely(ret)) { | 57 | if (unlikely(ret)) { |
@@ -37,7 +60,7 @@ index 89af77a..1fc03e5 100644 | |||
37 | ret = -EINVAL; | 60 | ret = -EINVAL; |
38 | goto error; | 61 | goto error; |
39 | } | 62 | } |
40 | @@ -323,7 +323,7 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, | 63 | @@ -338,7 +337,7 @@ int cryptodev_hash_init(struct hash_data *hdata, const char *alg_name, |
41 | if (hmac_mode != 0) { | 64 | if (hmac_mode != 0) { |
42 | ret = crypto_ahash_setkey(hdata->async.s, mackey, mackeylen); | 65 | ret = crypto_ahash_setkey(hdata->async.s, mackey, mackeylen); |
43 | if (unlikely(ret)) { | 66 | if (unlikely(ret)) { |
@@ -47,10 +70,10 @@ index 89af77a..1fc03e5 100644 | |||
47 | ret = -EINVAL; | 70 | ret = -EINVAL; |
48 | goto error; | 71 | goto error; |
49 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h | 72 | diff --git a/crypto/cryptodev.h b/crypto/cryptodev.h |
50 | index 7990f27..77bffc9 100644 | 73 | index d0cc542..e7edd97 100644 |
51 | --- a/crypto/cryptodev.h | 74 | --- a/crypto/cryptodev.h |
52 | +++ b/crypto/cryptodev.h | 75 | +++ b/crypto/cryptodev.h |
53 | @@ -235,6 +235,13 @@ struct crypt_auth_op { | 76 | @@ -234,6 +234,13 @@ struct crypt_auth_op { |
54 | #define CRYPTO_ALG_FLAG_RNG_ENABLE 2 | 77 | #define CRYPTO_ALG_FLAG_RNG_ENABLE 2 |
55 | #define CRYPTO_ALG_FLAG_DSA_SHA 4 | 78 | #define CRYPTO_ALG_FLAG_DSA_SHA 4 |
56 | 79 | ||
@@ -64,7 +87,7 @@ index 7990f27..77bffc9 100644 | |||
64 | struct crparam { | 87 | struct crparam { |
65 | __u8 *crp_p; | 88 | __u8 *crp_p; |
66 | __u32 crp_nbits; | 89 | __u32 crp_nbits; |
67 | @@ -250,7 +257,7 @@ struct crypt_kop { | 90 | @@ -249,7 +256,7 @@ struct crypt_kop { |
68 | __u16 crk_oparams; | 91 | __u16 crk_oparams; |
69 | __u32 crk_pad1; | 92 | __u32 crk_pad1; |
70 | struct crparam crk_param[CRK_MAXPARAM]; | 93 | struct crparam crk_param[CRK_MAXPARAM]; |
@@ -74,7 +97,7 @@ index 7990f27..77bffc9 100644 | |||
74 | void *cookie; | 97 | void *cookie; |
75 | }; | 98 | }; |
76 | diff --git a/cryptodev_int.h b/cryptodev_int.h | 99 | diff --git a/cryptodev_int.h b/cryptodev_int.h |
77 | index 7ea6976..e379eaf 100644 | 100 | index 5347cae..c83c885 100644 |
78 | --- a/cryptodev_int.h | 101 | --- a/cryptodev_int.h |
79 | +++ b/cryptodev_int.h | 102 | +++ b/cryptodev_int.h |
80 | @@ -88,7 +88,7 @@ struct compat_crypt_kop { | 103 | @@ -88,7 +88,7 @@ struct compat_crypt_kop { |
@@ -87,10 +110,19 @@ index 7ea6976..e379eaf 100644 | |||
87 | compat_uptr_t cookie; | 110 | compat_uptr_t cookie; |
88 | }; | 111 | }; |
89 | diff --git a/ioctl.c b/ioctl.c | 112 | diff --git a/ioctl.c b/ioctl.c |
90 | index 0344c0c..66cb05a 100644 | 113 | index 14888d6..20ab4ca 100644 |
91 | --- a/ioctl.c | 114 | --- a/ioctl.c |
92 | +++ b/ioctl.c | 115 | +++ b/ioctl.c |
93 | @@ -498,6 +498,7 @@ cryptodev_open(struct inode *inode, struct file *filp) | 116 | @@ -4,7 +4,7 @@ |
117 | * Copyright (c) 2004 Michal Ludvig <mludvig@logix.net.nz>, SuSE Labs | ||
118 | * Copyright (c) 2009,2010,2011 Nikos Mavrogiannopoulos <nmav@gnutls.org> | ||
119 | * Copyright (c) 2010 Phil Sutter | ||
120 | - * Copyright 2012 Freescale Semiconductor, Inc. | ||
121 | + * Copyright 2012-2014 Freescale Semiconductor, Inc. | ||
122 | * | ||
123 | * This file is part of linux cryptodev. | ||
124 | * | ||
125 | @@ -501,6 +501,7 @@ cryptodev_open(struct inode *inode, struct file *filp) | ||
94 | INIT_LIST_HEAD(&pcr->done.list); | 126 | INIT_LIST_HEAD(&pcr->done.list); |
95 | INIT_LIST_HEAD(&pcr->asym_completed_list); | 127 | INIT_LIST_HEAD(&pcr->asym_completed_list); |
96 | spin_lock_init(&pcr->completion_lock); | 128 | spin_lock_init(&pcr->completion_lock); |
@@ -98,7 +130,7 @@ index 0344c0c..66cb05a 100644 | |||
98 | INIT_WORK(&pcr->cryptask, cryptask_routine); | 130 | INIT_WORK(&pcr->cryptask, cryptask_routine); |
99 | 131 | ||
100 | init_waitqueue_head(&pcr->user_waiter); | 132 | init_waitqueue_head(&pcr->user_waiter); |
101 | @@ -777,8 +778,11 @@ static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) | 133 | @@ -780,8 +781,11 @@ static int fill_kcop_from_cop(struct kernel_crypt_op *kcop, struct fcrypt *fcr) |
102 | 134 | ||
103 | if (cop->iv) { | 135 | if (cop->iv) { |
104 | rc = copy_from_user(kcop->iv, cop->iv, kcop->ivlen); | 136 | rc = copy_from_user(kcop->iv, cop->iv, kcop->ivlen); |
@@ -111,6 +143,18 @@ index 0344c0c..66cb05a 100644 | |||
111 | } | 143 | } |
112 | 144 | ||
113 | return 0; | 145 | return 0; |
146 | diff --git a/main.c b/main.c | ||
147 | index 14dcf40..6365911 100644 | ||
148 | --- a/main.c | ||
149 | +++ b/main.c | ||
150 | @@ -3,6 +3,7 @@ | ||
151 | * | ||
152 | * Copyright (c) 2004 Michal Ludvig <mludvig@logix.net.nz>, SuSE Labs | ||
153 | * Copyright (c) 2009-2013 Nikos Mavrogiannopoulos <nmav@gnutls.org> | ||
154 | + * Copyright (c) 2014 Freescale Semiconductor, Inc. | ||
155 | * | ||
156 | * This file is part of linux cryptodev. | ||
157 | * | ||
114 | -- | 158 | -- |
115 | 1.7.9.7 | 159 | 2.2.0 |
116 | 160 | ||
diff --git a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0014-use-static-allocation-for-keys-copied-from-userspace.patch b/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0014-use-static-allocation-for-keys-copied-from-userspace.patch deleted file mode 100644 index c68f3d7c..00000000 --- a/meta-fsl-ppc/recipes-kernel/cryptodev/cryptodev-fsl/0014-use-static-allocation-for-keys-copied-from-userspace.patch +++ /dev/null | |||
@@ -1,131 +0,0 @@ | |||
1 | From 50c116780f736b3e6a11389c9d9b3f4a1d5cab90 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
3 | Date: Wed, 19 Mar 2014 17:59:17 +0200 | ||
4 | Subject: [[Patch][fsl 14/16] use static allocation for keys copied from | ||
5 | userspace | ||
6 | |||
7 | Upstream-status: Pending | ||
8 | |||
9 | There is no need to keep keys around for the entire duration of the | ||
10 | session. The keys are copied from user-space and then used to initialize | ||
11 | the ciphers. After this, the original keys can be discarded. | ||
12 | The total required space for keys is small and known in advance. This | ||
13 | patch uses this information to allocate required space on stack. | ||
14 | |||
15 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
16 | --- | ||
17 | cryptodev_int.h | 1 - | ||
18 | ioctl.c | 38 ++++++++++++++++++++------------------ | ||
19 | 2 files changed, 20 insertions(+), 19 deletions(-) | ||
20 | |||
21 | diff --git a/cryptodev_int.h b/cryptodev_int.h | ||
22 | index 8beeef0..7ea6976 100644 | ||
23 | --- a/cryptodev_int.h | ||
24 | +++ b/cryptodev_int.h | ||
25 | @@ -212,7 +212,6 @@ struct csession { | ||
26 | struct hash_data hdata; | ||
27 | uint32_t sid; | ||
28 | uint32_t alignmask; | ||
29 | - uint8_t *key; | ||
30 | |||
31 | unsigned int array_size; | ||
32 | unsigned int used_pages; /* the number of pages that are used */ | ||
33 | diff --git a/ioctl.c b/ioctl.c | ||
34 | index 1752880..16ce72c 100644 | ||
35 | --- a/ioctl.c | ||
36 | +++ b/ioctl.c | ||
37 | @@ -46,6 +46,8 @@ | ||
38 | #include <linux/uaccess.h> | ||
39 | #include <crypto/cryptodev.h> | ||
40 | #include <linux/scatterlist.h> | ||
41 | +#include <linux/rtnetlink.h> | ||
42 | +#include <crypto/authenc.h> | ||
43 | |||
44 | #include <linux/sysctl.h> | ||
45 | |||
46 | @@ -136,9 +138,17 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
47 | const char *alg_name = NULL; | ||
48 | const char *hash_name = NULL; | ||
49 | int hmac_mode = 1, stream = 0, aead = 0; | ||
50 | - uint8_t *key = NULL; | ||
51 | - unsigned int keylen; | ||
52 | - uint8_t mackey[CRYPTO_HMAC_MAX_KEY_LEN]; | ||
53 | + /* | ||
54 | + * With aead, only ckey is used and it can cover all the struct space; | ||
55 | + * otherwise both keys may be used simultaneously but they are confined | ||
56 | + * to their spaces | ||
57 | + */ | ||
58 | + struct { | ||
59 | + uint8_t ckey[CRYPTO_CIPHER_MAX_KEY_LEN]; | ||
60 | + uint8_t mkey[CRYPTO_HMAC_MAX_KEY_LEN]; | ||
61 | + /* padding space for aead keys */ | ||
62 | + uint8_t pad[RTA_SPACE(sizeof(struct crypto_authenc_key_param))]; | ||
63 | + } keys; | ||
64 | |||
65 | /* Does the request make sense? */ | ||
66 | if (unlikely(!sop->cipher && !sop->mac)) { | ||
67 | @@ -257,23 +267,17 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
68 | |||
69 | /* Set-up crypto transform. */ | ||
70 | if (alg_name) { | ||
71 | + unsigned int keylen; | ||
72 | ret = cryptodev_get_cipher_keylen(&keylen, sop, aead); | ||
73 | if (unlikely(ret < 0)) | ||
74 | goto error_cipher; | ||
75 | |||
76 | - key = kmalloc(keylen, GFP_KERNEL); | ||
77 | - ses_new->key = key; | ||
78 | - if (unlikely(!key)) { | ||
79 | - ret = -ENOMEM; | ||
80 | - goto error_cipher; | ||
81 | - } | ||
82 | - | ||
83 | - ret = cryptodev_get_cipher_key(key, sop, aead); | ||
84 | + ret = cryptodev_get_cipher_key(keys.ckey, sop, aead); | ||
85 | if (unlikely(ret < 0)) | ||
86 | goto error_cipher; | ||
87 | |||
88 | - ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, key, keylen, | ||
89 | - stream, aead); | ||
90 | + ret = cryptodev_cipher_init(&ses_new->cdata, alg_name, | ||
91 | + keys.ckey, keylen, stream, aead); | ||
92 | if (ret < 0) { | ||
93 | ddebug(1, "Failed to load cipher for %s", alg_name); | ||
94 | ret = -EINVAL; | ||
95 | @@ -289,14 +293,14 @@ crypto_create_session(struct fcrypt *fcr, struct session_op *sop) | ||
96 | goto error_hash; | ||
97 | } | ||
98 | |||
99 | - if (sop->mackey && unlikely(copy_from_user(mackey, sop->mackey, | ||
100 | - sop->mackeylen))) { | ||
101 | + if (sop->mackey && unlikely(copy_from_user(keys.mkey, | ||
102 | + sop->mackey, sop->mackeylen))) { | ||
103 | ret = -EFAULT; | ||
104 | goto error_hash; | ||
105 | } | ||
106 | |||
107 | ret = cryptodev_hash_init(&ses_new->hdata, hash_name, hmac_mode, | ||
108 | - mackey, sop->mackeylen); | ||
109 | + keys.mkey, sop->mackeylen); | ||
110 | if (ret != 0) { | ||
111 | ddebug(1, "Failed to load hash for %s", hash_name); | ||
112 | ret = -EINVAL; | ||
113 | @@ -349,7 +353,6 @@ error_hash: | ||
114 | kfree(ses_new->sg); | ||
115 | kfree(ses_new->pages); | ||
116 | error_cipher: | ||
117 | - kfree(key); | ||
118 | kfree(ses_new); | ||
119 | |||
120 | return ret; | ||
121 | @@ -370,7 +373,6 @@ crypto_destroy_session(struct csession *ses_ptr) | ||
122 | ddebug(2, "freeing space for %d user pages", ses_ptr->array_size); | ||
123 | kfree(ses_ptr->pages); | ||
124 | kfree(ses_ptr->sg); | ||
125 | - kfree(ses_ptr->key); | ||
126 | mutex_unlock(&ses_ptr->sem); | ||
127 | mutex_destroy(&ses_ptr->sem); | ||
128 | kfree(ses_ptr); | ||
129 | -- | ||
130 | 1.7.9.7 | ||
131 | |||