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

Side by Side Diff: components/os_crypt/ie7_password_win.cc

Issue 1279123004: Replace ToLower calls to the new format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 c.username = reinterpret_cast<const wchar_t*>(offset_to_data + 88 c.username = reinterpret_cast<const wchar_t*>(offset_to_data +
89 user_entry->offset); 89 user_entry->offset);
90 c.password = reinterpret_cast<const wchar_t*>(offset_to_data + 90 c.password = reinterpret_cast<const wchar_t*>(offset_to_data +
91 pass_entry->offset); 91 pass_entry->offset);
92 credentials->push_back(c); 92 credentials->push_back(c);
93 } 93 }
94 return true; 94 return true;
95 } 95 }
96 96
97 std::wstring GetUrlHash(const std::wstring& url) { 97 std::wstring GetUrlHash(const std::wstring& url) {
98 std::wstring lower_case_url = base::StringToLowerASCII(url); 98 std::wstring lower_case_url = base::ToLowerASCII(url);
99 // Get a data buffer out of our std::wstring to pass to SHA1HashString. 99 // Get a data buffer out of our std::wstring to pass to SHA1HashString.
100 std::string url_buffer( 100 std::string url_buffer(
101 reinterpret_cast<const char*>(lower_case_url.c_str()), 101 reinterpret_cast<const char*>(lower_case_url.c_str()),
102 (lower_case_url.size() + 1) * sizeof(wchar_t)); 102 (lower_case_url.size() + 1) * sizeof(wchar_t));
103 std::string hash_bin = base::SHA1HashString(url_buffer); 103 std::string hash_bin = base::SHA1HashString(url_buffer);
104 104
105 std::wstring url_hash; 105 std::wstring url_hash;
106 106
107 // Transform the buffer to an hexadecimal string. 107 // Transform the buffer to an hexadecimal string.
108 unsigned char checksum = 0; 108 unsigned char checksum = 0;
109 for (size_t i = 0; i < hash_bin.size(); ++i) { 109 for (size_t i = 0; i < hash_bin.size(); ++i) {
110 // std::string gives signed chars, which mess with StringPrintf and 110 // std::string gives signed chars, which mess with StringPrintf and
111 // check_sum. 111 // check_sum.
112 unsigned char hash_byte = static_cast<unsigned char>(hash_bin[i]); 112 unsigned char hash_byte = static_cast<unsigned char>(hash_bin[i]);
113 checksum += hash_byte; 113 checksum += hash_byte;
114 url_hash += base::StringPrintf(L"%2.2X", static_cast<unsigned>(hash_byte)); 114 url_hash += base::StringPrintf(L"%2.2X", static_cast<unsigned>(hash_byte));
115 } 115 }
116 url_hash += base::StringPrintf(L"%2.2X", checksum); 116 url_hash += base::StringPrintf(L"%2.2X", checksum);
117 117
118 return url_hash; 118 return url_hash;
119 } 119 }
120 120
121 bool DecryptPasswords(const std::wstring& url, 121 bool DecryptPasswords(const std::wstring& url,
122 const std::vector<unsigned char>& data, 122 const std::vector<unsigned char>& data,
123 std::vector<DecryptedCredentials>* credentials) { 123 std::vector<DecryptedCredentials>* credentials) {
124 std::wstring lower_case_url = base::StringToLowerASCII(url); 124 std::wstring lower_case_url = base::ToLowerASCII(url);
125 DATA_BLOB input = {0}; 125 DATA_BLOB input = {0};
126 DATA_BLOB output = {0}; 126 DATA_BLOB output = {0};
127 DATA_BLOB url_key = {0}; 127 DATA_BLOB url_key = {0};
128 128
129 input.pbData = const_cast<unsigned char*>(&data.front()); 129 input.pbData = const_cast<unsigned char*>(&data.front());
130 input.cbData = static_cast<DWORD>((data.size()) * 130 input.cbData = static_cast<DWORD>((data.size()) *
131 sizeof(std::string::value_type)); 131 sizeof(std::string::value_type));
132 132
133 url_key.pbData = reinterpret_cast<unsigned char*>( 133 url_key.pbData = reinterpret_cast<unsigned char*>(
134 const_cast<wchar_t*>(lower_case_url.data())); 134 const_cast<wchar_t*>(lower_case_url.data()));
(...skipping 10 matching lines...) Expand all
145 GetUserPassFromData(decrypted_data, credentials); 145 GetUserPassFromData(decrypted_data, credentials);
146 146
147 LocalFree(output.pbData); 147 LocalFree(output.pbData);
148 return true; 148 return true;
149 } 149 }
150 150
151 return false; 151 return false;
152 } 152 }
153 153
154 } // namespace ie7_password 154 } // namespace ie7_password
OLDNEW
« no previous file with comments | « components/nacl/renderer/ppb_nacl_private_impl.cc ('k') | components/plugins/renderer/mobile_youtube_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698