OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/os_crypt/ie7_password_win.h" | 5 #include "components/os_crypt/ie7_password_win.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/sha1.h" | 13 #include "base/sha1.h" |
15 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
16 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
17 #include "crypto/wincrypt_shim.h" | 16 #include "crypto/wincrypt_shim.h" |
18 | 17 |
19 namespace { | 18 namespace { |
20 | 19 |
21 // Structures that IE7/IE8 use to store a username/password. | 20 // Structures that IE7/IE8 use to store a username/password. |
22 // Some of the fields might have been incorrectly reverse engineered. | 21 // Some of the fields might have been incorrectly reverse engineered. |
23 struct PreHeader { | 22 struct PreHeader { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 return false; | 75 return false; |
77 | 76 |
78 if (information->header.fixed_header_size != sizeof(Header)) | 77 if (information->header.fixed_header_size != sizeof(Header)) |
79 return false; | 78 return false; |
80 | 79 |
81 const uint8_t* offset_to_data = &data[0] + | 80 const uint8_t* offset_to_data = &data[0] + |
82 information->pre_header.header_size + | 81 information->pre_header.header_size + |
83 information->pre_header.pre_header_size; | 82 information->pre_header.pre_header_size; |
84 | 83 |
85 for (int i = 0; i < entry_count / 2; ++i) { | 84 for (int i = 0; i < entry_count / 2; ++i) { |
86 | |
87 const Entry* user_entry = &information->entry[2*i]; | 85 const Entry* user_entry = &information->entry[2*i]; |
88 const Entry* pass_entry = user_entry+1; | 86 const Entry* pass_entry = user_entry+1; |
89 | 87 |
90 DecryptedCredentials c; | 88 DecryptedCredentials c; |
91 c.username = reinterpret_cast<const wchar_t*>(offset_to_data + | 89 c.username = reinterpret_cast<const wchar_t*>(offset_to_data + |
92 user_entry->offset); | 90 user_entry->offset); |
93 c.password = reinterpret_cast<const wchar_t*>(offset_to_data + | 91 c.password = reinterpret_cast<const wchar_t*>(offset_to_data + |
94 pass_entry->offset); | 92 pass_entry->offset); |
95 credentials->push_back(c); | 93 credentials->push_back(c); |
96 } | 94 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 GetUserPassFromData(decrypted_data, credentials); | 146 GetUserPassFromData(decrypted_data, credentials); |
149 | 147 |
150 LocalFree(output.pbData); | 148 LocalFree(output.pbData); |
151 return true; | 149 return true; |
152 } | 150 } |
153 | 151 |
154 return false; | 152 return false; |
155 } | 153 } |
156 | 154 |
157 } // namespace ie7_password | 155 } // namespace ie7_password |
OLD | NEW |