def checksum(key, data, errors, context):
    """
    Validates the `'checksum'` values of the CKAN package. A checksum is
    considered valid under the following conditions:
     - when either `hash` or `hash_algorithm` is present, the other must too be
       present
     - all given `'hash'` properties which are present are also valid

    :param Any key: Injected by CKAN core
    :param dict[Any, Any] data: Injected by CKAN core
    :param dict[Any, Any] errors: Injected by CKAN core
    :param dict[Any, Any] context: Injected by CKAN core
    :rtype: None
    """
    hash_tuple = ('resources', key[1], 'hash')

    if hash_tuple in data and data[hash_tuple] == '':
        data.pop(hash_tuple, None)
        errors.pop(hash_tuple, None)

    properties = [hash_tuple, ('resources', key[1], 'hash_algorithm')]
    properties_present = (prop in data for prop in properties if prop)
    message_format = '{0} is required when providing a valid checksum'

    if not any(properties_present):
        return key, data, errors, context

    if not all(properties_present):
        for prop in properties:
            errors[prop].append(message_format.format(prop[2]))

    return key, data, errors, context