Prev: The incompatibility hurdle
Next: Hash combining
From: Milen Rangelov on 10 Feb 2010 10:52 On Jan 26, 5:55 pm, Tom St Denis <t...(a)iahu.ca> wrote: > MD5 is computationally cheaper than SHA-1 if that helps. Well, that's not necessarily true. SHA-1 has 16 more iterations as compared to MD5, however it lacks multiplication and modulo operations. Actually, on my box, OpenSSL's implementation of SHA-1 is a bit faster than MD5 on short (16byte) messages: [root(a)dco-milen fd]# openssl speed md5 Doing md5 for 3s on 16 size blocks: 3129090 md5's in 2.99s Doing md5 for 3s on 64 size blocks: 2619221 md5's in 2.99s Doing md5 for 3s on 256 size blocks: 2058981 md5's in 2.99s Doing md5 for 3s on 1024 size blocks: 1000364 md5's in 2.99s Doing md5 for 3s on 8192 size blocks: 178505 md5's in 3.00s [root(a)dco-milen fd]# openssl speed sha1 Doing sha1 for 3s on 16 size blocks: 3342901 sha1's in 2.99s Doing sha1 for 3s on 64 size blocks: 2511148 sha1's in 3.00s Doing sha1 for 3s on 256 size blocks: 1432632 sha1's in 2.99s Doing sha1 for 3s on 1024 size blocks: 651407 sha1's in 2.99s Doing sha1 for 3s on 8192 size blocks: 100773 sha1's in 2.98s ....and slower for longer messages, possibly because the pre-processing stage (breaking each chunk into 32-bit words) is more computionally expensive for SHA-1.
From: Tom St Denis on 10 Feb 2010 11:53 On Feb 10, 10:52 am, Milen Rangelov <gat3...(a)gmail.com> wrote: > On Jan 26, 5:55 pm, Tom St Denis <t...(a)iahu.ca> wrote: > > > MD5 is computationally cheaper than SHA-1 if that helps. > > Well, that's not necessarily true. SHA-1 has 16 more iterations as > compared to MD5, however it lacks multiplication and modulo > operations. Actually, on my box, OpenSSL's implementation of SHA-1 is > a bit faster than MD5 on short (16byte) messages: Multiplication and modulo operations? > [root(a)dco-milen fd]# openssl speed md5 > Doing md5 for 3s on 16 size blocks: 3129090 md5's in 2.99s > Doing md5 for 3s on 64 size blocks: 2619221 md5's in 2.99s > Doing md5 for 3s on 256 size blocks: 2058981 md5's in 2.99s > Doing md5 for 3s on 1024 size blocks: 1000364 md5's in 2.99s > Doing md5 for 3s on 8192 size blocks: 178505 md5's in 3.00s > > [root(a)dco-milen fd]# openssl speed sha1 > Doing sha1 for 3s on 16 size blocks: 3342901 sha1's in 2.99s > Doing sha1 for 3s on 64 size blocks: 2511148 sha1's in 3.00s > Doing sha1 for 3s on 256 size blocks: 1432632 sha1's in 2.99s > Doing sha1 for 3s on 1024 size blocks: 651407 sha1's in 2.99s > Doing sha1 for 3s on 8192 size blocks: 100773 sha1's in 2.98s > > ...and slower for longer messages, possibly because the pre-processing > stage (breaking each chunk into 32-bit words) is more computionally > expensive for SHA-1. SHA-1 takes longer because it has more rounds and operates on more words at a time. I'd personally write off the 16-byte block size since the calling overhead is non-trivial at that point.
From: Scott Fluhrer on 10 Feb 2010 13:59 "Tom St Denis" <tom(a)iahu.ca> wrote in message news:fefec602-6438-41cd-9b79-ea364303dcc1(a)o3g2000yqb.googlegroups.com... > On Feb 10, 10:52 am, Milen Rangelov <gat3...(a)gmail.com> wrote: > > On Jan 26, 5:55 pm, Tom St Denis <t...(a)iahu.ca> wrote: > > > > > MD5 is computationally cheaper than SHA-1 if that helps. > > > > Well, that's not necessarily true. SHA-1 has 16 more iterations as > > compared to MD5, however it lacks multiplication and modulo > > operations. Actually, on my box, OpenSSL's implementation of SHA-1 is > > a bit faster than MD5 on short (16byte) messages: > > Multiplication and modulo operations? Maybe he got MD5 and RC5 confused... > SHA-1 takes longer because it has more rounds and operates on more > words at a time. Actually, a full answer would involve an analysis of how the CPU (and cache) handles both of the operations... > I'd personally write off the 16-byte block size since the calling > overhead is non-trivial at that point. Why? Doing hashes of small blocks isn't that uncommon... -- poncho
From: J.D. on 10 Feb 2010 16:55 > > Multiplication and modulo operations? > > Maybe he got MD5 and RC5 confused... RC6 uses a multiplication function: f(x) = x * (2x+1) mod 2^32. RC5 does not.
From: Scott Fluhrer on 10 Feb 2010 17:02
"J.D." <degolyer181(a)yahoo.com> wrote in message news:550319da-3671-4670-86c2-652e936e27c9(a)z39g2000vbb.googlegroups.com... >> > Multiplication and modulo operations? >> >> Maybe he got MD5 and RC5 confused... > > RC6 uses a multiplication function: f(x) = x * (2x+1) mod 2^32. RC5 > does not. Oops, you're correct... |