diff options
author | Guido van Rossum <guido@python.org> | 1993-11-01 16:20:18 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-11-01 16:20:18 (GMT) |
commit | 0667626694cf1d7232d3142aef645ecb2d8680c0 (patch) | |
tree | 24ccd4c5693bac43661295eabd6e39b0a232a9ee | |
parent | 13ecc7a1a2ea79d76533cd55210d4f732c7d324a (diff) | |
download | cpython-0667626694cf1d7232d3142aef645ecb2d8680c0.zip cpython-0667626694cf1d7232d3142aef645ecb2d8680c0.tar.gz cpython-0667626694cf1d7232d3142aef645ecb2d8680c0.tar.bz2 |
Replace <<-13 by >>13. Leave old code in #ifdef BUGGY_CODE_BW_COMPAT.
-rw-r--r-- | Modules/rotormodule.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/rotormodule.c b/Modules/rotormodule.c index 71bac90..f01c5fe 100644 --- a/Modules/rotormodule.c +++ b/Modules/rotormodule.c @@ -158,11 +158,26 @@ char *key; int i; int len=strlen(key); for (i=0;i<len;i++) { +#ifdef BUGGY_CODE_BW_COMPAT + /* This is the code as it was originally released. + It causes warnings on many systems and can generate + different results as well. If you have files + encrypted using an older version you may want to + #define BUGGY_CODE_BW_COMPAT so as to be able to + decrypt them... */ k1 = (((k1<<3 | k1<<-13) + key[i]) & 65535); k2 = (((k2<<3 | k2<<-13) ^ key[i]) & 65535); k3 = (((k3<<3 | k3<<-13) - key[i]) & 65535); k4 = ((key[i] - (k4<<3 | k4<<-13)) & 65535); k5 = (((k5<<3 | k5<<-13) ^ ~key[i]) & 65535); +#else + /* This code should be more portable */ + k1 = (((k1<<3 | k1>>13) + key[i]) & 65535); + k2 = (((k2<<3 | k2>>13) ^ key[i]) & 65535); + k3 = (((k3<<3 | k3>>13) - key[i]) & 65535); + k4 = ((key[i] - (k4<<3 | k4>>13)) & 65535); + k5 = (((k5<<3 | k5>>13) ^ ~key[i]) & 65535); +#endif } r->key[0] = (short)k1; r->key[1] = (short)(k2|1); |