Commit 4f4a9412 authored by osm0sis's avatar osm0sis Committed by John Wu

SignBoot: updates from AOSP for boot_img_hdr_v1 and v2

"Allow recovery-dtbo in recovery.img to be signed" by Hridya Valsaraju:
https://android.googlesource.com/platform/system/extras/+/9bb9f8f857170c5865944bdc9e4700a73a6e7434

"boot_signer should support boot header version 2" by Hridya Valsaraju
https://android.googlesource.com/platform/system/extras/+/590e58454d25218bc295cf0fbdc241b0d1b8ae8e
parent a92e0393
...@@ -162,6 +162,24 @@ public class SignBoot { ...@@ -162,6 +162,24 @@ public class SignBoot {
+ ((kernelSize + pageSize - 1) / pageSize) * pageSize + ((kernelSize + pageSize - 1) / pageSize) * pageSize
+ ((ramdskSize + pageSize - 1) / pageSize) * pageSize + ((ramdskSize + pageSize - 1) / pageSize) * pageSize
+ ((secondSize + 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
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");
}
}
length = ((length + pageSize - 1) / pageSize) * pageSize; length = ((length + pageSize - 1) / pageSize) * pageSize;
if (length <= 0) { if (length <= 0) {
throw new IllegalArgumentException("Invalid image header: invalid length"); throw new IllegalArgumentException("Invalid image header: invalid length");
...@@ -178,6 +196,8 @@ public class SignBoot { ...@@ -178,6 +196,8 @@ public class SignBoot {
private DEROctetString signature; private DEROctetString signature;
private PublicKey publicKey; private PublicKey publicKey;
private static final int FORMAT_VERSION = 1; private static final int FORMAT_VERSION = 1;
private static final int BOOT_IMAGE_HEADER_V1_RECOVERY_DTBO_SIZE_OFFSET = 1632;
private static final int BOOT_IMAGE_HEADER_V2_DTB_SIZE_OFFSET = 1648;
/** /**
* Initializes the object for signing an image file * Initializes the object for signing an image file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment