Expand description
hmac-sha256-sign
Zero-dependency pure-Rust SHA-256, precomputed-midstate HMAC-SHA256, RFC 5869 HKDF-SHA256, constant-time equality, Base64URL, signed tokens, and RFC 4226/6238 HOTP/TOTP.
Structs§
- Hmac
Sha256 Key - Precomputed-midstate HMAC-SHA256 key avoiding per-message ipad/opad block compression.
- Sha256
- Streaming FIPS 180-4 SHA-256 hasher with cloneable midstate for HMAC precomputation.
- Signed
Token Codec - Stateless expiring HMAC-SHA256 token signer and verifier (
<payload_b64>.<exp_unix>.<sig_b64>).
Constants§
- SHA256_
BLOCK_ LEN - SHA-256 block size in bytes (
64). - SHA256_
DIGEST_ LEN - SHA-256 digest length in bytes (
32).
Functions§
- base64url_
decode - Decodes an unpadded (or
=-padded) RFC 4648 Base64URL string. - base64url_
decode_ bytes - Decodes UTF-8 Base64URL byte input into raw bytes.
- base64url_
encode - Encodes
inputinto unpadded RFC 4648 Base64URL text. - constant_
time_ eq - Performs constant-time byte-slice equality comparison without early exit on mismatches.
- hex_
decode - Decodes a hexadecimal string into bytes (case-insensitive).
- hex_
encode - Encodes a byte slice as lowercase hexadecimal text.
- hkdf_
sha256 - One-shot RFC 5869 HKDF-SHA256 Extract + Expand derivation.
- hkdf_
sha256_ expand - Performs the RFC 5869 HKDF-Expand step into
out(up to255 * 32 = 8160bytes). - hkdf_
sha256_ extract - Performs the RFC 5869 HKDF-Extract step using HMAC-SHA256.
- hmac_
sha256 - Computes a one-shot RFC 2104 / RFC 4231 HMAC-SHA256 tag.
- hotp_
sha256 - Computes an RFC 4226 HOTP-SHA256 one-time code for
counterwithdigits(6..=9). - sha256
- Computes the one-shot FIPS 180-4 SHA-256 digest of
data. - totp_
sha256 - Computes an RFC 6238 TOTP-SHA256 one-time code at
unix_secswithperiod_secsanddigits. - verify_
totp_ sha256 - Verifies an RFC 6238 TOTP-SHA256 code allowing
skew_stepstime-step tolerance on each side.