29

TEE 可信执行环境 Intel SGX:环境搭建(Ubuntu)

 4 years ago
source link: http://blog.luoyuanhang.com/2019/12/05/intel-sgx-env-setup/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

本文介绍了如何在 Ubuntu 上安装 Intel SGX SDK。SGX 全称 Intel Software Guard Extensions,是 Intel 在其 CPU 体系下的扩展,用于增强软件的安全性,用于可信计算 TEE。

本文所使用环境:

操作系统:Ubuntu 16.04 LTS

按照如下步骤执行即可完成环境搭建:

  1. 执行:

    sudo apt-get update
    sudo apt-get install libssl-dev libcurl4-openssl-dev libprotobuf-dev
    sudo apt-get install build-essential python
    
  1. 下载 Intel SGX 驱动并安装:

    wget https://download.01.org/intel-sgx/sgx-linux/2.7.1/distro/ubuntu16.04-server/sgx_linux_x64_driver_2.6.0_4f5bb63.bin
    chmod +x sgx_linux_x64_driver_2.6.0_4f5bb63.bin
    sudo ./sgx_linux_x64_driver_2.6.0_4f5bb63.bin
    sudo reboot
    
  1. 下载 Intel SGX PSW 并安装:

    wget https://download.01.org/intel-sgx/sgx-linux/2.7.1/distro/ubuntu16.04-server/libsgx-enclave-common_2.7.101.3-xenial1_amd64.deb
    sudo dpkg -i ./libsgx-enclave-common_2.7.101.3-xenial1_amd64.deb
    
  1. 下载并安装 Intel SGX SDK:

    wget https://download.01.org/intel-sgx/sgx-linux/2.7.1/distro/ubuntu16.04-server/sgx_linux_x64_sdk_2.7.101.3.bin
    chmod +x ./sgx_linux_x64_sdk_2.7.101.3.bin
    ./sgx_linux_x64_sdk_2.7.101.3.bin
    

    安装过程中可以手动输入 SDK 要安装到的目标位置

  1. 添加环境变量,第 4 步结束会输出一行命令,执行:

    source /path/to/sgxsdk/environment
    

至此环境就已经搭建好了,现在我们来运行一下实例程序:

  1. 切换目录

    cd /path/to/sgxsdk/SampleCode/SampleEnclave
    
  1. 编辑一下 Makefile:

    # Intel SGX SDK 的安装位置
    SGX_SDK ?= /home/luoyhang003/SGX/sgxsdk
    # 运行类型:HW 真实环境;SIM 模拟器环境
    SGX_MODE ?= SIM
    # 运行架构:仅支持 64 位
    SGX_ARCH ?= x64
    # 是否为:Debug 调试模式
    SGX_DEBUG ?= 1
    
  1. 编译:

    sudo make
    
  1. 运行:

    ./app
    

    运行结果:

    Checksum(0x0x7fff2aa60d00, 100) = 0xfffd4143
    Info: executing thread synchronization, please wait...  
    Info: SampleEnclave successfully returned.
    Enter a character before exit ...
    

本文的版权归作者罗远航 所有,采用 Attribution-NonCommercial 3.0 License 。任何人可以进行转载、分享,但不可在未经允许的情况下用于商业用途;转载请注明出处。感谢配合!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK