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

Side by Side Diff: extensions/browser/verified_contents.cc

Issue 361523002: Fix some more problems with windows paths in content verification (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
« no previous file with comments | « extensions/browser/content_hash_fetcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "extensions/browser/verified_contents.h" 5 #include "extensions/browser/verified_contents.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 std::string encoded_root_hash; 178 std::string encoded_root_hash;
179 std::string root_hash; 179 std::string root_hash;
180 if (!data->GetString(kPathKey, &file_path_string) || 180 if (!data->GetString(kPathKey, &file_path_string) ||
181 !base::IsStringUTF8(file_path_string) || 181 !base::IsStringUTF8(file_path_string) ||
182 !data->GetString(kRootHashKey, &encoded_root_hash) || 182 !data->GetString(kRootHashKey, &encoded_root_hash) ||
183 !FixupBase64Encoding(&encoded_root_hash) || 183 !FixupBase64Encoding(&encoded_root_hash) ||
184 !base::Base64Decode(encoded_root_hash, &root_hash)) 184 !base::Base64Decode(encoded_root_hash, &root_hash))
185 return false; 185 return false;
186 base::FilePath file_path = 186 base::FilePath file_path =
187 base::FilePath::FromUTF8Unsafe(file_path_string); 187 base::FilePath::FromUTF8Unsafe(file_path_string);
188 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
189 file_path = file_path.NormalizePathSeparators();
190 #endif // defined(FILE_PATH_USES_WIN_SEPARATORS)
191 root_hashes_[file_path] = std::string(); 188 root_hashes_[file_path] = std::string();
192 root_hashes_[file_path].swap(root_hash); 189 root_hashes_[file_path].swap(root_hash);
193 } 190 }
194 191
195 break; 192 break;
196 } 193 }
197 return true; 194 return true;
198 } 195 }
199 196
200 const std::string* VerifiedContents::GetTreeHashRoot( 197 const std::string* VerifiedContents::GetTreeHashRoot(
201 const base::FilePath& relative_path) { 198 const base::FilePath& relative_path) {
202 std::map<base::FilePath, std::string>::const_iterator i = 199 std::map<base::FilePath, std::string>::const_iterator i =
203 root_hashes_.find(relative_path); 200 root_hashes_.find(relative_path.NormalizePathSeparatorsTo('/'));
204 if (i == root_hashes_.end()) 201 if (i == root_hashes_.end())
205 return NULL; 202 return NULL;
206 return &i->second; 203 return &i->second;
207 } 204 }
208 205
209 // We're loosely following the "JSON Web Signature" draft spec for signing 206 // We're loosely following the "JSON Web Signature" draft spec for signing
210 // a JSON payload: 207 // a JSON payload:
211 // 208 //
212 // http://tools.ietf.org/html/draft-ietf-jose-json-web-signature-26 209 // http://tools.ietf.org/html/draft-ietf-jose-json-web-signature-26
213 // 210 //
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 reinterpret_cast<const uint8*>(payload.data()), payload.size()); 335 reinterpret_cast<const uint8*>(payload.data()), payload.size());
339 336
340 if (!signature_verifier.VerifyFinal()) { 337 if (!signature_verifier.VerifyFinal()) {
341 VLOG(1) << "Could not verify signature - VerifyFinal failure"; 338 VLOG(1) << "Could not verify signature - VerifyFinal failure";
342 return false; 339 return false;
343 } 340 }
344 return true; 341 return true;
345 } 342 }
346 343
347 } // namespace extensions 344 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/content_hash_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698