Can the same pointer safely be used for the input and output buffers in
encrypt and decrypt operations ?
i.e. is something like AES_encrypt(out,out,key) guaranteed not to rewrite
the input before it's been processed ?

The following IMPLIES this is safe but lingering doubts remain.

(from crypto/aes/aes_core.c)
>>
>> /*
>>     * Encrypt a single block
>>     * in and out can overlap
>>     */
>> void AES_encrypt(const unsigned char *in, unsigned char *out, const
AES_KEY *key) {
>>

Note: I'm interested in the general case. AES was just used as an example
of the type of operation and it's the example I found which implied this
works.

Alternatively do any test cases exist that'd fail if someone provided asm
which broke this behaviour ?.

Checking the source code only goes so far, it'd be really hard to verify
all the asm modules.

We could write our own tests for this, but it'd be preferable that the
OpenSSL behaviour was known to preserve this feature - patching some random
asm module to 'fix' a break of this in the future wouldn't be trivial.

Thanks
Peter

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [email protected]

Reply via email to