Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: chrome/browser/chromeos/login/easy_unlock/easy_unlock_create_keys_operation.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iwyu fixes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory>
9 #include <string> 10 #include <string>
10 11
11 #include "base/base64url.h" 12 #include "base/base64url.h"
12 #include "base/bind.h" 13 #include "base/bind.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" 17 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
18 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h" 18 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h"
19 #include "chromeos/cryptohome/homedir_methods.h" 19 #include "chromeos/cryptohome/homedir_methods.h"
20 #include "chromeos/cryptohome/system_salt_getter.h" 20 #include "chromeos/cryptohome/system_salt_getter.h"
21 #include "chromeos/dbus/dbus_thread_manager.h" 21 #include "chromeos/dbus/dbus_thread_manager.h"
22 #include "chromeos/dbus/easy_unlock_client.h" 22 #include "chromeos/dbus/easy_unlock_client.h"
23 #include "chromeos/login/auth/key.h" 23 #include "chromeos/login/auth/key.h"
24 #include "components/proximity_auth/logging/logging.h" 24 #include "components/proximity_auth/logging/logging.h"
25 #include "crypto/encryptor.h" 25 #include "crypto/encryptor.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 DCHECK_GE(index, 0u); 265 DCHECK_GE(index, 0u);
266 if (index == devices_.size()) { 266 if (index == devices_.size()) {
267 callback_.Run(true); 267 callback_.Run(true);
268 return; 268 return;
269 } 269 }
270 270
271 std::string user_key; 271 std::string user_key;
272 crypto::RandBytes(base::WriteInto(&user_key, kUserKeyByteSize + 1), 272 crypto::RandBytes(base::WriteInto(&user_key, kUserKeyByteSize + 1),
273 kUserKeyByteSize); 273 kUserKeyByteSize);
274 274
275 scoped_ptr<crypto::SymmetricKey> session_key( 275 std::unique_ptr<crypto::SymmetricKey> session_key(
276 crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES, 276 crypto::SymmetricKey::GenerateRandomKey(crypto::SymmetricKey::AES,
277 kSessionKeyByteSize * 8)); 277 kSessionKeyByteSize * 8));
278 278
279 std::string iv(kSessionKeyByteSize, ' '); 279 std::string iv(kSessionKeyByteSize, ' ');
280 crypto::Encryptor encryptor; 280 crypto::Encryptor encryptor;
281 if (!encryptor.Init(session_key.get(), crypto::Encryptor::CBC, iv)) { 281 if (!encryptor.Init(session_key.get(), crypto::Encryptor::CBC, iv)) {
282 PA_LOG(ERROR) << "Easy unlock failed to init encryptor for key creation."; 282 PA_LOG(ERROR) << "Easy unlock failed to init encryptor for key creation.";
283 callback_.Run(false); 283 callback_.Run(false);
284 return; 284 return;
285 } 285 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 key_def.provider_data.push_back(cryptohome::KeyDefinition::ProviderData( 350 key_def.provider_data.push_back(cryptohome::KeyDefinition::ProviderData(
351 kEasyUnlockKeyMetaNamePubKey, device->public_key)); 351 kEasyUnlockKeyMetaNamePubKey, device->public_key));
352 key_def.provider_data.push_back(cryptohome::KeyDefinition::ProviderData( 352 key_def.provider_data.push_back(cryptohome::KeyDefinition::ProviderData(
353 kEasyUnlockKeyMetaNameChallenge, device->challenge)); 353 kEasyUnlockKeyMetaNameChallenge, device->challenge));
354 key_def.provider_data.push_back(cryptohome::KeyDefinition::ProviderData( 354 key_def.provider_data.push_back(cryptohome::KeyDefinition::ProviderData(
355 kEasyUnlockKeyMetaNameWrappedSecret, device->wrapped_secret)); 355 kEasyUnlockKeyMetaNameWrappedSecret, device->wrapped_secret));
356 356
357 // Add cryptohome key. 357 // Add cryptohome key.
358 const cryptohome::Identification id(user_context_.GetAccountId()); 358 const cryptohome::Identification id(user_context_.GetAccountId());
359 359
360 scoped_ptr<Key> auth_key(new Key(*user_context_.GetKey())); 360 std::unique_ptr<Key> auth_key(new Key(*user_context_.GetKey()));
361 if (auth_key->GetKeyType() == Key::KEY_TYPE_PASSWORD_PLAIN) 361 if (auth_key->GetKeyType() == Key::KEY_TYPE_PASSWORD_PLAIN)
362 auth_key->Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt); 362 auth_key->Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, system_salt);
363 363
364 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel()); 364 cryptohome::Authorization auth(auth_key->GetSecret(), auth_key->GetLabel());
365 cryptohome::HomedirMethods::GetInstance()->AddKeyEx( 365 cryptohome::HomedirMethods::GetInstance()->AddKeyEx(
366 id, 366 id,
367 auth, 367 auth,
368 key_def, 368 key_def,
369 true, // clobber 369 true, // clobber
370 base::Bind(&EasyUnlockCreateKeysOperation::OnKeyCreated, 370 base::Bind(&EasyUnlockCreateKeysOperation::OnKeyCreated,
(...skipping 21 matching lines...) Expand all
392 user_context_.GetKey()->GetLabel() == 392 user_context_.GetKey()->GetLabel() ==
393 EasyUnlockKeyManager::GetKeyLabel(key_creation_index_)) { 393 EasyUnlockKeyManager::GetKeyLabel(key_creation_index_)) {
394 user_context_.SetKey(user_key); 394 user_context_.SetKey(user_key);
395 } 395 }
396 396
397 ++key_creation_index_; 397 ++key_creation_index_;
398 CreateKeyForDeviceAtIndex(key_creation_index_); 398 CreateKeyForDeviceAtIndex(key_creation_index_);
399 } 399 }
400 400
401 } // namespace chromeos 401 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698