Struct Hmac

Source
pub struct Hmac<D> { /* private fields */ }
Available on crate feature hmac only.
Expand description

The HMAC algorithm as used when signing a JWS.

This type exists to associate the original key value with the digest. This is required for verification, and for the jwk field in the JWS header, if that field is enabled.

Implementations§

Source§

impl<D> Hmac<D>

Source

pub fn new(key: HmacKey) -> Self

Create a new HMAC digest wrapper with a given signing key.

Signing keys are arbitrary bytes.

Source

pub fn key(&self) -> &HmacKey

Reference to the HMAC key.

Trait Implementations§

Source§

impl<D> Clone for Hmac<D>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Debug> Debug for Hmac<D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<D> DeserializeJWK for Hmac<D>

Source§

fn build(parameters: BTreeMap<String, Value>) -> Result<Self, JsonWebKeyError>

From a set of parameters, build a key.
Source§

fn from_jwk(jwk: &JsonWebKey) -> Result<Self, JsonWebKeyError>

Build a concrete key type from JsonWebKey.
Source§

fn from_value(value: Value) -> Result<Self, JsonWebKeyError>

Deserialize a concrete key type from a JSON value.
Source§

fn from_str(s: &str) -> Result<Self, JsonWebKeyError>

Deserialize a concrete key type from a JSON string.
Source§

impl<D> JWKeyType for Hmac<D>

Source§

const KEY_TYPE: &'static str = "oct"

The string used to identify the JWK type in the kty field.
Source§

impl JsonWebAlgorithm for Hmac<Sha256>

Source§

const IDENTIFIER: AlgorithmIdentifier = crate::algorithms::AlgorithmIdentifier::HS256

The identifier for this algorithm when used in a JWT registered header. Read more
Source§

impl JsonWebAlgorithm for Hmac<Sha512>

Source§

const IDENTIFIER: AlgorithmIdentifier = crate::algorithms::AlgorithmIdentifier::HS512

The identifier for this algorithm when used in a JWT registered header. Read more
Source§

impl JsonWebAlgorithm for Hmac<Sha384>

Source§

const IDENTIFIER: AlgorithmIdentifier = crate::algorithms::AlgorithmIdentifier::HS384

The identifier for this algorithm when used in a JWT registered header. Read more
Source§

impl<D> Keypair for Hmac<D>

Source§

type VerifyingKey = Hmac<D>

Verifying key type for this keypair.
Source§

fn verifying_key(&self) -> Self::VerifyingKey

Get the verifying key which can verify signatures produced by the signing key portion of this keypair.
Source§

impl<D> SerializeJWK for Hmac<D>

Source§

fn parameters(&self) -> Vec<(String, Value)>

Return a list of parameters to be serialized in the JWK.
Source§

impl<D> TokenSigner<DigestSignature<D>> for Hmac<D>

Source§

fn try_sign_token( &self, header: &str, payload: &str, ) -> Result<DigestSignature<D>, Error>

Sign the contents of the JWT, when provided with the base64url-encoded header and payload. The header and payload are already serialized to JSON and then base64url-encoded, so this function should not perform any additional encoding. Read more
Source§

fn sign_token(&self, header: &str, payload: &str) -> S

Sign the contents of the JWT, when provided with the base64url-encoded header and payload. See TokenSigner::try_sign_token for more details. Read more
Source§

impl<D> TokenSigner for Hmac<D>

Source§

fn try_sign_token( &self, header: &str, payload: &str, ) -> Result<SignatureBytes, Error>

Sign the contents of the JWT, when provided with the base64url-encoded header and payload. The header and payload are already serialized to JSON and then base64url-encoded, so this function should not perform any additional encoding. Read more
Source§

fn sign_token(&self, header: &str, payload: &str) -> S

Sign the contents of the JWT, when provided with the base64url-encoded header and payload. See TokenSigner::try_sign_token for more details. Read more
Source§

impl<D> TokenVerifier<DigestSignature<D>> for Hmac<D>

Source§

fn verify_token( &self, header: &[u8], payload: &[u8], signature: &[u8], ) -> Result<DigestSignature<D>, Error>

Verify the signature of the JWT, when provided with the base64url-encoded header and payload, along side the signature. The header and payload are already encoded, so this function should not perform any additional encoding. Read more
Source§

impl<D> TokenVerifier for Hmac<D>

Source§

fn verify_token( &self, header: &[u8], payload: &[u8], signature: &[u8], ) -> Result<SignatureBytes, Error>

Verify the signature of the JWT, when provided with the base64url-encoded header and payload, along side the signature. The header and payload are already encoded, so this function should not perform any additional encoding. Read more

Auto Trait Implementations§

§

impl<D> Freeze for Hmac<D>

§

impl<D> RefUnwindSafe for Hmac<D>
where D: RefUnwindSafe,

§

impl<D> Send for Hmac<D>
where D: Send,

§

impl<D> Sync for Hmac<D>
where D: Sync,

§

impl<D> Unpin for Hmac<D>
where D: Unpin,

§

impl<D> UnwindSafe for Hmac<D>
where D: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynJsonWebAlgorithm for T

Source§

fn identifier(&self) -> AlgorithmIdentifier

The identifier for this algorithm when used in a JWT registered header.
Source§

impl<T> DynJwkKeyType for T
where T: JWKeyType,

Source§

fn key_type(&self) -> &'static str

The string used to identify the JWK type in the kty field.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,