managementshim/management.c
//Returns whether enclave is scheduled on this core.
Returns whether enclave is scheduled on this core.
Returns whether enclave is scheduled on this core .
enclave_id_t managementRoutine(const CoreID_t managementCore) {
  enclave_id_t retVal = ENCLAVE_INVALID_ID;
  int index;
  enclave_id_t savedEnclaveID = getCurrentEnclaveID();
  static enclave_id_t internalArgument = ENCLAVE_INVALID_ID;
  CoreID_t chosenCore = managementCore;
  struct Message_t message;
  receiveMessage(&message);
  struct Message_t response;
  response.source = message.destination;
  response.destination = message.source;
  response.type = message.type;
  response.arguments[0] = 0;
  response.arguments[1] = 0;
  if(message.source == ENCLAVE_DEFAULT_ID &&
      message.destination == ENCLAVE_MANAGEMENT_ID) {
    switch(message.type) {
      case MSG_CREATE:
#ifdef PRAESIDIO_DEBUG
        output_string("management.c: Received create enclave message.\n");
#endif
        index = createEnclave();
        if(index >= 0) {
          struct EnclaveData_t *enclaveData = (struct EnclaveData_t *) ENCLAVE_DATA_BASE_ADDRESS;
          response.arguments[0] = enclaveData[index].eID;
        } else {
          response.arguments[0] = ENCLAVE_INVALID_ID;
        }
        break;
      case MSG_DONATE_PAGE:
#ifdef PRAESIDIO_DEBUG
        output_string("management.c: Received donate page enclave message.\n");
#endif
        donatePage(message.arguments[0], message.arguments[1]);
        break;
      case MSG_FINALIZE:
#ifdef PRAESIDIO_DEBUG
        output_string("management.c: Received finalize enclave message.\n");
#endif
        finalizeEnclave(message.arguments[0]);
        break;
      case MSG_RUN:
#ifdef PRAESIDIO_DEBUG
        output_string("management.c: Received switch enclave message.\n");
#endif
        if(chosenCore == managementCore) {
          retVal = message.arguments[0];
        } else {
          switchEnclave(chosenCore, message.arguments[0]);
        }
        break;
      case MSG_ATTEST:
#ifdef PRAESIDIO_DEBUG
        output_string("management.c: Received attest enclave message.\n");
#endif
        break;
      case MSG_DELETE:
#ifdef PRAESIDIO_DEBUG
        output_string("management.c: Received delete enclave message.\n");
#endif
        break;
#ifdef PRAESIDIO_DEBUG
      default:
        output_string("management.c: Received message with unknown type.\n");
        break;
#endif
    }
    sendMessage(&response);
  }
  return retVal;
}
enclave_id_t managementRoutine ( const CoreID_t managementCore ) { enclave_id_t retVal = ENCLAVE_INVALID_ID ; int index ; enclave_id_t savedEnclaveID = getCurrentEnclaveID ( ) ; static enclave_id_t internalArgument = ENCLAVE_INVALID_ID ; CoreID_t chosenCore = managementCore ; struct Message_t message ; receiveMessage ( & message ) ; struct Message_t response ; response . source = message . destination ; response . destination = message . source ; response . type = message . type ; response . arguments [ 0 ] = 0 ; response . arguments [ 1 ] = 0 ; if ( message . source == ENCLAVE_DEFAULT_ID && message . destination == ENCLAVE_MANAGEMENT_ID ) { switch ( message . type ) { case MSG_CREATE : #ifdef PRAESIDIO_DEBUG output_string ( " \n " ) ; #endif index = createEnclave ( ) ; if ( index >= 0 ) { struct EnclaveData_t * enclaveData = ( struct EnclaveData_t * ) ENCLAVE_DATA_BASE_ADDRESS ; response . arguments [ 0 ] = enclaveData [ index ] . eID ; } else { response . arguments [ 0 ] = ENCLAVE_INVALID_ID ; } break ; case MSG_DONATE_PAGE : #ifdef PRAESIDIO_DEBUG output_string ( " \n " ) ; #endif donatePage ( message . arguments [ 0 ] , message . arguments [ 1 ] ) ; break ; case MSG_FINALIZE : #ifdef PRAESIDIO_DEBUG output_string ( " \n " ) ; #endif finalizeEnclave ( message . arguments [ 0 ] ) ; break ; case MSG_RUN : #ifdef PRAESIDIO_DEBUG output_string ( " \n " ) ; #endif if ( chosenCore == managementCore ) { retVal = message . arguments [ 0 ] ; } else { switchEnclave ( chosenCore , message . arguments [ 0 ] ) ; } break ; case MSG_ATTEST : #ifdef PRAESIDIO_DEBUG output_string ( " \n " ) ; #endif break ; case MSG_DELETE : #ifdef PRAESIDIO_DEBUG output_string ( " \n " ) ; #endif break ; #ifdef PRAESIDIO_DEBUG default : output_string ( " \n " ) ; break ; #endif } sendMessage ( & response ) ; } return retVal ; }
Returns whether enclave is scheduled on this core.
Returns whether enclave is scheduled on this core .
//TODO make this work with multiple enclave cores. //TODO implement attestation using the measurements of the management shim and the enclave. //TODO implement delete enclave when management shim interupts enclaves