7 Star 0 Fork 14

src-openEuler/itrustee_sdk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001-add-Makefile-to-create-libteec_adaptor.so.patch 5.47 KB
一键复制 编辑 原始数据 按行查看 历史
chenmaodong 提交于 2021-05-15 17:11 . init itrustee sdk package
From 8f20f580f94c4b12ac31e1fbddb9a74c8db916c6 Mon Sep 17 00:00:00 2001
From: chenmaodong <chenmaodong@huawei.com>
Date: Fri, 14 May 2021 16:00:04 +0800
Subject: [PATCH] add Makefile to create libteec_adaptor.so
Signed-off-by: chenmaodong <chenmaodong@huawei.com>
---
Makefile | 17 +++++++
src/CA/cloud/libteec_adaptor.c | 81 ++++++++++++++++++++++++++++++++++
2 files changed, 98 insertions(+)
create mode 100644 Makefile
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..7c84be3
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,17 @@
+CUR_DIR=$(shell pwd)
+iTrustee_SDK_PATH=${CUR_DIR}
+TARGET_APP := libteec_adaptor.so
+APP_SOURCES += $(iTrustee_SDK_PATH)/src/CA/cloud/libteec_adaptor.c
+APP_CFLAGS += -fstack-protector-strong -fPIC
+APP_CFLAGS += -I$(iTrustee_SDK_PATH)/include/CA -I$(iTrustee_SDK_PATH)/thirdparty/open_source/libboundscheck/include
+
+APP_LDFLAGS += -z text -z now -z relro -z noexecstack -pie -shared
+$(TARGET_APP): $(APP_SOURCE)
+ @$(CC) $(APP_CFLAGS) $(APP_LDFLAGS) $(APP_SOURCES) -o $@
+
+install: $(TARGET_APP)
+ install -d /opt/itrustee_sdk
+ cp -r build include License thirdparty /opt/itrustee_sdk
+ install -pm 644 libteec_adaptor.so /lib64/
+clean:
+ rm -rf *.o $(TARGET_APP)
diff --git a/src/CA/cloud/libteec_adaptor.c b/src/CA/cloud/libteec_adaptor.c
index f7a647e..a37cbac 100644
--- a/src/CA/cloud/libteec_adaptor.c
+++ b/src/CA/cloud/libteec_adaptor.c
@@ -41,6 +41,10 @@ typedef TEEC_Result (*allocateSharedMemory_f)(TEEC_Context *context,
TEEC_SharedMemory *sharedMem);
typedef void (*releaseSharedMemory_f)(TEEC_SharedMemory *sharedMem);
typedef void (*requestCancellation_f)(TEEC_Operation *operation);
+typedef TEEC_Result (*EXT_RegisterAgent_f)(uint32_t agentId, int *devFd, void **buffer);
+typedef TEEC_Result (*EXT_WaitEvent_f)(uint32_t agentId, int devFd);
+typedef TEEC_Result (*EXT_SendEventResponse_f)(uint32_t agentId, int devFd);
+typedef TEEC_Result (*EXT_UnregisterAgent_f)(uint32_t agentId, int devFd, void **buffer);
typedef struct {
initializeContext_f initializeContextFn;
@@ -52,6 +56,10 @@ typedef struct {
allocateSharedMemory_f allocateSharedMemoryFn;
releaseSharedMemory_f releaseSharedMemoryFn;
requestCancellation_f requestCancellationFn;
+ EXT_RegisterAgent_f EXT_RegisterAgentFn;
+ EXT_WaitEvent_f EXT_WaitEventFn;
+ EXT_SendEventResponse_f EXT_SendEventResponseFn;
+ EXT_UnregisterAgent_f EXT_UnregisterAgentFn;
} TeecApiTable;
static TeecApiTable g_teecApiTable;
@@ -94,6 +102,34 @@ static TEEC_Result GetBasicApiSymbol(TeecApiTable *teecApiTable)
TEEC_Error("get symbol TEEC_InvokeCommand failed\n");
return TEEC_ERROR_GENERIC;
}
+
+ teecApiTable->EXT_RegisterAgentFn =
+ (EXT_RegisterAgent_f)(dlsym(g_libTeecHandle, "TEEC_EXT_RegisterAgent"));
+ if (teecApiTable->EXT_RegisterAgentFn == NULL) {
+ TEEC_Error("get symbol TEEC_EXT_RegisterAgent failed\n");
+ return TEEC_ERROR_GENERIC;
+ }
+
+ teecApiTable->EXT_WaitEventFn =
+ (EXT_WaitEvent_f)(dlsym(g_libTeecHandle, "TEEC_EXT_WaitEvent"));
+ if (teecApiTable->EXT_WaitEventFn == NULL) {
+ TEEC_Error("get symbol TEEC_EXT_WaitEvent failed\n");
+ return TEEC_ERROR_GENERIC;
+ }
+
+ teecApiTable->EXT_SendEventResponseFn =
+ (EXT_SendEventResponse_f)(dlsym(g_libTeecHandle, "TEEC_EXT_SendEventResponse"));
+ if (teecApiTable->EXT_SendEventResponseFn == NULL) {
+ TEEC_Error("get symbol TEEC_EXT_SendEventResponse failed\n");
+ return TEEC_ERROR_GENERIC;
+ }
+
+ teecApiTable->EXT_UnregisterAgentFn =
+ (EXT_UnregisterAgent_f)(dlsym(g_libTeecHandle, "TEEC_EXT_UnregisterAgent"));
+ if (teecApiTable->EXT_UnregisterAgentFn == NULL) {
+ TEEC_Error("get symbol TEEC_EXT_UnregisterAgent failed\n");
+ return TEEC_ERROR_GENERIC;
+ }
return TEEC_SUCCESS;
}
@@ -266,3 +302,48 @@ void TEEC_RequestCancellation(TEEC_Operation *operation)
g_teecApiTable.requestCancellationFn(operation);
}
+
+/* This function is not support for usual user currently(just for secGear) */
+TEEC_Result TEEC_EXT_RegisterAgent(uint32_t agentId, int *devFd, void **buffer)
+{
+ if (g_teecApiTable.EXT_RegisterAgentFn == NULL) {
+ TEEC_Error("TEEC_EXT_RegisterAgent is null!\n");
+ return TEEC_ERROR_GENERIC;
+ }
+
+ g_teecApiTable.EXT_RegisterAgentFn(agentId, devFd, buffer);
+}
+
+/* This function is not support for usual user currently(just for secGear) */
+TEEC_Result TEEC_EXT_WaitEvent(uint32_t agentId, int devFd)
+{
+ if (g_teecApiTable.EXT_WaitEventFn == NULL) {
+ TEEC_Error("TEEC_EXT_WaitEvent is null!\n");
+ return TEEC_ERROR_GENERIC;
+ }
+
+ g_teecApiTable.EXT_WaitEventFn(agentId, devFd);
+}
+
+/* This function is not support for usual user currently(just for secGear) */
+TEEC_Result TEEC_EXT_SendEventResponse(uint32_t agentId, int devFd)
+{
+ if (g_teecApiTable.EXT_SendEventResponseFn == NULL) {
+ TEEC_Error("TEEC_EXT_SendEventResponse is null!\n");
+ return TEEC_ERROR_GENERIC;
+ }
+
+ g_teecApiTable.EXT_SendEventResponseFn(agentId, devFd);
+}
+
+/* This function is not support for usual user currently(just for secGear) */
+TEEC_Result TEEC_EXT_UnregisterAgent(uint32_t agentId, int devFd, void **buffer)
+{
+ if (g_teecApiTable.EXT_UnregisterAgentFn == NULL) {
+ TEEC_Error("TEEC_EXT_UnregisterAgent is null!\n");
+ return TEEC_ERROR_GENERIC;
+ }
+
+ g_teecApiTable.EXT_UnregisterAgentFn(agentId, devFd, buffer);
+}
+
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/itrustee_sdk.git
git@gitee.com:src-openeuler/itrustee_sdk.git
src-openeuler
itrustee_sdk
itrustee_sdk
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385