From 76f572ed0469a277d92378848250b7a9705d3071 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Sun, 20 Nov 2016 23:38:12 +0100 Subject: [PATCH] modes/ctr128.c: fix false carry in counter increment procedure. GH issue #1916 affects only big-endian platforms. TLS is not affected, because TLS fragment is never big enough. Reviewed-by: Matt Caswell --- crypto/modes/ctr128.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/modes/ctr128.c b/crypto/modes/ctr128.c index b7ffb73ab7..03920b4473 100644 --- a/crypto/modes/ctr128.c +++ b/crypto/modes/ctr128.c @@ -52,7 +52,7 @@ static void ctr128_inc_aligned(unsigned char *counter) --n; d = data[n] += c; /* did addition carry? */ - c = ((d - c) ^ d) >> (sizeof(size_t) * 8 - 1); + c = ((d - c) & ~d) >> (sizeof(size_t) * 8 - 1); } while (n); } #endif -- 2.34.1