def check_backend_available(backend_name): try: from pyeclib_c import check_backend_available if backend_name.startswith('flat_xor_hd'): int_type = PyECLib_EC_Types.get_by_name('flat_xor_hd') else: int_type = PyECLib_EC_Types.get_by_name(backend_name) if not int_type: return False return check_backend_available(int_type.value) except ImportError: # check_backend_available has been supported since # liberasurecode>=1.2.0 so we need to define the func for older # liberasurecode version # select available k, m values if backend_name.startswith('flat_xor_hd'): k, m = (10, 5) else: k, m = (10, 4) try: ECDriver(ec_type=backend_name, k=k, m=m) except ECDriverError: return False return True
def _PyECLibValidECTypes(): available_ec_types = [] for _type in ALL_EC_TYPES: if check_backend_available(_type): available_ec_types.append(_type) return available_ec_types