On Thu, Sep 2, 2010 at 3:02 PM, Wei Dai <[email protected]> wrote:
> You can reuse a Crypto++ SHA-256 object after you call Final() on it. No
> need to allocate a new object for each digest. That's probably causing most
> of the overhead, if Brian's benchmark is calling SHA256_new() every time.

I had been thinking of that, but this is up to the Python programmer.
A Python programmer typically wants to write:

d1 = SHA256(somedata).hexdigest()
d2 = SHA256(someotherdata).hexdigest()

Instead of some alternate API for initialization like:

h = SHA256()
h.init()
h.update(somedata)
d1 = h.digest()
h.init()
h.update(someotherdata)
d2 = h.digest()

If we could think of a way to reduce overhead while still supporting
the former API that would be good, but I couldn't think of one.


> If you do reuse SHA-256 objects, I see no reason why the per-digest overhead
> would be much higher than OpenSSLs.

Well I need to look more closely at hashlib's implementation [1], [2],
because it supports this API [3], and that's the way Brian's benchmark
script [4] uses it:

from hashlib import sha256
from pycryptopp.hash.sha256 import SHA256

    def hashlib(self):
        sha256(self.data).hexdigest()
    def pycryptopp(self):
        SHA256(self.data).hexdigest()

Regards,

Zooko

[1] http://svn.python.org/view/python/trunk/Lib/hashlib.py?view=markup
[2] http://svn.python.org/view/python/trunk/Modules/_hashopenssl.c?view=markup
[3] http://docs.python.org/library/hashlib.html#module-hashlib
[4] 
http://tahoe-lafs.org/pipermail/tahoe-dev/attachments/20100809/a88819c3/attachment.bin

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to