| OLD | NEW |
| 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 "components/os_crypt/os_crypt.h" | 5 #include "components/os_crypt/os_crypt.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "crypto/wincrypt_shim.h" | 10 #include "crypto/wincrypt_shim.h" |
| 11 | 11 |
| 12 #pragma comment(lib, "crypt32.lib") | |
| 13 | |
| 14 bool OSCrypt::EncryptString16(const base::string16& plaintext, | 12 bool OSCrypt::EncryptString16(const base::string16& plaintext, |
| 15 std::string* ciphertext) { | 13 std::string* ciphertext) { |
| 16 return EncryptString(base::UTF16ToUTF8(plaintext), ciphertext); | 14 return EncryptString(base::UTF16ToUTF8(plaintext), ciphertext); |
| 17 } | 15 } |
| 18 | 16 |
| 19 bool OSCrypt::DecryptString16(const std::string& ciphertext, | 17 bool OSCrypt::DecryptString16(const std::string& ciphertext, |
| 20 base::string16* plaintext) { | 18 base::string16* plaintext) { |
| 21 std::string utf8; | 19 std::string utf8; |
| 22 if (!DecryptString(ciphertext, &utf8)) | 20 if (!DecryptString(ciphertext, &utf8)) |
| 23 return false; | 21 return false; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 DATA_BLOB output; | 55 DATA_BLOB output; |
| 58 BOOL result = CryptUnprotectData(&input, NULL, NULL, NULL, NULL, | 56 BOOL result = CryptUnprotectData(&input, NULL, NULL, NULL, NULL, |
| 59 0, &output); | 57 0, &output); |
| 60 if (!result) | 58 if (!result) |
| 61 return false; | 59 return false; |
| 62 | 60 |
| 63 plaintext->assign(reinterpret_cast<char*>(output.pbData), output.cbData); | 61 plaintext->assign(reinterpret_cast<char*>(output.pbData), output.cbData); |
| 64 LocalFree(output.pbData); | 62 LocalFree(output.pbData); |
| 65 return true; | 63 return true; |
| 66 } | 64 } |
| OLD | NEW |