test_fit_verity_sign
Verify that the dm-verity roothash is covered by the FIT configuration signature.
A dm-verity protected filesystem image is not hashed by U-Boot; its integrity
is delegated to the kernel, which trusts the roothash taken from the FIT
dm-verity subnode. That roothash must therefore be part of the signed
region of the configuration, otherwise an attacker can replace both the
filesystem and the roothash while keeping the configuration signature valid.
This test signs a configuration referencing a filesystem image that carries a
dm-verity subnode, then flips one byte of the roothash and of the salt and
checks that verification rejects the image. A control tampering a byte that is
known to be signed confirms that the check is able to detect a broken region.
The FIT pairs a signed configuration with a filesystem image carrying a
dm-verity subnode:
images {
rootfs-1 {
data = /incbin/("rootfs.bin");
type = "filesystem";
compression = "none";
hash-1 {
algo = "sha256";
};
dm-verity {
algo = "sha256";
data-block-size = <4096>;
hash-block-size = <4096>;
num-data-blocks = <16>;
hash-start-block = <16>;
};
};
};
configurations {
conf-1 {
kernel = "kernel-1";
loadables = "rootfs-1";
signature-1 {
algo = "sha256,rsa2048";
key-name-hint = "dev";
sign-images = "kernel", "loadables";
};
};
};
mkimage builds the dm-verity hash tree when assembling the image and records
the resulting roothash and salt in the dm-verity subnode; fit_check_sign
must reject an image where either was modified after signing.
- test_fit_verity_sign.flip_prop_byte(ubman, fit, node, prop)
Flip the first byte of a byte-array property in a FIT, in place.
The property is rewritten with the same length so that no node is relaid out and the signed regions keep their offsets.
- test_fit_verity_sign.test_fit_verity_roothash_signed(ubman)
The dm-verity roothash must be inside the signed configuration region.