[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] pki_crypto: Replace deprecated RSA_generate_key() with RSA_generate_key_ex()


Hi guys.

This fixes problem on platforms (like Android) where OpenSSL is compiled with
-no-deprecated option so there is no RSA_generate_key function in library.

Regards,
Petar

Signed-off-by: Petar Koretic <petar.koretic@xxxxxxxxxx>
---
 src/pki_crypto.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/pki_crypto.c b/src/pki_crypto.c
index 89bb538..9ca7760 100644
--- a/src/pki_crypto.c
+++ b/src/pki_crypto.c
@@ -383,8 +383,16 @@ fail:
 }
 
 int pki_key_generate_rsa(ssh_key key, int parameter){
-    key->rsa = RSA_generate_key(parameter, 65537, NULL, NULL);
-    if(key->rsa == NULL)
+	BIGNUM *e;
+	e = BN_new();
+	BN_set_word(e, 65537);
+
+	RSA_generate_key_ex(key->rsa, parameter, e, NULL);
+
+	BN_free(e);
+	e = NULL;
+
+	if(key->rsa == NULL)
         return SSH_ERROR;
     return SSH_OK;
 }
-- 
1.9.0


Archive administrator: postmaster@lists.cynapses.org