JWEToken

Struct JWEToken 

Source
pub struct JWEToken;
Expand description

Utilities for working with JWE tokens.

Implementations§

Source§

impl JWEToken

Source

pub fn build( header: &JWEHeader, encrypted_key: &[u8], iv: &[u8], ciphertext: &[u8], tag: &[u8], ) -> Result<String, Error>

Build a JWE token.

This function is called by key management implementations to create the final JWE compact serialization.

§Arguments
  • header - The JWE header
  • encrypted_key - The encrypted CEK (or empty for direct key agreement)
  • iv - The initialization vector
  • ciphertext - The encrypted content
  • tag - The authentication tag
Source

pub fn build_from_claims<KeyWrapFn, CustomClaims: Serialize>( header: &JWEHeader, claims: &JWTClaims<CustomClaims>, content_encryption: ContentEncryption, key_wrap_fn: KeyWrapFn, ) -> Result<String, Error>
where KeyWrapFn: FnOnce(&[u8]) -> Result<Vec<u8>, Error>,

Build a JWE token from claims.

This is a helper that serializes claims to JSON before encryption.

Source

pub fn decrypt<KeyUnwrapFn, CustomClaims: DeserializeOwned>( expected_alg: &str, token: &str, options: Option<DecryptionOptions>, key_unwrap_fn: KeyUnwrapFn, ) -> Result<JWTClaims<CustomClaims>, Error>
where KeyUnwrapFn: FnOnce(&JWEHeader, &[u8]) -> Result<Vec<u8>, Error>,

Parse and decrypt a JWE token.

This function is called by key management implementations to decrypt a JWE token and return the claims.

Source

pub fn decode_metadata(token: &str) -> Result<JWETokenMetadata, Error>

Decode JWE token metadata without decrypting.

This allows inspection of the header to determine which key to use for decryption.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V