OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" | |
11 #include "base/file_util.h" | 10 #include "base/file_util.h" |
12 #include "base/file_util_proxy.h" | 11 #include "base/file_util_proxy.h" |
13 #include "base/memory/scoped_handle.h" | 12 #include "base/memory/scoped_handle.h" |
14 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
15 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
16 #include "base/path_service.h" | 15 #include "base/path_service.h" |
17 #include "base/task.h" | 16 #include "base/task.h" |
18 #include "base/utf_string_conversions.h" // TODO(viettrungluu): delete me. | 17 #include "base/utf_string_conversions.h" // TODO(viettrungluu): delete me. |
| 18 #include "crypto/signature_verifier.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
23 #include "chrome/common/extensions/extension_constants.h" | 23 #include "chrome/common/extensions/extension_constants.h" |
24 #include "chrome/common/extensions/extension_file_util.h" | 24 #include "chrome/common/extensions/extension_file_util.h" |
25 #include "chrome/common/extensions/extension_l10n_util.h" | 25 #include "chrome/common/extensions/extension_l10n_util.h" |
26 #include "chrome/common/extensions/extension_unpacker.h" | 26 #include "chrome/common/extensions/extension_unpacker.h" |
27 #include "chrome/common/json_value_serializer.h" | 27 #include "chrome/common/json_value_serializer.h" |
28 #include "content/browser/browser_thread.h" | 28 #include "content/browser/browser_thread.h" |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 if (len < header.signature_size) { | 324 if (len < header.signature_size) { |
325 // Invalid signature | 325 // Invalid signature |
326 ReportFailure( | 326 ReportFailure( |
327 CRX_SIGNATURE_INVALID, | 327 CRX_SIGNATURE_INVALID, |
328 l10n_util::GetStringFUTF8( | 328 l10n_util::GetStringFUTF8( |
329 IDS_EXTENSION_PACKAGE_ERROR_CODE, | 329 IDS_EXTENSION_PACKAGE_ERROR_CODE, |
330 ASCIIToUTF16("CRX_SIGNATURE_INVALID"))); | 330 ASCIIToUTF16("CRX_SIGNATURE_INVALID"))); |
331 return false; | 331 return false; |
332 } | 332 } |
333 | 333 |
334 base::SignatureVerifier verifier; | 334 crypto::SignatureVerifier verifier; |
335 if (!verifier.VerifyInit(extension_misc::kSignatureAlgorithm, | 335 if (!verifier.VerifyInit(extension_misc::kSignatureAlgorithm, |
336 sizeof(extension_misc::kSignatureAlgorithm), | 336 sizeof(extension_misc::kSignatureAlgorithm), |
337 &signature.front(), | 337 &signature.front(), |
338 signature.size(), | 338 signature.size(), |
339 &key.front(), | 339 &key.front(), |
340 key.size())) { | 340 key.size())) { |
341 // Signature verification initialization failed. This is most likely | 341 // Signature verification initialization failed. This is most likely |
342 // caused by a public key in the wrong format (should encode algorithm). | 342 // caused by a public key in the wrong format (should encode algorithm). |
343 ReportFailure( | 343 ReportFailure( |
344 CRX_SIGNATURE_VERIFICATION_INITIALIZATION_FAILED, | 344 CRX_SIGNATURE_VERIFICATION_INITIALIZATION_FAILED, |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 ERROR_SAVING_CATALOG, | 581 ERROR_SAVING_CATALOG, |
582 l10n_util::GetStringFUTF8( | 582 l10n_util::GetStringFUTF8( |
583 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, | 583 IDS_EXTENSION_PACKAGE_INSTALL_ERROR, |
584 ASCIIToUTF16("ERROR_SAVING_CATALOG"))); | 584 ASCIIToUTF16("ERROR_SAVING_CATALOG"))); |
585 return false; | 585 return false; |
586 } | 586 } |
587 } | 587 } |
588 | 588 |
589 return true; | 589 return true; |
590 } | 590 } |
OLD | NEW |