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

Unified Diff: chrome/browser/chromeos/platform_keys/platform_keys_service.cc

Issue 1141253003: chrome.platformKeys: Add filtering by certificate types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: chrome/browser/chromeos/platform_keys/platform_keys_service.cc
diff --git a/chrome/browser/chromeos/platform_keys/platform_keys_service.cc b/chrome/browser/chromeos/platform_keys/platform_keys_service.cc
index d4c38a66f3bdbe549cac32bb84082b2ed1fc8208..78cd351f80856a9bd82b5ba34c183387a597d69f 100644
--- a/chrome/browser/chromeos/platform_keys/platform_keys_service.cc
+++ b/chrome/browser/chromeos/platform_keys/platform_keys_service.cc
@@ -498,7 +498,30 @@ class PlatformKeysService::SelectTask : public Task {
DoStep();
return;
}
- matches_.swap(*matches);
+
+ // If the type field does not contain any entries, all certificate types
+ // shall be returned.
+ if (request_.certificate_key_types.size() == 0) {
+ matches_.swap(*matches);
+ DoStep();
+ return;
+ }
+
+ // Filter the retrieved certificates allowing only those whose type is
+ // contained in the type list of the certificate request.
+ for (scoped_refptr<net::X509Certificate>& certificate : *matches) {
+ net::X509Certificate::PublicKeyType key_type_tmp =
pneubeck (no reviews) 2015/05/19 10:09:00 maybe key_type_tmp -> actual_key_type
cschuet (SLOW) 2015/05/19 11:36:23 Done.
+ net::X509Certificate::kPublicKeyTypeUnknown;
+ size_t key_size_bits_tmp = 0;
pneubeck (no reviews) 2015/05/19 10:09:00 maybe s/_tmp// or maybe call it unused_key_size
cschuet (SLOW) 2015/05/19 11:36:23 Done.
+ net::X509Certificate::GetPublicKeyInfo(certificate->os_cert_handle(),
+ &key_size_bits_tmp, &key_type_tmp);
+ const std::vector<net::X509Certificate::PublicKeyType>& accepted_types =
+ request_.certificate_key_types;
+ if (std::find(accepted_types.begin(), accepted_types.end(),
+ key_type_tmp) != accepted_types.end()) {
+ matches_.push_back(certificate.Pass());
+ }
+ }
DoStep();
}

Powered by Google App Engine
This is Rietveld 408576698