def _select_algs(alg_type, algs, possible_algs, none_value=None):
    """Select a set of allowed algorithms"""
    if algs == ():
        return possible_algs
    elif algs:
        result = []
        for alg_str in algs:
            alg = alg_str.encode('ascii')
            if alg not in possible_algs:
                raise ValueError('%s is not a valid %s algorithm' % (
                    alg_str, alg_type))
            result.append(alg)
        return result
    elif none_value:
        return [none_value]
    else:
        raise ValueError('No %s algorithms selected' % alg_type)
