Skip to main content

VerifyingKey

Trait VerifyingKey 

Source
pub trait VerifyingKey: Key {
    // Required methods
    fn is_valid_signature(&self, message: &[u8], signature: Vec<u8>) -> bool;
    fn describe(&self) -> String;
}
Expand description

Represents a key that can be used to verify the signature on a JWT.

Required Methods§

Source

fn is_valid_signature(&self, message: &[u8], signature: Vec<u8>) -> bool

Verifies signature.

Source

fn describe(&self) -> String

Describe the key for use in errors

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl VerifyingKey for VerifyingKey

Source§

fn is_valid_signature(&self, message: &[u8], signature: Vec<u8>) -> bool

Source§

fn describe(&self) -> String

Implementors§

Source§

impl VerifyingKey for HS256

use pubhubs::misc::jwt::{HS256, VerifyingKey};
use base64ct::{Base64UrlUnpadded, Encoding as _};

// Example A.1.1 of RFC 7515
let key = HS256(Base64UrlUnpadded::decode_vec("AyM1SysPpbyDfgZld3umj1qzKObwVMkoqQ-EstJQLr_T-1qS0gZH75aKtMN3Yj0iPS4hcgUuTwjAzZr1Z9CAow").unwrap().into());
assert!(key.is_valid_signature("eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ".as_bytes(), Base64UrlUnpadded::decode_vec("dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk").unwrap()));
Source§

impl VerifyingKey for IgnoreSignature

Source§

impl VerifyingKey for RS256Vk