-
Notifications
You must be signed in to change notification settings - Fork 0
/
RA_client.hpp
123 lines (102 loc) · 2.41 KB
/
RA_client.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*!
*
* RA_client.hpp
*
* Copyright (c) 2020 IWATA Daiki
*
* This software is released under the MIT License.
* see http://opensource.org/licenses/mit-license
*
* Some function are released from Intel Corporation.
* LIENSE: https://github.com/intel/sgx-ra-sample/blob/master/LICENSE
*/
#ifndef _RA_client_hpp
#define RA_client_hpp
#pragma once
#include <string.h>
#include <string>
#ifndef _WIN32
#include "config.h"
#endif
//KS add
#include "sample_libcrypto.h"
//KS add end
#include <stdlib.h>
#include <limits.h>
#include <stdio.h>
#include <sys/stat.h>
#include <string.h>
#include <sys/types.h>
#ifdef _WIN32
#include <intrin.h>
#include <openssl/applink.c>
#include "win32/getopt.h"
#else
#include <signal.h>
#include <getopt.h>
#include <unistd.h>
#endif
#include <sgx_key_exchange.h>
#include <sgx_report.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
// #include "json.hpp"
#include "common.h"
#include "hexutil.h"
#include "fileio.h"
#include "crypto.h"
#include "byteorder.h"
#include "msgio.h"
#include "protocol.h"
#include "base64.h"
#include "iasrequest.h"
#include "logfile.h"
#include "settings.h"
#include "enclave_verify.h"
// using namespace json;
using namespace std;
#include <map>
#include <string>
#include <iostream>
#include <algorithm>
#ifdef _WIN32
#define strdup(x) _strdup(x)
#endif
extern MsgIO *msgio;
static const unsigned char def_service_private_key[32] = {
0x90, 0xe7, 0x6c, 0xbb, 0x2d, 0x52, 0xa1, 0xce,
0x3b, 0x66, 0xde, 0x11, 0x43, 0x9c, 0x87, 0xec,
0x1f, 0x86, 0x6a, 0x3b, 0x65, 0xb6, 0xae, 0xea,
0xad, 0x57, 0x34, 0x53, 0xd1, 0x03, 0x8c, 0x01
};
typedef struct ra_session_struct {
unsigned char g_a[64];
unsigned char g_b[64];
unsigned char kdk[16];
unsigned char smk[16];
unsigned char sk[16];
unsigned char mk[16];
unsigned char vk[16];
} ra_session_t;
typedef struct config_struct {
sgx_spid_t spid;
unsigned char pri_subscription_key[IAS_SUBSCRIPTION_KEY_SIZE+1];
unsigned char sec_subscription_key[IAS_SUBSCRIPTION_KEY_SIZE+1];
uint16_t quote_type;
EVP_PKEY *service_private_key;
char *proxy_server;
char *ca_bundle;
char *user_agent;
unsigned int proxy_port;
unsigned char kdk[16];
X509_STORE *store;
X509 *signing_ca;
unsigned int apiver;
int strict_trust;
sgx_measurement_t req_mrsigner;
sgx_prod_id_t req_isv_product_id;
sgx_isv_svn_t min_isvsvn;
int allow_debug_enclave;
} config_t;
int handshake_RA(int argc, char **argv, ra_session_t& session);
#endif