On May 16, 2010, at 19:28, RB Tilley wrote: > The smallsha library (http://code.google.com/p/smallsha1/) does the > sha1 generation in 40 seconds. Here is the same function using > smallsha:
One thing really jumps out at me: Your code using smallsha1 writes to an automatic char array, while your crypto++ code creates a 'string' object (presumably with dynamic storage allocation) via StringSink. If you want to compare them effectively, see if you can make the memory management method the same. I'd also rewrite both versions to not hex-encode the hash value for comparison, but instead do a binary comparison of the computed hash vs the hex-DEcoded target value; it's not a lot of extra cycles, comparatively, to do the hex encoding every time, but it's a waste nonetheless. Also possibly of interest: "Improving the Performance of the Secure Hash Algorithm (SHA-1)" in Dr Dobbs, http://www.drdobbs.com/224202549 , from just last month, discusses the use of SSE2 or SSSE3 instructions to speed up the inner loops. I haven't compared it with the crypto++ implementation. Another, side issue: Even if some parts of the algorithm don't lend themselves well to use of SIMD for computing a hash value, instructions like these may also be useful for computing multiple hashes in parallel, at least of messages of the same size, and perhaps requiring a different memory layout for the messages. This isn't a common application of hash functions, so general-purpose libraries aren't likely to optimize for it, but there may be brute-force hash implementations out there that do. Ken -- 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.
