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.
Implementors§
Source§impl Algorithm for Ed25519
Available on crate feature exonum-crypto only.
impl Algorithm for Ed25519
Available on crate feature
exonum-crypto only.type SigningKey = SecretKey
type VerifyingKey = PublicKey
type Signature = Signature
Source§impl Algorithm for Es256
Available on crate feature p256 only.
impl Algorithm for Es256
Available on crate feature
p256 only.type SigningKey = SigningKey<NistP256>
type VerifyingKey = VerifyingKey<NistP256>
type Signature = Signature<NistP256>
Source§impl Algorithm for Hs256
impl Algorithm for Hs256
type SigningKey = Hs256Key
type VerifyingKey = Hs256Key
type Signature = Hs256Signature
Source§impl Algorithm for Hs384
impl Algorithm for Hs384
type SigningKey = Hs384Key
type VerifyingKey = Hs384Key
type Signature = Hs384Signature
Source§impl Algorithm for Hs512
impl Algorithm for Hs512
type SigningKey = Hs512Key
type VerifyingKey = Hs512Key
type Signature = Hs512Signature
Source§impl Algorithm for Rsa
Available on crate feature rsa only.
impl Algorithm for Rsa
Available on crate feature
rsa only.