Crates.io | cca-realm-measurements |
lib.rs | cca-realm-measurements |
version | 0.1.0 |
source | src |
created_at | 2024-11-13 15:02:13.115705 |
updated_at | 2024-11-13 15:02:13.115705 |
description | Compute the Realm Initial and Extensible Measurements for Arm CCA |
homepage | |
repository | https://github.com/veraison/cca-realm-measurements.git |
max_upload_size | |
id | 1446635 |
size | 218,906 |
Given a VM configuration and the payload to run in the Realm, this tool calculates the Realm Initial and Extensible Measurements, needed for CCA attestation.
Build with:
cargo build
Run with:
target/debug/realm-measurements [options] <VMM> [vmm-args]
In the following example, the realm is started with kvmtool as VMM, using direct kernel boot. The host is QEMU TCG.
realm-measurement -c configs/qemu-max-8.2.conf -c configs/kvm.conf (1)
-k ~/build/linux-cca/arch/arm64/boot/Image (2)
--output-dtb ~/vm/shr/kvmtool-gen.dtb (3)
kvmtool (4)
-c 2 -m 256 --realm --console virtio --irqchip=gicv3-its
--sve-vl=512 --pmu -k guest_kernel -d disk --9p shr
This displays RIM and REM. With the endorsements parameters, it generates a CoMID file containing the reference values (cca-corim), that can be sent to a verifier:
--endorsements-template samples/comid-cca-realm.json
--endorsements-output cca-realm-endorsements.json
The reference values are then packed into a CoRIM file and sent to the verifier, using the cocli tool:
cocli comid create --template=cca-realm-endorsements.json
cocli corim create --template samples/corim-cca-realm.json
--comid cca-realm-endorsements.cbor --output cca-realm-corim.cbor
Provisionning a veraison verifier running locally can be done with:
veraison -- cocli corim submit --corim-file cca-realm-corim.cbor
--api-server=https://provisioning-service:8888/endorsement-provisioning/v1/submit
--media-type "'application/corim-unsigned+cbor; profile=http://arm.com/cca/realm/1'"
scripts/gen-run-vmm.sh generates a boot script and a DTB for the Realm. In the host run:
gen-run-vmm.sh [--kvmtool|--cloudhv]
./run-qemu.sh OR ./run-kvmtool.sh OR ./run-cloudhv.sh
The relying party or RV provider can run this same script to generate the Reference Value file (using templates in samples/):
gen-run-vmm.sh --corim-output cca-realm-corim.cbor
A config file gen-run-vmm.cfg for this script could be:
REALM_MEASUREMENTS=$HOME/src/realm-measurements/target/debug/realm-measurements
KERNEL=$HOME/build/linux/arch/arm64/boot/Image
INITRD=$HOME/build/buildroot/images/rootfs.cpio
EDK2_DIR=$HOME/src/edk2/
OUTPUT_SCRIPT_DIR=$HOME/shr/
OUTPUT_DTB_DIR=$HOME/shr/
CONFIGS_DIR=$HOME/src/realm-measurements/configs/
The event_log library parses a TCG event log to construct the reference values. See [docs/measurement-log.md], examples/ and the rust documentation for this library.
The Realm Token describes the state of the Realm VM at the time it is attested. It comprises the Realm Initial Measurement (RIM), which includes initial register and memory state, and Realm Extensible Measurement (REM) computed by the Realm itself, for example to measure a kernel image obtained from the host at runtime.
The following example uses language from the Remote Attestation standard RATS. A client (the Relying Party) wants to ensure that a remote service provider is running in a Realm the correct payload, on the correct hardware and firmware.
┌────────┐ ┌──────────┐ ┌────────┐
│ EAT │ │ │ │ │
│ (2) ──┼─┼─► ◄─┼─┼── (1) │
│ │ │ │ │ RV │
│ ◄─┼─┼── (3) │ │ │
│ │ │ EAR │ │ │
└────────┘ └──────────┘ └────────┘
Attester Verifier RV provider
The client initially provisions a trusted third party, the Verifier, with Reference Values (RV).
The Attester (Realm) establishes a secure connection to the Verifier. The Verifier sends a challenge, for example a random number that gets included into the realm token to guarantee freshness.
The Realm asks RMM for an attestation token. RMM produces the Realm token. The platform signs the Realm token and the platform token, forming the CCA attestation token.
The Realm sends the result of these calculations to the verifier, in the form of an Entity Attestation Token (EAT).
The verifier checks the signature and compares the returned tokens with known reference values, sends back appraisal EAR. If everything matches, the client can share secrets with the Realm.
This tool helps with calculating a Realm token in order to provision the verifier at step (1). The easiest way of computing the Realm token would be to run the payload in the same environment, on a machine that we own and trust. But neither client nor verifier might afford to own such hardware. In addition, many changes to VM parameters such as number of vCPUs, amount of memory, devices, would require running the whole payload again in order to collect the corresponding token. Here we provide ways to calculate a Realm Token independently from the Realm environment.