Skip to main content

Module join_token

Module join_token 

Source
Expand description

HMAC-SHA256 join-token issuance and constant-time verification.

Token format (opaque to callers, transmitted as hex):

[for_node: u64 LE | expiry_unix_secs: u64 LE | mac: 32 bytes]

The MAC is HMAC-SHA256 over for_node || expiry_unix_secs keyed by the cluster’s cluster_secret. Verification is constant-time via hmac::Mac::verify_slice (which uses the subtle crate internally).

The nodedb crate’s ctl::join_token module is a thin CLI wrapper that delegates issuance to issue_token here. Verification is consumed by the bootstrap-listener handler in nodedb/src/control/cluster/bootstrap_listener.rs.

Enums§

TokenError
Error returned by token operations.

Constants§

TOKEN_BYTE_LEN
Total token byte length before hex encoding.
TOKEN_HEADER_LEN
Number of bytes in the token header (for_node + expiry).
TOKEN_HEX_LEN
Expected hex string length of a token.
TOKEN_MAC_LEN
Number of bytes in the HMAC-SHA256 tag.

Functions§

issue_token
Convenience: issue a token and return it as a lowercase hex string.
issue_token_bytes
Issue a new HMAC-SHA256 join token for for_node that expires at expiry_unix_secs. Returns the raw token bytes (hex-encode for printing or transmission).
token_hash
Compute SHA-256 of the token bytes. Used as the stable identity for state-machine tracking (never stores the raw token).
token_to_hex
Encode raw token bytes as a lowercase hex string.
verify_token
Verify a hex-encoded token against secret. Returns the bound (for_node, expiry_unix_secs) on success.