Skip to content

Minor bug in RC2 key expansion function #1120

@Martomate

Description

@Martomate

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions