diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-25 04:28:42 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-25 04:28:42 +0000 |
commit | b6df29d526292b9c98948f5794f22450b3c5be91 (patch) | |
tree | 393ae8b9e97f2ae8382b1d025737c7482838588a /sync/util | |
parent | 233a6cceddb7c3446959ac6d590901f0a6365949 (diff) | |
download | chromium_src-b6df29d526292b9c98948f5794f22450b3c5be91.zip chromium_src-b6df29d526292b9c98948f5794f22450b3c5be91.tar.gz chromium_src-b6df29d526292b9c98948f5794f22450b3c5be91.tar.bz2 |
sync: Move data_encryption_win.h into syncer namespace.
R=akalin@chromium.org
TBR=dhollowa@chromium.org # for autofill
Review URL: https://chromiumcodereview.appspot.com/11421047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169392 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/util')
-rw-r--r-- | sync/util/data_encryption_win.cc | 17 | ||||
-rw-r--r-- | sync/util/data_encryption_win.h | 9 | ||||
-rw-r--r-- | sync/util/data_encryption_win_unittest.cc | 16 |
3 files changed, 18 insertions, 24 deletions
diff --git a/sync/util/data_encryption_win.cc b/sync/util/data_encryption_win.cc index bdc1e9d..943f849 100644 --- a/sync/util/data_encryption_win.cc +++ b/sync/util/data_encryption_win.cc @@ -1,8 +1,6 @@ // 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. -// -// NOTE: this file is Winodws specific. #include "sync/util/data_encryption_win.h" @@ -10,8 +8,6 @@ #include <wincrypt.h> #include <cstddef> -#include <string> -#include <vector> #include "base/logging.h" @@ -21,10 +17,9 @@ // chrome/browser/password_manager/encryptor_win.cc. Preferably, all // this stuff would live in crypto/. -using std::string; -using std::vector; +namespace syncer { -vector<uint8> EncryptData(const string& data) { +std::vector<uint8> EncryptData(const std::string& data) { DATA_BLOB unencrypted_data = { 0 }; unencrypted_data.pbData = (BYTE*)(data.data()); unencrypted_data.cbData = data.size(); @@ -34,13 +29,13 @@ vector<uint8> EncryptData(const string& data) { &encrypted_data)) LOG(ERROR) << "Encryption fails: " << data; - vector<uint8> result(encrypted_data.pbData, - encrypted_data.pbData + encrypted_data.cbData); + std::vector<uint8> result(encrypted_data.pbData, + encrypted_data.pbData + encrypted_data.cbData); LocalFree(encrypted_data.pbData); return result; } -bool DecryptData(const vector<uint8>& in_data, string* out_data) { +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])); @@ -58,3 +53,5 @@ bool DecryptData(const vector<uint8>& in_data, string* out_data) { return true; } } + +} // namespace syncer diff --git a/sync/util/data_encryption_win.h b/sync/util/data_encryption_win.h index 87732ba..5b7dc09 100644 --- a/sync/util/data_encryption_win.h +++ b/sync/util/data_encryption_win.h @@ -10,10 +10,11 @@ #include "base/basictypes.h" -using std::string; -using std::vector; +namespace syncer { -vector<uint8> EncryptData(const string& data); -bool DecryptData(const vector<uint8>& in_data, string* out_data); +std::vector<uint8> EncryptData(const std::string& data); +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 index 4fa5250..0510554 100644 --- a/sync/util/data_encryption_win_unittest.cc +++ b/sync/util/data_encryption_win_unittest.cc @@ -4,28 +4,24 @@ #include "sync/util/data_encryption_win.h" -#include <string> -#include <vector> - #include "testing/gtest/include/gtest/gtest.h" -using std::string; -using std::vector; - +namespace syncer { namespace { TEST(SyncDataEncryption, TestEncryptDecryptOfSampleString) { - vector<uint8> example(EncryptData("example")); + std::vector<uint8> example(EncryptData("example")); ASSERT_FALSE(example.empty()); - string result; + std::string result; ASSERT_TRUE(DecryptData(example, &result)); ASSERT_TRUE(result == "example"); } TEST(SyncDataEncryption, TestDecryptFailure) { - vector<uint8> example(0, 0); - string result; + std::vector<uint8> example(0, 0); + std::string result; ASSERT_FALSE(DecryptData(example, &result)); } } // namespace +} // namespace syncer |