Skip to main content

decrypt

Function decrypt 

Source
pub fn decrypt(key: &Key, sealed: &[u8]) -> Result<Vec<u8>, StreamError>
Expand description

Reverses encrypt under key - XOR is its own inverse (hazmat::strumok’s apply_keystream), so this recovers the original plaintext bit-for-bit when sealed is exactly encrypt’s own output. Never fails on tampered input - see the module doc’s “No authentication” section; a modified sealed decrypts to different, silently-wrong plaintext, not an error.

§Errors

Returns StreamError::Truncated if sealed is shorter than an IV (32 bytes) - the only possible error, since there is no tag to fail.