uselesskey-hmac 0.5.1

HMAC HS256/HS384/HS512 secret fixtures for deterministic and random tests.
Documentation

uselesskey-hmac

Crates.io docs.rs License: MIT OR Apache-2.0

HMAC secret fixtures for testing — generates deterministic or random symmetric secrets for HS256, HS384, and HS512 workflows.

Part of the uselesskey workspace. Use the facade crate for the simplest experience, or depend on this crate directly for minimal compile time.

Usage

use uselesskey_core::Factory;
use uselesskey_hmac::{HmacFactoryExt, HmacSpec};

let fx = Factory::random();
let secret = fx.hmac("issuer", HmacSpec::hs256());

assert_eq!(secret.secret_bytes().len(), 32);

Specs

Constructor Algorithm Secret Length
HmacSpec::hs256() HMAC-SHA256 32 bytes
HmacSpec::hs384() HMAC-SHA384 48 bytes
HmacSpec::hs512() HMAC-SHA512 64 bytes

Deterministic Mode

use uselesskey_core::{Factory, Seed};
use uselesskey_hmac::{HmacFactoryExt, HmacSpec};

let seed = Seed::from_env_value("test-seed").unwrap();
let fx = Factory::deterministic(seed);

// Same seed + label + spec = same secret
let s1 = fx.hmac("issuer", HmacSpec::hs384());
let s2 = fx.hmac("issuer", HmacSpec::hs384());
assert_eq!(s1.secret_bytes(), s2.secret_bytes());

Features

Feature Description
jwk Octet JWK/JWKS output via uselesskey-jwk

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

See the uselesskey crate for full documentation.