AU: Verify source rootfs/kernel hashes before applying delta.
New style full updates will not send the old rootfs hash so no check takes
place.
BUG=7562
TEST=unit tests, gmerged on device and tested with good/bad source partition
Change-Id: I65b28bf57110e4d87472d4aea59121878cde24b0
Review URL: http://codereview.chromium.org/3712003
diff --git a/omaha_hash_calculator.cc b/omaha_hash_calculator.cc
index fdc70f0..ac4edf4 100644
--- a/omaha_hash_calculator.cc
+++ b/omaha_hash_calculator.cc
@@ -113,6 +113,20 @@
return true;
}
+off_t OmahaHashCalculator::RawHashOfFile(const std::string& name, off_t length,
+ std::vector<char>* out_hash) {
+ OmahaHashCalculator calc;
+ off_t res = calc.UpdateFile(name, length);
+ if (res < 0) {
+ return res;
+ }
+ if (!calc.Finalize()) {
+ return -1;
+ }
+ *out_hash = calc.raw_hash();
+ return res;
+}
+
string OmahaHashCalculator::OmahaHashOfBytes(
const void* data, size_t length) {
OmahaHashCalculator calc;