Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
wolfhsm-src
Build-script crate that compiles wolfHSM
from C source as part of a Cargo build. Used internally by
wolfhsm-sys; has no public Rust API.
Why
Cargo cannot compile C libraries on behalf of an arbitrary crate — each
crate that links a C library needs a build.rs that drives the C
compiler. Splitting the C build into its own crate (the same pattern used
by wolfssl-src and wolftpm-src in
this workspace) keeps concerns separate:
wolfhsm-srcowns the C build — it can be versioned and replaced without touching the FFI or the safe Rust API.wolfhsm-sysowns the FFI boundary — bindgen runs there, consuming theDEP_WOLFHSM_SRC_*metadata emitted by this crate.wolfhsmowns the safe Rust API.links = "wolfhsm_src"prevents two copies of the wolfHSM static archive being linked into the same binary.
Usage
This crate is normally pulled in transitively via
wolfhsm-sys or wolfhsm. Add one of
those instead of depending on wolfhsm-src directly.
If you need to build a different FFI crate against the same wolfHSM
build, declare wolfhsm-src as a regular [dependency] (not a
[build-dependency]) so Cargo propagates the DEP_WOLFHSM_SRC_*
metadata to your build script:
[]
= "0.1"
Supplying the wolfHSM source
Two ways to provide the wolfHSM C source tree:
Environment variable (recommended for development):
Bundled submodule:
The submodule tracks the upstream wolfSSL/wolfHSM main branch.
Supplying wolfSSL headers
wolfHSM uses wolfSSL/wolfCrypt for all cryptographic operations. Supply the headers via any of:
| Variable | Description |
|---|---|
WOLFSSL_DIR |
Install prefix — headers at $WOLFSSL_DIR/include |
WOLFSSL_INCLUDE_DIR |
Direct path to the wolfSSL include directory |
WOLFSSL_SRC |
wolfSSL source tree root (vendored build) |
The pre-built wolfSSL must have been compiled with WOLF_CRYPTO_CB
enabled.
How it works
build.rs performs five steps:
- Locate wolfHSM source — checks
WOLFHSM_SRCfirst, then falls back to the bundled git submodule atwolfhsm-src/wolfhsm/. - Locate wolfSSL headers — checks
WOLFSSL_INCLUDE_DIR,WOLFSSL_DIR, thenWOLFSSL_SRCin that priority order (same as the rest of the workspace). - Generate
wolfhsm_cfg.hinOUT_DIR— wolfHSM'swh_settings.hunconditionally#includeswolfhsm_cfg.h. The generated file enables the POSIX time hook (WOLFHSM_CFG_PORT_GETTIME), client-side functionality (WOLFHSM_CFG_ENABLE_CLIENT), and CryptoCb support (WOLF_CRYPTO_CB). When thesheCargo feature is enabled it also definesWOLFHSM_CFG_SHE_EXTENSION. - Compile wolfHSM — uses the
cccrate to compile the client-side sources (wh_client.c,wh_client_crypto.c,wh_comm.c, message layer files, and more) together with the POSIX transport implementations (posix_transport_tcp.c,posix_transport_shm.c,posix_transport_uds.c) when present. - Emit Cargo metadata —
DEP_WOLFHSM_SRC_INCLUDE(wolfHSM source root) andDEP_WOLFHSM_SRC_LIB(directory holdinglibwolfhsm.aandwolfhsm_cfg.h) for consumption bywolfhsm-sys.
Features
| Feature | Description |
|---|---|
she |
Enable SHE (Secure Hardware Extension) AutoSAR automotive key management — defines WOLFHSM_CFG_SHE_EXTENSION in the generated wolfhsm_cfg.h. Requires WOLFSSL_AES_DIRECT and HAVE_AES_ECB in the linked wolfSSL. |
References
- wolfhsm-sys — bindgen-generated FFI built on top of this crate
- wolfhsm — safe Rust API
- wolfssl-src — sibling source-build crate for wolfSSL
- wolftpm-src — sibling source-build crate for wolfTPM
- wolfHSM repository
- wolfHSM documentation
- workspace README
Copyright
Copyright (C) 2006-2026 wolfSSL Inc.
wolfHSM is copyright wolfSSL Inc. and its contributors.
License
GPL-3.0-only OR LicenseRef-wolfSSL-commercial.
The underlying wolfHSM C library is licensed under GPL-3.0-or-later with a commercial option available from wolfSSL Inc.