|
@@ -23,7 +23,7 @@ std::vector<uint16_t> storage_map;
|
|
|
std::vector<uint16_t> ingestion_map;
|
|
|
unsigned long setup_time;
|
|
|
uint16_t nthreads = 1;
|
|
|
-bool private_routing;
|
|
|
+bool token_channel;
|
|
|
|
|
|
// Split a hostport string like "127.0.0.1:12000" at the rightmost colon
|
|
|
// into a host part "127.0.0.1" and a port part "12000".
|
|
@@ -84,13 +84,13 @@ void displayMessage(unsigned char *msg, uint16_t msg_size,
|
|
|
unsigned char *ptr = msg;
|
|
|
rid = *((clientid_t*) ptr);
|
|
|
ptr+=sizeof(rid);
|
|
|
- if (!private_routing) {
|
|
|
+ if (!token_channel) {
|
|
|
prio = *((uint32_t*) ptr);
|
|
|
ptr+=sizeof(prio);
|
|
|
}
|
|
|
sid = *((clientid_t*) ptr);
|
|
|
ptr+=sizeof(sid);
|
|
|
- if (private_routing) {
|
|
|
+ if (token_channel) {
|
|
|
outbuf << std::hex
|
|
|
<< "Cli: "
|
|
|
<< std::setfill('0') << std::setw(8) << client
|
|
@@ -158,37 +158,37 @@ void displayPtMessageBundle(unsigned char *bundle, uint16_t num_out,
|
|
|
printf("\n");
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t encPubMsgBundleSize(uint16_t pub_out, uint16_t msg_size)
|
|
|
+static inline uint32_t encPubMsgBundleSize(uint16_t id_out, uint16_t msg_size)
|
|
|
{
|
|
|
- return SGX_AESGCM_IV_SIZE + (uint32_t(pub_out) * msg_size)
|
|
|
+ return SGX_AESGCM_IV_SIZE + (uint32_t(id_out) * msg_size)
|
|
|
+ SGX_AESGCM_MAC_SIZE;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t ptPubMsgBundleSize(uint16_t pub_out, uint16_t msg_size)
|
|
|
+static inline uint32_t ptPubMsgBundleSize(uint16_t id_out, uint16_t msg_size)
|
|
|
{
|
|
|
- return uint32_t(pub_out) * msg_size;
|
|
|
+ return uint32_t(id_out) * msg_size;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t encMsgBundleSize(uint16_t priv_out, uint16_t msg_size)
|
|
|
+static inline uint32_t encMsgBundleSize(uint16_t token_out, uint16_t msg_size)
|
|
|
{
|
|
|
- return SGX_AESGCM_IV_SIZE + (uint32_t(priv_out) * (msg_size + TOKEN_SIZE))
|
|
|
+ return SGX_AESGCM_IV_SIZE + (uint32_t(token_out) * (msg_size + TOKEN_SIZE))
|
|
|
+ SGX_AESGCM_MAC_SIZE;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t ptMsgBundleSize(uint16_t priv_out, uint16_t msg_size)
|
|
|
+static inline uint32_t ptMsgBundleSize(uint16_t token_out, uint16_t msg_size)
|
|
|
{
|
|
|
- return uint32_t(priv_out) * (msg_size + TOKEN_SIZE);
|
|
|
+ return uint32_t(token_out) * (msg_size + TOKEN_SIZE);
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t encMailboxSize(uint16_t priv_in, uint16_t msg_size)
|
|
|
+static inline uint32_t encMailboxSize(uint16_t token_in, uint16_t msg_size)
|
|
|
{
|
|
|
- return SGX_AESGCM_IV_SIZE + (uint32_t(priv_in) * msg_size)
|
|
|
+ return SGX_AESGCM_IV_SIZE + (uint32_t(token_in) * msg_size)
|
|
|
+ SGX_AESGCM_MAC_SIZE;
|
|
|
}
|
|
|
|
|
|
-static inline uint32_t ptMailboxSize(uint16_t priv_in, uint16_t msg_size)
|
|
|
+static inline uint32_t ptMailboxSize(uint16_t token_in, uint16_t msg_size)
|
|
|
{
|
|
|
- return uint32_t(priv_in) * msg_size;
|
|
|
+ return uint32_t(token_in) * msg_size;
|
|
|
}
|
|
|
|
|
|
bool config_parse(Config &config, const std::string configstr,
|
|
@@ -212,14 +212,14 @@ bool config_parse(Config &config, const std::string configstr,
|
|
|
config.msg_size = pentry.second.get_value<uint16_t>();
|
|
|
} else if (!pentry.first.compare("user_count")) {
|
|
|
config.user_count = pentry.second.get_value<uint32_t>();
|
|
|
- } else if (!pentry.first.compare("priv_out")) {
|
|
|
- config.m_priv_out = pentry.second.get_value<uint8_t>();
|
|
|
- } else if (!pentry.first.compare("priv_in")) {
|
|
|
- config.m_priv_in = pentry.second.get_value<uint8_t>();
|
|
|
- } else if (!pentry.first.compare("pub_out")) {
|
|
|
- config.m_pub_out = pentry.second.get_value<uint8_t>();
|
|
|
- } else if (!pentry.first.compare("pub_in")) {
|
|
|
- config.m_pub_in = pentry.second.get_value<uint8_t>();
|
|
|
+ } else if (!pentry.first.compare("token_out")) {
|
|
|
+ config.m_token_out = pentry.second.get_value<uint8_t>();
|
|
|
+ } else if (!pentry.first.compare("token_in")) {
|
|
|
+ config.m_token_in = pentry.second.get_value<uint8_t>();
|
|
|
+ } else if (!pentry.first.compare("id_out")) {
|
|
|
+ config.m_id_out = pentry.second.get_value<uint8_t>();
|
|
|
+ } else if (!pentry.first.compare("id_in")) {
|
|
|
+ config.m_id_in = pentry.second.get_value<uint8_t>();
|
|
|
// A stub hardcoded shared secret to derive various
|
|
|
// keys for client <-> server communications and tokens
|
|
|
// In reality, this would be a key exchange
|
|
@@ -227,8 +227,8 @@ bool config_parse(Config &config, const std::string configstr,
|
|
|
std::string hex_key = pentry.second.data();
|
|
|
memcpy(config.master_secret, hex_key.c_str(),
|
|
|
SGX_AESGCM_KEY_SIZE);
|
|
|
- } else if (!pentry.first.compare("private_routing")) {
|
|
|
- config.private_routing = pentry.second.get_value<bool>();
|
|
|
+ } else if (!pentry.first.compare("token_channel")) {
|
|
|
+ config.token_channel = pentry.second.get_value<bool>();
|
|
|
} else {
|
|
|
std::cerr << "Unknown field in params: " <<
|
|
|
pentry.first << "\n";
|
|
@@ -403,7 +403,7 @@ void Client::initClient(clientid_t cid, uint16_t stg_id,
|
|
|
id = stg_id << DEST_UID_BITS;
|
|
|
id += (cid/num_storage_nodes);
|
|
|
|
|
|
- token_list = new token[config.m_priv_out];
|
|
|
+ token_list = new token[config.m_token_out];
|
|
|
memcpy(ing_key, ikey, SGX_AESGCM_KEY_SIZE);
|
|
|
memcpy(stg_key, skey, SGX_AESGCM_KEY_SIZE);
|
|
|
}
|
|
@@ -552,11 +552,11 @@ void Client::initializeIngSocket(boost::asio::io_context &ioc,
|
|
|
Populates the buffer pt_msgbundle with a valid message pt_msgbundle.
|
|
|
Assumes that it is supplied with a pt_msgbundle buffer of the correct length
|
|
|
|
|
|
- num_out is either priv_out or pub_out, depending on whether we're
|
|
|
- doing private or public routing
|
|
|
+ num_out is either token_out or id_out, depending on whether we're
|
|
|
+ doing token channel or ID channel routing
|
|
|
|
|
|
Correct length for pt_msgbundle = (num_out)*(msg_size) +
|
|
|
- (only for private routing) (num_out)*TOKEN_SIZE
|
|
|
+ (only for token channel routing) (num_out)*TOKEN_SIZE
|
|
|
|
|
|
*/
|
|
|
void Client::generateMessageBundle(uint8_t num_out, uint32_t msg_size,
|
|
@@ -573,8 +573,8 @@ void Client::generateMessageBundle(uint8_t num_out, uint32_t msg_size,
|
|
|
uint32_t rid = id;
|
|
|
#if 0
|
|
|
uint32_t dest_uid_mask = (1 << DEST_UID_BITS) - 1;
|
|
|
- if (!private_routing) {
|
|
|
- // If we're testing public routing, have each user send a
|
|
|
+ if (!token_channel) {
|
|
|
+ // If we're testing ID channel routing, have each user send a
|
|
|
// message to the user with the same local id, but on
|
|
|
// storage server 0.
|
|
|
rid &= dest_uid_mask;
|
|
@@ -584,11 +584,11 @@ void Client::generateMessageBundle(uint8_t num_out, uint32_t msg_size,
|
|
|
memcpy(ptr, &rid, sizeof(rid));
|
|
|
ptr += sizeof(rid);
|
|
|
|
|
|
- // Priority (for public routing only)
|
|
|
- if (!private_routing) {
|
|
|
+ // Priority (for ID channel routing only)
|
|
|
+ if (!token_channel) {
|
|
|
uint32_t priority = 0;
|
|
|
#ifdef SHOW_RECEIVED_MESSAGES
|
|
|
- // If we're testing public routing, set the priority so that
|
|
|
+ // If we're testing ID channel routing, set the priority so that
|
|
|
// messages to different users will have the highest
|
|
|
// priority messages sent from users at different servers
|
|
|
uint32_t id_low_bits = id &
|
|
@@ -613,9 +613,9 @@ void Client::generateMessageBundle(uint8_t num_out, uint32_t msg_size,
|
|
|
ptr+=(remaining_message_size);
|
|
|
}
|
|
|
|
|
|
- if(private_routing) {
|
|
|
+ if(token_channel) {
|
|
|
// Add the tokens for this msgbundle
|
|
|
- memcpy(ptr, token_list, config.m_priv_out * TOKEN_SIZE);
|
|
|
+ memcpy(ptr, token_list, config.m_token_out * TOKEN_SIZE);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -688,33 +688,33 @@ static thread_local LimitLogger
|
|
|
|
|
|
void Client::sendMessageBundle()
|
|
|
{
|
|
|
- uint16_t priv_out = config.m_priv_out;
|
|
|
- uint16_t pub_out = config.m_pub_out;
|
|
|
+ uint16_t token_out = config.m_token_out;
|
|
|
+ uint16_t id_out = config.m_id_out;
|
|
|
uint16_t msg_size = config.msg_size;
|
|
|
uint32_t send_pt_msgbundle_size, send_enc_msgbundle_size;
|
|
|
|
|
|
- if(private_routing) {
|
|
|
- send_pt_msgbundle_size = ptMsgBundleSize(priv_out, msg_size);
|
|
|
- send_enc_msgbundle_size = encMsgBundleSize(priv_out, msg_size);
|
|
|
+ if(token_channel) {
|
|
|
+ send_pt_msgbundle_size = ptMsgBundleSize(token_out, msg_size);
|
|
|
+ send_enc_msgbundle_size = encMsgBundleSize(token_out, msg_size);
|
|
|
} else {
|
|
|
- send_pt_msgbundle_size = ptPubMsgBundleSize(pub_out, msg_size);
|
|
|
- send_enc_msgbundle_size = encPubMsgBundleSize(pub_out, msg_size);
|
|
|
+ send_pt_msgbundle_size = ptPubMsgBundleSize(id_out, msg_size);
|
|
|
+ send_enc_msgbundle_size = encPubMsgBundleSize(id_out, msg_size);
|
|
|
}
|
|
|
|
|
|
unsigned char *send_pt_msgbundle =
|
|
|
(unsigned char*) malloc (send_pt_msgbundle_size);
|
|
|
unsigned char *send_enc_msgbundle =
|
|
|
(unsigned char*) malloc (send_enc_msgbundle_size);
|
|
|
- if(private_routing) {
|
|
|
- generateMessageBundle(priv_out, msg_size, send_pt_msgbundle);
|
|
|
+ if(token_channel) {
|
|
|
+ generateMessageBundle(token_out, msg_size, send_pt_msgbundle);
|
|
|
} else {
|
|
|
- generateMessageBundle(pub_out, msg_size, send_pt_msgbundle);
|
|
|
+ generateMessageBundle(id_out, msg_size, send_pt_msgbundle);
|
|
|
}
|
|
|
encryptMessageBundle(send_enc_msgbundle_size, send_pt_msgbundle,
|
|
|
send_enc_msgbundle);
|
|
|
|
|
|
#ifdef VERBOSE_CLIENT
|
|
|
- displayPtMessageBundle(send_pt_msgbundle, priv_out, msg_size);
|
|
|
+ displayPtMessageBundle(send_pt_msgbundle, token_out, msg_size);
|
|
|
#endif
|
|
|
|
|
|
free(send_pt_msgbundle);
|
|
@@ -935,19 +935,19 @@ using the tokens they received in this epoch
|
|
|
|
|
|
void Client::epoch_process() {
|
|
|
|
|
|
- uint32_t pt_token_size = uint32_t(config.m_priv_out) * TOKEN_SIZE;
|
|
|
+ uint32_t pt_token_size = uint32_t(config.m_token_out) * TOKEN_SIZE;
|
|
|
uint32_t token_bundle_size = pt_token_size + SGX_AESGCM_IV_SIZE
|
|
|
+ SGX_AESGCM_MAC_SIZE;
|
|
|
unsigned char *enc_tokens = nullptr;
|
|
|
- uint16_t num_in = config.m_pub_in;
|
|
|
+ uint16_t num_in = config.m_id_in;
|
|
|
|
|
|
std::vector<boost::asio::mutable_buffer> toreceive;
|
|
|
|
|
|
- if (private_routing) {
|
|
|
+ if (token_channel) {
|
|
|
enc_tokens = (unsigned char*) malloc (token_bundle_size);
|
|
|
toreceive.push_back(boost::asio::buffer(enc_tokens,
|
|
|
token_bundle_size));
|
|
|
- num_in = config.m_priv_in;
|
|
|
+ num_in = config.m_token_in;
|
|
|
}
|
|
|
|
|
|
uint16_t msg_size = config.msg_size;
|
|
@@ -961,8 +961,8 @@ void Client::epoch_process() {
|
|
|
toreceive.push_back(boost::asio::buffer(recv_enc_mailbox,
|
|
|
recv_enc_mailbox_size));
|
|
|
|
|
|
- // Async read the encrypted tokens (for private routing only) and
|
|
|
- // encrypted mailbox (both private and public routing) for this
|
|
|
+ // Async read the encrypted tokens (for token channel routing only) and
|
|
|
+ // encrypted mailbox (both token and ID channels) for this
|
|
|
// epoch
|
|
|
boost::asio::async_read(*storage_sock, toreceive,
|
|
|
[this, enc_tokens, token_bundle_size, pt_token_size, num_in,
|
|
@@ -999,7 +999,7 @@ void Client::epoch_process() {
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
- if (private_routing) {
|
|
|
+ if (token_channel) {
|
|
|
// Decrypt the token bundle
|
|
|
unsigned char *enc_tkn_ptr = enc_tokens + SGX_AESGCM_IV_SIZE;
|
|
|
unsigned char *enc_tkn_tag = enc_tokens + SGX_AESGCM_IV_SIZE +
|
|
@@ -1124,7 +1124,7 @@ int main(int argc, char **argv)
|
|
|
exit(1);
|
|
|
}
|
|
|
|
|
|
- private_routing = config.private_routing;
|
|
|
+ token_channel = config.token_channel;
|
|
|
clients = new Client[config.user_count];
|
|
|
#ifdef VERBOSE_CLIENT
|
|
|
printf("Number of ingestion_nodes = %ld, Number of storage_node = %ld\n",
|