wolfBoot/tools/unit-tests
Daniele Lacamera 740383a3f5 F-4790: clamp OTP pubkey_size in keystore_get_size to prevent OOB read
keystore_get_size() returned slot->pubkey_size verbatim from the OTP
keystore slot with no upper bound. A corrupted or mis-provisioned slot
with pubkey_size > KEYSTORE_PUBKEY_SIZE produces a positive value that
passes every caller guard (pubkey_sz < 0 / <= 0). The callers in image.c
(key_sha256/key_sha384/key_sha3_384 and the ECC verify y-coordinate
offset) then read past otp_slot_item_cache, which only holds
KEYSTORE_PUBKEY_SIZE pubkey bytes.

Reject an out-of-range pubkey_size by returning -1, matching the existing
defensive validation of item_count in keystore_num_pubkeys() and the -1
error convention the callers already handle.

Add unit-otp-keystore, which compiles flash_otp_keystore.c in isolation
and verifies keystore_get_size() rejects oversized slots.
2026-06-09 15:52:07 +02:00
..
Makefile F-4790: clamp OTP pubkey_size in keystore_get_size to prevent OOB read 2026-06-09 15:52:07 +02:00
README.md
gpt-sfdisk-test.h
target.h Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
txt_filler.h
unit-boot-x86_fsp.c
unit-common.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-delta.c Cap backward delta match length 2026-04-29 11:34:23 +02:00
unit-disk.c Add GPT single-sector partition test 2026-04-29 12:24:41 +02:00
unit-enc-nvm.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-extflash.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-fdt.c F-4710: reject oversized FDT property length to prevent ~4GB FIT memcpy 2026-06-05 19:26:28 +02:00
unit-fit-fpga.c Add wolfBoot FIT support for loading bitstream 2026-06-09 15:30:27 +02:00
unit-fit-gzip.c Peer review fixes (copilot) 2026-05-05 10:16:16 +02:00
unit-flash-erase-h7.c F-5129: fix stm32h7 hal_flash_erase Bank 2 sector underflow 2026-06-09 15:52:07 +02:00
unit-fwtpm-stub.c Proper interface renaming + documentation 2026-04-22 14:14:28 +02:00
unit-gzip.c Peer review fixes (copilot) 2026-05-05 10:16:16 +02:00
unit-image.c review feedback 2026-05-05 16:37:54 +02:00
unit-keygen-xmss-params.c Fix XMSS keygen param fallback 2026-04-29 12:30:23 +02:00
unit-keystore.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-linux-loader-e820.c F-4711: bound e820 entries to prevent boot_params stack overflow 2026-06-05 19:19:05 +02:00
unit-linux-loader-syssize.c Fix test regression, addressed copilot comments 2026-06-05 20:55:52 +02:00
unit-loader-tpm-init.c loader: panic on TPM init failure 2026-04-14 07:48:59 +02:00
unit-max-space.c Fix WOLFBOOT_MAX_SPACE precedence and test 2026-04-14 14:28:44 +02:00
unit-mock-flash.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-mock-state.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-mpusize.c F-5132: complete mpusize() table so MPU stays enabled for >64KB wolfBoot 2026-06-09 15:52:07 +02:00
unit-multiboot.c Fix multiboot debug header length guard 2026-04-29 11:27:58 +02:00
unit-nvm.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-otp-keystore.c F-4790: clamp OTP pubkey_size in keystore_get_size to prevent OOB read 2026-06-09 15:52:07 +02:00
unit-parser.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-pci.c F-5674: cap PCI IO BAR allocator at the 16-bit IO ceiling 2026-06-09 15:50:48 +02:00
unit-pkcs11_store.c Fix test regression, addressed copilot comments 2026-06-05 20:55:52 +02:00
unit-policy-create.c Fix policy_create PCR digest validation 2026-04-08 19:51:17 +02:00
unit-policy-sign.c
unit-psa_store.c Fix store header search bounds 2026-03-30 16:23:16 +02:00
unit-qspi-flash.c Abort QSPI writes after WE failure 2026-04-29 12:13:40 +02:00
unit-rot-auth.c F-4973: clamp TPM-supplied nvPublic.dataSize before NV read-back in rot.c 2026-06-09 15:52:07 +02:00
unit-sdhci-disk-unaligned.c Clamp unaligned SDHCI disk I/O spans 2026-04-14 07:38:41 +02:00
unit-sdhci-response-bits.c Fix SDHCI response bit span check 2026-03-30 16:23:16 +02:00
unit-sectorflags.c Add sector flag unit coverage 2026-04-29 12:26:55 +02:00
unit-sign-delta-cert-inv-off.py F-5131: fix stale delta inverse-patch offset when cert chain expands header 2026-06-09 15:52:07 +02:00
unit-sign-delta-tlv.py F-5352: emit 4-byte delta size TLVs from Python signer 2026-06-09 15:50:48 +02:00
unit-sign-encrypted-output.c Reject oversized signature TLV lengths 2026-04-14 14:25:10 +02:00
unit-sign-encrypted-output.mkfrag Update wolfssl submodule to latest master 2026-05-18 23:02:54 -07:00
unit-spi-flash.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-store-sbrk.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-string.c Preparing release v2.8.0 + update copyright 2026-04-16 13:11:56 +02:00
unit-tpm-api-names.c Bound TPM name fallback copies 2026-04-29 12:16:03 +02:00
unit-tpm-blob.c Fix TPM unseal handle cleanup 2026-04-14 07:46:13 +02:00
unit-tpm-check-rot-auth.c Rebased, addressed comments 2026-03-30 16:30:27 +02:00
unit-tpm-rsa-exp.c
unit-uart-flash.c Addressed copilot's comments 2026-04-29 13:15:52 +02:00
unit-update-disk.c Add explicit integrity/authenticity failure tests in update-disk suite 2026-06-09 15:50:14 +02:00
unit-update-flash.c Unit tests: check hal_flash_protect actually gets called 2026-05-06 19:03:12 +02:00
unit-update-ram-nofixed.c Unit tests: check hal_flash_protect actually gets called 2026-05-06 19:03:12 +02:00
unit-update-ram.c Unit tests: check hal_flash_protect actually gets called 2026-05-06 19:03:12 +02:00

README.md

Unit Test Tools

This uses the "check" unit test framework for C.

You may need to run "apt install check", "yum install check" or "brew install check".

Building

Use make to build.

Expected output

$ ./unit-parser
Running suite(s): wolfBoot
Explicit end of options reached
This field is too large (bigger than the space available in the current header)
This field is too large and would overflow the image header
Illegal address (too high)
Illegal address (too high)
100%: Checks: 2, Failures: 0, Errors: 0