Skip to main content

RustCryptoHmacExt

Trait RustCryptoHmacExt 

Source
pub trait RustCryptoHmacExt {
    // Required methods
    fn hmac_sha256(&self) -> Hmac<Sha256>;
    fn hmac_sha384(&self) -> Hmac<Sha384>;
    fn hmac_sha512(&self) -> Hmac<Sha512>;
}
Expand description

Extension trait to convert uselesskey HMAC fixtures into hmac::Hmac types.

§Examples

use uselesskey_core::Factory;
use uselesskey_hmac::{HmacFactoryExt, HmacSpec};
use uselesskey_rustcrypto::RustCryptoHmacExt;
use hmac::Mac;

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

let mut mac = secret.hmac_sha256();
mac.update(b"hello");
let result = mac.finalize();
assert_eq!(result.into_bytes().len(), 32);

Required Methods§

Source

fn hmac_sha256(&self) -> Hmac<Sha256>

Create an Hmac<Sha256> from the HMAC secret.

Source

fn hmac_sha384(&self) -> Hmac<Sha384>

Create an Hmac<Sha384> from the HMAC secret.

Source

fn hmac_sha512(&self) -> Hmac<Sha512>

Create an Hmac<Sha512> from the HMAC secret.

Implementations on Foreign Types§

Source§

impl RustCryptoHmacExt for HmacSecret

Available on crate feature hmac only.

Implementors§