protected function validateHashContext($context)
    {
        if (!($context instanceof HashContext) && (false === $context
            || !is_resource($context)
            || (is_resource($context) && static::HASH_CONTEXT_RESOURCE_TYPE !== get_resource_type($context)))) {
            throw new InvalidArgumentException(
                'Unable to initialize hashing context. Your system might not support the supplied algorithm.'
            );
        }

        return $context;
    }