pub struct JWEToken;Expand description
Utilities for working with JWE tokens.
Implementations§
Source§impl JWEToken
impl JWEToken
Sourcepub fn build(
header: &JWEHeader,
encrypted_key: &[u8],
iv: &[u8],
ciphertext: &[u8],
tag: &[u8],
) -> Result<String, Error>
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 headerencrypted_key- The encrypted CEK (or empty for direct key agreement)iv- The initialization vectorciphertext- The encrypted contenttag- The authentication tag
Sourcepub fn build_from_claims<KeyWrapFn, CustomClaims: Serialize>(
header: &JWEHeader,
claims: &JWTClaims<CustomClaims>,
content_encryption: ContentEncryption,
key_wrap_fn: KeyWrapFn,
) -> Result<String, Error>
pub fn build_from_claims<KeyWrapFn, CustomClaims: Serialize>( header: &JWEHeader, claims: &JWTClaims<CustomClaims>, content_encryption: ContentEncryption, key_wrap_fn: KeyWrapFn, ) -> Result<String, Error>
Build a JWE token from claims.
This is a helper that serializes claims to JSON before encryption.
Sourcepub fn decrypt<KeyUnwrapFn, CustomClaims: DeserializeOwned>(
expected_alg: &str,
token: &str,
options: Option<DecryptionOptions>,
key_unwrap_fn: KeyUnwrapFn,
) -> Result<JWTClaims<CustomClaims>, Error>
pub fn decrypt<KeyUnwrapFn, CustomClaims: DeserializeOwned>( expected_alg: &str, token: &str, options: Option<DecryptionOptions>, key_unwrap_fn: KeyUnwrapFn, ) -> Result<JWTClaims<CustomClaims>, Error>
Parse and decrypt a JWE token.
This function is called by key management implementations to decrypt a JWE token and return the claims.
Sourcepub fn decode_metadata(token: &str) -> Result<JWETokenMetadata, Error>
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§
impl Freeze for JWEToken
impl RefUnwindSafe for JWEToken
impl Send for JWEToken
impl Sync for JWEToken
impl Unpin for JWEToken
impl UnwindSafe for JWEToken
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
Mutably borrows from an owned value. Read more