From 516c441fd89bf4dc8a40bbf0ed8faaf1f9a404b7 Mon Sep 17 00:00:00 2001 From: Yurii Zubrytskyi Date: Wed, 19 Feb 2020 14:46:16 -0800 Subject: [PATCH] [adb] Add a version field to v4 signature format Test: manual Change-Id: I8a1034d7131905463749d5b131dd9a3c8703fe96 --- adb/client/incremental.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/adb/client/incremental.cpp b/adb/client/incremental.cpp index cffd4bd0b..b728a6bb3 100644 --- a/adb/client/incremental.cpp +++ b/adb/client/incremental.cpp @@ -54,6 +54,13 @@ static inline int32_t read_be_int32(borrowed_fd fd) { return int32_t(be32toh(read_int32(fd))); } +static inline void append_int(borrowed_fd fd, std::vector* bytes) { + int32_t be_val = read_int32(fd); + auto old_size = bytes->size(); + bytes->resize(old_size + sizeof(be_val)); + memcpy(bytes->data() + old_size, &be_val, sizeof(be_val)); +} + static inline void append_bytes_with_size(borrowed_fd fd, std::vector* bytes) { int32_t be_size = read_int32(fd); int32_t size = int32_t(be32toh(be_size)); @@ -65,6 +72,7 @@ static inline void append_bytes_with_size(borrowed_fd fd, std::vector* byt static inline std::pair, int32_t> read_id_sig_headers(borrowed_fd fd) { std::vector result; + append_int(fd, &result); // version append_bytes_with_size(fd, &result); // verityRootHash append_bytes_with_size(fd, &result); // v3Digest append_bytes_with_size(fd, &result); // pkcs7SignatureBlock