OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sync/util/data_encryption_win.h" | 5 #include "sync/util/data_encryption_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <wincrypt.h> | 8 #include <wincrypt.h> |
9 | 9 |
10 #include <cstddef> | 10 #include <cstddef> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 | 13 |
14 #pragma comment(lib, "crypt32.lib") | 14 #pragma comment(lib, "crypt32.lib") |
15 | 15 |
16 // TODO(akalin): Merge this with similar code in | 16 // TODO(akalin): Merge this with similar code in |
17 // chrome/browser/password_manager/encryptor_win.cc. Preferably, all | 17 // components/webdata/encryptor/encryptor_win.cc. Preferably, all |
18 // this stuff would live in crypto/. | 18 // this stuff would live in crypto/. |
19 | 19 |
20 namespace syncer { | 20 namespace syncer { |
21 | 21 |
22 std::vector<uint8> EncryptData(const std::string& data) { | 22 std::vector<uint8> EncryptData(const std::string& data) { |
23 DATA_BLOB unencrypted_data = { 0 }; | 23 DATA_BLOB unencrypted_data = { 0 }; |
24 unencrypted_data.pbData = (BYTE*)(data.data()); | 24 unencrypted_data.pbData = (BYTE*)(data.data()); |
25 unencrypted_data.cbData = data.size(); | 25 unencrypted_data.cbData = data.size(); |
26 DATA_BLOB encrypted_data = { 0 }; | 26 DATA_BLOB encrypted_data = { 0 }; |
27 | 27 |
(...skipping 20 matching lines...) Expand all Loading... |
48 return false; | 48 return false; |
49 } else { | 49 } else { |
50 out_data->assign(reinterpret_cast<const char*>(decrypted_data.pbData), | 50 out_data->assign(reinterpret_cast<const char*>(decrypted_data.pbData), |
51 decrypted_data.cbData); | 51 decrypted_data.cbData); |
52 LocalFree(decrypted_data.pbData); | 52 LocalFree(decrypted_data.pbData); |
53 return true; | 53 return true; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 } // namespace syncer | 57 } // namespace syncer |
OLD | NEW |