diff options
author | jkim <jkim@FreeBSD.org> | 2006-07-25 22:20:05 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2006-07-25 22:20:05 +0000 |
commit | 80e8ac2fbce049780719a4be4aa0734e70e5a5ad (patch) | |
tree | 191957cbccf26256736f69538da240c4fbef6ea1 | |
parent | ac9fb55e4032e6fd5eec0e0a72543cfa27615e80 (diff) | |
download | FreeBSD-src-80e8ac2fbce049780719a4be4aa0734e70e5a5ad.zip FreeBSD-src-80e8ac2fbce049780719a4be4aa0734e70e5a5ad.tar.gz |
Fix 32-bit integer math on 64-bit processor. Just use int32_t(!) instead
of incorrect and machine-dependent integer math. Now we can encrypt a file
on an i386 and decrypt it on an amd64, and vice versa.
Submitted by: Andrew Heybey < ath at niksun dot com >
-rw-r--r-- | usr.bin/enigma/enigma.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/usr.bin/enigma/enigma.c b/usr.bin/enigma/enigma.c index 25bb456..68fd29d 100644 --- a/usr.bin/enigma/enigma.c +++ b/usr.bin/enigma/enigma.c @@ -1,4 +1,4 @@ -/* +/*- * "enigma.c" is in file cbw.tar from * anonymous FTP host watmsg.waterloo.edu: pub/crypt/cbw.tar.Z * @@ -40,7 +40,7 @@ setup(char *pw) int ic, i, k, temp; char salt[3]; unsigned rnd; - long seed; + int32_t seed; strlcpy(salt, pw, sizeof(salt)); memcpy(buf, crypt(pw, salt), sizeof(buf)); @@ -53,13 +53,6 @@ setup(char *pw) } for(i=0;i<ROTORSZ;i++) { seed = 5*seed + buf[i%13]; - if( sizeof(long) > 4 ) { - /* Force seed to stay in 32-bit signed math */ - if( seed & 0x80000000 ) - seed = seed | (-1L & ~0xFFFFFFFFL); - else - seed &= 0x7FFFFFFF; - } rnd = seed % 65521; k = ROTORSZ-1 - i; ic = (rnd&MASK)%(k+1); @@ -140,7 +133,7 @@ shuffle(char deckary[]) { int i, ic, k, temp; unsigned rnd; - static long seed = 123; + static int32_t seed = 123; for(i=0;i<ROTORSZ;i++) { seed = 5*seed + buf[i%13]; |