| 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 "chrome/browser/chromeos/platform_keys/platform_keys.h" | 5 #include "chrome/browser/chromeos/platform_keys/platform_keys.h" |
| 6 | 6 |
| 7 #include <cert.h> | 7 #include <cert.h> |
| 8 #include <cryptohi.h> | 8 #include <cryptohi.h> |
| 9 #include <keyhi.h> | 9 #include <keyhi.h> |
| 10 #include <secder.h> | 10 #include <secder.h> |
| 11 #include <stddef.h> |
| 12 #include <stdint.h> |
| 11 | 13 |
| 12 #include "base/bind.h" | 14 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
| 14 #include "base/callback.h" | 16 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 16 #include "base/location.h" | 18 #include "base/location.h" |
| 17 #include "base/logging.h" | 19 #include "base/logging.h" |
| 18 #include "base/macros.h" | 20 #include "base/macros.h" |
| 19 #include "base/single_thread_task_runner.h" | 21 #include "base/single_thread_task_runner.h" |
| 20 #include "base/thread_task_runner_handle.h" | 22 #include "base/thread_task_runner_handle.h" |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 439 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 438 // Only the slot and not the NSSCertDatabase is required. Ignore |cert_db|. | 440 // Only the slot and not the NSSCertDatabase is required. Ignore |cert_db|. |
| 439 base::WorkerPool::PostTask( | 441 base::WorkerPool::PostTask( |
| 440 FROM_HERE, | 442 FROM_HERE, |
| 441 base::Bind(&GenerateRSAKeyOnWorkerThread, base::Passed(&state)), | 443 base::Bind(&GenerateRSAKeyOnWorkerThread, base::Passed(&state)), |
| 442 true /*task is slow*/); | 444 true /*task is slow*/); |
| 443 } | 445 } |
| 444 | 446 |
| 445 // Does the actual signing on a worker thread. Used by SignRSAWithDB(). | 447 // Does the actual signing on a worker thread. Used by SignRSAWithDB(). |
| 446 void SignRSAOnWorkerThread(scoped_ptr<SignRSAState> state) { | 448 void SignRSAOnWorkerThread(scoped_ptr<SignRSAState> state) { |
| 447 const uint8* public_key_uint8 = | 449 const uint8_t* public_key_uint8 = |
| 448 reinterpret_cast<const uint8*>(state->public_key_.data()); | 450 reinterpret_cast<const uint8_t*>(state->public_key_.data()); |
| 449 std::vector<uint8> public_key_vector( | 451 std::vector<uint8_t> public_key_vector( |
| 450 public_key_uint8, public_key_uint8 + state->public_key_.size()); | 452 public_key_uint8, public_key_uint8 + state->public_key_.size()); |
| 451 | 453 |
| 452 crypto::ScopedSECKEYPrivateKey rsa_key; | 454 crypto::ScopedSECKEYPrivateKey rsa_key; |
| 453 if (state->slot_) { | 455 if (state->slot_) { |
| 454 rsa_key = crypto::FindNSSKeyFromPublicKeyInfoInSlot(public_key_vector, | 456 rsa_key = crypto::FindNSSKeyFromPublicKeyInfoInSlot(public_key_vector, |
| 455 state->slot_.get()); | 457 state->slot_.get()); |
| 456 } else { | 458 } else { |
| 457 rsa_key = crypto::FindNSSKeyFromPublicKeyInfo(public_key_vector); | 459 rsa_key = crypto::FindNSSKeyFromPublicKeyInfo(public_key_vector); |
| 458 } | 460 } |
| 459 | 461 |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 NSSOperationState* state_ptr = state.get(); | 890 NSSOperationState* state_ptr = state.get(); |
| 889 GetCertDatabase(std::string() /* don't get any specific slot */, | 891 GetCertDatabase(std::string() /* don't get any specific slot */, |
| 890 base::Bind(&GetTokensWithDB, base::Passed(&state)), | 892 base::Bind(&GetTokensWithDB, base::Passed(&state)), |
| 891 browser_context, | 893 browser_context, |
| 892 state_ptr); | 894 state_ptr); |
| 893 } | 895 } |
| 894 | 896 |
| 895 } // namespace platform_keys | 897 } // namespace platform_keys |
| 896 | 898 |
| 897 } // namespace chromeos | 899 } // namespace chromeos |
| OLD | NEW |