[ pycrypto-Patches-1438820 ] dramatically improve HMAC performance

"SourceForge.net" <[email protected]> Sat, 25 Feb 2006 16:14:08 -0800
Newsgroups gmane.comp.python.cryptography.cvs
Message-ID <[email protected]>
Patches item #1438820, was opened at 2006-02-25 16:14
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=320937&aid=1438820&group_id=20937

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Robey Pointer (robey)
Assigned to: Nobody/Anonymous (nobody)
Summary: dramatically improve HMAC performance

Initial Comment:
When profiling paramiko (an SSH library), I eventually got to the point 
where the largest chunk of time was falling in pycrypto's HMAC class. 

In SSH (and in SSL also, IIRC), every outbound and inbound packet has an 
HMAC calculated on it.  So this is a very high-traffic code path.

I played around with different optimizations, including writing all of the 
HMAC class in pyrex, which gave a 25x performance improvement.  
However, I found out that improving just a single function (strxor) can 
give 10-15x improvement by itself.

Since I believe there is some advantage in keeping as much of the code in 
python as possible, I'm submitting a patch which merely moves strxor 
into native C, and streamlines the HMAC setup a bit.  IMHO the roughly 
2x faster speed you'd get from making the whole class native C wouldn't 
be worth losing the readability.

With this patch, a pure-python SSH implementation (based on pycrypto) is 
actually quite competitive with openssh for speed.

Please consider this patch (or some variation of it) for the next pycrypto 
release.

Thanks!


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=320937&aid=1438820&group_id=20937


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642