Skip to content

Instantly share code, notes, and snippets.

View sangfansh's full-sized avatar

Fan Sang sangfansh

View GitHub Profile
#ifndef WEBSERVICE_H
#define WEBSERVICE_H
#include <string>
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
#include <stdio.h>
#include <curl/curl.h>
#include <jsoncpp/json/json.h>
int VerificationManager::init() {
if (this->sp) {
delete this->sp;
this->sp = new ServiceProvider(this->ws);
}
this->nm->Init();
this->nm->connectCallbackHandler([this](string v, int type) {
return this->incomingHandler(v, type);
});
vector<string> VerificationManager::incomingHandler(string v, int type) {
vector<string> res;
if (!v.empty()) {
string s;
bool ret;
switch (type) {
case RA_MSG0: {
Messages::MessageMsg0 msg0;
void VerificationManager::start() {
this->nm->startService();
Log("Remote attestation done");
}
void NetworkManagerClient::startService() {
this->client->startConnection();
}
void Client::startConnection() {
Log("Start connecting...");
boost::system::error_code ec;
boost::asio::connect(socket_.lowest_layer(), this->endpoint_iterator, ec);
handle_connect(ec);
}
void Client::handle_connect(const boost::system::error_code &error) {
int main(int argc, char** argv) {
sgx_enclave_id_t eid = 0;
sgx_launch_token_t token = {0};
int updated, ret;
sgx_status_t ecall_status, enclave_status;
enclave_status = sgx_create_enclave(ENCLAVE_FILE, SGX_DEBUG_FLAG, &token, &updated, &eid, NULL);
if(enclave_status != SGX_SUCCESS) {
error_print("Fail to initialize enclave.");
#define MAX_ITEMS 100
#define MAX_ITEM_SIZE 100
// item
struct Item {
char title[MAX_ITEM_SIZE];
char username[MAX_ITEM_SIZE];
char password[MAX_ITEM_SIZE];
};
typedef struct Item item_t;
enclave {
// includes
include "wallet.h"
// define ECALLs
trusted {
public int ecall_create_wallet(
int ecall_create_wallet(const char* master_password) {
//
// OVERVIEW:
// 1. check password policy
// 2. [ocall] abort if wallet already exist
// 3. create wallet
// 4. seal wallet
// 5. [ocall] save wallet
// 6. exit enclave