Struct HS256

Source
pub struct HS256 { /* private fields */ }
Available on crate feature hmac-sha2 only.
Expand description

HMAC using SHA2-256.

This algorithm is required to be implemented (i.e. available) according to section 3.1 of RFC 7518, but jwt2 does not enforce this requirement. In the terms of RFCs this crate treats HS256’s “Required” as a “Recommended”.

Implementations§

Source§

impl HS256

Source

pub fn new(key: &[u8]) -> Result<Self, ConstructError>

Creates a HS256 instance.

See the security considerations of this module.

Source§

impl HS256

Source

pub fn generate_key<R>(rng: &mut R) -> Vec<u8>
where R: CryptoRngCore,

Available on crate feature rand only.

Generates a suitable key for this algorithm.

Trait Implementations§

Source§

impl JwsSigner for HS256

Source§

fn sign(&self, data: &[u8]) -> Vec<u8>

Creates a signature for data.
Source§

impl JwsVerifier for HS256

Source§

fn verify_signature(&self, data: &[u8], signature: &[u8]) -> bool

Verifies that signature is a valid signature for data. Read more
Source§

impl RecommendHeaderParams for HS256

Source§

fn alg(&self) -> Algorithm

Recommends an algorithm.
Source§

fn kid(&self) -> Option<&str>

Recommends a key ID. See crate::util::WithKeyId.
Source§

impl ValidateHeaderParams for HS256

Source§

fn validate_header(&self, header: &Header) -> bool

Check that the header is supported by this verifier.

Auto Trait Implementations§

§

impl Freeze for HS256

§

impl RefUnwindSafe for HS256

§

impl Send for HS256

§

impl Sync for HS256

§

impl Unpin for HS256

§

impl UnwindSafe for HS256

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> 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, 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