[pycrypto] Crypto.Random crashes due to unaligned access

Sebastian Ramacher sebastian+lists at ramacher.at
Mon Oct 28 10:13:44 PDT 2013


On 2013-10-27 15:58:52, Greg Price wrote:
> Fortunately, 'rk' is an address we control.  It's st->ek, where st
> came from newALGobject in src/block_template.c.  The alignment there
> comes from PyObject_New, but we could add an indirection to storage we
> allocate directly to ensure alignment.  (Sadly I don't think the
> Python C API has a cousin of PyObject_New that takes an alignment.)

I've implemented this approach now by allocating ek and dk with one of
posix_memalign (POSIX), aligned_alloc (C11) or _aligned_malloc
(Windows/Visual Studio). A pull request is available at
https://github.com/dlitz/pycrypto/pull/62. I'd appreciate any testing
and feedback.

Regards
-- 
Sebastian Ramacher
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.dlitz.net/pipermail/pycrypto/attachments/20131028/bb5a0193/attachment.sig>


More information about the pycrypto mailing list