Skip to main content

SymmetricKey

Enum SymmetricKey 

Source
#[non_exhaustive]
pub enum SymmetricKey { Hs256(Hs256Key), Hs384(Hs384Key), Hs512(Hs512Key), }

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Hs256(Hs256Key)

§

Hs384(Hs384Key)

§

Hs512(Hs512Key)

Implementations§

Source§

impl SymmetricKey

Source

pub fn new_for_alg( key: Vec<u8>, alg: &JsonWebSignatureAlg, ) -> Result<Self, InvalidAlgorithm>

Create a new symmetric key for the given algorithm with the given key.

§Errors

Returns an error if the algorithm is not supported.

Source

pub const fn hs256(key: Vec<u8>) -> Self

Create a new symmetric key using the HS256 algorithm with the given key.

Source

pub const fn hs384(key: Vec<u8>) -> Self

Create a new symmetric key using the HS384 algorithm with the given key.

Source

pub const fn hs512(key: Vec<u8>) -> Self

Create a new symmetric key using the HS512 algorithm with the given key.

Auto Trait Implementations§

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<S, T> AsyncRandomizedSigner<S> for T
where T: RandomizedSigner<S>,

Source§

async fn try_sign_with_rng_async<R>( &self, rng: &mut R, msg: &[u8], ) -> Result<S, Error>
where R: TryCryptoRng + ?Sized,

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
Source§

async fn sign_with_rng_async<R>(&self, rng: &mut R, msg: &[u8]) -> S
where R: CryptoRng + ?Sized,

Sign the given message and return a digital signature. Read more
Source§

impl<S, T> AsyncSigner<S> for T
where T: Signer<S>,

Source§

async fn sign_async(&self, msg: &[u8]) -> Result<S, Error>

Attempt to sign the given message, returning a digital signature on success, or an error if something went wrong. Read more
Source§

impl<S, T> AsyncVerifier<S> for T
where T: Verifier<S>,

Source§

async fn verify_async(&self, msg: &[u8], signature: &S) -> Result<(), Error>

Asynchronously verify that the provided signature for a given message bytestring is authentic. 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> ErasedDestructor for T
where T: 'static,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<S, T> RandomizedSignerMut<S> for T
where T: RandomizedSigner<S>,

Source§

fn try_sign_with_rng<R>(&mut self, rng: &mut R, msg: &[u8]) -> Result<S, Error>
where R: TryCryptoRng + ?Sized,

Attempt to sign the given message, updating the state, and returning a digital signature on success, or an error if something went wrong. Read more
Source§

fn sign_with_rng<R>(&mut self, rng: &mut R, msg: &[u8]) -> S
where R: CryptoRng + ?Sized,

Sign the given message, update the state, and return a digital signature. Read more
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.