meta-openembedded/meta-oe/classes
Jan Luebbe 6f4501734f
Add class for appending dm-verity hash data to block device images
Add support to generate a dm-verity image and the parameters required to
assemble the corresponding table for the device-mapper driver. The latter will
be stored in the file ${DEPLOY_DIR_IMAGE}/<IMAGE_LINK_NAME>.verity-params.
Note that in the resulting image the hash tree data is appended to the contents
of the original image without an explicit superblock to keep things simple and
compact.

The above mentioned parameter file can be sourced by a shell to finally create
the desired blockdevice via "dmsetup" (found in meta-oe's recipe
"libdevmapper"), e.g.

  . <IMAGE_LINK_NAME>.verity-params
  dmsetup create <dm_dev_name> --readonly --table "0 $VERITY_DATA_SECTORS verity \
      1 <dev> <hash_dev> \
      $VERITY_DATA_BLOCK_SIZE  $VERITY_HASH_BLOCK_SIZE \
      $VERITY_DATA_BLOCKS  $VERITY_DATA_BLOCKS \
      $VERITY_HASH_ALGORITHM  $VERITY_ROOT_HASH  $VERITY_SALT \
      1 ignore_zero_blocks"

As the hash tree data is found at the end of the image, <dev> and <hash_dev>
should be the same blockdevice in the command shown above while <dm_dev_name> is
the name of the to be created dm-verity-device.

The root hash is calculated using a salt to make attacks more difficult. Thus,
please grant each image recipe its own salt which could be generated e.g. via

  dd if=/dev/random bs=1k count=1 | sha256sum

and assign it to the parameter VERITY_SALT.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2024-04-23 15:18:30 -07:00
..
breakpad.bbclass Convert to new override syntax 2021-08-03 10:21:25 -07:00
gitpkgv.bbclass gitpkgv.bbclass: adjust the example in comment a bit 2024-02-09 09:52:12 -08:00
gitver.bbclass gitver: Pass git directory argument to gitrev_run 2019-06-15 17:17:09 -07:00
gpe.bbclass Convert to new override syntax 2021-08-03 10:21:25 -07:00
image_types_sparse.bbclass image_types_sparse: Fix syntax error 2023-08-01 10:26:51 -07:00
image_types_verity.bbclass Add class for appending dm-verity hash data to block device images 2024-04-23 15:18:30 -07:00
itstool.bbclass Convert to new override syntax 2021-08-03 10:21:25 -07:00
machine_kernel_pr.bbclass remove True option to getVar calls 2016-12-02 09:16:17 +01:00
scancode.bbclass meta-oe: remove True option to getVar calls (again) 2019-01-13 10:28:01 -08:00
signing.bbclass signing.bbclass: fix typos 2024-03-05 15:09:24 -08:00
socorro-syms.bbclass Convert to new override syntax 2021-08-03 10:21:25 -07:00