Skip to content

Instantly share code, notes, and snippets.

@sangfansh
Created August 10, 2018 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sangfansh/9e159a13dc47ed196facd14a9a2e148a to your computer and use it in GitHub Desktop.
Save sangfansh/9e159a13dc47ed196facd14a9a2e148a to your computer and use it in GitHub Desktop.
#ifndef MESSAGEHANDLER_H
#define MESSAGEHANDLER_H
#include <string>
#include <stdio.h>
#include <limits.h>
#include <unistd.h>
#include <iostream>
#include <iomanip>
#include "Enclave.h"
#include "NetworkManagerServer.h"
#include "Messages.pb.h"
#include "UtilityFunctions.h"
#include "remote_attestation_result.h"
#include "LogBase.h"
#include "../GeneralSettings.h"
using namespace std;
using namespace util;
class MessageHandler {
public:
MessageHandler(int port = Settings::rh_port);
virtual ~MessageHandler();
sgx_ra_msg3_t* getMSG3();
int init();
void start();
vector<string> incomingHandler(string v, int type);
private:
sgx_status_t initEnclave();
uint32_t getExtendedEPID_GID(uint32_t *extended_epid_group_id);
sgx_status_t getEnclaveStatus();
void assembleAttestationMSG(Messages::AttestationMessage msg, ra_samp_response_header_t **pp_att_msg);
string handleAttestationResult(Messages::AttestationMessage msg);
void assembleMSG2(Messages::MessageMSG2 msg, sgx_ra_msg2_t **pp_msg2);
string handleMSG2(Messages::MessageMSG2 msg);
string handleMSG0(Messages::MessageMsg0 msg);
string generateMSG1();
string handleVerification();
string generateMSG0();
string createInitMsg(int type, string msg);
protected:
Enclave *enclave = NULL;
private:
int busy_retry_time = 4;
NetworkManagerServer *nm = NULL;
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment