pub enum HmacSpec {
Hs256,
Hs384,
Hs512,
}Expand description
Specification for HMAC secret generation.
Variants§
Implementations§
Source§impl HmacSpec
impl HmacSpec
Sourcepub fn hs256() -> HmacSpec
pub fn hs256() -> HmacSpec
HS256 (HMAC-SHA256). Produces a 32-byte secret.
§Examples
use uselesskey_core_hmac_spec::HmacSpec;
let spec = HmacSpec::hs256();
assert_eq!(spec.byte_len(), 32);Sourcepub fn hs384() -> HmacSpec
pub fn hs384() -> HmacSpec
HS384 (HMAC-SHA384). Produces a 48-byte secret.
§Examples
use uselesskey_core_hmac_spec::HmacSpec;
let spec = HmacSpec::hs384();
assert_eq!(spec.byte_len(), 48);Sourcepub fn hs512() -> HmacSpec
pub fn hs512() -> HmacSpec
HS512 (HMAC-SHA512). Produces a 64-byte secret.
§Examples
use uselesskey_core_hmac_spec::HmacSpec;
let spec = HmacSpec::hs512();
assert_eq!(spec.byte_len(), 64);Sourcepub fn alg_name(&self) -> &'static str
pub fn alg_name(&self) -> &'static str
JOSE/JWT alg name for this HMAC algorithm.
§Examples
use uselesskey_core_hmac_spec::HmacSpec;
assert_eq!(HmacSpec::hs256().alg_name(), "HS256");Sourcepub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
Secret length, in bytes.
§Examples
use uselesskey_core_hmac_spec::HmacSpec;
assert_eq!(HmacSpec::hs256().byte_len(), 32);
assert_eq!(HmacSpec::hs384().byte_len(), 48);
assert_eq!(HmacSpec::hs512().byte_len(), 64);Sourcepub fn stable_bytes(&self) -> [u8; 4]
pub fn stable_bytes(&self) -> [u8; 4]
Stable encoding for cache keys / deterministic derivation.
If you change this, bump the derivation version in uselesskey-core.
§Examples
use uselesskey_core_hmac_spec::HmacSpec;
let bytes = HmacSpec::hs256().stable_bytes();
assert_eq!(bytes.len(), 4);Trait Implementations§
impl Copy for HmacSpec
impl Eq for HmacSpec
impl StructuralPartialEq for HmacSpec
Auto Trait Implementations§
impl Freeze for HmacSpec
impl RefUnwindSafe for HmacSpec
impl Send for HmacSpec
impl Sync for HmacSpec
impl Unpin for HmacSpec
impl UnsafeUnpin for HmacSpec
impl UnwindSafe for HmacSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more