There seems to be a missing minus sign in the key expansion function for RC2 on this line. The T1 variable should be negated (which is what they do here).
- var TM = 0xff >> (T1 & 0x07);
+ var TM = 0xff >> (-T1 & 0x07);
This bug only affects RC2 if the "effective key bits" (T1) is not a multiple of 8, and since the default is 128 it probably doesn't affect that many users. Notably, CyberChef is not affected (since they use the default value).
I have verified that 0xff >> (-T1 & 0x07) is equivalent to the expression used in the spec, whereas 0xff >> (T1 & 0x07) is not.
There seems to be a missing minus sign in the key expansion function for RC2 on this line. The
T1variable should be negated (which is what they do here).This bug only affects RC2 if the "effective key bits" (T1) is not a multiple of 8, and since the default is 128 it probably doesn't affect that many users. Notably, CyberChef is not affected (since they use the default value).
I have verified that
0xff >> (-T1 & 0x07)is equivalent to the expression used in the spec, whereas0xff >> (T1 & 0x07)is not.