common-mock: mock btg_key_validator so we can test failure states

Signed-off-by: Michał Iwanicki <michal.iwanicki@3mdeb.com>
This commit is contained in:
Michał Iwanicki
2026-01-14 12:23:08 +01:00
parent ce5fe88d0e
commit 26828e4183
3 changed files with 25 additions and 1 deletions
+23
View File
@@ -793,3 +793,26 @@ amdtool_on_amd_mock() {
cap_upd_tool_common_mock() {
return 0
}
################################################################################
# cap_upd_tool
################################################################################
# Set this variable to:
# - leave empty - call original tool
# - "success" - key verification succeeded
# - "fail_hash" - key verification failed with hash error
# - anything else - return 1 and don't print anything
TEST_KEY_VALIDATOR_RESULT="${TEST_KEY_VALIDATOR_RESULT:-}"
btg_key_validator_common_mock() {
if [ -z "${TEST_KEY_VALIDATOR_RESULT}" ]; then
btg_key_validator "$@"
return
elif [ "${TEST_KEY_VALIDATOR_RESULT}" = "success" ]; then
echo "Firmware is signed with expected key hash"
return 0
elif [ "${TEST_KEY_VALIDATOR_RESULT}" = "fail_hash" ]; then
print_error "Firmware signature doesn't match expected hash"
fi
return 1
}
+1
View File
@@ -60,6 +60,7 @@ RDMSR="tool_wrapper rdmsr"
LSPCI="tool_wrapper lspci"
LSUSB="tool_wrapper lsusb"
DUMP_PCRS="tool_wrapper dump_pcrs"
BTG_KEY_VALIDATOR="tool_wrapper btg_key_validator"
################################################################################
# Tools wrapper.
+1 -1
View File
@@ -1596,7 +1596,7 @@ fuse_workflow() {
check_if_ac
download_bios
verify_artifacts bios
btg_key_validator --file "$BIOS_UPDATE_FILE" --key-hash "$INTEL_BTG_HASH"
$BTG_KEY_VALIDATOR --file "$BIOS_UPDATE_FILE" --key-hash "$INTEL_BTG_HASH"
error_check "Firmware Intel BootGuard signature check failed. Aborting...
Platform has not been fused and no changes were made."
# Ask user for confirmation: