diff options
Diffstat (limited to 'recipes-connectivity/openssl/openssl-qoriq/qoriq/0044-cryptodev-check-for-errors-inside-cryptodev_dh_compu.patch')
-rw-r--r-- | recipes-connectivity/openssl/openssl-qoriq/qoriq/0044-cryptodev-check-for-errors-inside-cryptodev_dh_compu.patch | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/recipes-connectivity/openssl/openssl-qoriq/qoriq/0044-cryptodev-check-for-errors-inside-cryptodev_dh_compu.patch b/recipes-connectivity/openssl/openssl-qoriq/qoriq/0044-cryptodev-check-for-errors-inside-cryptodev_dh_compu.patch new file mode 100644 index 00000000..be996435 --- /dev/null +++ b/recipes-connectivity/openssl/openssl-qoriq/qoriq/0044-cryptodev-check-for-errors-inside-cryptodev_dh_compu.patch | |||
@@ -0,0 +1,76 @@ | |||
1 | From 42a1c45091ab7996c4411f3dd74539c908c63208 Mon Sep 17 00:00:00 2001 | ||
2 | From: Cristian Stoica <cristian.stoica@nxp.com> | ||
3 | Date: Tue, 9 Feb 2016 11:53:33 +0200 | ||
4 | Subject: [PATCH 44/48] cryptodev: check for errors inside | ||
5 | cryptodev_dh_compute_key_async | ||
6 | |||
7 | Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> | ||
8 | --- | ||
9 | crypto/engine/eng_cryptodev.c | 29 +++++++++++++++++++++-------- | ||
10 | 1 file changed, 21 insertions(+), 8 deletions(-) | ||
11 | |||
12 | diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c | ||
13 | index 55b2047..e0f9d4b 100644 | ||
14 | --- a/crypto/engine/eng_cryptodev.c | ||
15 | +++ b/crypto/engine/eng_cryptodev.c | ||
16 | @@ -4095,19 +4095,28 @@ static int | ||
17 | cryptodev_dh_compute_key_async(unsigned char *key, const BIGNUM *pub_key, | ||
18 | DH *dh, struct pkc_cookie_s *cookie) | ||
19 | { | ||
20 | - struct crypt_kop *kop = malloc(sizeof(struct crypt_kop)); | ||
21 | + struct crypt_kop *kop; | ||
22 | int ret = 1; | ||
23 | int p_len; | ||
24 | unsigned char *padded_pub_key = NULL, *p = NULL; | ||
25 | |||
26 | + kop = malloc(sizeof(struct crypt_kop)); | ||
27 | + if (kop == NULL) { | ||
28 | + goto err; | ||
29 | + } | ||
30 | + | ||
31 | memset(kop, 0, sizeof(struct crypt_kop)); | ||
32 | kop->crk_op = CRK_DH_COMPUTE_KEY; | ||
33 | /* inputs: dh->priv_key pub_key dh->p key */ | ||
34 | - spcf_bn2bin(dh->p, &p, &p_len); | ||
35 | - spcf_bn2bin_ex(pub_key, &padded_pub_key, &p_len); | ||
36 | - | ||
37 | - if (bn2crparam(dh->priv_key, &kop->crk_param[0])) | ||
38 | + if (spcf_bn2bin(dh->p, &p, &p_len) != 0) { | ||
39 | + goto err; | ||
40 | + } | ||
41 | + if (spcf_bn2bin_ex(pub_key, &padded_pub_key, &p_len) != 0) { | ||
42 | goto err; | ||
43 | + } | ||
44 | + if (bn2crparam(dh->priv_key, &kop->crk_param[0]) != 0) { | ||
45 | + goto err; | ||
46 | + } | ||
47 | kop->crk_param[1].crp_p = padded_pub_key; | ||
48 | kop->crk_param[1].crp_nbits = p_len * 8; | ||
49 | kop->crk_param[2].crp_p = p; | ||
50 | @@ -4119,16 +4128,20 @@ cryptodev_dh_compute_key_async(unsigned char *key, const BIGNUM *pub_key, | ||
51 | kop->crk_param[3].crp_nbits = p_len * 8; | ||
52 | kop->crk_oparams = 1; | ||
53 | |||
54 | - if (cryptodev_asym_async(kop, 0, NULL, 0, NULL)) | ||
55 | + if (cryptodev_asym_async(kop, 0, NULL, 0, NULL)) { | ||
56 | goto err; | ||
57 | + } | ||
58 | |||
59 | return p_len; | ||
60 | err: | ||
61 | { | ||
62 | const DH_METHOD *meth = DH_OpenSSL(); | ||
63 | - | ||
64 | - if (kop) | ||
65 | + free(p); | ||
66 | + free(padded_pub_key); | ||
67 | + if (kop) { | ||
68 | free(kop); | ||
69 | + } | ||
70 | + | ||
71 | ret = (meth->compute_key) (key, pub_key, dh); | ||
72 | /* Call user cookie handler */ | ||
73 | cookie->pkc_callback(cookie, 0); | ||
74 | -- | ||
75 | 2.7.0 | ||
76 | |||