imsys

Security providers and token keys

Choose a wake-up verifier and run the same authenticated CLS meter read with a file-backed key or a disposable PKCS#11 identity.

Supply a wake-up verifier

A commissioned gateway administrator has a public verification key. Implement BrainpoolP256Verifier for that key, or enable the openssl feature on smgw-sec and load a BrainpoolP256PublicKey. The provider verifies the original signed bytes with Brainpool P-256 and SHA-256. The gateway owns recipient selection, time checks, signature-attempt accounting and the replay watermark. The default provider contract builds on Cortex-M without a heap. Verification contract · OpenSSL verifier · Wake-up policy

Provision a CLS identity

Give TlsIdentity::new the leaf certificate, intermediates in issuer order and a provisioned OpenSSL private-key handle. For fixtures, TlsIdentity::from_pem reads a leaf-first chain and either a software key or the PKCS#11 provider's reference PEM. The reference contains a locator. The configured provider resolves it and asks the token to sign. Provision token login through the host's OpenSSL provider configuration. TLS identity API · Provider reference PEM

Pass the identity, trust anchor and expected peer leaf to TlsEndpoint::from_identity. The endpoint checks the local key matches the certificate, negotiates the CLS TLS profile and authenticates its peer. The gateway validates the HAN peer and authorizes its SNI route before dialing the WAN endpoint. CLS endpoint API · Connection walkthrough

Run the token-backed meter read

From the workspace root, use Rust 1.90 or later, Python 3, OpenSSL with Brainpool support, SoftHSM 2, OpenSC and the OpenSSL PKCS#11 provider. On Ubuntu the build prerequisites are build-essential git libssl-dev pkg-config openssl softhsm2 opensc meson ninja-build. On macOS install OpenSSL, SoftHSM, OpenSC, Meson, Ninja and pkg-config with Homebrew. Use the same OpenSSL installation for the CLI, Rust and the provider.

If the provider is already installed, run just token. To build the version used by CI locally, run these commands.

git clone --branch v1.3.0 --depth 1 https://github.com/openssl-projects/pkcs11-provider.git target/token-tools/source
meson setup target/token-tools/build target/token-tools/source
meson compile -C target/token-tools/build pkcs11
just token

The check looks for the provider in the OpenSSL modules directory and the local build above. For a different installation, set SMGW_PKCS11_PROVIDER to the provider library, SMGW_SOFTHSM_MODULE to SoftHSM's PKCS#11 library and SMGW_OPENSSL to the matching OpenSSL executable as needed.

Each run creates a private temporary token, generates a non-extractable Brainpool key and issues the HAN gateway certificate from its signed request. Both identities must read 1250 W through the ordinary HAN and WAN mutual-TLS connections. The check then substitutes an unrelated signing key and removes access to the token. Both attempts must fail. The temporary token, PIN and PKI are removed when the check finishes. This exercises PKCS#11 with a software token. Physical HSM interoperability requires testing the selected device, firmware and provider.