From ef0960e1e9a05cacb14c0cd8318d1f3d943ea8f7 Mon Sep 17 00:00:00 2001 From: David Kohlbrenner Date: Thu, 10 Jan 2019 10:45:23 -0800 Subject: [PATCH] Updated demo application with cleaner output messages, including hex of encrypted messages. Added --ignore-valid flag to trusted client to speed up testing. --- enclave-host.cpp | 28 ++++++++++++++++++++++++---- include/enclave_expected_hash.h | 12 ++++++------ server_eapp/channel.c | 17 ++++++++--------- server_eapp/server_eapp.c | 9 ++++----- trusted_client/client.cpp | 9 ++++++++- trusted_client/trusted_client.cpp | 13 +++++++++---- trusted_client/trusted_client.h | 2 +- 7 files changed, 60 insertions(+), 30 deletions(-) diff --git a/enclave-host.cpp b/enclave-host.cpp index a1fa7c4..519ddb8 100644 --- a/enclave-host.cpp +++ b/enclave-host.cpp @@ -1,5 +1,3 @@ -#include -#include #include #include #include @@ -8,10 +6,17 @@ #include #include #include +#include +#include +#include +#include +#include #include "keystone.h" #include "edge_wrapper.h" #include "encl_message.h" +#define PRINT_MESSAGE_BUFFERS 1 + /* We hardcode these for demo purposes. */ const char* enc_path = "server_eapp.eapp_riscv"; const char* runtime_path = "eyrie-rt"; @@ -35,6 +40,17 @@ byte* recv_buffer(size_t* len){ return reply; } +void print_hex_data(unsigned char* data, size_t len){ + unsigned int i; + std::string str; + for(i=0; imsg_type == CALC_MSG_EXIT){ - ocall_print_buffer("SE: Received exit, exiting\n"); + ocall_print_buffer("Received exit, exiting\n"); EAPP_RETURN(0); } @@ -51,7 +50,7 @@ void handle_messages(){ size_t reply_size =channel_get_send_size(sizeof(int)); unsigned char* reply_buffer = malloc(reply_size); if(reply_buffer == NULL){ - ocall_print_buffer("SE: Reply too large to allocate, no reply sent\n"); + ocall_print_buffer("Reply too large to allocate, no reply sent\n"); continue; } diff --git a/trusted_client/client.cpp b/trusted_client/client.cpp index 843ed04..903813a 100644 --- a/trusted_client/client.cpp +++ b/trusted_client/client.cpp @@ -36,11 +36,18 @@ byte* recv_buffer(size_t* len){ int main(int argc, char *argv[]) { + int ignore_valid = 0; if(argc < 2) { printf("Usage %s hostname\n", argv[0]); exit(-1); } + if(argc >= 3){ + if(strcmp(argv[2],"--ignore-valid") == 0){ + ignore_valid =1; + } + } + fd_sock = socket(AF_INET, SOCK_STREAM, 0); if(fd_sock < 0){ printf("No socket\n"); @@ -66,7 +73,7 @@ int main(int argc, char *argv[]) size_t report_size; byte* report_buffer = recv_buffer(&report_size); - trusted_client_get_report(report_buffer); + trusted_client_get_report(report_buffer, ignore_valid); free(report_buffer); /* Send pubkey */ diff --git a/trusted_client/trusted_client.cpp b/trusted_client/trusted_client.cpp index 2a7882f..9cca2e0 100644 --- a/trusted_client/trusted_client.cpp +++ b/trusted_client/trusted_client.cpp @@ -47,7 +47,7 @@ byte* trusted_client_pubkey(size_t* len){ return (byte*)client_pk; } -void trusted_client_get_report(void* buffer){ +void trusted_client_get_report(void* buffer, int ignore_valid){ Report report; report.fromBytes((unsigned char*)buffer); @@ -57,12 +57,17 @@ void trusted_client_get_report(void* buffer){ sm_expected_hash, _sanctum_dev_public_key)) { - printf("[TC]Attestation signature and enclave hash are valid\n"); + printf("[TC] Attestation signature and enclave hash are valid\n"); } else { - printf("[TC]Attestation report is NOT valid\n"); - trusted_client_exit(); + printf("[TC] Attestation report is NOT valid\n"); + if( ignore_valid ){ + printf("[TC] Ignore Validation was set, CONTINUING WITH INVALID REPORT\n"); + } + else{ + trusted_client_exit(); + } } if(report.getDataSize() != crypto_kx_PUBLICKEYBYTES){ diff --git a/trusted_client/trusted_client.h b/trusted_client/trusted_client.h index 54bd447..325ee38 100644 --- a/trusted_client/trusted_client.h +++ b/trusted_client/trusted_client.h @@ -17,7 +17,7 @@ typedef unsigned char byte; void trusted_client_exit(); void trusted_client_init(); byte* trusted_client_pubkey(size_t* len); -void trusted_client_get_report(void* buffer); +void trusted_client_get_report(void* buffer, int ignore_valid); int trusted_client_read_reply(unsigned char* data, size_t len); void send_exit_message(); void send_wc_message(char* buffer);