| Index: components/password_manager/core/browser/login_database_win.cc
|
| diff --git a/components/password_manager/core/browser/login_database_win.cc b/components/password_manager/core/browser/login_database_win.cc
|
| index 2b2b2725573c21466fb57fe6cb1a674e94548c9a..6cf9c2188e789b31ea81ce7c105d1e34afcec5e1 100644
|
| --- a/components/password_manager/core/browser/login_database_win.cc
|
| +++ b/components/password_manager/core/browser/login_database_win.cc
|
| @@ -22,6 +22,19 @@ LoginDatabase::EncryptionResult LoginDatabase::EncryptedString(
|
| LoginDatabase::EncryptionResult LoginDatabase::DecryptedString(
|
| const std::string& cipher_text,
|
| base::string16* plain_text) {
|
| + // Unittests need to read sample database entries. If these entries had real
|
| + // passwords, their encoding would need to be different for every platform.
|
| + // To avoid the need for that, the entries have empty passwords. OSCrypt on
|
| + // Windows does not recognise the empty string as a valid encrypted string.
|
| + // Changing that for all clients of OSCrypt could have too broad an impact,
|
| + // therefore to allow platform-independent data files for LoginDatabase
|
| + // tests, the special handling of the empty string is added below instead.
|
| + // See also https://codereview.chromium.org/2291123008/#msg14 for a
|
| + // discussion.
|
| + if (cipher_text.empty()) {
|
| + plain_text->clear();
|
| + return ENCRYPTION_RESULT_SUCCESS;
|
| + }
|
| if (OSCrypt::DecryptString16(cipher_text, plain_text))
|
| return ENCRYPTION_RESULT_SUCCESS;
|
| return ENCRYPTION_RESULT_ITEM_FAILURE;
|
|
|