| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extension_creator.h" | 5 #include "chrome/browser/extensions/extension_creator.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 return false; | 204 return false; |
| 205 } | 205 } |
| 206 | 206 |
| 207 return true; | 207 return true; |
| 208 } | 208 } |
| 209 | 209 |
| 210 bool ExtensionCreator::SignZip(const base::FilePath& zip_path, | 210 bool ExtensionCreator::SignZip(const base::FilePath& zip_path, |
| 211 crypto::RSAPrivateKey* private_key, | 211 crypto::RSAPrivateKey* private_key, |
| 212 std::vector<uint8>* signature) { | 212 std::vector<uint8>* signature) { |
| 213 scoped_ptr<crypto::SignatureCreator> signature_creator( | 213 scoped_ptr<crypto::SignatureCreator> signature_creator( |
| 214 crypto::SignatureCreator::Create(private_key)); | 214 crypto::SignatureCreator::Create(private_key, |
| 215 crypto::SignatureCreator::SHA1)); |
| 215 base::ScopedFILE zip_handle(base::OpenFile(zip_path, "rb")); | 216 base::ScopedFILE zip_handle(base::OpenFile(zip_path, "rb")); |
| 216 size_t buffer_size = 1 << 16; | 217 size_t buffer_size = 1 << 16; |
| 217 scoped_ptr<uint8[]> buffer(new uint8[buffer_size]); | 218 scoped_ptr<uint8[]> buffer(new uint8[buffer_size]); |
| 218 int bytes_read = -1; | 219 int bytes_read = -1; |
| 219 while ((bytes_read = fread(buffer.get(), 1, buffer_size, | 220 while ((bytes_read = fread(buffer.get(), 1, buffer_size, |
| 220 zip_handle.get())) > 0) { | 221 zip_handle.get())) > 0) { |
| 221 if (!signature_creator->Update(buffer.get(), bytes_read)) { | 222 if (!signature_creator->Update(buffer.get(), bytes_read)) { |
| 222 error_message_ = | 223 error_message_ = |
| 223 l10n_util::GetStringUTF8(IDS_EXTENSION_ERROR_WHILE_SIGNING); | 224 l10n_util::GetStringUTF8(IDS_EXTENSION_ERROR_WHILE_SIGNING); |
| 224 return false; | 225 return false; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 SignZip(zip_path, key_pair.get(), &signature) && | 323 SignZip(zip_path, key_pair.get(), &signature) && |
| 323 WriteCRX(zip_path, key_pair.get(), signature, crx_path)) { | 324 WriteCRX(zip_path, key_pair.get(), signature, crx_path)) { |
| 324 result = true; | 325 result = true; |
| 325 } | 326 } |
| 326 | 327 |
| 327 base::DeleteFile(zip_path, false); | 328 base::DeleteFile(zip_path, false); |
| 328 return result; | 329 return result; |
| 329 } | 330 } |
| 330 | 331 |
| 331 } // namespace extensions | 332 } // namespace extensions |
| OLD | NEW |