Asylo
Public Member Functions | Friends | Related Functions | List of all members
asylo::TrustedApplication Class Reference

Abstract base class for trusted applications. More...

#include <trusted_application.h>

Public Member Functions

virtual Status Initialize (const EnclaveConfig &config)
 Implements enclave initialization entry-point. More...
 
virtual Status Run (const EnclaveInput &input, EnclaveOutput *output)
 Implements enclave execution entry-point. More...
 
virtual Status Finalize (const EnclaveFinal &final_input)
 Implements enclave finalization behavior. More...
 
virtual ~TrustedApplication ()=default
 Trivial destructor. More...
 

Friends

int __asylo_user_init (const char *name, const char *config, size_t config_len, char **output, size_t *output_len)
 
int __asylo_user_run (const char *input, size_t input_len, char **output, size_t *output_len)
 
int __asylo_user_fini (const char *input, size_t input_len, char **output, size_t *output_len)
 

Related Functions

(Note that these are not member functions.)

TrustedApplicationBuildTrustedApplication ()
 User-supplied factory function for making a trusted application instance. More...
 
TrustedApplicationGetApplicationInstance ()
 Returns the trusted application instance. More...
 

Detailed Description

Abstract base class for trusted applications.

To implement an enclave application, client code declares a TrustedApplication and implements the entry points it wishes to handle. For example:

class HelloWorld : public TrustedApplication {
public:
Status Initialize(const EnclaveConfig &config) override {
return absl::OkStatus();
}
Status Run(const EnclaveInput &input, EnclaveOutput *output) override {
return absl::OkStatus();
}
Status Finalize(const EnclaveFinal &fini) override {
return absl::OkStatus();
}
};

At startup, the runtime will call the user supplied function BuildTrustedApplication and install the returned instance as the handler for enclave entries events. For instance:

TrustedApplication *BuildTrustedApplication() {
return new HelloWorld;
}

Note that types derived from TrustedApplication must be trivially destructible, and any such destructor will never be invoked by the runtime.

Constructor & Destructor Documentation

◆ ~TrustedApplication()

virtual asylo::TrustedApplication::~TrustedApplication ( )
virtualdefault

Trivial destructor.

Trivial destructor. Note that classes derived from of TrustedApplication must not add a non-trivial destructor, as they will not be called by the enclave runtime.

Member Function Documentation

◆ Finalize()

virtual Status asylo::TrustedApplication::Finalize ( const EnclaveFinal &  final_input)
inlinevirtual

Implements enclave finalization behavior.

Parameters
final_inputMessage passed on enclave finalization.
Returns
OK status or error

◆ Initialize()

virtual Status asylo::TrustedApplication::Initialize ( const EnclaveConfig &  config)
inlinevirtual

Implements enclave initialization entry-point.

Parameters
configThe configuration used to initialize the enclave.
Returns
An OK status or an error if the enclave could not be initialized.

◆ Run()

virtual Status asylo::TrustedApplication::Run ( const EnclaveInput &  input,
EnclaveOutput *  output 
)
inlinevirtual

Implements enclave execution entry-point.

Parameters
inputMessage passed to determine behavior for the Run routine.
outputMessage passed back to the untrusted caller.
Returns
OK status or error

Friends And Related Function Documentation

◆ __asylo_user_fini

int __asylo_user_fini ( const char *  input,
size_t  input_len,
char **  output,
size_t *  output_len 
)
friend

◆ __asylo_user_init

int __asylo_user_init ( const char *  name,
const char *  config,
size_t  config_len,
char **  output,
size_t *  output_len 
)
friend

◆ __asylo_user_run

int __asylo_user_run ( const char *  input,
size_t  input_len,
char **  output,
size_t *  output_len 
)
friend

◆ BuildTrustedApplication()

TrustedApplication * BuildTrustedApplication ( )
related

User-supplied factory function for making a trusted application instance.

Returns
A new TrustedApplication instance, or nullptr on failure.

◆ GetApplicationInstance()

TrustedApplication * GetApplicationInstance ( )
related

Returns the trusted application instance.

Returns
The enclave application instance or nullptr on failure.

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