Trait jwt_compact::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§
sourcetype SigningKey
type SigningKey
Key used when issuing new tokens.
sourcetype VerifyingKey
type VerifyingKey
Key used when verifying tokens. May coincide with Self::SigningKey
for symmetric
algorithms (e.g., HS*
).
sourcetype Signature: AlgorithmSignature
type Signature: AlgorithmSignature
Signature produced by the algorithm.
Required Methods§
sourcefn name(&self) -> Cow<'static, str>
fn name(&self) -> Cow<'static, str>
Returns the name of this algorithm, as mentioned in the alg
field of the JWT header.
sourcefn sign(
&self,
signing_key: &Self::SigningKey,
message: &[u8],
) -> Self::Signature
fn sign( &self, signing_key: &Self::SigningKey, message: &[u8], ) -> Self::Signature
Signs a message
with the signing_key
.
sourcefn verify_signature(
&self,
signature: &Self::Signature,
verifying_key: &Self::VerifyingKey,
message: &[u8],
) -> bool
fn verify_signature( &self, signature: &Self::Signature, verifying_key: &Self::VerifyingKey, message: &[u8], ) -> bool
Verifies the message
against the signature
and verifying_key
.