[hipl-dev] [Merge] lp:~scolphoy/hipl/RSA_generate_key_ex into lp:hipl

  • From: Juhani Toivonen <juhani.toivonen@xxxxxxxxxxxxxx>
  • To: mp+186684@xxxxxxxxxxxxxxxxxx
  • Date: Thu, 19 Sep 2013 22:53:25 -0000

Juhani Toivonen has proposed merging lp:~scolphoy/hipl/RSA_generate_key_ex into 
lp:hipl.

Requested reviews:
  HIPL core team (hipl-core)

For more details, see:
https://code.launchpad.net/~scolphoy/hipl/RSA_generate_key_ex/+merge/186684

Change RSA_generate_key to RSA_generate_key_ex in crypto.c

The RSA_generate_key function has been deprecated in OpenSSL
in favour of the newer function RSA_generate_key_ex.
http://www.openssl.org/docs/crypto/RSA_generate_key.html

RSA_generate_key_ex with its current interface has been 
part of OpenSSL starting from version 0.9.8 (July 2005).
Granted it still remains a bit poorly documented.

If OpenSSL was compiled with the 'no-deprecated' argument,
the old function will not be available. This is the case
e.g. with modern versions of Android.

I tried compiling the revision from trunk added with
these changes and connecting to a hip-enabled host; 
I found no difference in operation compared to using
the older function.
-- 
https://code.launchpad.net/~scolphoy/hipl/RSA_generate_key_ex/+merge/186684
Your team HIPL core team is requested to review the proposed merge of 
lp:~scolphoy/hipl/RSA_generate_key_ex into lp:hipl.
=== modified file 'libcore/crypto.c'
--- libcore/crypto.c    2012-05-12 06:54:33 +0000
+++ libcore/crypto.c    2013-09-19 22:52:14 +0000
@@ -766,13 +766,14 @@
  */
 RSA *create_rsa_key(const int bits)
 {
-    RSA *rsa = NULL;
+    RSA    *rsa = RSA_new();
+    BIGNUM *f4  = BN_new();
+    BN_set_word(f4, RSA_F4);
 
     /* generate private and public keys */
     HIP_DEBUG("*****************Creating RSA of %d bits\n\n\n", bits);
-    rsa = RSA_generate_key(bits, RSA_F4, NULL, NULL);
-    if (!rsa) {
-        HIP_ERROR("create_rsa_key failed (RSA_generate_key): %s\n",
+    if (!RSA_generate_key_ex(rsa, bits, f4, NULL)) {
+        HIP_ERROR("create_rsa_key failed (RSA_generate_key_ex): %s\n",
                   ERR_error_string(ERR_get_error(), NULL));
         goto err_out;
     }

Other related posts: