Skip to main content

derive_keys_from_salted

Function derive_keys_from_salted 

Source
pub fn derive_keys_from_salted(
    mechanism: SaslMechanism,
    salted: &[u8],
) -> (Vec<u8>, Vec<u8>)
Expand description

Reconstruct (stored_key, server_key) from the salted-password output the client sends in an AlterUserScramCredentialsRequest per KIP-554.

The KIP places PBKDF2 on the client side. The wire request carries the already-stretched PBKDF2 output, which is 32 bytes for SHA-256 and 64 bytes for SHA-512, and the broker derives the two stored keys from it. This keeps the broker from holding the raw password even briefly. The transformation, for each hash H, is:

client_key  = HMAC-H(salted_password, "Client Key")
stored_key  = H(client_key)
server_key  = HMAC-H(salted_password, "Server Key")

The mechanism argument selects which H to use. This function panics on a non-SCRAM mechanism.

ยงPanics

Panics if validated key material has an impossible size or synchronized credential state is poisoned.