Struct jsonwebtoken::DecodingKey

source ·
pub struct DecodingKey { /* private fields */ }
Expand description

All the different kind of keys we can use to decode a JWT. This key can be re-used so make sure you only initialize it once if you can for better performance.

Implementations§

source§

impl DecodingKey

source

pub fn from_secret(secret: &[u8]) -> Self

If you’re using HMAC, use this.

source

pub fn from_base64_secret(secret: &str) -> Result<Self>

If you’re using HMAC with a base64 encoded secret, use this.

source

pub fn from_rsa_pem(key: &[u8]) -> Result<Self>

If you are loading a public RSA key in a PEM format, use this. Only exists if the feature use_pem is enabled.

source

pub fn from_rsa_components(modulus: &str, exponent: &str) -> Result<Self>

If you have (n, e) RSA public key components as strings, use this.

source

pub fn from_rsa_raw_components(modulus: &[u8], exponent: &[u8]) -> Self

If you have (n, e) RSA public key components already decoded, use this.

source

pub fn from_ec_pem(key: &[u8]) -> Result<Self>

If you have a ECDSA public key in PEM format, use this. Only exists if the feature use_pem is enabled.

source

pub fn from_ec_components(x: &str, y: &str) -> Result<Self>

If you have (x,y) ECDSA key components

source

pub fn from_ed_pem(key: &[u8]) -> Result<Self>

If you have a EdDSA public key in PEM format, use this. Only exists if the feature use_pem is enabled.

source

pub fn from_rsa_der(der: &[u8]) -> Self

If you know what you’re doing and have a RSA DER encoded public key, use this.

source

pub fn from_ec_der(der: &[u8]) -> Self

If you know what you’re doing and have a RSA EC encoded public key, use this.

source

pub fn from_ed_der(der: &[u8]) -> Self

If you know what you’re doing and have a Ed DER encoded public key, use this.

source

pub fn from_ed_components(x: &str) -> Result<Self>

From x part (base64 encoded) of the JWK encoding

source

pub fn from_jwk(jwk: &Jwk) -> Result<Self>

If you have a key in Jwk format

Trait Implementations§

source§

impl Clone for DecodingKey

source§

fn clone(&self) -> DecodingKey

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

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where 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 T
where 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 T
where 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 T
where 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.