简体   繁体   中英

Compounding CRC polynomials

I am trying to compound 2 CRC polynomials. I have a message for which I produce a CRC using one polynomial. I then CRC the result of the first CRC in order to obtain a second result. Is there any possible way to do this in one go?

Example: Given the message 0xC and the polynomial 0x17 I compute the CRC which is 0xA. I then take this result and another polynomial 0x13 and compute the CRC again which produces the result 0xD. I am trying to derive a new polynomial which given the message 0xC will produce the result 0xD.

I have only tried to work this on paper so I do not have any code but some code should look like this:

def CRC(message, poly):
    #CRC implementation


a = CRC(0xC, 0x17)
#The value of a right now would be 0xA

b = CRC(a, 0x13)
#The value of b is 0xD right now

I am trying to obtain the same result using my initial message and one single function call

b = CRC(0xC, ???)
#I would want the value of b after this call to be 0xD

It seems like a dumb request but I find it helpful. I have tried applying simple math specifically The quotient remainder theorem but I find multiplying in finite fields to be overly complex.

I misunderstood the question in my original answer. I'm assuming this is a single nibble message, since the second CRC only has a single nibble input, the CRC from 0x17. This could be implemented using a table with 16 entries. Using n to represent the nibble, using carryless and borrowless binary math, and hex numbers:

crc = (((n*10)%17)*10)%13 = (((n*7)%17)*3)%13

I'm wondering if instead, the goal here is to work with a message of more than one nibble. For example, say the message is {xyz}, then the encoded message would be

{x y z crc17{x y z} crc13{x y z}}

or

{x y z crc17{x y z} crc13{x y z crc17{x y z}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM