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

Side by Side Diff: chrome/browser/chromeos/login/auth/cryptohome_authenticator_unittest.cc

Issue 1106103003: Don't use RSAPrivateKey in NSS integration code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ocsp-refactor
Patch Set: pneubeck comments Created 5 years, 7 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/auth/chrome_cryptohome_authenticator.h" 5 #include "chrome/browser/chromeos/login/auth/chrome_cryptohome_authenticator.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 27 matching lines...) Expand all
38 #include "chromeos/dbus/fake_cryptohome_client.h" 38 #include "chromeos/dbus/fake_cryptohome_client.h"
39 #include "chromeos/login/auth/key.h" 39 #include "chromeos/login/auth/key.h"
40 #include "chromeos/login/auth/mock_auth_status_consumer.h" 40 #include "chromeos/login/auth/mock_auth_status_consumer.h"
41 #include "chromeos/login/auth/mock_url_fetchers.h" 41 #include "chromeos/login/auth/mock_url_fetchers.h"
42 #include "chromeos/login/auth/test_attempt_state.h" 42 #include "chromeos/login/auth/test_attempt_state.h"
43 #include "chromeos/login/auth/user_context.h" 43 #include "chromeos/login/auth/user_context.h"
44 #include "chromeos/login/login_state.h" 44 #include "chromeos/login/login_state.h"
45 #include "components/ownership/mock_owner_key_util.h" 45 #include "components/ownership/mock_owner_key_util.h"
46 #include "components/user_manager/fake_user_manager.h" 46 #include "components/user_manager/fake_user_manager.h"
47 #include "content/public/test/test_browser_thread_bundle.h" 47 #include "content/public/test/test_browser_thread_bundle.h"
48 #include "crypto/nss_key_util.h"
48 #include "crypto/nss_util_internal.h" 49 #include "crypto/nss_util_internal.h"
49 #include "crypto/scoped_test_nss_chromeos_user.h" 50 #include "crypto/scoped_test_nss_chromeos_user.h"
50 #include "google_apis/gaia/mock_url_fetcher_factory.h" 51 #include "google_apis/gaia/mock_url_fetcher_factory.h"
51 #include "net/base/net_errors.h" 52 #include "net/base/net_errors.h"
52 #include "net/url_request/url_request_status.h" 53 #include "net/url_request/url_request_status.h"
53 #include "testing/gmock/include/gmock/gmock.h" 54 #include "testing/gmock/include/gmock/gmock.h"
54 #include "testing/gtest/include/gtest/gtest.h" 55 #include "testing/gtest/include/gtest/gtest.h"
55 #include "third_party/cros_system_api/dbus/service_constants.h" 56 #include "third_party/cros_system_api/dbus/service_constants.h"
56 #include "url/gurl.h" 57 #include "url/gurl.h"
57 58
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 0xf3, 0xec, 0xab, 0x41, 0x57, 0x1d, 0x5f, 0xed, 0xcf, 0x09, 0xf4, 0xcc, 112 0xf3, 0xec, 0xab, 0x41, 0x57, 0x1d, 0x5f, 0xed, 0xcf, 0x09, 0xf4, 0xcc,
112 0xbb, 0x52, 0x52, 0xe8, 0x46, 0xf5, 0xc5, 0x01, 0xa3, 0xd8, 0x24, 0xc0, 113 0xbb, 0x52, 0x52, 0xe8, 0x46, 0xf5, 0xc5, 0x01, 0xa3, 0xd8, 0x24, 0xc0,
113 0x15, 0xc5, 0x65, 0x50, 0x7d, 0xbd, 0x4e, 0x81, 0xb2, 0x28, 0x38, 0xf9, 114 0x15, 0xc5, 0x65, 0x50, 0x7d, 0xbd, 0x4e, 0x81, 0xb2, 0x28, 0x38, 0xf9,
114 0x3d, 0x3e, 0x2a, 0x68, 0xf7, 0x02, 0x03, 0x01, 0x00, 0x01}; 115 0x3d, 0x3e, 0x2a, 0x68, 0xf7, 0x02, 0x03, 0x01, 0x00, 0x01};
115 116
116 std::vector<uint8> GetOwnerPublicKey() { 117 std::vector<uint8> GetOwnerPublicKey() {
117 return std::vector<uint8>(kOwnerPublicKey, 118 return std::vector<uint8>(kOwnerPublicKey,
118 kOwnerPublicKey + arraysize(kOwnerPublicKey)); 119 kOwnerPublicKey + arraysize(kOwnerPublicKey));
119 } 120 }
120 121
121 scoped_ptr<crypto::RSAPrivateKey> CreateOwnerKeyInSlot(PK11SlotInfo* slot) { 122 bool CreateOwnerKeyInSlot(PK11SlotInfo* slot) {
122 const std::vector<uint8> key(kOwnerPrivateKey, 123 const std::vector<uint8> key(kOwnerPrivateKey,
123 kOwnerPrivateKey + arraysize(kOwnerPrivateKey)); 124 kOwnerPrivateKey + arraysize(kOwnerPrivateKey));
124 return make_scoped_ptr( 125 return crypto::ImportNSSKeyFromPrivateKeyInfo(slot, key,
125 crypto::RSAPrivateKey::CreateSensitiveFromPrivateKeyInfo(slot, key)); 126 true /* permanent */);
126 } 127 }
127 128
128 } // namespace 129 } // namespace
129 130
130 class CryptohomeAuthenticatorTest : public testing::Test { 131 class CryptohomeAuthenticatorTest : public testing::Test {
131 public: 132 public:
132 CryptohomeAuthenticatorTest() 133 CryptohomeAuthenticatorTest()
133 : user_context_("me@nowhere.org"), 134 : user_context_("me@nowhere.org"),
134 user_manager_(new user_manager::FakeUserManager()), 135 user_manager_(new user_manager::FakeUserManager()),
135 user_manager_enabler_(user_manager_), 136 user_manager_enabler_(user_manager_),
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 } 466 }
466 467
467 // Test the case that login switches to SafeMode and the Owner logs in, which 468 // Test the case that login switches to SafeMode and the Owner logs in, which
468 // should lead to a successful login. 469 // should lead to a successful login.
469 TEST_F(CryptohomeAuthenticatorTest, ResolveOwnerNeededSuccess) { 470 TEST_F(CryptohomeAuthenticatorTest, ResolveOwnerNeededSuccess) {
470 crypto::ScopedTestNSSChromeOSUser test_user_db(user_context_.GetUserIDHash()); 471 crypto::ScopedTestNSSChromeOSUser test_user_db(user_context_.GetUserIDHash());
471 owner_key_util_->SetPublicKey(GetOwnerPublicKey()); 472 owner_key_util_->SetPublicKey(GetOwnerPublicKey());
472 473
473 crypto::ScopedPK11Slot user_slot( 474 crypto::ScopedPK11Slot user_slot(
474 crypto::GetPublicSlotForChromeOSUser(user_context_.GetUserIDHash())); 475 crypto::GetPublicSlotForChromeOSUser(user_context_.GetUserIDHash()));
475 CreateOwnerKeyInSlot(user_slot.get()); 476 ASSERT_TRUE(CreateOwnerKeyInSlot(user_slot.get()));
476 477
477 profile_manager_.reset( 478 profile_manager_.reset(
478 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); 479 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
479 ASSERT_TRUE(profile_manager_->SetUp()); 480 ASSERT_TRUE(profile_manager_->SetUp());
480 481
481 ExpectLoginSuccess(user_context_); 482 ExpectLoginSuccess(user_context_);
482 483
483 // Set up state as though a cryptohome mount attempt has occurred 484 // Set up state as though a cryptohome mount attempt has occurred
484 // and succeeded but we are in safe mode and the current user is not owner. 485 // and succeeded but we are in safe mode and the current user is not owner.
485 state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE); 486 state_->PresetCryptohomeStatus(true, cryptohome::MOUNT_ERROR_NONE);
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 // salt. 773 // salt.
773 ExpectGetKeyDataExCall( 774 ExpectGetKeyDataExCall(
774 make_scoped_ptr(new int64(Key::KEY_TYPE_SALTED_SHA256)), 775 make_scoped_ptr(new int64(Key::KEY_TYPE_SALTED_SHA256)),
775 scoped_ptr<std::string>()); 776 scoped_ptr<std::string>());
776 777
777 auth_->AuthenticateToLogin(NULL, user_context_); 778 auth_->AuthenticateToLogin(NULL, user_context_);
778 base::RunLoop().Run(); 779 base::RunLoop().Run();
779 } 780 }
780 781
781 } // namespace chromeos 782 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.cc » ('j') | components/ownership.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698