jwt_compact

Trait Algorithm

Source
pub trait Algorithm {
    type SigningKey;
    type VerifyingKey;
    type Signature: AlgorithmSignature;

    // Required methods
    fn name(&self) -> Cow<'static, str>;
    fn sign(
        &self,
        signing_key: &Self::SigningKey,
        message: &[u8],
    ) -> Self::Signature;
    fn verify_signature(
        &self,
        signature: &Self::Signature,
        verifying_key: &Self::VerifyingKey,
        message: &[u8],
    ) -> bool;
}
Expand description

JWT signing algorithm.

Required Associated Types§

Source

type SigningKey

Key used when issuing new tokens.

Source

type VerifyingKey

Key used when verifying tokens. May coincide with Self::SigningKey for symmetric algorithms (e.g., HS*).

Source

type Signature: AlgorithmSignature

Signature produced by the algorithm.

Required Methods§

Source

fn name(&self) -> Cow<'static, str>

Returns the name of this algorithm, as mentioned in the alg field of the JWT header.

Source

fn sign( &self, signing_key: &Self::SigningKey, message: &[u8], ) -> Self::Signature

Signs a message with the signing_key.

Source

fn verify_signature( &self, signature: &Self::Signature, verifying_key: &Self::VerifyingKey, message: &[u8], ) -> bool

Verifies the message against the signature and verifying_key.

Implementors§

Source§

impl Algorithm for Ed25519

Source§

type SigningKey = SecretKey

Source§

type VerifyingKey = PublicKey

Source§

type Signature = Signature

Source§

impl Algorithm for Es256

Source§

type SigningKey = SigningKey<NistP256>

Source§

type VerifyingKey = VerifyingKey<NistP256>

Source§

type Signature = Signature<NistP256>

Source§

impl Algorithm for Hs256

Source§

impl Algorithm for Hs384

Source§

impl Algorithm for Hs512

Source§

impl Algorithm for Rsa

Source§

impl<A: Algorithm> Algorithm for Renamed<A>

Source§

impl<D> Algorithm for Es256k<D>
where D: FixedOutputReset<OutputSize = U32> + BlockSizeUser + Clone + Default + HashMarker,

Source§

impl<T: Algorithm> Algorithm for StrongAlg<T>