| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/api/platform_keys/platform_keys_api.h" | 5 #include "chrome/browser/extensions/api/platform_keys/platform_keys_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 void PlatformKeysInternalSelectClientCertificatesFunction:: | 241 void PlatformKeysInternalSelectClientCertificatesFunction:: |
| 242 OnSelectedCertificates(scoped_ptr<net::CertificateList> matches, | 242 OnSelectedCertificates(scoped_ptr<net::CertificateList> matches, |
| 243 const std::string& error_message) { | 243 const std::string& error_message) { |
| 244 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 244 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 245 | 245 |
| 246 if (!error_message.empty()) { | 246 if (!error_message.empty()) { |
| 247 Respond(Error(error_message)); | 247 Respond(Error(error_message)); |
| 248 return; | 248 return; |
| 249 } | 249 } |
| 250 DCHECK(matches); | 250 DCHECK(matches); |
| 251 std::vector<linked_ptr<api_pk::Match>> result_matches; | 251 std::vector<api_pk::Match> result_matches; |
| 252 for (const scoped_refptr<net::X509Certificate>& match : *matches) { | 252 for (const scoped_refptr<net::X509Certificate>& match : *matches) { |
| 253 PublicKeyInfo key_info; | 253 PublicKeyInfo key_info; |
| 254 key_info.public_key_spki_der = | 254 key_info.public_key_spki_der = |
| 255 chromeos::platform_keys::GetSubjectPublicKeyInfo(match); | 255 chromeos::platform_keys::GetSubjectPublicKeyInfo(match); |
| 256 if (!chromeos::platform_keys::GetPublicKey(match, &key_info.key_type, | 256 if (!chromeos::platform_keys::GetPublicKey(match, &key_info.key_type, |
| 257 &key_info.key_size_bits)) { | 257 &key_info.key_size_bits)) { |
| 258 LOG(ERROR) << "Could not retrieve public key info."; | 258 LOG(ERROR) << "Could not retrieve public key info."; |
| 259 continue; | 259 continue; |
| 260 } | 260 } |
| 261 if (key_info.key_type != net::X509Certificate::kPublicKeyTypeRSA) { | 261 if (key_info.key_type != net::X509Certificate::kPublicKeyTypeRSA) { |
| 262 LOG(ERROR) << "Skipping unsupported certificate with non-RSA key."; | 262 LOG(ERROR) << "Skipping unsupported certificate with non-RSA key."; |
| 263 continue; | 263 continue; |
| 264 } | 264 } |
| 265 | 265 |
| 266 linked_ptr<api_pk::Match> result_match(new api_pk::Match); | 266 api_pk::Match result_match; |
| 267 std::string der_encoded_cert; | 267 std::string der_encoded_cert; |
| 268 net::X509Certificate::GetDEREncoded(match->os_cert_handle(), | 268 net::X509Certificate::GetDEREncoded(match->os_cert_handle(), |
| 269 &der_encoded_cert); | 269 &der_encoded_cert); |
| 270 result_match->certificate.assign(der_encoded_cert.begin(), | 270 result_match.certificate.assign(der_encoded_cert.begin(), |
| 271 der_encoded_cert.end()); | 271 der_encoded_cert.end()); |
| 272 | 272 |
| 273 BuildWebCryptoRSAAlgorithmDictionary( | 273 BuildWebCryptoRSAAlgorithmDictionary( |
| 274 key_info, &result_match->key_algorithm.additional_properties); | 274 key_info, &result_match.key_algorithm.additional_properties); |
| 275 result_matches.push_back(result_match); | 275 result_matches.push_back(std::move(result_match)); |
| 276 } | 276 } |
| 277 Respond(ArgumentList( | 277 Respond(ArgumentList( |
| 278 api_pki::SelectClientCertificates::Results::Create(result_matches))); | 278 api_pki::SelectClientCertificates::Results::Create(result_matches))); |
| 279 } | 279 } |
| 280 | 280 |
| 281 PlatformKeysInternalSignFunction::~PlatformKeysInternalSignFunction() { | 281 PlatformKeysInternalSignFunction::~PlatformKeysInternalSignFunction() { |
| 282 } | 282 } |
| 283 | 283 |
| 284 ExtensionFunction::ResponseAction PlatformKeysInternalSignFunction::Run() { | 284 ExtensionFunction::ResponseAction PlatformKeysInternalSignFunction::Run() { |
| 285 scoped_ptr<api_pki::Sign::Params> params( | 285 scoped_ptr<api_pki::Sign::Params> params( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 result.debug_errors.push_back(kCertStatusErrors[i].name); | 384 result.debug_errors.push_back(kCertStatusErrors[i].name); |
| 385 } | 385 } |
| 386 } | 386 } |
| 387 } | 387 } |
| 388 | 388 |
| 389 Respond(ArgumentList( | 389 Respond(ArgumentList( |
| 390 api_pk::VerifyTLSServerCertificate::Results::Create(result))); | 390 api_pk::VerifyTLSServerCertificate::Results::Create(result))); |
| 391 } | 391 } |
| 392 | 392 |
| 393 } // namespace extensions | 393 } // namespace extensions |
| OLD | NEW |