Trait openidconnect::JsonWebKey
source · pub trait JsonWebKey<JS, JT, JU>: Clone + Debug + DeserializeOwned + Serialize + 'static{
// Required methods
fn key_id(&self) -> Option<&JsonWebKeyId>;
fn key_type(&self) -> &JT;
fn key_use(&self) -> Option<&JU>;
fn signing_alg(&self) -> JsonWebKeyAlgorithm<&JS>;
fn new_symmetric(key: Vec<u8>) -> Self;
fn verify_signature(
&self,
signature_alg: &JS,
message: &[u8],
signature: &[u8]
) -> Result<(), SignatureVerificationError>;
}
Expand description
JSON Web Key.
Required Methods§
sourcefn key_id(&self) -> Option<&JsonWebKeyId>
fn key_id(&self) -> Option<&JsonWebKeyId>
Returns the key ID, or None
if no key ID is specified.
sourcefn key_use(&self) -> Option<&JU>
fn key_use(&self) -> Option<&JU>
Returns the allowed key usage (e.g., signing or encryption), or None
if no usage is
specified.
sourcefn signing_alg(&self) -> JsonWebKeyAlgorithm<&JS>
fn signing_alg(&self) -> JsonWebKeyAlgorithm<&JS>
Returns the algorithm (e.g. ES512) this key must be used with, or Unspecified
if
no algorithm constraint was given, or unsupported if the algorithm is not for signing.
It’s not sufficient to tell whether a key can be used for signing, as key use also has to be validated.
sourcefn new_symmetric(key: Vec<u8>) -> Self
fn new_symmetric(key: Vec<u8>) -> Self
Initializes a new symmetric key or shared signing secret from the specified raw bytes.
sourcefn verify_signature(
&self,
signature_alg: &JS,
message: &[u8],
signature: &[u8]
) -> Result<(), SignatureVerificationError>
fn verify_signature( &self, signature_alg: &JS, message: &[u8], signature: &[u8] ) -> Result<(), SignatureVerificationError>
Verifies the given signature
using the given signature algorithm (signature_alg
) over
the given message
.
Returns Ok
if the signature is valid, or an Err
otherwise.
Object Safety§
This trait is not object safe.