Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pkcs#11 services through OP-TEE SKS TA #121

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ endif(CCACHE_FOUND)
add_subdirectory (libteec)
add_subdirectory (tee-supplicant)
add_subdirectory (public)
add_subdirectory (libsks)
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ INCLUDEDIR ?= /include

CFG_TA_GPROF_SUPPORT ?= n

.PHONY: all build build-libteec install copy_export \
.PHONY: all build build-libteec build-libsks install copy_export \
clean cscope clean-cscope \
checkpatch-pre-req checkpatch-modified-patch checkpatch-modified-file \
checkpatch-last-commit-patch checkpatch-last-commit-file \
Expand All @@ -37,18 +37,26 @@ build-tee-supplicant: build-libteec
@echo "Building tee-supplicant"
$(MAKE) --directory=tee-supplicant --no-print-directory --no-builtin-variables

build: build-libteec build-tee-supplicant
build: build-libteec build-tee-supplicant build-libsks

build-libsks:
@echo "Building libsks.so"
@$(MAKE) --directory=libsks --no-print-directory --no-builtin-variables

install: copy_export

clean: clean-libteec clean-tee-supplicant clean-cscope
clean: clean-libteec clean-tee-supplicant clean-cscope clean-libsks

clean-libteec:
@$(MAKE) --directory=libteec --no-print-directory clean

clean-tee-supplicant:
@$(MAKE) --directory=tee-supplicant --no-print-directory clean

clean-libsks:
@$(MAKE) --directory=libsks --no-print-directory clean


cscope:
@echo " CSCOPE"
${VPREFIX}find ${CURDIR} -name "*.[chsS]" > cscope.files
Expand Down Expand Up @@ -129,3 +137,6 @@ copy_export: build
cp -a ${O}/libteec/libteec.a $(DESTDIR)$(LIBDIR)
cp ${O}/tee-supplicant/tee-supplicant $(DESTDIR)$(BINDIR)
cp public/*.h $(DESTDIR)$(INCLUDEDIR)
cp libsks/include/*.h $(DESTDIR)$(INCLUDEDIR)
cp -a ${O}/libsks/libsks.so* $(DESTDIR)$(LIBDIR)
cp -a ${O}/libsks/libsks.a $(DESTDIR)$(LIBDIR)
69 changes: 69 additions & 0 deletions libsks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
project(sks C)

set(PROJECT_VERSION "1.0.0")

################################################################################
# Packages
################################################################################
find_package(Threads REQUIRED)
if(NOT THREADS_FOUND)
message(FATAL_ERROR "Threads not found")
endif()

include(GNUInstallDirs)

################################################################################
# Source files
################################################################################
set (SRC
src/pkcs11_api.c
)

################################################################################
# Built library
################################################################################
add_library (sks SHARED ${SRC})

set_target_properties (sks PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_NAME}
)

################################################################################
# Flags always set
################################################################################
target_compile_definitions (sks
PRIVATE -D_GNU_SOURCE
PRIVATE -DBINARY_PREFIX="LT"
)

################################################################################
# Optional flags
################################################################################

################################################################################
# Public and private header and library dependencies
################################################################################
target_include_directories(sks
PUBLIC include
PRIVATE src
)

target_include_directories(teec
PUBLIC include
)

target_link_libraries (sks
PRIVATE pthread
PRIVATE teec
PRIVATE m
)

################################################################################
# Install targets
################################################################################
install (TARGETS sks
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

add_subdirectory(include)
65 changes: 65 additions & 0 deletions libsks/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
include ../flags.mk
include ../config.mk

OUT_DIR := $(OO)/libsks

.PHONY: all libsks clean

all: libsks
install: libsks

LIB_NAME := libsks
MAJOR_VERSION := 0
MINOR_VERSION := 0

LIB_MAJOR := $(LIB_NAME).so.$(MAJOR_VERSION)
LIB_MAJ_MIN := $(LIB_NAME).so.$(MAJOR_VERSION).$(MINOR_VERSION)
LIBSKS_SO_LIBRARY := $(LIB_MAJ_MIN)
LIBSKS_AR_LIBRARY := $(LIB_NAME).a

LIBSKS_SRC_DIR := src

LIBSKS_SRCS = pkcs11_api.c

LIBSKS_INCLUDES = ${CURDIR}/include
LIBSKS_INCLUDES += ${CURDIR}/../public

LIBSKS_CFLAGS := $(addprefix -I, $(LIBSKS_INCLUDES)) \
$(CFLAGS) -D_GNU_SOURCE -fPIC

LIBSKS_OBJ_DIR := $(OUT_DIR)
LIBSKS_OBJS := $(patsubst %.c,$(LIBSKS_OBJ_DIR)/%.o, $(LIBSKS_SRCS))

$(LIBSKS_OBJ_DIR)/%.o: ${LIBSKS_SRC_DIR}/%.c
$(VPREFIX)mkdir -p $(LIBSKS_OBJ_DIR)
@echo " CC $<"
$(VPREFIX)$(CC) $(LIBSKS_CFLAGS) -c $< -o $@

libsks: $(OUT_DIR)/$(LIBSKS_SO_LIBRARY)

$(OUT_DIR)/$(LIBSKS_SO_LIBRARY): $(LIBSKS_OBJS)
@echo " LINK $@"
$(VPREFIX)$(CC) -shared -Wl,-soname,$(LIBSKS_SO_LIBRARY) $(LIBSKS_LFLAGS) -o $@ $+
@echo ""

libsks: $(OUT_DIR)/$(LIBSKS_AR_LIBRARY)

$(OUT_DIR)/$(LIBSKS_AR_LIBRARY): $(LIBSKS_OBJS)
@echo " AR $@"
$(VPREFIX)$(AR) rcs $@ $+

libsks:
$(VPREFIX)ln -sf $(LIB_MAJ_MIN) $(OUT_DIR)/$(LIB_MAJOR)
$(VPREFIX)ln -sf $(LIB_MAJOR) $(OUT_DIR)/$(LIB_NAME).so

################################################################################
# Cleaning up configuration
################################################################################
clean:
$(RM) $(LIBSKS_OBJS)
$(RM) $(OUT_DIR)/$(LIB_MAJ_MIN)
$(RM) $(OUT_DIR)/$(LIB_MAJOR)
$(RM) $(OUT_DIR)/$(LIBSKS_SO_LIBRARY)
$(RM) $(OUT_DIR)/$(LIBSKS_AR_LIBRARY)
$(call rmdir,$(OUT_DIR))

7 changes: 7 additions & 0 deletions libsks/include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project (optee-cryptoki-headers C)

FILE(GLOB INSTALL_HEADERS "*.h")

add_library(${PROJECT_NAME} INTERFACE)

install (FILES ${INSTALL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
Loading