当 Android HLOS 从上一阶段接收到其 CDI 值和 DICE 链时,会读取这些值和链,然后派生并擦除 SDV 服务发现所需的必要密钥(例如公钥/私钥对和进一步的 CDI 阶段)。
此过程在启动流程中尽早进行,在第二阶段 init 的 early-init 期间进行。这样做可确保 Android HLOS 在任何第三方代码执行之前使用并擦除 CDI 值。
Android 引导加载程序(或虚拟机监控程序中的 guest 加载程序,如果不存在 Android 引导加载程序)通过 SDV 的 Linux 内核将以下值传递给 Android 用户空间中的 second stage init:
- Android HLOS 层的证明 CDI 值。
- Android HLOS 层的密封 CDI 值。
- CBOR 编码的 DICE 链,直到 Android HLOS 层。
这些值使用 SdvDiceHandover 格式。SdvDiceHandover 是由以下 CDDL 片段描述的 CBOR 编码映射:
SdvDiceHandover = {
1 : bstr .size 32, ; CDI_Attest
2 : bstr .size 32, ; CDI_Seal
3 : DiceCertChain, ; Android SDV DICE chain
}
IRemotelyProvisionedComponent HAL DiceCertChain 指定了 DiceCertChain 的格式。您不需要为 SdvDiceHandover 使用确定性编码的 CBOR,但强烈建议这样做,因为这样可以支持更广泛的 DICE 政策。
SdvDiceHandover 格式与以下格式非常相似:
AndroidDiceHandover格式(由 DICE 参考实现的开放配置文件定义),pvmfw用于将 DICE 链移交给 pVM 的PvmfwDiceHandover格式。例如,Microdroid。
与 AndroidDiceHandover 不同,与 PvmfwDiceHandover 格式类似,DiceCertChain 是必需的,而不是可选的。
针对 DICE 内核驱动程序的开放式配置文件
Android HLOS CDI 从 Android 引导加载程序(或虚拟机监控程序中的 guest 加载程序,如果没有引导加载程序)到 Android HLOS 的 DICE 移交依赖于 Open Profile for DICE 内核驱动程序。Android 引导加载程序将 DICE 链条条目写入访客内存中设备树 (DT) 必须指定的区域。
驱动程序读取 DT 指定的此内存区域,并将其作为 /dev/open-dice0 设备公开给用户空间。驱动程序允许读取和擦除此内存区域。DICE 驱动程序的开放配置文件仅存在于 arm64 架构上,因为设备树是 arm64 独有的概念。
使用 DT 中通过在 compatible 属性中指定 "google,open-dice" 为驱动程序标记的 reserved-memory 节点,指定 Open Profile for DICE 驱动程序公开的内存区域。例如:
reserved-memory {
// The number of u32 cells to represent the address of a memory region
#address-cells = <2>;
// The number of u32 cells to represent the size of a memory region
#size-cells = <2>;
ranges;
// The unit address (after the @) must match the address in the reg property
dice@D1C30000 {
compatible = "google,open-dice";
no-map;
// The address and the size of the memory region that is passed to the Open
// Profile for DICE driver. The address must be page-aligned, and the size a
// multiple of the page size. The first two hex numbers (cells) represent
// the address of the memory region, the last two represent its size.
reg = <0x0 0xD1C30000 0x0 0x1000>;
};
};