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