Re: [PATCH] builtin/receive-pack: use constant-time comparison for HMAC value
On Thu, Apr 09, 2020 at 11:37:30PM +0000, brian m. carlson wrote:
Show 11 quoted lines
> +/*
> + * Return zero if a and b are equal up to n bytes and nonzero if they are not.
> + * This operation is guaranteed to run in constant time to avoid leaking data.
> + */
> +static int constant_memequal(const char *a, const char *b, size_t n)
> +{
> + int res = 0;
> + for (size_t i = 0; i < n; i++)
> + res |= a[i] ^ b[i];
> + return res;
> +} CC builtin/receive-pack.o
builtin/receive-pack.c: In function ‘constant_memequal’:
builtin/receive-pack.c:509:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
for (size_t i = 0; i < n; i++)
^