summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/net.gyp1
-rw-r--r--net/test/cert_test_util.h15
-rw-r--r--net/test/cert_test_util_nss.cc29
3 files changed, 17 insertions, 28 deletions
diff --git a/net/net.gyp b/net/net.gyp
index ca90dbb..2dcc2c8 100644
--- a/net/net.gyp
+++ b/net/net.gyp
@@ -506,6 +506,7 @@
# TODO(mmenke): This depends on icu, figure out a way to build tests
# without icu.
'../base/base.gyp:test_support_base',
+ '../crypto/crypto.gyp:crypto',
'../testing/gtest.gyp:gtest',
'../testing/gmock.gyp:gmock',
],
diff --git a/net/test/cert_test_util.h b/net/test/cert_test_util.h
index 8ad5664..219ccd8 100644
--- a/net/test/cert_test_util.h
+++ b/net/test/cert_test_util.h
@@ -12,8 +12,6 @@
#include "net/cert/x509_certificate.h"
#if defined(USE_NSS_CERTS)
-#include "base/memory/scoped_ptr.h"
-
// From <pk11pub.h>
typedef struct PK11SlotInfoStr PK11SlotInfo;
#endif
@@ -31,13 +29,12 @@ namespace net {
class EVRootCAMetadata;
#if defined(USE_NSS_CERTS)
-// Imports a private key from file |key_filename| in |dir|. The file must
-// contain a PKCS#8 PrivateKeyInfo in DER encoding. The key is imported to
-// |slot|.
-scoped_ptr<crypto::RSAPrivateKey> ImportSensitiveKeyFromFile(
- const base::FilePath& dir,
- const std::string& key_filename,
- PK11SlotInfo* slot);
+// Imports a private key from file |key_filename| in |dir| into |slot|. The file
+// must contain a PKCS#8 PrivateKeyInfo in DER encoding. Returns true on success
+// and false on failure.
+bool ImportSensitiveKeyFromFile(const base::FilePath& dir,
+ const std::string& key_filename,
+ PK11SlotInfo* slot);
bool ImportClientCertToSlot(const scoped_refptr<X509Certificate>& cert,
PK11SlotInfo* slot);
diff --git a/net/test/cert_test_util_nss.cc b/net/test/cert_test_util_nss.cc
index 74884c7..4427ceb 100644
--- a/net/test/cert_test_util_nss.cc
+++ b/net/test/cert_test_util_nss.cc
@@ -9,30 +9,22 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
+#include "crypto/nss_key_util.h"
#include "crypto/nss_util.h"
-#include "crypto/rsa_private_key.h"
+#include "crypto/scoped_nss_types.h"
#include "net/cert/cert_type.h"
namespace net {
-scoped_ptr<crypto::RSAPrivateKey> ImportSensitiveKeyFromFile(
- const base::FilePath& dir,
- const std::string& key_filename,
- PK11SlotInfo* slot) {
-#if defined(USE_OPENSSL)
- // TODO(davidben): Port RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo away
- // from RSAPrivateKey so it doesn't make assumptions about the internal crypto
- // library. Instead, return a ScopedSECKEYPrivateKey or have this function
- // just return bool. https://crbug.com/478777
- NOTIMPLEMENTED();
- return nullptr;
-#else
+bool ImportSensitiveKeyFromFile(const base::FilePath& dir,
+ const std::string& key_filename,
+ PK11SlotInfo* slot) {
base::FilePath key_path = dir.AppendASCII(key_filename);
std::string key_pkcs8;
bool success = base::ReadFileToString(key_path, &key_pkcs8);
if (!success) {
LOG(ERROR) << "Failed to read file " << key_path.value();
- return scoped_ptr<crypto::RSAPrivateKey>();
+ return false;
}
const uint8* key_pkcs8_begin =
@@ -40,13 +32,12 @@ scoped_ptr<crypto::RSAPrivateKey> ImportSensitiveKeyFromFile(
std::vector<uint8> key_vector(key_pkcs8_begin,
key_pkcs8_begin + key_pkcs8.length());
- scoped_ptr<crypto::RSAPrivateKey> private_key(
- crypto::RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo(slot,
- key_vector));
+ crypto::ScopedSECKEYPrivateKey private_key(
+ crypto::ImportNSSKeyFromPrivateKeyInfo(slot, key_vector,
+ true /* permanent */));
LOG_IF(ERROR, !private_key) << "Could not create key from file "
<< key_path.value();
- return private_key.Pass();
-#endif
+ return private_key;
}
bool ImportClientCertToSlot(const scoped_refptr<X509Certificate>& cert,