Trait jws::Verifier

source ·
pub trait Verifier: Sized {
    // Required method
    fn verify(
        &self,
        protected_header: Option<&JsonObject>,
        unprotected_header: Option<&JsonObject>,
        encoded_header: &[u8],
        encoded_payload: &[u8],
        signature: &[u8]
    ) -> Result<()>;

    // Provided methods
    fn or<Other: Verifier>(self, other: Other) -> OrVerifier<Self, Other> { ... }
    fn and<Other: Verifier>(self, other: Other) -> AndVerifier<Self, Other> { ... }
}
Expand description

A verifier for JWS messages.

Required Methods§

source

fn verify( &self, protected_header: Option<&JsonObject>, unprotected_header: Option<&JsonObject>, encoded_header: &[u8], encoded_payload: &[u8], signature: &[u8] ) -> Result<()>

Verify the signature of a JWS message.

This function needs access to the decoded message headers in order to determine which MAC algorithm to use. It also needs access to the base64-url encoded parts to verify the signature.

If the signature is invalid, the function should return a Error::InvalidSignature error. If the algorithm is not supported by the verifier, it should return a Error::UnsupportedMacAlgorithm error. It may also report any of the other supported error variants.

Args:
  • protected_header: The parsed protected header, if any.
  • unprotected_header: The parsed unprotected header, if any.
  • encoded_header: The base64-url encoded protected header, needed to compute the MAC. If there is no protected header, this is an empty slice.
  • encoded_payload: The base64-url encoded payload, needed to compute the MAC.
  • signature: The signature associated with the message, should be tested against the computed MAC.

Provided Methods§

source

fn or<Other: Verifier>(self, other: Other) -> OrVerifier<Self, Other>

Create a new verifier that accepts a message if either this or the other verifier does.

source

fn and<Other: Verifier>(self, other: Other) -> AndVerifier<Self, Other>

Create a new verifier that accepts a message if both this and the other verifier does.

Object Safety§

This trait is not object safe.

Implementors§