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
impl JwsSlice
pub fn new<T>(data: &T) -> Result<&JwsSlice, InvalidJws<&T>>
sourcepub unsafe fn new_unchecked(data: &[u8]) -> &JwsSlice
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.
pub const fn validate(bytes: &[u8]) -> bool
pub const fn validate_range(bytes: &[u8], i: usize, end: usize) -> bool
pub fn check_signing_bytes(bytes: &[u8]) -> bool
pub fn len(&self) -> usize
pub fn decode_header(&self) -> Result<Header, InvalidHeader>
sourcepub fn decode_payload(
&self,
header: &Header,
) -> Result<Cow<'_, [u8]>, DecodeError>
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.
pub fn decode_signature(&self) -> Result<JwsSignature, DecodeError>
sourcepub fn decode(&self) -> Result<DecodedJws<'_, Cow<'_, [u8]>>, DecodeError>
pub fn decode(&self) -> Result<DecodedJws<'_, Cow<'_, [u8]>>, DecodeError>
Decodes the entire JWS.
sourcepub fn signing_bytes(&self) -> &[u8] ⓘ
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.
pub fn as_bytes(&self) -> &[u8] ⓘ
sourcepub async fn verify<V>(
&self,
params: V,
) -> Result<Result<(), Invalid>, ProofValidationError>
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 asparams
, 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 PartialOrd for JwsSlice
impl PartialOrd for JwsSlice
source§impl ToDecodedJwt for JwsSlice
impl ToDecodedJwt for JwsSlice
source§fn to_decoded_custom_jwt<C>(
&self,
) -> Result<DecodedJws<'_, JWTClaims<C>>, DecodeError>where
C: DeserializeOwned,
fn to_decoded_custom_jwt<C>(
&self,
) -> Result<DecodedJws<'_, JWTClaims<C>>, DecodeError>where
C: DeserializeOwned,
source§fn to_decoded_jwt(&self) -> Result<DecodedJws<'_, JWTClaims>, DecodeError>
fn to_decoded_jwt(&self) -> Result<DecodedJws<'_, JWTClaims>, DecodeError>
source§async fn verify_jwt<V>(
&self,
verifier: &V,
) -> Result<Result<(), Invalid>, ProofValidationError>
async fn verify_jwt<V>( &self, verifier: &V, ) -> Result<Result<(), Invalid>, ProofValidationError>
impl Eq for JwsSlice
impl StructuralPartialEq for JwsSlice
Auto Trait Implementations§
impl Freeze for JwsSlice
impl RefUnwindSafe for JwsSlice
impl Send for JwsSlice
impl !Sized for JwsSlice
impl Sync for JwsSlice
impl Unpin for JwsSlice
impl UnwindSafe for JwsSlice
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CallHasher for T
impl<T> CallHasher for T
source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
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
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
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
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.