OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef COMPONENTS_WEBDATA_ENCRYPTOR_IE7_PASSWORD_H_ | 5 #ifndef COMPONENTS_WEBDATA_ENCRYPTOR_IE7_PASSWORD_H_ |
6 #define COMPONENTS_WEBDATA_ENCRYPTOR_IE7_PASSWORD_H_ | 6 #define COMPONENTS_WEBDATA_ENCRYPTOR_IE7_PASSWORD_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 | 14 |
15 // Contains the information read from the IE7/IE8 Storage2 key in the registry. | 15 // Contains the information read from the IE7/IE8 Storage2 key in the registry. |
16 struct IE7PasswordInfo { | 16 struct IE7PasswordInfo { |
17 // Hash of the url. | 17 // Hash of the url. |
18 std::wstring url_hash; | 18 std::wstring url_hash; |
19 | 19 |
20 // Encrypted data containing the username, password and some more undocumented | 20 // Encrypted data containing the username, password and some more undocumented |
21 // fields. | 21 // fields. |
22 std::vector<unsigned char> encrypted_data; | 22 std::vector<unsigned char> encrypted_data; |
23 | 23 |
24 // When the login was imported. | 24 // When the login was imported. |
25 base::Time date_created; | 25 base::Time date_created; |
26 }; | 26 }; |
27 | 27 |
28 namespace ie7_password { | 28 namespace ie7_password { |
29 | 29 |
30 // Parses a data structure to find the password and the username. | 30 struct DecryptedCredentials { |
| 31 std::wstring username; |
| 32 std::wstring password; |
| 33 }; |
| 34 |
| 35 // Parses a data structure to find passwords and usernames. |
| 36 // The collection of bytes in |data| is interpreted as a special PasswordEntry |
| 37 // structure. IE saves the login information as a binary dump of this structure. |
| 38 // Credentials extracted from |data| end up in |credentials|. |
31 bool GetUserPassFromData(const std::vector<unsigned char>& data, | 39 bool GetUserPassFromData(const std::vector<unsigned char>& data, |
32 std::wstring* username, | 40 std::vector<DecryptedCredentials>* credentials); |
33 std::wstring* password); | |
34 | 41 |
35 // Decrypts the username and password for a given data vector using the url as | 42 // Decrypts usernames and passwords for a given data vector using the url as |
36 // the key. | 43 // the key. |
37 bool DecryptPassword(const std::wstring& url, | 44 // Output ends up in |credentials|. |
38 const std::vector<unsigned char>& data, | 45 bool DecryptPasswords(const std::wstring& url, |
39 std::wstring* username, std::wstring* password); | 46 const std::vector<unsigned char>& data, |
| 47 std::vector<DecryptedCredentials>* credentials); |
40 | 48 |
41 // Returns the hash of a url. | 49 // Returns the hash of a url. |
42 std::wstring GetUrlHash(const std::wstring& url); | 50 std::wstring GetUrlHash(const std::wstring& url); |
43 | 51 |
44 } // namespace ie7_password | 52 } // namespace ie7_password |
45 | 53 |
46 #endif // COMPONENTS_WEBDATA_ENCRYPTOR_IE7_PASSWORD_H_ | 54 #endif // COMPONENTS_WEBDATA_ENCRYPTOR_IE7_PASSWORD_H_ |
OLD | NEW |