* Interprets c as 8 groups of 5 bits which are the coefficients of a degree 8 polynomial over GF(32), * multiplies that polynomial by x, computes its remainder modulo a generator, and adds the constant term val. * * This generator is G(x) = x^8 + {30}x^7 + {23}x^6 + {15}x^5 + {14}x^4 + {10}x^3 + {6}x^2 + {12}x + {9}. * It is chosen to define an cyclic error detecting code which is selected by:
| 108 | * print("0x%x" % v) |
| 109 | */ |
| 110 | uint64_t PolyMod(uint64_t c, int val) |
| 111 | { |
| 112 | uint8_t c0 = c >> 35; |
| 113 | c = ((c & 0x7ffffffff) << 5) ^ val; |
| 114 | if (c0 & 1) c ^= 0xf5dee51989; |
| 115 | if (c0 & 2) c ^= 0xa9fdca3312; |
| 116 | if (c0 & 4) c ^= 0x1bab10e32d; |
| 117 | if (c0 & 8) c ^= 0x3706b1677a; |
| 118 | if (c0 & 16) c ^= 0x644d626ffd; |
| 119 | return c; |
| 120 | } |
| 121 | |
| 122 | std::string DescriptorChecksum(const std::span<const char>& span) |
| 123 | { |
no outgoing calls
no test coverage detected