Client C++ Library
1. Introduction
The Sharemind HI Client C++ Library provides the most complete API, but it is kept minimal and offloads things like configuration and state management to the user of the library.
2. Installation
When developing the client application for Linux, it is recommended to use the sharemind-hi-create-task-enclave-project
binary (from the same package). This pulls in all the necessary dependencies including the Sharemind HI Client CLI, Sharemind HI Server and CMake helpers.
The C++ library can also be used on iOS and Android. Documentation and source code is provided separately, if requested.
The following packages and files are relevant:
Package |
Files |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3. CMake Integration
The following code shows how to link against the C++ client library with CMake:
# (1) Tell CMake where it can find the Sharemind HI sources.
SET(sharemind-hi_ROOT "/home/user/sharemind-hi/sim")
# (2) Search for the package.
FIND_PACKAGE(sharemind-hi REQUIRED COMPONENTS client)
# (3) Link it into your target.
TARGET_LINK_LIBRARIES(your_app PRIVATE sharemind-hi::client)
4. Operations
The sharemind_hi::client::Client
class from the Client.h
file provides the interface to communicate with the Sharemind HI Server.
The class is initialized with a set of configuration options which resemble the configuration file of the CLI client.
// Small excerpt with the most relevant functions.
class Client {
// Manual remote attestation
auto redoAttestation() -> void;
// Enforcer: Approve the DFC
auto dataflowConfigurationApprove(…) -> void;
// Auditor: Access the audit log
auto auditLogDownloadKey() -> AuditLogKey;
// Producer: Upload data
auto dataUpload(...) -> DataId;
// Consumer: Download data
auto dataDownload(...) -> void;
// Task Runner: Run the task
auto taskRun(...) -> TaskInstance;
auto query(...) -> QueryResponse;
// All stakeholders: Query information about a task instance
auto taskWait(...) -> void;
auto taskStatus(...) -> TaskInstance;
// ...
};
The client can be configured to either talk directly through gRPC with the server, or hand all messages to a custom callback of yours which needs to translate the message to a gRPC call in your back end.
This is explained in the TunneledChannel.h
header file.
The audit log can be decrypted with a function from the AuditLog.h
header:
size_t decrypt(std::istream & encryptedFile,
enclave::AuditLogKey const &,
std::ostream & outFile,
bool verify = true);
The header files contain more documentation.