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

Unified Diff: components/ownership/owner_key_util_impl.cc

Issue 1128153003: Reland "Don't use RSAPrivateKey in NSS integration code." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add TODO Created 5 years, 7 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
« no previous file with comments | « components/ownership/BUILD.gn ('k') | crypto/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ownership/owner_key_util_impl.cc
diff --git a/components/ownership/owner_key_util_impl.cc b/components/ownership/owner_key_util_impl.cc
index bc7208e4642d21603513324d40236fddf4a4207c..5a400d52012561993048dc1d437bc04320d1316b 100644
--- a/components/ownership/owner_key_util_impl.cc
+++ b/components/ownership/owner_key_util_impl.cc
@@ -8,7 +8,12 @@
#include "base/files/file_util.h"
#include "base/logging.h"
+
+#if defined(USE_NSS_CERTS)
+#include <keythi.h>
+#include "crypto/nss_key_util.h"
#include "crypto/rsa_private_key.h"
+#endif
namespace ownership {
@@ -54,7 +59,21 @@ bool OwnerKeyUtilImpl::ImportPublicKey(std::vector<uint8>* output) {
crypto::RSAPrivateKey* OwnerKeyUtilImpl::FindPrivateKeyInSlot(
const std::vector<uint8>& key,
PK11SlotInfo* slot) {
- return crypto::RSAPrivateKey::FindFromPublicKeyInfoInSlot(key, slot);
+ if (!slot)
+ return nullptr;
+
+ crypto::ScopedSECKEYPrivateKey private_key(
+ crypto::FindNSSKeyFromPublicKeyInfoInSlot(key, slot));
+ if (!private_key || SECKEY_GetPrivateKeyType(private_key.get()) != rsaKey)
+ return nullptr;
+#if defined(USE_OPENSSL)
+ // TODO(davidben): This assumes that crypto::RSAPrivateKey also uses NSS.
+ // https://crbug.com/478777
+ NOTIMPLEMENTED();
+ return nullptr;
+#else
+ return crypto::RSAPrivateKey::CreateFromKey(private_key.get());
+#endif
}
#endif // defined(USE_NSS_CERTS)
« no previous file with comments | « components/ownership/BUILD.gn ('k') | crypto/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698