summaryrefslogtreecommitdiffstats
path: root/recipes-connectivity/openssl/openssl-fsl/0011-RSA-Keygen-Fix.patch
blob: b2d636a4d0b78765d32f432a097c4bc3fa6b6ac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From f44fc935d5bc601cd625a64a366e64b19f2bb730 Mon Sep 17 00:00:00 2001
From: Yashpal Dutta <yashpal.dutta@freescale.com>
Date: Wed, 16 Apr 2014 22:53:04 +0545
Subject: [PATCH][fsl 11/15] RSA Keygen Fix

Upstream-status: Pending

If Kernel driver doesn't support RSA Keygen or same returns
error handling the keygen operation, the keygen is gracefully
handled by software supported rsa_keygen handler

Signed-off-by: Yashpal Dutta <yashpal.dutta@freescale.com>
Tested-by: Cristian Stoica <cristian.stoica@freescale.com>
---
 crypto/engine/eng_cryptodev.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c
index 0a6567c..5d54f7e 100644
--- a/crypto/engine/eng_cryptodev.c
+++ b/crypto/engine/eng_cryptodev.c
@@ -1921,7 +1921,7 @@ static int cryptodev_rsa_keygen(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)
 	int i;
 
 	if ((fd = get_asym_dev_crypto()) < 0)
-		return fd;
+		goto sw_try;
 
 	if(!rsa->n && ((rsa->n=BN_new()) == NULL)) goto err;
 	if(!rsa->d && ((rsa->d=BN_new()) == NULL)) goto err;
@@ -1942,7 +1942,7 @@ static int cryptodev_rsa_keygen(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)
 	/* p length */
 	kop.crk_param[kop.crk_iparams].crp_p = calloc(p_len + 1, sizeof(char));
 	if (!kop.crk_param[kop.crk_iparams].crp_p)
-		goto err;
+		goto sw_try;
 	kop.crk_param[kop.crk_iparams].crp_nbits = p_len * 8;
 	memset(kop.crk_param[kop.crk_iparams].crp_p, 0xff, p_len + 1);
 	kop.crk_iparams++;
@@ -1950,7 +1950,7 @@ static int cryptodev_rsa_keygen(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)
 	/* q length */
 	kop.crk_param[kop.crk_iparams].crp_p = calloc(q_len + 1, sizeof(char));
 	if (!kop.crk_param[kop.crk_iparams].crp_p)
-		goto err;
+		goto sw_try;
 	kop.crk_param[kop.crk_iparams].crp_nbits = q_len * 8;
 	memset(kop.crk_param[kop.crk_iparams].crp_p, 0xff, q_len + 1);
 	kop.crk_iparams++;
@@ -2015,8 +2015,10 @@ static int cryptodev_rsa_keygen(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb)
 	}
 sw_try:
 	{
-		const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
-		ret = (meth->rsa_keygen)(rsa, bits, e, cb);
+		const RSA_METHOD *meth = rsa->meth;
+		rsa->meth = RSA_PKCS1_SSLeay();
+		ret = RSA_generate_key_ex(rsa, bits, e, cb);
+		rsa->meth = meth;
 	}
 	return ret;
 
-- 
1.7.9.7