RustCrypto / block-modes

Collection of generic block mode algorithms written in pure Rust
64 stars 13 forks source link

Add a way to estimate the encryption buffer needed size #7

Closed Keruspe closed 2 years ago

Keruspe commented 2 years ago

With cipher 0.3 and block-modes 0.8, there used to be some encrypt_vec method which would allocate just enough room for the encrypted data + padding. Having a helper to calculate this size (or restoring some encrypt_padded_vec, and maybe decrypt_padded_vec too, or something like that) would be really helpful.

newpavlov commented 2 years ago

In general, it should be enough to have one block of reserve space.

I plan to restore the allocating methods in the next cipher release. I wanted to somehow avoid zeroizing allocated output buffers, but, unfortunately, I couldn't find a simple sound solution.