pub trait AlgorithmSignature: Sized {
const LENGTH: Option<NonZeroUsize> = None;
// Required methods
fn try_from_slice(slice: &[u8]) -> Result<Self>;
fn as_bytes(&self) -> Cow<'_, [u8]>;
}Expand description
Signature for a certain JWT signing Algorithm.
We require that signature can be restored from a byte slice, and can be represented as a byte slice.
Provided Associated Constants§
Sourceconst LENGTH: Option<NonZeroUsize> = None
const LENGTH: Option<NonZeroUsize> = None
Constant byte length of signatures supported by the Algorithm, or None if
the signature length is variable.
- If this value is
Some(_), the signature will be first checked for its length during token verification. AnInvalidSignatureLenerror will be raised if the length is invalid.Self::try_from_slice()will thus always receive a slice with the expected length. - If this value is
None, no length check is performed before callingSelf::try_from_slice().
Required Methods§
Sourcefn try_from_slice(slice: &[u8]) -> Result<Self>
fn try_from_slice(slice: &[u8]) -> Result<Self>
Attempts to restore a signature from a byte slice. This method may fail if the slice is malformed.
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 AlgorithmSignature for Signature
Available on crate feature secp256k1 only.
impl AlgorithmSignature for Signature
Available on crate feature
secp256k1 only.Source§impl AlgorithmSignature for Signature
Available on crate feature exonum-crypto only.
impl AlgorithmSignature for Signature
Available on crate feature
exonum-crypto only.Source§impl AlgorithmSignature for Signature
Available on crate feature p256 only.
impl AlgorithmSignature for Signature
Available on crate feature
p256 only.Implementors§
Source§impl AlgorithmSignature for Hs256Signature
impl AlgorithmSignature for Hs256Signature
const LENGTH: Option<NonZeroUsize>
Source§impl AlgorithmSignature for Hs384Signature
impl AlgorithmSignature for Hs384Signature
const LENGTH: Option<NonZeroUsize>
Source§impl AlgorithmSignature for Hs512Signature
impl AlgorithmSignature for Hs512Signature
const LENGTH: Option<NonZeroUsize>
impl AlgorithmSignature for RsaSignature
Available on crate feature
rsa only.