| 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 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/location.h" | 16 #include "base/location.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 20 #include "base/stl_util.h" | |
| 21 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
| 22 #include "base/threading/worker_pool.h" | 21 #include "base/threading/worker_pool.h" |
| 23 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 23 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
| 25 #include "chrome/browser/chromeos/certificate_provider/certificate_provider.h" | 24 #include "chrome/browser/chromeos/certificate_provider/certificate_provider.h" |
| 26 #include "chrome/browser/chromeos/net/client_cert_filter_chromeos.h" | 25 #include "chrome/browser/chromeos/net/client_cert_filter_chromeos.h" |
| 27 #include "chrome/browser/chromeos/net/client_cert_store_chromeos.h" | 26 #include "chrome/browser/chromeos/net/client_cert_store_chromeos.h" |
| 28 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 27 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 29 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 28 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 30 #include "chrome/browser/extensions/api/enterprise_platform_keys/enterprise_plat
form_keys_api.h" | 29 #include "chrome/browser/extensions/api/enterprise_platform_keys/enterprise_plat
form_keys_api.h" |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 state->data_.size()}; | 475 state->data_.size()}; |
| 477 | 476 |
| 478 // Compute signature of hash. | 477 // Compute signature of hash. |
| 479 int signature_len = PK11_SignatureLen(rsa_key.get()); | 478 int signature_len = PK11_SignatureLen(rsa_key.get()); |
| 480 if (signature_len <= 0) { | 479 if (signature_len <= 0) { |
| 481 state->OnError(FROM_HERE, kErrorInternal); | 480 state->OnError(FROM_HERE, kErrorInternal); |
| 482 return; | 481 return; |
| 483 } | 482 } |
| 484 | 483 |
| 485 std::vector<unsigned char> signature(signature_len); | 484 std::vector<unsigned char> signature(signature_len); |
| 486 SECItem signature_output = { | 485 SECItem signature_output = {siBuffer, signature.data(), signature.size()}; |
| 487 siBuffer, vector_as_array(&signature), signature.size()}; | |
| 488 if (PK11_Sign(rsa_key.get(), &signature_output, &input) == SECSuccess) | 486 if (PK11_Sign(rsa_key.get(), &signature_output, &input) == SECSuccess) |
| 489 signature_str.assign(signature.begin(), signature.end()); | 487 signature_str.assign(signature.begin(), signature.end()); |
| 490 } else { | 488 } else { |
| 491 SECOidTag sign_alg_tag = SEC_OID_UNKNOWN; | 489 SECOidTag sign_alg_tag = SEC_OID_UNKNOWN; |
| 492 switch (state->hash_algorithm_) { | 490 switch (state->hash_algorithm_) { |
| 493 case HASH_ALGORITHM_SHA1: | 491 case HASH_ALGORITHM_SHA1: |
| 494 sign_alg_tag = SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION; | 492 sign_alg_tag = SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION; |
| 495 break; | 493 break; |
| 496 case HASH_ALGORITHM_SHA256: | 494 case HASH_ALGORITHM_SHA256: |
| 497 sign_alg_tag = SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION; | 495 sign_alg_tag = SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION; |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 NSSOperationState* state_ptr = state.get(); | 892 NSSOperationState* state_ptr = state.get(); |
| 895 GetCertDatabase(std::string() /* don't get any specific slot */, | 893 GetCertDatabase(std::string() /* don't get any specific slot */, |
| 896 base::Bind(&GetTokensWithDB, base::Passed(&state)), | 894 base::Bind(&GetTokensWithDB, base::Passed(&state)), |
| 897 browser_context, | 895 browser_context, |
| 898 state_ptr); | 896 state_ptr); |
| 899 } | 897 } |
| 900 | 898 |
| 901 } // namespace platform_keys | 899 } // namespace platform_keys |
| 902 | 900 |
| 903 } // namespace chromeos | 901 } // namespace chromeos |
| OLD | NEW |