Closed VogelIBR closed 2 years ago
What is the Intel CPU you're using? Is this a Skylake, CoffeeLake, Icelake, etc.?
Some Intel CPUs support only EPID, some Intel CPUs support only DCAP.
Also, it is illegal to install both EPID- and DCAP-specific Intel SGX PSW packages (which I presume you've done).
Finally, you're writing:
For the DCAP example I had to build and specify the LD_PATH of
libra_tls_verify_dcap.so
myself since it doesn't seem to be provided by the gramine installed through ubuntu
This is correct. The current latest Gramine package for Ubuntu (v1.1) does not come with DCAP libraries provided. This will be fixed in the next release (v1.2).
But how did you get libra_tls_verify_dcap.so
then? You manually performed the build steps of git-cloned Gramine sources via meson build -Ddcap=enabled ...
+ sudo ninja build install
?
In general, I would recommend to just check out the latest master
version of Gramine from GitHub and manually build and install it, with the -Ddcap=enabled
option. This will make sure to install Gramine with DCAP supported.
I am using Intel(R) Xeon(R) E-2176G CPU
which seems to be Coffee Lake.
But how did you get libra_tls_verify_dcap.so then? You manually performed the build steps of git-cloned Gramine sources via
meson build -Ddcap=enabled ...
+sudo ninja build install
?
Yes I build it myself, but I did not install it. I made it available to the client with LD_LIBRARY_PATH=/ibr/home/vogel/tmp/gramine/build/Pal/src/host/Linux-SGX/tools/ra-tls/ ./client ...
Yes I build it myself, but I did not install it.
Hm, that's brittle and clearly not as it's supposed to be.
Please try to install Gramine in a manual way. Please refer to https://gramine.readthedocs.io/en/latest/devel/building.html#id2. Note that this step is done after you git-cloned Gramine and cd
ed into the cloned directory. Don't forget to add -Ddcap=enabled
to the meson build
command.
This is the output of the clients with gramine at f34f093cdc781a25d9fb4b27a7b5149b616e0da8 setup as meson setup build/ --buildtype=release -Ddirect=enabled -Dsgx=enabled -Ddcap=enabled
vogel@ssgx7:/opt/gramine/CI-Examples/ra-tls-mbedtls$ ./client epid 0 0 0 0
[ using our own SGX-measurement verification callback (via command line options) ]
- ignoring MRENCLAVE
- ignoring MRSIGNER
- ignoring ISV_PROD_ID
- ignoring ISV_SVN
. Seeding the random number generator... ok
. Connecting to tcp/localhost/4433... ok
. Setting up the SSL/TLS structure... ok
. Loading the CA root certificate ... ok
. Installing RA-TLS callback ... ok
. Performing the SSL/TLS handshake... failed
! mbedtls_ssl_handshake returned -0x2800
Last error was: -10240 - X509 - Input invalid
vogel@ssgx7:/opt/gramine/CI-Examples/ra-tls-mbedtls$ ./client dcap 0 0 0 0
[ using our own SGX-measurement verification callback (via command line options) ]
- ignoring MRENCLAVE
- ignoring MRSIGNER
- ignoring ISV_PROD_ID
- ignoring ISV_SVN
. Seeding the random number generator... ok
. Connecting to tcp/localhost/4433... ok
. Setting up the SSL/TLS structure... ok
. Loading the CA root certificate ... ok
. Installing RA-TLS callback ... ok
. Performing the SSL/TLS handshake... failed
! mbedtls_ssl_handshake returned -0x3000
Last error was: -12288 - X509 - A fatal error occurred, eg the chain is too long or the vrfy callback failed
vogel@ssgx7:/opt/gramine/CI-Examples/ra-tls-mbedtls$ gramine-sgx client_dcap dcap 0 0 0 0
Gramine is starting. Parsing TOML manifest file, this may take some time...
-----------------------------------------------------------------------------------------------------------------------
Gramine detected the following insecure configurations:
- sgx.debug = true (this is a debug enclave)
- loader.insecure__use_cmdline_argv = true (forwarding command-line args from untrusted host to the app)
- loader.insecure__use_host_env = true (forwarding environment vars from untrusted host to the app)
- sgx.allowed_files = [ ... ] (some files are passed through from untrusted host without verification)
Gramine will continue application execution, but this configuration must not be used in production!
-----------------------------------------------------------------------------------------------------------------------
[ using our own SGX-measurement verification callback (via command line options) ]
- ignoring MRENCLAVE
- ignoring MRSIGNER
- ignoring ISV_PROD_ID
- ignoring ISV_SVN
. Seeding the random number generator... ok
. Connecting to tcp/localhost/4433... ok
. Setting up the SSL/TLS structure... ok
. Loading the CA root certificate ... ok
. Installing RA-TLS callback ... ok
. Performing the SSL/TLS handshake...[get_driver_type /home/sgx/jenkins/ubuntuServer2004-release-build-trunk-216/build_target/PROD/label/Builder-UbuntuSrv20/label_exp/ubuntu64/linux-trunk-opensource/psw/urts/linux/edmm_utility.cpp:116] Failed to open Intel SGX device.
[get_driver_type /home/sgx/jenkins/ubuntuServer2004-release-build-trunk-216/build_target/PROD/label/Builder-UbuntuSrv20/label_exp/ubuntu64/linux-trunk-opensource/psw/urts/linux/edmm_utility.cpp:116] Failed to open Intel SGX device.
failed
! mbedtls_ssl_handshake returned -0x3000
Last error was: -12288 - X509 - A fatal error occurred, eg the chain is too long or the vrfy callback failed
vogel@ssgx7:/opt/gramine/CI-Examples/ra-tls-mbedtls$ gramine-sgx client_epid epid 0 0 0 0
Gramine is starting. Parsing TOML manifest file, this may take some time...
-----------------------------------------------------------------------------------------------------------------------
Gramine detected the following insecure configurations:
- sgx.debug = true (this is a debug enclave)
- loader.insecure__use_cmdline_argv = true (forwarding command-line args from untrusted host to the app)
- loader.insecure__use_host_env = true (forwarding environment vars from untrusted host to the app)
- sgx.allowed_files = [ ... ] (some files are passed through from untrusted host without verification)
Gramine will continue application execution, but this configuration must not be used in production!
-----------------------------------------------------------------------------------------------------------------------
[ using our own SGX-measurement verification callback (via command line options) ]
- ignoring MRENCLAVE
- ignoring MRSIGNER
- ignoring ISV_PROD_ID
- ignoring ISV_SVN
. Seeding the random number generator... ok
. Connecting to tcp/localhost/4433... ok
. Setting up the SSL/TLS structure... ok
. Loading the CA root certificate ... ok
. Installing RA-TLS callback ... ok
. Performing the SSL/TLS handshake... failed
! mbedtls_ssl_handshake returned -0x2800
Last error was: -10240 - X509 - Input invalid
Please try to build & install Gramine, as I recommended above. You're basically using two different versions: your core Gramine is v1.1, but your RA-TLS DCAP library is the master
version. Combining two versions leads to unpredictable results.
Please try to build & install Gramine, as I recommended above. You're basically using two different versions: your core Gramine is v1.1, but your RA-TLS DCAP library is the
master
version. Combining two versions leads to unpredictable results.
Oh sorry I didn't make that clear. The output from above is with gramine installed as you recommended it. It's the output after apt remove gramine-dcap
, and then building gramine from master at commit https://github.com/gramineproject/gramine/commit/f34f093cdc781a25d9fb4b27a7b5149b616e0da8. Build and install steps were meson setup build/ --buildtype=release -Ddirect=enabled -Dsgx=enabled -Ddcap=enabled
and sudo ninja -C build/ install
.
Sorry, that was my blunder. I forgot to update this GitHub page today, so I had the stale messages still :)
It's hard to say what goes wrong in this ra-tls-mbedtls
example. I'm afraid you need to verify your installation of the SGX PSW + DCAP software stack. You should start here, if you haven't done it already: https://www.intel.com/content/www/us/en/developer/articles/guide/intel-software-guard-extensions-data-center-attestation-primitives-quick-install-guide.html
Looking at the output again, is this correct?
gramine-sgx-sign \
--key /ibr/home/vogel/.config/gramine/enclave-key.pem \
--manifest client_epid.manifest \
--output client_epid.manifest.sgx
Attributes:
size: 0x10000000
thread_num: 4
isv_prod_id: 0
isv_svn: 0
attr.flags: 0x6
attr.xfrm: 0x3
misc_select: 0x0
SGX remote attestation:
DCAP/ECDSA
Why would it use DCAP for RA when generating the client_epid?
Anyways I tried the whole setup from scratch again with the same outcome.
Installing only epid:
echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | sudo tee /etc/a pt/sources.list.d/intel-sgx.list
wget -qO - https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key | sudo apt-key add
sudo apt-get update
sudo apt-get install libsgx-epid libsgx-quote-ex
Installing gramine dependencies
sudo apt-get install -y autoconf bison build-essential gawk \
python3 python3-click python3-jinja2 wget
sudo pip3 install meson
sudo apt-get install -y libcurl4-openssl-dev libprotobuf-c-dev \
protobuf-c-compiler python3-pip python3-protobuf
python3 -m pip install toml>=0.10
Building and installing gramine from master
sudo ninja -C build/ install
meson setup build/ --buildtype=release -Ddirect=enabled -Dsgx=enabled
And again I get (also same when running it simply as ./client)
$ gramine-sgx client_epid epid 0 0 0 0
Gramine is starting. Parsing TOML manifest file, this may take some time...
Detected a huge manifest, preallocating 64MB of internal memory.
-----------------------------------------------------------------------------------------------------------------------
Gramine detected the following insecure configurations:
- sgx.debug = true (this is a debug enclave)
- loader.insecure__use_cmdline_argv = true (forwarding command-line args from untrusted host to the app)
- loader.insecure__use_host_env = true (forwarding environment vars from untrusted host to the app)
- sgx.allowed_files = [ ... ] (some files are passed through from untrusted host without verification)
Gramine will continue application execution, but this configuration must not be used in production!
-----------------------------------------------------------------------------------------------------------------------
[ using our own SGX-measurement verification callback (via command line options) ]
- ignoring MRENCLAVE
- ignoring MRSIGNER
- ignoring ISV_PROD_ID
- ignoring ISV_SVN
. Seeding the random number generator... ok
. Connecting to tcp/localhost/4433... ok
. Setting up the SSL/TLS structure... ok
. Loading the CA root certificate ... ok
. Installing RA-TLS callback ... ok
. Performing the SSL/TLS handshake... failed
! mbedtls_ssl_handshake returned -0x2800
Last error was: -10240 - X509 - Input invalid
while the Intel SDX RemoteAttestation sample works
Looks like your machine supports both EPID and DCAP.
Ok, please start with EPID flows (since you already installed them on the machine).
Why would it use DCAP for RA when generating the client_epid?
That's because you seem to forgot to specify RA_CLIENT_SPID=12345678901234567890123456789012 RA_CLIENT_LINKABLE=0 make app epid ...
environment variables during application build.
When you register at Intel EPID attestation internet webpage, you'll get your SPID and EPID key (and also you'll choose the "linkable"/"unlinkable" version). You need to specify these SGX EPID parameters when you build and run the SGX application.
Please read the README carefully: https://github.com/gramineproject/gramine/blob/master/CI-Examples/ra-tls-mbedtls/README.md
Thanks a lot. I got it to run now.
One last thing: I had to specify loader.pal_internal_mem_size = "64M"
for both server and client for them to run.
gramine-sgx server native
Gramine is starting. Parsing TOML manifest file, this may take some time...
Detected a huge manifest, preallocating 64MB of internal memory.
error: Too small `loader.pal_internal_mem_size`, need at least 64MB because the manifest is large
One last thing: I had to specify
loader.pal_internal_mem_size = "64M"
for both server and client for them to run.
Yes, these memory sizes depend on how many files you have in your default system paths (I don't want to go into details here). So it looks like your system has a lot of stuff installed. On my local system, I don't need to add this environment option (the default size of internal memory is enough for my system).
Description of the problem
The ra-tls-mbedtls example does not work for me both with EPID and DCAP. See the output below.
For the DCAP example I had to build and specify the LD_PATH of
libra_tls_verify_dcap.so
myself since it doesn't seem to be provided by the gramine installed through ubuntu. But that seems to be a unrelated problem I assume.Steps to reproduce
git checkout v1.1
openssl genrsa -3 -out "$HOME"/.config/gramine/enclave-key.pem 3072
make SGX=1 SGX_SIGNER_KEY=~/.config/gramine/enclave-key.pem
gramine-sgx server epid
./client epid 1deaf12d5caa694ce2958df7e3ab86b492658173a76247198bc9ff4a30a9a22c 6dbfdcaa4e7439d34752207bb323fb25c074746c27a018fdb729cb49ab46eb82 0 0
System info:
Expected results
Normal output from both server and client.
Actual results
EPID
EPID build:
Server output:
Client EPID output:
DCAP
DCAP Build
Server DCAP output
Client DCAP output