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

§

type SigningKey = SecretKey

§

type VerifyingKey = PublicKey

§

type Signature = Signature

source§

impl Algorithm for Es256

§

type SigningKey = SigningKey<NistP256>

§

type VerifyingKey = VerifyingKey<NistP256>

§

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>