当前位置:   article > 正文

Ubuntu【16.04/20.04】上搭建intel SGX环境_ubuntu 跳过sgx

ubuntu 跳过sgx

 当用U盘启动盘刷了Ubuntu的机子后,可以配置一下:(请忽略)

1. 更新

  1. sudo apt update #update the list
  2. sudo apt upgrade #update contents of the list

2. 切换代理

  1. sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
  2. sudo vim /etc/apt/sources.list #https://developer.aliyun.com/mirror/ubuntu在此网址找到对应版本粘贴进去,保存
  3. sudo apt-get update

正文

在尝试了一些教程之后,发现搭建SGX环境的过程较为复杂,不适合将代码下载到本地进行编译,容易出现各种各样的报错,令人头疼。终于、找到一篇教程,并在Ubuntu20.04和16.04的版本上亲测过搭建成功!将20.04版本的也补充在这里:(建议选择本地编译还是看github上intel sgx的官方教程)

操作系统:Ubuntu 16.04/20.04 LTS

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

1. 执行:

  1. sudo apt-get update
  2. sudo apt-get install libssl-dev libcurl4-openssl-dev libprotobuf-dev
  3. sudo apt-get install build-essential python

2. 下载 Intel SGX 驱动并安装:

  1. ******16.04******
  2. 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
  3. chmod +x sgx_linux_x64_driver_2.6.0_4f5bb63.bin
  4. sudo ./sgx_linux_x64_driver_2.6.0_4f5bb63.bin
  5. ******20.04******
  6. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_driver_2.11.0_2d2b795.bin
  7. chmod +x sgx_linux_x64_driver_2.11.0_2d2b795.bin
  8. sudo ./sgx_linux_x64_driver_2.11.0_2d2b795.bin
sudo reboot

3. 下载 Intel SGX PSW 并安装:

  1. ******16.04******
  2. 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
  3. sudo dpkg -i ./libsgx-enclave-common_2.7.101.3-xenial1_amd64.deb
  4. ******20.04******
  5. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/debian_pkgs/libs/libsgx-enclave-common/libsgx-enclave-common_2.15.100.3-focal1_amd64.deb
  6. sudo dpkg -i ./libsgx-enclave-common_2.15.100.3-focal1_amd64.deb

4. 下载并安装 Intel SGX SDK:

  1. ******16.04******
  2. 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
  3. chmod +x ./sgx_linux_x64_sdk_2.7.101.3.bin
  4. ./sgx_linux_x64_sdk_2.7.101.3.bin
  5. ******20.04******
  6. wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
  7. chmod +x ./sgx_linux_x64_sdk_2.15.100.3.bin
  8. ./sgx_linux_x64_sdk_2.15.100.3.bin

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

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

source /path/to/sgxsdk/environment

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

① 切换目录

cd /path/to/sgxsdk/SampleCode/SampleEnclave

② 编辑一下 Makefile

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

③ 编译

sudo make

④ 运行

./app

运行结果:

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

​​​​​​TEE 可信执行环境 Intel SGX:环境搭建(Ubuntu) |远航 (luoyuanhang.com)

附上原文链接,感谢作者!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/65088
推荐阅读
相关标签
  

闽ICP备14008679号