| 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 "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/files/file_util.h" | 8 #include "base/files/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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 std::string root_hash; | 180 std::string root_hash; |
| 181 if (!data->GetString(kPathKey, &file_path_string) || | 181 if (!data->GetString(kPathKey, &file_path_string) || |
| 182 !base::IsStringUTF8(file_path_string) || | 182 !base::IsStringUTF8(file_path_string) || |
| 183 !data->GetString(kRootHashKey, &encoded_root_hash) || | 183 !data->GetString(kRootHashKey, &encoded_root_hash) || |
| 184 !FixupBase64Encoding(&encoded_root_hash) || | 184 !FixupBase64Encoding(&encoded_root_hash) || |
| 185 !base::Base64Decode(encoded_root_hash, &root_hash)) | 185 !base::Base64Decode(encoded_root_hash, &root_hash)) |
| 186 return false; | 186 return false; |
| 187 base::FilePath file_path = | 187 base::FilePath file_path = |
| 188 base::FilePath::FromUTF8Unsafe(file_path_string); | 188 base::FilePath::FromUTF8Unsafe(file_path_string); |
| 189 RootHashes::iterator i = root_hashes_.insert(std::make_pair( | 189 RootHashes::iterator i = root_hashes_.insert(std::make_pair( |
| 190 base::StringToLowerASCII(file_path.value()), std::string())); | 190 base::ToLowerASCII(file_path.value()), std::string())); |
| 191 i->second.swap(root_hash); | 191 i->second.swap(root_hash); |
| 192 } | 192 } |
| 193 | 193 |
| 194 break; | 194 break; |
| 195 } | 195 } |
| 196 return true; | 196 return true; |
| 197 } | 197 } |
| 198 | 198 |
| 199 bool VerifiedContents::HasTreeHashRoot( | 199 bool VerifiedContents::HasTreeHashRoot( |
| 200 const base::FilePath& relative_path) const { | 200 const base::FilePath& relative_path) const { |
| 201 base::FilePath::StringType path = base::StringToLowerASCII( | 201 base::FilePath::StringType path = base::ToLowerASCII( |
| 202 relative_path.NormalizePathSeparatorsTo('/').value()); | 202 relative_path.NormalizePathSeparatorsTo('/').value()); |
| 203 return root_hashes_.find(path) != root_hashes_.end(); | 203 return root_hashes_.find(path) != root_hashes_.end(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 bool VerifiedContents::TreeHashRootEquals(const base::FilePath& relative_path, | 206 bool VerifiedContents::TreeHashRootEquals(const base::FilePath& relative_path, |
| 207 const std::string& expected) const { | 207 const std::string& expected) const { |
| 208 base::FilePath::StringType path = base::StringToLowerASCII( | 208 base::FilePath::StringType path = base::ToLowerASCII( |
| 209 relative_path.NormalizePathSeparatorsTo('/').value()); | 209 relative_path.NormalizePathSeparatorsTo('/').value()); |
| 210 for (RootHashes::const_iterator i = root_hashes_.find(path); | 210 for (RootHashes::const_iterator i = root_hashes_.find(path); |
| 211 i != root_hashes_.end(); | 211 i != root_hashes_.end(); |
| 212 ++i) { | 212 ++i) { |
| 213 if (expected == i->second) | 213 if (expected == i->second) |
| 214 return true; | 214 return true; |
| 215 } | 215 } |
| 216 return false; | 216 return false; |
| 217 } | 217 } |
| 218 | 218 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 reinterpret_cast<const uint8*>(payload.data()), payload.size()); | 348 reinterpret_cast<const uint8*>(payload.data()), payload.size()); |
| 349 | 349 |
| 350 if (!signature_verifier.VerifyFinal()) { | 350 if (!signature_verifier.VerifyFinal()) { |
| 351 VLOG(1) << "Could not verify signature - VerifyFinal failure"; | 351 VLOG(1) << "Could not verify signature - VerifyFinal failure"; |
| 352 return false; | 352 return false; |
| 353 } | 353 } |
| 354 return true; | 354 return true; |
| 355 } | 355 } |
| 356 | 356 |
| 357 } // namespace extensions | 357 } // namespace extensions |
| OLD | NEW |