-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
TOP=$(abspath ../..) | ||
include $(TOP)/defs.mak | ||
|
||
APPDIR = appdir | ||
CFLAGS = -fPIC | ||
LDFLAGS = -Wl,-rpath=$(MUSL_LIB) | ||
|
||
all: | ||
$(MAKE) myst | ||
$(MAKE) rootfs | ||
|
||
rootfs: hello.c | ||
mkdir -p $(APPDIR)/bin | ||
$(CC) $(CFLAGS) -o $(APPDIR)/bin/hello hello.c $(LDFLAGS) | ||
$(MYST) mkext2 $(APPDIR) rootfs | ||
|
||
OPTS = | ||
|
||
ifdef STRACE | ||
OPTS += --strace | ||
endif | ||
|
||
ifdef PERF | ||
OPTS += --perf | ||
endif | ||
|
||
OPTS += --thread-stack-size=1048576 | ||
|
||
tests: all | ||
$(RUNTEST) $(MYST_EXEC) rootfs /bin/hello $(OPTS) | ||
$(MAKE) sign | ||
$(MAKE) verify | ||
$(MAKE) fail | ||
@ echo "=== passed all tests" | ||
|
||
private.pem: | ||
openssl genrsa -out private.pem -3 3072 | ||
|
||
sign: private.pem | ||
$(MYST) fssig --roothash rootfs > roothash | ||
rm -rf hello.signed | ||
$(MYST) sign-sgx rootfs private.pem config.json --roothash=roothash | ||
|
||
verify: | ||
( cd hello.signed; ./bin/myst exec-sgx rootfs /bin/hello $(OPTS) ) | ||
|
||
myst: | ||
$(MAKE) -C $(TOP)/tools/myst | ||
|
||
clean: | ||
rm -rf $(APPDIR) rootfs export ramfs hello.signed roothash private.pem | ||
|
||
## | ||
## Negative test to verify that hacking rootfs fails loading. | ||
## | ||
fail: | ||
$(MAKE) sign | ||
$(MYST) mkext2 --force $(APPDIR) hello.signed/rootfs | ||
$(MAKE) verify 2> /dev/null; test $$? -eq 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
sign | ||
==== | ||
|
||
This test verifies that a simple Mystikos application can be signed and | ||
executed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": "0.1", | ||
"Debug": 1, | ||
"ProductID": 1, | ||
"SecurityVersion": 1, | ||
"MemorySize": "40m", | ||
"ThreadStackSize": "16m", | ||
"ApplicationPath": "/bin/hello", | ||
"ApplicationParameters": [], | ||
"HostApplicationParameters": false, | ||
"EnvironmentVariables": [], | ||
"HostEnvironmentVariables": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
#include <assert.h> | ||
#include <limits.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
int main(int argc, const char* argv[]) | ||
{ | ||
printf("Hello!\n"); | ||
printf("=== passed test (%s)\n", argv[0]); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters