summaryrefslogtreecommitdiffstats
path: root/src/lib/crypto
diff options
context:
space:
mode:
authorRichard Basch <probe@mit.edu>1995-11-28 19:50:53 +0000
committerRichard Basch <probe@mit.edu>1995-11-28 19:50:53 +0000
commit7d339153b49875a6a3fc28705bb9c393fc420eb9 (patch)
tree49b5878c2a405efc6ce06cd30aa91f310179db37 /src/lib/crypto
parent4a2201102cd90d4b3579fd8a5509d8d1ae1f962e (diff)
downloadkrb5-7d339153b49875a6a3fc28705bb9c393fc420eb9.tar.gz
krb5-7d339153b49875a6a3fc28705bb9c393fc420eb9.tar.xz
krb5-7d339153b49875a6a3fc28705bb9c393fc420eb9.zip
Corrected bit rotation to match documented algorithm
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7139 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/crypto')
-rw-r--r--src/lib/crypto/des/u_nfold.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/lib/crypto/des/u_nfold.c b/src/lib/crypto/des/u_nfold.c
index e35edd480..4311b9185 100644
--- a/src/lib/crypto/des/u_nfold.c
+++ b/src/lib/crypto/des/u_nfold.c
@@ -73,10 +73,11 @@ mit_des_n_fold(inbuf, inlen, outbuf, outlen)
/* Rotate input */
k = ((bytes/inlen) * ROTATE_VALUE) % (inlen*8);
- for (j = (k+7)/8; j < inlen + (k/7)/8; j++)
+ for (j = (k+7)/8; j < inlen + (k+7)/8; j++)
tempbuf[j % inlen] =
- (inbuf[((8*j-k)/8)%inlen] & (((1<<(8-(k&7)))-1) <<(k&7))) +
- (inbuf[((8*j-k)/8 + 1)%inlen] >> (8-(k&7)));
+ ((inbuf[((8*j-k)/8)%inlen] << ((8-(k&7))&7)) +
+ ((k&7) ? (inbuf[((8*j-k)/8 +1)%inlen] >> (k&7)) : 0))
+ & 0xff;
}
@@ -85,7 +86,7 @@ mit_des_n_fold(inbuf, inlen, outbuf, outlen)
j = i;
k = 0;
while (j--) {
- k = outbuf[(bytes+j) % outlen] + tempbuf[(bytes+j) % inlen] + k;
+ k += outbuf[(bytes+j) % outlen] + tempbuf[(bytes+j) % inlen];
outbuf[(bytes+j) % outlen] = k & 0xff;
k >>= 8;
}
@@ -98,7 +99,7 @@ mit_des_n_fold(inbuf, inlen, outbuf, outlen)
}
bytes += i;
- } while (((bytes % inlen) == 0) && ((bytes % outlen) == 0));
+ } while (((bytes % inlen) != 0) || ((bytes % outlen) != 0));
return 0;
}