DaGenix / rust-crypto

A (mostly) pure-Rust implementation of various cryptographic algorithms.
Apache License 2.0
1.39k stars 295 forks source link

AES-CBC padding buffer length passed to PaddingProcessor is too short #426

Closed drahnr closed 6 years ago

drahnr commented 7 years ago

Decrypting a a 32byte payload with AES-CBC with a key of 256bit and iv of 128bit and a custom padding scheme (\n followed by \0, legacy code compat) the stream buffer available to

fn strip_output<R: ReadBuffer>(&mut self, output_buffer: &mut R) -> bool {

output_buffer has only a length of 16 bytes and not 32 as I would have expected.

This was determined by output_buffer.peek_remaining().len()

musoke commented 6 years ago

Doesn't AES always have 128 bits for the block size? 256 refers to the key size.

drahnr commented 6 years ago

Yes you are right, block size is 128bits - always - independent of the key length. My issues were elsewhere. Sorry for the noise.