赞
踩
当用U盘启动盘刷了Ubuntu的机子后,可以配置一下:(请忽略)
1. 更新
- sudo apt update #update the list
- sudo apt upgrade #update contents of the list
2. 切换代理
- sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
- sudo vim /etc/apt/sources.list #https://developer.aliyun.com/mirror/ubuntu在此网址找到对应版本粘贴进去,保存
- sudo apt-get update
正文
在尝试了一些教程之后,发现搭建SGX环境的过程较为复杂,不适合将代码下载到本地进行编译,容易出现各种各样的报错,令人头疼。终于、找到一篇教程,并在Ubuntu20.04和16.04的版本上亲测过搭建成功!将20.04版本的也补充在这里:(建议选择本地编译还是看github上intel sgx的官方教程)
操作系统:Ubuntu 16.04/20.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
2. 下载 Intel SGX 驱动并安装:
- ******16.04******
- 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
-
- ******20.04******
- wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_driver_2.11.0_2d2b795.bin
- chmod +x sgx_linux_x64_driver_2.11.0_2d2b795.bin
- sudo ./sgx_linux_x64_driver_2.11.0_2d2b795.bin
sudo reboot
3. 下载 Intel SGX PSW 并安装:
- ******16.04******
- 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
-
- ******20.04******
- 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
- sudo dpkg -i ./libsgx-enclave-common_2.15.100.3-focal1_amd64.deb
4. 下载并安装 Intel SGX SDK:
- ******16.04******
- 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
-
- ******20.04******
- wget https://download.01.org/intel-sgx/sgx-linux/2.15/distro/ubuntu20.04-server/sgx_linux_x64_sdk_2.15.100.3.bin
- chmod +x ./sgx_linux_x64_sdk_2.15.100.3.bin
- ./sgx_linux_x64_sdk_2.15.100.3.bin
安装过程中可以手动输入 SDK 要安装到的目标位置
5. 添加环境变量,第 4 步结束会输出一行命令,执行:
source /path/to/sgxsdk/environment
至此环境就已经搭建好了,现在我们来运行一下实例程序:
① 切换目录
cd /path/to/sgxsdk/SampleCode/SampleEnclave
② 编辑一下 Makefile
- # Intel SGX SDK 的安装位置
- SGX_SDK ?= /home/luoyhang003/SGX/sgxsdk
- # 运行类型:HW 真实环境;SIM 模拟器环境
- SGX_MODE ?= SIM
- # 运行架构:仅支持 64 位
- SGX_ARCH ?= x64
- # 是否为:Debug 调试模式
- SGX_DEBUG ?= 1
③ 编译
sudo make
④ 运行
./app
运行结果:
- Checksum(0x0x7fff2aa60d00, 100) = 0xfffd4143
- Info: executing thread synchronization, please wait...
- Info: SampleEnclave successfully returned.
- Enter a character before exit ...
TEE 可信执行环境 Intel SGX:环境搭建(Ubuntu) |远航 (luoyuanhang.com)
附上原文链接,感谢作者!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。