Clarify HMAC code and add ProtocolErr type