Giter VIP home page Giter VIP logo

intel / linux-sgx Goto Github PK

View Code? Open in Web Editor NEW
1.3K 93.0 536.0 27.44 MB

Intel SGX for Linux*

Home Page: https://www.intel.com/content/www/us/en/developer/tools/software-guard-extensions/linux-overview.html

License: Other

Shell 1.52% HTML 0.67% CSS 0.04% Java 0.85% C 34.42% C++ 52.73% Makefile 3.09% Python 0.47% Assembly 2.70% M4 0.33% TeX 0.58% OCaml 0.82% Roff 0.55% Perl 0.81% CMake 0.31% Dockerfile 0.07% Hack 0.04%

linux-sgx's Introduction

Intel(R) Software Guard Extensions for Linux* OS

linux-sgx

Introduction

Intel(R) Software Guard Extensions (Intel(R) SGX) is an Intel technology for application developers seeking to protect select code and data from disclosure or modification.

The Linux* Intel(R) SGX software stack is comprised of the Intel(R) SGX driver, the Intel(R) SGX SDK, and the Intel(R) SGX Platform Software (PSW). The Intel(R) SGX SDK and Intel(R) SGX PSW are hosted in the linux-sgx project.

The SGXDataCenterAttestationPrimitives project maintains an out-of-tree driver for the Linux* Intel(R) SGX software stack, which will be used until the driver upstreaming process is complete. It is used on the platforms with Flexible Launch Control and Intel(R) AES New Instructions support and could support both Elliptic Curve Digital Signature algorithm (ECDSA) based attestation and Enhanced Privacy Identification (EPID) based attestation.

Note: Ice Lake Xeon-SP (and the future Xeon-SP platforms) doesn't support EPID attestation.

The linux-sgx-driver project hosts the other out-of-tree driver for the Linux* Intel(R) SGX software stack, which will be used until the driver upstreaming process is complete. It is used to support Enhanced Privacy Identification (EPID) based attestation on the platforms without Flexible Launch Control.

The intel-device-plugins-for-kubernetes project enables users to run container applications running Intel(R) SGX enclaves in Kubernetes clusters. It also gives instructions how to set up ECDSA based attestation in a cluster.

The intel-sgx-ssl project provides a full-strength general purpose cryptography library for Intel(R) SGX enclave applications. It is based on the underlying OpenSSL* Open Source project. Intel(R) SGX provides a build combination to build out a SGXSSL based SDK as below. Users could also utilize this cryptography library in SGX enclave applications seperately.

This repository provides a reference implementation of a Launch Enclave for 'Flexible Launch Control' under psw/ae/ref_le. The reference LE implementation can be used as a basis for enforcing different launch control policy by the platform developer or owner. To build and try it by yourself, please refer to the ref_le.md for details. NOTE: The reference LE is only workable with linux-sgx-driver and is planned to be deprecated starting from Intel(R) SGX release 2.20.

License

See License.txt for details.

Contributing

See CONTRIBUTING.md for details.

Documentation

Quick Start with Docker and Docker Compose

  • Build PSW and SDK from source. See this README for details.
$ cd docker/build && ./build_compose_run.sh
  • Build and deploy SGX exclave applications using prebuilt PSW and SDK downloaded from 01.org. See this README for details.
$ cd linux/installer/docker && ./build_compose_run.sh

Build and Install the Intel(R) SGX Driver

Follow the README.md in the SGXDataCenterAttestationPrimitives project to build and install the Intel(R) SGX driver. NOTE: The above Intel(R) SGX driver requires Flexible Launch Control and Intel(R) AES New Instructions support. If your platform doesn't meet the requirement, please follow the instructions in the linux-sgx-driver project to build and install this version of Intel(R) SGX driver.

Build the Intel(R) SGX SDK and Intel(R) SGX PSW Package

Prerequisites:

  • Ensure that you have one of the following required operating systems:

    • Ubuntu* 20.04 LTS Desktop 64bits
    • Ubuntu* 20.04 LTS Server 64bits
    • Ubuntu* 22.04 LTS Server 64bits
    • Ubuntu* 23.10 Server 64bits
    • Red Hat Enterprise Linux Server release 9.2 64bits
    • CentOS Stream 9 64bits
    • CentOS 8.3 64bits
    • SUSE Linux Enterprise Server 15.4 64bits
    • Anolis OS 8.6 64bits
    • Debian 10 64bits
  • Use the following command(s) to install the required tools to build the Intel(R) SGX SDK:

    • On Debian 10:
      $ sudo apt-get install build-essential ocaml ocamlbuild automake autoconf libtool wget python3 libssl-dev git cmake perl
      $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
    
    • On Ubuntu 20.04, Ubuntu 22.04 and Ubuntu 23.10:
      $ sudo apt-get install build-essential ocaml ocamlbuild automake autoconf libtool wget python-is-python3 libssl-dev git cmake perl
    
    • On Red Hat Enterprise Linux 9.2:
      $ sudo yum groupinstall 'Development Tools'
      $ sudo yum install ocaml ocaml-ocamlbuild wget python3 openssl-devel git cmake perl
    
    • On CentOS Stream 9:
      $ sudo dnf group install 'Development Tools'
      $ sudo dnf install ocaml ocaml-ocamlbuild redhat-rpm-config openssl-devel wget rpm-build git cmake perl python3
    
    • On CentOS 8.3:
      $ sudo dnf group install 'Development Tools'
      $ sudo dnf --enablerepo=powertools install ocaml ocaml-ocamlbuild redhat-rpm-config openssl-devel wget rpm-build git cmake perl python3
      $ sudo alternatives --set python /usr/bin/python3
    
    • On Anolis 8.6:
      $ sudo dnf group install 'Development Tools'
      $ sudo dnf --enablerepo=PowerTools install ocaml ocaml-ocamlbuild redhat-rpm-config openssl-devel wget rpm-build git cmake perl python3
      $ sudo alternatives --set python /usr/bin/python3
    
    • On SUSE Linux Enterprise Server 15.4:
      $ sudo zypper install --type pattern devel_basis
      $ sudo zypper install ocaml ocaml-ocamlbuild automake autoconf libtool wget python3 libopenssl-devel rpm-build git cmake perl
      $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
    

    Note: To build Intel(R) SGX SDK, gcc version is required to be 7.3 or above and glibc version is required to be 2.27 or above.

  • Use the following command to install additional required tools and latest Intel(R) SGX SDK Installer to build the Intel(R) SGX PSW:

    1. To install the additional required tools:
      • On Debian 10:
        $ sudo apt-get install libssl-dev libcurl4-openssl-dev protobuf-compiler libprotobuf-dev debhelper cmake reprepro unzip lsb-release libsystemd0
      
      • On Ubuntu 20.04, Ubuntu 22.04 and Ubuntu 23.10:
        $ sudo apt-get install libssl-dev libcurl4-openssl-dev protobuf-compiler libprotobuf-dev debhelper cmake reprepro unzip pkgconf libboost-dev libboost-system-dev libboost-thread-dev lsb-release libsystemd0
      
      • On Red Hat Enterprise Linux 9.2:
        $ sudo yum install openssl-devel libcurl-devel protobuf-devel cmake rpm-build createrepo yum-utils pkgconf boost-devel protobuf-lite-devel systemd-libs
      
      • On CentOS Stream 9:
        $ sudo dnf install openssl-devel libcurl-devel protobuf-devel cmake rpm-build createrepo yum-utils pkgconf boost-devel protobuf-lite-devel systemd-libs
      
      • On CentOS 8.3:
        $ sudo dnf --enablerepo=powertools install openssl-devel libcurl-devel protobuf-devel cmake rpm-build createrepo yum-utils pkgconf boost-devel protobuf-lite-devel systemd-libs
      
      • On Anolis 8.6:
        $ sudo dnf --enablerepo=PowerTools install openssl-devel libcurl-devel protobuf-devel cmake rpm-build createrepo yum-utils pkgconf boost-devel protobuf-lite-devel systemd-libs
      
      • On SUSE Linux Enterprise Server 15.4:
        $ sudo zypper install libopenssl-devel libcurl-devel protobuf-devel cmake rpm-build createrepo libsystemd0
      
      1. To install latest Intel(R) SGX SDK Installer Ensure that you have downloaded latest Intel(R) SGX SDK Installer from the Intel(R) SGX SDK and followed the Installation Guide in the same page to install latest Intel(R) SGX SDK Installer.
  • Download the source code and prepare the submodules and prebuilt binaries:

   $ git clone https://github.com/intel/linux-sgx.git
   $ cd linux-sgx && make preparation

The above make preparation would trigger the script download_prebuilt.sh to download the prebuilt binaries. You may need to set an https proxy for the wget tool used by the script (such as export https_proxy=http://test-proxy:test-port)

  • (Optional) If the binutils on your current operating system distribution doesn't support mitigation options, copy the mitigation tools corresponding to current OS distribution from external/toolset/{current_distr} to /usr/local/bin and make sure they have execute permission:
      $ sudo cp external/toolset/{current_distr}/* /usr/local/bin
      $ which ar as ld objcopy objdump ranlib
    
    Note: Mitigation tools are only provided for the operating systems whose binutils lack mitigation options support. If your operating system is not listed in the external/toolset/{current_distr} directory, you can skip this step. Otherwise, even if you previously copied the mitigation tools to /usr/local/bin, performing the above action is still necessary. This ensures that the latest mitigation tools are used during the subsequent build process.

Build the Intel(R) SGX SDK and Intel(R) SGX SDK Installer

  • To build Intel(R) SGX SDK with default configuration, enter the following command:
  $ make sdk

You can find the three flavors of tools and libraries generated in the build directory.

  • This repository supports to build the Intel(R) SGX SDK with below three combinations:
    • USE_OPT_LIBS=0 --- build SDK using SGXSSL and open sourced String/Math
    • USE_OPT_LIBS=1 --- build SDK using optimized IPP crypto and open sourced String/Math
    • USE_OPT_LIBS=2 --- build SDK with no mitigation using SGXSSL and optimized String/Math
    • USE_OPT_LIBS=3 --- build SDK with no mitigation using IPP crypto and optimized String/Math The default build uses USE_OPT_LIBS=1, if you directly type $ make sdk as above. You can switch to the other build combinations instead by entering the following command:
  $ make sdk USE_OPT_LIBS=0

or

  $ make sdk_no_mitigation USE_OPT_LIBS=2

or

  $ make sdk_no_mitigation USE_OPT_LIBS=3

Note: Building the Intel(R) SGX PSW with open sourced SGXSSL/string/math libraries is not supported. Note: Building mitigation SDK with USE_OPT_LIBS=2 or USE_OPT_LIBS=3 is not allowed.

  • To build Intel(R) SGX SDK with debug information, enter the following command:
  $ make sdk DEBUG=1
  • To clean the files generated by previous make sdk command, enter the following command:
  $ make clean
  • To build the Intel(R) SGX SDK installer, enter the following command:
  $ make sdk_install_pkg

You can find the generated Intel(R) SGX SDK installer sgx_linux_x64_sdk_${version}.bin located under linux/installer/bin/, where ${version} refers to the version number.

Note: The above command builds the Intel(R) SGX SDK with default configuration firstly and then generates the target SDK Installer. To build the Intel(R) SGX SDK Installer with debug information kept in the tools and libraries, enter the following command:

  $ make sdk_install_pkg DEBUG=1

Build the Intel(R) SGX PSW and Intel(R) SGX PSW Installer

  • To build Intel(R) SGX PSW with default configuration, enter the following command:
  $ make psw

You can find the tools and libraries generated in the build/linux directory. Note: You can also go to the psw folder and use the make command to build the Intel(R) SGX PSW component only.

  • To build Intel(R) SGX PSW with debug information, enter the following command:
  $ make psw DEBUG=1
  • To clean the files generated by previous make psw command, enter the following command:
  $ make clean

The build above uses prebuilt Intel(R) Architecture Enclaves(LE/PvE/QE/PCE) - the files psw/ae/data/prebuilt/libsgx_*.signed.so, which have been signed by Intel in advance.

  • To build those enclaves by yourself (without a signature), first you need to install latest Intel(R) SGX SDK from the Intel(R) SGX SDK and then build PSW with the default configuration. After that, you can build each Architecture Enclave by using the make command from the corresponding folder:
  $ cd psw/ae/le
  $ make
  • To build the Intel(R) SGX PSW installer, enter the following command:

    • On Ubuntu 20.04, Ubuntu 22.04, Ubuntu 23.10 and Debian 10:
    $ make deb_psw_pkg
    

    You can find the generated Intel(R) SGX PSW installers located under linux/installer/deb/libsgx-urts, linux/installer/deb/libsgx-enclave-common, linux/installer/deb/libsgx-uae-service, linux/installer/deb/libsgx-epid, linux/installer/deb/libsgx-launch, linux/installer/deb/libsgx-quote-ex and linux/installer/deb/sgx-aesm-service respectively.

    Note: Besides the Intel(R) SGX PSW installer, the above command generates another debug symbol package named package-name-dbgsym_${version}-${revision}_amd64.ddeb for debug purpose. Note: Starting with the 2.10 release, besides the Intel(R) SGX PSW installer, the above command generates SGXDataCenterAttestationPrimitives installers as well. Note: On Debian 10, the default PATH environment may not include /sbin. In this case, before trigger the build, please add /sbin to PATH environment by export PATH=$PATH:/sbin. Note: The above command builds the Intel(R) SGX PSW with default configuration firstly and then generates the target PSW Installer. To build the Intel(R) SGX PSW Installer without optimization and with full debug information kept in the tools and libraries, enter the following command:

    $ make deb_psw_pkg DEBUG=1
    
    • On Red Hat Enterprise Linux 9.2, CentOS Stream 9, CentOS 8.3, Anolis OS 8.6 and SUSE Linux Enterprise Server 15.4:
    $ make rpm_psw_pkg
    

    You can find the generated Intel(R) SGX PSW installers located under linux/installer/rpm/libsgx-urts, linux/installer/rpm/libsgx-enclave-common, linux/installer/rpm/libsgx-uae-service, linux/installer/rpm/libsgx-epid, linux/installer/rpm/libsgx-launch, linux/installer/rpm/libsgx-quote-ex and linux/installer/rpm/sgx-aesm-service respectively.

    Note: The above command builds the Intel(R) SGX PSW with default configuration firstly and then generates the target PSW Installer. To build the Intel(R) SGX PSW Installer with debug information kept in the tools and libraries, enter the following command:

    $ make rpm_psw_pkg DEBUG=1
    
  • To build local Debian package repository, enter the following command:

    $ make deb_local_repo
    

    You can find the local package repository located under linux/installer/deb/sgx_debian_local_repo.

    Note: The above command builds the local package repository. If you want to use it, you need to add it to the system repository configuration. The local package repository is not signed, you need to trust it for the purpose of development.

  • To add the local Debian package repository to the system repository configuration, append the following line to /etc/apt/sources.list. You need to replace PATH_TO_LOCAL_REPO with the proper path on your system:

    • On Ubuntu 20.04:
    deb [trusted=yes arch=amd64] file:/PATH_TO_LOCAL_REPO focal main
    
    • On Ubuntu 22.04:
    deb [trusted=yes arch=amd64] file:/PATH_TO_LOCAL_REPO jammy main
    
    • On Ubuntu 23.10:
    deb [trusted=yes arch=amd64] file:/PATH_TO_LOCAL_REPO mantic main
    
    • On Debian 10:
    deb [trusted=yes arch=amd64] file:/PATH_TO_LOCAL_REPO buster main
    

    After that, you need to update the apt:

    $ sudo apt update
    
  • To build local RPM package repository, enter the following command:

    $ make rpm_local_repo
    

    You can find the local package repository located under linux/installer/rpm/sgx_rpm_local_repo.

    Note: The above command builds the local package repository. If you want to use it, you need to add it to the system repository configuration. Since the local package repository is not signed with GPG, you should ignore the gpgcheck when installing the packages.

  • To add the local RPM package repository to the system repository configuration, you can use the following command. You need to replace PATH_TO_LOCAL_REPO with the proper path on your system:

    • On Red Hat Enterprise Linux 9.2, CentOS Stream 9, CentOS 8.3, Anolis OS 8.6:
    $ sudo yum-config-manager --add-repo file://PATH_TO_LOCAL_REPO
    
    • On SUSE Linux Enterprise Server 15.4, you need to replace LOCAL_REPO_ALIAS with proper alias name for the local repo:
    $ sudo zypper addrepo PATH_TO_LOCAL_REPO LOCAL_REPO_ALIAS
    
  • To ignore the gpgcheck when you install the package, enter the following command:

    • On Red Hat Enterprise Linux 9.2, CentOS Stream 9, CentOS 8.3, Anolis OS 8.6:
    $ sudo yum --nogpgcheck install <package>
    
    • On SUSE Linux Enterprise Server 15.4:
    $ sudo zypper --no-gpg-checks install <package>
    

Install the Intel(R) SGX SDK

Prerequisites

  • Ensure that you have one of the following operating systems:
    • Ubuntu* 20.04 LTS Desktop 64bits
    • Ubuntu* 20.04 LTS Server 64bits
    • Ubuntu* 22.04 LTS Server 64bits
    • Ubuntu* 23.10 Server 64bits
    • Red Hat Enterprise Linux Server release 9.2 64bits
    • CentOS Stream 9 64bits
    • CentOS 8.3 64bits
    • SUSE Linux Enterprise Server 15.4 64bits
    • Anolis OS 8.6 64bits
    • Debian 10 64bits
  • Use the following command to install the required tool to use Intel(R) SGX SDK:
    • On Debian 10:
      $ sudo apt-get install build-essential python3
      $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
    
    • On Ubuntu 20.04, Ubuntu 22.04 and Ubuntu 23.10:
      $ sudo apt-get install build-essential python-is-python3
    
    • On Red Hat Enterprise Linux 9.2 and CentOS Stream 9:
       $ sudo yum groupinstall 'Development Tools'
       $ sudo yum install python3
    
    • On CentOS 8.3 and Anolis OS 8.6:
       $ sudo yum groupinstall 'Development Tools'
       $ sudo yum install python3
       $ sudo alternatives --set python /usr/bin/python3
    
    • On SUSE Linux Enterprise Server 15.4:
       $ sudo zypper install --type pattern devel_basis
       $ sudo zypper install python3
       $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
    

Install the Intel(R) SGX SDK

To install the Intel(R) SGX SDK, invoke the installer, as follows:

$ cd linux/installer/bin
$ ./sgx_linux_x64_sdk_${version}.bin

The above command requires you to specify the installation path. You can use the following command to use the non-interactive installation mode:

$ cd linux/installer/bin
$ ./sgx_linux_x64_sdk_${version}.bin --prefix {SDK_INSTALL_PATH_PREFIX}

NOTE: You need to set up the needed environment variables before compiling your code. To do so, run:

  $ source ${sgx-sdk-install-path}/environment

Test the Intel(R) SGX SDK Package with the Code Samples

  • Compile and run each code sample in Simulation mode to make sure the package works well:
  $ cd ${sgx-sdk-install-path}/SampleCode/LocalAttestation
  $ make SGX_MODE=SIM
  $ cd bin
  $ ./app

Use similar commands for other sample codes.

Compile and Run the Code Samples in the Hardware Mode

If you use an Intel SGX hardware enabled machine, you can run the code samples in Hardware mode. Ensure that you install Intel(R) SGX driver and Intel(R) SGX PSW installer on the machine. See the earlier topic, Build and Install the Intel(R) SGX Driver, for information on how to install the Intel(R) SGX driver. See the later topic, Install Intel(R) SGX PSW, for information on how to install the PSW package.

  • Compile and run each code sample in Hardware mode, Debug build, as follows:
  $ cd ${sgx-sdk-install-path}/SampleCode/LocalAttestation
  $ make
  $ cd bin
  $ ./app

Use similar commands for other code samples. Note: On Ubuntu 22.04 or any distro with systemd v248 or later, /dev/sgx_enclave is only accessible by users in the group "sgx". The enclave app should be run with a uid in the sgx group.

# check systemd version:
$ systemctl --version
# add sgx group to user if it's 248 or above:
$ sudo usermod -a -G sgx <user name>

Install the Intel(R) SGX PSW

Prerequisites

  • Ensure that you have one of the following operating systems:
    • Ubuntu* 20.04 LTS Desktop 64bits
    • Ubuntu* 20.04 LTS Server 64bits
    • Ubuntu* 22.04 LTS Server 64bits
    • Ubuntu* 23.10 Server 64bits
    • Red Hat Enterprise Linux Server release 9.2 64bits
    • CentOS Stream 9 64bits
    • CentOS 8.3 64bits
    • SUSE Linux Enterprise Server 15.4 64bits
    • Anolis OS 8.6 64bits
    • Debian 10 64bits
  • Ensure that you have a system with the following required hardware:
    • 6th Generation Intel(R) Core(TM) Processor or newer
  • Configure the system with the Intel SGX hardware enabled option and install Intel(R) SGX driver in advance. See the earlier topic, Build and Install the Intel(R) SGX Driver, for information on how to install the Intel(R) SGX driver.
  • Install the library using the following command:
    • On Ubuntu 20.04, Ubuntu 22.04, Ubuntu 23.10 and Debian 10:
      $ sudo apt-get install libssl-dev libcurl4-openssl-dev libprotobuf-dev
    
    • On Red Hat Enterprise Linux 9.2:
      $ sudo yum install openssl-devel libcurl-devel protobuf-devel
    
    • On CentOS Stream 9:
      $ sudo dnf install libcurl-devel protobuf-devel
    
    • On CentOS 8.3:
      $ sudo dnf --enablerepo=powertools install libcurl-devel protobuf-devel
    
    • On Anolis OS 8.6:
      $ sudo dnf --enablerepo=PowerTools install libcurl-devel protobuf-devel
    
    • On SUSE Linux Enterprise Server 15.4:
      $ sudo zypper install libopenssl-devel libcurl-devel protobuf-devel
    

Install the Intel(R) SGX PSW

The SGX PSW provides 3 services: launch, EPID-based attestation, and algorithm agnostic attestation. Starting with the 2.8 release, the SGX PSW is split into smaller packages and the user can choose which features and services to install. There are 2 methods to install the required packages: Using individual packages or using the local repo generated by the build system. Using the local repo is recommended since the system will resolve the dependencies automatically. Currently, we support .deb and .rpm based repos.

Using the local repo(recommended)

Ubuntu 20.04, Ubuntu 22.04, Ubuntu 23.10 and Debian 10 Red Hat Enterprise Linux 9.2, CentOS Stream 9, CentOS 8.3 and Anolis OS 8.6 SUSE Linux Enterprise Server 15
launch service apt-get install libsgx-launch libsgx-urts yum install libsgx-launch libsgx-urts zypper install libsgx-launch libsgx-urts
EPID-based attestation service apt-get install libsgx-epid libsgx-urts yum install libsgx-epid libsgx-urts zypper install libsgx-epid libsgx-urts
algorithm agnostic attestation service apt-get install libsgx-quote-ex libsgx-urts yum install libsgx-quote-ex libsgx-urts zypper install libsgx-quote-ex libsgx-urts
DCAP ECDSA-based service apt-get install libsgx-dcap-ql yum install libsgx-dcap-ql zypper install libsgx-dcap-ql

Optionally, you can install *-dbgsym or *-debuginfo packages to get the debug symbols, and install *-dev or *-devel packages to get the header files for development.

Using the individual packages

Please refer Intel_SGX_Installation_Guide_Linux for detail.

Upgrade from a legacy installation

Sometimes we will split old package into smaller ones or move file between different packages. In such cases, you will encounter error messages like: "dpkg: error processing archive ....(--unpack): trying to overwrite ...". You can use 2 methods to address it.

  • Uninstall the old installation first, then install new packages.
  • Add -o Dpkg::Options::="--force-overwrite" option to overwrite existing files and use โ€œdist-upgradeโ€ instead of "upgrade" to install new packages when upgrading. In short, you should use this command:
apt-get dist-upgrade -o Dpkg::Options::="--force-overwrite"

Configure the installation

Some packages are configured with recommended dependency on other packages that are not required for certain usage. For instance, the background daemon is not required for container usage. It will be installed by default, but you can drop it by using the additional option during the installation.

  • On Ubuntu 20.04, Ubuntu 22.04, Ubuntu 23.10 and Debian 10:
  --no-install-recommends
  • On Red Hat Enterprise Linux 9.2, CentOS Stream 9, CentOS 8.3 and Anolis OS 8.6:
  --setopt=install_weak_deps=False
  • On SUSE Linux Enterprise Server 15.4:
  --no-recommends

ECDSA attestation

To enable ECDSA attestation

  • Ensure that you have the following required hardware:
    • 8th Generation Intel(R) Core(TM) Processor or newer with Flexible Launch Control support*
    • Intel(R) Atom(TM) Processor with Flexible Launch Control support*
  • To use ECDSA attestation, you must install Intel(R) Software Guard Extensions Driver for Data Center Attestation Primitives (Intel(R) SGX DCAP). Please follow the Intel(R) SGX DCAP Installation Guide for Linux* OS to install the Intel(R) SGX DCAP driver.

NOTE: If you had already installed Intel(R) SGX driver without ECDSA attestation, please uninstall the driver firstly and then install the Intel(R) SGX DCAP driver. Otherwise the newly installed Intel(R) SGX DCAP driver will be unworkable.

  • Install Quote Provider Library(QPL). You can use your own customized QPL or use default QPL provided by Intel(libsgx-dcap-default-qpl)

  • Install PCK Caching Service. For how to install and configure PCK Caching Service, please refer to SGXDataCenterAttestationPrimitives

  • Ensure the PCK Caching Service is setup correctly by local administrator or data center administrator. Also make sure that the configure file of quote provider library (/etc/sgx_default_qcnl.conf) is consistent with the real environment, for example: PCS_URL=https://your_pcs_server:8081/sgx/certification/v1/

Start or Stop aesmd Service

The Intel(R) SGX PSW installer installs an aesmd service in your machine, which is running in a special linux account aesmd. To stop the service: $ sudo service aesmd stop To start the service: $ sudo service aesmd start To restart the service: $ sudo service aesmd restart

Configure the Proxy for aesmd Service

The aesmd service uses the HTTP protocol to initialize some services. If a proxy is required for the HTTP protocol, you may need to manually set up the proxy for the aesmd service. You should manually edit the file /etc/aesmd.conf (refer to the comments in the file) to set the proxy for the aesmd service. After you configure the proxy, you need to restart the service to enable the proxy.

Reproducibility

Intel(R) SGX is providing several prebuilt binaries. All the prebuilt binaries are built from a reproducible environment in SGX docker container. To reproduce the prebuilt binaries, please follow the reproducibility README.md to prepare the SGX docker container and build out the binaries you want to verify. Most of the binaries could be verified utilizing Linux system command diff, except Intel(R) AEs. Please refer to the README.md for how to verify the reproducibililty of the built out AEs.

linux-sgx's People

Contributors

akryeem-intc avatar andyzyb avatar chrisr3 avatar daveti avatar dcmiddle avatar deeglaze avatar dingelish avatar eximius avatar fqiu1 avatar guilhemn avatar guzongmin avatar haitaohuang avatar henrywang8atfbdotcom avatar ipuustin avatar jiazhang0 avatar junjungu1 avatar lengyijun avatar lingyuj avatar llly avatar lzha101 avatar melhindi avatar mitar avatar npmccallum avatar rodolfoams avatar sbellem avatar sethmoo avatar volcano0dr avatar yuguorui avatar yuyuany avatar zhaohuidu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

linux-sgx's Issues

sgx_enable_device

What is the method to enable SGX, when SGX is software controlled, on a linux platform. I have been asking on the Intel forums and they told me I need to call sgx_enable_device. But from this document, there isn't a document method to do this from linux.

Can this be done from linux or do I need to do this from a windows VM running on the host?

simulation SDK on macOS

This might sound a bit off-topic for now but do you guys plan to provide an SDK for macOS? I'm not talking about PSW or driver, but just SDK. Simulation-only SDK is fine for that mattes.

SGX new intructions

Hi,

Since SGX introduces several new instructions, I was wondering which part consists of those new instructions: PSW, SDK or enclave?

My second question is how compilers transfer source code into SGX binary application. For example, I write a function sgx_create_enclave. To initialize an enclave, the CPU need to run EINIT instruction. But existing compilers like gcc can't produce those new instructions. Does PSW contain binary code that already has those instructions?

Thanks

Segmentation Fault when running SampleCodes

I installed SGX as described in the installation guide on a platform running Ubuntu 16.10, kernel version 4.8.0-26-generic.
I entered the directory /opt/sgxsdk/SampleCode/SampleEnclave and run the make command without any further options, and received the following output:

CC   <=  App/Enclave_u.c
CXX  <=  App/App.cpp
CXX  <=  App/Edger8rSyntax/Types.cpp
CXX  <=  App/Edger8rSyntax/Pointers.cpp
CXX  <=  App/Edger8rSyntax/Arrays.cpp
CXX  <=  App/Edger8rSyntax/Functions.cpp
CXX  <=  App/TrustedLibrary/Thread.cpp
CXX  <=  App/TrustedLibrary/Libcxx.cpp
CXX  <=  App/TrustedLibrary/Libc.cpp
LINK =>  app
GEN  =>  Enclave/Enclave_t.c
CC   <=  Enclave/Enclave_t.c
CXX  <=  Enclave/Enclave.cpp
CXX  <=  Enclave/Edger8rSyntax/Types.cpp
CXX  <=  Enclave/Edger8rSyntax/Pointers.cpp
CXX  <=  Enclave/Edger8rSyntax/Arrays.cpp
CXX  <=  Enclave/Edger8rSyntax/Functions.cpp
CXX  <=  Enclave/TrustedLibrary/Thread.cpp
CXX  <=  Enclave/TrustedLibrary/Libcxx.cpp
CXX  <=  Enclave/TrustedLibrary/Libc.cpp
LINK =>  enclave.so
<EnclaveConfiguration>
    <ProdID>0</ProdID>
    <ISVSVN>0</ISVSVN>
    <StackMaxSize>0x40000</StackMaxSize>
    <HeapMaxSize>0x100000</HeapMaxSize>
    <TCSNum>10</TCSNum>
    <TCSPolicy>1</TCSPolicy>
    <DisableDebug>0</DisableDebug>
    <MiscSelect>0</MiscSelect>
    <MiscMask>0xFFFFFFFF</MiscMask>
</EnclaveConfiguration>
Succeed.
SIGN =>  enclave.signed.so```

When running the created `app` I receive a Segmentation Fault. When running the program with valgrind I receive:

```==31277== Memcheck, a memory error detector
==31277== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==31277== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==31277== Command: ./app
==31277== 
==31277== Invalid read of size 4
==31277==    at 0x4E4A088: Node<int, CTrustThread*>::Find(int const&) (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E475A5: CTrustThreadPool::get_bound_thread(int) (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E4768E: CTrustThreadPool::_acquire_thread() (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E4773C: CTrustThreadPool::acquire_thread() (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E46C9F: CEnclave::ecall(int, void const*, void*) (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E4D008: EnclaveCreatorSim::initialize(unsigned long) (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E4A792: _create_enclave(bool, int, _se_file_t&, _le_prd_css_file_t*, unsigned char (*) [1024], int*, unsigned long*, _sgx_misc_attribute_t*) (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E4AB2A: sgx_create_enclave (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x10A31E: initialize_enclave() (in /opt/sgxsdk/SampleCode/SampleEnclave/app)
==31277==    by 0x1094B8: main (in /opt/sgxsdk/SampleCode/SampleEnclave/app)
==31277==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==31277== 
==31277== 
==31277== Process terminating with default action of signal 11 (SIGSEGV)
==31277==  Access not within mapped region at address 0x0
==31277==    at 0x4E4A088: Node<int, CTrustThread*>::Find(int const&) (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E475A5: CTrustThreadPool::get_bound_thread(int) (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E4768E: CTrustThreadPool::_acquire_thread() (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E4773C: CTrustThreadPool::acquire_thread() (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E46C9F: CEnclave::ecall(int, void const*, void*) (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E4D008: EnclaveCreatorSim::initialize(unsigned long) (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E4A792: _create_enclave(bool, int, _se_file_t&, _le_prd_css_file_t*, unsigned char (*) [1024], int*, unsigned long*, _sgx_misc_attribute_t*) (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x4E4AB2A: sgx_create_enclave (in /opt/sgxsdk/lib64/libsgx_urts_sim.so)
==31277==    by 0x10A31E: initialize_enclave() (in /opt/sgxsdk/SampleCode/SampleEnclave/app)
==31277==    by 0x1094B8: main (in /opt/sgxsdk/SampleCode/SampleEnclave/app)
==31277==  If you believe this happened as a result of a stack
==31277==  overflow in your program's main thread (unlikely but
==31277==  possible), you can try to increase the size of the
==31277==  main thread stack using the --main-stacksize= flag.
==31277==  The main thread stack size used in this run was 8388608.
==31277== 
==31277== HEAP SUMMARY:
==31277==     in use at exit: 23,820 bytes in 31 blocks
==31277==   total heap usage: 128 allocs, 97 frees, 119,812 bytes allocated
==31277== 
==31277== LEAK SUMMARY:
==31277==    definitely lost: 0 bytes in 0 blocks
==31277==    indirectly lost: 0 bytes in 0 blocks
==31277==      possibly lost: 0 bytes in 0 blocks
==31277==    still reachable: 23,820 bytes in 31 blocks
==31277==         suppressed: 0 bytes in 0 blocks
==31277== Rerun with --leak-check=full to see details of leaked memory
==31277== 
==31277== For counts of detected and suppressed errors, rerun with: -v
==31277== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)```

I also receive Segmentation Faults when running the other SampleCode examples

EnclaveCreatorHW::create_enclave generates duplicate enclave IDs

The logic in EnclaveCreatorHW::create_enclave that is responsible for generating unique IDs has multiple bugs. The primary bug is that incrementing g_eid_low and consuming the result is not an atomic operation. If two threads increment g_eid_low simultaneously, then both threads will see the same value of g_eid_low when generating the enclave_id. This results in CEnclavePool::add_enclave failing because it detects duplicate IDs.

The secondary bug is that the code is fundamentally flawed. Splicing together two separate atomics is in itself not an atomic operation, i.e. there is no way to prevent race conditions where a thread sees the "wrong" g_eid_high value.

The immediate bug can be fixed by consuming tmp instead of g_eid_low when writing enclave_id. Properly fixing all bugs requires adding/using a 64-bit atomic or wrapping the entire thing in a mutex.

  init: g_eid_low <= 1, g_eid_high <= 0
    T1: se_atomic_inc(&g_eid_low),  g_eid_low <= 2
    T2: se_atomic_inc(&g_eid_low),  g_eid_low <= 3
    T1: *enclave_id = ((uint64_t)g_eid_high << 32) | g_eid_low;  *enclave_id <= 3
    T2: *enclave_id = ((uint64_t)g_eid_high << 32) | g_eid_low;  *enclave_id <= 3

enclave_creator_hw.cpp

    uint32_t tmp = se_atomic_inc(&g_eid_low);
    //32bit overflow
    if(0 == tmp)
        g_eid_high++;
    *enclave_id = ((uint64_t)g_eid_high << 32) | g_eid_low;

Compilation issue following the README

Hi,
thank you for this very nice project !

I have an Ubuntu 14.04 64-bits in a vmware virtual machine. My CPU is Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz and I am trying to use the project only for simulation. I follow the README procedure for installation with the latest master commit and after running:

make sdk_install_pkg

I get

Generated sdk installer: ./linux/installer/bin/sgx_linux_x86_sdk_1.6.100.34922.bin

This seems strange to me as I have a 64 bit system and I would expect getting the x64 installer:

$ uname -a
Linux zerosix-linux 3.13.0-68-generic #111-Ubuntu SMP Fri Nov 6 18:17:06 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Then I run the installer and when I try to compile the sample code in SampleCode/LocalAttestation I get

make: *** Pas de rรจgle pour fabriquer la cible ยซ /XXX/linux/installer/bin/sgxsdk/bin/x64/sgx_edger8r ยป, nรฉcessaire pour ยซ LocalAttestationCode/LocalAttestationCode_t.c ยป. Arrรชt.

Which means "No rule to make tarkget ... /x64/sgx_edger8r". If I go to the sgxsdk/bin directory I see an x86 directory but no x64 directory which probably means that everything starts being wrong when I get the x86 installer instead of the x64 ...

Thanks in advance for any help,

best,

Carlos

sgx-gdb yields python errors on every ocall

When running my enclave in sim mode with the sgx-gdb tool I get errors like this:

Python Exception <class 'TypeError'> %x format: an integer is required, not gdb.Value:

Breakpoint -8, notify_gdb_to_update (base=0x7fffed991000, tcs=0x7ffff3fcb000, of=140737488344768) at /home/mike/linux-sgx/psw/urts/linux/debugger_support.cpp:116

This happens every time my enclave does an ocall, it seems. Looks like an easily fixed error?

Do you plan support for WSL (Ubuntu "Bash" in Windows 10)?

Developing in the recent Windows 10 Ubuntu subsystem (WSL) has several advantages over MS/Visual Studio for me. The Linux SDK compiles and installs just fine. However, when I try to run an app, I get an error msg like this one:

~/linux-sgx/SampleCode/SampleEnclave$ ./app
./app: error while loading shared libraries: libsgx_urts_sim.so: cannot enable executable stack as shared object requires: Invalid argument

It his fixable?

Debugging tool for enclave code?

Do you guys have a gdb plugin to allow me to print out the stack frames while the program is in the enclave? I'm debugging a SIGILL problem, and the core file seems only contain the backtrace up to the ECALL.

(gdb) bt
#0  0x00007f00c2e73418 in __GI_raise (sig=4) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007f00c434b892 in sig_handler(int, siginfo_t*, void*) () from /usr/lib/libsgx_urts.so
#2  <signal handler called>
#3  0x00007f00c434679d in __morestack () from /usr/lib/libsgx_urts.so
#4  0x00007f00c434ba2e in do_ecall(int, void const*, void const*, CTrustThread*) () from /usr/lib/libsgx_urts.so
#5  0x00007f00c4348df9 in CEnclave::ecall(int, void const*, void*) () from /usr/lib/libsgx_urts.so
#6  0x00007f00c4349f92 in sgx_ecall () from /usr/lib/libsgx_urts.so
#7  0x000000000040777c in my_function (eid=2, retval=0x7ffedaf9e394, nonce=0, id=1, type=2, data=0x2604ae0 "\366\215*2\317\027\261\061,m\263\362\066\243\214\224", 
    data_len=192, tx=0x7ffedaf9e530 "", len=0x7ffedaf9e39c) at /home/me/App/Enclave_u.c:259

sgx-gdb throws OSError

Traceback (most recent call last):
  File "<string>", line 249, in on_stop
  File "<string>", line 292, in build
  File "<string>", line 342, in update_term_width
OSError: [Errno 25] Inappropriate ioctl for device

gdb version: GNU gdb (GDB) 7.12

Launch tokens from previous SDK don't seem to be compatible with the new one

I saw that the 1.6 release has now been dropped ... I realise it's a bit early and there are no release notes yet, etc, but I figured I'd report an issue I hit immediately: the sample apps stopped working.

It took a lot of messing around and I'm not entirely sure how I fixed it, but as far as I can tell I did the following:

  • Uninstalled the prior PSW and SDK completely (means ensuring aesmd is stopped)
  • Re-downloaded the prebuilt binary files
  • did a make clean and make DEBUG=1
  • Reinstalled the PSW and SDK, this time the SDK went to a local directory
  • Deleted ~/launch.token

I hadn't realised that the last step might be necessary and was puzzled for an hour or so as to why the sample apps had stopped working with a generic error that told me nothing. You should probably consider NOT caching launch tokens in the sample apps, or at the very least, caching them to the local directory and erasing them on "make clean" because it is not at all obvious that this file is being created and reused unless you read the code.

Wrong function name used in Developer Reference

In the SDK Developer Reference v1.6 the function name sgx_get_mac_add_text_len is used in the description of sgx_unseal_data on pages 153 and 154.
On page 159 the function name sgx_get_add_mac_text_len is used.
But in the source code, the function is actually named sgx_get_add_mac_txt_len.

Error when compiling in pre-release mode

I have downloaded the example applications and tried to compile the remote attestation example in pre-release mode "make SGX_MODE=HW SGX_PRERELEASE=1"
The compilation runs without errors, but when executing the generated application I receive a missing library error:

./app: error while loading shared libraries: libsgx_urts.so: cannot open shared object file: No such file or directory

[Question] vm_mmap() fails when requesting the huge enclave size

Hi,

I try to create an enclave with a huge size, 64GB.
Although the virtual space is big, I did not activate most of them (I used less than 1GB active EPC pages).

I realized that requesting the creation of an enclave with a huge size make vm_mmap() fail in the device driver.
(in the isgx_ioctl_enclave_create() of isgx_ioctl.c)

Is there any way to bypass this error?
I need to create an enclave with a huge virtual size.

Thanks in advance

Eclipse version

Hi. I'm with a lot of troubles to put this working with Eclipse. I think that it was because of the versions... You know how can I find the versions that you recommend?

Receiving Error 400 from IAS

Hello,
I've used IAS successfully to retrieve the SigRL from it, but when verifying the Quote enclave I kepp getting an error 400. Here is the relevant code:

ret = sgx_ra_proc_msg2(this->enclave->getContext(), this->enclave->getID(), sgx_ra_proc_msg2_trusted, sgx_ra_get_msg3_trusted, p_msg2, size, &p_msg3, &msg3_size);

this call returns with SGX_SUCCESS. Then I take the quote, convert it to a std::string and and encode it to Base64:

std::string quoteStr = ConvertToString(p_msg3->quote);
quoteStr = EncodeToBase64(quoteStr);

This quote will then be put in JSON format as described here https://software.intel.com/sites/default/files/managed/3d/c8/IAS_1_0_API_spec_1_1_Final.pdf,
which gives me
{"isvEnclaveQuote": "MDIwMDAxMDBlMzBhMDAwMDA0MDA...RiMjUyYTgxOGE4NTIzMzQxZDY3"}

When I now send this as a payload to the IAS it always returns with a "400 Bad Request", which according to the API above, indicates an invalid payload!?

Am I doing something wrong here with the encoding?

Thanks

SIGSEGV due to malloc failure with SGX_MODE=SIM and HeapMaxSize=0

The simulation flow for EREPORT includes a call to sgx_rijndael128_cmac_msg, which uses malloc to allocate the buffer for the temporary CMAC state. This causes SGX applications to crash when compiled with HeapMaxSize=0 and SGX_MODE=SIM. The same application runs clean with HeapMaxSize=0 and SGX_MODE=HW as there are no heap allocations in the application itself. Running with HeapMaxSize=0 may not be recommended/common, but the simulator should not crash on an application that runs clean on hardware.

Replacing malloc with alloca in sgx_rijndael128_cmac_msg seems like a viable solution, as the temp buffer is fully contained within the function and is relatively small (less than 1k bytes). This approach allows the application to run cleanly in the simulator with HeapMaxSize=0 and StackMaxSize=0x4000.

Code to reproduce the issue can be found at this commit.

Program received signal SIGSEGV, Segmentation fault.
0x00007fffee8e872b in sys_alloc (m=0x7ffff3304280 <_gm_>, nb=688) at stdlib/malloc.c:4299
4299      MALLOC_FAILURE_ACTION;
(gdb) bt
#0  0x00007fffee8e872b in sys_alloc (m=0x7ffff3304280 <_gm_>, nb=688) at stdlib/malloc.c:4299
#1  0x00007fffee8eba9e in malloc (bytes=671) at stdlib/malloc.c:4728
#2  0x00007fffee8fb392 in sgx_rijndael128_cmac_msg (p_key=0x7fffee8ff3b0 <BASE_REPORT_KEY>, p_src=0x7ffff330a148 "\003", src_len=120, p_mac=0x7ffff330a130) at sgx_cmac128.cpp:62
#3  0x00007fffee8e410f in derive_key (dd=0x7ffff330a140, okey=0x7ffff330a130 "") at /home/sean/go/src/github.com/01org/linux-sgx/sdk/simulation/trtssim/linux/../../tinst/deriv.cpp:86
#4  0x00007fffee8e3e50 in _EREPORT (ti=0x7fffee8ff000 <SYNTHETIC_STATE>, rd=0x7fffee8ff000 <SYNTHETIC_STATE>, report=0x7ffff330aa00) at /home/sean/go/src/github.com/01org/linux-sgx/sdk/simulation/trtssim/linux/../../tinst/t_instructions.cpp:273
#5  0x00007fffee8e404c in _SE3 (xax=0, xbx=140737195798528, xcx=140737195798528, xdx=140737273440768, xsi=140737195798528, xdi=140737195798528) at /home/sean/go/src/github.com/01org/linux-sgx/sdk/simulation/trtssim/linux/../../tinst/t_instructions.cpp:343
#6  0x00007fffee8e4489 in do_ereport () at /home/sean/go/src/github.com/01org/linux-sgx/sdk/trts/linux/trts_pic.S:410
#7  0x00007ffff330aa00 in ?? ()
#8  0x00007fffee8ff000 in ?? ()
#9  0x00007ffff330c000 in ?? ()
#10 0x00007fffee8e2de0 in get_xfeature_state () at /home/sean/go/src/github.com/01org/linux-sgx/sdk/trts/trts_xsave.cpp:66
#11 0x00007fffee8e17c1 in init_enclave (enclave_base=0x7fffee8e0000, ms=0x7fffffffb990) at /home/sean/go/src/github.com/01org/linux-sgx/sdk/trts/init_enclave.cpp:101
#12 0x00007fffee8e186b in do_init_enclave (ms=0x7fffffffb990) at /home/sean/go/src/github.com/01org/linux-sgx/sdk/trts/init_enclave.cpp:129
#13 0x00007fffee8e1d13 in enter_enclave (index=-1, ms=0x7fffffffb990, tcs=0x7ffff330c000, cssa=0) at /home/sean/go/src/github.com/01org/linux-sgx/sdk/trts/trts.cpp:307
#14 0x00007fffee8e42a1 in enclave_entry () at /home/sean/go/src/github.com/01org/linux-sgx/sdk/trts/linux/trts_pic.S:136
#15 0x00007ffff7bb2b2d in __morestack () at enter_enclave.S:56
#16 0x00007ffff7bab9f0 in do_ecall (fn=-1, ocall_table=0x0, ms=0x7fffffffb990, trust_thread=0x616830) at /home/sean/go/src/github.com/01org/linux-sgx/psw/urts/linux/sig_handler.cpp:244
#17 0x00007ffff7b9f848 in CEnclave::ecall (this=0x616690, proc=-1, ocall_table=0x0, ms=0x7fffffffb990) at /home/sean/go/src/github.com/01org/linux-sgx/psw/urts/enclave.cpp:165
#18 0x00007ffff7bb223b in EnclaveCreatorSim::initialize (this=0x615030, enclave_id=91933774970882) at ../enclave_creator_sim.cpp:223
#19 0x00007ffff7ba9ba5 in __create_enclave (parser=..., base_addr=0x7ffff7f99000 "\177ELF\002\001\001", metadata=0x7ffff7fbd1c9, file=..., debug=true, lc=0x615220, prd_css_file=0x0, enclave_id=0x7fffffffdf28, misc_attr=0x0)
    at /home/sean/go/src/github.com/01org/linux-sgx/psw/urts/urts_com.h:247
#20 0x00007ffff7ba9fc9 in _create_enclave (debug=true, pfile=3, file=..., prd_css_file=0x0, launch=0x7fffffffdf30, launch_updated=0x7fffffffdf24, enclave_id=0x7fffffffdf28, misc_attr=0x0) at /home/sean/go/src/github.com/01org/linux-sgx/psw/urts/urts_com.h:333
#21 0x00007ffff7baa2ce in sgx_create_enclave (file_name=0x401272 "stream_enclave.signed.so", debug=1, launch_token=0x7fffffffdf30, launch_token_updated=0x7fffffffdf24, enclave_id=0x7fffffffdf28, misc_attr=0x0)
    at /home/sean/go/src/github.com/01org/linux-sgx/psw/urts/linux/urts.cpp:60
#22 0x00000000004007d6 in main ()

iostream support?

Hi,

As far as I can tell the Intel SGX SDK states that the trusted C++ standard library provided with the SDK should contain iostream support:

"The Intel(R) Software Guard Extensions SDK includes a trusted version of the
C++ standard library (including STL) that conforms to the C++03 standard.
The library is ported from STLport.
As for C++ standard library, most functions will work just as its untrusted part,
but here is a high level summary of features that are supported inside the
enclave:

  1. I/O related functions and classes, like iostream;
  2. Functions depend on locale library;
  3. Any other functions that require system calls."

Looking at the source code in this repository, this also suggests the same.

Is this correct? If so, what do I need to do to use access these headers? Simply including #include iostream in my enclave application doesn't seem to work. I have also added the "-lsgx_tstdc -lsgx_tstdcxx" flags to my linker.

Thanks for your help!!

sgx_init_quote is returning strange target_info

When I run sgx_init_quote and inspect resulting target_info contents, I get strange output, in base64:

7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u4BAAAAAAAAAAMAAAAAAAAA4Ol6AwAAAAAAAAAAAAAAAIDSNAv+fwAAXdgmikx/AADw1TQL/n8AAJbLMgEAAAAAnZoCAAAAAADPHKgsAAAAANDVNAv+fwAAMDe1AAAAAAAAAAAAAAAAAMhnfgMAAAAAANM0C/5/AAAs88UAAAAAAODSNAv+fwAAAgAAAAAAAAAwMoYDAAAAAM6PwbsnAAAA4Il6AwAAAABY1zQL/n8AAFjXNAv+fwAA6Gd+AwAAAABBQgB2yiEAAAAAAAAAAAAAAAAAAAAAAAC7i9cAAAAAAAibhgMAAAAA2Gd+AwAAAACQaH4DAAAAAOCJegMAAAAAyGd+AwAAAADgiXoDAAAAADCHfgMAAAAAWNc0C/5/AADgiXoDAAAAADCHfgMAAAAAQNY0C/5/AABY1zQL/n8AAMhnfgMAAAAAk4nLpLYCAAAYzXsDAAAAAOCJegMAAAAAEM17AwAAAACTicuktgIAAODTNAv+fwAAfW/HAAAAAADw0zQL/n8AACDWNAv+fwAAsNQ0C/5/AAAg1jQL/n8AAAEAAAAAAAAAINc0C/5/AACw1DQL/n8AAJDUNAv+fwAAUNQ0C/5/AAAw/NoAAAAAAGDUNAv+fwAAMPzaAAAAAAA=

When I provide this target info to sgx_create_report it fails with SGX_ERROR_INVALID_PARAMETER. Because reserved bytes are non-zero.

Bug in build-installpkg.sh script

The function get_arch() from this script expects the output of the readelf command to contain the string "Class:" along with the information needed. This will fail on an OS configured in other languages other than English, causing an error later on, since the installers will be using the wrong architecture (x86 instead of x64).

This bug can be reproduced in the latest master. (Running on a Dell Optiplex 5040 with i7-6700, SGX is enabled, Ubuntu 14.04.5 (64 bit), PT_BR system language).

Unclear how is report data for qe_report computed

In sgx_get_quote comment in the implementation it is written:

 * @param p_qe_report[out] Pointer to QE report, which reportdata is
 *                         sha256(nonce || quote)

But from code it looks like it is not just simply concatenation of nonce and quote, but that sha256 is computed in a more complicated manner. Is this documented anywhere more properly?

make SDK installer non-interactive

Hi, guys,

It would be really handy for scripting if the SDK installer doesn't ask questions (Do you want to install in the current directory? [yes/no] ). I'd suggest using arguments to do this (e.g. --prefix), which seem to be more standard...

Best,
Fan

Support for Ubuntu LTS 16.04

It would be great if there could be official support for Ubuntu LTS 16.04. It seems it works, but official support would be easier to run it in production.

How to calculate the max HeapMaxSize given the physical memory size?

I have a server with 64GB memory. When I set HeapMaxSize to 0x800000000 (2 ** 35 = 32GB), the compilation succeeds while running the program fails with unloadable enclave.

When HeapMaxSize is 0x700000000 (2 ** 32 * 7 = 28 GB), the program works. Also, I notice the program consumes around 40GB cache memory using top cmd. The TCSNum is 1.

So my question is what is the max value of HeapMaxSize?

C++11 move semantics

Hi,

One would be able to write much nicer code if move semantics were supported. Are they on the roadmap? If not, I'd possibly be willing to help implement them.

Build issues while doing a make in Ubuntu 14.04

I am getting a bunch of compilation errors while doing a make in Ubuntu 14.04.

Attaching the output of Make here.

Is there any specific arguments I should supply while doing a make?

I have been trying to follow the instructions in the README file.

log.txt

aesm_service won't start

aesmd_service can not be started.

journalctl -u aesmd.service
Sep 25 15:41:12  aesm_service[2601]: SGX Service unavailable
Sep 25 15:41:12  aesm_service[2601]: Fail to start service.

A real remote attestation example using Intel service

It seems to me that current example uses a simulated remote attestation service and not the proper Intel ones? Could there be an example of a real remote attestation be provided, where the program doing the remote attestation connects to the Intel service to check if attestation is correct?

Ubuntu 16 LTS works too

I accidentally ended up installing the latest Ubuntu and decided to proceed anyway. The SGX example apps all run in hardware mode just fine, at least on my HP machine. You could update the README to reflect that.

Got error "Please use the correct uRTS library from PSW package." when SGX_MODE=HW

Error Info

Got error "Please use the correct uRTS library from PSW package." when SGX_MODE=HW
Here is my output when trying to run the SampleEnclave with SGX_MODE=HW

[15:05:08]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin/sgxsdk/SampleCode/SampleEnclave# make SGX_MODE=HW SGX_DEBUG=1
GEN => App/Enclave_u.c
CC <= App/Enclave_u.c
CXX <= App/App.cpp
CXX <= App/Edger8rSyntax/Arrays.cpp
CXX <= App/Edger8rSyntax/Functions.cpp
CXX <= App/Edger8rSyntax/Pointers.cpp
CXX <= App/Edger8rSyntax/Types.cpp
CXX <= App/TrustedLibrary/Libc.cpp
CXX <= App/TrustedLibrary/Libcxx.cpp
CXX <= App/TrustedLibrary/Thread.cpp
LINK => app
GEN => Enclave/Enclave_t.c
CC <= Enclave/Enclave_t.c
CXX <= Enclave/Enclave.cpp
CXX <= Enclave/Edger8rSyntax/Arrays.cpp
CXX <= Enclave/Edger8rSyntax/Functions.cpp
CXX <= Enclave/Edger8rSyntax/Pointers.cpp
CXX <= Enclave/Edger8rSyntax/Types.cpp
CXX <= Enclave/TrustedLibrary/Libc.cpp
CXX <= Enclave/TrustedLibrary/Libcxx.cpp
CXX <= Enclave/TrustedLibrary/Thread.cpp
LINK => enclave.so
<EnclaveConfiguration>
  <ProdID>0</ProdID>
  <ISVSVN>0</ISVSVN>
  <StackMaxSize>0x40000</StackMaxSize>
  <HeapMaxSize>0x100000</HeapMaxSize>
  <TCSNum>10</TCSNum>
  <TCSPolicy>1</TCSPolicy>
  <DisableDebug>0</DisableDebug>
  <MiscSelect>0</MiscSelect>
  <MiscMask>0xFFFFFFFF</MiscMask>
</EnclaveConfiguration>
Parsing key file is OK.
[build_secs /home/young/repos/linux-sgx/psw/urts/loader.cpp:385] enclave start address = (nil), size = 800000
RSAVerify() returns success. The signature_verified is 1
Succeed.
SIGN => enclave.signed.so
[15:05:14]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin/sgxsdk/SampleCode/SampleEnclave# ./app
Please use the correct uRTS library from PSW package.
Error: Unexpected error occurred.
Enter a character before exit ...

About my Installation

I have successfully installed the sgx driver with this tutorial and loaded it by following https://github.com/01org/linux-sgx-driver

[14:21:18]root@young-Inspiron-13-7359:/home/young/repos/SGX-hardware# lsmod | grep sgx
isgx                   53248  1

I have successfully installed The SGX SDK and SGX PSW by following https://github.com/01org/linux-sgx-driver

[15:08:50]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin# sudo service aesmd restart
aesmd stop/waiting
aesmd start/running, process 4546
[15:09:10]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin# ps aux | grep 4546
aesmd     4546  0.0  0.1 280716 10452 ?        Ssl  15:09   0:00 /opt/intel/sgxpsw/aesm/aesm_service
root      4555  0.0  0.0  15944  2540 pts/33   S+   15:09   0:00 grep --color=auto 4546
[15:09:18]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin#

About my hardware

I'm using dell laptop Inspiron i7359-6790SLV

I'm sure that SGX is available for my CPU and enabled in BIOS by running this script https://github.com/ayeks/SGX-hardware/blob/master/test-sgx.c
Here is my result

eax: 406e3 ebx: 1100800 ecx: 7ffafbbf edx: bfebfbff
stepping 3
model 14
family 6
processor type 0
extended model 4
extended family 0
smx: 0

Extended feature bits (EAX=07H, ECX=0H)
eax: 0 ebx: 29c67af ecx: 0 edx: 0
sgx available: 1

CPUID Leaf 12H, Sub-Leaf 0 of Intel SGX Capabilities (EAX=12H,ECX=0)
eax: 1 ebx: 0 ecx: 0 edx: 241f
sgx 1 supported: 1
sgx 2 supported: 0
MaxEnclaveSize_Not64: 1f
MaxEnclaveSize_64: 24

CPUID Leaf 12H, Sub-Leaf 1 of Intel SGX Capabilities (EAX=12H,ECX=1)
eax: 36 ebx: 0 ecx: 1f edx: 0

CPUID Leaf 12H, Sub-Leaf 2 of Intel SGX Capabilities (EAX=12H,ECX=2)
eax: 80200001 ebx: 0 ecx: 5d80001 edx: 0

CPUID Leaf 12H, Sub-Leaf 3 of Intel SGX Capabilities (EAX=12H,ECX=3)
eax: 0 ebx: 0 ecx: 0 edx: 0

CPUID Leaf 12H, Sub-Leaf 4 of Intel SGX Capabilities (EAX=12H,ECX=4)
eax: 0 ebx: 0 ecx: 0 edx: 0

CPUID Leaf 12H, Sub-Leaf 5 of Intel SGX Capabilities (EAX=12H,ECX=5)
eax: 0 ebx: 0 ecx: 0 edx: 0

CPUID Leaf 12H, Sub-Leaf 6 of Intel SGX Capabilities (EAX=12H,ECX=6)
eax: 0 ebx: 0 ecx: 0 edx: 0

CPUID Leaf 12H, Sub-Leaf 7 of Intel SGX Capabilities (EAX=12H,ECX=7)
eax: 0 ebx: 0 ecx: 0 edx: 0

CPUID Leaf 12H, Sub-Leaf 8 of Intel SGX Capabilities (EAX=12H,ECX=8)
eax: 0 ebx: 0 ecx: 0 edx: 0

CPUID Leaf 12H, Sub-Leaf 9 of Intel SGX Capabilities (EAX=12H,ECX=9)
eax: 0 ebx: 0 ecx: 0 edx: 0

About my OS

[15:16:58]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin/sgxsdk/SampleCode/SampleEnclave# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.4 LTS
Release:        14.04
Codename:       trusty
[15:20:53]root@young-Inspiron-13-7359:/home/young/repos/linux-sgx/linux/installer/bin/sgxsdk/SampleCode/SampleEnclave# uname -r
4.2.0-41-generic

Any comments will be appreciated.
Thanks!!!!

Eclipse Indexer not working with sample code

Steps to reproduce:

  1. Build latest Eclipse Plugin and install
  2. Import Localattestation Project
  3. Build and run works perfectly but eclipse shows 100s of errors (see attached screenshot)

Indexer can not find stdio.h, map, inttypes.h even after manually adding required include directories
eclipseerrorsgx

Build process does not support cross compilation

The build process does not support cross compilation to allow it to be compiled with Yocto or BuildRoot or to be packaged to practically to any distribution because all distributions use some kind of cross compilation environment for compiling the binaries.

The only known working way to compile the distribution is to meet the following requirements:

  1. You must compile it in the target machine where you want to run it.
  2. The target machine must have a recent version of Ubuntu installed to it.

I've tried for four weeks to package it for BuildRoot without success. The fixes I've made so far are located in here (*.patch):

http://git.infradead.org/users/jjs/buildroot-isgx.git/tree/HEAD:/package/intel-sgx-psw

Can you put priority on fixing the issue? This practically prevents the whole world from experimenting with SGX because most of the people won't even try it unless they can conveniently install packages from a package repository for their distribution.

Error running SealedData

I'm trying to run the example of SealedData but when I make "./app" I got the error:

	Replay Protected DRM operation:
cannot create_sealed_policy, function return fail, error code =0x4001
Initialization the DRM failed.

	Replay Protected DRM update limitation:
cannot create_sealed_policy, function return fail, error code =0x4001
Initialization the DRM failed.

	Replay Protected DRM replay attack protection:
cannot create_sealed_policy, function return fail, error code =0x4001
Initialization the DRM failed.

	Time based policy operation:
cannot create_time_based_policy, function return fail, error code = 0x4001
Initialization the time based policy failed.

	Time based policy expiration:
cannot create_time_based_policy, function return fail, error code = 0x4001
Initialization the time based policy failed.
Enter a character before exit ...

Any help?

Page permission setup

Hi, I want to report a page permission setting error.
(If there is my mistake, please let me know it)

For my research work, I needed RWX pages.
I tried two ways:

  1. add extra RWX pages like heap pages --> I needed to modify the sign tool (i.e., sdk/sign_tool/SignTool/manage_metadata.cpp)
  2. add an extra RWX section in the enclave program.

The first way had a problem, so I report it here.

I confirm that the sdk and driver try to setup RWX pages correctly, but it seems that hardware does not set it up as RWX.
Writing shell code to a RWX page works fine, but executing it causes a fault.

I briefly explained this error in a git repo.

Could you please explain what is problem?

Build process is broken in cross compilation environments

libunwind fork included in cpprt fails to compile on cross compilation environments even if you patch autogen-linux.sh with an alternative HOST_OPT.

This has been a blocker for testing any kernel changes with SDK based tests for months now so it is better to make it visible here.

sgx_create_enclave hangs in infinite loop if EENTER faults

The signal handler installed by uRTS marks the SGX_ERROR_ENCLAVE_LOST if EENTER encounters an exception. Up the stack, _create_enclave unconditionally retries __create_enclave if the return value is SGX_ERROR_ENCLAVE_LOST. The intent of this code is to handle the scenario where the enclave is invalidated due to a power transition, in which case retrying __create_enclave will work, most of the time. If EENTER faults for a different reason, e.g. a driver bug, then retrying __create_enclave will never succeed and the call to sgx_create_enclave will hang indefinitely.

At the very least, the do-while loop in _create_enclave needs to have a timeout counter to break out of the loop after an arbitrary number of failed attempts. Ideally the retry logic would be exposed to the user, e.g. applications may want to control the number of retry attempts and preventing retries could be helpful for debugging.

sig_handler.cpp

    else if(xip == get_eenterp()
            && SE_EENTER == xax)
    {
        assert(reinterpret_cast<tcs_t *>(xbx) == param->tcs);
        assert(ENCLU == (*xip & 0xffffff));
        SE_TRACE(SE_TRACE_NOTICE, "exception on EENTER\n");
        //enter_enlcave function will return with SE_ERROR_ENCLAVE_LOST
        context->uc_mcontext.gregs[REG_XIP] = reinterpret_cast<greg_t>(get_eretp());
        context->uc_mcontext.gregs[REG_XSI] = SGX_ERROR_ENCLAVE_LOST;
        return;
    }

urts_com.h

    //Need to set the whole misc_attr instead of just secs_attr.
    do {
        ret = __create_enclave(parser, mh->base_addr, metadata, file, debug, lc, prd_css_file, enclave_id,
                               misc_attr);
        //SGX_ERROR_ENCLAVE_LOST caused by initializing enclave while power transition occurs
    } while(SGX_ERROR_ENCLAVE_LOST == ret);

IAS access 405 error

Since the code samples do not provide any IAS connection, I was trying to access it via Curl. Unfortunately I receive a 405 method not allowed error with is not even documented in the REST API documentation https://software.intel.com/sites/default/files/managed/3d/c8/IAS_1_0_API_spec_1_1_Final.pdf

Here is the code part that tries to perform the quote verification:

string WebService::createJSONforIAS(uint8_t *quote, uint8_t *pseManifest, uint8_t *nonce) {
Json::Value request;
string quoteStr = ByteArrayToString(quote, 1116);
quoteStr = base64encode(quoteStr);
request["isvEnclaveQuote"] = quoteStr;
Json::FastWriter fastWriter;
std::string output = fastWriter.write(request);
return output;
}

void WebService::sendToIAS(string str) {
CURL *curl;
CURLcode res = CURLE_OK;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://test-as.sgx.trustedservices.intel.com:443/attestation/sgx/v1/report");
curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_SSLCERT, "/home/kyoto/SICS_MASTERTHESIS/Development/src/WebService/client.pem");
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");
res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
cout << str << endl;
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, str);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, str.size());
res = curl_easy_perform(curl);
if (res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
curl_easy_cleanup(curl);
}
}

and here the output of curl:

* Trying 208.39.114.225...
* Connected to test-as.sgx.trustedservices.intel.com (208.39.114.225) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* NPN, negotiated HTTP1.1
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: C=US; ST=CA; L=Santa Clara; O=Intel Corporation; CN=test-as.sgx.trustedservices.intel.com
* start date: Sep 14 17:24:30 2016 GMT
* expire date: Sep 4 17:24:30 2018 GMT
* subjectAltName: test-as.sgx.trustedservices.intel.com matched
* issuer: C=US; ST=CA; L=Santa Clara; O=Intel Corporation; CN=Intel External Issuing CA 6A
* SSL certificate verify ok.
> POST /attestation/sgx/v1/report HTTP/1.1
Host: test-as.sgx.trustedservices.intel.com
Accept: application/json
Content-Type: application/json
charsets: utf-8
Content-Length: 2999
Expect: 100-continue

< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 405 Method Not Allowed
< Request-ID: 61bc4e8be2c646ebbcb97ad52d005e18
< Date: Thu, 12 Jan 2017 14:54:30 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
`

Any idea why this is failing?

aesmd - EINIT returns 2 on startup

I am on Ubuntu 16.04, using the latest master for linux-sgx and linux-sgx-driver. When I start aesmd, I get this message in dmesg:

[448620.384306] isgx: [8831:0x00007fd8aeb00000] EINIT returned 2

I assume this is not good. Any advice?

Thanks!

You forgot to put "./build-installpkg.sh sdk" in the readme

Hey guys, I'm a newbie trying to install your sdk. I noticed that in "install intel sgx sdk" section of the readme the command to generate the sdk package is missing. I think, it's good to add "$ ./build-installpkg.sh sdk" and organize this section of the readme as follows to eliminate any potential mistake.

$ cd linux/installer/bin
$ ./build-installpkg.sh sdk
$ ./sgx_linux_x64_sdk_${version}.bin

aesmd daemon does not work

I am using both master branches for intel-sgx (SDK/PSW) and intel-sgx-driver.
Until yesterday, sgx sample applications worked well, however, not I cannot run all of them.

After investigating some reason, I found the following message in dmesg:

init: aesmd main process (...), terminated with status 1
init: aesmd main process ended, respawning
...
init: aesmd respawning too fast, stopped

And then I saw /var/log/syslog, which says to be that:

aesm_service[1346]: SGX Service unavailable
aesm_service[1346]: Fail to start service.
kernel: init: aesmd main process (1346) terminated with status 1
kernel: init: aesmd main process ended, respawning
...

Hence, creating enclave was failed when I tried to run samples due to lack of aesmd.
I also saw that this is known issue of SGX SDK 1.7 release.
How can I solve this problem?

Thanks.

Remote Attestation Service Provider Sample Crypto Library to Real Crypto Library

TL;DR:

  1. Should we just be able to swap out the lib_sample_libcrypto library for the sgx_tcrypto library?
  2. If we modified the lib_sample_libcrypto library to use real random numbers instead of deterministically returning 9 each time, could it be used in a production environment?

Hi there,

I'm playing around with the Remote Attestation code example and see that the service provider uses a sample cryptographic library for debugging purposes (as described on page 82 of the developer guide[1]). This all makes sense to me, and I'm now trying to modify the example so that the service provider code also executes in an enclave. (The idea being that I could eventually remotely attest between two enclaves using this code -- ignoring any network communication outside the enclave etc.)

Of course, I can't use the sample_libcrypto inside an enclave for the service provider and in a production enclave I should instead use the real crypto library (sgx_tcrypto). It seems to me that by modifying the Service Provider/ECP/IAS_RA code, I should just be able to change all of the references from the sample crypto functions/data structures to the sgx crypto functions/data structures (for example, change sample_rijndael128_cmac_msg(...) -> sgx_rijndael128_cmac_msg(...), sample_status_t -> sgx_status_t and so on.) Is this the idea?

I have tried this, but it doesn't seem to work (once I've made all the changes and updated the edl file/ memory allocations so that messages are appropriately passed across the enclave boundary, the sample Remote Attestation code fails when the service provider tries to verify the cmac of the message, after calling sgx_rijndael128_cmac_msg (used to be sample_rijndael128_cmac_msg), the code fails the check here [3]. It seems to me like the example is structured in a way that the two libraries should be replaceable, unless there are differences between the data structures? I'm wondering if this was the original intention of the example?

Looking at the source code for the sample crypto library[2] it looks like the reason this library shouldn't be used in a production environment is because the __do_get_rand_32 function is deterministic (for debugging). Is this the only reason? If so, could one replace this function to produce real random numbers and thus use the library in a production environment?

Thanks so much for your help!!
Josh

[1] https://download.01.org/intel-sgx/linux-1.7/docs/Intel_SGX_SDK_Developer_Reference_Linux_1.7_Open_Source.pdf

[2] https://github.com/01org/linux-sgx/tree/master/sdk/sample_libcrypto

[3]https://github.com/01org/linux-sgx/blob/master/SampleCode/RemoteAttestation/service_provider/service_provider.cpp#L496

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.