summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/net/cookie_store_util.cc8
-rw-r--r--chrome/browser/services/gcm/gcm_profile_service_unittest.cc6
-rw-r--r--chrome/browser/signin/local_auth.cc6
-rw-r--r--chrome/browser/signin/local_auth_unittest.cc4
-rw-r--r--chrome/browser/signin/mutable_profile_oauth2_token_service_unittest.cc4
-rw-r--r--chrome/browser/sync/test/integration/sync_test.cc4
-rw-r--r--chrome/test/base/in_process_browser_test.cc4
-rw-r--r--components/autofill/core/browser/autofill_ie_toolbar_import_win.cc4
-rw-r--r--components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc4
-rw-r--r--components/autofill/core/browser/autofill_test_utils.cc4
-rw-r--r--components/autofill/core/browser/webdata/autofill_table.cc8
-rw-r--r--components/autofill/core/browser/webdata/autofill_table_unittest.cc4
-rw-r--r--components/components_tests.gyp4
-rw-r--r--components/encryptor.gypi18
-rw-r--r--components/encryptor/encryptor.h51
-rw-r--r--components/encryptor/encryptor_switches.h2
-rw-r--r--components/encryptor/keychain_password_mac.h (renamed from components/encryptor/encryptor_password_mac.h)21
-rw-r--r--components/encryptor/keychain_password_mac.mm (renamed from components/encryptor/encryptor_password_mac.mm)4
-rw-r--r--components/encryptor/keychain_password_mac_unittest.mm (renamed from components/encryptor/encryptor_password_mac_unittest.cc)37
-rw-r--r--components/encryptor/os_crypt.h48
-rw-r--r--components/encryptor/os_crypt_mac.mm (renamed from components/encryptor/encryptor_mac.mm)26
-rw-r--r--components/encryptor/os_crypt_posix.cc (renamed from components/encryptor/encryptor_posix.cc)18
-rw-r--r--components/encryptor/os_crypt_unittest.cc (renamed from components/encryptor/encryptor_unittest.cc)75
-rw-r--r--components/encryptor/os_crypt_win.cc (renamed from components/encryptor/encryptor_win.cc)19
-rw-r--r--components/password_manager/core/browser/login_database_win.cc9
-rw-r--r--components/signin/core/webdata/token_service_table.cc6
-rw-r--r--components/sync_driver/system_encryptor.cc6
-rw-r--r--components/sync_driver/system_encryptor_unittest.cc4
-rw-r--r--google_apis/gcm/engine/gcm_store_impl.cc10
-rw-r--r--google_apis/gcm/engine/mcs_client_unittest.cc4
-rw-r--r--google_apis/gcm/gcm_client_impl_unittest.cc4
31 files changed, 214 insertions, 212 deletions
diff --git a/chrome/browser/net/cookie_store_util.cc b/chrome/browser/net/cookie_store_util.cc
index 0b00984..0ba5b0d 100644
--- a/chrome/browser/net/cookie_store_util.cc
+++ b/chrome/browser/net/cookie_store_util.cc
@@ -16,7 +16,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cookie_crypto_delegate.h"
#include "content/public/browser/cookie_store_factory.h"
@@ -107,7 +107,7 @@ namespace {
// because ChromeOS and Android already protect the entire profile contents.
//
// TODO(bcwhite): Enable on MACOSX -- requires all Cookie tests to call
-// Encryptor::UseMockKeychain or will hang waiting for user input.
+// OSCrypt::UseMockKeychain or will hang waiting for user input.
class CookieOSCryptoDelegate : public content::CookieCryptoDelegate {
public:
virtual bool EncryptString(const std::string& plaintext,
@@ -118,12 +118,12 @@ class CookieOSCryptoDelegate : public content::CookieCryptoDelegate {
bool CookieOSCryptoDelegate::EncryptString(const std::string& plaintext,
std::string* ciphertext) {
- return Encryptor::EncryptString(plaintext, ciphertext);
+ return OSCrypt::EncryptString(plaintext, ciphertext);
}
bool CookieOSCryptoDelegate::DecryptString(const std::string& ciphertext,
std::string* plaintext) {
- return Encryptor::DecryptString(ciphertext, plaintext);
+ return OSCrypt::DecryptString(ciphertext, plaintext);
}
// Using a LazyInstance is safe here because this class is stateless and
diff --git a/chrome/browser/services/gcm/gcm_profile_service_unittest.cc b/chrome/browser/services/gcm/gcm_profile_service_unittest.cc
index b3cac28f..b797225 100644
--- a/chrome/browser/services/gcm/gcm_profile_service_unittest.cc
+++ b/chrome/browser/services/gcm/gcm_profile_service_unittest.cc
@@ -25,7 +25,7 @@
#include "chrome/common/extensions/features/feature_channel.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -504,10 +504,10 @@ class GCMProfileServiceTest : public testing::Test {
test_user_manager_.reset(new chromeos::ScopedTestUserManager());
#endif
- // Encryptor ends up needing access to the keychain on OS X. So use the mock
+ // OSCrypt ends up needing access to the keychain on OS X. So use the mock
// keychain to prevent prompts.
#if defined(OS_MACOSX)
- Encryptor::UseMockKeychain(true);
+ OSCrypt::UseMockKeychain(true);
#endif
// Create a main profile consumer.
diff --git a/chrome/browser/signin/local_auth.cc b/chrome/browser/signin/local_auth.cc
index 2bff8fb..7f7b14c 100644
--- a/chrome/browser/signin/local_auth.cc
+++ b/chrome/browser/signin/local_auth.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/pref_names.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "crypto/random.h"
#include "crypto/secure_util.h"
@@ -62,7 +62,7 @@ std::string EncodePasswordHashRecord(const std::string& record,
// Encrypt the hash using the OS account-password protection (if available).
std::string encoded;
- const bool success = Encryptor::EncryptString(record, &encoded);
+ const bool success = OSCrypt::EncryptString(record, &encoded);
DCHECK(success);
// Convert binary record to text for preference database.
@@ -91,7 +91,7 @@ bool DecodePasswordHashRecord(const std::string& encoded,
return false;
// Decrypt the record using the OS account-password protection (if available).
- return Encryptor::DecryptString(unbase64, decoded);
+ return OSCrypt::DecryptString(unbase64, decoded);
}
} // namespace
diff --git a/chrome/browser/signin/local_auth_unittest.cc b/chrome/browser/signin/local_auth_unittest.cc
index 55affcc..0995971 100644
--- a/chrome/browser/signin/local_auth_unittest.cc
+++ b/chrome/browser/signin/local_auth_unittest.cc
@@ -12,7 +12,7 @@
#include "chrome/test/base/testing_pref_service_syncable.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -29,7 +29,7 @@ TEST(LocalAuthTest, SetAndCheckCredentials) {
EXPECT_EQ("", cache.GetLocalAuthCredentialsOfProfileAtIndex(0));
#if defined(OS_MACOSX)
- Encryptor::UseMockKeychain(true);
+ OSCrypt::UseMockKeychain(true);
#endif
std::string password("Some Password");
diff --git a/chrome/browser/signin/mutable_profile_oauth2_token_service_unittest.cc b/chrome/browser/signin/mutable_profile_oauth2_token_service_unittest.cc
index 6a921fb..bc3b71f 100644
--- a/chrome/browser/signin/mutable_profile_oauth2_token_service_unittest.cc
+++ b/chrome/browser/signin/mutable_profile_oauth2_token_service_unittest.cc
@@ -18,7 +18,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_MACOSX)
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#endif
// Defining constant here to handle backward compatiblity tests, but this
@@ -40,7 +40,7 @@ class MutableProfileOAuth2TokenServiceTest :
virtual void SetUp() OVERRIDE {
#if defined(OS_MACOSX)
- Encryptor::UseMockKeychain(true);
+ OSCrypt::UseMockKeychain(true);
#endif
profile_.reset(new TestingProfile);
diff --git a/chrome/browser/sync/test/integration/sync_test.cc b/chrome/browser/sync/test/integration/sync_test.cc
index 8bd527b..5f1ed3c 100644
--- a/chrome/browser/sync/test/integration/sync_test.cc
+++ b/chrome/browser/sync/test/integration/sync_test.cc
@@ -41,7 +41,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/ui_test_utils.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/test_browser_thread.h"
#include "google_apis/gaia/gaia_urls.h"
@@ -179,7 +179,7 @@ void SyncTest::SetUp() {
// Mock the Mac Keychain service. The real Keychain can block on user input.
#if defined(OS_MACOSX)
- Encryptor::UseMockKeychain(true);
+ OSCrypt::UseMockKeychain(true);
#endif
// Start up a sync test server if one is needed and setup mock gaia responses.
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc
index 518977e..523fbce 100644
--- a/chrome/test/base/in_process_browser_test.cc
+++ b/chrome/test/base/in_process_browser_test.cc
@@ -41,7 +41,7 @@
#include "chrome/test/base/test_switches.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/ui_test_utils.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/test/browser_test_utils.h"
@@ -188,7 +188,7 @@ void InProcessBrowserTest::SetUp() {
// Always use the MockKeychain if OS encription is used (which is when
// anything sensitive gets stored, including Cookies). Without this,
// many tests will hang waiting for a user to approve KeyChain access.
- Encryptor::UseMockKeychain(true);
+ OSCrypt::UseMockKeychain(true);
#endif
#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
diff --git a/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc b/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc
index 682f1917..f39fc4d 100644
--- a/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc
+++ b/components/autofill/core/browser/autofill_ie_toolbar_import_win.cc
@@ -24,7 +24,7 @@
#include "components/autofill/core/browser/personal_data_manager_observer.h"
#include "components/autofill/core/browser/phone_number.h"
#include "components/autofill/core/browser/phone_number_i18n.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
using base::win::RegKey;
@@ -86,7 +86,7 @@ base::string16 ReadAndDecryptValue(const RegKey& key,
result = key.ReadValue(value_name, &(data[0]), &data_size, &data_type);
if (result == ERROR_SUCCESS) {
std::string out_data;
- if (Encryptor::DecryptString(data, &out_data)) {
+ if (OSCrypt::DecryptString(data, &out_data)) {
// The actual data is in UTF16 already.
if (!(out_data.size() & 1) && (out_data.size() > 2) &&
!out_data[out_data.size() - 1] && !out_data[out_data.size() - 2]) {
diff --git a/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc b/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc
index 24108ec..4e5c833 100644
--- a/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc
+++ b/components/autofill/core/browser/autofill_ie_toolbar_import_win_unittest.cc
@@ -10,7 +10,7 @@
#include "components/autofill/core/browser/autofill_profile.h"
#include "components/autofill/core/browser/credit_card.h"
#include "components/autofill/core/browser/field_types.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::win::RegKey;
@@ -92,7 +92,7 @@ void EncryptAndWrite(RegKey* key, const ValueDescription* value) {
memcpy(&data[0], value->value, data_size);
std::string encrypted_data;
- Encryptor::EncryptString(data, &encrypted_data);
+ OSCrypt::EncryptString(data, &encrypted_data);
EXPECT_EQ(ERROR_SUCCESS, key->WriteValue(value->value_name,
&encrypted_data[0], encrypted_data.size(), REG_BINARY));
}
diff --git a/components/autofill/core/browser/autofill_test_utils.cc b/components/autofill/core/browser/autofill_test_utils.cc
index a46ed28..c163875 100644
--- a/components/autofill/core/browser/autofill_test_utils.cc
+++ b/components/autofill/core/browser/autofill_test_utils.cc
@@ -16,7 +16,7 @@
#include "components/autofill/core/common/autofill_pref_names.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_field_data.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_context.h"
@@ -207,7 +207,7 @@ void SetCreditCardInfo(CreditCard* credit_card,
void DisableSystemServices(content::BrowserContext* browser_context) {
// Use a mock Keychain rather than the OS one to store credit card data.
#if defined(OS_MACOSX)
- Encryptor::UseMockKeychain(true);
+ OSCrypt::UseMockKeychain(true);
#endif
// Disable auxiliary profiles for unit testing. These reach out to system
diff --git a/components/autofill/core/browser/webdata/autofill_table.cc b/components/autofill/core/browser/webdata/autofill_table.cc
index 039942f..c4656ad 100644
--- a/components/autofill/core/browser/webdata/autofill_table.cc
+++ b/components/autofill/core/browser/webdata/autofill_table.cc
@@ -26,7 +26,7 @@
#include "components/autofill/core/browser/webdata/autofill_change.h"
#include "components/autofill/core/browser/webdata/autofill_entry.h"
#include "components/autofill/core/common/form_field_data.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "components/webdata/common/web_database.h"
#include "sql/statement.h"
#include "sql/transaction.h"
@@ -109,8 +109,8 @@ void BindCreditCardToStatement(const CreditCard& credit_card,
s->BindString16(index++, GetInfo(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR));
std::string encrypted_data;
- Encryptor::EncryptString16(credit_card.GetRawInfo(CREDIT_CARD_NUMBER),
- &encrypted_data);
+ OSCrypt::EncryptString16(credit_card.GetRawInfo(CREDIT_CARD_NUMBER),
+ &encrypted_data);
s->BindBlob(index++, encrypted_data.data(),
static_cast<int>(encrypted_data.length()));
@@ -135,7 +135,7 @@ scoped_ptr<CreditCard> CreditCardFromStatement(const sql::Statement& s) {
std::string encrypted_number;
encrypted_number.resize(encrypted_number_len);
memcpy(&encrypted_number[0], s.ColumnBlob(index++), encrypted_number_len);
- Encryptor::DecryptString16(encrypted_number, &credit_card_number);
+ OSCrypt::DecryptString16(encrypted_number, &credit_card_number);
} else {
index++;
}
diff --git a/components/autofill/core/browser/webdata/autofill_table_unittest.cc b/components/autofill/core/browser/webdata/autofill_table_unittest.cc
index 649eec3..474af46 100644
--- a/components/autofill/core/browser/webdata/autofill_table_unittest.cc
+++ b/components/autofill/core/browser/webdata/autofill_table_unittest.cc
@@ -19,7 +19,7 @@
#include "components/autofill/core/browser/webdata/autofill_entry.h"
#include "components/autofill/core/browser/webdata/autofill_table.h"
#include "components/autofill/core/common/form_field_data.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "components/webdata/common/web_database.h"
#include "sql/statement.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -118,7 +118,7 @@ class AutofillTableTest : public testing::Test {
protected:
virtual void SetUp() {
#if defined(OS_MACOSX)
- Encryptor::UseMockKeychain(true);
+ OSCrypt::UseMockKeychain(true);
#endif
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
file_ = temp_dir_.path().AppendASCII("TestWebDatabase");
diff --git a/components/components_tests.gyp b/components/components_tests.gyp
index ea83ae6..c47e05e 100644
--- a/components/components_tests.gyp
+++ b/components/components_tests.gyp
@@ -86,9 +86,9 @@
'variations/variations_seed_processor_unittest.cc',
'variations/variations_seed_simulator_unittest.cc',
'visitedlink/test/visitedlink_unittest.cc',
- 'encryptor/encryptor_password_mac_unittest.cc',
- 'encryptor/encryptor_unittest.cc',
+ 'encryptor/keychain_password_mac_unittest.mm',
'encryptor/ie7_password_unittest_win.cc',
+ 'encryptor/os_crypt_unittest.cc',
'web_modal/web_contents_modal_dialog_manager_unittest.cc',
],
'include_dirs': [
diff --git a/components/encryptor.gypi b/components/encryptor.gypi
index 3ddc7a1..f534a85 100644
--- a/components/encryptor.gypi
+++ b/components/encryptor.gypi
@@ -15,29 +15,29 @@
'../crypto/crypto.gyp:crypto',
],
'sources': [
- 'encryptor/encryptor.h',
- 'encryptor/encryptor_mac.mm',
- 'encryptor/encryptor_password_mac.h',
- 'encryptor/encryptor_password_mac.mm',
- 'encryptor/encryptor_posix.cc',
'encryptor/encryptor_switches.cc',
'encryptor/encryptor_switches.h',
- 'encryptor/encryptor_win.cc',
'encryptor/ie7_password_win.cc',
'encryptor/ie7_password_win.h',
+ 'encryptor/keychain_password_mac.h',
+ 'encryptor/keychain_password_mac.mm',
+ 'encryptor/os_crypt.h',
+ 'encryptor/os_crypt_mac.mm',
+ 'encryptor/os_crypt_posix.cc',
+ 'encryptor/os_crypt_win.cc',
],
'conditions': [
['OS=="mac"', {
'sources!': [
- 'encryptor/encryptor_posix.cc',
+ 'encryptor/os_crypt_posix.cc',
],
}],
],
'target_conditions': [
['OS=="ios"', {
'sources/': [
- ['include', '^encryptor/encryptor_mac\\.mm$'],
- ['include', '^encryptor/encryptor_password_mac\\.mm$'],
+ ['include', '^encryptor/keychain_password_mac\\.mm$'],
+ ['include', '^encryptor/os_crypt_mac\\.mm$'],
],
}],
],
diff --git a/components/encryptor/encryptor.h b/components/encryptor/encryptor.h
deleted file mode 100644
index 48bb2e5..0000000
--- a/components/encryptor/encryptor.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_ENCRYPTOR_ENCRYPTOR_H_
-#define COMPONENTS_ENCRYPTOR_ENCRYPTOR_H_
-
-#include <string>
-
-#include "base/strings/string16.h"
-
-// The Encryptor class gives access to simple encryption and decryption of
-// strings. Note that on Mac, access to the system Keychain is required and
-// these calls can block the current thread to collect user input.
-class Encryptor {
- public:
- // Encrypt a string16. The output (second argument) is
- // really an array of bytes, but we're passing it back
- // as a std::string
- static bool EncryptString16(const base::string16& plaintext,
- std::string* ciphertext);
-
- // Decrypt an array of bytes obtained with EncryptString16
- // back into a string16. Note that the input (first argument)
- // is a std::string, so you need to first get your (binary)
- // data into a string.
- static bool DecryptString16(const std::string& ciphertext,
- base::string16* plaintext);
-
- // Encrypt a string.
- static bool EncryptString(const std::string& plaintext,
- std::string* ciphertext);
-
- // Decrypt an array of bytes obtained with EnctryptString
- // back into a string. Note that the input (first argument)
- // is a std::string, so you need to first get your (binary)
- // data into a string.
- static bool DecryptString(const std::string& ciphertext,
- std::string* plaintext);
-
-#if defined(OS_MACOSX)
- // For unit testing purposes we instruct the Encryptor to use a mock Keychain
- // on the Mac. The default is to use the real Keychain.
- static void UseMockKeychain(bool use_mock);
-#endif
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(Encryptor);
-};
-
-#endif // COMPONENTS_ENCRYPTOR_ENCRYPTOR_H_
diff --git a/components/encryptor/encryptor_switches.h b/components/encryptor/encryptor_switches.h
index 5f25e14..4df069a 100644
--- a/components/encryptor/encryptor_switches.h
+++ b/components/encryptor/encryptor_switches.h
@@ -7,7 +7,7 @@
#ifndef COMPONENTS_ENCRYPTOR__ENCRYPTOR_SWITCHES_H_
#define COMPONENTS_ENCRYPTOR__ENCRYPTOR_SWITCHES_H_
-#include "base/basictypes.h"
+#include "build/build_config.h"
namespace encryptor {
namespace switches {
diff --git a/components/encryptor/encryptor_password_mac.h b/components/encryptor/keychain_password_mac.h
index fc2a915..7cb8faf 100644
--- a/components/encryptor/encryptor_password_mac.h
+++ b/components/encryptor/keychain_password_mac.h
@@ -2,34 +2,35 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_ENCRYPTOR_ENCRYPTOR_PASSWORD_MAC_H_
-#define COMPONENTS_ENCRYPTOR_ENCRYPTOR_PASSWORD_MAC_H_
+#ifndef COMPONENTS_ENCRYPTOR_KEYCHAIN_PASSWORD_MAC_H_
+#define COMPONENTS_ENCRYPTOR_KEYCHAIN_PASSWORD_MAC_H_
#include <string>
-#include "base/basictypes.h"
+#include "base/macros.h"
namespace crypto {
class AppleKeychain;
-} // namespace crypto
+}
-class EncryptorPassword {
+class KeychainPassword {
public:
- explicit EncryptorPassword(const crypto::AppleKeychain& keychain)
+ explicit KeychainPassword(const crypto::AppleKeychain& keychain)
: keychain_(keychain) {
}
- // Get the Encryptor password for this system. If no password exists
+ // Get the OSCrypt password for this system. If no password exists
// in the Keychain then one is generated, stored in the Mac keychain, and
// returned.
// If one exists then it is fetched from the Keychain and returned.
// If the user disallows access to the Keychain (or an error occurs) then an
// empty string is returned.
- std::string GetEncryptorPassword() const;
+ std::string GetPassword() const;
private:
- DISALLOW_COPY_AND_ASSIGN(EncryptorPassword);
const crypto::AppleKeychain& keychain_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeychainPassword);
};
-#endif // COMPONENTS_ENCRYPTOR_ENCRYPTOR_PASSWORD_MAC_H_
+#endif // COMPONENTS_ENCRYPTOR_KEYCHAIN_PASSWORD_MAC_H_
diff --git a/components/encryptor/encryptor_password_mac.mm b/components/encryptor/keychain_password_mac.mm
index 0cefdd5..7a078bf 100644
--- a/components/encryptor/encryptor_password_mac.mm
+++ b/components/encryptor/keychain_password_mac.mm
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/encryptor/encryptor_password_mac.h"
+#include "components/encryptor/keychain_password_mac.h"
#import <Security/Security.h>
@@ -47,7 +47,7 @@ std::string AddRandomPasswordToKeychain(const AppleKeychain& keychain,
} // namespace
-std::string EncryptorPassword::GetEncryptorPassword() const {
+std::string KeychainPassword::GetPassword() const {
// These two strings ARE indeed user facing. But they are used to access
// the encryption keyword. So as to not lose encrypted data when system
// locale changes we DO NOT LOCALIZE.
diff --git a/components/encryptor/encryptor_password_mac_unittest.cc b/components/encryptor/keychain_password_mac_unittest.mm
index bc95a44..efa32b4 100644
--- a/components/encryptor/encryptor_password_mac_unittest.cc
+++ b/components/encryptor/keychain_password_mac_unittest.mm
@@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/encryptor/encryptor_password_mac.h"
+#include "components/encryptor/keychain_password_mac.h"
+
#include "crypto/mock_apple_keychain.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -12,62 +13,62 @@ using crypto::MockAppleKeychain;
// Test that if we have an existing password in the Keychain and we are
// authorized by the user to read it then we get it back correctly.
-TEST(EncryptorPasswordTest, FindPasswordSuccess) {
+TEST(KeychainPasswordTest, FindPasswordSuccess) {
MockAppleKeychain keychain;
keychain.set_find_generic_result(noErr);
- EncryptorPassword password(keychain);
- EXPECT_FALSE(password.GetEncryptorPassword().empty());
+ KeychainPassword password(keychain);
+ EXPECT_FALSE(password.GetPassword().empty());
EXPECT_FALSE(keychain.called_add_generic());
EXPECT_EQ(0, keychain.password_data_count());
}
// Test that if we do not have an existing password in the Keychain then it
// gets added successfully and returned.
-TEST(EncryptorPasswordTest, FindPasswordNotFound) {
+TEST(KeychainPasswordTest, FindPasswordNotFound) {
MockAppleKeychain keychain;
keychain.set_find_generic_result(errSecItemNotFound);
- EncryptorPassword password(keychain);
- EXPECT_EQ(24U, password.GetEncryptorPassword().length());
+ KeychainPassword password(keychain);
+ EXPECT_EQ(24U, password.GetPassword().length());
EXPECT_TRUE(keychain.called_add_generic());
EXPECT_EQ(0, keychain.password_data_count());
}
// Test that if get denied access by the user then we return an empty password.
// And we should not try to add one.
-TEST(EncryptorPasswordTest, FindPasswordNotAuthorized) {
+TEST(KeychainPasswordTest, FindPasswordNotAuthorized) {
MockAppleKeychain keychain;
keychain.set_find_generic_result(errSecAuthFailed);
- EncryptorPassword password(keychain);
- EXPECT_TRUE(password.GetEncryptorPassword().empty());
+ KeychainPassword password(keychain);
+ EXPECT_TRUE(password.GetPassword().empty());
EXPECT_FALSE(keychain.called_add_generic());
EXPECT_EQ(0, keychain.password_data_count());
}
// Test that if some random other error happens then we return an empty
// password, and we should not try to add one.
-TEST(EncryptorPasswordTest, FindPasswordOtherError) {
+TEST(KeychainPasswordTest, FindPasswordOtherError) {
MockAppleKeychain keychain;
keychain.set_find_generic_result(errSecNotAvailable);
- EncryptorPassword password(keychain);
- EXPECT_TRUE(password.GetEncryptorPassword().empty());
+ KeychainPassword password(keychain);
+ EXPECT_TRUE(password.GetPassword().empty());
EXPECT_FALSE(keychain.called_add_generic());
EXPECT_EQ(0, keychain.password_data_count());
}
// Test that subsequent additions to the keychain give different passwords.
-TEST(EncryptorPasswordTest, PasswordsDiffer) {
+TEST(KeychainPasswordTest, PasswordsDiffer) {
MockAppleKeychain keychain1;
keychain1.set_find_generic_result(errSecItemNotFound);
- EncryptorPassword encryptor_password1(keychain1);
- std::string password1 = encryptor_password1.GetEncryptorPassword();
+ KeychainPassword encryptor_password1(keychain1);
+ std::string password1 = encryptor_password1.GetPassword();
EXPECT_FALSE(password1.empty());
EXPECT_TRUE(keychain1.called_add_generic());
EXPECT_EQ(0, keychain1.password_data_count());
MockAppleKeychain keychain2;
keychain2.set_find_generic_result(errSecItemNotFound);
- EncryptorPassword encryptor_password2(keychain2);
- std::string password2 = encryptor_password2.GetEncryptorPassword();
+ KeychainPassword encryptor_password2(keychain2);
+ std::string password2 = encryptor_password2.GetPassword();
EXPECT_FALSE(password2.empty());
EXPECT_TRUE(keychain2.called_add_generic());
EXPECT_EQ(0, keychain2.password_data_count());
diff --git a/components/encryptor/os_crypt.h b/components/encryptor/os_crypt.h
new file mode 100644
index 0000000..ae899aa
--- /dev/null
+++ b/components/encryptor/os_crypt.h
@@ -0,0 +1,48 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_ENCRYPTOR_OS_CRYPT_H_
+#define COMPONENTS_ENCRYPTOR_OS_CRYPT_H_
+
+#include <string>
+
+#include "base/strings/string16.h"
+
+// The OSCrypt class gives access to simple encryption and decryption of
+// strings. Note that on Mac, access to the system Keychain is required and
+// these calls can block the current thread to collect user input.
+class OSCrypt {
+ public:
+ // Encrypt a string16. The output (second argument) is really an array of
+ // bytes, but we're passing it back as a std::string.
+ static bool EncryptString16(const base::string16& plaintext,
+ std::string* ciphertext);
+
+ // Decrypt an array of bytes obtained with EncryptString16 back into a
+ // string16. Note that the input (first argument) is a std::string, so you
+ // need to first get your (binary) data into a string.
+ static bool DecryptString16(const std::string& ciphertext,
+ base::string16* plaintext);
+
+ // Encrypt a string.
+ static bool EncryptString(const std::string& plaintext,
+ std::string* ciphertext);
+
+ // Decrypt an array of bytes obtained with EnctryptString back into a string.
+ // Note that the input (first argument) is a std::string, so you need to first
+ // get your (binary) data into a string.
+ static bool DecryptString(const std::string& ciphertext,
+ std::string* plaintext);
+
+#if defined(OS_MACOSX)
+ // For unit testing purposes we instruct the Encryptor to use a mock Keychain
+ // on the Mac. The default is to use the real Keychain.
+ static void UseMockKeychain(bool use_mock);
+#endif
+
+ private:
+ DISALLOW_IMPLICIT_CONSTRUCTORS(OSCrypt);
+};
+
+#endif // COMPONENTS_ENCRYPTOR_OS_CRYPT_H_
diff --git a/components/encryptor/encryptor_mac.mm b/components/encryptor/os_crypt_mac.mm
index 583f18a..13d6c2e 100644
--- a/components/encryptor/encryptor_mac.mm
+++ b/components/encryptor/os_crypt_mac.mm
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include <CommonCrypto/CommonCryptor.h> // for kCCBlockSizeAES128
@@ -10,8 +10,8 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/utf_string_conversions.h"
-#include "components/encryptor/encryptor_password_mac.h"
#include "components/encryptor/encryptor_switches.h"
+#include "components/encryptor/keychain_password_mac.h"
#include "crypto/apple_keychain.h"
#include "crypto/encryptor.h"
#include "crypto/symmetric_key.h"
@@ -51,8 +51,8 @@ crypto::SymmetricKey* GetEncryptionKey() {
password = "mock_password";
} else {
AppleKeychain keychain;
- EncryptorPassword encryptor_password(keychain);
- password = encryptor_password.GetEncryptorPassword();
+ KeychainPassword encryptor_password(keychain);
+ password = encryptor_password.GetPassword();
}
if (password.empty())
@@ -74,13 +74,13 @@ crypto::SymmetricKey* GetEncryptionKey() {
} // namespace
-bool Encryptor::EncryptString16(const base::string16& plaintext,
- std::string* ciphertext) {
+bool OSCrypt::EncryptString16(const base::string16& plaintext,
+ std::string* ciphertext) {
return EncryptString(base::UTF16ToUTF8(plaintext), ciphertext);
}
-bool Encryptor::DecryptString16(const std::string& ciphertext,
- base::string16* plaintext) {
+bool OSCrypt::DecryptString16(const std::string& ciphertext,
+ base::string16* plaintext) {
std::string utf8;
if (!DecryptString(ciphertext, &utf8))
return false;
@@ -89,8 +89,8 @@ bool Encryptor::DecryptString16(const std::string& ciphertext,
return true;
}
-bool Encryptor::EncryptString(const std::string& plaintext,
- std::string* ciphertext) {
+bool OSCrypt::EncryptString(const std::string& plaintext,
+ std::string* ciphertext) {
if (plaintext.empty()) {
*ciphertext = std::string();
return true;
@@ -113,8 +113,8 @@ bool Encryptor::EncryptString(const std::string& plaintext,
return true;
}
-bool Encryptor::DecryptString(const std::string& ciphertext,
- std::string* plaintext) {
+bool OSCrypt::DecryptString(const std::string& ciphertext,
+ std::string* plaintext) {
if (ciphertext.empty()) {
*plaintext = std::string();
return true;
@@ -149,7 +149,7 @@ bool Encryptor::DecryptString(const std::string& ciphertext,
return true;
}
-void Encryptor::UseMockKeychain(bool use_mock) {
+void OSCrypt::UseMockKeychain(bool use_mock) {
use_mock_keychain = use_mock;
}
diff --git a/components/encryptor/encryptor_posix.cc b/components/encryptor/os_crypt_posix.cc
index 1bcfe3d..3dc6758 100644
--- a/components/encryptor/encryptor_posix.cc
+++ b/components/encryptor/os_crypt_posix.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -54,13 +54,13 @@ crypto::SymmetricKey* GetEncryptionKey() {
} // namespace
-bool Encryptor::EncryptString16(const base::string16& plaintext,
- std::string* ciphertext) {
+bool OSCrypt::EncryptString16(const base::string16& plaintext,
+ std::string* ciphertext) {
return EncryptString(base::UTF16ToUTF8(plaintext), ciphertext);
}
-bool Encryptor::DecryptString16(const std::string& ciphertext,
- base::string16* plaintext) {
+bool OSCrypt::DecryptString16(const std::string& ciphertext,
+ base::string16* plaintext) {
std::string utf8;
if (!DecryptString(ciphertext, &utf8))
return false;
@@ -69,8 +69,8 @@ bool Encryptor::DecryptString16(const std::string& ciphertext,
return true;
}
-bool Encryptor::EncryptString(const std::string& plaintext,
- std::string* ciphertext) {
+bool OSCrypt::EncryptString(const std::string& plaintext,
+ std::string* ciphertext) {
// This currently "obfuscates" by encrypting with hard-coded password.
// We need to improve this password situation by moving a secure password
// into a system-level key store.
@@ -98,8 +98,8 @@ bool Encryptor::EncryptString(const std::string& plaintext,
return true;
}
-bool Encryptor::DecryptString(const std::string& ciphertext,
- std::string* plaintext) {
+bool OSCrypt::DecryptString(const std::string& ciphertext,
+ std::string* plaintext) {
// This currently "obfuscates" by encrypting with hard-coded password.
// We need to improve this password situation by moving a secure password
// into a system-level key store.
diff --git a/components/encryptor/encryptor_unittest.cc b/components/encryptor/os_crypt_unittest.cc
index 2e90b1e..fcc4d22 100644
--- a/components/encryptor/encryptor_unittest.cc
+++ b/components/encryptor/os_crypt_unittest.cc
@@ -2,31 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include <string>
+#include "base/compiler_specific.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
-class EncryptorTest : public testing::Test {
+class OSCryptTest : public testing::Test {
public:
- EncryptorTest() {}
+ OSCryptTest() {}
- virtual void SetUp() {
+ virtual void SetUp() OVERRIDE {
#if defined(OS_MACOSX)
- Encryptor::UseMockKeychain(true);
+ OSCrypt::UseMockKeychain(true);
#endif
}
private:
- DISALLOW_COPY_AND_ASSIGN(EncryptorTest);
+ DISALLOW_COPY_AND_ASSIGN(OSCryptTest);
};
-TEST_F(EncryptorTest, String16EncryptionDecryption) {
+TEST_F(OSCryptTest, String16EncryptionDecryption) {
base::string16 plaintext;
base::string16 result;
std::string utf8_plaintext;
@@ -34,21 +35,21 @@ TEST_F(EncryptorTest, String16EncryptionDecryption) {
std::string ciphertext;
// Test borderline cases (empty strings).
- EXPECT_TRUE(Encryptor::EncryptString16(plaintext, &ciphertext));
- EXPECT_TRUE(Encryptor::DecryptString16(ciphertext, &result));
+ EXPECT_TRUE(OSCrypt::EncryptString16(plaintext, &ciphertext));
+ EXPECT_TRUE(OSCrypt::DecryptString16(ciphertext, &result));
EXPECT_EQ(plaintext, result);
// Test a simple string.
plaintext = base::ASCIIToUTF16("hello");
- EXPECT_TRUE(Encryptor::EncryptString16(plaintext, &ciphertext));
- EXPECT_TRUE(Encryptor::DecryptString16(ciphertext, &result));
+ EXPECT_TRUE(OSCrypt::EncryptString16(plaintext, &ciphertext));
+ EXPECT_TRUE(OSCrypt::DecryptString16(ciphertext, &result));
EXPECT_EQ(plaintext, result);
// Test a 16-byte aligned string. This previously hit a boundary error in
- // base::Encryptor::Crypt() on Mac.
+ // base::OSCrypt::Crypt() on Mac.
plaintext = base::ASCIIToUTF16("1234567890123456");
- EXPECT_TRUE(Encryptor::EncryptString16(plaintext, &ciphertext));
- EXPECT_TRUE(Encryptor::DecryptString16(ciphertext, &result));
+ EXPECT_TRUE(OSCrypt::EncryptString16(plaintext, &ciphertext));
+ EXPECT_TRUE(OSCrypt::DecryptString16(ciphertext, &result));
EXPECT_EQ(plaintext, result);
// Test Unicode.
@@ -61,81 +62,81 @@ TEST_F(EncryptorTest, String16EncryptionDecryption) {
plaintext = wchars;
utf8_plaintext = base::UTF16ToUTF8(plaintext);
EXPECT_EQ(plaintext, base::UTF8ToUTF16(utf8_plaintext));
- EXPECT_TRUE(Encryptor::EncryptString16(plaintext, &ciphertext));
- EXPECT_TRUE(Encryptor::DecryptString16(ciphertext, &result));
+ EXPECT_TRUE(OSCrypt::EncryptString16(plaintext, &ciphertext));
+ EXPECT_TRUE(OSCrypt::DecryptString16(ciphertext, &result));
EXPECT_EQ(plaintext, result);
- EXPECT_TRUE(Encryptor::DecryptString(ciphertext, &utf8_result));
+ EXPECT_TRUE(OSCrypt::DecryptString(ciphertext, &utf8_result));
EXPECT_EQ(utf8_plaintext, base::UTF16ToUTF8(result));
- EXPECT_TRUE(Encryptor::EncryptString(utf8_plaintext, &ciphertext));
- EXPECT_TRUE(Encryptor::DecryptString16(ciphertext, &result));
+ EXPECT_TRUE(OSCrypt::EncryptString(utf8_plaintext, &ciphertext));
+ EXPECT_TRUE(OSCrypt::DecryptString16(ciphertext, &result));
EXPECT_EQ(plaintext, result);
- EXPECT_TRUE(Encryptor::DecryptString(ciphertext, &utf8_result));
+ EXPECT_TRUE(OSCrypt::DecryptString(ciphertext, &utf8_result));
EXPECT_EQ(utf8_plaintext, base::UTF16ToUTF8(result));
}
-TEST_F(EncryptorTest, EncryptionDecryption) {
+TEST_F(OSCryptTest, EncryptionDecryption) {
std::string plaintext;
std::string result;
std::string ciphertext;
// Test borderline cases (empty strings).
- ASSERT_TRUE(Encryptor::EncryptString(plaintext, &ciphertext));
- ASSERT_TRUE(Encryptor::DecryptString(ciphertext, &result));
+ ASSERT_TRUE(OSCrypt::EncryptString(plaintext, &ciphertext));
+ ASSERT_TRUE(OSCrypt::DecryptString(ciphertext, &result));
EXPECT_EQ(plaintext, result);
// Test a simple string.
plaintext = "hello";
- ASSERT_TRUE(Encryptor::EncryptString(plaintext, &ciphertext));
- ASSERT_TRUE(Encryptor::DecryptString(ciphertext, &result));
+ ASSERT_TRUE(OSCrypt::EncryptString(plaintext, &ciphertext));
+ ASSERT_TRUE(OSCrypt::DecryptString(ciphertext, &result));
EXPECT_EQ(plaintext, result);
// Make sure it null terminates.
plaintext.assign("hello", 3);
- ASSERT_TRUE(Encryptor::EncryptString(plaintext, &ciphertext));
- ASSERT_TRUE(Encryptor::DecryptString(ciphertext, &result));
+ ASSERT_TRUE(OSCrypt::EncryptString(plaintext, &ciphertext));
+ ASSERT_TRUE(OSCrypt::DecryptString(ciphertext, &result));
EXPECT_EQ(plaintext, "hel");
}
-TEST_F(EncryptorTest, CypherTextDiffers) {
+TEST_F(OSCryptTest, CypherTextDiffers) {
std::string plaintext;
std::string result;
std::string ciphertext;
// Test borderline cases (empty strings).
- ASSERT_TRUE(Encryptor::EncryptString(plaintext, &ciphertext));
- ASSERT_TRUE(Encryptor::DecryptString(ciphertext, &result));
+ ASSERT_TRUE(OSCrypt::EncryptString(plaintext, &ciphertext));
+ ASSERT_TRUE(OSCrypt::DecryptString(ciphertext, &result));
// |cyphertext| is empty on the Mac, different on Windows.
EXPECT_TRUE(ciphertext.empty() || plaintext != ciphertext);
EXPECT_EQ(plaintext, result);
// Test a simple string.
plaintext = "hello";
- ASSERT_TRUE(Encryptor::EncryptString(plaintext, &ciphertext));
- ASSERT_TRUE(Encryptor::DecryptString(ciphertext, &result));
+ ASSERT_TRUE(OSCrypt::EncryptString(plaintext, &ciphertext));
+ ASSERT_TRUE(OSCrypt::DecryptString(ciphertext, &result));
EXPECT_NE(plaintext, ciphertext);
EXPECT_EQ(plaintext, result);
// Make sure it null terminates.
plaintext.assign("hello", 3);
- ASSERT_TRUE(Encryptor::EncryptString(plaintext, &ciphertext));
- ASSERT_TRUE(Encryptor::DecryptString(ciphertext, &result));
+ ASSERT_TRUE(OSCrypt::EncryptString(plaintext, &ciphertext));
+ ASSERT_TRUE(OSCrypt::DecryptString(ciphertext, &result));
EXPECT_NE(plaintext, ciphertext);
EXPECT_EQ(result, "hel");
}
-TEST_F(EncryptorTest, DecryptError) {
+TEST_F(OSCryptTest, DecryptError) {
std::string plaintext;
std::string result;
std::string ciphertext;
// Test a simple string, messing with ciphertext prior to decrypting.
plaintext = "hello";
- ASSERT_TRUE(Encryptor::EncryptString(plaintext, &ciphertext));
+ ASSERT_TRUE(OSCrypt::EncryptString(plaintext, &ciphertext));
EXPECT_NE(plaintext, ciphertext);
ASSERT_LT(4UL, ciphertext.size());
ciphertext[3] = ciphertext[3] + 1;
- EXPECT_FALSE(Encryptor::DecryptString(ciphertext, &result));
+ EXPECT_FALSE(OSCrypt::DecryptString(ciphertext, &result));
EXPECT_NE(plaintext, result);
EXPECT_TRUE(result.empty());
}
diff --git a/components/encryptor/encryptor_win.cc b/components/encryptor/os_crypt_win.cc
index 6dd6673..3853509 100644
--- a/components/encryptor/encryptor_win.cc
+++ b/components/encryptor/os_crypt_win.cc
@@ -2,21 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include <windows.h>
#include <wincrypt.h>
+
#include "base/strings/utf_string_conversions.h"
#pragma comment(lib, "crypt32.lib")
-bool Encryptor::EncryptString16(const base::string16& plaintext,
- std::string* ciphertext) {
+bool OSCrypt::EncryptString16(const base::string16& plaintext,
+ std::string* ciphertext) {
return EncryptString(base::UTF16ToUTF8(plaintext), ciphertext);
}
-bool Encryptor::DecryptString16(const std::string& ciphertext,
- base::string16* plaintext) {
+bool OSCrypt::DecryptString16(const std::string& ciphertext,
+ base::string16* plaintext) {
std::string utf8;
if (!DecryptString(ciphertext, &utf8))
return false;
@@ -25,8 +26,8 @@ bool Encryptor::DecryptString16(const std::string& ciphertext,
return true;
}
-bool Encryptor::EncryptString(const std::string& plaintext,
- std::string* ciphertext) {
+bool OSCrypt::EncryptString(const std::string& plaintext,
+ std::string* ciphertext) {
DATA_BLOB input;
input.pbData = const_cast<BYTE*>(
reinterpret_cast<const BYTE*>(plaintext.data()));
@@ -46,8 +47,8 @@ bool Encryptor::EncryptString(const std::string& plaintext,
return true;
}
-bool Encryptor::DecryptString(const std::string& ciphertext,
- std::string* plaintext) {
+bool OSCrypt::DecryptString(const std::string& ciphertext,
+ std::string* plaintext) {
DATA_BLOB input;
input.pbData = const_cast<BYTE*>(
reinterpret_cast<const BYTE*>(ciphertext.data()));
diff --git a/components/password_manager/core/browser/login_database_win.cc b/components/password_manager/core/browser/login_database_win.cc
index 44a1d56..3479aef 100644
--- a/components/password_manager/core/browser/login_database_win.cc
+++ b/components/password_manager/core/browser/login_database_win.cc
@@ -2,14 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/strings/string_util.h"
-#include "components/encryptor/encryptor.h"
#include "components/password_manager/core/browser/login_database.h"
+#include "base/strings/string_util.h"
+#include "components/encryptor/os_crypt.h"
+
LoginDatabase::EncryptionResult LoginDatabase::EncryptedString(
const base::string16& plain_text,
std::string* cipher_text) const {
- if (Encryptor::EncryptString16(plain_text, cipher_text))
+ if (OSCrypt::EncryptString16(plain_text, cipher_text))
return ENCRYPTION_RESULT_SUCCESS;
return ENCRYPTION_RESULT_ITEM_FAILURE;
}
@@ -17,7 +18,7 @@ LoginDatabase::EncryptionResult LoginDatabase::EncryptedString(
LoginDatabase::EncryptionResult LoginDatabase::DecryptedString(
const std::string& cipher_text,
base::string16* plain_text) const {
- if (Encryptor::DecryptString16(cipher_text, plain_text))
+ if (OSCrypt::DecryptString16(cipher_text, plain_text))
return ENCRYPTION_RESULT_SUCCESS;
return ENCRYPTION_RESULT_ITEM_FAILURE;
}
diff --git a/components/signin/core/webdata/token_service_table.cc b/components/signin/core/webdata/token_service_table.cc
index bce7fe2..a455bc7 100644
--- a/components/signin/core/webdata/token_service_table.cc
+++ b/components/signin/core/webdata/token_service_table.cc
@@ -8,7 +8,7 @@
#include <string>
#include "base/logging.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "components/webdata/common/web_database.h"
#include "sql/statement.h"
@@ -72,7 +72,7 @@ bool TokenServiceTable::RemoveTokenForService(const std::string& service) {
bool TokenServiceTable::SetTokenForService(const std::string& service,
const std::string& token) {
std::string encrypted_token;
- bool encrypted = Encryptor::EncryptString(token, &encrypted_token);
+ bool encrypted = OSCrypt::EncryptString(token, &encrypted_token);
if (!encrypted) {
return false;
}
@@ -105,7 +105,7 @@ bool TokenServiceTable::GetAllTokens(
bool entry_ok = !service.empty() &&
s.ColumnBlobAsString(1, &encrypted_token);
if (entry_ok) {
- Encryptor::DecryptString(encrypted_token, &decrypted_token);
+ OSCrypt::DecryptString(encrypted_token, &decrypted_token);
(*tokens)[service] = decrypted_token;
} else {
NOTREACHED();
diff --git a/components/sync_driver/system_encryptor.cc b/components/sync_driver/system_encryptor.cc
index 3198d6f..2a82a6c 100644
--- a/components/sync_driver/system_encryptor.cc
+++ b/components/sync_driver/system_encryptor.cc
@@ -4,7 +4,7 @@
#include "components/sync_driver/system_encryptor.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
namespace browser_sync {
@@ -12,12 +12,12 @@ SystemEncryptor::~SystemEncryptor() {}
bool SystemEncryptor::EncryptString(const std::string& plaintext,
std::string* ciphertext) {
- return ::Encryptor::EncryptString(plaintext, ciphertext);
+ return ::OSCrypt::EncryptString(plaintext, ciphertext);
}
bool SystemEncryptor::DecryptString(const std::string& ciphertext,
std::string* plaintext) {
- return ::Encryptor::DecryptString(ciphertext, plaintext);
+ return ::OSCrypt::DecryptString(ciphertext, plaintext);
}
} // namespace browser_sync
diff --git a/components/sync_driver/system_encryptor_unittest.cc b/components/sync_driver/system_encryptor_unittest.cc
index b015004..f4c9203 100644
--- a/components/sync_driver/system_encryptor_unittest.cc
+++ b/components/sync_driver/system_encryptor_unittest.cc
@@ -4,7 +4,7 @@
#include "components/sync_driver/system_encryptor.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace browser_sync {
@@ -22,7 +22,7 @@ TEST_F(SystemEncryptorTest, EncryptDecrypt) {
#if defined(OS_MACOSX)
// SystemEncryptor ends up needing access to the keychain on OS X,
// so use the mock keychain to prevent prompts.
- ::Encryptor::UseMockKeychain(true);
+ ::OSCrypt::UseMockKeychain(true);
#endif
std::string ciphertext;
EXPECT_TRUE(encryptor_.EncryptString(kPlaintext, &ciphertext));
diff --git a/google_apis/gcm/engine/gcm_store_impl.cc b/google_apis/gcm/engine/gcm_store_impl.cc
index efbb1f38..31b258f 100644
--- a/google_apis/gcm/engine/gcm_store_impl.cc
+++ b/google_apis/gcm/engine/gcm_store_impl.cc
@@ -17,7 +17,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/tracked_objects.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "google_apis/gcm/base/mcs_message.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/protocol/mcs.pb.h"
@@ -241,8 +241,8 @@ void GCMStoreImpl::Backend::SetDeviceCredentials(
write_options.sync = true;
std::string encrypted_token;
- Encryptor::EncryptString(base::Uint64ToString(device_security_token),
- &encrypted_token);
+ OSCrypt::EncryptString(base::Uint64ToString(device_security_token),
+ &encrypted_token);
std::string android_id_str = base::Uint64ToString(device_android_id);
leveldb::Status s =
db_->Put(write_options,
@@ -487,7 +487,7 @@ bool GCMStoreImpl::Backend::LoadDeviceCredentials(uint64* android_id,
}
if (s.ok()) {
std::string decrypted_token;
- Encryptor::DecryptString(result, &decrypted_token);
+ OSCrypt::DecryptString(result, &decrypted_token);
if (!base::StringToUint64(decrypted_token, security_token)) {
LOG(ERROR) << "Failed to restore security token.";
return false;
@@ -618,7 +618,7 @@ GCMStoreImpl::GCMStoreImpl(
weak_ptr_factory_(this) {
// On OSX, prevent the Keychain permissions popup during unit tests.
#if defined(OS_MACOSX)
- Encryptor::UseMockKeychain(use_mock_keychain);
+ OSCrypt::UseMockKeychain(use_mock_keychain);
#endif
}
diff --git a/google_apis/gcm/engine/mcs_client_unittest.cc b/google_apis/gcm/engine/mcs_client_unittest.cc
index 7eab21b..c4ab792 100644
--- a/google_apis/gcm/engine/mcs_client_unittest.cc
+++ b/google_apis/gcm/engine/mcs_client_unittest.cc
@@ -9,7 +9,7 @@
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/simple_test_clock.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/engine/fake_connection_factory.h"
#include "google_apis/gcm/engine/fake_connection_handler.h"
@@ -146,7 +146,7 @@ MCSClientTest::MCSClientTest()
// On OSX, prevent the Keychain permissions popup during unit tests.
#if defined(OS_MACOSX)
- Encryptor::UseMockKeychain(true);
+ OSCrypt::UseMockKeychain(true);
#endif
// Advance the clock to a non-zero time.
diff --git a/google_apis/gcm/gcm_client_impl_unittest.cc b/google_apis/gcm/gcm_client_impl_unittest.cc
index cb8d217c..d45a0fc 100644
--- a/google_apis/gcm/gcm_client_impl_unittest.cc
+++ b/google_apis/gcm/gcm_client_impl_unittest.cc
@@ -8,7 +8,7 @@
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/test/simple_test_clock.h"
-#include "components/encryptor/encryptor.h"
+#include "components/encryptor/os_crypt.h"
#include "google_apis/gcm/base/mcs_message.h"
#include "google_apis/gcm/base/mcs_util.h"
#include "google_apis/gcm/engine/fake_connection_factory.h"
@@ -287,7 +287,7 @@ void GCMClientImplTest::InitializeGCMClient() {
#if defined(OS_MACOSX)
// On OSX, prevent the Keychain permissions popup during unit tests.
- Encryptor::UseMockKeychain(true); // Must be after Initialize.
+ OSCrypt::UseMockKeychain(true); // Must be after Initialize.
#endif
// Starting loading and check-in.