The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: brethren on July 29, 2011, 01:54:26 PM

Title: fast hashing algos
Post by: brethren on July 29, 2011, 01:54:26 PM
the app i'm coding uses the sha-1 hashing function. Currently i'm using a version of sha-1 written in C and linking it in with my app.:)

what do you guys use when you need a fast sha-1 implementation? Has anyone written a highly optimized asm version?

thanks
nick
Title: Re: fast hashing algos
Post by: Twister on July 29, 2011, 02:02:53 PM
ASM + GPU. That's as optimized as it can get.
Title: Re: fast hashing algos
Post by: hutch-- on July 29, 2011, 03:27:58 PM
brethren,

Funny enough the Crypto API SHA1 is not slow. If you have not played with it, have a look and see if its fast enough. MichaelW did a prototype that I translated to another language and it was very good when chomping through very large files > 2 gig. Seemed to work best with a much smaller buffer size than I expected, from about 16k to about 64k from memory.
Title: Re: fast hashing algos
Post by: brethren on July 29, 2011, 11:04:26 PM
thanks for the replies, guys. i'm gonna do some timing tests with my current code against the crypto api. as for using the gpu i've had no experience in this area but i'm gonna look into it as i've just found a version written using openCL :wink

still, if anyone has an optimized asm version that'd be great:D
Title: Re: fast hashing algos
Post by: Glenn9999 on August 01, 2011, 10:41:20 AM
Quote from: brethren on July 29, 2011, 11:04:26 PM
thanks for the replies, guys. i'm gonna do some timing tests with my current code against the crypto api. as for using the gpu i've had no experience in this area but i'm gonna look into it as i've just found a version written using openCL :wink

still, if anyone has an optimized asm version that'd be great:D

The cryptoAPI is very good for a number of things, and probably will be sufficient unless you really want to experiment.  That said, here's what I came up with when I was doing hashes as a learning project.  All the x86 asm code for SHA-1 that profiled out to be needed for optimization in my Delphi main program.  The rest in the Delphi source is just file I/O and routine things.

http://www.masm32.com/board/index.php?topic=15788.msg130634#msg130634

Can post the Delphi source part as well if desired, though if you have a C implementation you should know where these parts fit.  Good luck.
Title: Re: fast hashing algos
Post by: brethren on August 01, 2011, 05:22:53 PM
thanks for posting, glenn :U i'm gonna have a good look at your code