Struct ssi_claims::JwsSlice

source ·
pub struct JwsSlice(/* private fields */);
Expand description

Borrowed JWS without any encoding guaranties.

This is an unsized type borrowing the JWS and meant to be referenced as &JwsSlice, just like &[u8]. Use JwsVec if you need to own the JWS.

This type is similar to the Jws type. However contrarily to Jws, there is no guarantee that the JWS is a valid UTF-8 string (and even less URL-safe).

Use JwsStr if you expect UTF-8 encoded JWSs. Use Jws if you expect URL-safe JWSs.

Implementations§

source§

impl JwsSlice

source

pub fn new<T>(data: &T) -> Result<&JwsSlice, InvalidJws<&T>>
where T: AsRef<[u8]> + ?Sized,

source

pub unsafe fn new_unchecked(data: &[u8]) -> &JwsSlice

Creates a new compact JWS without checking the data.

§Safety

The input data must represent a valid compact JWS.

source

pub const fn validate(bytes: &[u8]) -> bool

source

pub const fn validate_range(bytes: &[u8], i: usize, end: usize) -> bool

source

pub fn check_signing_bytes(bytes: &[u8]) -> bool

source

pub fn len(&self) -> usize

source

pub fn header(&self) -> &[u8]

Returns the Base64 encoded header.

source

pub fn decode_header(&self) -> Result<Header, InvalidHeader>

source

pub fn payload(&self) -> &[u8]

Returns the Base64 encoded payload.

source

pub fn decode_payload( &self, header: &Header, ) -> Result<Cow<'_, [u8]>, DecodeError>

Decode the payload bytes.

The header is necessary to know how the payload is encoded.

source

pub fn signature(&self) -> &str

Returns the Base64 encoded signature.

source

pub fn decode_signature(&self) -> Result<JwsSignature, DecodeError>

source

pub fn decode(&self) -> Result<DecodedJws<'_, Cow<'_, [u8]>>, DecodeError>

Decodes the entire JWS.

source

pub fn signing_bytes(&self) -> &[u8]

Returns the signing bytes.

It is the concatenation of the Base64 encoded headers, a period ‘.’ and the Base64 encoded payload.

source

pub fn as_bytes(&self) -> &[u8]

source

pub async fn verify<V>( &self, params: V, ) -> Result<Result<(), Invalid>, ProofValidationError>

Verify the JWS signature.

This will only check the signature and not the validity of the decoded payload. For instance if the payload is a set of JWT claims, those claims will not be validated.

To perform a more precise verification, specify use a specialized T instead of the default Vec<u8>

The params argument provides all the verification parameters required to validate the claims and proof.

§What verification parameters should I use?

Any type that providing a JWKResolver through the ResolverProvider trait will be fine. Notable implementors are:

  • VerificationParameters: A good default providing many other common verification parameters that are not necessary here.
  • JWK: allows you to put a JWK as params, which will resolve into itself. Can be useful if you don’t need key resolution because you know in advance what key was used to sign the JWS.
§Passing the parameters by reference

If the validation traits are implemented for P, they will be implemented for &P as well. This means the parameters can be passed by move or by reference.

Trait Implementations§

source§

impl Debug for JwsSlice

source§

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

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

impl Hash for JwsSlice

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
source§

impl Ord for JwsSlice

source§

fn cmp(&self, other: &JwsSlice) -> Ordering

This method returns an Ordering between self and other. Read more
source§

impl PartialEq for JwsSlice

source§

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

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

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

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

impl PartialOrd for JwsSlice

source§

fn partial_cmp(&self, other: &JwsSlice) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl ToDecodedJwt for JwsSlice

source§

fn to_decoded_custom_jwt<C>( &self, ) -> Result<DecodedJws<'_, JWTClaims<C>>, DecodeError>

Decodes a JWT with custom claims.
source§

fn to_decoded_jwt(&self) -> Result<DecodedJws<'_, JWTClaims>, DecodeError>

Decodes a JWT.
source§

async fn verify_jwt<V>( &self, verifier: &V, ) -> Result<Result<(), Invalid>, ProofValidationError>

Verify the JWS signature. Read more
source§

impl Eq for JwsSlice

source§

impl StructuralPartialEq for JwsSlice

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> CallHasher for T
where T: Hash + ?Sized,

source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

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

source§

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

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

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

source§

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

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

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

source§

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

source§

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

source§

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

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

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

source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
source§

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

source§

fn with<C>(&self, context: C) -> Contextual<&T, C>

source§

fn into_with<C>(self, context: C) -> Contextual<T, C>