dlitz/pycrypto — pull request #62 by sebastinas (2013-10-28 17:08:03+00:00)
Title: AES-NI alignment

This should fix all the alignment issues in the AES-NI code [1]. ek and dk are now allocated with one of posix_memalign, aligned_alloc or _aligned_malloc to get them properly aligned. The first two functions should cover all systems that implement POSIX or C11, the last one is for Windows/Visual Studio.

I think this is one of the better options to fix this. Replacing every access of ek and dk with unaligned instructions would add additional overhead to each call to block_encrypt and block_decrypt. The downside is that we need introduce a block_finalize function to clean up the allocated memory. In all the other block ciphers this is just an empty function.

[1] Tested on both Debian amd64 and in a i386 chroot.