#crypto/hkdf
Xu 0.13.1 API
import: #crypto/hkdf
counts: 3 functions, 0 methods, 0 types, 0 constants, 0 method sets
HKDF (RFC 5869): HMAC-based Extract-and-Expand Key Derivation Function using SHA-256. Aligned with `.org/x/crypto/hkdf`. Key derivation proceeds in two steps 1. Extract: PRK = HMAC-Hash(salt, IKM) to extract a pseudorandom key. 2. Expand: OKM = HKDF-Expand(PRK, info, L) to expand to desired length.
expand
pub fn expand(prk &string, info &string, length int) string
Purpose
expand expands a pseudorandom key (PRK) with optional context info to length bytes. Maximum length is 255 * 32 = 8160 bytes per RFC 5869 §2.3. Throws on failure; handle the error or propagate it to the caller.
Parameters
prk &string- prk (read-only borrow; caller keeps the original; type &string)
info &string- info (read-only borrow; caller keeps the original; type &string)
length int- length (int)
Returns
string — result string
key
pub fn key(secret &string, salt &string, info &string, length int) string
Purpose
key derives length bytes from secret, salt, and info in a single call. Throws on failure; handle the error or propagate it to the caller.
Parameters
secret &string- secret (read-only borrow; caller keeps the original; type &string)
salt &string- salt (read-only borrow; caller keeps the original; type &string)
info &string- info (read-only borrow; caller keeps the original; type &string)
length int- length (int)
Returns
string — result string