summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/crypto/sha1/ChangeLog4
-rw-r--r--src/lib/crypto/sha1/shs.c28
2 files changed, 32 insertions, 0 deletions
diff --git a/src/lib/crypto/sha1/ChangeLog b/src/lib/crypto/sha1/ChangeLog
index 487f09e40..9da70f9c4 100644
--- a/src/lib/crypto/sha1/ChangeLog
+++ b/src/lib/crypto/sha1/ChangeLog
@@ -1,3 +1,7 @@
+2005-05-01 Ken Raeburn <raeburn@mit.edu>
+
+ * shs.c (SHSTransform) [CONFIG_SMALL]: Roll loops for each round.
+
2004-02-18 Ken Raeburn <raeburn@mit.edu>
* shs.c: Use ANSI C style function definitions.
diff --git a/src/lib/crypto/sha1/shs.c b/src/lib/crypto/sha1/shs.c
index f97856ee4..a6d3c9f8b 100644
--- a/src/lib/crypto/sha1/shs.c
+++ b/src/lib/crypto/sha1/shs.c
@@ -112,6 +112,32 @@ void SHSTransform(SHS_LONG *digest, const SHS_LONG *data)
E = digest[ 4 ];
memcpy(eData, data, sizeof (eData));
+#ifdef CONFIG_SMALL
+
+ {
+ int i;
+ SHS_LONG temp;
+ for (i = 0; i < 20; i++) {
+ SHS_LONG x = (i < 16) ? eData[i] : expand(eData, i);
+ subRound(A, B, C, D, E, f1, K1, x);
+ temp = E, E = D, D = C, C = B, B = A, A = temp;
+ }
+ for (i = 20; i < 40; i++) {
+ subRound(A, B, C, D, E, f2, K2, expand(eData, i));
+ temp = E, E = D, D = C, C = B, B = A, A = temp;
+ }
+ for (i = 40; i < 60; i++) {
+ subRound(A, B, C, D, E, f3, K3, expand(eData, i));
+ temp = E, E = D, D = C, C = B, B = A, A = temp;
+ }
+ for (i = 60; i < 80; i++) {
+ subRound(A, B, C, D, E, f4, K4, expand(eData, i));
+ temp = E, E = D, D = C, C = B, B = A, A = temp;
+ }
+ }
+
+#else
+
/* Heavy mangling, in 4 sub-rounds of 20 interations each. */
subRound( A, B, C, D, E, f1, K1, eData[ 0 ] );
subRound( E, A, B, C, D, f1, K1, eData[ 1 ] );
@@ -197,6 +223,8 @@ void SHSTransform(SHS_LONG *digest, const SHS_LONG *data)
subRound( C, D, E, A, B, f4, K4, expand( eData, 78 ) );
subRound( B, C, D, E, A, f4, K4, expand( eData, 79 ) );
+#endif
+
/* Build message digest */
digest[ 0 ] += A;
digest[ 0 ] &= 0xffffffff;