Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0667626

Browse files
committed
Replace <<-13 by >>13. Leave old code in #ifdef BUGGY_CODE_BW_COMPAT.
1 parent 13ecc7a commit 0667626

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Modules/rotormodule.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,26 @@ char *key;
158158
int i;
159159
int len=strlen(key);
160160
for (i=0;i<len;i++) {
161+
#ifdef BUGGY_CODE_BW_COMPAT
162+
/* This is the code as it was originally released.
163+
It causes warnings on many systems and can generate
164+
different results as well. If you have files
165+
encrypted using an older version you may want to
166+
#define BUGGY_CODE_BW_COMPAT so as to be able to
167+
decrypt them... */
161168
k1 = (((k1<<3 | k1<<-13) + key[i]) & 65535);
162169
k2 = (((k2<<3 | k2<<-13) ^ key[i]) & 65535);
163170
k3 = (((k3<<3 | k3<<-13) - key[i]) & 65535);
164171
k4 = ((key[i] - (k4<<3 | k4<<-13)) & 65535);
165172
k5 = (((k5<<3 | k5<<-13) ^ ~key[i]) & 65535);
173+
#else
174+
/* This code should be more portable */
175+
k1 = (((k1<<3 | k1>>13) + key[i]) & 65535);
176+
k2 = (((k2<<3 | k2>>13) ^ key[i]) & 65535);
177+
k3 = (((k3<<3 | k3>>13) - key[i]) & 65535);
178+
k4 = ((key[i] - (k4<<3 | k4>>13)) & 65535);
179+
k5 = (((k5<<3 | k5>>13) ^ ~key[i]) & 65535);
180+
#endif
166181
}
167182
r->key[0] = (short)k1;
168183
r->key[1] = (short)(k2|1);

0 commit comments

Comments
 (0)