From 6f4c0a8aec449b497e0c808255ace994d3545665 Mon Sep 17 00:00:00 2001 From: Paul Zinselmeyer Date: Sat, 6 Jul 2024 18:06:12 +0200 Subject: [PATCH] [Assignment-7] small changes --- 7-SGX_Hands-on/src/Makefile | 2 +- 7-SGX_Hands-on/src/app/embedded_device.c | 18 ++++++++++-------- 7-SGX_Hands-on/src/app/employee.c | 10 +++++----- 7-SGX_Hands-on/src/app/main.c | 1 + 7-SGX_Hands-on/src/app/util.c | 5 ++++- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/7-SGX_Hands-on/src/Makefile b/7-SGX_Hands-on/src/Makefile index 5049582..1cea4ae 100644 --- a/7-SGX_Hands-on/src/Makefile +++ b/7-SGX_Hands-on/src/Makefile @@ -74,7 +74,7 @@ else Urts_Library_Name := sgx_urts endif -App_C_Files := app/main.c app/proxy.c app/proxysetup.c app/employee.c app/util.c +App_C_Files := app/main.c app/proxy.c app/proxysetup.c app/employee.c app/util.c app/embedded_device.c App_Include_Paths := -IInclude -Iapp -I$(SGX_SDK)/include App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths) diff --git a/7-SGX_Hands-on/src/app/embedded_device.c b/7-SGX_Hands-on/src/app/embedded_device.c index 76be276..23fe486 100644 --- a/7-SGX_Hands-on/src/app/embedded_device.c +++ b/7-SGX_Hands-on/src/app/embedded_device.c @@ -23,18 +23,18 @@ typedef struct { char *embedded_device_syntax(void) { return - "embedded device (sim) mock up implementation of a embedded device\n" - " -ppub file path of the PEM encoded public key of the proxy\n" - " -firm path of to firmware binary\n"; + "embedded mock up implementation of a embedded device\n" + " -ppub file path of the PEM encoded public key of the proxy\n" + " -firm path of to firmware binary\n"; } -static EVP_PKEY *read_public_key(uint8_t *public_key_file_path, EVP_PKEY **key) { - if(public_key_file == NULL) { +static EVP_PKEY *read_public_key(char *public_key_file_path, EVP_PKEY **key) { + if(public_key_file_path == NULL) { fprintf(stderr, "public_key_file_path is a null pointer!\n"); return NULL; } - FILE *fd = fopen(public_key_file, "rb"); + FILE *fd = fopen(public_key_file_path, "rb"); if(fd == NULL) { fprintf(stderr, "failed to open public key file!\n"); return NULL; @@ -110,7 +110,9 @@ int handle_embedded_device(int argc, char **argv) { hash_firmware(args.firmware_path, &ctx); if (EVP_DigestVerifyFinal(ctx, signature, signature_size) != 1) { fprintf(stderr, "failed to verify firmware signature\n"); - } + }else { + printf("successfully verified firmware signature\n"); + } clean: ; if(key != NULL) @@ -119,4 +121,4 @@ int handle_embedded_device(int argc, char **argv) { EVP_MD_CTX_free(ctx); return 0; -} \ No newline at end of file +} diff --git a/7-SGX_Hands-on/src/app/employee.c b/7-SGX_Hands-on/src/app/employee.c index 4a770df..379d51a 100644 --- a/7-SGX_Hands-on/src/app/employee.c +++ b/7-SGX_Hands-on/src/app/employee.c @@ -23,11 +23,11 @@ struct EmployeeArgs { char* employee_syntax(void) { return - "employee mock up implementation of the employee binary\n" - " outputs signature on stdout\n" - " WARNING: output is in binary format, may mess up terminal\n" - " -ekey file path of the PEM encoded private key of the employee\n" - " -firm path of the firmware\n"; + "employee mock up implementation of the employee binary\n" + " outputs signature on stdout\n" + " WARNING: output is in binary format, may mess up terminal\n" + " -ekey file path of the PEM encoded private key of the employee\n" + " -firm path of the firmware\n"; } int handle_employee(int argc, char** argv) { diff --git a/7-SGX_Hands-on/src/app/main.c b/7-SGX_Hands-on/src/app/main.c index f4356b0..1d08212 100644 --- a/7-SGX_Hands-on/src/app/main.c +++ b/7-SGX_Hands-on/src/app/main.c @@ -1,6 +1,7 @@ #include #include +#include "embedded_device.h" #include "employee.h" #include "proxy.h" #include "proxysetup.h" diff --git a/7-SGX_Hands-on/src/app/util.c b/7-SGX_Hands-on/src/app/util.c index 3a49bf2..6cc715b 100644 --- a/7-SGX_Hands-on/src/app/util.c +++ b/7-SGX_Hands-on/src/app/util.c @@ -7,6 +7,7 @@ #include #include +#include "embedded_device.h" #include "employee.h" #include "util.h" #include "proxy.h" @@ -27,9 +28,11 @@ void syntax_exit(void) { "\n" "%s" "\n" + "%s" + "\n" "%s"; - printf(syntax, BIN_NAME, employee_syntax(), proxy_syntax(), proxysetup_syntax()); + printf(syntax, BIN_NAME, proxysetup_syntax(), employee_syntax(), proxy_syntax(), embedded_device_syntax()); exit (EXIT_FAILURE); }