|
|
|
@ -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) {
|
|
|
|
|