From fb2139eeee603320cdb3e135c4c63c67492602e0 Mon Sep 17 00:00:00 2001 From: Lucas Gabriel Vuotto Date: Tue, 11 Jun 2024 02:29:00 +0000 Subject: [PATCH] ct/cmp: save the final shift by switching the direction of shifts --- ct.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ct.c b/ct.c index 7775407..9599c49 100644 --- a/ct.c +++ b/ct.c @@ -25,10 +25,10 @@ lc_ct_cmp(const uint8_t *x, const uint8_t *y, size_t l) for (; l > 0; l--) r |= *x++ ^ *y++; - /* Ensures that if any bit is set, then bit 7 is set. */ - r |= r << 4; - r |= r << 2; - r |= r << 1; + /* Ensures that if any bit is set, then LSB is set. */ + r |= r >> 4; + r |= r >> 2; + r |= r >> 1; - return 0xffffffff + ((r & 0x80) >> 7); + return 0xffffffff + (r & 1); }