| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/install_signer.h" | 5 #include "chrome/browser/extensions/install_signer.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/process/process_info.h" | 15 #include "base/process/process_info.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 22 #include "base/values.h" | 22 #include "base/values.h" |
| 23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 24 #include "components/crx_file/constants.h" |
| 24 #include "crypto/random.h" | 25 #include "crypto/random.h" |
| 25 #include "crypto/secure_hash.h" | 26 #include "crypto/secure_hash.h" |
| 26 #include "crypto/sha2.h" | 27 #include "crypto/sha2.h" |
| 27 #include "crypto/signature_verifier.h" | 28 #include "crypto/signature_verifier.h" |
| 28 #include "extensions/common/constants.h" | |
| 29 #include "net/url_request/url_fetcher.h" | 29 #include "net/url_request/url_fetcher.h" |
| 30 #include "net/url_request/url_fetcher_delegate.h" | 30 #include "net/url_request/url_fetcher_delegate.h" |
| 31 #include "net/url_request/url_request_context_getter.h" | 31 #include "net/url_request/url_request_context_getter.h" |
| 32 #include "net/url_request/url_request_status.h" | 32 #include "net/url_request/url_request_status.h" |
| 33 #include "url/gurl.h" | 33 #include "url/gurl.h" |
| 34 | 34 |
| 35 #if defined(ENABLE_RLZ) | 35 #if defined(ENABLE_RLZ) |
| 36 #include "rlz/lib/machine_id.h" | 36 #include "rlz/lib/machine_id.h" |
| 37 #endif | 37 #endif |
| 38 | 38 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 return false; | 246 return false; |
| 247 signed_data.append(hash_base64); | 247 signed_data.append(hash_base64); |
| 248 | 248 |
| 249 signed_data.append(signature.expire_date); | 249 signed_data.append(signature.expire_date); |
| 250 | 250 |
| 251 std::string public_key; | 251 std::string public_key; |
| 252 if (!Extension::ParsePEMKeyBytes(kPublicKeyPEM, &public_key)) | 252 if (!Extension::ParsePEMKeyBytes(kPublicKeyPEM, &public_key)) |
| 253 return false; | 253 return false; |
| 254 | 254 |
| 255 crypto::SignatureVerifier verifier; | 255 crypto::SignatureVerifier verifier; |
| 256 if (!verifier.VerifyInit(extension_misc::kSignatureAlgorithm, | 256 if (!verifier.VerifyInit(crx_file::kSignatureAlgorithm, |
| 257 sizeof(extension_misc::kSignatureAlgorithm), | 257 sizeof(crx_file::kSignatureAlgorithm), |
| 258 reinterpret_cast<const uint8*>( | 258 reinterpret_cast<const uint8*>( |
| 259 signature.signature.data()), | 259 signature.signature.data()), |
| 260 signature.signature.size(), | 260 signature.signature.size(), |
| 261 reinterpret_cast<const uint8*>(public_key.data()), | 261 reinterpret_cast<const uint8*>(public_key.data()), |
| 262 public_key.size())) | 262 public_key.size())) |
| 263 return false; | 263 return false; |
| 264 | 264 |
| 265 verifier.VerifyUpdate(reinterpret_cast<const uint8*>(signed_data.data()), | 265 verifier.VerifyUpdate(reinterpret_cast<const uint8*>(signed_data.data()), |
| 266 signed_data.size()); | 266 signed_data.size()); |
| 267 return verifier.VerifyFinal(); | 267 return verifier.VerifyFinal(); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 if (!verified) | 501 if (!verified) |
| 502 result.reset(); | 502 result.reset(); |
| 503 } | 503 } |
| 504 | 504 |
| 505 if (!callback_.is_null()) | 505 if (!callback_.is_null()) |
| 506 callback_.Run(result.Pass()); | 506 callback_.Run(result.Pass()); |
| 507 } | 507 } |
| 508 | 508 |
| 509 | 509 |
| 510 } // namespace extensions | 510 } // namespace extensions |
| OLD | NEW |