Add constant time memcmp_ct function

This patch adds a constant time memory compare function that mitigates
timing attacks. This patch also fixes three locations where this could
be a problem.

Signed-off-by: Joakim Bech <joakim.bech@linaro.org>