/* Rotate array buf of length 'len' to the left (towards low indices) by 'num' bytes if ctl is 1; otherwise, leave it unchanged. This is constant-time. 'num' MUST be lower than 'len'. 'len' MUST be lower than or equal to 64.  */
static void cond_rotate(uint32_t ctl, unsigned char *buf, size_t len, size_t num)
/* Rotate array buf of length 'len' to the left (towards low indices) by 'num' bytes if ctl is 1; otherwise, leave it unchanged. This is constant-time. 'num' MUST be lower than 'len'. 'len' MUST be lower than or equal to 64.  */
static void cond_rotate(uint32_t ctl, unsigned char *buf, size_t len, size_t num)
{
	unsigned char tmp[64];
	size_t u, v;
	for (u = 0, v = num; u < len; u ++) {
		tmp[u] = MUX(ctl, buf[v], buf[u]);
		if (++ v == len) {
			v = 0;
		}
	}
	memcpy(buf, tmp, len);
}