Closed Tardymo closed 2 years ago
I think, and I could be wrong, but what you're defining here isn't CBC mode, which this function implements? But instead, you should perhaps, wrap around ECB mode with your own IV manipulation?
Hi @Tardymo :)
I agree with what @jmons says: It sounds like you're doing something other than CBC?
See https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Cipher_block_chaining_(CBC)
The IV should be updated between each block. That is the reason for the memcpy-call.
https://github.com/kokke/tiny-AES-c/blob/12e7744b4919e9d55de75b7ab566326a1c8e7a67/aes.c#L513
Is storing of IV really necessary at the end of AES_CBC_encrypt_buffer? My use case requires the same IV for each encryption, so now I must call AES_ctx_set_iv each time. There are two unnecessary memcpy calls then. Sure I can comment the line out, but maybe you could add an #ifder configuration macro for this?