From 697e286654b1fa1cdfbb564c0737106e7e982010 Mon Sep 17 00:00:00 2001 From: osm0sis Date: Tue, 6 Jun 2017 13:22:25 -0300 Subject: [PATCH] AK2: add Android Verified Boot (AVB) signature support - add built-in support for BootSignature_Android.jar for AVB signature enforcing devices (see https://forum.xda-developers.com/android/software-hacking/signing-boot-images-android-verified-t3600606) --- tools/ak2-core.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/ak2-core.sh b/tools/ak2-core.sh index e0b7f1c..2c78872 100755 --- a/tools/ak2-core.sh +++ b/tools/ak2-core.sh @@ -189,6 +189,29 @@ write_boot() { fi; mv -f boot-new-signed.img boot-new.img; fi; + if [ -f "$bin/BootSignature_Android.jar" -a -d "$bin/avb" ]; then + if [ -f "/system/system/bin/dalvikvm" ]; then + umount /system; + umount /system; + mkdir /system_root; + mount -o ro -t auto /dev/block/bootdevice/by-name/system$slot /system_root; + mount -o bind /system_root/system /system; + fi; + unset LD_LIBRARY_PATH; + pk8=`ls $bin/avb/*.pk8`; + der=`ls $bin/avb/*.der`; + /system/bin/dalvikvm -Xbootclasspath:/system/framework/core-oj.jar:/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/bouncycastle.jar -Xnodex2oat -Xnoimage-dex2oat -cp BootSignature_Android.jar com.android.verity.BootSignature /boot boot-new.img $pk8 $der boot-new-signed.img; + if [ $? != 0 ]; then + ui_print " "; ui_print "Signing image failed. Aborting..."; exit 1; + fi; + mv -f boot-new-signed.img boot-new.img; + if [ -d "/system_root" ]; then + umount /system; + umount /system_root; + rmdir /system_root; + mount -o ro -t auto /system; + fi; + fi; if [ -f "$bin/blobpack" ]; then printf '-SIGNED-BY-SIGNBLOB-\00\00\00\00\00\00\00\00' > boot-new-signed.img; $bin/blobpack tempblob LNX boot-new.img;