1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-10-22 10:31:56 +02:00

test: vboot: Add a test for a forged configuration

Add a check to make sure that it is not possible to add a new
configuration and use the hashed nodes and hash of another configuration.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2020-03-18 11:43:59 -06:00
parent 477f559edf
commit c021971e13
2 changed files with 440 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ import pytest
import sys
import struct
import u_boot_utils as util
import vboot_forge
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('fit_signature')
@@ -182,7 +183,22 @@ def test_vboot(u_boot_console):
util.run_and_log(cons, [fit_check_sign, '-f', fit, '-k', dtb])
# Replace header bytes
# Make sure that U-Boot checks that the config is in the list of hashed
# nodes. If it isn't, a security bypass is possible.
with open(fit, 'rb') as fp:
root, strblock = vboot_forge.read_fdt(fp)
root, strblock = vboot_forge.manipulate(root, strblock)
with open(fit, 'w+b') as fp:
vboot_forge.write_fdt(root, strblock, fp)
util.run_and_log_expect_exception(cons,
[fit_check_sign, '-f', fit, '-k', dtb],
1, 'Failed to verify required signature')
run_bootm(sha_algo, 'forged config', 'Bad Data Hash', False)
# Create a new properly signed fit and replace header bytes
make_fit('sign-configs-%s%s.its' % (sha_algo, padding))
sign_fit(sha_algo)
bcfg = u_boot_console.config.buildconfig
max_size = int(bcfg.get('config_fit_signature_max_size', 0x10000000), 0)
existing_size = replace_fit_totalsize(max_size + 1)