1) The keylen in cryptodev_dh_compute_key is already in bits. So, avoid 
multiplying
it with 8 while passing it to cryptodev.

2) cryptodev_dh_compute_key must return size of secret generated as expected by 
openssl.

Signed-off-by: Yashpal Dutta <yashpal.du...@freescale.com>
---
The fixes are tested against openssl-1.0.1c.

 extras/eng_cryptodev.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/extras/eng_cryptodev.c b/extras/eng_cryptodev.c
index 718596a..48eb0a5 100644
--- a/extras/eng_cryptodev.c
+++ b/extras/eng_cryptodev.c
@@ -1400,8 +1400,9 @@ cryptodev_dh_compute_key(unsigned char *key, const BIGNUM 
*pub_key, DH *dh)
        kop.crk_iparams = 3;
 
        kop.crk_param[3].crp_p = (void*) key;
-       kop.crk_param[3].crp_nbits = keylen * 8;
+       kop.crk_param[3].crp_nbits = keylen;
        kop.crk_oparams = 1;
+       dhret = keylen/8;
 
        if (ioctl(fd, CIOCKEY, &kop) == -1) {
                const DH_METHOD *meth = DH_OpenSSL();
-- 
1.7.0.4



_______________________________________________
Cryptodev-linux-devel mailing list
Cryptodev-linux-devel@gna.org
https://mail.gna.org/listinfo/cryptodev-linux-devel

Reply via email to