With the AES Key Wrap algorithm, the wrapped key is 8 bytes longer than the original plaintext key. By default a checkword of A6A6A6A6A6A6A6A6 is pre-pended to the original plaintext key. In the OpenSSL code, this is referred to as the IV. The Checkword plus plaintext key is then subjected to several rounds of AES encryption using the Key Encryption Key. It appears that the output buffer is used as a working area for this process and thus initializes it with the original plaintext key.
Bill -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alfred Arnold Sent: September 28, 2008 4:54 AM To: openssl-users@openssl.org Subject: AES_wrap_key()/AES_unwrap_key() and in-place operation? Hi everybody, I'm using OpenSSL 0.9.8i in an embedded project and I have a question related to the (relatively new?) functions to perform AES key wrapping resp. unwrapping. Are these functions meant to be used for in-place operation, i.e. the source and destination buffers are the same? Looking at the sources in aes_wrap.c, I'd say they are not at the moment, because of a memcpy() right at the beginning: memcpy(out + 8, in, inlen); resp. memcpy(out, in + 8, inlen); If in and out point tho the same location, this will result in a memcpy of overlapping memory regions, which leads to undefined behaviour. Would it be sufficient to replace these memcpy() calls with memmove()? I didn't find any documentation about these function in the doc/ subdirectory. Best regards Alfred Arnold -- Alfred Arnold E-Mail: [EMAIL PROTECTED] Computer Club at the http://john.ccac.rwth-aachen.de:8000/alf/ Technical University of Aachen ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED] ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]