OLD | NEW |
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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 } | 434 } |
435 | 435 |
436 // Continues generating a RSA key with the obtained NSSCertDatabase. Used by | 436 // Continues generating a RSA key with the obtained NSSCertDatabase. Used by |
437 // GenerateRSAKey(). | 437 // GenerateRSAKey(). |
438 void GenerateRSAKeyWithDB(std::unique_ptr<GenerateRSAKeyState> state, | 438 void GenerateRSAKeyWithDB(std::unique_ptr<GenerateRSAKeyState> state, |
439 net::NSSCertDatabase* cert_db) { | 439 net::NSSCertDatabase* cert_db) { |
440 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 440 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
441 // Only the slot and not the NSSCertDatabase is required. Ignore |cert_db|. | 441 // Only the slot and not the NSSCertDatabase is required. Ignore |cert_db|. |
442 // This task interacts with the TPM, hence MayBlock(). | 442 // This task interacts with the TPM, hence MayBlock(). |
443 base::PostTaskWithTraits( | 443 base::PostTaskWithTraits( |
444 FROM_HERE, base::TaskTraits() | 444 FROM_HERE, |
445 .MayBlock() | 445 {base::MayBlock(), base::TaskPriority::BACKGROUND, |
446 .WithPriority(base::TaskPriority::BACKGROUND) | 446 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, |
447 .WithShutdownBehavior( | |
448 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), | |
449 base::Bind(&GenerateRSAKeyOnWorkerThread, base::Passed(&state))); | 447 base::Bind(&GenerateRSAKeyOnWorkerThread, base::Passed(&state))); |
450 } | 448 } |
451 | 449 |
452 // Does the actual signing on a worker thread. Used by SignRSAWithDB(). | 450 // Does the actual signing on a worker thread. Used by SignRSAWithDB(). |
453 void SignRSAOnWorkerThread(std::unique_ptr<SignRSAState> state) { | 451 void SignRSAOnWorkerThread(std::unique_ptr<SignRSAState> state) { |
454 const uint8_t* public_key_uint8 = | 452 const uint8_t* public_key_uint8 = |
455 reinterpret_cast<const uint8_t*>(state->public_key_.data()); | 453 reinterpret_cast<const uint8_t*>(state->public_key_.data()); |
456 std::vector<uint8_t> public_key_vector( | 454 std::vector<uint8_t> public_key_vector( |
457 public_key_uint8, public_key_uint8 + state->public_key_.size()); | 455 public_key_uint8, public_key_uint8 + state->public_key_.size()); |
458 | 456 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 state->CallBack(FROM_HERE, signature_str, std::string() /* no error */); | 528 state->CallBack(FROM_HERE, signature_str, std::string() /* no error */); |
531 } | 529 } |
532 | 530 |
533 // Continues signing with the obtained NSSCertDatabase. Used by Sign(). | 531 // Continues signing with the obtained NSSCertDatabase. Used by Sign(). |
534 void SignRSAWithDB(std::unique_ptr<SignRSAState> state, | 532 void SignRSAWithDB(std::unique_ptr<SignRSAState> state, |
535 net::NSSCertDatabase* cert_db) { | 533 net::NSSCertDatabase* cert_db) { |
536 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 534 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
537 // Only the slot and not the NSSCertDatabase is required. Ignore |cert_db|. | 535 // Only the slot and not the NSSCertDatabase is required. Ignore |cert_db|. |
538 // This task interacts with the TPM, hence MayBlock(). | 536 // This task interacts with the TPM, hence MayBlock(). |
539 base::PostTaskWithTraits( | 537 base::PostTaskWithTraits( |
540 FROM_HERE, base::TaskTraits() | 538 FROM_HERE, |
541 .MayBlock() | 539 {base::MayBlock(), base::TaskPriority::BACKGROUND, |
542 .WithPriority(base::TaskPriority::BACKGROUND) | 540 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, |
543 .WithShutdownBehavior( | |
544 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), | |
545 base::Bind(&SignRSAOnWorkerThread, base::Passed(&state))); | 541 base::Bind(&SignRSAOnWorkerThread, base::Passed(&state))); |
546 } | 542 } |
547 | 543 |
548 // Called when ClientCertStoreChromeOS::GetClientCerts is done. Builds the list | 544 // Called when ClientCertStoreChromeOS::GetClientCerts is done. Builds the list |
549 // of net::CertificateList and calls back. Used by | 545 // of net::CertificateList and calls back. Used by |
550 // SelectCertificatesOnIOThread(). | 546 // SelectCertificatesOnIOThread(). |
551 void DidSelectCertificatesOnIOThread( | 547 void DidSelectCertificatesOnIOThread( |
552 std::unique_ptr<SelectCertificatesState> state, | 548 std::unique_ptr<SelectCertificatesState> state, |
553 net::CertificateList certs) { | 549 net::CertificateList certs) { |
554 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 550 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 } | 596 } |
601 | 597 |
602 // Passes the obtained certificates to the worker thread for filtering. Used by | 598 // Passes the obtained certificates to the worker thread for filtering. Used by |
603 // GetCertificatesWithDB(). | 599 // GetCertificatesWithDB(). |
604 void DidGetCertificates(std::unique_ptr<GetCertificatesState> state, | 600 void DidGetCertificates(std::unique_ptr<GetCertificatesState> state, |
605 std::unique_ptr<net::CertificateList> all_certs) { | 601 std::unique_ptr<net::CertificateList> all_certs) { |
606 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 602 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
607 state->certs_ = std::move(all_certs); | 603 state->certs_ = std::move(all_certs); |
608 // This task interacts with the TPM, hence MayBlock(). | 604 // This task interacts with the TPM, hence MayBlock(). |
609 base::PostTaskWithTraits( | 605 base::PostTaskWithTraits( |
610 FROM_HERE, base::TaskTraits() | 606 FROM_HERE, |
611 .MayBlock() | 607 {base::MayBlock(), base::TaskPriority::BACKGROUND, |
612 .WithPriority(base::TaskPriority::BACKGROUND) | 608 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, |
613 .WithShutdownBehavior( | |
614 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN), | |
615 base::Bind(&FilterCertificatesOnWorkerThread, base::Passed(&state))); | 609 base::Bind(&FilterCertificatesOnWorkerThread, base::Passed(&state))); |
616 } | 610 } |
617 | 611 |
618 // Continues getting certificates with the obtained NSSCertDatabase. Used by | 612 // Continues getting certificates with the obtained NSSCertDatabase. Used by |
619 // GetCertificates(). | 613 // GetCertificates(). |
620 void GetCertificatesWithDB(std::unique_ptr<GetCertificatesState> state, | 614 void GetCertificatesWithDB(std::unique_ptr<GetCertificatesState> state, |
621 net::NSSCertDatabase* cert_db) { | 615 net::NSSCertDatabase* cert_db) { |
622 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 616 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
623 // Get the pointer to slot before base::Passed releases |state|. | 617 // Get the pointer to slot before base::Passed releases |state|. |
624 PK11SlotInfo* slot = state->slot_.get(); | 618 PK11SlotInfo* slot = state->slot_.get(); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 NSSOperationState* state_ptr = state.get(); | 899 NSSOperationState* state_ptr = state.get(); |
906 GetCertDatabase(std::string() /* don't get any specific slot */, | 900 GetCertDatabase(std::string() /* don't get any specific slot */, |
907 base::Bind(&GetTokensWithDB, base::Passed(&state)), | 901 base::Bind(&GetTokensWithDB, base::Passed(&state)), |
908 browser_context, | 902 browser_context, |
909 state_ptr); | 903 state_ptr); |
910 } | 904 } |
911 | 905 |
912 } // namespace platform_keys | 906 } // namespace platform_keys |
913 | 907 |
914 } // namespace chromeos | 908 } // namespace chromeos |
OLD | NEW |