Line 146:
Line 146:
uint16_t * plain = (uint16_t *) voidplain;
uint16_t * plain = (uint16_t *) voidplain;
uint16_t * cipher = (uint16_t *) voidcipher;
uint16_t * cipher = (uint16_t *) voidcipher;
−
size_t halfCount = size / sizeof(uint16_t);
+
size_t halfCount = size >> 1; // Divide by 2 rounding towards zero
uint16_t xorval = htobe16(0xE963);
uint16_t xorval = htobe16(0xE963);
Line 160:
Line 160:
uint16_t * cipher = (uint16_t *) voidcipher;
uint16_t * cipher = (uint16_t *) voidcipher;
uint16_t * plain = (uint16_t *) voidplain;
uint16_t * plain = (uint16_t *) voidplain;
−
size_t halfCount = size / sizeof(uint16_t);
+
size_t halfCount = size >> 1; // Divide by 2 rounding towards zero
−
if (halfCount) {
+
uint16_t xorval = htobe16(0xE963);
−
size_t i;
+
size_t i;
−
for (i = halfCount - 1; i > 0; i--) {
−
plain[i] = cipher[i] ^ cipher[i - 1];
−
}
−
plain[0] = cipher[0] ^ htobe16(0xE963);
+
for (i = 0; i < halfCount; i++) {
+
uint16_t word = plain[i];
+
cipher[i] = xorval ^ word;
+
xorval = word;
}
}
}</nowiki>
}</nowiki>