Asylo
Public Member Functions | Static Public Member Functions | List of all members
asylo::EnclaveManager Class Reference

A manager object responsible for creating and managing enclave instances. More...

#include <enclave_manager.h>

Public Member Functions

Status LoadEnclave (const std::string &name, const EnclaveLoader &loader, void *base_address=nullptr)
 Loads an enclave. More...
 
Status LoadEnclave (const std::string &name, const EnclaveLoader &loader, EnclaveConfig config, void *base_address=nullptr)
 Loads an enclave. More...
 
EnclaveClientGetClient (const std::string &name) const
 Fetches a client to a loaded enclave. More...
 
const std::string GetName (const EnclaveClient *client) const
 Returns the name of an enclave client. More...
 
Status DestroyEnclave (EnclaveClient *client, const EnclaveFinal &final_input, bool skip_finalize=false)
 Destroys an enclave. More...
 
SharedResourceManagershared_resources ()
 Fetches the shared resource manager object. More...
 
const SharedResourceManagershared_resources () const
 Fetches the shared resource manager object. More...
 

Static Public Member Functions

static StatusOr< EnclaveManager * > Instance ()
 Fetches the EnclaveManager singleton instance. More...
 
static Status Configure (const EnclaveManagerOptions &options)
 Configures the enclave manager. More...
 

Detailed Description

A manager object responsible for creating and managing enclave instances.

EnclaveManager is a singleton class that tracks the status of enclaves within a process. Users of this class first supply a configuration using the static Configure() method, and then get a pointer to the singleton instance as specified by this configuration by calling the static Instance() method. Note that the EnclaveManager class must be configured before the instance pointer can be obtained.

The EnclaveManager::Configure() method takes an instance of the EnclaveManagerOptions as its only input. This instance can be configured by calling its public setter methods. Note that these setter methods return an instance of the EnclaveManagerOptions() by reference so that the various setters could be chained together.

Example Usage:

EnclaveManagerOptions()
.set_config_server_address("[::]:8000")
.set_daemon_connection_timeout(absl::Milliseconds(100)));
auto manager_result = EnclaveManager::Instance();
if (!manager_result.ok()) {
LOG(QFATAL) << manager_result.status();
}
EnclaveManager *manager = manager_result.ValueOrDie();
...

One of the responsibilities of the EnclaveManager class is to provide sane initial configuration to the enclaves it launches. The contents of the EnclaveManagerOptions instance control how the default values for the configuration are chosen.

Member Function Documentation

◆ Configure()

static Status asylo::EnclaveManager::Configure ( const EnclaveManagerOptions options)
static

Configures the enclave manager.

Parameters
optionsConfiguration options as described in EnclaveManagerOptions.

◆ DestroyEnclave()

Status asylo::EnclaveManager::DestroyEnclave ( EnclaveClient client,
const EnclaveFinal &  final_input,
bool  skip_finalize = false 
)

Destroys an enclave.

Destroys an enclave. This method calls client's EnterAndFinalize entry point with final_input unless skip_finalize is true, then calls client's DestroyEnclave method, and then removes client's name from the EnclaveManager client registry. The manager owns the client, so removing it calls client's destructor and frees its memory.

Parameters
clientA client attached to the enclave to destroy.
final_inputInput to pass the enclave's finalizer.
skip_finalizeIf true, the enclave is destroyed without invoking its Finalize method.

◆ GetClient()

EnclaveClient* asylo::EnclaveManager::GetClient ( const std::string &  name) const

Fetches a client to a loaded enclave.

Parameters
nameThe name of an EnclaveClient that may be registered in the EnclaveManager.
Returns
A mutable pointer to the EnclaveClient if the name is registered. Otherwise returns nullptr.

◆ GetName()

const std::string asylo::EnclaveManager::GetName ( const EnclaveClient client) const

Returns the name of an enclave client.

Parameters
clientA pointer to a client that may be registered in the EnclaveManager.
Returns
The name of an enclave client. If no enclave matches client the empty string will be returned.

◆ Instance()

static StatusOr<EnclaveManager *> asylo::EnclaveManager::Instance ( )
static

Fetches the EnclaveManager singleton instance.

Returns
A StatusOr containing either the global EnclaveManager instance or an error describing why it could not be returned.

◆ LoadEnclave() [1/2]

Status asylo::EnclaveManager::LoadEnclave ( const std::string &  name,
const EnclaveLoader loader,
void *  base_address = nullptr 
)

Loads an enclave.

Loads a new enclave with default enclave config settings and binds it to a name. The actual work of opening the enclave is delegated to the passed loader object.

It is an error to specify a name which is already bound to an enclave.

Example:

LoadEnclave("/EchoEnclave", SgxLoader("echoService.so"));
Parameters
nameName to bind the loaded enclave under.
loaderConfigured enclave loader to load from.

◆ LoadEnclave() [2/2]

Status asylo::EnclaveManager::LoadEnclave ( const std::string &  name,
const EnclaveLoader loader,
EnclaveConfig  config,
void *  base_address = nullptr 
)

Loads an enclave.

Loads a new enclave with custom enclave config settings and binds it to a name. The actual work of opening the enclave is delegated to the passed loader object.

It is an error to specify a name which is already bound to an enclave.

Example:

EnclaveConfig config;
... // populate config proto.
LoadEnclave("/EchoEnclave", SgxLoader("echoService.so"), config);
Parameters
nameName to bind the loaded enclave under.
loaderConfigured enclave loader to load from.
configEnclave configuration to launch the enclave with.

◆ shared_resources() [1/2]

SharedResourceManager* asylo::EnclaveManager::shared_resources ( )
inline

Fetches the shared resource manager object.

Returns
The SharedResourceManager instance.

◆ shared_resources() [2/2]

const SharedResourceManager* asylo::EnclaveManager::shared_resources ( ) const
inline

Fetches the shared resource manager object.

Returns
The SharedResourceManager instance.

The documentation for this class was generated from the following file: