!1 init itrustee sdk package

From: @chenmaodong
Reviewed-by: @blue0613
Signed-off-by: @blue0613
This commit is contained in:
openeuler-ci-bot 2021-05-17 14:43:10 +08:00 committed by Gitee
commit ce03af6a21
3 changed files with 188 additions and 0 deletions

View File

@ -0,0 +1,148 @@
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

40
itrustee_sdk.spec Normal file
View File

@ -0,0 +1,40 @@
Name: itrustee_sdk
Version: 0.1.0
Release: 1%{?dist}
Summary: Confidential computing framework for developing TA on itrustee OS
ExclusiveArch: aarch64
Group: OS Security
License: Mulan PSL v2
URL: https://gitee.com/openeuler/itrustee_sdk
Source0: https://gitee.com/openeuler/itrustee_sdk/repository/archive/v%{version}.tar.gz
Patch0: 0001-add-Makefile-to-create-libteec_adaptor.so.patch
%define debug_package %{nil}
%description
itrustee_sdk is a confidential computing framework for developing TA on itrustee OS
%prep
%autosetup -n %{name} -p1
%build
sed -i 's/fPIC/fPIC -g/g' Makefile
sed -i 's/\/opt\/itrustee_sdk/$(DESTDIR)\/opt\/itrustee_sdk/g' Makefile
sed -i 's/\/lib64/$(DESTDIR)\/lib64/g' Makefile
make
%install
install -d %{buildroot}/opt/
install -d %{buildroot}/lib64/
make install DESTDIR=%{buildroot}/
%files
%defattr(-,root,root)
/opt/itrustee_sdk
/lib64/libteec_adaptor.so
%changelog
* Sat May 8 2021 chenmaodong<chenmaodong@huawei.com> - 0.1.0-1
- DESC:init itrustee_sdk

BIN
v0.1.0.tar.gz Normal file

Binary file not shown.