summaryrefslogtreecommitdiffstats
path: root/recipes-connectivity/openssl/openssl-qoriq/qoriq/0026-cryptodev-simplify-cryptodev-pkc-support-code.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-connectivity/openssl/openssl-qoriq/qoriq/0026-cryptodev-simplify-cryptodev-pkc-support-code.patch')
-rw-r--r--recipes-connectivity/openssl/openssl-qoriq/qoriq/0026-cryptodev-simplify-cryptodev-pkc-support-code.patch250
1 files changed, 250 insertions, 0 deletions
diff --git a/recipes-connectivity/openssl/openssl-qoriq/qoriq/0026-cryptodev-simplify-cryptodev-pkc-support-code.patch b/recipes-connectivity/openssl/openssl-qoriq/qoriq/0026-cryptodev-simplify-cryptodev-pkc-support-code.patch
new file mode 100644
index 0000000..6527ac8
--- /dev/null
+++ b/recipes-connectivity/openssl/openssl-qoriq/qoriq/0026-cryptodev-simplify-cryptodev-pkc-support-code.patch
@@ -0,0 +1,250 @@
1From 787539e7720c99785f6c664a7484842bba08f6ed Mon Sep 17 00:00:00 2001
2From: Cristian Stoica <cristian.stoica@freescale.com>
3Date: Thu, 19 Feb 2015 13:39:52 +0200
4Subject: [PATCH 26/26] cryptodev: simplify cryptodev pkc support code
5
6- Engine init returns directly a file descriptor instead of a pointer to one
7- Similarly, the Engine close will now just close the file
8
9Change-Id: Ief736d0776c7009dee002204fb1d4ce9d31c8787
10Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
11Reviewed-on: http://git.am.freescale.net:8181/34221
12---
13 crypto/crypto.h | 2 +-
14 crypto/engine/eng_cryptodev.c | 35 +++-----------------------
15 crypto/engine/eng_int.h | 14 +++--------
16 crypto/engine/eng_lib.c | 57 +++++++++++++++++++++----------------------
17 crypto/engine/engine.h | 13 +++++-----
18 5 files changed, 42 insertions(+), 79 deletions(-)
19
20diff --git a/crypto/crypto.h b/crypto/crypto.h
21index ce12731..292427e 100644
22--- a/crypto/crypto.h
23+++ b/crypto/crypto.h
24@@ -618,7 +618,7 @@ struct pkc_cookie_s {
25 * -EINVAL: Parameters Invalid
26 */
27 void (*pkc_callback)(struct pkc_cookie_s *cookie, int status);
28- void *eng_handle;
29+ int eng_handle;
30 };
31
32 #ifdef __cplusplus
33diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
34index c9db27d..f173bde 100644
35--- a/crypto/engine/eng_cryptodev.c
36+++ b/crypto/engine/eng_cryptodev.c
37@@ -1742,7 +1742,7 @@ cryptodev_asym_async(struct crypt_kop *kop, int rlen, BIGNUM *r, int slen,
38 struct pkc_cookie_s *cookie = kop->cookie;
39 struct cryptodev_cookie_s *eng_cookie;
40
41- fd = *(int *)cookie->eng_handle;
42+ fd = cookie->eng_handle;
43
44 eng_cookie = malloc(sizeof(struct cryptodev_cookie_s));
45 if (!eng_cookie)
46@@ -1802,38 +1802,11 @@ cryptodev_asym(struct crypt_kop *kop, int rlen, BIGNUM *r, int slen, BIGNUM *s)
47 return (ret);
48 }
49
50-/* Close an opened instance of cryptodev engine */
51-void cryptodev_close_instance(void *handle)
52-{
53- int fd;
54-
55- if (handle) {
56- fd = *(int *)handle;
57- close(fd);
58- free(handle);
59- }
60-}
61-
62-/* Create an instance of cryptodev for asynchronous interface */
63-void *cryptodev_init_instance(void)
64-{
65- int *fd = malloc(sizeof(int));
66-
67- if (fd) {
68- if ((*fd = open("/dev/crypto", O_RDWR, 0)) == -1) {
69- free(fd);
70- return NULL;
71- }
72- }
73- return fd;
74-}
75-
76 #include <poll.h>
77
78 /* Return 0 on success and 1 on failure */
79-int cryptodev_check_availability(void *eng_handle)
80+int cryptodev_check_availability(int fd)
81 {
82- int fd = *(int *)eng_handle;
83 struct pkc_cookie_list_s cookie_list;
84 struct pkc_cookie_s *cookie;
85 int i;
86@@ -4540,8 +4513,8 @@ ENGINE_load_cryptodev(void)
87 }
88
89 ENGINE_set_check_pkc_availability(engine, cryptodev_check_availability);
90- ENGINE_set_close_instance(engine, cryptodev_close_instance);
91- ENGINE_set_init_instance(engine, cryptodev_init_instance);
92+ ENGINE_set_close_instance(engine, put_dev_crypto);
93+ ENGINE_set_open_instance(engine, open_dev_crypto);
94 ENGINE_set_async_map(engine, ENGINE_ALLPKC_ASYNC);
95
96 ENGINE_add(engine);
97diff --git a/crypto/engine/eng_int.h b/crypto/engine/eng_int.h
98index 8fc3077..8fb79c0 100644
99--- a/crypto/engine/eng_int.h
100+++ b/crypto/engine/eng_int.h
101@@ -181,23 +181,15 @@ struct engine_st
102 ENGINE_LOAD_KEY_PTR load_pubkey;
103
104 ENGINE_SSL_CLIENT_CERT_PTR load_ssl_client_cert;
105- /*
106- * Instantiate Engine handle to be passed in check_pkc_availability
107- * Ensure that Engine is instantiated before any pkc asynchronous call.
108- */
109- void *(*engine_init_instance)(void);
110- /*
111- * Instantiated Engine handle will be closed with this call.
112- * Ensure that no pkc asynchronous call is made after this call
113- */
114- void (*engine_close_instance)(void *handle);
115+ int (*engine_open_instance)(void);
116+ int (*engine_close_instance)(int fd);
117 /*
118 * Check availability will extract the data from kernel.
119 * eng_handle: This is the Engine handle corresponds to which
120 * the cookies needs to be polled.
121 * return 0 if cookie available else 1
122 */
123- int (*check_pkc_availability)(void *eng_handle);
124+ int (*check_pkc_availability)(int fd);
125 /*
126 * The following map is used to check if the engine supports asynchronous implementation
127 * ENGINE_ASYNC_FLAG* for available bitmap. Any application checking for asynchronous
128diff --git a/crypto/engine/eng_lib.c b/crypto/engine/eng_lib.c
129index 6fa621c..6c9471b 100644
130--- a/crypto/engine/eng_lib.c
131+++ b/crypto/engine/eng_lib.c
132@@ -99,7 +99,7 @@ void engine_set_all_null(ENGINE *e)
133 e->load_privkey = NULL;
134 e->load_pubkey = NULL;
135 e->check_pkc_availability = NULL;
136- e->engine_init_instance = NULL;
137+ e->engine_open_instance = NULL;
138 e->engine_close_instance = NULL;
139 e->cmd_defns = NULL;
140 e->async_map = 0;
141@@ -237,47 +237,46 @@ int ENGINE_set_id(ENGINE *e, const char *id)
142 return 1;
143 }
144
145-void ENGINE_set_init_instance(ENGINE *e, void *(*engine_init_instance)(void))
146- {
147- e->engine_init_instance = engine_init_instance;
148- }
149+void ENGINE_set_open_instance(ENGINE *e, int (*engine_open_instance)(void))
150+{
151+ e->engine_open_instance = engine_open_instance;
152+}
153
154-void ENGINE_set_close_instance(ENGINE *e,
155- void (*engine_close_instance)(void *))
156- {
157- e->engine_close_instance = engine_close_instance;
158- }
159+void ENGINE_set_close_instance(ENGINE *e, int (*engine_close_instance)(int))
160+{
161+ e->engine_close_instance = engine_close_instance;
162+}
163
164 void ENGINE_set_async_map(ENGINE *e, int async_map)
165 {
166 e->async_map = async_map;
167 }
168
169-void *ENGINE_init_instance(ENGINE *e)
170- {
171- return e->engine_init_instance();
172- }
173-
174-void ENGINE_close_instance(ENGINE *e, void *eng_handle)
175- {
176- e->engine_close_instance(eng_handle);
177- }
178-
179 int ENGINE_get_async_map(ENGINE *e)
180 {
181 return e->async_map;
182 }
183
184-void ENGINE_set_check_pkc_availability(ENGINE *e,
185- int (*check_pkc_availability)(void *eng_handle))
186- {
187- e->check_pkc_availability = check_pkc_availability;
188- }
189+int ENGINE_open_instance(ENGINE *e)
190+{
191+ return e->engine_open_instance();
192+}
193
194-int ENGINE_check_pkc_availability(ENGINE *e, void *eng_handle)
195- {
196- return e->check_pkc_availability(eng_handle);
197- }
198+int ENGINE_close_instance(ENGINE *e, int fd)
199+{
200+ return e->engine_close_instance(fd);
201+}
202+
203+void ENGINE_set_check_pkc_availability(ENGINE *e,
204+ int (*check_pkc_availability)(int fd))
205+{
206+ e->check_pkc_availability = check_pkc_availability;
207+}
208+
209+int ENGINE_check_pkc_availability(ENGINE *e, int fd)
210+{
211+ return e->check_pkc_availability(fd);
212+}
213
214 int ENGINE_set_name(ENGINE *e, const char *name)
215 {
216diff --git a/crypto/engine/engine.h b/crypto/engine/engine.h
217index ccff86a..3ba3e97 100644
218--- a/crypto/engine/engine.h
219+++ b/crypto/engine/engine.h
220@@ -473,9 +473,6 @@ ENGINE *ENGINE_new(void);
221 int ENGINE_free(ENGINE *e);
222 int ENGINE_up_ref(ENGINE *e);
223 int ENGINE_set_id(ENGINE *e, const char *id);
224-void ENGINE_set_init_instance(ENGINE *e, void *(*engine_init_instance)(void));
225-void ENGINE_set_close_instance(ENGINE *e,
226- void (*engine_free_instance)(void *));
227 /*
228 * Following FLAGS are bitmap store in async_map to set asynchronous interface capability
229 *of the engine
230@@ -492,11 +489,13 @@ void ENGINE_set_async_map(ENGINE *e, int async_map);
231 * to confirm asynchronous methods supported
232 */
233 int ENGINE_get_async_map(ENGINE *e);
234-void *ENGINE_init_instance(ENGINE *e);
235-void ENGINE_close_instance(ENGINE *e, void *eng_handle);
236+int ENGINE_open_instance(ENGINE *e);
237+int ENGINE_close_instance(ENGINE *e, int fd);
238+void ENGINE_set_init_instance(ENGINE *e, int(*engine_init_instance)(void));
239+void ENGINE_set_close_instance(ENGINE *e, int(*engine_close_instance)(int));
240 void ENGINE_set_check_pkc_availability(ENGINE *e,
241- int (*check_pkc_availability)(void *eng_handle));
242-int ENGINE_check_pkc_availability(ENGINE *e, void *eng_handle);
243+ int (*check_pkc_availability)(int fd));
244+int ENGINE_check_pkc_availability(ENGINE *e, int fd);
245 int ENGINE_set_name(ENGINE *e, const char *name);
246 int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth);
247 int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth);
248--
2492.3.5
250