lkml.org 
[lkml]   [2007]   [Jun]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] [CRYPTO] Add optimized SHA-1 implementation for i486+
linux@horizon.com wrote:
> /* Majority: (x^y)|(y&z)|(z&x) = (x & z) + ((x ^ z) & y)
> #define F3(x,y,z,dest) \
> movl z, TMP; \
> andl x, TMP; \
> addl TMP, dest; \
> movl z, TMP; \
> xorl x, TMP; \
> andl y, TMP; \
> addl TMP, dest
>
> Since y is the most recently computed result (it's rotated in the
> previous round), I arranged the code to delay its use as late as
> possible.
>
>
> Now you have one more register to play with.

Okay, thanks. It doesn't actually give one more register except in the
F3 rounds (TMP2 is normally used to hold the magic constants) but it's a
good cleanup.

> A faster way is to unroll 5 iterations and do:
> e += F(b, c, d) + K + rol32(a, 5) + W[i ]; b = rol32(b, 30);
> d += F(a, b, c) + K + rol32(e, 5) + W[i+1]; a = rol32(a, 30);
> c += F(e, a, b) + K + rol32(d, 5) + W[i+2]; e = rol32(e, 30);
> b += F(d, e, a) + K + rol32(c, 5) + W[i+3]; d = rol32(d, 30);
> a += F(c, d, e) + K + rol32(b, 5) + W[i+4]; c = rol32(c, 30);
> then loop over that 4 times each. This is somewhat larger, but
> still reasonably compact; only 20 of the 80 rounds are written out
> long-hand.

I got this code from Nettle, originally, and I never looked at the SHA-1
round structure very closely. I'll give that approach a try.

Thanks
--Benjamin Gilbert
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-06-11 21:21    [W:0.052 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site