Exemplo n.º 1
0
def get_enclave_service_info(spid) :
    """Retrieve information about the enclave. This function should
    only be called outside of the normal initialization of the enclave
    and corresponding libraries.
    """
    global _pdo
    global logger

    if _pdo :
        raise Exception('get_enclave_service_info must be called exclusively')

    enclave._SetLogger(logger)

    signed_enclave = __find_enclave_library(None)
    logger.debug("Attempting to load enclave at: %s", signed_enclave)

    num_of_enclaves = 1
    pdo = enclave.pdo_enclave_info(signed_enclave, spid, num_of_enclaves)
    if pdo is None :
        raise Exception('unable to load the enclave')

    info = [ pdo.mr_enclave, pdo.basename ]
    pdo = None

    return info
Exemplo n.º 2
0
def initialize_with_configuration(config):
    global _pdo
    global _ias
    global logger

    enclave._SetLogger(logger)

    # Ensure that the required keys are in the configuration
    valid_keys = set(
        ['spid', 'ias_url', 'spid_cert_file', 'block_store_file_name'])
    found_keys = set(config.keys())

    missing_keys = valid_keys.difference(found_keys)
    if missing_keys:
        raise \
            ValueError(
                'PDO enclave config file missing the following keys: '
                '{}'.format(
                    ', '.join(sorted(list(missing_keys)))))

    num_of_enclaves = int(
        config['num_of_enclaves']) if 'num_of_enclaves' in config else 1

    if not _ias:
        _ias = \
            ias_client.IasClient(
                IasServer = config['ias_url'],
                SpidCert = config['spid_cert_file'],
                Spid = config['spid'],
                HttpsProxy = config.get('https_proxy',""))

    if not _pdo:
        signed_enclave = __find_enclave_library(config)
        logger.debug("Attempting to load enclave at: %s", signed_enclave)
        _pdo = enclave.pdo_enclave_info(signed_enclave, config['spid'],
                                        num_of_enclaves)
        logger.info("Basename: %s", get_enclave_basename())
        logger.info("MRENCLAVE: %s", get_enclave_measurement())

    sig_rl_updated = False
    while not sig_rl_updated:
        try:
            update_sig_rl()
            sig_rl_updated = True
        except (SSLError, Timeout, HTTPError) as e:
            logger.warning("Failed to retrieve initial sig rl from IAS: %s",
                           str(e))
            logger.warning("Retrying in 60 sec")
            time.sleep(60)

    enclave.block_store_init(config['block_store_file_name'])
Exemplo n.º 3
0
def get_enclave_service_info(spid) :
    global _pdo
    global _ias
    global logger

    enclave._SetLogger(logger)

    num_of_enclaves = 1

    if not _pdo:
        signed_enclave = __find_enclave_library(None)
        logger.debug("Attempting to load enclave at: %s", signed_enclave)
        _pdo = enclave.pdo_enclave_info(signed_enclave, spid, num_of_enclaves)
        logger.info("Basename: %s", get_enclave_basename())
        logger.info("MRENCLAVE: %s", get_enclave_measurement())