Skip to main content

strip_padding

Function strip_padding 

Source
pub fn strip_padding(plaintext: &[u8]) -> Result<&[u8], WireError>
Available on crate feature std only.
Expand description

Strip a padding trailer from a decrypted, PADDED-flagged plaintext: read the trailing u16be pad length, then drop that many zero bytes plus the 2-byte field. Returns the inner plaintext slice. A trailer that claims more bytes than are present is WireError::Truncated (an authenticated peer cannot reach this with a malformed trailer — the AEAD already verified — but a buggy peer must not panic the receiver).