mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-27 12:05:30 +00:00
SignBoot: updates from AOSP for boot_img_hdr_v1 and v2
"Allow recovery-dtbo in recovery.img to be signed" by Hridya Valsaraju:9bb9f8f857
"boot_signer should support boot header version 2" by Hridya Valsaraju590e58454d
This commit is contained in:
parent
a92e039363
commit
4f4a9412a3
@ -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 {
|
|||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user