Ok jemarch. I have written some examples for libgcrypt and I can do it
works incrementally, but we would change the crypt API. So, I propose
the following changes:
1. Edit crypt module (AESV2 only) in order to it doesn't pad the
content.
2. Provide a function:
void pdf_crypt_cipher_pad (CIPHER, OUT, OUT_SIZE, BUFFER, SIZE)
Pad a buffer in memory. The new buffer is written in OUT.
3. Provide high level functions:
pdf_status_t pdf_crypt_encrypt_buffer (ALGO, OUT, OUT_SIZE, IN, IN_SIZE);
pdf_status_t pdf_crypt_decrypt_buffer (ALGO, OUT, OUT_SIZE, IN, IN_SIZE);
which they work with a buffer in memory (with padding).
In this way, crypt filters only will need to use `pdf_crypt_cipher_pad'
in `finish_p'.
What do you think? If you agree, I write this.