[][src]Trait jwt_compact::Algorithm

pub trait Algorithm {
    type SigningKey;
    type VerifyingKey;
    type Signature: AlgorithmSignature;
    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; }

JWT signing algorithm.

Associated Types

type SigningKey

Key used when issuing new tokens.

type VerifyingKey

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

type Signature: AlgorithmSignature

Signature produced by the algorithm.

Loading content...

Required methods

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

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

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

Signs a message with the signing_key.

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

Verifies the message against the signature and verifying_key.

Loading content...

Implementors

impl Algorithm for Ed25519[src]

type SigningKey = SecretKey

type VerifyingKey = PublicKey

type Signature = Signature

impl Algorithm for Hs256[src]

type SigningKey = Hs256Key

type VerifyingKey = Hs256Key

type Signature = MacResult<U32>

impl Algorithm for Hs384[src]

type SigningKey = Hs384Key

type VerifyingKey = Hs384Key

type Signature = MacResult<U48>

impl Algorithm for Hs512[src]

type SigningKey = Hs512Key

type VerifyingKey = Hs512Key

type Signature = MacResult<U64>

impl<A: Algorithm> Algorithm for Renamed<A>[src]

type SigningKey = A::SigningKey

type VerifyingKey = A::VerifyingKey

type Signature = A::Signature

impl<D> Algorithm for Es256k<D> where
    D: Digest<OutputSize = U32> + Default
[src]

type SigningKey = SecretKey

type VerifyingKey = PublicKey

type Signature = Signature

Loading content...