Skip to main content

Crate hmac_sha256_sign

Crate hmac_sha256_sign 

Source
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§

HmacSha256Key
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.
SignedTokenCodec
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 input into 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 to 255 * 32 = 8160 bytes).
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 counter with digits (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_secs with period_secs and digits.
verify_totp_sha256
Verifies an RFC 6238 TOTP-SHA256 code allowing skew_steps time-step tolerance on each side.