赞
踩
Open Enclave SDK提供了对Open Portable TEE OS(OP-TEE OS)的预览支持。OP-TEE是一个用于实现传统内核模式和用户模式执行环境的TEE的操作系统。它在支持ARM TrustZone的A-profile ARM系统上运行。因此,Open Enclave SDK 也可以被用来针对这些系统。
原文链接请参考Open Enclave SDK for OP-TEE OS。
启动SGX功能的前提条件时:Windows® 10 is booted in Legacy or UEFI Mode。如果是Legacy mode,则需要修改为UEFI mode,并重装windows 10。
在 Microsoft Store 中下载安装Intel(R) Software Guard Extensions Activation APP
。并以 Admin 方式打开 Intel(R) Software Guard Extensions Activation APP
,单击 【Activate】启动SGX。
安装Open Enclave SDK的环境要求如下:
下面根据自己电脑上缺失工具进行安装。
Visual Studio Build 2017下载地址在这儿。记住一定选择64位。在安装 enclave 开发环境过程中,使用2019、2022都出现了蓝屏。
安装时选择【C++ build tools】,中文是【使用C++的桌面开发】进行安装;
Visual Studio Build Tools 2017支持CMake 3.12版(构建Open Enclave SDK需要CMake 3.12版或以上)。
C:\Program Files\Git\bin
和C:\Program Files\Git\mingw64\bin
添加到 PATH
。windows10的ME下载地址在这儿。下载后直接安装,安装文件为\ME_SW_2216.16.0.2805\ME_SW_DCH\SetupME.exe
。
实验中这种方式总是提示版本不对,即使在 SGX 已经激活的状态下。
下载地址在这儿。下载后直接安装。
官方文档说SGX1+FLC
才安装PSW,但是所有支持SGX的都需要安装PSW。
查看windows版本。在cmd
或powershell
中输入:winver
,查看版本。1709是指2017年9月第一版windows10。所以一般都是使用above版本安装。
解压Intel SGX PSW v2.13.100.2
,下载地址在这儿。下载之后,解压。
进入\Intel SGX PSW for Windows v2.13.100.2\PSW_INF_RS3_and_above
目录,command(Admin)下执行:
pnputil /add-driver sgx_psw.inf /install
注:官方文档使用devcon.exe update
安装总是出错,使用pnputil没有问题。
检查PSW是否安装成功:检查C:\Windows\System32
下是否有sgx_urts.dll
,【右键->属性->详细信息】查看版本。
查看PSW是否启动。command(Admin)下执行sc query aesmservice
,输出如下信息表示已经启动。启动命令Start-Service "AESMService"
,重启命令Restart-Service "AESMService"
。
SERVICE_NAME: aesmservice
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
nuget
工具。
PATH
。3.安装openenclave nupkg
。打开Powershell(Admin),执行以下命令:
nuget.exe install open-enclave -Source D:\software\windows\SGX -OutputDirectory C:\oe -ExcludeVersion -pre
C:\oe
路径下。使用下面的命令来复制SDK到C:\openenclave
。xcopy /E C:\oe C:\openenclave\
// Powershell或者cmd下输入:
> oesgx.exe
CPU supports Software Guard Extensions:SGX1
MaxEnclaveSize_64: 2^(36)
CPU supports Key Sharing & Separation (KSS): false
EPC size on the platform: 98041856
oesgx output | SGX support level |
---|---|
CPU supports SGX_FLC:Flexible Launch Control CPU supports Software Guard Extensions:SGX1 | SGX1+FLC |
CPU supports Software Guard Extensions:SGX1 | SGX1 |
CPU does not support SGX | None |
所以本系统支持SGX1
。
安装WDK(Windows Driver Kit),获取devcon.exe
等工具。
C:\Program Files (x86)\Windows Kits\10\WindowsSDK
,其他选项根据需要进行修改。(Windows SDK 貌似不支持家庭版,因为在安装WDK的时候总是提示Windows SDK未安装。)C:\Program Files (x86)\Windows Kits\10
添加到PATH
。C:\Program Files (x86)\Windows Kits\10\Tools\x64
添加到PATH
。安装Intel SGX DCAP for Windows。
Intel SGX DCAP for Windows v1.11.100.2.exe
,解压到C:
。reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sgx_lc_msr\Parameters /v "SGX_Launch_Config_Optin" /t REG_DWORD /d 1
reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sgx_lc_msr\Parameters /v "SGX_Launch_Config_Optin"
C:\Intel SGX DCAP for Windows v1.11.100.2
目录,在command(Admin)下执行如下安装命令:devcon.exe update dcap\WindowsServer2016\sgx_dcap_dev.inf "SWC\VEN_INT&DEV_0E0C_DCAP"
devcon.exe update base\WindowsServer2019_Windows10\sgx_base.inf *INT0E0C
// 或
pnputil /add-driver base\WindowsServer2019_Windows10\sgx_base.inf /install
pnputil /add-driver dcap\WindowsServer2016\sgx_dcap_dev.inf /install
DCAP_Components
。command(Amind)执行如下命令。// 安装 DCAP_Components
nuget.exe install DCAP_Components -Source "C:\Intel SGX DCAP for Windows v1.11.100.2\nuget\DCAP_Components" -OutputDirectory C:\oe_prereqs -ExcludeVersion
// 安装 EnclaveCommonAPI
> nuget.exe install EnclaveCommonAPI -Source "C:\Intel SGX DCAP for Windows v1.11.100.2\nuget\EnclaveCommonAPI" -OutputDirectory C:\oe_prereqs -ExcludeVersion
如果安装EnclaveCommonAPI
提示错误Unable to resolve dependency 'SgxHeaders'. Source(s) used: 'nuget.org'.
或错误Unable to find package 'DCAP_Components'. Existing packages must be restored before performing an install or update.
。则不指定源,使用所有源安装EnclaveCommonAPI
。
nuget.exe install EnclaveCommonAPI -OutputDirectory C:\oe_prereqs -ExcludeVersion
Intel® Software Guard Extensions SDK for Windows*
下载地址在这儿,通过邮箱免费注册。
注册成功后,Intel 会给你的邮箱发一个邮件。通过邮件链接进入下载页面:
注册成功邮件
下载页面
注意:试了QQ、163 邮箱,QQ连注册成功的消息都无法收到。163邮箱收到了,但是通过链接都无法进入到下载界面,每次进入都会提示未注册。后来尝试了gmail邮箱就ok了(也是尝试了多次)。所以,大家多尝试下吧,我因为这个搞了好久。 不知道大家有没有这个问题。
下载之后,将 exe
修改为 zip
,运行SEWizardVS2017.vsix
,SEConfigureVS2017.vsix
, SGXDebugLauncher.vsix
,等待各自安装成功。安装成功之后,打开 visual studio 2017 新建项目即可看到 【Intel® SGX Enclave Project】 选项了。
从 visual studio 2019 开始,可以在插件中直接安装 sgx 开发环境,由于测试电脑在 visual studio 2019 上安装 sgx 开发插件时总是蓝屏(可能安装到32位),所以没有成功测试过。 搭建安装的时候注意即可。
注意:目前该SDK仅支持64bit的程序。
Path | 说明 |
---|---|
bin | Developer tools such as oedebugrt.dll for debugging and oesign for signing your enclaves. |
include\openenclave | Open Enclave runtime headers for use in your enclave (enclave.h) and its host (host.h). |
include\openenclave\3rdparty | Headers for libc, libcxx and mbedlts libraries for use inside the enclave. See the API Reference section for supported functions. |
lib\openenclave\cmake | Open Enclave SDK CMake Package for integration with your CMake projects. See README.md for more details. |
lib\openenclave\enclave | Libraries for linking into the enclave, including the libc, libcxx and mbedtls libraries for Open Enclave. |
lib\openenclave\host | Library for linking into the host process of the enclave. |
lib\openenclave\debugger | Libraries used by the gdb plug-in for debugging enclaves. |
share\openenclave\samples | Sample code showing how to use the Open Enclave SDK. |
在环境变量中增加CMAKE_PREFIX_PATH
,值为C:\openenclave\lib\openenclave\cmake
。或者:
set CMAKE_PREFIX_PATH=%CMAKE_PREFIX_PATH%;C:\openenclave\lib\openenclave\cmake
Open Enclave SDK的测试例相关文档:
// 示例
xcopy /E C:\openenclave\share\openenclave\samples E:\codes\MPC\oe-tee
适用于 VS 2017 的 x64 本机工具命令提示
编译(如果选择其他,则会提示find_package The following configuration files were considered but not accepted
的错误)。进入到程序目录。注:visual studio的各个shell工具说明在这儿。
helloworld
测试代码mkdir build
cd build
> cmake .. -G Ninja -DNUGET_PACKAGE_PATH=C:\oe_prereqs
// 等待无错误输出
> ninja
[1/1] Generating enclave/enclave.signed
Created E:/codes/MPC/oe-samples/helloworld/build/enclave/enclave.signed
> ninja run
[1/1] cmd.exe /C "cd /D E:\codes\MPC\oe-samples\helloworld...es/MPC/oe-samples/helloworld/build/enclave/enclave.signed"
Hello world from the enclave
Enclave called into host to print: Hello World!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。