refactored hmac generate/verify