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

Unified Diff: components/webdata/encryptor/ie7_password_win.cc

Issue 26465006: Fix IE password import (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Renaming ie7_password to ie7_password_win Created 7 years, 2 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
« no previous file with comments | « components/webdata/encryptor/ie7_password_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/webdata/encryptor/ie7_password_win.cc
diff --git a/components/webdata/encryptor/ie7_password.cc b/components/webdata/encryptor/ie7_password_win.cc
similarity index 76%
rename from components/webdata/encryptor/ie7_password.cc
rename to components/webdata/encryptor/ie7_password_win.cc
index e7db3ab3be0268842fc8415417668b81b4524a7b..c5ed4ffe5ad0522d3fad100e526b745198c824f3 100644
--- a/components/webdata/encryptor/ie7_password.cc
+++ b/components/webdata/encryptor/ie7_password_win.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/webdata/encryptor/ie7_password.h"
+#include "components/webdata/encryptor/ie7_password_win.h"
#include <wincrypt.h>
#include <string>
@@ -28,8 +28,7 @@ struct Header {
char wick[4]; // The string "WICK". I don't know what it means.
DWORD fixed_header_size; // The size of this structure without the entries:
// sizeof(Header).
- DWORD item_count; // Number of entries. It should always be 2. One for
- // the username, and one for the password.
+ DWORD item_count; // Number of entries. Should be even.
wchar_t two_letters[2]; // Two unknown bytes.
DWORD unknown[2]; // Two unknown DWORDs.
};
@@ -45,17 +44,16 @@ struct Entry {
struct PasswordEntry {
PreHeader pre_header; // Contains the size of the different sections.
Header header; // Contains the number of items.
- Entry entry[1]; // List of entries containing a string. The first one
- // is the username, the second one if the password.
+ Entry entry[1]; // List of entries containing a string. Even-indexed
+ // are usernames, odd are passwords. There may be
+ // several sets saved for a single url hash.
};
-
} // namespace
namespace ie7_password {
bool GetUserPassFromData(const std::vector<unsigned char>& data,
- std::wstring* username,
- std::wstring* password) {
+ std::vector<DecryptedCredentials>* credentials) {
const PasswordEntry* information =
reinterpret_cast<const PasswordEntry*>(&data.front());
@@ -64,23 +62,29 @@ bool GetUserPassFromData(const std::vector<unsigned char>& data,
if (information->pre_header.pre_header_size != sizeof(PreHeader))
return false;
- if (information->header.item_count != 2) // Username and Password
+ const int entry_count = information->header.item_count;
+ if (entry_count % 2) // Usernames and Passwords
return false;
if (information->header.fixed_header_size != sizeof(Header))
return false;
- const uint8* ptr = &data.front();
- const uint8* offset_to_data = ptr + information->pre_header.header_size +
+ const uint8* offset_to_data = &data[0] +
+ information->pre_header.header_size +
information->pre_header.pre_header_size;
- const Entry* user_entry = information->entry;
- const Entry* pass_entry = user_entry+1;
+ for (int i = 0; i < entry_count / 2; ++i) {
+
+ const Entry* user_entry = &information->entry[2*i];
+ const Entry* pass_entry = user_entry+1;
- *username = reinterpret_cast<const wchar_t*>(offset_to_data +
- user_entry->offset);
- *password = reinterpret_cast<const wchar_t*>(offset_to_data +
- pass_entry->offset);
+ DecryptedCredentials c;
+ c.username = reinterpret_cast<const wchar_t*>(offset_to_data +
+ user_entry->offset);
+ c.password = reinterpret_cast<const wchar_t*>(offset_to_data +
+ pass_entry->offset);
+ credentials->push_back(c);
+ }
return true;
}
@@ -108,9 +112,9 @@ std::wstring GetUrlHash(const std::wstring& url) {
return url_hash;
}
-bool DecryptPassword(const std::wstring& url,
- const std::vector<unsigned char>& data,
- std::wstring* username, std::wstring* password) {
+bool DecryptPasswords(const std::wstring& url,
+ const std::vector<unsigned char>& data,
+ std::vector<DecryptedCredentials>* credentials) {
std::wstring lower_case_url = StringToLowerASCII(url);
DATA_BLOB input = {0};
DATA_BLOB output = {0};
@@ -132,7 +136,7 @@ bool DecryptPassword(const std::wstring& url,
decrypted_data.resize(output.cbData);
memcpy(&decrypted_data.front(), output.pbData, output.cbData);
- GetUserPassFromData(decrypted_data, username, password);
+ GetUserPassFromData(decrypted_data, credentials);
LocalFree(output.pbData);
return true;
« no previous file with comments | « components/webdata/encryptor/ie7_password_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698