Skip to main content

Key

Enum Key 

Source
pub enum Key {
    Blake3(Blake3Key),
    HmacSha256(HmacSha256Key),
    HmacSha512(HmacSha512Key),
    Ed25519Secret(Ed25519SecretKey),
    Ed25519Public(Ed25519PublicKey),
    P256Secret(P256SecretKey),
    P256Public(P256PublicKey),
    RsaPublic(Box<RsaPublicKey>),
}
Expand description

A concrete cryptographic key extracted from and that can be converted to a Jwk.

Use Key::try_from(&Jwk) to convert a Jwk (e.g. from a JWKS endpoint) into a key without knowing the exact key type at compile time. The result can be passed directly to crate::parse_and_verify or crate::sign.

Use [Key::into](Jwk) to convert a Key into a Jwk.

RsaPublicKeys require heap-allocation to avoid bloating the enum, as RSA should now be deprecated.

Variants§

§

Blake3(Blake3Key)

§

HmacSha256(HmacSha256Key)

§

HmacSha512(HmacSha512Key)

§

Ed25519Secret(Ed25519SecretKey)

§

Ed25519Public(Ed25519PublicKey)

§

P256Secret(P256SecretKey)

§

P256Public(P256PublicKey)

§

RsaPublic(Box<RsaPublicKey>)

Trait Implementations§

Source§

impl From<&Key> for Jwk

Source§

fn from(key: &Key) -> Self

Converts to this type from the input type.
Source§

impl Signer for Key

Source§

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

Source§

fn algorithm(&self) -> Algorithm

Source§

impl TryFrom<&Jwk> for Key

Source§

type Error = Error

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

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

Performs the conversion.
Source§

impl Verifier for Key

Source§

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

Source§

fn algorithm(&self) -> Algorithm

Auto Trait Implementations§

§

impl Freeze for Key

§

impl RefUnwindSafe for Key

§

impl Send for Key

§

impl Sync for Key

§

impl Unpin for Key

§

impl UnsafeUnpin for Key

§

impl UnwindSafe for Key

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 = 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.