1 From c8a5f714d35c3bd63d2511ad69e0661a7d1d5dcd Mon Sep 17 00:00:00 2001
2 From: Cristian Stoica <cristian.stoica@nxp.com>
3 Date: Tue, 9 Feb 2016 11:53:22 +0200
4 Subject: [PATCH 43/48] cryptodev: check for errors inside
5 cryptodev_dh_compute_key
7 Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
9 crypto/engine/eng_cryptodev.c | 15 +++++++++++----
10 1 file changed, 11 insertions(+), 4 deletions(-)
12 diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
13 index 8e84972..55b2047 100644
14 --- a/crypto/engine/eng_cryptodev.c
15 +++ b/crypto/engine/eng_cryptodev.c
16 @@ -4043,11 +4043,15 @@ cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
17 memset(&kop, 0, sizeof kop);
18 kop.crk_op = CRK_DH_COMPUTE_KEY;
19 /* inputs: dh->priv_key pub_key dh->p key */
20 - spcf_bn2bin(dh->p, &p, &p_len);
21 - spcf_bn2bin_ex(pub_key, &padded_pub_key, &p_len);
22 - if (bn2crparam(dh->priv_key, &kop.crk_param[0]))
23 + if (spcf_bn2bin(dh->p, &p, &p_len) != 0) {
27 + if (spcf_bn2bin_ex(pub_key, &padded_pub_key, &p_len) != 0) {
30 + if (bn2crparam(dh->priv_key, &kop.crk_param[0]) != 0) {
33 kop.crk_param[1].crp_p = padded_pub_key;
34 kop.crk_param[1].crp_nbits = p_len * 8;
35 kop.crk_param[2].crp_p = p;
36 @@ -4074,10 +4078,13 @@ cryptodev_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh)
37 kop.crk_param[3].crp_p = NULL;
43 const DH_METHOD *meth = DH_OpenSSL();
46 + free(padded_pub_key);
47 dhret = (meth->compute_key) (key, pub_key, dh);