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

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

Issue 448853002: Move StringToLowerASCII to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 <wincrypt.h> 7 #include <wincrypt.h>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 c.username = reinterpret_cast<const wchar_t*>(offset_to_data + 82 c.username = reinterpret_cast<const wchar_t*>(offset_to_data +
83 user_entry->offset); 83 user_entry->offset);
84 c.password = reinterpret_cast<const wchar_t*>(offset_to_data + 84 c.password = reinterpret_cast<const wchar_t*>(offset_to_data +
85 pass_entry->offset); 85 pass_entry->offset);
86 credentials->push_back(c); 86 credentials->push_back(c);
87 } 87 }
88 return true; 88 return true;
89 } 89 }
90 90
91 std::wstring GetUrlHash(const std::wstring& url) { 91 std::wstring GetUrlHash(const std::wstring& url) {
92 std::wstring lower_case_url = StringToLowerASCII(url); 92 std::wstring lower_case_url = base::StringToLowerASCII(url);
93 // Get a data buffer out of our std::wstring to pass to SHA1HashString. 93 // Get a data buffer out of our std::wstring to pass to SHA1HashString.
94 std::string url_buffer( 94 std::string url_buffer(
95 reinterpret_cast<const char*>(lower_case_url.c_str()), 95 reinterpret_cast<const char*>(lower_case_url.c_str()),
96 (lower_case_url.size() + 1) * sizeof(wchar_t)); 96 (lower_case_url.size() + 1) * sizeof(wchar_t));
97 std::string hash_bin = base::SHA1HashString(url_buffer); 97 std::string hash_bin = base::SHA1HashString(url_buffer);
98 98
99 std::wstring url_hash; 99 std::wstring url_hash;
100 100
101 // Transform the buffer to an hexadecimal string. 101 // Transform the buffer to an hexadecimal string.
102 unsigned char checksum = 0; 102 unsigned char checksum = 0;
103 for (size_t i = 0; i < hash_bin.size(); ++i) { 103 for (size_t i = 0; i < hash_bin.size(); ++i) {
104 // std::string gives signed chars, which mess with StringPrintf and 104 // std::string gives signed chars, which mess with StringPrintf and
105 // check_sum. 105 // check_sum.
106 unsigned char hash_byte = static_cast<unsigned char>(hash_bin[i]); 106 unsigned char hash_byte = static_cast<unsigned char>(hash_bin[i]);
107 checksum += hash_byte; 107 checksum += hash_byte;
108 url_hash += base::StringPrintf(L"%2.2X", static_cast<unsigned>(hash_byte)); 108 url_hash += base::StringPrintf(L"%2.2X", static_cast<unsigned>(hash_byte));
109 } 109 }
110 url_hash += base::StringPrintf(L"%2.2X", checksum); 110 url_hash += base::StringPrintf(L"%2.2X", checksum);
111 111
112 return url_hash; 112 return url_hash;
113 } 113 }
114 114
115 bool DecryptPasswords(const std::wstring& url, 115 bool DecryptPasswords(const std::wstring& url,
116 const std::vector<unsigned char>& data, 116 const std::vector<unsigned char>& data,
117 std::vector<DecryptedCredentials>* credentials) { 117 std::vector<DecryptedCredentials>* credentials) {
118 std::wstring lower_case_url = StringToLowerASCII(url); 118 std::wstring lower_case_url = base::StringToLowerASCII(url);
119 DATA_BLOB input = {0}; 119 DATA_BLOB input = {0};
120 DATA_BLOB output = {0}; 120 DATA_BLOB output = {0};
121 DATA_BLOB url_key = {0}; 121 DATA_BLOB url_key = {0};
122 122
123 input.pbData = const_cast<unsigned char*>(&data.front()); 123 input.pbData = const_cast<unsigned char*>(&data.front());
124 input.cbData = static_cast<DWORD>((data.size()) * 124 input.cbData = static_cast<DWORD>((data.size()) *
125 sizeof(std::string::value_type)); 125 sizeof(std::string::value_type));
126 126
127 url_key.pbData = reinterpret_cast<unsigned char*>( 127 url_key.pbData = reinterpret_cast<unsigned char*>(
128 const_cast<wchar_t*>(lower_case_url.data())); 128 const_cast<wchar_t*>(lower_case_url.data()));
(...skipping 10 matching lines...) Expand all
139 GetUserPassFromData(decrypted_data, credentials); 139 GetUserPassFromData(decrypted_data, credentials);
140 140
141 LocalFree(output.pbData); 141 LocalFree(output.pbData);
142 return true; 142 return true;
143 } 143 }
144 144
145 return false; 145 return false;
146 } 146 }
147 147
148 } // namespace ie7_password 148 } // 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