Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: net/test/cert_test_util_nss.cc

Issue 1106103003: Don't use RSAPrivateKey in NSS integration code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ocsp-refactor
Patch Set: pneubeck comments Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« components/ownership.gypi ('K') | « net/test/cert_test_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/cert_test_util_nss.cc
diff --git a/net/test/cert_test_util_nss.cc b/net/test/cert_test_util_nss.cc
index 74884c7dd6c53117f202a7200d845e16ec0a10b7..4427cebe117deb1de458b46f4bf70f63db0209a8 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,
« components/ownership.gypi ('K') | « net/test/cert_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698