<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_hash_algorithm(value=None):
 """Parse a hash algorithm value. The most common use case is to pass a str naming a class in :py:mod:`~cg:cryptography.hazmat.primitives.hashes`. For convenience, passing ``None`` will return the value of :ref:`CA_DIGEST_ALGORITHM <settings-ca-digest-algorithm>`, and passing an :py:class:`~cg:cryptography.hazmat.primitives.hashes.HashAlgorithm` will return that instance unchanged. Example usage:: Traceback (most recent call last):
 ValueError: Unknown hash algorithm: Wrong Traceback (most recent call last):
 ValueError: Unknown type passed: object Parameters value : str or :py:class:`~cg:cryptography.hazmat.primitives.hashes.HashAlgorithm`, optional The value to parse, the function description on how possible values are used. Returns ------- algorithm A :py:class:`~cg:cryptography.hazmat.primitives.hashes.HashAlgorithm` instance. Raises ------ ValueError If an unknown object is passed or if ``value`` does not name a known algorithm. """

    if value is None:
        return ca_settings.CA_DIGEST_ALGORITHM
    elif isinstance(value, type) and issubclass(value, hashes.HashAlgorithm):
        return value()
    elif isinstance(value, hashes.HashAlgorithm):
        return value
    elif isinstance(value, six.string_types):
        try:
            return getattr(hashes, value.strip())()
        except AttributeError:
            raise ValueError('Unknown hash algorithm: %s' % value)
    else:
        raise ValueError('Unknown type passed: %s' % type(value).__name__)