pub struct Token { /* private fields */ }Implementations§
Source§impl Token
impl Token
pub fn new(key: &[u8]) -> Result<Self, TokenError>
pub fn encrypt(&self, plaintext: &[u8], rng: &mut dyn Rng) -> Vec<u8> ⓘ
pub fn encrypt_with_iv(&self, plaintext: &[u8], iv: &[u8; 16]) -> Vec<u8> ⓘ
pub fn verify_hmac(&self, token: &[u8]) -> Result<bool, TokenError>
pub fn decrypt(&self, token: &[u8]) -> Result<Vec<u8>, TokenError>
Sourcepub fn decrypt_chunks(
&self,
chunks: &[&[u8]],
skip: usize,
) -> Result<Vec<u8>, TokenError>
pub fn decrypt_chunks( &self, chunks: &[&[u8]], skip: usize, ) -> Result<Vec<u8>, TokenError>
Decrypt a token that arrives as consecutive chunks, such as the parts
of a resource, without joining them first. Each chunk is authenticated
and decrypted while it is still in cache; nothing is returned unless
the tag matches. The result is Token::decrypt of the joined bytes
with its first skip bytes (at most one block) dropped, and the errors
are the same, except that a plaintext shorter than skip is
TokenError::DecryptionFailed.
Auto Trait Implementations§
impl Freeze for Token
impl RefUnwindSafe for Token
impl Send for Token
impl Sync for Token
impl Unpin for Token
impl UnsafeUnpin for Token
impl UnwindSafe for Token
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