/* SPDX-License-Identifier: LicenseRef-Starship-1.0 * Copyright (c) 2023-2026 Robert A. James */ /* test_capsule_sig.c -- which capsule signature results the kernel refuses (#139; * docs/v4.0.0/plans/2026-11-20-capsule-trust.md, ruled 2026-11-20): capsule_sig_refused(), the one * decision every caller asks. INVALID is refused on every build. A signed build (built with the * signing key, CAPSULE_SIGNED_BUILD 1) also refuses MISSING and NO_ROOT_KEY; a build without the key * warns of them and boots. Built twice: as here, unsigned, and as test_capsule_sig_signed.c. */ #include "harness.h" #include "starkernel/capsule_sig.h" #ifndef CAPSULE_SIGNED_BUILD #define CAPSULE_SIGNED_BUILD 0 #endif int main(void) { printf("capsule_sig_refused, a %s build\n", CAPSULE_SIGNED_BUILD ? "signed" : "developer (unsigned)"); CHECK(!capsule_sig_refused(CAPSULE_SIG_OK), "a good signature is never refused"); CHECK(capsule_sig_refused(CAPSULE_SIG_INVALID), "a signature that does not verify is always refused"); CHECK(capsule_sig_refused(CAPSULE_SIG_MISSING) == CAPSULE_SIGNED_BUILD, "an unsigned capsule: refused on a signed build, warned of on a developer build"); CHECK(capsule_sig_refused(CAPSULE_SIG_NO_ROOT_KEY) == CAPSULE_SIGNED_BUILD, "no signing certificate to check by: refused on a signed build, warned of on a developer build"); return DONE(); }