Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: delta_diff_generator.cc

Issue 6265001: AU: Add support for signing of update payloads after they're generated. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: rename function Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « delta_diff_generator.h ('k') | delta_performer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 "update_engine/delta_diff_generator.h" 5 #include "update_engine/delta_diff_generator.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <inttypes.h> 9 #include <inttypes.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 << next_blob_offset; 1419 << next_blob_offset;
1420 } 1420 }
1421 next_blob_offset += op->data_length(); 1421 next_blob_offset += op->data_length();
1422 } 1422 }
1423 } 1423 }
1424 } 1424 }
1425 1425
1426 // Signatures appear at the end of the blobs. Note the offset in the 1426 // Signatures appear at the end of the blobs. Note the offset in the
1427 // manifest 1427 // manifest
1428 if (!private_key_path.empty()) { 1428 if (!private_key_path.empty()) {
1429 LOG(INFO) << "Making room for signature in file";
1430 manifest.set_signatures_offset(next_blob_offset);
1431 LOG(INFO) << "set? " << manifest.has_signatures_offset();
1432 // Add a dummy op at the end to appease older clients
1433 DeltaArchiveManifest_InstallOperation* dummy_op =
1434 manifest.add_kernel_install_operations();
1435 dummy_op->set_type(DeltaArchiveManifest_InstallOperation_Type_REPLACE);
1436 dummy_op->set_data_offset(next_blob_offset);
1437 manifest.set_signatures_offset(next_blob_offset);
1438 uint64_t signature_blob_length = 0; 1429 uint64_t signature_blob_length = 0;
1439 TEST_AND_RETURN_FALSE( 1430 TEST_AND_RETURN_FALSE(
1440 PayloadSigner::SignatureBlobLength(private_key_path, 1431 PayloadSigner::SignatureBlobLength(private_key_path,
1441 &signature_blob_length)); 1432 &signature_blob_length));
1442 dummy_op->set_data_length(signature_blob_length); 1433 AddSignatureOp(next_blob_offset, signature_blob_length, &manifest);
1443 manifest.set_signatures_size(signature_blob_length);
1444 Extent* dummy_extent = dummy_op->add_dst_extents();
1445 // Tell the dummy op to write this data to a big sparse hole
1446 dummy_extent->set_start_block(kSparseHole);
1447 dummy_extent->set_num_blocks((signature_blob_length + kBlockSize - 1) /
1448 kBlockSize);
1449 } 1434 }
1450 1435
1451 TEST_AND_RETURN_FALSE(InitializePartitionInfos(old_kernel_part, 1436 TEST_AND_RETURN_FALSE(InitializePartitionInfos(old_kernel_part,
1452 new_kernel_part, 1437 new_kernel_part,
1453 old_image, 1438 old_image,
1454 new_image, 1439 new_image,
1455 &manifest)); 1440 &manifest));
1456 1441
1457 // Serialize protobuf 1442 // Serialize protobuf
1458 string serialized_manifest; 1443 string serialized_manifest;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 << ") and also " << vertex << "(" 1575 << ") and also " << vertex << "("
1591 << graph[vertex].file_name << ")"; 1576 << graph[vertex].file_name << ")";
1592 } 1577 }
1593 (*blocks)[block].*access_type = vertex; 1578 (*blocks)[block].*access_type = vertex;
1594 } 1579 }
1595 } 1580 }
1596 } 1581 }
1597 return true; 1582 return true;
1598 } 1583 }
1599 1584
1585 void DeltaDiffGenerator::AddSignatureOp(uint64_t signature_blob_offset,
1586 uint64_t signature_blob_length,
1587 DeltaArchiveManifest* manifest) {
1588 LOG(INFO) << "Making room for signature in file";
1589 manifest->set_signatures_offset(signature_blob_offset);
1590 LOG(INFO) << "set? " << manifest->has_signatures_offset();
1591 // Add a dummy op at the end to appease older clients
1592 DeltaArchiveManifest_InstallOperation* dummy_op =
1593 manifest->add_kernel_install_operations();
1594 dummy_op->set_type(DeltaArchiveManifest_InstallOperation_Type_REPLACE);
1595 dummy_op->set_data_offset(signature_blob_offset);
1596 manifest->set_signatures_offset(signature_blob_offset);
1597 dummy_op->set_data_length(signature_blob_length);
1598 manifest->set_signatures_size(signature_blob_length);
1599 Extent* dummy_extent = dummy_op->add_dst_extents();
1600 // Tell the dummy op to write this data to a big sparse hole
1601 dummy_extent->set_start_block(kSparseHole);
1602 dummy_extent->set_num_blocks((signature_blob_length + kBlockSize - 1) /
1603 kBlockSize);
1604 }
1605
1600 const char* const kBsdiffPath = "bsdiff"; 1606 const char* const kBsdiffPath = "bsdiff";
1601 const char* const kBspatchPath = "bspatch"; 1607 const char* const kBspatchPath = "bspatch";
1602 const char* const kDeltaMagic = "CrAU"; 1608 const char* const kDeltaMagic = "CrAU";
1603 1609
1604 }; // namespace chromeos_update_engine 1610 }; // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « delta_diff_generator.h ('k') | delta_performer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698