Skip to main content

account_key

Function account_key 

Source
fn account_key(
    identity_id: &str,
    origin: &str,
    realm: &str,
    is_proxy: bool,
) -> String
Expand description

Build the keychain account string for one (identity, protection-space) pair. Deliberately NOT naive :-concatenation of the raw fields — origin itself contains : (https://host:8443) and realm is server-supplied, effectively attacker-influenced, free text, so two different (origin, realm) pairs could otherwise concatenate to the same string (e.g. origin="https://a:1" + realm="b" vs origin="https://a" + realm="1:b"). Hashing a NUL-separated tuple removes any field-boundary ambiguity — NUL can’t appear in either field in practice, but even if it could, the hash input’s own delimiter collision risk is the same NUL-in-a-field edge case for both operands, which cancels out (unlike :, which is valid content in origin).

identity_id is kept as a literal prefix (not folded into the hash) so a corrupted/missing hash can’t accidentally resolve under a different identity, and so the account string stays legible in diagnostic contexts (e.g. keyring-crate error messages) without revealing the origin/realm themselves — only which identity owns the entry.