1 # This package _builds_ (but doesn't run!) the sgx-ssl test enclave + harness.
2 # The whole package effectively does:
5 # SGX_MODE=${sgxMode} make -C Linux/sgx/test_app
6 # cp Linux/sgx/{TestApp,TestEnclave.signed.so} $out/bin
9 # OfBorg fails to run these tests since they require real Intel HW. That
10 # includes the simulation mode! The tests appears to do something fancy with
11 # cpuid and exception trap handlers that make them very non-portable.
13 # These tests are split out from the parent pkg since recompiling the parent
14 # takes like 30 min : )
23 , opensslVersion ? throw "required parameter"
24 , sgxMode ? throw "required parameter" # "SIM" or "HW"
27 inherit (sgx-ssl) postPatch src version;
28 pname = sgx-ssl.pname + "-tests-${sgxMode}";
30 postUnpack = sgx-ssl.postUnpack + ''
31 sourceRootAbs=$(readlink -e $sourceRoot)
32 packageDir=$sourceRootAbs/Linux/package
34 # Do the inverse of 'make install' and symlink built artifacts back into
35 # '$src/Linux/package/' to avoid work.
36 mkdir $packageDir/lib $packageDir/lib64
37 ln -s ${lib.getLib sgx-ssl}/lib/* $packageDir/lib/
38 ln -s ${lib.getLib sgx-ssl}/lib64/* $packageDir/lib64/
39 ln -sf ${lib.getDev sgx-ssl}/include/* $packageDir/include/
41 # test_app needs some internal openssl headers.
42 # See: tail end of 'Linux/build_openssl.sh'
43 tar -C $sourceRootAbs/openssl_source -xf $sourceRootAbs/openssl_source/openssl-${opensslVersion}.tar.gz
44 echo '#define OPENSSL_VERSION_STR "${opensslVersion}"' > $sourceRootAbs/Linux/sgx/osslverstr.h
45 ln -s $sourceRootAbs/openssl_source/openssl-${opensslVersion}/include/crypto $sourceRootAbs/Linux/sgx/test_app/enclave/
46 ln -s $sourceRootAbs/openssl_source/openssl-${opensslVersion}/include/internal $sourceRootAbs/Linux/sgx/test_app/enclave/
56 # Need to regerate the edl header
57 make -C Linux/sgx/libsgx_tsgxssl sgx_tsgxssl_t.c
61 "-C Linux/sgx/test_app"
68 # Enclaves can't be stripped after signing.
69 install -Dm 755 Linux/sgx/test_app/TestEnclave.signed.so -t $TMPDIR/enclaves
71 install -Dm 755 Linux/sgx/test_app/TestApp -t $out/bin
77 # Move the enclaves where they actually belong.
78 mv $TMPDIR/enclaves/*.signed.so* $out/bin/
80 # HW SGX must runs against sgx-psw, not sgx-sdk.
81 if [[ "${sgxMode}" == "HW" ]]; then
84 patchelf --print-rpath $out/bin/TestApp \
85 | sed 's|${lib.getLib sgx-sdk}|${lib.getLib sgx-psw}|' \
92 platforms = [ "x86_64-linux" ];
93 mainProgram = "TestApp";