EcdsaKeyVerifier

Struct EcdsaKeyVerifier 

Source
pub struct EcdsaKeyVerifier<K, A>
where K: EcdsaKey, A: Algorithm,
{ /* private fields */ }
Available on crate feature ring only.
Expand description

Wrapper for ::ring::signature::UnparsedPublicKey.

§Examples

§ES256 PKCS8

let public_key =
"-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEerEk+zqoG1oYBLD3ohuz0tzIlU7X
zFG1098HcCOu0CmVAsp8ZLYXqYD3ts6+j0CV/I2yfzwx/ojBrm+Z/pSQnA==
-----END PUBLIC KEY-----";

// Convert the PKCS8 PEM to SPK.
// Note that ring requires SPK (not SPKI) keys for ECDSA_P256_SHA256 public keys.
// See https://github.com/briansmith/ring/issues/881
let public_key = convert_pkcs8_pem_to_spk(public_key);

let public_key = ::ring::signature::UnparsedPublicKey::new(
  &::ring::signature::ECDSA_P256_SHA256_FIXED,
  public_key,
);

let verifier = min_jwt::verify::ring::EcdsaKeyVerifier::with_es256(&public_key);
let verified_jwt = min_jwt::verify(jwt, &verifier)?;

let header = verified_jwt.decode_header();
let claims = verified_jwt.decode_claims();

Implementations§

Source§

impl<K, A> EcdsaKeyVerifier<K, A>
where K: EcdsaKey, A: Algorithm,

Source

pub fn into_inner(self) -> K

Returns the inner key.

Source§

impl<K> EcdsaKeyVerifier<K, Es256>
where K: EcdsaKey,

Source

pub fn with_es256(key: K) -> EcdsaKeyVerifier<K, Es256>

Creates a new Es256 key verifier.

Trait Implementations§

Source§

impl<K, A> Debug for EcdsaKeyVerifier<K, A>
where K: EcdsaKey + Debug, A: Algorithm + Debug,

Source§

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

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

impl<K, A> Verifier for EcdsaKeyVerifier<K, A>
where K: EcdsaKey, A: Algorithm,

Source§

fn verify(&self, message: &[u8], signature: &[u8]) -> Result<()>

Verifies the message with the given signature. Read more

Auto Trait Implementations§

§

impl<K, A> Freeze for EcdsaKeyVerifier<K, A>
where K: Freeze,

§

impl<K, A> RefUnwindSafe for EcdsaKeyVerifier<K, A>

§

impl<K, A> Send for EcdsaKeyVerifier<K, A>
where K: Send, A: Send,

§

impl<K, A> Sync for EcdsaKeyVerifier<K, A>
where K: Sync, A: Sync,

§

impl<K, A> Unpin for EcdsaKeyVerifier<K, A>
where K: Unpin, A: Unpin,

§

impl<K, A> UnwindSafe for EcdsaKeyVerifier<K, A>
where K: UnwindSafe, A: UnwindSafe,

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V