Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: components/password_manager/core/browser/login_database_win.cc

Issue 2291123008: Test that LoginDatabase preserves PasswordForm::Scheme through migration (Closed)
Patch Set: Add comment Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698