Turns out RSA_generate_key is deprecated and  is removed on some platforms, so using the lesser-documented RSA_generate_key_ex method instead.

Also removes usage of the imaginary vector<>::data() method.

BUG=None
TEST=base_unittests filter=*RSA*

Review URL: http://codereview.chromium.org/5603013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68598 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/crypto/rsa_private_key_openssl.cc b/base/crypto/rsa_private_key_openssl.cc
index 0776b63..891ea52 100644
--- a/base/crypto/rsa_private_key_openssl.cc
+++ b/base/crypto/rsa_private_key_openssl.cc
@@ -50,9 +50,13 @@
 // static
 RSAPrivateKey* RSAPrivateKey::Create(uint16 num_bits) {
   OpenSSLErrStackTracer err_tracer(FROM_HERE);
-  ScopedOpenSSL<RSA, RSA_free> rsa_key(RSA_generate_key(num_bits, 65537L,
-                                                        NULL, NULL));
-  if (!rsa_key.get())
+
+  ScopedOpenSSL<RSA, RSA_free> rsa_key(RSA_new());
+  ScopedOpenSSL<BIGNUM, BN_free> bn(BN_new());
+  if (!rsa_key.get() || !bn.get() || !BN_set_word(bn.get(), 65537L))
+    return NULL;
+
+  if (!RSA_generate_key_ex(rsa_key.get(), num_bits, bn.get(), NULL))
     return NULL;
 
   scoped_ptr<RSAPrivateKey> result(new RSAPrivateKey);
@@ -75,7 +79,8 @@
   OpenSSLErrStackTracer err_tracer(FROM_HERE);
 
   // BIO_new_mem_buf is not const aware, but it does not modify the buffer.
-  char* data = reinterpret_cast<char*>(const_cast<uint8*>(input.data()));
+  char* data = reinterpret_cast<char*>(const_cast<uint8*>(
+      vector_as_array(&input)));
   ScopedOpenSSL<BIO, BIO_free_all> bio(BIO_new_mem_buf(data, input.size()));
   if (!bio.get())
     return NULL;