# Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
# secGear is licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
#set auto code prefix
set(PREFIX helloworld)
#set sign key
set(PEM Enclave_private.pem)
#set enclave src code
set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/hello.c)
#set log level
set(PRINT_LEVEL 3)
add_definitions(-DPRINT_LEVEL=${PRINT_LEVEL})
if(CC_GP)
#set signed output
set(OUTPUT ${UUID}.sec)
#set whilelist. default: /vendor/bin/teec_hello
set(WHITE_LIST_0 /vendor/bin/helloworld)
set(WHITE_LIST_OWNER root)
set(WHITE_LIST_1 /vendor/bin/secgear_helloworld)
set(WHITELIST WHITE_LIST_0 WHITE_LIST_1)
set(AUTO_FILES ${CMAKE_CURRENT_BINARY_DIR}/${PREFIX}_t.c)
add_custom_command(OUTPUT ${AUTO_FILES}
DEPENDS ${CURRENT_ROOT_PATH}/${EDL_FILE}
COMMAND ${CODEGEN} --${CODETYPE} --trusted ${CURRENT_ROOT_PATH}/${EDL_FILE} --search-path ${SECGEAR_INSTALL_DIR})
endif()
if(CC_SGX)
set(OUTPUT enclave.signed.so)
set(AUTO_FILES ${CMAKE_CURRENT_BINARY_DIR}/${PREFIX}_t.c)
add_custom_command(OUTPUT ${AUTO_FILES}
DEPENDS ${CURRENT_ROOT_PATH}/${EDL_FILE}
COMMAND ${CODEGEN} --${CODETYPE} --trusted ${CURRENT_ROOT_PATH}/${EDL_FILE} --search-path ${SECGEAR_INSTALL_DIR} --search-path ${SDK_PATH}/include)
endif()
if(CC_PL)
set(OUTPUT penglai-ELF)
set(AUTO_FILES ${CMAKE_CURRENT_BINARY_DIR}/${PREFIX}_t.c)
add_custom_command(OUTPUT ${AUTO_FILES}
DEPENDS ${CURRENT_ROOT_PATH}/${EDL_FILE}
COMMAND ${CODEGEN} --${CODETYPE} --trusted ${CURRENT_ROOT_PATH}/${EDL_FILE} --search-path ${SECGEAR_INSTALL_DIR})
endif()
set(COMMON_C_FLAGS "-W -Wall -Werror -fno-short-enums -fno-omit-frame-pointer -fstack-protector \
-Wstack-protector --param ssp-buffer-size=4 -frecord-gcc-switches -Wextra -nostdinc -nodefaultlibs \
-fno-peephole -fno-peephole2 -Wno-main -Wno-error=unused-parameter \
-Wno-error=unused-but-set-variable -Wno-error=format-truncation=")
set(COMMON_C_LINK_FLAGS "-Wl,-z,now -Wl,-z,relro -Wl,-z,noexecstack -Wl,-nostdlib -nodefaultlibs -nostartfiles")
if(CC_GP)
set(CMAKE_C_FLAGS "${COMMON_C_FLAGS} -march=armv8-a ")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -s -fPIC")
set(CMAKE_SHARED_LINKER_FLAGS "${COMMON_C_LINK_FLAGS} -Wl,-s")
set(ITRUSTEE_TEEDIR ${SDK_PATH}/)
set(ITRUSTEE_LIBC ${SDK_PATH}/thirdparty/open_source/musl/libc)
if(${CMAKE_VERSION} VERSION_LESS "3.13.0")
link_directories(${CMAKE_BINARY_DIR}/lib/)
endif()
add_library(${PREFIX} SHARED ${SOURCE_FILES} ${AUTO_FILES})
target_include_directories( ${PREFIX} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${SECGEAR_INSTALL_DIR}/
${ITRUSTEE_TEEDIR}/include/TA
${ITRUSTEE_TEEDIR}/include/TA/huawei_ext
${ITRUSTEE_LIBC}/arch/aarch64
${ITRUSTEE_LIBC}/
${ITRUSTEE_LIBC}/arch/arm/bits
${ITRUSTEE_LIBC}/arch/generic
${ITRUSTEE_LIBC}/arch/arm)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0")
target_link_directories(${PREFIX} PRIVATE
${CMAKE_BINARY_DIR}/lib/)
endif()
foreach(WHITE_LIST ${WHITELIST})
add_definitions(-D${WHITE_LIST}="${${WHITE_LIST}}")
endforeach(WHITE_LIST)
add_definitions(-DWHITE_LIST_OWNER="${WHITE_LIST_OWNER}")
target_link_libraries(${PREFIX} -lsecgear_tee)
#for trustzone compiling, you should connact us to get config and private_key.pem for test, so we will not sign and install binary in this example #
add_custom_command(TARGET ${PREFIX}
POST_BUILD
COMMAND bash ${SIGN_TOOL} -d sign -x trustzone -i ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${PREFIX}.so -c ${CMAKE_CURRENT_SOURCE_DIR}/manifest.txt -m ${CMAKE_CURRENT_SOURCE_DIR}/config_cloud.ini -o ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${OUTPUT})
install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${OUTPUT}
DESTINATION /data
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif()
if(CC_SGX)
set(SGX_DIR ${SDK_PATH})
set(CMAKE_C_FLAGS "${COMMON_C_FLAGS} -m64 -fvisibility=hidden")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -s")
set(LINK_LIBRARY_PATH ${SGX_DIR}/lib64)
if(CC_SIM)
set(Trts_Library_Name sgx_trts_sim)
set(Service_Library_Name sgx_tservice_sim)
else()
set(Trts_Library_Name sgx_trts)
set(Service_Library_Name sgx_tservice)
endif()
set(Crypto_Library_Name sgx_tcrypto)
set(CMAKE_SHARED_LINKER_FLAGS "${COMMON_C_LINK_FLAGS} -Wl,-z,defs -Wl,-pie -Bstatic -Bsymbolic -eenclave_entry \
-Wl,--export-dynamic -Wl,--defsym,__ImageBase=0 -Wl,--gc-sections -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/Enclave.lds")
if(${CMAKE_VERSION} VERSION_LESS "3.13.0")
link_directories(${LINK_LIBRARY_PATH})
endif()
add_library(${PREFIX} SHARED ${SOURCE_FILES} ${AUTO_FILES})
target_include_directories(${PREFIX} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${SGX_DIR}/include/tlibc
${SGX_DIR}/include/libcxx
${SGX_DIR}/include
${SECGEAR_INSTALL_DIR}/)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.13.0")
target_link_directories(${PREFIX} PRIVATE
${LINK_LIBRARY_PATH})
endif()
target_link_libraries(${PREFIX} -Wl,--whole-archive ${Trts_Library_Name} -Wl,--no-whole-archive
-Wl,--start-group -lsgx_tstdc -lsgx_tcxx -l${Crypto_Library_Name} -l${Service_Library_Name} -Wl,--end-group)
add_custom_command(TARGET ${PREFIX}
POST_BUILD
COMMAND umask 0177
COMMAND openssl genrsa -3 -out ${PEM} 3072
COMMAND bash ${SIGN_TOOL} -d sign -x sgx -i ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${PREFIX}.so -k ${PEM} -o ${OUTPUT} -c ${CMAKE_CURRENT_SOURCE_DIR}/Enclave.config.xml)
endif()
if(NOT DEFINED CC_PL)
set_target_properties(${PREFIX} PROPERTIES SKIP_BUILD_RPATH TRUE)
endif()
if(CC_PL)
set(SDK_LIB_DIR ${SDK_PATH}/lib)
set(SDK_INCLUDE_DIR ${SDK_LIB_DIR}/app/include)
set(SDK_APP_LIB ${SDK_LIB_DIR}/libpenglai-enclave-eapp.a)
set(MUSL_LIB_DIR ${SDK_PATH}/musl/lib)
set(MUSL_LIBC ${MUSL_LIB_DIR}/libc.a)
set(GCC_LIB ${SDK_LIB_DIR}/libgcc.a)
set(SECGEAR_TEE_LIB ${CMAKE_BINARY_DIR}/lib/libsecgear_tee.a)
set(SOURCE_C_OBJS "")
foreach(SOURCE_FILE ${SOURCE_FILES})
STRING(REGEX REPLACE ".+/(.+)\\..*" "\\1" SOURCE_FILE_NAME ${SOURCE_FILE})
set(SOURCE_OBJ ${CMAKE_CURRENT_BINARY_DIR}/${SOURCE_FILE_NAME}.o)
add_custom_command(
OUTPUT ${SOURCE_OBJ}
DEPENDS ${SOURCE_FILES}
COMMAND gcc -Wall -I${SDK_INCLUDE_DIR} -I${CMAKE_CURRENT_BINARY_DIR} -I${CMAKE_BINARY_DIR}/inc
-I${LOCAL_ROOT_PATH}/inc/host_inc -I${LOCAL_ROOT_PATH}/inc/host_inc/penglai -I${LOCAL_ROOT_PATH}/inc/enclave_inc
-I${LOCAL_ROOT_PATH}/inc/enclave_inc/penglai -c -o ${SOURCE_OBJ} ${SOURCE_FILE}
COMMENT "generate SOURCE_OBJ"
)
list(APPEND SOURCE_C_OBJS ${SOURCE_OBJ})
endforeach()
set(APP_C_OBJ ${CMAKE_CURRENT_BINARY_DIR}/${PREFIX}_t.o)
add_custom_command(
OUTPUT ${APP_C_OBJ}
DEPENDS ${AUTO_FILES}
COMMAND gcc -Wall -I${SDK_INCLUDE_DIR} -I${CMAKE_CURRENT_BINARY_DIR} -I${CMAKE_BINARY_DIR}/inc
-I${LOCAL_ROOT_PATH}/inc/host_inc -I${LOCAL_ROOT_PATH}/inc/host_inc/penglai -I${LOCAL_ROOT_PATH}/inc/enclave_inc
-I${LOCAL_ROOT_PATH}/inc/enclave_inc/penglai -c -o ${APP_C_OBJ} ${CMAKE_CURRENT_BINARY_DIR}/${PREFIX}_t.c
COMMENT "generate APP_C_OBJ"
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${OUTPUT}
没有合适的资源?快使用搜索试试~ 我知道了~
基于硬件TEE的Confidential Computing框架设计源码
共380个文件
h:76个
txt:69个
c:69个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 121 浏览量
2024-09-24
05:10:54
上传
评论
收藏 2MB ZIP 举报
温馨提示
该项目是一个基于硬件TEE的Confidential Computing框架设计源码,主要使用C语言编写,共包含335个文件。其中包含75个C头文件(.h),68个纯文本文件(.txt),68个C源文件(.c),29个EDL文件,21个Markdown文件(.md),18个机器学习文件(.ml),11个链接脚本文件(.lds),10个XML配置文件(.xml),9个INI配置文件(.ini),5个C++源文件(.cpp)。适用于开发基于硬件TEE的安全飞地应用程序。
资源推荐
资源详情
资源评论
收起资源包目录
基于硬件TEE的Confidential Computing框架设计源码 (380个子文件)
cJSON.c 76KB
gp_enclave.c 31KB
main.c 25KB
secure_channel_common.c 22KB
secure_channel_client.c 19KB
enclave_internal.c 19KB
secure_channel_enclave.c 18KB
secure_channel_host.c 15KB
enclave.c 11KB
itrustee_tswitchless.c 11KB
gp_shared_memory.c 10KB
sgx_enclave.c 10KB
itrustee_seal_data.c 9KB
penglai_enclave.c 9KB
itrustee_shared_memory.c 8KB
gp_uswitchless.c 8KB
gp.c 7KB
server.c 5KB
secgear_seal_data.c 5KB
gp_local_attest.c 5KB
client.c 5KB
enclave_ocall.c 5KB
client.c 4KB
gp_ocall.c 4KB
gp_report_helper.c 4KB
main.c 3KB
main.c 3KB
decode.c 3KB
seal_data.c 3KB
secgear_shared_memory.c 3KB
enclave.c 3KB
gp_ra_report.c 3KB
base64url.c 2KB
example.c 2KB
main.c 2KB
error_conversion.c 2KB
encode.c 2KB
gp_ra_report_verify.c 2KB
sgx_seal_data.c 2KB
bottom_memory_check.c 2KB
main.c 2KB
main.c 2KB
penglai_ocall.c 2KB
enclave.c 2KB
error_conversion.c 2KB
penglai_seal_data.c 2KB
memory_check.c 1KB
bottom_memory_check.c 1KB
main.c 1KB
sg_ra_report.c 1KB
sgx_shared_memory.c 1KB
bottom_memory_check.c 1KB
sg_ra_report_verify.c 1KB
secgear_random.c 1KB
sgx_ra_report.c 1KB
sgx_ra_report_verify.c 1KB
enclave.c 949B
enclave.c 937B
sg_local_attest.c 877B
error_conversion.c 822B
hello.c 804B
lrt.c 803B
ocall_log.c 796B
sgx_random.c 767B
sgx_local_attest.c 758B
enclave.c 741B
penglai_random.c 736B
itrustee_random.c 725B
buffer.c 628B
virtcca.cbor 3KB
secgear.conf 166B
attestation-service.conf 161B
attestation-agent.conf 148B
enclave_kms.cpp 44KB
kms.cpp 27KB
main.cpp 20KB
secgear_ds.cpp 16KB
test.cpp 7KB
virtcca_aik_cert.der 1KB
Dockerfile 1KB
dune 775B
dune 663B
dune 227B
dune-project 312B
kms.edl 4KB
secgear_ds.edl 2KB
secure_channel.edl 2KB
switchless.edl 1KB
sc_demo.edl 932B
switchless.edl 856B
seal_data.edl 747B
la_demo.edl 729B
helloworld.edl 719B
lrt.edl 719B
ra_demo.edl 640B
secgear_tswitchless.edl 194B
secgear_tkey_exchange.edl 142B
secgear_tprotected_fs.edl 142B
secgear_tssl.edl 136B
secgear_pthread.edl 136B
共 380 条
- 1
- 2
- 3
- 4
资源评论
wjs2024
- 粉丝: 2368
- 资源: 5482
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Revman软件进行meta分析的几点介绍沈陈军.pptx
- SCADA数据采集与监视控制系统简介kunli.pptx
- Unit5Whosedogisit省公共课一等奖全国赛课获奖课件.pptx
- Unit1Howcanwebecomegoodlearners全单元2省公共课一等奖全国赛课获奖课件.pptx
- TCGA癌症数据库介绍专题.pptx
- We-fly-kites-in-spring省公开课一等奖新名师优质课比赛一等奖课件.pptx
- XX单位职工WPS办公软件培训PPT精讲.pptx
- unity三D和物联网省公共课一等奖全国赛课获奖课件.pptx
- 安阳企业如何利用互联网提升企业品牌.pptx
- 安达信—某软件公司的咨询方案.pptx
- 阿里巴巴2014产品经理实习生任务提案大学生导购网站的产品设计.pptx
- 办公自动化教案省公共课一等奖全国赛课获奖课件.pptx
- 班通信网理论基础1Internet的地址路由和管理技术walkaway.pptx
- 并行计算与多核程序设计OpenMP研讨课.pptx
- 并行程序设计导论.pptx
- 变电站综合自动化.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功