Subject: Re: [PATCH] builtin/receive-pack: use constant-time comparison for HMAC value

From: SZEDER Gábor <[email-masked]>
Date: Wed, 22 Apr 2020 12:27:34 +0200

On Thu, Apr 09, 2020 at 11:37:30PM +0000, brian m. carlson wrote:
> +/*
> + * 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++)
  ^