OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/extensions/sandboxed_extension_unpacker.h" | 5 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/crypto/signature_verifier.h" | 10 #include "base/crypto/signature_verifier.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 if (header.key_size > kMaxPublicKeySize || | 222 if (header.key_size > kMaxPublicKeySize || |
223 header.signature_size > kMaxSignatureSize) { | 223 header.signature_size > kMaxSignatureSize) { |
224 ReportFailure("Excessively large key or signature"); | 224 ReportFailure("Excessively large key or signature"); |
225 return false; | 225 return false; |
226 } | 226 } |
227 if (header.key_size == 0) { | 227 if (header.key_size == 0) { |
228 ReportFailure("Key length is zero"); | 228 ReportFailure("Key length is zero"); |
229 return false; | 229 return false; |
230 } | 230 } |
| 231 if (header.signature_size == 0) { |
| 232 ReportFailure("Signature length is zero"); |
| 233 return false; |
| 234 } |
231 | 235 |
232 std::vector<uint8> key; | 236 std::vector<uint8> key; |
233 key.resize(header.key_size); | 237 key.resize(header.key_size); |
234 len = fread(&key.front(), sizeof(uint8), header.key_size, file.get()); | 238 len = fread(&key.front(), sizeof(uint8), header.key_size, file.get()); |
235 if (len < header.key_size) { | 239 if (len < header.key_size) { |
236 ReportFailure("Invalid public key"); | 240 ReportFailure("Invalid public key"); |
237 return false; | 241 return false; |
238 } | 242 } |
239 | 243 |
240 std::vector<uint8> signature; | 244 std::vector<uint8> signature; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 if (!file_util::WriteFile(path, | 415 if (!file_util::WriteFile(path, |
412 catalog_json.c_str(), | 416 catalog_json.c_str(), |
413 catalog_json.size())) { | 417 catalog_json.size())) { |
414 ReportFailure("Error saving catalog."); | 418 ReportFailure("Error saving catalog."); |
415 return false; | 419 return false; |
416 } | 420 } |
417 } | 421 } |
418 | 422 |
419 return true; | 423 return true; |
420 } | 424 } |
OLD | NEW |