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 0000000..be99643 --- /dev/null +++ b/recipes-connectivity/openssl/openssl-qoriq/qoriq/0044-cryptodev-check-for-errors-inside-cryptodev_dh_compu.patch @@ -0,0 +1,76 @@ +From 42a1c45091ab7996c4411f3dd74539c908c63208 Mon Sep 17 00:00:00 2001 +From: Cristian Stoica <cristian.stoica@nxp.com> +Date: Tue, 9 Feb 2016 11:53:33 +0200 +Subject: [PATCH 44/48] cryptodev: check for errors inside + cryptodev_dh_compute_key_async + +Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com> +--- + crypto/engine/eng_cryptodev.c | 29 +++++++++++++++++++++-------- + 1 file changed, 21 insertions(+), 8 deletions(-) + +diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c +index 55b2047..e0f9d4b 100644 +--- a/crypto/engine/eng_cryptodev.c ++++ b/crypto/engine/eng_cryptodev.c +@@ -4095,19 +4095,28 @@ static int + cryptodev_dh_compute_key_async(unsigned char *key, const BIGNUM *pub_key, + DH *dh, struct pkc_cookie_s *cookie) + { +- struct crypt_kop *kop = malloc(sizeof(struct crypt_kop)); ++ struct crypt_kop *kop; + int ret = 1; + int p_len; + unsigned char *padded_pub_key = NULL, *p = NULL; + ++ kop = malloc(sizeof(struct crypt_kop)); ++ if (kop == NULL) { ++ goto err; ++ } ++ + memset(kop, 0, sizeof(struct crypt_kop)); + kop->crk_op = CRK_DH_COMPUTE_KEY; + /* inputs: dh->priv_key pub_key dh->p key */ +- spcf_bn2bin(dh->p, &p, &p_len); +- spcf_bn2bin_ex(pub_key, &padded_pub_key, &p_len); +- +- if (bn2crparam(dh->priv_key, &kop->crk_param[0])) ++ if (spcf_bn2bin(dh->p, &p, &p_len) != 0) { ++ goto err; ++ } ++ if (spcf_bn2bin_ex(pub_key, &padded_pub_key, &p_len) != 0) { + goto err; ++ } ++ if (bn2crparam(dh->priv_key, &kop->crk_param[0]) != 0) { ++ goto err; ++ } + kop->crk_param[1].crp_p = padded_pub_key; + kop->crk_param[1].crp_nbits = p_len * 8; + kop->crk_param[2].crp_p = p; +@@ -4119,16 +4128,20 @@ cryptodev_dh_compute_key_async(unsigned char *key, const BIGNUM *pub_key, + kop->crk_param[3].crp_nbits = p_len * 8; + kop->crk_oparams = 1; + +- if (cryptodev_asym_async(kop, 0, NULL, 0, NULL)) ++ if (cryptodev_asym_async(kop, 0, NULL, 0, NULL)) { + goto err; ++ } + + return p_len; + err: + { + const DH_METHOD *meth = DH_OpenSSL(); +- +- if (kop) ++ free(p); ++ free(padded_pub_key); ++ if (kop) { + free(kop); ++ } ++ + ret = (meth->compute_key) (key, pub_key, dh); + /* Call user cookie handler */ + cookie->pkc_callback(cookie, 0); +-- +2.7.0 + |