Method
unpad
(block: &[u8], strict: bool)
Source from the content-addressed store, hash-verified
| 166 | impl Pkcs7 { |
| 167 | #[inline] |
| 168 | fn unpad(block: &[u8], strict: bool) -> Result<&[u8], Error> { |
| 169 | assert!(block.len() <= 255, "block size is too big for PKCS#7"); |
| 170 | let bs = block.len(); |
| 171 | let n = block[bs - 1]; |
| 172 | if n == 0 || n as usize > bs { |
| 173 | return Err(Error); |
| 174 | } |
| 175 | let s = bs - n as usize; |
| 176 | if strict && block[s..bs - 1].iter().any(|&v| v != n) { |
| 177 | return Err(Error); |
| 178 | } |
| 179 | Ok(&block[..s]) |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | impl Padding for Pkcs7 { |
Callers
nothing calls this directly
Tested by
no test coverage detected