pub struct TokenDecryptStream { /* private fields */ }Expand description
An incremental Token::decrypt_chunks: the token’s bytes are fed in
order with TokenDecryptStream::update, and TokenDecryptStream::finish
checks the tag and returns the plaintext. The last 32 bytes seen are held
back as the candidate tag; everything before them is authenticated and
decrypted as it arrives. Decrypted bytes are not authentic until finish
accepts the tag.
Implementations§
Source§impl TokenDecryptStream
impl TokenDecryptStream
Sourcepub fn hash_plaintext(&mut self)
pub fn hash_plaintext(&mut self)
Also hash the plaintext, together with the tag’s MAC, as it settles;
Self::finish_hashed returns the hash. Call before any update.
Sourcepub fn plaintext(&self) -> &[u8] ⓘ
pub fn plaintext(&self) -> &[u8] ⓘ
The plaintext decrypted so far, without the skipped bytes. Its last
block may still hold the padding, and none of it is authentic until
Self::finish succeeds.
Sourcepub fn finish_hashed(self) -> Result<(Vec<u8>, Option<Sha256>), TokenError>
pub fn finish_hashed(self) -> Result<(Vec<u8>, Option<Sha256>), TokenError>
Self::finish, with the SHA-256 state over the whole plaintext
when Self::hash_plaintext was called.
Sourcepub fn finish(self) -> Result<Vec<u8>, TokenError>
pub fn finish(self) -> Result<Vec<u8>, TokenError>
Check the tag and return the plaintext, as Token::decrypt_chunks
of every byte fed.