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_create_keys_oper
ation.h" | 5 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_create_keys_oper
ation.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 } | 256 } |
257 | 257 |
258 void EasyUnlockCreateKeysOperation::CreateKeyForDeviceAtIndex(size_t index) { | 258 void EasyUnlockCreateKeysOperation::CreateKeyForDeviceAtIndex(size_t index) { |
259 DCHECK_GE(index, 0u); | 259 DCHECK_GE(index, 0u); |
260 if (index == devices_.size()) { | 260 if (index == devices_.size()) { |
261 callback_.Run(true); | 261 callback_.Run(true); |
262 return; | 262 return; |
263 } | 263 } |
264 | 264 |
265 std::string user_key; | 265 std::string user_key; |
266 crypto::RandBytes(WriteInto(&user_key, kUserKeyByteSize + 1), | 266 crypto::RandBytes(base::WriteInto(&user_key, kUserKeyByteSize + 1), |
267 kUserKeyByteSize); | 267 kUserKeyByteSize); |
268 | 268 |
269 scoped_ptr<crypto::SymmetricKey> session_key( | 269 scoped_ptr<crypto::SymmetricKey> session_key( |
270 crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, | 270 crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, |
271 kSessionKeyByteSize * 8)); | 271 kSessionKeyByteSize * 8)); |
272 | 272 |
273 std::string iv(kSessionKeyByteSize, ' '); | 273 std::string iv(kSessionKeyByteSize, ' '); |
274 crypto::Encryptor encryptor; | 274 crypto::Encryptor encryptor; |
275 if (!encryptor.Init(session_key.get(), crypto::Encryptor::CBC, iv)) { | 275 if (!encryptor.Init(session_key.get(), crypto::Encryptor::CBC, iv)) { |
276 LOG(ERROR) << "Easy unlock failed to init encryptor for key creation."; | 276 LOG(ERROR) << "Easy unlock failed to init encryptor for key creation."; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 user_context_.GetKey()->GetLabel() == | 385 user_context_.GetKey()->GetLabel() == |
386 EasyUnlockKeyManager::GetKeyLabel(key_creation_index_)) { | 386 EasyUnlockKeyManager::GetKeyLabel(key_creation_index_)) { |
387 user_context_.SetKey(user_key); | 387 user_context_.SetKey(user_key); |
388 } | 388 } |
389 | 389 |
390 ++key_creation_index_; | 390 ++key_creation_index_; |
391 CreateKeyForDeviceAtIndex(key_creation_index_); | 391 CreateKeyForDeviceAtIndex(key_creation_index_); |
392 } | 392 } |
393 | 393 |
394 } // namespace chromeos | 394 } // namespace chromeos |
OLD | NEW |