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

Unified Diff: delta_performer.cc

Issue 3599025: AU: Verify that the applied delta update matches the server-sent hashes. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « delta_performer.h ('k') | delta_performer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: delta_performer.cc
diff --git a/delta_performer.cc b/delta_performer.cc
index 3c24d5b9c889c88214631ddbab9313eb3ef7c444..7ee9d4fb20976e0db6a23d178a23e1da6ccf20c8 100644
--- a/delta_performer.cc
+++ b/delta_performer.cc
@@ -545,8 +545,6 @@ bool DeltaPerformer::VerifyPayload(
key_path,
&signed_hash_data));
OmahaHashCalculator signed_hasher;
- // TODO(petkov): Make sure signed_hash_context_ is loaded when resuming an
- // update.
TEST_AND_RETURN_FALSE(signed_hasher.SetContext(signed_hash_context_));
TEST_AND_RETURN_FALSE(signed_hasher.Finalize());
const vector<char>& hash_data = signed_hasher.raw_hash();
@@ -555,6 +553,28 @@ bool DeltaPerformer::VerifyPayload(
return true;
}
+bool DeltaPerformer::VerifyAppliedUpdate(const string& path,
+ const string& kernel_path) {
+ LOG(INFO) << "Verifying applied update.";
+ TEST_AND_RETURN_FALSE(manifest_valid_ &&
+ manifest_.has_new_kernel_info() &&
+ manifest_.has_new_rootfs_info());
+ const string* paths[] = { &kernel_path, &path };
+ const PartitionInfo* infos[] = {
+ &manifest_.new_kernel_info(), &manifest_.new_rootfs_info()
+ };
+ for (size_t i = 0; i < arraysize(paths); ++i) {
+ OmahaHashCalculator hasher;
+ TEST_AND_RETURN_FALSE(hasher.UpdateFile(*paths[i], infos[i]->size()));
+ TEST_AND_RETURN_FALSE(hasher.Finalize());
+ TEST_AND_RETURN_FALSE(hasher.raw_hash().size() == infos[i]->hash().size());
+ TEST_AND_RETURN_FALSE(memcmp(hasher.raw_hash().data(),
+ infos[i]->hash().data(),
+ hasher.raw_hash().size()) == 0);
+ }
+ return true;
+}
+
void DeltaPerformer::DiscardBufferHeadBytes(size_t count) {
hash_calculator_.Update(&buffer_[0], count);
buffer_.erase(buffer_.begin(), buffer_.begin() + count);
« no previous file with comments | « delta_performer.h ('k') | delta_performer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698