0
votes

Suppose the following scenario:

  • There is a binary image of some application, for a microcontroller (to avoid stirring this towards ELF / PE format problems, anyway, my particular related problem is a microcontroller project).
  • This binary image is protected by CRC (to detect errors in it, no cryptographic concerns).
  • I want to have a section it which can be replaced later (for example using a bootloader), without affecting the CRC.

The problem is solveable, an example for CRC32 follows:

  • Inner stream 1: 0x49 0xA3 0x45 0xEF => CRC32: 0xA1DD6F3B
  • Inner stream 2: 0xAD 0x33 0x10 0x86 => CRC32: 0xF6717149
  • Binary 1: 0x11 0x49 0xA3 0x45 0xEF 0x3B 0x6F 0xDD 0xA1 0x22 => 0xDEAD20F7
  • Binary 2: 0x11 0xAD 0x33 0x10 0x86 0x49 0x71 0x71 0xF6 0x22 => 0xDEAD20F7

That is, embedding a block of data with CRC32 within another one having a CRC32, the inner block can be replaced without affecting the outer CRC (this relates to that performing the CRC calculation on the block with the CRC included, you get the same "magic value": 0xDEBB20E3, or complemented as could be seen in a CRC calculator: 0x2144DF1C).

I think this inclusion shouldn't affect the performance (error detecting capability) of CRC, neither in any part of the outer block or the inner block (if I checked it only by the outer CRC, naturally the inner block checked by its own CRC can't be affected), however I am not entirely sure.

(Of course the inner block won't get any improvement in its error detection by the outer CRC as when an undetectable fault by the inner CRC happens in it, that means it yields the same "magic value", thus also defeating the outer CRC's capability to detect an error in it)

So the question is, if CRC is used in this manner, whether parts of the outer block (or the inner block if only checked by the outer CRC) would suffer any degradation in the performance of error detection.

2
the inner block [doesn't benefit from] the outer CRC I doubt this holds with different polynomialsgreybeard
@greybeard Maybe true. But it is not a requirement to improve error correction performance, just to be sure that it doesn't degrade anywhere. Practically the inner block only has a CRC to eliminate its effect on the outer block's CRC. I am not even sure a different polynomial inner block CRC would work for this goal.Jubatian
This is rather unclear. Where did 0x22 come from? What does => 0xDEAD20F7 mean? What is "magic value": 0xDEBB20E3 and how did you get that?Lundin
@Lundin Ouch, I will reconsider the wording of the question then, I thought these were obvious for someone having enough interest in CRC to see this question relevant for him. The "magic value" is a property of CRC algorithms: If you calculate CRC including the CRC value itself, you will always get the same result, in case of CRC32, this is 0xDEBB20E3. The 0x11 and 0x22 in the examples are supposed parts of the binary embedding the inner stream, while 0xDEAD20F7 is the CRC32 of those binaries, demonstrating that the replacement of the inner stream doesn't alter it.Jubatian
@Jubatian I have quite some experience of CRC, having implemented such algorithms myself both in C and digital logic hardware. And I don't understand the question. None of these are the polynomial in any of the commonly known CRC32. Which CRC32 are you using? Are you using inverted or non-inverted FCS? Do you include the FCS initially in the calculation or not? And so on. So I take it that 0xDEBB20E3 is the value that you get when you calculate a package with nothing else but the polynomial? Which CRC32 is that? See a list at en.wikipedia.org/wiki/Cyclic_redundancy_checkLundin

2 Answers

0
votes

No. In fact you have increased the overall error detection probability some by inserting a second CRC inside the message. You can check that one as well to see if there is an error just in the replaced section.

-1
votes

Whether or not an error is caught by the CRC check depends on which bits of the input are flipped by the error, not the original value of those bits.

The data being checked, therefore, has no effect on the error detecting capability of the CRC unless it predisposes the transmission system to producing certain kinds of errors.

That is unlikely to be the case, and almost certainly won't depend on the CRC of the data, so your scheme won't degrade error detection.