Skip to content
wolfSSLPublic

About

Embedded FIDO Device Onboard (FDO) 2.0 device agent in C. DI, TO1 and TO2 over HTTP/CBOR with wolfCOSE, no dynamic allocation, pluggable credential and key backends (software, TPM 2.0), fdo.download straight into a wolfBoot update partition. Post-quantum key exchange and attestation as an extension.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

wolfFDO

wolfFDO is a device-side implementation of the FIDO Device Onboard (FDO) 2.0 protocol for embedded targets. It performs Device Initialize (DI), Transfer Ownership 1 and 2 (TO1, TO2) against a standard Rendezvous and Owner server, speaks HTTP with CBOR message bodies, and builds its COSE signatures, Entity Attestation Tokens and encrypted ServiceInfo on wolfCOSE and wolfCrypt. The core has no dynamic allocation, works in one caller-supplied message buffer, and is configured through user_settings.h.

Device keys and the credential HMAC secret live behind a key backend: software for development, or a TPM 2.0 for production through wolfTPM, where the attestation key and the HMAC secret never leave the TPM and the credential blob is kept in TPM NV. wolfTPM drives the Infineon OPTIGA TPM SLB9670, SLB9672, SLB9673 and SLB9678 among other TPM 2.0 parts (see TPM 2.0). The fdo.download module can stream firmware into a wolfBoot update partition and request the update, so a device is onboarded and running its owner's firmware in one TO2 session.

Interoperability is tested in CI against the go-fdo reference server with the FDO 2.0 and 1.1 message sets (see Interoperability).

Features

  • FDO 2.0 (PS-v2.0-20260402) device protocol: DI (messages 10-13), TO1 (30-33), TO2 (80-91), ErrorMessage handling, domain-separated COSE_Sign1 external AAD, maxOwnerMessageSize, the RendezvousInfo retry pause
  • FDO 1.1 (protocol version 101) alongside 2.0: DI picks the version, the credential carries it and TO1/TO2 follow it (message types 60-71, /fdo/101/msg/ paths); WOLFFDO_NO_PROTO_11 drops it
  • Device attestation with ES256 or ES384, in software or in a TPM 2.0; HashML-DSA-65 where wolfSSL provides ML-DSA (experimental, see below)
  • Owner keys: ECDSA P-256 and P-384, RSA 2048 and 3072 (RS256, RS384, PS256, PS384 voucher and owner signatures)
  • Key exchange: ECDH256, ECDH384, DHKEXid14, DHKEXid15, ML-KEM-768 and the ECDH256MLKEM768 hybrid (experimental: the post-quantum suites are not in the FDO 2.0 specification); AES-128-GCM and AES-256-GCM session encryption
  • Ownership voucher chain verification, credential replacement at TO2 Done with HMAC secret rotation, credential reuse, DispDisable
  • Delegation: an Owner delegate (X.509 chain with the FDO permission OIDs) may sign TO2.ProveOVHdr20, credential reuse and the rendezvous blob; resale and disable need the matching permission
  • RendezvousInfo directive interpretation (DNS then IP, port, protocol, bypass, delay), unusable directives skipped
  • ServiceInfo modules: devmod, fdo.download (SHA-384 checked) with a pluggable download sink, fdo.upload with a pluggable file source, fdo.wget (http and https, chunked or not) into the download sink, fdo.command with a pluggable runner (POSIX fork and exec, behind an allow-list)
  • Backends: software key, file and flash credential stores, TPM 2.0 key and HMAC objects with an NV credential store, wolfBoot update partition sink (direct or through the TrustZone secure gateway), POSIX sockets, wolfIP for bare-metal targets, and TLS with wolfSSL over either of them (server certificate pinned by the RendezvousInfo hash, a configured pin, or a CA chain)
  • Error strings (wolfFDO_ErrorString) and a log callback for WOLFFDO_DEBUG builds; module and backend error codes come back unchanged

Quick start

Needs a C compiler, make, git, Go 1.26 or later (for the go-fdo reference server) and python3. From an empty directory, which ends up holding wolfFDO, go-fdo and the fdo server side by side:

git clone --recursive https://github.com/wolfSSL/wolfFDO.git
git clone https://github.com/fido-device-onboard/go-fdo && cd go-fdo
git fetch origin ca3a0a2ca3beead5a11d34363221e7c980b36243
git checkout ca3a0a2ca3beead5a11d34363221e7c980b36243
git apply ../wolfFDO/tools/interop/go-fdo-pr285.patch
cd examples && go build -o ../../fdo ./cmd && cd ../../wolfFDO
make check examples
../fdo server -http 127.0.0.1:9998 -ext-http 127.0.0.1:9998 -reuse-cred \
    -db /tmp/fdo.db -download README.md &
examples/di 127.0.0.1 9998 /tmp/dev wolffdo-quickstart
mkdir -p /tmp/dl && examples/onboard 127.0.0.1 9998 /tmp/dev /tmp/dl

The server and the examples run in wolfFDO: the server opens the fdo.download file relative to where it was started, and only when TO2 reaches it, so a server started elsewhere passes DI and TO1 and then drops TO2. DI stores the credential next to /tmp/dev; the onboarding runs TO1 and TO2 with the server, which sends README.md through fdo.download into /tmp/dl. Run examples/onboard again to onboard with the replacement credential. tools/interop/run.sh ../fdo runs the whole interoperability matrix.

Building

wolfSSL, wolfCOSE and wolfTPM are git submodules under lib/, compiled from source with config/user_settings.h by the default build on Linux and macOS; no installed wolfSSL is needed. Objects land under build/<CONFIG>/ (host by default), so builds with different flags live side by side.

git clone --recursive https://github.com/wolfSSL/wolfFDO.git
cd wolfFDO
make check examples

git submodule update --init fetches the submodules in an existing clone.

Target What it does
make libwolffdo.a and libwolffdo_port_posix.a with the submodule libraries
make check the unit tests (tests/wolffdo_test <substring> runs one test; FDO_TEST_SEED=<n> replays a run)
make examples examples/di, to1 and onboard
make tpm examples/fdo_tpm from the wolfTPM submodule (WOLFTPM_DIR= uses a wolfTPM build tree or install)
make check-tpm the TPM backend against the mock Owner on a machine with a TPM, or TPM=swtpm CONFIG=swtpm against a simulator on localhost:2321
make check-wolfip WOLFIP= the wolfIP transport against the mock Owner over two wolfIP stacks joined in memory, with DNS, a mid-body close, a stalled server and more data than the TCP windows hold, and TLS over it against a wolfSSL server on the other stack (DI and onboarding, a wrong pin, a server that closes after each reply, a stalled handshake)
make wolfboot WOLFBOOT_DIR= examples/onboard_wolfboot against a built wolfBoot simulator tree
make coverage the unit tests under gcov, lcov report in build/coverage/
make install PREFIX= headers, libraries and wolffdo.pc
make -C tools/size report the Cortex-M33 footprint of a profile (ES384=1, DELEGATE=1, PROTO11=1, CSR=1, NOSHA384=1); check-budget holds it to tools/size/BUDGET
make -C tests/fuzz run SECONDS=60 the libFuzzer harnesses (clang, ASan and UBSan)
make -C tools/vectors check the captured go-fdo vectors still match the transcripts
make doc the API reference from the public headers into docs/html/ (Doxygen); make doc-check fails on any undocumented function or Doxygen warning

WERROR=1 turns warnings into errors (CI does), EXTRA_CFLAGS adds flags to the wolfFDO sources and TP_EXTRA_CFLAGS to the third-party ones, CC=clang and CONFIG=clang keep a second compiler's objects apart.

Against an installed wolfSSL

make WOLFSSL_PREFIX=/path/to/wolfssl check examples builds against an installed wolfSSL (5.9.2 or later, configured with --enable-keygen --enable-certgen --enable-certreq --enable-certext --enable-cryptocb --enable-sha3 --enable-mlkem --enable-mldsa --enable-experimental --enable-aesccm --enable-ip-alt-name CFLAGS=-DWOLFSSL_PUBLIC_MP) with its options.h instead of the submodule; the example binaries then carry that library path.

Installing and consuming

make install PREFIX=/opt/wolffdo installs the wolfFDO and wolfCOSE headers and libraries and, in the submodule build, the wolfSSL library with the headers and user_settings.h it was built with. pkg-config --cflags --libs wolffdo then gives everything an application needs; tools/pkgconfig_check.c is the smallest such program.

CMakeLists.txt builds the same libraries and tests (cmake -B build-cmake && cmake --build build-cmake && ctest --test-dir build-cmake), takes the WOLFFDO_* options below as cache variables (-DWOLFFDO_NO_PQC=ON), installs with cmake --install, and is consumed with add_subdirectory(wolfFDO) or find_package(wolffdo) through the exported wolffdo::wolffdo and wolffdo::wolffdo_port_posix targets. WOLFFDO_WOLFSSL_PREFIX names an installed wolfSSL.

Embedded builds

An embedded build defines WOLFSSL_USER_SETTINGS and supplies one user_settings.h that configures wolfCrypt, wolfCOSE and wolfFDO together; WOLFFDO_USER_SETTINGS names the same file for a build of wolfFDO alone. sources.mk lists the core sources, the POSIX, TPM and bare-metal port sources, and the wolfCrypt and wolfTPM files the host profile needs, so any build system can take them from one place. config/user_settings_cortexm.h is the Cortex-M profile the footprint build and the NUCLEO-H563ZI example share: a target's own user_settings.h defines its entropy source and switches and includes it. include/wolffdo/visibility.h exports the API alone from a shared object (-fvisibility=hidden -DBUILDING_WOLFFDO); WOLFFDO_DLL selects the Windows import and export attributes.

Configuration

Every option is a preprocessor define, read from user_settings.h or the compiler command line, and wolfFDO_Init refuses an application compiled with another set (WOLFFDO_E_BUILD).

Define Effect
WOLFFDO_ES384 the P-384 attestation profile: ES384, SHA-384, HMAC-SHA384 (ES256 otherwise)
WOLFFDO_NO_PROTO_11 FDO 2.0 only
WOLFFDO_NO_PQC neither ML-KEM nor ML-DSA, even when wolfSSL has them
WOLFFDO_NO_MLKEM, WOLFFDO_NO_MLDSA one of the two post-quantum algorithms out
WOLFFDO_NO_DELEGATE delegate chains refused, no certificate parsing
WOLFFDO_NO_DOWNLOAD, WOLFFDO_NO_UPLOAD, WOLFFDO_NO_WGET, WOLFFDO_NO_COMMAND the fdo.download, fdo.upload, fdo.wget and fdo.command modules out
WOLFFDO_NO_SHA384 SHA-384 and SHA-512 out (needs WOLFFDO_NO_DOWNLOAD, not WOLFFDO_ES384, and leaves fdo.upload and fdo.wget out); the device offers SHA-256 only
WOLFFDO_NO_ERROR_REPORT no ErrorMessage sent to the server when the device stops a protocol
WOLFFDO_NO_ERROR_STRINGS wolfFDO_ErrorString returns an empty string
WOLFFDO_DEBUG the log callback (wolfFDO_SetLogCb) hears every message sent, received and failed
WOLFFDO_MAX_MSG_SZ the message buffer the application supplies (4096, or 8192 with ML-DSA)
WOLFFDO_MAX_HOST_SZ longest server name, NUL included (128; 64 on the embedded profiles)
WOLFFDO_SVCINFO_OUT_SZ queue for module replies between ServiceInfo rounds (1024; 512 in the Cortex-M profile)
WOLFFDO_TO2_SCRATCH_SZ TO2 working buffer for the COSE Enc_structure and an RSA signature copy (640; 64 with NO_RSA)
WOLFFDO_MAX_TO1D_SZ, WOLFFDO_MAX_PUBKEY_SZ, WOLFFDO_MAX_DELEGATE_CERTS rendezvous blob, Owner key and delegate chain bounds
WOLFFDO_MAX_DEVINFO_SZ, WOLFFDO_MAX_RVINFO_SZ, WOLFFDO_MAX_HMACREF_SZ, WOLFFDO_CRED_MAX_SZ credential field and image bounds
WOLFFDO_MAX_RVDIRECTIVES, WOLFFDO_MAX_RVINSTR, WOLFFDO_MAX_RVTO2ADDR RendezvousInfo and RVTO2Addr entries kept
WOLFFDO_MAX_CMD_SZ, WOLFFDO_MAX_CMD_ARGS_SZ, WOLFFDO_MAX_CMD_ARGC, WOLFFDO_MAX_CMD_OUT_SZ fdo.command bounds
WOLFFDO_MAX_DL_NAME_SZ, WOLFFDO_MAX_SVCINFO_ROUNDS fdo.download, fdo.upload and fdo.wget file name, ServiceInfo round bound
WOLFFDO_UL_CHUNK_SZ largest fdo.upload data chunk (1014, as the fdo-sim modules send)
WOLFFDO_MAX_URL_SZ, WOLFFDO_WGET_BUF_SZ longest fdo.wget URL path (256), its receive buffer and HTTP header bound (1024)
WOLFFDO_WGET_ROUND_SZ, WOLFFDO_WGET_RECV_MS, WOLFFDO_WGET_IDLE_ROUNDS fdo.wget pacing: bytes read per round (256 KB), wait for more bytes (200 ms), rounds without a byte before the fetch is given up (60)
WOLFFDO_HTTP_TIMEOUT_MS, WOLFFDO_SVCINFO_IDLE_MS transport timeout, idle ServiceInfo pacing
WOLFFDO_RV_RETRY_DELAY_SEC, WOLFFDO_RV_RETRY_JITTER_SEC the pause after the last RendezvousInfo directive fails (120 s, plus or minus 30)
WOLFFDO_MAX_RV_DELAY_SEC longest RVDelaysec honored (3600)
WOLFFDO_MAX_CAPFLAGS_SZ, WOLFFDO_MAX_TOKEN_SZ CapabilityFlags accepted from a peer (8), HTTP authorization token kept (128)
WOLFFDO_URL_PREFIX, WOLFFDO_URL_PREFIX_11 HTTP path in front of the message type (/fdo/200/msg/, /fdo/101/msg/)

Backend options: WOLFFDO_TPM (set by make tpm) turns on the wolfTPM settings in config/user_settings.h; WOLFFDO_CRED_FILE_PATH_SZ bounds the file store's path; WOLFFDO_SINK_PAGE_SZ is the wolfBoot sink's write unit and WOLFFDO_SINK_WOLFBOOT_NSC makes it call the TrustZone secure gateway. The CMake build also takes WOLFFDO_BUILD_TESTS and WOLFFDO_BUILD_EXAMPLES (both on).

include/wolffdo/settings.h documents each with its default; the backend options are documented in their headers under include/wolffdo/port/.

Porting

The application fills a WOLFFDO_CONFIG with its backends and buffers and hands it to wolfFDO_Init; the context keeps the pointer, so the configuration must outlive it. The top of include/wolffdo/wolffdo.h gives the return convention, what each error code means and which are reported to the server or retried, and the rules for using contexts from several threads. The callbacks:

  • WOLFFDO_NET_CB (connect, send, recv, close): one TCP connection at a time. connect gets the host, port, whether TLS is wanted and the RendezvousInfo certificate hash when there is one; it returns -1 when TLS was asked for and cannot be provided. recv returns 0 with no bytes at end of stream, -1 on failure or timeout. The HTTP layer keeps the connection for the next message; when a kept connection turns out closed (the send fails, or end of stream comes before the first reply byte) it sends the message once more on a fresh connection, and never after a timeout. src/port/net_posix.c, net_tls.c and net_wolfip.c are the references; net_tls.c runs wolfSSL over another WOLFFDO_NET_CB given to wolfFDO_NetTlsInit, so its timeouts and end of stream are that transport's.
  • WOLFFDO_CRED_CB (read, write, erase): two slots of at least WOLFFDO_CRED_MAX_SZ bytes. read returns 0 with a length of 0 for an empty slot and -1 only when the slot cannot be read, which the library reports as WOLFFDO_E_STORAGE rather than starting a new DI. A write that is torn is detected by the image CRC and the previous generation stays current. src/port/cred_file.c, cred_flash.c (memory-mapped or through a read op) and cred_tpm.c implement it.
  • WOLFFDO_KEY_CB (hmacGen, hmac, sign): the device attestation key and the credential HMAC secret. hmacGen makes a fresh secret and returns the reference the credential will carry (the raw secret for the software backend, a handle for a TPM); sign signs the given digest with the configured algorithm. src/port/key_sw.c and key_tpm.c.
  • WOLFFDO_DL_SINK (begin, write, end) receives a file from fdo.download; end says whether the SHA-384 matched. fdo.download carries no offset, so a download cut short is ended as failed and the retried TO2 sends the whole file again, starting with a new begin. src/port/sink_wolfboot.c stages a wolfBoot update.
  • WOLFFDO_UL_SOURCE (open, read, close) serves a file the Owner asks for through fdo.upload, a chunk per round sized to the Owner's maxDeviceServiceInfoSz, then its SHA-384 when asked. The Owner chooses the name, so the source decides what may be read; the examples' exFileSource serves only plain names directly in one directory, and examples/onboard offers fdo.upload only when given that directory.
  • wolfFDO_WgetInit takes a transport of its own (TO2's connection stays open meanwhile) and a WOLFFDO_DL_SINK for the file. The GET runs a slice per ServiceInfo round: it reads while bytes arrive within WOLFFDO_WGET_RECV_MS, up to WOLFFDO_WGET_ROUND_SZ a round, and gives up after WOLFFDO_WGET_IDLE_ROUNDS rounds in a row without a byte. Bodies with a Content-Length, chunked or ending at the close are taken; the sink never gets more than an announced length. A failed fetch goes back to the Owner as error with a reason and does not end TO2. Any http or https URL is fetched unless wolfFDO_WgetSetAllow sets a check; https needs a TLS transport, so examples/onboard, which gives fdo.wget a plain socket, fetches http only.
  • WOLFFDO_CMD_RUNNER (start, poll, stop) runs a command for fdo.command; poll hands back what the command printed so far and its exit code once it ended, and is called once per ServiceInfo round until then. src/port/cmd_posix.c, with cmd_allow.c as an allow-list in front of any runner.
  • delayMs is called for every wait (RVDelaysec, idle ServiceInfo rounds, the gap between onboarding attempts); NULL skips them all, which the tests use.
  • afterTo1 is called by wolfFDO_Onboard between TO1 and TO2 on every attempt, which is where a device confirms a new firmware image (the NUCLEO-H563ZI example does); a non-zero return ends the onboarding with that code.
  • WOLFFDO_LOG_CB (wolfFDO_SetLogCb) receives a static location string, the message type and the return code at every step of a WOLFFDO_DEBUG build.

Modules other than devmod are registered in modules; wolfFDO_DownloadInit, wolfFDO_UploadInit, wolfFDO_WgetInit and wolfFDO_CommandInit fill a WOLFFDO_MODULE each. A module's own error code ends TO2 and is what wolfFDO_Onboard returns.

TPM 2.0

src/port/key_tpm.c keeps the device attestation key and the credential HMAC secret in the TPM as persistent objects, so neither leaves it, and src/port/cred_tpm.c keeps the credential in two NV indices (0x01800100 and 0x01800101 in the examples). The attestation key is ECC P-256 or P-384, or HashML-DSA-65 on a TPM that implements the TPM 2.0 version 1.85 post-quantum commands. FDO_TPM_SESSION=1 in examples/fdo_tpm runs the TPM traffic in a salted session with AES-CFB parameter encryption, so the HMAC secret and the credential do not cross the bus in the clear.

wolfTPM supports the Infineon OPTIGA TPM SLB9670 (SPI), SLB9672 (SPI), SLB9673 (I2C) and SLB9678 (SPI or I2C), and other TPM 2.0 parts listed in its supported hardware. config/user_settings.h builds for a TPM on chip select 1 of the Linux SPI device with wolfTPM's WOLFTPM_SLB9672 settings; another part takes its own define in that block (WOLFTPM_SLB9670, WOLFTPM_SLB9678, or WOLFTPM_SLB9673 with WOLFTPM_I2C). make tpm builds examples/fdo_tpm (see Examples and targets); the backend runs on a Raspberry Pi 5 with a TPM 2.0 and in CI against swtpm.

Examples and targets

The host examples share examples/common.c, keep the credential in two files next to <cred-base> and the device key in <cred-base>.key, take their options from the environment, and (to1, onboard, onboard_wolfboot and fdo_tpm) take - as the host to use the Rendezvous Server in the credential. They sign with the profile the library was built with (WOLFFDO_ES384 for P-384). The variables: FDO_PROTVER=101 asks for an FDO 1.1 credential at DI, FDO_KEX=ecdh384|mlkem768|ecdh256mlkem768 the key exchange, FDO_TLS=1 TLS on a command-line host with FDO_TLS_PIN=<sha256 of the DER certificate>, FDO_TLS_CA=<pem> or FDO_TLS_INSECURE=1, and FDO_DEBUG=1 prints the log callback.

  • Against go-fdo on this host: fdo -debug server -http 127.0.0.1:9998 -ext-http 127.0.0.1:9998 -reuse-cred -db t.db -download <file> (add -upload <name> -upload-dir <dir>, -wget <url> and -command-date for the other modules), then examples/di 127.0.0.1 9998 <cred-base> <device-info> [owner-key-type], examples/to1 127.0.0.1 9998 <cred-base> and examples/onboard 127.0.0.1 9998 <cred-base> <download-dir> [upload-dir]. onboard serves fdo.upload only from the upload-dir, fetches fdo.wget URLs over plain http into the download-dir, and runs only date and echo for fdo.command. The owner key type asks the manufacturer for that kind of voucher (10 P-256, 11 P-384, 5 RSA PKCS, 6 RSA PSS). tools/interop/run.sh runs the whole matrix and tools/interop/README.md says how to build the server.
  • Raspberry Pi 5 with a TPM 2.0: make tpm, then examples/fdo_tpm <host> <port> [download-dir] [device-info] runs DI on the first call and an onboarding on every later one, with the attestation key and HMAC secret as TPM objects and the credential in two NV indices. fdo_tpm reset erases them, fdo_tpm handles lists the persistent handles, fdo_tpm clear runs TPM2_Clear. Besides the common variables, FDO_ES384=1 provisions a P-384 key, FDO_PQ=1 provisions a HashML-DSA-65 key (WOLFFDO_SG_HMLDSA65), FDO_OWNER_PK=<pkType> asks the manufacturer for that kind of voucher, and FDO_TPM_SESSION=1 runs the TPM traffic in a salted session with AES-CFB parameter encryption (the words nosalt, xor and noenc in the value vary it). make check-tpm runs the backend against the in-process mock Owner.
  • NUCLEO-H563ZI (examples/stm32h563/, setup and flash layout in its README): the non-secure image launched by wolfBoot with TrustZone, DHCP over the on-board Ethernet with wolfIP, the key and credential in flash sectors above the partitions, and fdo.download staged in the update partition through wolfBoot's secure gateway. make -C examples/stm32h563 WOLFIP=<wolfIP tree> WOLFBOOT=<built wolfBoot tree> produces the signed image; VERSION= numbers it and EXTRA_CFLAGS='-DWOLFFDO_SERVER_HOST=\"<ip>\"' names the server (192.168.1.100 by default, port WOLFFDO_SERVER_PORT 9995), WOLFFDO_DEVICE_INFO the DeviceInfo string sent at DI (wolffdo-h563), and WOLFIP_IP, WOLFIP_NETMASK, WOLFIP_GW and WOLFIP_STATIC_DNS_IP set the static address used when no DHCP lease arrives. The wolfBoot tree needs examples/stm32h563/wolfboot_ns_data.patch and the .config lines in .github/workflows/build.yml. TLS=1 (built in build_tls/) adds wolfSSL's TLS 1.3 client over wolfIP with a heap for wolfSSL alone: EXTRA_CFLAGS='-DWOLFFDO_TLS_PIN=\"<sha256 of the server certificate DER>\"' pins the server when RendezvousInfo carries no certificate hash, and -DWOLFFDO_SERVER_TLS runs DI over TLS too. DI sends an X.509 certificate request for the device key (WOLFFDO_CORTEXM_CSR), and -DWOLFFDO_NO_CONFIRM builds an image that never confirms itself, for testing wolfBoot's rollback. The agent brings Ethernet up from HSI at 32 MHz (wolfIP's PHY waits are sized for it) and then returns to the PLL1 wolfBoot left running, 248 MHz on this board. Its MAC is a locally administered address hashed from the chip's unique ID, so two boards on a LAN are very unlikely to share one; -DWOLFFDO_ETH_MAC=0x02,... fixes it instead.
  • wolfBoot simulator: build wolfBoot for its simulator (cp config/examples/sim.config .config && make in a wolfBoot tree), then make wolfboot WOLFBOOT_DIR=<that tree> builds examples/onboard_wolfboot. onboard_wolfboot <rv-host|-> <rv-port> <cred-base>, run in the directory holding the simulator's internal_flash.dd, onboards like onboard, stages the downloaded image in the update partition and requests the update. tools/interop/wolfboot_sim.sh <fdo> <simulator tree> runs that against go-fdo with a signed version 2 image and checks that the simulator then boots version 2.

Interoperability

tools/interop/run.sh onboards the example device against go-fdo's example server, built from go-fdo's FDO 2.0 series (pull request 285) with tools/interop/go-fdo-pr285.patch, and CI runs it on every push:

  • FDO 2.0: DI and two onboardings with credential reuse; FDO 1.1: DI and an onboarding
  • An RSA Owner with DHKEXid15, the ES384 profile, and the ML-KEM-768 and ECDH256MLKEM768 key exchanges (the patch adds their Owner side)
  • fdo.download, fdo.upload, fdo.wget from a local HTTP server and fdo.command running date, each file and output checked
  • tools/interop/wolfboot_sim.sh: a signed version 2 image delivered through fdo.download, staged by examples/onboard_wolfboot and booted by the wolfBoot simulator

The parsers are also tested against DI and TO1/TO2 messages captured from go-fdo (tools/vectors/), and the delegate tests use certificate chains go-fdo issued. The NUCLEO-H563ZI agent has onboarded against the same server over HTTP and over TLS 1.3, with the delivered image installed by wolfBoot. tools/interop/README.md says how to build the server.

Testing

make check runs the unit tests against an in-process mock Manufacturer, Rendezvous Server and Owner (tests/mock_owner.c) that covers every suite and Owner key type, breaks each check the device makes one at a time, bends its HTTP replies, issues delegate chains and the replacement voucher after a resale, plus the port tests (file and flash stores, the POSIX command runner, the TLS transport against a wolfSSL server in a child process) and the parsers against messages captured from go-fdo (tests/*_vectors.h, regenerated by tools/vectors/). Every test sits behind the switch of the feature it needs, so the suite runs under any option set.

CI (.github/workflows/) runs the suite with gcc, clang and on macOS, under the sanitizers, with every build switch, against an installed wolfSSL and through pkg-config and CMake; the TPM backend against swtpm; the fuzz harnesses; the go-fdo interoperability matrix; the wolfIP transport against a pinned wolfIP tree; the NUCLEO-H563ZI image against pinned wolfIP and wolfBoot trees; and the Cortex-M33 footprint of every profile against tools/size/BUDGET, with line coverage of src/ as an artifact.

Security notes

  • TLS is refused unless the server certificate can be checked: the RendezvousInfo certificate hash, a pin set with wolfFDO_NetTlsSetPin, or a CA set with wolfFDO_NetTlsSetCa (the host is then matched against the certificate's name or IP entries; IP matching needs wolfSSL built with WOLFSSL_IP_ALT_NAME). allowUnverified in WOLFFDO_NET_TLS is for development only.
  • requireKexSuite and requireCipher make the device refuse an Owner that does not offer its preferred suite; without them it takes what the Owner offers from its own list, and an FDO 1.1 Owner never gets a post-quantum suite.
  • fdo.command runs whatever the Owner sends; put wolfFDO_CmdAllow with an allow-list in front of the runner, as examples/onboard does (it allows date and echo).
  • fdo.wget connects wherever the Owner's URL points, hosts on the device's own network included, unless wolfFDO_WgetSetAllow sets a check; an https URL is only as trusted as the TLS transport given to wolfFDO_WgetInit (a plain socket fetches http only).
  • fdo.upload sends any file its WOLFFDO_UL_SOURCE agrees to open, and fdo.download and fdo.wget write under the name the Owner sends; the source and sink decide what is reachable (in examples/ the source serves one directory and refuses path separators, . and .., and the sink keeps only the last path component).
  • The session key exchange follows go-fdo for the order of the two randoms in ShSe (the Owner's first in FDO 2.0, the device's first in 1.1; section 3.7.3 of the 2.0 text still reads as the 1.1 order) and uses HMAC-SHA256 in the KDF for both AES-GCM suites, as go-fdo's cipher table does.
  • A delegate certificate's validity dates are not checked (no clock on the device); its chain, the permission OIDs and the Owner's signature are.
  • An ErrorMessage with code 7 (WOLFFDO_EC_SWITCH_VERSION) is reported to the application as WOLFFDO_E_PEER; the credential fixes the protocol version, so switching is the manufacturer's decision at DI.
  • WOLFFDO_NO_ERROR_REPORT keeps the device quiet about why it stopped, which the specification allows.

Limitations and future work

The specification asks a device to support one combination of each choice (sections 1.7.5 and 1.7.6); these are the ones wolfFDO does not offer yet.

  • TO2 session encryption is AES-128-GCM or AES-256-GCM. The AES-CCM suites are planned; the Encrypt-then-MAC suites (AES-CTR or AES-CBC with HMAC), which the specification calls legacy, are not.
  • No ASYMKEX2048 or ASYMKEX3072 key exchange, and no RSA device attestation (the device signs with ECDSA or HashML-DSA-65; RSA Owner keys are supported).
  • Owner keys are taken in X.509 encoding only; the X5CHAIN and COSEKEY encodings are refused.
  • RendezvousInfo: RVUserInput directives are skipped, and the Wi-Fi, medium, client certificate and external RV instructions are ignored. HTTP and HTTPS only (no CoAP), and no rvserver.local discovery over mDNS.
  • HashML-DSA-65 attestation uses a private-use COSE algorithm identifier with a SHA-256 pre-hash, so only Owners that know wolfFDO's profile verify it.
  • fdo.csr is not implemented. An fdo.download cut short by a lost connection starts again from the first byte on the retried TO2, since the module carries no offset.
  • The go-fdo interoperability run needs go-fdo's FDO 2.0 pull request 285 plus tools/interop/go-fdo-pr285.patch (tools/interop/README.md).
  • The NUCLEO-H563ZI example needs wolfBoot with examples/stm32h563/wolfboot_ns_data.patch until wolfBoot pull request 1023, which adds the same SAU window, is merged. The TPM 2.0 backend is tested on the Raspberry Pi 5 and swtpm, not on that board yet.
  • Planned examples: the Infineon PSoC 6, and a TPM 2.0 on the NUCLEO-H563ZI.

Footprint

make -C tools/size report for the Cortex-M33 ES256 profile (-Os, FDO 2.0 only, no delegation, fdo.download, no fdo.command), bytes:

Component Flash
wolfFDO 24,969
wolfCOSE 7,713
wolfCrypt (P-256, SHA-256/384, AES-GCM, HMAC, DRBG) 50,309
whole image with the reference application 84,705

sizeof(WOLFFDO_CTX) is 4,680 bytes and the application's static RAM 10,060 bytes, message buffer included. tools/size/BUDGET holds every profile.

The NUCLEO-H563ZI agent (arm-none-eabi-size, GCC 13.2, and the agent's own report over the console after an onboarding with fdo.download against go-fdo -insecure-tls, whose certificate is ECDSA P-384):

Build Text Data + bss Heap peak Stack used
plain HTTP 132,044 165,704 none not measured
TLS=1 207,204 167,864 12,360 5,712 of 16,384

The heap peak is newlib's arena after the run; the stack figure is the painted region the run overwrote.

Layout

  • include/wolffdo/wolffdo.h the application API: callbacks, credential, transport, WOLFFDO_CTX with wolfFDO_DI, wolfFDO_TO1, wolfFDO_TO2 and wolfFDO_Onboard
  • include/wolffdo/types.h protocol constants and wire types with their CBOR encoders and decoders; include/wolffdo/crypto.h hashing, KDF, key exchange, EAT and COSE helpers. These are exported for tests, tools and custom modules; until 1.0 they may change between releases, while wolffdo.h and the port/ headers are the stable API.
  • include/wolffdo/settings.h build-time sizes and options; include/wolffdo/port/ backend headers
  • docs/ the Doxygen configuration and main page of the API reference (make doc)
  • src/fdo_cbor.c byte-string wrapping and bounded decode helpers over the wolfCOSE CBOR API
  • src/fdo_types.c Hash, HMac, PublicKey, SigInfo, RendezvousInfo and ErrorMessage encoders and decoders
  • src/fdo_crypto.c hash, HMAC and the SP 800-108 counter-mode KDF
  • src/fdo_cose.c COSE_Sign1 built and verified from a streamed Sig_structure digest, domain separation, RSA signature verification
  • src/fdo_eat.c Entity Attestation Token for TO1 and TO2
  • src/fdo_kex.c ECDH, DH and ML-KEM key exchange
  • src/fdo_cred.c credential blob encode, decode and the two-slot store
  • src/fdo_http.c HTTP client for the FDO message transport
  • src/fdo_msg.c message posting, ErrorMessage mapping, error strings and the log callback
  • src/fdo_rv.c RendezvousInfo interpretation
  • src/fdo_di.c, src/fdo_to1.c Device Initialize and Transfer Ownership 1
  • src/fdo_to2.c (hello, attestation, run loop), src/fdo_to2_ovhdr.c (voucher header and entry chain), src/fdo_to2_svcinfo.c (ServiceInfo), src/fdo_to2_setup.c (SetupDevice, replacement credential, Done), src/fdo_to2_v11.c (the FDO 1.1 messages) Transfer Ownership 2
  • src/fdo_delegate.c delegate chain verification
  • src/fdo_sim_download.c, src/fdo_sim_upload.c, src/fdo_sim_wget.c, src/fdo_sim_command.c the fdo.download, fdo.upload, fdo.wget and fdo.command modules
  • src/fdo.c the device agent context: configuration, credential, and the flows run from the credential's RendezvousInfo and the rendezvous blob
  • src/port/ key, credential, transport, sink and runner backends
  • examples/ di, to1, onboard, fdo_tpm, onboard_wolfboot, with shared helpers in common.c; examples/stm32h563/ the NUCLEO-H563ZI agent
  • tests/ unit tests, the mock Owner and the captured go-fdo vectors; tests/fuzz/ libFuzzer harnesses
  • tools/size/ Cortex-M footprint build and budget; tools/interop/ go-fdo matrix; tools/vectors/ vector regeneration; config/ the host and Cortex-M profiles; sources.mk the source lists

License

wolfFDO is licensed under the GNU General Public License version 3 or later; see LICENSE. Commercial licensing is available from wolfSSL Inc.

About

Embedded FIDO Device Onboard (FDO) 2.0 device agent in C. DI, TO1 and TO2 over HTTP/CBOR with wolfCOSE, no dynamic allocation, pluggable credential and key backends (software, TPM 2.0), fdo.download straight into a wolfBoot update partition. Post-quantum key exchange and attestation as an extension.

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages