| 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 "components/webdata/encryptor/encryptor.h" | 5 #include "components/webdata/encryptor/encryptor.h" |
| 6 | 6 |
| 7 #include <CommonCrypto/CommonCryptor.h> // for kCCBlockSizeAES128 | 7 #include <CommonCrypto/CommonCryptor.h> // for kCCBlockSizeAES128 |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 kDerivedKeySizeInBits)); | 64 kDerivedKeySizeInBits)); |
| 65 DCHECK(encryption_key.get()); | 65 DCHECK(encryption_key.get()); |
| 66 | 66 |
| 67 return encryption_key.release(); | 67 return encryption_key.release(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 } // namespace | 70 } // namespace |
| 71 | 71 |
| 72 bool Encryptor::EncryptString16(const base::string16& plaintext, | 72 bool Encryptor::EncryptString16(const base::string16& plaintext, |
| 73 std::string* ciphertext) { | 73 std::string* ciphertext) { |
| 74 return EncryptString(UTF16ToUTF8(plaintext), ciphertext); | 74 return EncryptString(base::UTF16ToUTF8(plaintext), ciphertext); |
| 75 } | 75 } |
| 76 | 76 |
| 77 bool Encryptor::DecryptString16(const std::string& ciphertext, | 77 bool Encryptor::DecryptString16(const std::string& ciphertext, |
| 78 base::string16* plaintext) { | 78 base::string16* plaintext) { |
| 79 std::string utf8; | 79 std::string utf8; |
| 80 if (!DecryptString(ciphertext, &utf8)) | 80 if (!DecryptString(ciphertext, &utf8)) |
| 81 return false; | 81 return false; |
| 82 | 82 |
| 83 *plaintext = UTF8ToUTF16(utf8); | 83 *plaintext = base::UTF8ToUTF16(utf8); |
| 84 return true; | 84 return true; |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool Encryptor::EncryptString(const std::string& plaintext, | 87 bool Encryptor::EncryptString(const std::string& plaintext, |
| 88 std::string* ciphertext) { | 88 std::string* ciphertext) { |
| 89 if (plaintext.empty()) { | 89 if (plaintext.empty()) { |
| 90 *ciphertext = std::string(); | 90 *ciphertext = std::string(); |
| 91 return true; | 91 return true; |
| 92 } | 92 } |
| 93 | 93 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 if (!encryptor.Decrypt(raw_ciphertext, plaintext)) | 141 if (!encryptor.Decrypt(raw_ciphertext, plaintext)) |
| 142 return false; | 142 return false; |
| 143 | 143 |
| 144 return true; | 144 return true; |
| 145 } | 145 } |
| 146 | 146 |
| 147 void Encryptor::UseMockKeychain(bool use_mock) { | 147 void Encryptor::UseMockKeychain(bool use_mock) { |
| 148 use_mock_keychain = use_mock; | 148 use_mock_keychain = use_mock; |
| 149 } | 149 } |
| 150 | 150 |
| OLD | NEW |