From 445e42f4d37dca55bf08593cc732363db4a58fcc Mon Sep 17 00:00:00 2001 From: Paul Zinselmeyer Date: Mon, 8 Jul 2024 09:41:14 +0200 Subject: [PATCH] [Assignment-7] Add License / Copy Notices --- 7-SGX_Hands-on/src/app/employee.c | 1 - 7-SGX_Hands-on/src/app/main.c | 3 +++ 7-SGX_Hands-on/src/app/proxy.c | 8 +++++--- 7-SGX_Hands-on/src/app/proxysetup.c | 4 ++++ 7-SGX_Hands-on/src/app/util.c | 20 +++++++++++++++++--- 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/7-SGX_Hands-on/src/app/employee.c b/7-SGX_Hands-on/src/app/employee.c index 379d51a..940b70d 100644 --- a/7-SGX_Hands-on/src/app/employee.c +++ b/7-SGX_Hands-on/src/app/employee.c @@ -83,7 +83,6 @@ int handle_employee(int argc, char** argv) { * Sign Firmware */ - mdctx = EVP_MD_CTX_new(); if (EVP_DigestSignInit(mdctx, NULL, EVP_sha256(), NULL, key) != 1) { fprintf(stderr, "Message digest initialization failed.\n"); diff --git a/7-SGX_Hands-on/src/app/main.c b/7-SGX_Hands-on/src/app/main.c index 1d08212..e39e9e4 100644 --- a/7-SGX_Hands-on/src/app/main.c +++ b/7-SGX_Hands-on/src/app/main.c @@ -8,6 +8,9 @@ #include "util.h" +/* + * main method of the binary calls the implementation of the specified subcommand + */ int main(int argc, char** argv) { if(argc < 1) syntax_exit(); diff --git a/7-SGX_Hands-on/src/app/proxy.c b/7-SGX_Hands-on/src/app/proxy.c index 70974e8..e80d424 100644 --- a/7-SGX_Hands-on/src/app/proxy.c +++ b/7-SGX_Hands-on/src/app/proxy.c @@ -11,8 +11,6 @@ #include - - #include "enclave_u.h" #include "proxy.h" #include "util.h" @@ -221,6 +219,10 @@ static int ECDSA_SIG_to_sgx_signature(ECDSA_SIG* ecdsa_sig, sgx_ec256_signature_ return (0); } +/* + * This function is a modified version of the `sgx_ecdsa_verify_hash` function in the [Intel SGX crypto library](https://github.com/intel/linux-sgx/blob/main/sdk/tlibcrypto/sgxssl/sgx_ecc256_ecdsa.cpp). + * The specified License applies. + */ static int sgx_signature_to_ECDSA_SIG(sgx_ec256_signature_t* sgx_signature, ECDSA_SIG** ecdsa_signature) { BIGNUM *bn_r = NULL; BIGNUM *bn_s = NULL; @@ -318,7 +320,7 @@ int handle_proxy(int argc, char** argv) { syntax_exit(); /* - * Read Signature Input + * Read And Parse Signature Input */ ecdsa_signature_data = malloc(1024); diff --git a/7-SGX_Hands-on/src/app/proxysetup.c b/7-SGX_Hands-on/src/app/proxysetup.c index be4709d..0852633 100644 --- a/7-SGX_Hands-on/src/app/proxysetup.c +++ b/7-SGX_Hands-on/src/app/proxysetup.c @@ -28,6 +28,10 @@ char* proxysetup_syntax(void) { " -token (optional) file path of the sgx token\n"; } +/* + * This function is a modified version of the `get_pub_key_from_coords` function in the [Intel SGX crypto library](https://github.com/intel/linux-sgx/blob/c1ceb4fe146e0feb1097dee81c7e89925443e43c/sdk/tlibcrypto/sgxssl/sgx_ecc256.cpp). + * The specified License applies. + */ static EVP_PKEY *sgx_public_to_EVP_PKEY(const sgx_ec256_public_t *p_public) { EVP_PKEY *evp_key = NULL; diff --git a/7-SGX_Hands-on/src/app/util.c b/7-SGX_Hands-on/src/app/util.c index 6cc715b..5a59ef2 100644 --- a/7-SGX_Hands-on/src/app/util.c +++ b/7-SGX_Hands-on/src/app/util.c @@ -39,13 +39,20 @@ void syntax_exit(void) { void set_bin_name(char* bin_name) { BIN_NAME = bin_name; } - +/* + * This definition is copied from the provided SGX Examples. + * The specified License applies. + */ typedef struct _sgx_errlist_t { sgx_status_t err; const char *msg; const char *sug; /* Suggestion */ } sgx_errlist_t; +/* + * This definition is copied from the provided SGX Examples. + * The specified License applies. + */ /* Error code returned by sgx_create_enclave */ static sgx_errlist_t sgx_errlist[] = { { @@ -124,7 +131,10 @@ static sgx_errlist_t sgx_errlist[] = { NULL }, }; - +/* + * This Method is copied from the provided SGX Examples. + * The specified License applies. + */ /* Check error conditions for loading enclave */ void sgx_print_error_message(sgx_status_t ret) { @@ -139,11 +149,15 @@ void sgx_print_error_message(sgx_status_t ret) break; } } - + if (idx == ttl) printf("Error code is 0x%X. Please refer to the \"Intel SGX SDK Developer Reference\" for more details.\n", ret); } +/* + * This Method is copied from the provided SGX Examples. + * The specified License applies. + */ int initialize_enclave(char* token_path) { FILE* sgx_token_file = NULL; sgx_launch_token_t token = {0};