Implement VerifyPayloadApplicable.
Parse the payload metadata and validate the source hash of all operations.
Return false if any error occur or hash mismatch.
Bug: 65283633
Test: mma
Change-Id: I6f5ae3cb69f4de973cecd0e3d7b733a48b2462f1
(cherry picked from commit 8371c1c852eae461043d8a3d911394a0ec0db909)
diff --git a/payload_consumer/delta_performer.h b/payload_consumer/delta_performer.h
index 55a19d8..b156e2f 100644
--- a/payload_consumer/delta_performer.h
+++ b/payload_consumer/delta_performer.h
@@ -165,6 +165,14 @@
// it returns that value, otherwise it returns the default value.
uint32_t GetMinorVersion() const;
+ // Compare |calculated_hash| with source hash in |operation|, return false and
+ // dump hash and set |error| if don't match.
+ // |source_fd| is the file descriptor of the source partition.
+ static bool ValidateSourceHash(const brillo::Blob& calculated_hash,
+ const InstallOperation& operation,
+ const FileDescriptorPtr source_fd,
+ ErrorCode* error);
+
private:
friend class DeltaPerformerTest;
friend class DeltaPerformerIntegrationTest;