diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-27 17:54:48 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-27 17:54:48 +0000 |
commit | b584a879c1f8c607d952890a84b1625fa8d0a74f (patch) | |
tree | 57ac2dba65c764a22f31f15cc5e86c666a83a207 /sync | |
parent | afcc6820dc65730d049495cae6c418711aa5fa30 (diff) | |
download | chromium_src-b584a879c1f8c607d952890a84b1625fa8d0a74f.zip chromium_src-b584a879c1f8c607d952890a84b1625fa8d0a74f.tar.gz chromium_src-b584a879c1f8c607d952890a84b1625fa8d0a74f.tar.bz2 |
components/autofill: Break the dependency on sync utility file.
Do this moving data_encryption_win* into core/browser, since it's only used
from there.
BUG=140037
TEST=unit_tests,checkdeps.py
R=joi@chromium.org,isherman@chromium.org,akalin@chromium.org
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/17745004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208948 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/sync_core.gypi | 6 | ||||
-rw-r--r-- | sync/sync_tests.gypi | 1 | ||||
-rw-r--r-- | sync/util/data_encryption_win.cc | 57 | ||||
-rw-r--r-- | sync/util/data_encryption_win.h | 22 | ||||
-rw-r--r-- | sync/util/data_encryption_win_unittest.cc | 27 |
5 files changed, 0 insertions, 113 deletions
diff --git a/sync/sync_core.gypi b/sync/sync_core.gypi index 5d0bac9..f61d622 100644 --- a/sync/sync_core.gypi +++ b/sync/sync_core.gypi @@ -167,12 +167,6 @@ 'syncable/write_transaction_info.h', 'util/cryptographer.cc', 'util/cryptographer.h', - - # TODO(akalin): Figure out a better place to put - # data_encryption_win*; it's also used by autofill. - 'util/data_encryption_win.cc', - 'util/data_encryption_win.h', - 'util/data_type_histogram.h', 'util/encryptor.h', 'util/extensions_activity_monitor.cc', diff --git a/sync/sync_tests.gypi b/sync/sync_tests.gypi index 7c56492..e2f7c9e 100644 --- a/sync/sync_tests.gypi +++ b/sync/sync_tests.gypi @@ -268,7 +268,6 @@ 'syncable/syncable_unittest.cc', 'syncable/syncable_util_unittest.cc', 'util/cryptographer_unittest.cc', - 'util/data_encryption_win_unittest.cc', 'util/data_type_histogram_unittest.cc', 'util/get_session_name_unittest.cc', 'util/nigori_unittest.cc', diff --git a/sync/util/data_encryption_win.cc b/sync/util/data_encryption_win.cc deleted file mode 100644 index 5fec33b..0000000 --- a/sync/util/data_encryption_win.cc +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2012 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. - -#include "sync/util/data_encryption_win.h" - -#include <windows.h> -#include <wincrypt.h> - -#include <cstddef> - -#include "base/logging.h" - -#pragma comment(lib, "crypt32.lib") - -// TODO(akalin): Merge this with similar code in -// components/webdata/encryptor/encryptor_win.cc. Preferably, all -// this stuff would live in crypto/. - -namespace syncer { - -std::vector<uint8> EncryptData(const std::string& data) { - DATA_BLOB unencrypted_data = { 0 }; - unencrypted_data.pbData = (BYTE*)(data.data()); - unencrypted_data.cbData = data.size(); - DATA_BLOB encrypted_data = { 0 }; - - if (!CryptProtectData(&unencrypted_data, L"", NULL, NULL, NULL, 0, - &encrypted_data)) - LOG(ERROR) << "Encryption fails: " << data; - - std::vector<uint8> result(encrypted_data.pbData, - encrypted_data.pbData + encrypted_data.cbData); - LocalFree(encrypted_data.pbData); - return result; -} - -bool DecryptData(const std::vector<uint8>& in_data, std::string* out_data) { - DATA_BLOB encrypted_data, decrypted_data; - encrypted_data.pbData = - (in_data.empty() ? NULL : const_cast<BYTE*>(&in_data[0])); - encrypted_data.cbData = in_data.size(); - LPWSTR descrip = L""; - - if (!CryptUnprotectData(&encrypted_data, &descrip, NULL, NULL, NULL, 0, - &decrypted_data)) { - LOG(ERROR) << "Decryption fails: "; - return false; - } else { - out_data->assign(reinterpret_cast<const char*>(decrypted_data.pbData), - decrypted_data.cbData); - LocalFree(decrypted_data.pbData); - return true; - } -} - -} // namespace syncer diff --git a/sync/util/data_encryption_win.h b/sync/util/data_encryption_win.h deleted file mode 100644 index 1b037c7..0000000 --- a/sync/util/data_encryption_win.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 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 SYNC_UTIL_DATA_ENCRYPTION_WIN_H_ -#define SYNC_UTIL_DATA_ENCRYPTION_WIN_H_ - -#include <string> -#include <vector> - -#include "base/basictypes.h" -#include "sync/base/sync_export.h" - -namespace syncer { - -SYNC_EXPORT_PRIVATE std::vector<uint8> EncryptData(const std::string& data); -SYNC_EXPORT bool DecryptData(const std::vector<uint8>& in_data, - std::string* out_data); - -} // namespace syncer - -#endif // SYNC_UTIL_DATA_ENCRYPTION_WIN_H_ diff --git a/sync/util/data_encryption_win_unittest.cc b/sync/util/data_encryption_win_unittest.cc deleted file mode 100644 index 0510554..0000000 --- a/sync/util/data_encryption_win_unittest.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2012 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. - -#include "sync/util/data_encryption_win.h" - -#include "testing/gtest/include/gtest/gtest.h" - -namespace syncer { -namespace { - -TEST(SyncDataEncryption, TestEncryptDecryptOfSampleString) { - std::vector<uint8> example(EncryptData("example")); - ASSERT_FALSE(example.empty()); - std::string result; - ASSERT_TRUE(DecryptData(example, &result)); - ASSERT_TRUE(result == "example"); -} - -TEST(SyncDataEncryption, TestDecryptFailure) { - std::vector<uint8> example(0, 0); - std::string result; - ASSERT_FALSE(DecryptData(example, &result)); -} - -} // namespace -} // namespace syncer |