summaryrefslogtreecommitdiffstats
path: root/src/lib/crypto
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2005-05-01 08:29:10 +0000
committerKen Raeburn <raeburn@mit.edu>2005-05-01 08:29:10 +0000
commit1cc4c8f72a6086a93342b23645dfbf5ba0dc3d9d (patch)
tree06fd5894033fc8bcaef6bddc12b2f2a4c83a1a5c /src/lib/crypto
parent054e9e78053bf9624c434d2c4e30c6763c540284 (diff)
downloadkrb5-1cc4c8f72a6086a93342b23645dfbf5ba0dc3d9d.tar.gz
krb5-1cc4c8f72a6086a93342b23645dfbf5ba0dc3d9d.tar.xz
krb5-1cc4c8f72a6086a93342b23645dfbf5ba0dc3d9d.zip
* md5.c (Transform) [CONFIG_SMALL]: Roll loops for each round
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17208 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto')
-rw-r--r--src/lib/crypto/md5/ChangeLog4
-rw-r--r--src/lib/crypto/md5/md5.c56
2 files changed, 60 insertions, 0 deletions
diff --git a/src/lib/crypto/md5/ChangeLog b/src/lib/crypto/md5/ChangeLog
index 26f5c8f38..ab8d2ca30 100644
--- a/src/lib/crypto/md5/ChangeLog
+++ b/src/lib/crypto/md5/ChangeLog
@@ -1,3 +1,7 @@
+2005-05-01 Ken Raeburn <raeburn@mit.edu>
+
+ * md5.c (Transform) [CONFIG_SMALL]: Roll loops for each round.
+
2004-02-18 Ken Raeburn <raeburn@mit.edu>
* md5.c: Use ANSI C style function definitions.
diff --git a/src/lib/crypto/md5/md5.c b/src/lib/crypto/md5/md5.c
index 6c4cc57a3..4b56755a8 100644
--- a/src/lib/crypto/md5/md5.c
+++ b/src/lib/crypto/md5/md5.c
@@ -204,6 +204,60 @@ 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++) {
+ const unsigned char round1s[] = { 7, 12, 17, 22 };
+ const krb5_ui_4 round1consts[] = {
+ 3614090360UL, 3905402710UL, 606105819UL, 3250441966UL,
+ 4118548399UL, 1200080426UL, 2821735955UL, 4249261313UL,
+ 1770035416UL, 2336552879UL, 4294925233UL, 2304563134UL,
+ 1804603682UL, 4254626195UL, 2792965006UL, 1236535329UL,
+ };
+ FF (a, b, c, d, in[i], round1s[i%4], round1consts[i]);
+ ROTATE;
+ }
+ for (i = 0; i < 16; i++) {
+ const unsigned char round2s[] = { 5, 9, 14, 20 };
+ const krb5_ui_4 round2consts[] = {
+ 4129170786UL, 3225465664UL, 643717713UL, 3921069994UL,
+ 3593408605UL, 38016083UL, 3634488961UL, 3889429448UL,
+ 568446438UL, 3275163606UL, 4107603335UL, 1163531501UL,
+ 2850285829UL, 4243563512UL, 1735328473UL, 2368359562UL,
+ };
+ int r2index = (1 + i * 5) % 16;
+ GG (a, b, c, d, in[r2index], round2s[i%4], round2consts[i]);
+ ROTATE;
+ }
+ for (i = 0; i < 16; i++) {
+ static const unsigned char round3s[] = { 4, 11, 16, 23 };
+ static const krb5_ui_4 round3consts[] = {
+ 4294588738UL, 2272392833UL, 1839030562UL, 4259657740UL,
+ 2763975236UL, 1272893353UL, 4139469664UL, 3200236656UL,
+ 681279174UL, 3936430074UL, 3572445317UL, 76029189UL,
+ 3654602809UL, 3873151461UL, 530742520UL, 3299628645UL,
+ };
+ int r3index = (5 + i * 3) % 16;
+ HH (a, b, c, d, in[r3index], round3s[i%4], round3consts[i]);
+ ROTATE;
+ }
+ for (i = 0; i < 16; i++) {
+ static const unsigned char round4s[] = { 6, 10, 15, 21 };
+ static const krb5_ui_4 round4consts[] = {
+ 4096336452UL, 1126891415UL, 2878612391UL, 4237533241UL,
+ 1700485571UL, 2399980690UL, 4293915773UL, 2240044497UL,
+ 1873313359UL, 4264355552UL, 2734768916UL, 1309151649UL,
+ 4149444226UL, 3174756917UL, 718787259UL, 3951481745UL,
+ };
+ int r4index = (7 * i) % 16;
+ II (a, b, c, d, in[r4index], round4s[i%4], round4consts[i]);
+ ROTATE;
+ }
+
+#else
+
/* Round 1 */
#define S11 7
#define S12 12
@@ -292,6 +346,8 @@ static void Transform (krb5_ui_4 *buf, krb5_ui_4 *in)
II ( c, d, a, b, in[ 2], S43, 718787259UL); /* 63 */
II ( b, c, d, a, in[ 9], S44, 3951481745UL); /* 64 */
+#endif /* small? */
+
buf[0] += a;
buf[1] += b;
buf[2] += c;