summaryrefslogtreecommitdiff
path: root/verity
diff options
context:
space:
mode:
authorHridya Valsaraju <hridya@google.com>2018-03-23 16:01:03 -0700
committerHridya Valsaraju <hridya@google.com>2018-03-28 11:37:58 -0700
commit9bb9f8f857170c5865944bdc9e4700a73a6e7434 (patch)
tree0cae75b03879c89184703e5c296b6cbc872f6c51 /verity
parent81ed0ea0e64d536287e823431f4999f183cc3cf1 (diff)
downloadextras-9bb9f8f857170c5865944bdc9e4700a73a6e7434.tar.gz
Allow recovery-dtbo in recovery.img to be signed
Non-A/B devices need to include the DTBO image within the recovery partition to be self-sufficient and prevent OTA failures. The CL includes the size of recovery DTBO in the size of the boot image to be signed to prevent image truncation. Test: Verified that recovery.img was not getting truncated. Bug: 74763691 Change-Id: Id56928129dfea167e2451aa5f4609fef77e00ff4
Diffstat (limited to 'verity')
-rw-r--r--verity/BootSignature.java21
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) {