diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/utils/mem_ops.h | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/lib/utils/mem_ops.h b/src/lib/utils/mem_ops.h index 175f38e2f..55d572618 100644 --- a/src/lib/utils/mem_ops.h +++ b/src/lib/utils/mem_ops.h @@ -166,28 +166,25 @@ inline void xor_buf(uint8_t out[], { while(length >= 16) { - out[0] ^= in[0]; - out[1] ^= in[1]; - out[2] ^= in[2]; - out[3] ^= in[3]; - out[4] ^= in[4]; - out[5] ^= in[5]; - out[6] ^= in[6]; - out[7] ^= in[7]; - out[8] ^= in[8]; - out[9] ^= in[9]; - out[10] ^= in[10]; - out[11] ^= in[11]; - out[12] ^= in[12]; - out[13] ^= in[13]; - out[14] ^= in[14]; - out[15] ^= in[15]; + uint64_t x0, x1, y0, y1; + memcpy(&x0, in, 8); + memcpy(&x1, in + 8, 8); + memcpy(&y0, out, 8); + memcpy(&y1, out + 8, 8); + + y0 ^= x0; + y1 ^= x1; + memcpy(out, &y0, 8); + memcpy(out + 8, &y1, 8); out += 16; in += 16; length -= 16; } - for(size_t i = 0; i != length; ++i) + while(length > 0) { - out[i] ^= in[i]; + out[0] ^= in[0]; + out += 1; + in += 1; + length -= 1; } } |