diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-03-29 23:51:09 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-03-29 23:51:09 +0000 |
commit | bc7aa28c0f156f2221b26665e2b9e9c941abc081 (patch) | |
tree | 1b686a2891e20e58db7b57a9065d61ff53630b77 | |
parent | c2f4a88c5ad4310b39864d31756ee8bfb621576c (diff) | |
parent | a8bca119c28824ebb5ebc0bc688c3c20886ec10f (diff) | |
download | extras-bc7aa28c0f156f2221b26665e2b9e9c941abc081.tar.gz |
Merge "Allow recovery-dtbo in recovery.img to be signed" into pi-dev
-rw-r--r-- | verity/BootSignature.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/verity/BootSignature.java b/verity/BootSignature.java index 3cf94990..10171c31 100644 --- a/verity/BootSignature.java +++ b/verity/BootSignature.java @@ -72,6 +72,11 @@ public class BootSignature extends ASN1Object private PublicKey publicKey; private static final int FORMAT_VERSION = 1; + /** + * Offset of recovery DTBO length in a boot image header of version greater than + * or equal to 1. + */ + private static final int BOOT_IMAGE_HEADER_V1_RECOVERY_DTBO_SIZE_OFFSET = 1632; /** * Initializes the object for signing an image file @@ -209,6 +214,22 @@ public class BootSignature extends ASN1Object + ((ramdskSize + pageSize - 1) / pageSize) * pageSize + ((secondSize + pageSize - 1) / pageSize) * pageSize; + int headerVersion = image.getInt(); // boot image header version + if (headerVersion > 0) { + image.position(BOOT_IMAGE_HEADER_V1_RECOVERY_DTBO_SIZE_OFFSET); + int recoveryDtboLength = image.getInt(); + length += ((recoveryDtboLength + pageSize - 1) / pageSize) * pageSize; + + image.getLong(); // recovery_dtbo address + if (headerVersion == 1) { + int headerSize = image.getInt(); + if (image.position() != headerSize) { + throw new IllegalArgumentException( + "Invalid image header: invalid header length"); + } + } + } + length = ((length + pageSize - 1) / pageSize) * pageSize; if (length <= 0) { |