From 5c394ff2033f5f812896da41e38a9ab8b565e6e3 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Fri, 9 Jun 2023 20:10:36 +0100 Subject: [PATCH] Use a single fast-path in mbedtls_xor, gains around 1% in benchmarks Signed-off-by: Dave Rodgman --- library/common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/common.h b/library/common.h index 89f3b1ffb..b48a1fc66 100644 --- a/library/common.h +++ b/library/common.h @@ -142,11 +142,12 @@ inline void mbedtls_xor(unsigned char *r, const unsigned char *a, const unsigned uint64_t x = mbedtls_get_unaligned_uint64(a + i) ^ mbedtls_get_unaligned_uint64(b + i); mbedtls_put_unaligned_uint64(r + i, x); } -#endif +#else for (; (i + 4) <= n; i += 4) { uint32_t x = mbedtls_get_unaligned_uint32(a + i) ^ mbedtls_get_unaligned_uint32(b + i); mbedtls_put_unaligned_uint32(r + i, x); } +#endif #endif for (; i < n; i++) { r[i] = a[i] ^ b[i];