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/login/easy_unlock/easy_unlock_tpm_key_manager. h" | 5 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager. h" |
6 | 6 |
7 #include <cryptohi.h> | 7 #include <cryptohi.h> |
8 #include <keyhi.h> | 8 #include <keyhi.h> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 // |slot|. | 59 // |slot|. |
60 // Must be called on a worker thread. | 60 // Must be called on a worker thread. |
61 crypto::ScopedSECKEYPrivateKey GetPrivateKeyOnWorkerThread( | 61 crypto::ScopedSECKEYPrivateKey GetPrivateKeyOnWorkerThread( |
62 PK11SlotInfo* slot, | 62 PK11SlotInfo* slot, |
63 const std::string& public_key) { | 63 const std::string& public_key) { |
64 const uint8* public_key_uint8 = | 64 const uint8* public_key_uint8 = |
65 reinterpret_cast<const uint8*>(public_key.data()); | 65 reinterpret_cast<const uint8*>(public_key.data()); |
66 std::vector<uint8> public_key_vector( | 66 std::vector<uint8> public_key_vector( |
67 public_key_uint8, public_key_uint8 + public_key.size()); | 67 public_key_uint8, public_key_uint8 + public_key.size()); |
68 | 68 |
69 // TODO(davidben): This should be equivalent to calling | |
70 // FindNSSKeyFromPublicKeyInfoInSlot. | |
71 crypto::ScopedSECKEYPrivateKey rsa_key( | 69 crypto::ScopedSECKEYPrivateKey rsa_key( |
72 crypto::FindNSSKeyFromPublicKeyInfo(public_key_vector)); | 70 crypto::FindNSSKeyFromPublicKeyInfoInSlot(public_key_vector, slot)); |
pneubeck (no reviews)
2015/05/12 09:48:38
for clarification: this is only equivalent if slot
davidben
2015/05/12 18:00:42
Done. (There are CHECKs up the call chain, so this
| |
73 if (!rsa_key || rsa_key->pkcs11Slot != slot || | 71 if (!rsa_key || SECKEY_GetPrivateKeyType(rsa_key.get()) != rsaKey) |
74 SECKEY_GetPrivateKeyType(rsa_key.get()) != rsaKey) { | |
75 return nullptr; | 72 return nullptr; |
76 } | |
77 return rsa_key.Pass(); | 73 return rsa_key.Pass(); |
78 } | 74 } |
79 | 75 |
80 // Signs |data| using a private key associated with |public_key| and stored in | 76 // Signs |data| using a private key associated with |public_key| and stored in |
81 // |slot|. Once the data is signed, callback is run on |response_task_runner|. | 77 // |slot|. Once the data is signed, callback is run on |response_task_runner|. |
82 // In case of an error, the callback will be passed an empty string. | 78 // In case of an error, the callback will be passed an empty string. |
83 void SignDataOnWorkerThread( | 79 void SignDataOnWorkerThread( |
84 crypto::ScopedPK11Slot slot, | 80 crypto::ScopedPK11Slot slot, |
85 const std::string& public_key, | 81 const std::string& public_key, |
86 const std::string& data, | 82 const std::string& data, |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 // If key creation failed, reset the state machine. | 348 // If key creation failed, reset the state machine. |
353 create_tpm_key_state_ = | 349 create_tpm_key_state_ = |
354 public_key.empty() ? CREATE_TPM_KEY_NOT_STARTED : CREATE_TPM_KEY_DONE; | 350 public_key.empty() ? CREATE_TPM_KEY_NOT_STARTED : CREATE_TPM_KEY_DONE; |
355 } | 351 } |
356 | 352 |
357 void EasyUnlockTpmKeyManager::OnDataSigned( | 353 void EasyUnlockTpmKeyManager::OnDataSigned( |
358 const base::Callback<void(const std::string&)>& callback, | 354 const base::Callback<void(const std::string&)>& callback, |
359 const std::string& signature) { | 355 const std::string& signature) { |
360 callback.Run(signature); | 356 callback.Run(signature); |
361 } | 357 } |
OLD | NEW |