Android Verified Boot 2.0

本文由英文所写,英文水平有限,如有错误请联系本作者,谢谢!

Brief

AVB2.0 is used in bootloader, it add an image “vbmeta.img” for this usage. A public Key will be compiled into Bootloader for verify vbmeta data and vbmeta.img include a signature that should be verified by this public key.

The vbmeta.img also include the public key for later verify using, but this key would only be trusted when vbmeta.img is verified by bootloader. This is just like a certification, include trusted public key and a signature.

这里写图片描述
So, we have two important key in AVB, one is the OEM key for vbmeta.img verify and another verity_key for other partition(boot/system/vendor) verify.And of course you can just use your oem key as your verity_key as well.

Bootloader OEM Key (Qcom platform)

  • public key:

1) UserKey - Saved in DevInfo.


bootable/bootloader/edk2/QcomModulePkg/Include/Library/DeviceInfo.h

typedef struct device_info

{

<snip>

UINT32 user_public_key_length;

CHAR8 user_public_key[MAX_USER_KEY_SIZE];

<snip>

}DeviceInfo;

2) OEMKey - Saved in “OEMPublicKey.h” of ABL


bootable\bootloader\edk2\QcomModulePkg\Library\avb\OEMPublicKey.h

/**

* Internal builds use TestKeyRSA4096Public

* OEM should replace this Array with public key used to sign boot.img

* avbtool extract_public_key --key KEY --output OUTPUT

*/

static const char OEMPublicKey[] = {

“avbtool” can extract public key through extract_public_key option, but the private key file is needed to set as an argument:


avbtool extract_public_key --key KEY --output OUTPUT

--key KEY        Path to RSA private key file

--output OUTPUT  Output file name to write public key
 - If the public key in vbmeta partition was matched with UserKey, the BootState would be GREEN.

 - If it was unmatched with UserKey, but matched with OEMKey, the BootState would be YELLOW.

 - If it was unmatched with either of them, the BootState would be RED.
  • private key:

1) Default private key


external/avb/test/data/testkey_rsa4096.pem

2) Customized private key

use “BOARD_AVB_KEY_PATH :=” to define a customized key path.

Other partition Verity Key (Qcom platform)

We have known that the OEM key is used to verify vbmeta.img in bootloader. This is not enough, we must verify other partitions too.The public key that included by vbmeta.img is used for this purpose. Just like the verity_key in avb 1.0, this public key is used to verify system partition, vendor partition and boot partition as well. There are some differences here. “avb 1.0” uses the oem key to verify boot partition, and “/verity_key” to verity system/vendor partition, but “avb 2.0” uses the ome key to verify vbmeta.img, and the public key in it to verify other partition include boot partition.

On Qcom platform the public key in vbmeta.img is the same key as OEM public key, this public key is for later usage, such as boot/system/vendor verify.The bootloader just verify vbmeta.img and boot.img then boot to kernel, other image is verify by init/fs_mgr. We only need to maintain one pair of keys in this solution, I guess this is the reason why qcom do it this way.

Non-A/B system

AVB 1.0:
这里写图片描述

AVB 2.0:

As we have said above, avb 2.0 uses OEM boot key to verify vbmeta.img, and this public key to verify other partition.
Bootloader will verify two partition, one is vbmeta.img, the other is boot.img for booting, system/vendor is verified by init/fs_mgr.

A/B system

AVB 1.0:
这里写图片描述

AVB 2.0:

这里写图片描述

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
My original intent was to have this package dependency-free, but as you can see, I did have to include Cygwin. Initially just for mkbootimg since the huaixzk standalone version wouldn't work (it wasn't loading the kernel as binary, thanks trevd); then I discovered that using the GNUWin32 cpio to unpack somehow didn't play nice with repacking the ramdisk in a usable state, so at that point I decided I might as well go Cygwin across the board. As it is, I've included the latest Cygwin-dependent executables and required libraries from their repos and built my own custom Cygwin image and ramdisk utilities built from the latest sources. Originally only for Google Pixel/Nexus/AOSP standard boot.img files, built-in support has now expanded to Android Verified Boot (AVBv1)/ChromeOS/SignBlob signed boot.img files, Barnes & Noble Nook "Green Loader" signed boot.img files, Samsung/Spreadtrum DHTB header signed boot.img files, the Samsung/Marvell PXA1088/1908 board boot.img variant (AOSP-PXA), Loki patched boot.img files, Sony SIN signed/packaged kernel.elf extraction, Sony ELF kernel.elf files, Intel OSIP Android image files, DENX U-Boot uImage files, Rockchip KRNL signed ramdisk image files, MTK headers for zImage/ramdisk, and LG Bump/Samsung SEAndroid footers for boot.img. The main advantage here is you don't need Cygwin shell or PERL scripts. Other guides exist but none of them are universal for target device, compression and/or developed for Windows, Android ARM/x86/MIPS + ARM64/x86_64/MIPS64, and now macOS. With this universality in mind I've automated the whole process with batch/shell scripts. My development work on my many projects comes out of my free time, so if you enjoy this project or anything else I've done on xda, please do hit the donate link from my profile. Thank you for your support!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序猿Ricky的日常干货

你的鼓励将是我最大的动力!

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值