Skip to main content

SecretKey

Struct SecretKey 

Source
pub struct SecretKey<'a> { /* private fields */ }
Expand description

A symmetric secret key used with the BLAKE3, HS256, HS384, and HS512 algorithms.

The key is borrowed, so it must outlive any signing or verification.

Signing and verification fail with Error::InvalidKey if algorithm is not one of the supported MAC algorithms, if a BLAKE3 key is not exactly 32 bytes long, or if an HMAC key is shorter than 16 bytes (128 bits).

Implementations§

Source§

impl<'a> SecretKey<'a>

Source

pub fn new(algorithm: Algorithm, key: &'a [u8]) -> Self

Creates a new SecretKey for algorithm.

Trait Implementations§

Source§

impl From<&SecretKey<'_>> for Jwk

Source§

fn from(key: &SecretKey<'_>) -> Self

Converts to this type from the input type.
Source§

impl Signer for SecretKey<'_>

Source§

fn sign(&self, message: &[u8]) -> Result<Signature, Error>

Source§

fn algorithm(&self) -> Algorithm

Source§

impl<'a> TryFrom<&'a Jwk> for SecretKey<'a>

Source§

type Error = Error

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

fn try_from(jwk: &'a Jwk) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Verifier for SecretKey<'_>

Source§

fn verify(&self, message: &[u8], signature: &[u8]) -> Result<(), Error>

Source§

fn algorithm(&self) -> Algorithm

Auto Trait Implementations§

§

impl<'a> Freeze for SecretKey<'a>

§

impl<'a> RefUnwindSafe for SecretKey<'a>

§

impl<'a> Send for SecretKey<'a>

§

impl<'a> Sync for SecretKey<'a>

§

impl<'a> Unpin for SecretKey<'a>

§

impl<'a> UnsafeUnpin for SecretKey<'a>

§

impl<'a> UnwindSafe for SecretKey<'a>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.