aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2005-05-01 08:20:56 +0000
committerKen Raeburn <raeburn@mit.edu>2005-05-01 08:20:56 +0000
commit054e9e78053bf9624c434d2c4e30c6763c540284 (patch)
treeb58c08deac0f1157018813697e0587685686c0b6 /src/lib
parent2fb475de1943c6d243f8e77498c3b86486c9dd82 (diff)
downloadkrb5-054e9e78053bf9624c434d2c4e30c6763c540284.zip
krb5-054e9e78053bf9624c434d2c4e30c6763c540284.tar.gz
krb5-054e9e78053bf9624c434d2c4e30c6763c540284.tar.bz2
* md4.c (Transform) [CONFIG_SMALL]: Roll loops for each round
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17207 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/crypto/md4/ChangeLog4
-rw-r--r--src/lib/crypto/md4/md4.c23
2 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/crypto/md4/ChangeLog b/src/lib/crypto/md4/ChangeLog
index 8968b27..06eac6c 100644
--- a/src/lib/crypto/md4/ChangeLog
+++ b/src/lib/crypto/md4/ChangeLog
@@ -1,3 +1,7 @@
+2005-05-01 Ken Raeburn <raeburn@mit.edu>
+
+ * md4.c (Transform) [CONFIG_SMALL]: Roll loops for each round.
+
2004-02-18 Ken Raeburn <raeburn@mit.edu>
* md4.c: Use ANSI C style function definitions.
diff --git a/src/lib/crypto/md4/md4.c b/src/lib/crypto/md4/md4.c
index 3541bce..5e95d35 100644
--- a/src/lib/crypto/md4/md4.c
+++ b/src/lib/crypto/md4/md4.c
@@ -167,6 +167,28 @@ static void Transform (krb5_ui_4 *buf, krb5_ui_4 *in)
{
register krb5_ui_4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
+#ifdef CONFIG_SMALL
+ int i;
+#define ROTATE { krb5_ui_4 temp; temp = d, d = c, c = b, b = a, a = temp; }
+ for (i = 0; i < 16; i++) {
+ static const unsigned char round1consts[] = { 3, 7, 11, 19, };
+ FF (a, b, c, d, in[i], round1consts[i%4]); ROTATE;
+ }
+ for (i = 0; i < 16; i++) {
+ static const unsigned char round2indices[] = {
+ 0,4,8,12,1,5,9,13,2,6,10,14,3,7,11,15
+ };
+ static const unsigned char round2consts[] = { 3, 5, 9, 13 };
+ GG (a, b, c, d, in[round2indices[i]], round2consts[i%4]); ROTATE;
+ }
+ for (i = 0; i < 16; i++) {
+ static const unsigned char round3indices[] = {
+ 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15
+ };
+ static const unsigned char round3consts[] = { 3, 9, 11, 15 };
+ HH (a, b, c, d, in[round3indices[i]], round3consts[i%4]); ROTATE;
+ }
+#else
/* Round 1 */
FF (a, b, c, d, in[ 0], 3);
FF (d, a, b, c, in[ 1], 7);
@@ -220,6 +242,7 @@ static void Transform (krb5_ui_4 *buf, krb5_ui_4 *in)
HH (d, a, b, c, in[11], 9);
HH (c, d, a, b, in[ 7], 11);
HH (b, c, d, a, in[15], 15);
+#endif
buf[0] += a;
buf[1] += b;