summaryrefslogtreecommitdiff
path: root/verity
diff options
context:
space:
mode:
authorHridya Valsaraju <hridya@google.com>2019-01-24 18:38:07 -0800
committerHridya Valsaraju <hridya@google.com>2019-01-24 22:12:19 -0800
commit590e58454d25218bc295cf0fbdc241b0d1b8ae8e (patch)
treeebec95e0d438faa1213de3b86368cb499154a94b /verity
parente3ee735617969aef7c29a544e512b26591252ef0 (diff)
downloadextras-590e58454d25218bc295cf0fbdc241b0d1b8ae8e.tar.gz
boot_signer should support boot header version 2
Boot Image header version two modifies the boot image format to include DTB. Test: make Bug: 111136242 Change-Id: Icfc1fce695d0e19ff15a1d74afd00b9b88cccf7e
Diffstat (limited to 'verity')
-rw-r--r--verity/BootSignature.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/verity/BootSignature.java b/verity/BootSignature.java
index 10171c31..28864cee 100644
--- a/verity/BootSignature.java
+++ b/verity/BootSignature.java
@@ -77,6 +77,12 @@ public class BootSignature extends ASN1Object
* or equal to 1.
*/
private static final int BOOT_IMAGE_HEADER_V1_RECOVERY_DTBO_SIZE_OFFSET = 1632;
+ /**
+ * Offset of DTB length in a boot image header of version greater than
+ * or equal to 2.
+ */
+ private static final int BOOT_IMAGE_HEADER_V2_DTB_SIZE_OFFSET = 1648;
+
/**
* Initializes the object for signing an image file
@@ -221,12 +227,16 @@ public class BootSignature extends ASN1Object
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");
- }
+ int headerSize = image.getInt();
+ if (headerVersion == 2) {
+ image.position(BOOT_IMAGE_HEADER_V2_DTB_SIZE_OFFSET);
+ int dtbLength = image.getInt();
+ length += ((dtbLength + pageSize - 1) / pageSize) * pageSize;
+ image.getLong(); // dtb address
+ }
+ if (image.position() != headerSize) {
+ throw new IllegalArgumentException(
+ "Invalid image header: invalid header length");
}
}