Refactor HMAC validation