KBKDF Key Derivation
The kitchen-sink key derivation node — NIST SP 800-108 counter mode
- message
- label
- context
- fixed
- derived_key
KBKDF_Derive is the most configurable - and easily the most intimidating - key derivation node in this pack. KBKDF (Key-Based Key Derivation) comes from NIST SP 800-108, and its counter mode works by repeatedly hashing a counter plus fixed data until enough bytes come out. Where HKDF is "give it a secret, get a key," KBKDF is "specify the counter width, its placement, the label, the context, and whether you want HMAC or CMAC underneath." It's the node you reach for when you need to match an exact key-derivation recipe - usually to interoperate with some existing system - rather than when you just want a key.
What all the inputs mean
The core KDF inputs are the familiar trio: message (BYTESLIKE, the input key material), length (16–256 bytes), and algorithm (the hash, 15 choices). Then it gets interesting:
operation_mode-KBKDFHMAC(HMAC-based, the sane default) orKBKDFCMAC(CMAC-based, using AES - only sensible if you specifically need CMAC).rlenandllen- the byte widths of the binary counter (rlen) and its length prefix (llen). Both default to 4 and are the "why is this even exposed?" fields of the node. You change them only to match an external specification; for everything else, leave them alone.location- where the counter bytes go:BeforeFixed,AfterFixed, orMiddleFixed.BeforeFixed(default) is the common case.break_location- only used withMiddleFixed: the byte offset inside the fixed data where the counter lands. Default 0.labelandcontext- application-specificBYTESLIKEfields, the NIST-sanctioned way to bind the derived key to a purpose and a usage context.fixed- an alternative: instead of separatelabelandcontext, you can supply one blob of fixed data. The tooltip is explicit: iffixedis set,labelandcontextare ignored.
The output
derived_key(BYTESLIKE) - the derived key bytes, wired into whatever consumer wants them.
Installing it
Part of the ComfyUI ARG Toolkit:
cd ComfyUI/custom_nodes
git clone https://github.com/AzelusLightvale/ComfyUI-ARG-Toolkit
Restart ComfyUI, or install via ComfyUI Manager ("ComfyUI ARG Toolkit") - cryptography provides the KBKDF implementation.
Where people get burned
- Over-configuring for no reason. Every one of
rlen,llen,location,break_location,label,contextis a chance to produce a key that doesn't match the other side. If you don't have an external spec to match, you shouldn't be touching half of these - and honestly, you probably shouldn't be using KBKDF at all. HKDF does the same job with a tenth of the knobs. fixedvslabel/context. Settingfixedsilently disables the other two. If you wire up all three expecting them to combine, you'll get thefixed-only derivation and wonder where the label went.- Mismatched recipe, silent
False. Unlike the derive nodes, there's no error when the recipe differs from what the verifier expects - you just get a key that doesn't match downstream.
Reach for KBKDF_Derive when a puzzle or system hands you a spec with "NIST SP 800-108" in it and you have to reproduce its exact output. For the 99% case - derive a key from a shared secret and move on - the pack's HKDF node is the one you'd actually reach for. This one is the specialist's tool, powerful, precise, and overkill for almost everything.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| length | INT | 3216–256 | The desired length of the derived key in bytes. |
| message | BYTESLIKE | The message to derive key from. Must be bytes. | |
| algorithm | COMBO | The algorithm to use for hash generation. | |
| rlen | INT | 4 | — |
| llen | INT | 4 | — |
| location | COMBO | BeforeFixed | The location to put the counter bytes. |
| operation_mode | COMBO | KBKDFHMAC | The operation mode to use. |
| labelopt | BYTESLIKE | Application-specific label information | |
| contextopt | BYTESLIKE | Application-specific context information | |
| fixedopt | BYTESLIKE | Instead of supplying `label` and `context`, you can supply fixed data in this field instead. Note that if this is specified, `label` and `context` will be ignored. | |
| break_locationopt | INT | 0 | When MiddleFixed is chosen as the counter location method, this field will be used to indicate the bytes offset where counter bytes are to be located. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| derived_key | BYTESLIKE | — |