pub enum SignatureAlgorithm {
Show 13 variants None, HS256, HS384, HS512, RS256, RS384, RS512, ES256, ES384, ES512, PS256, PS384, PS512,
}
Expand description

The algorithms supported for digital signature and MACs, defined by RFC7518#3.

Variants§

§

None

No encryption/signature is included for the JWT. During verification, the signature MUST BE empty or verification will fail.

§

HS256

HMAC using SHA-256

§

HS384

HMAC using SHA-384

§

HS512

HMAC using SHA-512

§

RS256

RSASSA-PKCS1-v1_5 using SHA-256

§

RS384

RSASSA-PKCS1-v1_5 using SHA-384

§

RS512

RSASSA-PKCS1-v1_5 using SHA-512

§

ES256

ECDSA using P-256 and SHA-256

§

ES384

ECDSA using P-384 and SHA-384

§

ES512

ECDSA using P-521 and SHA-512 – This variant is unsupported and will probably never be.

§

PS256

RSASSA-PSS using SHA-256 and MGF1 with SHA-256. The size of the salt value is the same size as the hash function output.

§

PS384

RSASSA-PSS using SHA-384 and MGF1 with SHA-384 The size of the salt value is the same size as the hash function output.

§

PS512

RSASSA-PSS using SHA-512 and MGF1 with SHA-512 The size of the salt value is the same size as the hash function output.

Implementations§

source§

impl SignatureAlgorithm

source

pub fn sign(self, data: &[u8], secret: &Secret) -> Result<Vec<u8>, Error>

Take some bytes and sign it according to the algorithm and secret provided.

source

pub fn verify( self, expected_signature: &[u8], data: &[u8], secret: &Secret ) -> Result<(), Error>

Verify signature based on the algorithm and secret provided.

Trait Implementations§

source§

impl Clone for SignatureAlgorithm

source§

fn clone(&self) -> SignatureAlgorithm

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SignatureAlgorithm

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for SignatureAlgorithm

source§

fn default() -> SignatureAlgorithm

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for SignatureAlgorithm

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for SignatureAlgorithm

source§

fn eq(&self, other: &SignatureAlgorithm) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for SignatureAlgorithm

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for SignatureAlgorithm

source§

impl Eq for SignatureAlgorithm

source§

impl StructuralEq for SignatureAlgorithm

source§

impl StructuralPartialEq for SignatureAlgorithm

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,