Skip to content

Commit d7821b2

Browse files
committed
fixup! Add Application Secrets TEE client library
Signed-off-by: Tuomas Salokanto <tuomas.salokanto@vaisala.com>
1 parent 166b77f commit d7821b2

4 files changed

Lines changed: 35 additions & 9 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set(CMAKE_TOOLCHAIN_FILE CMakeToolchain.txt)
66

77
option(CFG_WERROR "Build with -Werror" TRUE)
88
option(WITH_TEEACL "Build libteeacl" TRUE)
9+
option(WITH_ASTEEC "Build libasteec" TRUE)
910

1011
include(GNUInstallDirs)
1112

@@ -47,4 +48,6 @@ if(WITH_TEEACL)
4748
add_subdirectory(libteeacl)
4849
endif(WITH_TEEACL)
4950
add_subdirectory(libseteec)
50-
add_subdirectory(libasteec)
51+
if(WITH_ASTEEC)
52+
add_subdirectory(libasteec)
53+
endif(WITH_ASTEEC)

Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ libdir ?= $(LIBDIR)
2020
includedir ?= $(INCLUDEDIR)
2121

2222
WITH_TEEACL ?= 1
23+
WITH_ASTEEC ?= 1
2324

2425
.PHONY: all build build-libteec build-libckteec build-libseteec \
2526
build-libteeacl build-libasteec install copy_export clean cscope \
@@ -40,10 +41,13 @@ build-tee-supplicant: build-libteec
4041
@echo "Building tee-supplicant"
4142
$(MAKE) --directory=tee-supplicant --no-print-directory --no-builtin-variables CFG_TEE_SUPP_LOG_LEVEL=$(CFG_TEE_SUPP_LOG_LEVEL)
4243

43-
build: build-libteec build-tee-supplicant build-libckteec build-libseteec build-libasteec
44+
build: build-libteec build-tee-supplicant build-libckteec build-libseteec
4445
ifeq ($(WITH_TEEACL),1)
4546
build: build-libteeacl
4647
endif
48+
ifeq ($(WITH_ASTEEC),1)
49+
build: build-libasteec
50+
endif
4751

4852
build-libckteec: build-libteec
4953
@echo "Building libckteec.so"
@@ -64,10 +68,13 @@ build-libasteec: build-libteec
6468
install: copy_export
6569

6670
clean: clean-libteec clean-tee-supplicant clean-cscope clean-libckteec \
67-
clean-libseteec clean-libasteec
71+
clean-libseteec
6872
ifeq ($(WITH_TEEACL),1)
6973
clean: clean-libteeacl
7074
endif
75+
ifeq ($(WITH_ASTEEC),1)
76+
clean: clean-libasteec
77+
endif
7178

7279
clean-libteec:
7380
@$(MAKE) --directory=libteec --no-print-directory clean
@@ -179,6 +186,8 @@ endif
179186
cp libseteec/include/*.h $(DESTDIR)$(includedir)
180187
cp -d ${O}/libseteec/libseteec.so* $(DESTDIR)$(libdir)
181188
cp -d ${O}/libseteec/libseteec.a $(DESTDIR)$(libdir)
189+
ifeq ($(WITH_ASTEEC),1)
182190
cp libasteec/include/*.h $(DESTDIR)$(includedir)
183191
cp -d ${O}/libasteec/libasteec.so* $(DESTDIR)$(libdir)
184192
cp -d ${O}/libasteec/libasteec.a $(DESTDIR)$(libdir)
193+
endif

libasteec/include/asteec.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ extern "C" {
2323
* TEEC_LOGIN_GROUP_APPLICATION methods
2424
* @param plain Pointer to plain secret
2525
* @param plain_len Byte length of plain secret
26-
* @param sealed Pointer to buffer to receive sealed secret datablob
27-
* @param sealed_len Byte length of buffer @sealed, updated with actual size
26+
* @param sealed Pointer to buffer to receive sealed secret datablob.
27+
* May be NULL when *sealed_len is 0 to query the
28+
* required output size.
29+
* @param sealed_len On input, byte length of buffer @sealed. On output,
30+
* updated with the actual size on success or the required
31+
* size when TEEC_ERROR_SHORT_BUFFER is returned.
2832
*
2933
* @return TEEC_SUCCESS on success, TEEC_ERROR_* on failure
3034
*/
@@ -40,8 +44,12 @@ TEEC_Result asteec_seal(uint32_t login_method, gid_t login_gid,
4044
* TEEC_LOGIN_GROUP_APPLICATION methods
4145
* @param sealed Pointer to sealed secret datablob
4246
* @param sealed_len Byte length of sealed secret datablob
43-
* @param plain Pointer to buffer to receive plain secret
44-
* @param plain_len Byte length of buffer @plain, updated with actual size
47+
* @param plain Pointer to buffer to receive plain secret.
48+
* May be NULL when *plain_len is 0 to query the
49+
* required output size.
50+
* @param plain_len On input, byte length of buffer @plain. On output,
51+
* updated with the actual size on success or the required
52+
* size when TEEC_ERROR_SHORT_BUFFER is returned.
4553
*
4654
* @return TEEC_SUCCESS on success, TEEC_ERROR_* on failure
4755
*/

libasteec/src/asteec.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ TEEC_Result asteec_seal(uint32_t login_method, gid_t login_gid,
4444
TEEC_Operation op = { 0 };
4545
TEEC_Result res = TEEC_ERROR_GENERIC;
4646

47-
if (!plain || plain_len == 0 || !sealed_len)
47+
if (!plain || !plain_len || !sealed_len)
48+
return TEEC_ERROR_BAD_PARAMETERS;
49+
50+
if (!sealed && *sealed_len)
4851
return TEEC_ERROR_BAD_PARAMETERS;
4952

5053
res = TEEC_InitializeContext(NULL, &ctx);
@@ -86,7 +89,10 @@ TEEC_Result asteec_unseal(uint32_t login_method, gid_t login_gid,
8689
TEEC_Operation op = { 0 };
8790
TEEC_Result res = TEEC_ERROR_GENERIC;
8891

89-
if (!sealed || !plain_len)
92+
if (!sealed || !sealed_len || !plain_len)
93+
return TEEC_ERROR_BAD_PARAMETERS;
94+
95+
if (!plain && *plain_len)
9096
return TEEC_ERROR_BAD_PARAMETERS;
9197

9298
res = TEEC_InitializeContext(NULL, &ctx);

0 commit comments

Comments
 (0)