Browse Source

openssl: fix use of deprecated calls

rdb 8 years ago
parent
commit
4bcf225baf
2 changed files with 13 additions and 4 deletions
  1. 1 1
      dtool/src/prc/encryptStreamBuf.cxx
  2. 12 3
      dtool/src/prckeys/makePrcKey.cxx

+ 1 - 1
dtool/src/prc/encryptStreamBuf.cxx

@@ -236,7 +236,7 @@ open_write(ostream *dest, bool owns_dest, const string &password) {
   // Generate a random IV.  It doesn't need to be cryptographically secure,
   // Generate a random IV.  It doesn't need to be cryptographically secure,
   // just unique.
   // just unique.
   unsigned char *iv = (unsigned char *)alloca(iv_length);
   unsigned char *iv = (unsigned char *)alloca(iv_length);
-  RAND_pseudo_bytes(iv, iv_length);
+  RAND_bytes(iv, iv_length);
 
 
   _write_ctx = EVP_CIPHER_CTX_new();
   _write_ctx = EVP_CIPHER_CTX_new();
   nassertv(_write_ctx != NULL);
   nassertv(_write_ctx != NULL);

+ 12 - 3
dtool/src/prckeys/makePrcKey.cxx

@@ -108,16 +108,25 @@ output_c_string(ostream &out, const string &string_name,
  */
  */
 EVP_PKEY *
 EVP_PKEY *
 generate_key() {
 generate_key() {
-  RSA *rsa = RSA_generate_key(1024, 7, NULL, NULL);
+  RSA *rsa = RSA_new();
+  BIGNUM *e = BN_new();
+  if (rsa == nullptr || e == nullptr) {
+    output_ssl_errors();
+    exit(1);
+  }
 
 
-  if (rsa == (RSA *)NULL) {
+  BN_set_word(e, 7);
+
+  if (!RSA_generate_key_ex(rsa, 1024, e, nullptr)) {
+    BN_free(e);
+    RSA_free(rsa);
     output_ssl_errors();
     output_ssl_errors();
     exit(1);
     exit(1);
   }
   }
+  BN_free(e);
 
 
   EVP_PKEY *pkey = EVP_PKEY_new();
   EVP_PKEY *pkey = EVP_PKEY_new();
   EVP_PKEY_assign_RSA(pkey, rsa);
   EVP_PKEY_assign_RSA(pkey, rsa);
-
   return pkey;
   return pkey;
 }
 }