I am trying to reverse engineer a checksum or CRC wherein an 8 bit number* gets converted to a 5 bit number for error checking. I have an incomplete list of data values and checksums, and need to figure out the algorithm so I can fill in the missing data. I've plotted it out in hex and binary and can't spot a pattern. I'm hoping someone recognizes the algorithm/technique that was used.
Here is my incomplete list (values are in decimal):

*It might be 16 bits. There are another 8 bits that come afterwards that in my sample data are not used and all zeros. In which case it might be:

1024 = 15;
1280 = 2;
1536 = 1;
1792 = 12;
2048 = 17;
2304 = 28;
etc.

If it is 16 bit as I suspect, I need the algorithm to handle those bits as well.
FYI: This is part of a proprietary infrared format used by the old Microsoft Media Center Infrared Keyboard from XP, similar to but not quite like the RC5 protocol. The documentation I have found is sparse, incomplete, and contains errors.

1 Answer
1

I have been working on this project off and on for about 3 years. I've done tons of google searches with every keyword combination I could think of. But since the last time I worked on this and last time I googled, someone else "The Robman" on the JP1 Forums cracked it. Each of the 5 bits of the checksum is xored from various bits of the 16 bit value, but not in any logical or consistent way.

Checksum Bit 4 = xor of value bits 15,14,13,12,11

Checksum Bit 3 = xor of value bits 10,9,8,7,6,5,4

Checksum Bit 2 = xor of value bits 15,14,11,10,9,8,2,1

Checksum Bit 1 = xor of value bits 13,12,10,9,7,5,3,2,0

Checksum Bit 0 = xor of value bits 15,13,11,10,8,7,4,3,0

The Robman did not explain how he ended up figuring that out but I've tested it and got a 100% match. I'd be curious to find out his technique.

Possibly just brute force; possibly he plotted it in binary and spotted a pattern.
– immibisApr 11 '18 at 3:55

The technique is quite simple: find two values that differ only in bit 1, see how their checksums differ. Then find two values that differ in bit 2, ... It's called differential cryptanalysis.
– Rainer P.Apr 11 '18 at 21:05

I got an answer back from The Robman. He wrote a script with a bunch of nested loops trying various combinations of bits until he found the right one.
– DrWizardApr 12 '18 at 13:58