HSM / PKCS#11 / SP 800-108 KDF

What you will do: Generate a local key shaped like an ETSI QKD 014 response and import it into the browser HSM. Compare SP 800-108 counter-mode derivations with the same session context and a one-bit change.

Worked example: Run the local HSM sample. Repeating the same inputs reproduces the key. Changing the session context gives a different key from the same imported secret and label.

Runtime and privacy: The cryptographic exercise runs in this browser. Review the site privacy terms before entering sensitive material; use synthetic inputs for learning and evaluation.

Browse all Crypto Lab tools · Learn with Quantum Key Distribution

For your role

Developer / Engineer
Press Fetch QKD Key to start from the ETSI QKD 014 REST step, then follow the SP 800-108 counter-mode derivation: the label and context inputs are what bind the derived key to one purpose, and the same call applies to a KEM shared secret or a PSK.
Security Architect
Read KBKDF vs HKDF — Choosing the Right KDF before the run: it says when SP 800-108 counter mode and when HKDF is the right choice for splitting one master secret into encryption, MAC and IV keys.
Researcher / Academic
Open What runs live vs. simulated? to see that the QKD retrieval is a modelled REST exchange while the derivation runs in the PKCS#11 log; the QKD/HSM PQC Known Answer Tests panel runs the KDF checks and labels each result with its evidence class.
Certification & Validation Engineer
Follow the SP 800-108 counter-mode derivation in the PKCS#11 log, then run the QKD/HSM PQC Known Answer Tests panel: each KDF check carries its evidence class, and What runs live vs. simulated? says the QKD retrieval is modelled.

Local sample workflow: key retrieval is simulated and browser WASM (SoftHSM3) is an educational sandbox, not a FIPS 140-3 / CMVP-validated production HSM. Successful optional PKCS#11 calls are separate from the walkthrough; no QKD network or second peer runs. The sample secret and any returned key bytes are visible in browser memory. This is not a non-exportability test.

Live HSM Mode Active

SoftHSM3 · PKCS#11 v3.2 · Rust · session open

Live WASM — real crypto

SP 800-108 Key Derivation — Beyond QKD

NIST SP 800-108 counter-mode KDF is a universal primitive used wherever a master secret must produce multiple purpose-specific keys. This demo uses QKD as the input source, but the same KDF applies to:

KEM Shared SecretsML-KEM encapsulation produces a 32-byte random secret. SP 800-108 derives encryption, MAC, and IV keys with domain separation (label + context).
Pre-Shared Keys (PSK)Protocol-specific PSK processing must follow the agreed profile. A generic KBKDF call is not a replacement for a TLS or IKE key schedule.
Password-Based (PBKDF2)CKM_PKCS5_PBKD2 derives key material from passwords. Often chained with SP 800-108 for key hierarchy (master → KEK → DEK).

KBKDF vs HKDF — Choosing the Right KDF

KBKDF (SP 800-108 Counter Mode)
Where: Inside the HSM — CKM_SP800_108_COUNTER_KDF
Input: A single fixed-length key handle (e.g., QKD master secret) already in HSM storage
Output: One or more purpose-specific sub-keys; this sample reads returned bytes into JavaScript
Use when: Key hierarchy expansion (master → KEK → DEK) must stay within the HSM security boundary
HKDF (RFC 5869)
Where: Software layer or HSM via CKM_HKDF_DERIVE (PKCS#11 v3.0)
Input: Variable-length IKM + optional salt (extract phase), then context info (expand phase)
Output: Arbitrary-length OKM; each caller context produces independent key material
Use when: TLS 1.3 key schedule, QUIC, or Signal — where IKM arrives from a DH/KEM exchange in software

Both mechanism support and key attributes depend on the actual tool and configuration. This sample imports an extractable session secret and reads derived bytes back into JavaScript. It does not establish that KBKDF or HKDF keeps keys inside a production HSM. Evaluate supported mechanisms, attributes, output policy and failure behavior in your own tools.

QKD scenario below: This demo follows the ETSI GS QKD 014 key retrieval API → PKCS#11 v3.0 HSM import → NIST SP 800-108 related key-derivation concepts. The network retrieval and second peer are not executed. Evaluate mutual authentication, delivered-key correlation, token attributes and actual protocol integration with production tools.

Local Sample Key Retrieval
Import into HSM
SP 800-108 Counter-Mode KDF
Session Key Output
Session Key Use

Step 1: Local Key-Delivery Illustration

Reference flow — not executed (ETSI GS QKD 014 §§5.1, 5.3–5.4)
POST /api/v1/keys/{slave_SAE_ID}/enc_keysPeer: POST /api/v1/keys/{master_SAE_ID}/dec_keys with delivered key_IDs

SAE and KME authenticate certificates and identities using mutual TLS before API use. A certificate is not an HTTP bearer token. This button only generates local random sample bytes and JSON; it contacts no key manager or QKD hardware.

QKD/HSM PQC Known Answer Tests

ETSI GS QKD 014 · NIST FIPS 198-1 (HMAC-SHA-256) · SP 800-108r1 + RFC 5869 (HKDF)

Click Run known-answer checks to run 2 use-case scenarios. Evidence in this set: NIST ACVP-Server reference sample — Expected values copied from the public NIST ACVP-Server repository with immutable source identity; Published standard KAT — Expected values printed in a cited standard or consensus RFC.

Reference samples from the public NIST ACVP-Server repository · ETSI GS QKD 014 · NIST FIPS 198-1 (HMAC-SHA-256) · SP 800-108r1 + RFC 5869 (HKDF) · Generated keys are for educational use only.

Production Tool Capabilities & Verification Requirements

What this sample check establishes: Demonstrates HKDF (RFC 5869), SP 800-108, and SP 800-56C / SP 800-227 key derivation combining classical ECDH and post-quantum ML-KEM shared secrets with context labels.

Browser sandbox limitation (non-certification boundary): Runs in browser WASM/WebCrypto; it does not enforce hardware key-isolation attributes on derived keys.

What to require and test in your production tools:

  • SP 800-227 / ETSI TS 103 744 compliant hybrid KDF combiner, preferably one that binds ciphertexts, encapsulation keys and a domain separator into the derivation (SP 800-227 §4.6.2).
  • HSM PKCS#11 v3.2 key derivation (`CKM_HKDF_DERIVE` / SP 800-108) keeping derived traffic/wrapping keys inside the HSM boundary when required.
  • Immediate zeroization of intermediate shared secrets (`Z_ecdh`, `Z_mlkem`) after key derivation.

Try it

  1. 1. Predict before you run it.
  2. 2. Run or change the tool above.
  3. 3. Explain what the result shows.

What binds the derived session key to its purpose in the SP 800-108 step?

Next step

Turn it into a plan: Infrastructure Modernization Planner

This tool practises the KMS & PQC Key Management module, phase 6 (Infrastructure & Performance); Infrastructure Modernization Planner produces a deliverable of that phase.