-
- if (length == 0) return (~remainder);
-
- for (int byte = 0; byte < length; ++byte) {
- remainder ^= (message[byte] << 8);
- for (uint8_t bit = 8; bit > 0; --bit) {
- if (remainder & 0x8000) {
- remainder = (remainder << 1) ^ polynomial;
- } else {
- remainder = (remainder << 1);
- }
- }
- }
- return remainder;
+
+ if (length == 0)
+ return (~remainder);
+
+ for (uint32_t i = 0; i < length; ++i) {
+ remainder ^= (message[i] << 8);
+ for (uint8_t bit = 8; bit > 0; --bit) {
+ if (remainder & 0x8000) {
+ remainder = (remainder << 1) ^ polynomial;
+ } else {
+ remainder = (remainder << 1);
+ }
+ }
+ }
+ return remainder;