Skip to content

Commit ee2b078

Browse files
authored
Merge pull request #675 from fortanix/raoul/rte-252-ppid_retrieval_runtime_container
[rte-252] ppid_retrieval runtime container
2 parents d5fb4f5 + cea9c54 commit ee2b078

File tree

6 files changed

+94
-52
lines changed

6 files changed

+94
-52
lines changed

.github/workflows/build-docker-images.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ jobs:
2424
- uses: actions/checkout@v4
2525
- name: Build the Docker image
2626
run: |
27-
cd intel-sgx/ppid-retrieval-tool
28-
docker build -t ppid-retrieval-tool:$(date +%s) .
29-
27+
cd intel-sgx/ppid-retrieval-tool/Docker
28+
./build.sh
29+
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Stage 0: A Intel SGX SDK container
2+
FROM ubuntu:24.04 AS sgx_sdk
3+
4+
## Install user
5+
RUN useradd -rm -d /home/ppid-tool -s /bin/bash -g root -G sudo -u 1010 ppid-tool
6+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
7+
RUN echo 'ppid-tool:ppid-tool' | chpasswd
8+
USER ppid-tool
9+
WORKDIR /home/ppid-tool
10+
11+
## Install SGX Dev tools
12+
USER root
13+
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
14+
gnupg \
15+
wget \
16+
sudo
17+
18+
## App build time dependencies
19+
RUN apt-get update
20+
RUN apt-get install -y build-essential
21+
22+
WORKDIR /opt/intel
23+
RUN wget https://download.01.org/intel-sgx/sgx-linux/2.25/distro/ubuntu24.04-server/sgx_linux_x64_sdk_2.25.100.3.bin
24+
RUN chmod +x sgx_linux_x64_sdk_2.25.100.3.bin
25+
RUN echo 'yes' | ./sgx_linux_x64_sdk_2.25.100.3.bin
26+
27+
## Install SGX runtime libraries
28+
USER root
29+
RUN echo 'deb [signed-by=/etc/apt/keyrings/intel-sgx-keyring.asc arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu noble main' | sudo tee /etc/apt/sources.list.d/intel-sgx.list
30+
RUN wget https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key
31+
RUN echo 92f96f84281031d889deb81060c44325f0481aee621ae47a15ae1df4431b4a23 intel-sgx-deb.key | sha256sum -c
32+
RUN cat intel-sgx-deb.key | sudo tee /etc/apt/keyrings/intel-sgx-keyring.asc > /dev/null
33+
RUN apt-get update
34+
RUN apt-get install -y libsgx-urts
35+
36+
# Stage 1: Building the ppid_retrieval tool
37+
FROM sgx_sdk AS ppid_retrieval_dev
38+
USER root
39+
40+
WORKDIR ppid-tool
41+
COPY Enclave Enclave
42+
COPY pce pce
43+
COPY main.c main.c
44+
COPY Makefile Makefile
45+
46+
RUN source /opt/intel/sgxsdk/environment && make
47+
48+
ENTRYPOINT bash
49+
50+
# Stage 2: Running the ppid_retrieval tool
51+
FROM ubuntu:24.04 AS ppid_retrieval
52+
53+
# Install Intel SGX runtime
54+
RUN apt-get update && apt-get upgrade -y && apt-get install -y wget
55+
RUN echo 'deb [signed-by=/etc/apt/keyrings/intel-sgx-keyring.asc arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu noble main' | tee /etc/apt/sources.list.d/intel-sgx.list
56+
RUN wget https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key
57+
RUN echo 92f96f84281031d889deb81060c44325f0481aee621ae47a15ae1df4431b4a23 intel-sgx-deb.key | sha256sum -c
58+
RUN cat intel-sgx-deb.key | tee /etc/apt/keyrings/intel-sgx-keyring.asc > /dev/null
59+
RUN apt-get update
60+
RUN apt-get install -y libsgx-urts
61+
62+
# Install ppid_retrieval tool
63+
COPY --from=ppid_retrieval_dev /opt/intel/ppid-tool/ppid_retrieval /ppid_retrieval
64+
COPY --from=ppid_retrieval_dev /opt/intel/ppid-tool/pce/libsgx_pce.signed.so.1.25.100.1 /pce/libsgx_pce.signed.so.1.25.100.1
65+
COPY --from=ppid_retrieval_dev /opt/intel/ppid-tool/Enclave/ppid.so /Enclave/ppid.so
66+
67+
CMD ["/ppid_retrieval"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash -ex
2+
this_dir=$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")
3+
cd ${this_dir}
4+
5+
docker build -t ppid_retrieval:$(cat version) -f ./Dockerfile ../
6+
7+
set +x
8+
echo "Build ready, you can run the tool"
9+
echo ""
10+
echo " docker run --device /dev/sgx ppid_retrieval:$(cat version)"
11+
echo ""
12+
echo "Note: the SGX device on your host may differ"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

intel-sgx/ppid-retrieval-tool/Dockerfile

Lines changed: 0 additions & 46 deletions
This file was deleted.

intel-sgx/ppid-retrieval-tool/main.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
66
#include <stdio.h>
7+
#include <string.h>
78
#include <sgx_urts.h>
89
#include "Enclave/ppid_u.h"
910
#include "pce/pce_u.h"
@@ -13,11 +14,14 @@
1314
#define DEBUG_ENCLAVE 1
1415
#define RELEASE_ENCLAVE 0
1516

16-
void print_decrypted_ppid(unsigned char decrypted_ppid[], size_t length) {
17-
printf("Decrypted PPID: ");
17+
void print_decrypted_ppid(unsigned char decrypted_ppid[], size_t length, int verbose) {
18+
if (verbose)
19+
printf("Plaintext PPID: ");
20+
1821
for (size_t i = 0; i < length; ++i) {
1922
printf("%02x", decrypted_ppid[i]); // Print each byte in hex
2023
}
24+
2125
printf("\n");
2226
}
2327

@@ -111,6 +115,10 @@ int main(int argc, char **argv)
111115
sgx_status_t ecall_ret = SGX_SUCCESS;
112116
uint8_t decrypted_ppid[DECRYPTED_PPID_LENGTH];
113117
sgx_enclave_id_t ppid_enclave_eid = 0;
118+
int verbose = 0;
119+
120+
if (argc == 2)
121+
verbose = (strcmp(argv[1], "-v") == 0);
114122

115123
memset(decrypted_ppid, 0x00, DECRYPTED_PPID_LENGTH);
116124

@@ -135,7 +143,7 @@ int main(int argc, char **argv)
135143
goto CLEANUP;
136144
}
137145

138-
print_decrypted_ppid(decrypted_ppid, sizeof(decrypted_ppid));
146+
print_decrypted_ppid(decrypted_ppid, sizeof(decrypted_ppid), verbose);
139147

140148
CLEANUP:
141149
if(ppid_enclave_eid != 0) {

0 commit comments

Comments
 (0)