2016-11-07 71 views
1

我有一个串行通信协议,并且在查找已使用的校验和算法时遇到了一些麻烦。我已经尝试了几个CRC16 algorithms,他们都没有工作。找出使用了哪种CRC16算法

消息看起来像这样(在十六进制):

55 13 04 03 09 f1 01 00 00 06 50 08 00 02 00 00 00 cc 1a 
55 13 04 03 09 f1 01 00 00 06 50 00 00 02 00 00 00 94 3b 
55 13 04 03 09 f1 02 00 00 06 50 08 00 02 00 00 00 7f e4 
55 13 04 03 09 f1 02 00 00 06 50 00 00 02 00 00 00 27 c5 
55 13 04 03 09 f1 03 00 00 06 50 08 00 02 00 00 00 ee b1 
55 13 04 03 09 f1 03 00 00 06 50 00 00 02 00 00 00 b6 90 

我知道起始字节是0x55和第二字节是消息长度

如果有必要,我可以提供更多的数据。任何帮助或提示,将不胜感激;)

最好的问候,阿米尔

+0

这对于[security.SE]来说是个好问题吗? – Cullub

回答

0

这取决于CRC计算在什么字节。

您可以使用RevEng尝试从示例中提取CRC参数。从您的示例中可以明显看出,这是一个16位的CRC,其多项式为0x1021,并且反映了CRC(多项式在应用于输入时位反转,CRC寄存器向右移位,而不是左移) 。然而,初始值和最终的异或 - 取决于CRC计算的字节。为了真正地指出这些,你还需要不同长度的示例消息。

RevEng catalog of 16-bit CRCs有几个标准的CRC,它可能是:

width=16 poly=0x1021 init=0xffff refin=true refout=true xorout=0x0000 check=0x6f91 name="CRC-16/MCRF4XX" 
width=16 poly=0x1021 init=0xb2aa refin=true refout=true xorout=0x0000 check=0x63d0 name="CRC-16/RIELLO" 
width=16 poly=0x1021 init=0x89ec refin=true refout=true xorout=0x0000 check=0x26b1 name="CRC-16/TMS37157" 
width=16 poly=0x1021 init=0xc6c6 refin=true refout=true xorout=0x0000 check=0xbf05 name="CRC-A" 
width=16 poly=0x1021 init=0x0000 refin=true refout=true xorout=0x0000 check=0x2189 name="KERMIT" 
width=16 poly=0x1021 init=0xffff refin=true refout=true xorout=0xffff check=0x906e name="X-25" 

我没有得到任何的假设整个事情的是消息,也不如果我把第一个或两个字节。

该列表中最常见的CRC是KERMIT(也称为CCITT CRC-16)和X-25。