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

Side by Side Diff: chrome/browser/chromeos/platform_keys/platform_keys_nss.cc

Issue 2898573002: Refactor client cert private key handling. (Closed)
Patch Set: removed no longer needed forward declaration Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <cert.h> 5 #include <cert.h>
6 #include <cryptohi.h> 6 #include <cryptohi.h>
7 #include <keyhi.h> 7 #include <keyhi.h>
8 #include <secder.h> 8 #include <secder.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 {base::MayBlock(), base::TaskPriority::BACKGROUND, 539 {base::MayBlock(), base::TaskPriority::BACKGROUND,
540 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, 540 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
541 base::Bind(&SignRSAOnWorkerThread, base::Passed(&state))); 541 base::Bind(&SignRSAOnWorkerThread, base::Passed(&state)));
542 } 542 }
543 543
544 // Called when ClientCertStoreChromeOS::GetClientCerts is done. Builds the list 544 // Called when ClientCertStoreChromeOS::GetClientCerts is done. Builds the list
545 // of net::CertificateList and calls back. Used by 545 // of net::CertificateList and calls back. Used by
546 // SelectCertificatesOnIOThread(). 546 // SelectCertificatesOnIOThread().
547 void DidSelectCertificatesOnIOThread( 547 void DidSelectCertificatesOnIOThread(
548 std::unique_ptr<SelectCertificatesState> state, 548 std::unique_ptr<SelectCertificatesState> state,
549 net::CertificateList certs) { 549 net::ClientCertIdentityList identities) {
550 DCHECK_CURRENTLY_ON(BrowserThread::IO); 550 DCHECK_CURRENTLY_ON(BrowserThread::IO);
551 state->CallBack(FROM_HERE, 551 // Convert the ClientCertIdentityList to a CertificateList since returning
552 base::MakeUnique<net::CertificateList>(std::move(certs)), 552 // ClientCertIdentities would require changing the platformKeys extension
553 std::string() /* no error */); 553 // api. This assumes that the necessary keys can be found later with
554 // crypto::FindNSSKeyFromPublicKeyInfo.
555 std::unique_ptr<net::CertificateList> certs =
556 base::MakeUnique<net::CertificateList>();
557 for (const std::unique_ptr<net::ClientCertIdentity>& identity : identities)
558 certs->push_back(identity->certificate());
559 state->CallBack(FROM_HERE, std::move(certs), std::string() /* no error */);
554 } 560 }
555 561
556 // Continues selecting certificates on the IO thread. Used by 562 // Continues selecting certificates on the IO thread. Used by
557 // SelectClientCertificates(). 563 // SelectClientCertificates().
558 void SelectCertificatesOnIOThread( 564 void SelectCertificatesOnIOThread(
559 std::unique_ptr<SelectCertificatesState> state) { 565 std::unique_ptr<SelectCertificatesState> state) {
560 DCHECK_CURRENTLY_ON(BrowserThread::IO); 566 DCHECK_CURRENTLY_ON(BrowserThread::IO);
561 state->cert_store_.reset(new ClientCertStoreChromeOS( 567 state->cert_store_.reset(new ClientCertStoreChromeOS(
562 nullptr, // no additional provider 568 nullptr, // no additional provider
563 base::MakeUnique<ClientCertFilterChromeOS>(state->use_system_key_slot_, 569 base::MakeUnique<ClientCertFilterChromeOS>(state->use_system_key_slot_,
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 NSSOperationState* state_ptr = state.get(); 905 NSSOperationState* state_ptr = state.get();
900 GetCertDatabase(std::string() /* don't get any specific slot */, 906 GetCertDatabase(std::string() /* don't get any specific slot */,
901 base::Bind(&GetTokensWithDB, base::Passed(&state)), 907 base::Bind(&GetTokensWithDB, base::Passed(&state)),
902 browser_context, 908 browser_context,
903 state_ptr); 909 state_ptr);
904 } 910 }
905 911
906 } // namespace platform_keys 912 } // namespace platform_keys
907 913
908 } // namespace chromeos 914 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698