diff --git a/7-SGX_Hands-on/.gitkeep b/7-SGX_Hands-on/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Assignment 7 - SGX Hands-on/LICENSE b/7-SGX_Hands-on/LICENSE similarity index 100% rename from Assignment 7 - SGX Hands-on/LICENSE rename to 7-SGX_Hands-on/LICENSE diff --git a/Assignment 7 - SGX Hands-on/README.md b/7-SGX_Hands-on/README.md similarity index 93% rename from Assignment 7 - SGX Hands-on/README.md rename to 7-SGX_Hands-on/README.md index 1ad57aa..40a9cbb 100644 --- a/Assignment 7 - SGX Hands-on/README.md +++ b/7-SGX_Hands-on/README.md @@ -4,7 +4,7 @@ Documentation of the Assignment 7 in Systems Security at Ruhr-Universität Bochu This is a program, that uses a TEE to build a signature relay to sign firmware with a master key. For more informationm, read the [project description](doc/abgabe.pdf). -We recommend viewing the [repository](https://git.pfzetto.de/RubNoobs/Systemsicherheit/src/branch/master/Assignment%207%20-%20SGX%20Hands-on) we worked on together at. +We recommend viewing the [repository](https://git.pfzetto.de/RubNoobs/Systemsicherheit/src/branch/master/Assignment 7 - SGX Hands-on) we worked on together at. ## Requirements diff --git a/Assignment 7 - SGX Hands-on/employee_keys/alice_private.pem b/7-SGX_Hands-on/employee_keys/alice_private.pem similarity index 100% rename from Assignment 7 - SGX Hands-on/employee_keys/alice_private.pem rename to 7-SGX_Hands-on/employee_keys/alice_private.pem diff --git a/Assignment 7 - SGX Hands-on/employee_keys/alice_public.pem b/7-SGX_Hands-on/employee_keys/alice_public.pem similarity index 100% rename from Assignment 7 - SGX Hands-on/employee_keys/alice_public.pem rename to 7-SGX_Hands-on/employee_keys/alice_public.pem diff --git a/Assignment 7 - SGX Hands-on/employee_keys/bob_private.pem b/7-SGX_Hands-on/employee_keys/bob_private.pem similarity index 100% rename from Assignment 7 - SGX Hands-on/employee_keys/bob_private.pem rename to 7-SGX_Hands-on/employee_keys/bob_private.pem diff --git a/Assignment 7 - SGX Hands-on/employee_keys/bob_public.pem b/7-SGX_Hands-on/employee_keys/bob_public.pem similarity index 100% rename from Assignment 7 - SGX Hands-on/employee_keys/bob_public.pem rename to 7-SGX_Hands-on/employee_keys/bob_public.pem diff --git a/Assignment 7 - SGX Hands-on/employee_keys/oskar_private.pem b/7-SGX_Hands-on/employee_keys/oskar_private.pem similarity index 100% rename from Assignment 7 - SGX Hands-on/employee_keys/oskar_private.pem rename to 7-SGX_Hands-on/employee_keys/oskar_private.pem diff --git a/Assignment 7 - SGX Hands-on/employee_keys/oskar_public.pem b/7-SGX_Hands-on/employee_keys/oskar_public.pem similarity index 100% rename from Assignment 7 - SGX Hands-on/employee_keys/oskar_public.pem rename to 7-SGX_Hands-on/employee_keys/oskar_public.pem diff --git a/Assignment 7 - SGX Hands-on/flake.lock b/7-SGX_Hands-on/flake.lock similarity index 100% rename from Assignment 7 - SGX Hands-on/flake.lock rename to 7-SGX_Hands-on/flake.lock diff --git a/Assignment 7 - SGX Hands-on/flake.nix b/7-SGX_Hands-on/flake.nix similarity index 100% rename from Assignment 7 - SGX Hands-on/flake.nix rename to 7-SGX_Hands-on/flake.nix diff --git a/Assignment 7 - SGX Hands-on/src/Makefile b/7-SGX_Hands-on/src/Makefile similarity index 100% rename from Assignment 7 - SGX Hands-on/src/Makefile rename to 7-SGX_Hands-on/src/Makefile diff --git a/Assignment 7 - SGX Hands-on/src/app/embedded_device.c b/7-SGX_Hands-on/src/app/embedded_device.c similarity index 100% rename from Assignment 7 - SGX Hands-on/src/app/embedded_device.c rename to 7-SGX_Hands-on/src/app/embedded_device.c diff --git a/Assignment 7 - SGX Hands-on/src/app/embedded_device.h b/7-SGX_Hands-on/src/app/embedded_device.h similarity index 100% rename from Assignment 7 - SGX Hands-on/src/app/embedded_device.h rename to 7-SGX_Hands-on/src/app/embedded_device.h diff --git a/Assignment 7 - SGX Hands-on/src/app/employee.c b/7-SGX_Hands-on/src/app/employee.c similarity index 100% rename from Assignment 7 - SGX Hands-on/src/app/employee.c rename to 7-SGX_Hands-on/src/app/employee.c diff --git a/Assignment 7 - SGX Hands-on/src/app/employee.h b/7-SGX_Hands-on/src/app/employee.h similarity index 100% rename from Assignment 7 - SGX Hands-on/src/app/employee.h rename to 7-SGX_Hands-on/src/app/employee.h diff --git a/Assignment 7 - SGX Hands-on/src/app/main.c b/7-SGX_Hands-on/src/app/main.c similarity index 100% rename from Assignment 7 - SGX Hands-on/src/app/main.c rename to 7-SGX_Hands-on/src/app/main.c diff --git a/Assignment 7 - SGX Hands-on/src/app/proxy.c b/7-SGX_Hands-on/src/app/proxy.c similarity index 100% rename from Assignment 7 - SGX Hands-on/src/app/proxy.c rename to 7-SGX_Hands-on/src/app/proxy.c diff --git a/Assignment 7 - SGX Hands-on/src/app/proxy.h b/7-SGX_Hands-on/src/app/proxy.h similarity index 100% rename from Assignment 7 - SGX Hands-on/src/app/proxy.h rename to 7-SGX_Hands-on/src/app/proxy.h diff --git a/Assignment 7 - SGX Hands-on/src/app/proxysetup.c b/7-SGX_Hands-on/src/app/proxysetup.c similarity index 100% rename from Assignment 7 - SGX Hands-on/src/app/proxysetup.c rename to 7-SGX_Hands-on/src/app/proxysetup.c diff --git a/Assignment 7 - SGX Hands-on/src/app/proxysetup.h b/7-SGX_Hands-on/src/app/proxysetup.h similarity index 100% rename from Assignment 7 - SGX Hands-on/src/app/proxysetup.h rename to 7-SGX_Hands-on/src/app/proxysetup.h diff --git a/Assignment 7 - SGX Hands-on/src/app/util.c b/7-SGX_Hands-on/src/app/util.c similarity index 100% rename from Assignment 7 - SGX Hands-on/src/app/util.c rename to 7-SGX_Hands-on/src/app/util.c diff --git a/Assignment 7 - SGX Hands-on/src/app/util.h b/7-SGX_Hands-on/src/app/util.h similarity index 100% rename from Assignment 7 - SGX Hands-on/src/app/util.h rename to 7-SGX_Hands-on/src/app/util.h diff --git a/Assignment 7 - SGX Hands-on/src/enclave/enclave.c b/7-SGX_Hands-on/src/enclave/enclave.c similarity index 98% rename from Assignment 7 - SGX Hands-on/src/enclave/enclave.c rename to 7-SGX_Hands-on/src/enclave/enclave.c index f99f22e..23d2771 100644 --- a/Assignment 7 - SGX Hands-on/src/enclave/enclave.c +++ b/7-SGX_Hands-on/src/enclave/enclave.c @@ -206,7 +206,13 @@ sgx_status_t get_public_key(const uint8_t *sealed, uint32_t sealed_size, uint8_t } // unseal public key - return unseal_key_pair(sealed, NULL, (sgx_ec256_public_t *)public); + sgx_status_t status; + if((status = unseal_key_pair(sealed, NULL, (sgx_ec256_public_t *)public)) != SGX_SUCCESS) { + return status; + } + + // return success + return status; } /* diff --git a/Assignment 7 - SGX Hands-on/src/enclave/enclave.config.xml b/7-SGX_Hands-on/src/enclave/enclave.config.xml similarity index 100% rename from Assignment 7 - SGX Hands-on/src/enclave/enclave.config.xml rename to 7-SGX_Hands-on/src/enclave/enclave.config.xml diff --git a/Assignment 7 - SGX Hands-on/src/enclave/enclave.edl b/7-SGX_Hands-on/src/enclave/enclave.edl similarity index 100% rename from Assignment 7 - SGX Hands-on/src/enclave/enclave.edl rename to 7-SGX_Hands-on/src/enclave/enclave.edl diff --git a/Assignment 7 - SGX Hands-on/src/enclave/enclave.h b/7-SGX_Hands-on/src/enclave/enclave.h similarity index 100% rename from Assignment 7 - SGX Hands-on/src/enclave/enclave.h rename to 7-SGX_Hands-on/src/enclave/enclave.h diff --git a/Assignment 7 - SGX Hands-on/src/enclave/enclave.lds b/7-SGX_Hands-on/src/enclave/enclave.lds similarity index 100% rename from Assignment 7 - SGX Hands-on/src/enclave/enclave.lds rename to 7-SGX_Hands-on/src/enclave/enclave.lds diff --git a/Assignment 7 - SGX Hands-on/src/enclave/enclave_private.pem b/7-SGX_Hands-on/src/enclave/enclave_private.pem similarity index 100% rename from Assignment 7 - SGX Hands-on/src/enclave/enclave_private.pem rename to 7-SGX_Hands-on/src/enclave/enclave_private.pem diff --git a/Assignment 7 - SGX Hands-on/src/setup b/7-SGX_Hands-on/src/setup similarity index 100% rename from Assignment 7 - SGX Hands-on/src/setup rename to 7-SGX_Hands-on/src/setup diff --git a/Assignment 7 - SGX Hands-on/src/simulate b/7-SGX_Hands-on/src/simulate similarity index 100% rename from Assignment 7 - SGX Hands-on/src/simulate rename to 7-SGX_Hands-on/src/simulate diff --git a/Assignment 7 - SGX Hands-on/.gitkeep b/Assignment 7 - SGX Hands-on/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Assignment 7 - SGX Hands-on/doc/abgabe.pdf b/Assignment 7 - SGX Hands-on/doc/abgabe.pdf deleted file mode 100644 index 05d5adc..0000000 Binary files a/Assignment 7 - SGX Hands-on/doc/abgabe.pdf and /dev/null differ diff --git a/Assignment 7 - SGX Hands-on/doc/abgabe.typ b/Assignment 7 - SGX Hands-on/doc/abgabe.typ deleted file mode 100644 index 751a8f9..0000000 --- a/Assignment 7 - SGX Hands-on/doc/abgabe.typ +++ /dev/null @@ -1,131 +0,0 @@ -#let conf( - title: none, - assignmentno: none, - authors: (), - doc -) = { - set page( - paper: "a4", - header: [ - #set text(size: 9pt) - #grid( - columns: 3, - gutter: 1fr, - rows: 1, - align(left + horizon, smallcaps(title)), - align(center + horizon, "Assignment-" + assignmentno), - grid( - align: right, - columns: 1, - rows: authors.len(), - row-gutter: 3pt, - ..authors.map(author => [ - #author - ]) - ) - ) - #line(length: 100%) - ], - footer: context [ - #line(length: 100%) - #set align(center) - #counter(page).display( - "1 / 1", - both: true - ) - ], - ) - set text( - size: 11pt, - font: "DejaVu Serif" - ) - doc -} - -#show: doc => conf( - title: "System Security", - assignmentno: "7", - authors: ( - "Benjamin Haschka", - "Sascha Tommasone", - "Paul Zinselmeyer" - ), - doc -) - -= Firmware Signatur-Relay in einer TEE - -Das Program hat den Zweck, Signaturen die von einzelnen Nutzern über eine Firmware gemacht werden, mit einem permanenten Produktions-Key zu maskieren, ohne, dass der Nutzer diesen kennt. -Dabei wird eine Encalve als Signatur-Relay verwendet. -Die Enclave kann Signaturen über Daten mit einem festen Satz an öffentlichen Schlüsseln, die vertrauenswürdig sind, verifizieren. -Wenn die Signatur gültig ist, entfernt die Enclave die Signatur und erzeugt eine eigene Signatur mit dem Produktions-Key. - - -#grid( - columns: 2, - figure( - image("correct-signature.png"), - caption: "Valid Signature" - ), - figure( - image("unknown-signature.png"), - caption: "Invalid Signature" - ) -) - -Diese Signatur kann dann mit dem öffentlichen Schlüssel der Enclave, der von außen angefragt werden kann, überprüft werden. -Damit kann der Nutzer seine eigene Signatur mit der Signatur der Enclave maskieren. - -Der Schlüssel ist dabei den Nutzern nie bekannt. -Sie haben den Schlüssel nur versiegelt und können ihn der Enclave geben, die den Schlüssel dann entsiegeln und in der vertrauenswürdigen Umgebung verwenden kann. - - - -== Szenario - -In diesem Szenario wird ein Unternehmen betrachtet, das Embedded Geräte produziert. -Für die Geräte sollen regelmäßig Updates für die Firmware veröffentlicht werden. -Diese Firmware muss mit einem permanenten Key signiert werden, der in der Produktion der Geräte fest codiert wird. -Ist die Signatur nicht vorhanden, lädt keines der Geräte das Update. - -Mitarbeitende, die die Firmware hochladen wollen, müssen also die implementierte Firmware mit dem Produktions-Key signieren. -Wenn sie den Produktions-Key besitzen, bringt das gewissen risiken, z.B.: - -- Mitarbeitende können (absichtilich oder nicht) den Schlüssel veröffentlichen -- Mitarbeitende, die nicht mehr in dem Unternehmen arbeiten, können den Key für schlechte Zwecke missbrauchen - -Es ist also sinnvoll, wenn die Mitarbeitende den Key nicht kennen. Dazu kann das beschriebene Signatur-Relay verwendet werden. -Die Mitarbeitenden signieren die Firmware vorerst mit ihrem eigenen Key. -Diese Keys sind in das Relay als trusted Keys eingebunden. -Anschließend kann der Mitarbeitende die selbst-signierte Firmware an das Signatur-Relay senden. -Das Relay prüft dann die Gültigkeit der Signatur und schickt, falls gültig, eine eigene Signatur über die Firmware zurück. -Damit kann dann der Mitarbeitende die Firmware an die Embedded Geräte senden, bei Gültigkeit die neue Firmware laden können. - -Falls ein Mitarbeitender den eigenen Schlüssel verlieren oder veröffentlichen sollte, besteht in dem Fall auch nicht das Problem, dass der Produktionsschlüssel ungültig wird. -Es kann einfach der Schlüssel des Mitarbeitenden von der Liste der trusted Keys zurückgezogen werden. - -Zudem ist es wichtig, dass keine bösartigen Programme auf den Systemen der Mitarbeitenden den Signaturprozess mitbekommen oder gar verändern können. - -Aus diesen Gründen ist es in diesem Szenario wichtig, dass das Relay mit all seinen Funktionen besonders geschützt ist. -Dementsprechend sollte es in einer Enclave laufen. - -== Details - -1. *Key Management* - -Das Key Management wird mit der eingebauten `seal` Funktion der Encalve gemacht. -Dabei kann jeder Nutzer eine versiegelte Kopie des Schlüssels behalten, da er damit nichts anfangen kann. -Erst, wenn der Schlüssel in die Enclave kommt und entsiegelt wird, kann der Schlüssel verwendet werden. - -2. *Signatur Erstellung* - -Die Enclave bietet eine Schnittstelle für Signaturen mit ECDSA an. -Dabei wird die Kurve secp256r1 verwendet. - -== Vorteile - -Dieses Programm bietet einige Vorteile, unter anderem: - -- Nutzern unbekannter Hauptschlüssel -- Vereinfacht das Zurückziehen der Schlüssel -- Sicherheit der Gültigkeit der Firmware diff --git a/Assignment 7 - SGX Hands-on/doc/correct-signature.png b/Assignment 7 - SGX Hands-on/doc/correct-signature.png deleted file mode 100644 index 24dc28f..0000000 Binary files a/Assignment 7 - SGX Hands-on/doc/correct-signature.png and /dev/null differ diff --git a/Assignment 7 - SGX Hands-on/doc/unknown-signature.png b/Assignment 7 - SGX Hands-on/doc/unknown-signature.png deleted file mode 100644 index 04820e3..0000000 Binary files a/Assignment 7 - SGX Hands-on/doc/unknown-signature.png and /dev/null differ