diff --git a/build/Makefile b/build/Makefile index a66b5615..1b9fdd03 100644 --- a/build/Makefile +++ b/build/Makefile @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. ifneq ($V,) VER := else diff --git a/build/mk/common/cfi/llvm-apps-cfi.mk b/build/mk/common/cfi/llvm-apps-cfi.mk index 91795e43..360ebd29 100644 --- a/build/mk/common/cfi/llvm-apps-cfi.mk +++ b/build/mk/common/cfi/llvm-apps-cfi.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + ifeq ($(CONFIG_LLVM_CFI),y) ifeq ($(CONFIG_LLVM_LTO),y) diff --git a/build/mk/common/config/arch_config.mk b/build/mk/common/config/arch_config.mk index 84ca4928..d6758d01 100644 --- a/build/mk/common/config/arch_config.mk +++ b/build/mk/common/config/arch_config.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. +# CFLAGS := CPPFLAGS := ASFLAGS := diff --git a/build/mk/common/config/cfg.mk b/build/mk/common/config/cfg.mk index 54fa5852..a585830b 100644 --- a/build/mk/common/config/cfg.mk +++ b/build/mk/common/config/cfg.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + include $(BUILD_CONFIG)/var.mk PREBUILD_SDK := $(PREBUILD_DIR)/headers/sdk PREBUILD_INNER_SDK := $(PREBUILD_DIR)/headers/inner_sdk diff --git a/build/mk/common/config/feature-macro.mk b/build/mk/common/config/feature-macro.mk index 5108e9f9..bd1bfaf7 100644 --- a/build/mk/common/config/feature-macro.mk +++ b/build/mk/common/config/feature-macro.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + # extra-flags is for export.txt and extern.txt of libteec_share ifeq ($(CONFIG_SSA_64BIT), true) flags += -DTEE_SUPPORT_SSA_64BIT diff --git a/build/mk/common/config/plat_config_file.mk b/build/mk/common/config/plat_config_file.mk index 533dacb0..f177c54c 100644 --- a/build/mk/common/config/plat_config_file.mk +++ b/build/mk/common/config/plat_config_file.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + export PLAT_AUTOCONF_FILE := $(PREBUILD_DIR)/headers/platautoconf.h DEBUG_RELEASE_MACRO := release diff --git a/build/mk/common/config/teeos-flags.mk b/build/mk/common/config/teeos-flags.mk index 51c9f0ae..f295e3e0 100644 --- a/build/mk/common/config/teeos-flags.mk +++ b/build/mk/common/config/teeos-flags.mk @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # #teeos-flags.mk # diff --git a/build/mk/common/config/toolchain.mk b/build/mk/common/config/toolchain.mk index 8ab35599..93b7af91 100644 --- a/build/mk/common/config/toolchain.mk +++ b/build/mk/common/config/toolchain.mk @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # #toolchain.mk # diff --git a/build/mk/common/config/var.mk b/build/mk/common/config/var.mk index c5a0e907..38ae7d5c 100644 --- a/build/mk/common/config/var.mk +++ b/build/mk/common/config/var.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + # basic dirs, these variables will be used by whole project override BUILD_DIR := $(OUTPUTDIR)/$(ARCH)/obj/$(ARCH)/$(MODULE_FOLDER) override LIB_DIR := $(OUTPUTDIR)/$(ARCH)/libs diff --git a/build/mk/common/operation/common.mk b/build/mk/common/operation/common.mk index e64de23d..9622818b 100644 --- a/build/mk/common/operation/common.mk +++ b/build/mk/common/operation/common.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + MODULE_FOLDER := $(shell basename $(CURDIR)) ifeq ($(ARCH),) diff --git a/build/mk/common/operation/project.mk b/build/mk/common/operation/project.mk index bc413d18..76d19121 100644 --- a/build/mk/common/operation/project.mk +++ b/build/mk/common/operation/project.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + # # FILE: project.mk # diff --git a/build/mk/common/operation/rule.mk b/build/mk/common/operation/rule.mk index 1b8ddf47..5c06d4a3 100644 --- a/build/mk/common/operation/rule.mk +++ b/build/mk/common/operation/rule.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + ## This function will generate $(1)_objs variables which provided ## the objects needed to compile to the $(1) module. ## diff --git a/build/mk/driver_common/drv-common.mk b/build/mk/driver_common/drv-common.mk index 1dbd9b41..266404e6 100644 --- a/build/mk/driver_common/drv-common.mk +++ b/build/mk/driver_common/drv-common.mk @@ -1,2 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + include $(BUILD_DRIVER)/drv-flags.mk include $(BUILD_OPERATION)/common.mk diff --git a/build/mk/driver_common/drv-flags.mk b/build/mk/driver_common/drv-flags.mk index aaf48944..837a8c0c 100644 --- a/build/mk/driver_common/drv-flags.mk +++ b/build/mk/driver_common/drv-flags.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + # hm entrypoint ENTRY_POINT ?= _hm_start diff --git a/build/mk/framework_common/ta-common.mk b/build/mk/framework_common/ta-common.mk index 0d8ff0e0..e41ad518 100644 --- a/build/mk/framework_common/ta-common.mk +++ b/build/mk/framework_common/ta-common.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + TARGET_IS_TA := y # setup toolchain include $(BUILD_CONFIG)/cfg.mk diff --git a/build/mk/lib_common/lib-common.mk b/build/mk/lib_common/lib-common.mk index 66c39383..e8d3a8e7 100644 --- a/build/mk/lib_common/lib-common.mk +++ b/build/mk/lib_common/lib-common.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + # llvm c++ libs and headers PREBUILD_TOOLCHAIN := $(TOPDIR)/prebuild/toolchains/llvm_sysroot LLVM_INC := $(PREBUILD_TOOLCHAIN)/$(ARCH)/include diff --git a/build/mk/pack/bootfs.mk b/build/mk/pack/bootfs.mk index a236c143..e46c68fa 100644 --- a/build/mk/pack/bootfs.mk +++ b/build/mk/pack/bootfs.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + RAMFSMKIMG := $(PREBUILD_TOOLS)/ramfsmkimg # prebuild apps diff --git a/build/mk/pack/plat_config.mk b/build/mk/pack/plat_config.mk index 213c9321..52f6f90c 100644 --- a/build/mk/pack/plat_config.mk +++ b/build/mk/pack/plat_config.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + ifeq ($(CONFIG_TA_64BIT), true) product_apps += $(OUTPUTDIR)/aarch64/drivers/tarunner.elf endif diff --git a/build/mk/service_common/svc-common.mk b/build/mk/service_common/svc-common.mk index 02064d56..38fe4d86 100644 --- a/build/mk/service_common/svc-common.mk +++ b/build/mk/service_common/svc-common.mk @@ -1,2 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + include $(BUILD_SERVICE)/svc-flags.mk include $(BUILD_OPERATION)/common.mk diff --git a/build/mk/service_common/svc-flags.mk b/build/mk/service_common/svc-flags.mk index 79e57bb5..abb4f6b1 100644 --- a/build/mk/service_common/svc-flags.mk +++ b/build/mk/service_common/svc-flags.mk @@ -1,3 +1,13 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. + # hm entrypoint ENTRY_POINT ?= _hm_start diff --git a/build/tools/generate_img/check-syms.sh b/build/tools/generate_img/check-syms.sh index 46932de0..0f7f179d 100755 --- a/build/tools/generate_img/check-syms.sh +++ b/build/tools/generate_img/check-syms.sh @@ -1,6 +1,14 @@ #!/bin/bash # Usage: check-syms.sh TA.elf libc.so libtee.so -# Copyright Huawei Technologies Co., Ltd. 2010-2022. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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 -e # add ignored syms to IGNORED diff --git a/build/tools/generate_img/cpio-strip/Makefile b/build/tools/generate_img/cpio-strip/Makefile index 9f287815..2c919cd1 100644 --- a/build/tools/generate_img/cpio-strip/Makefile +++ b/build/tools/generate_img/cpio-strip/Makefile @@ -1,5 +1,12 @@ -# cpio-strip compile rule. -# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. override CC := gcc GENERAL_OPTIONS := -Wall -Werror -Wextra -Wfloat-equal -Wshadow -Wtrampolines -Wformat=2\ diff --git a/build/tools/generate_img/cpio-strip/cpio_strip.c b/build/tools/generate_img/cpio-strip/cpio_strip.c index 15577030..f8bc70f5 100644 --- a/build/tools/generate_img/cpio-strip/cpio_strip.c +++ b/build/tools/generate_img/cpio-strip/cpio_strip.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: cpio strip function - * Create: 2020-06-04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #define _XOPEN_SOURCE 700 diff --git a/build/tools/generate_img/gen_boot_function.sh b/build/tools/generate_img/gen_boot_function.sh index 0c546152..ebec8f41 100644 --- a/build/tools/generate_img/gen_boot_function.sh +++ b/build/tools/generate_img/gen_boot_function.sh @@ -1,6 +1,14 @@ #!/bin/bash # function belong to gen_boot_image. -# Copyright Huawei Technologies Co., Ltd. 2010-2022. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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 -e function pad8_name() { diff --git a/build/tools/generate_img/gen_boot_image.sh b/build/tools/generate_img/gen_boot_image.sh index 557ce2da..767d30f7 100755 --- a/build/tools/generate_img/gen_boot_image.sh +++ b/build/tools/generate_img/gen_boot_image.sh @@ -1,6 +1,14 @@ #!/bin/bash # Print all commands if V=3; maximum verbosity. -# Copyright Huawei Technologies Co., Ltd. 2010-2019. All rights reserved.] +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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 -e source ${BUILD_TOOLS}/generate_img/gen_boot_function.sh diff --git a/build/tools/generate_img/smart-strip.sh b/build/tools/generate_img/smart-strip.sh index 15f5e2ba..64abf28b 100755 --- a/build/tools/generate_img/smart-strip.sh +++ b/build/tools/generate_img/smart-strip.sh @@ -1,6 +1,14 @@ #!/bin/bash # Get the elf file, judge 32 or 64, and strip off some symbol information and debugging information to make the file smaller -# Copyright Huawei Technologies Co., Ltd. 2010-2019. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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 -e strip_file() { diff --git a/build/tools/hmfilemgr/Makefile b/build/tools/hmfilemgr/Makefile index 1c8ba285..a731355e 100755 --- a/build/tools/hmfilemgr/Makefile +++ b/build/tools/hmfilemgr/Makefile @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # # @TAG(HUAWEI) # diff --git a/build/tools/hmfilemgr/src/get_ramfs_data.c b/build/tools/hmfilemgr/src/get_ramfs_data.c index da2fa92d..086fc8ef 100644 --- a/build/tools/hmfilemgr/src/get_ramfs_data.c +++ b/build/tools/hmfilemgr/src/get_ramfs_data.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: Procedure for reading ramfs data (for AArch64) - * Create: 2018-05-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "get_ramfs_data.h" diff --git a/build/tools/hmfilemgr/src/get_ramfs_data.h b/build/tools/hmfilemgr/src/get_ramfs_data.h index 52e759c6..096796b2 100644 --- a/build/tools/hmfilemgr/src/get_ramfs_data.h +++ b/build/tools/hmfilemgr/src/get_ramfs_data.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: Procedure for reading ramfs data (for AArch64) - * Create: 2018-05-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef _GET_RAMFS_DATA_H_ #define _GET_RAMFS_DATA_H_ diff --git a/build/tools/pack_img/elf_extract.c b/build/tools/pack_img/elf_extract.c index fa4b1e37..8fb7585e 100644 --- a/build/tools/pack_img/elf_extract.c +++ b/build/tools/pack_img/elf_extract.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Create: 2019-06-18 - * Description: copy symtab and strtab + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/build/tools/pack_img/header.py b/build/tools/pack_img/header.py index 35256cb6..fcc3638d 100755 --- a/build/tools/pack_img/header.py +++ b/build/tools/pack_img/header.py @@ -1,6 +1,14 @@ #!/usr/bin/env python3 #trustedcore package header generator -# Copyright Huawei Technologies Co., Ltd. 2010-2019. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. """Description:package image for phone """ from __future__ import print_function diff --git a/build/tools/pack_img/packimg.sh b/build/tools/pack_img/packimg.sh index 02f95bd6..925588a6 100755 --- a/build/tools/pack_img/packimg.sh +++ b/build/tools/pack_img/packimg.sh @@ -1,5 +1,13 @@ #!/bin/bash -# Copyright Huawei Technologies Co., Ltd. 2010-2022. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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 -e COMPARE_IMAGE="$2" diff --git a/build/tools/ramfsmkimg_host/Makefile b/build/tools/ramfsmkimg_host/Makefile index e87a8c46..04f81cc8 100755 --- a/build/tools/ramfsmkimg_host/Makefile +++ b/build/tools/ramfsmkimg_host/Makefile @@ -1,6 +1,12 @@ -# Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. -# Description: makeflie for rmfs -# Create: 2019-08-20 +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. CC = cc CPPFLAGS := diff --git a/build/tools/ramfsmkimg_host/src/main.c b/build/tools/ramfsmkimg_host/src/main.c index 2a45c8bf..06f72ab7 100644 --- a/build/tools/ramfsmkimg_host/src/main.c +++ b/build/tools/ramfsmkimg_host/src/main.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: main function of ramfs - * Create: 2019-08-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/config/debug_config/oh_32_debug_config b/config/debug_config/oh_32_debug_config index cb16dd95..1c05b15f 100644 --- a/config/debug_config/oh_32_debug_config +++ b/config/debug_config/oh_32_debug_config @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # # PLATFORM # diff --git a/config/debug_config/oh_64_debug_config b/config/debug_config/oh_64_debug_config index cad0c69e..74620d14 100644 --- a/config/debug_config/oh_64_debug_config +++ b/config/debug_config/oh_64_debug_config @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # # PLATFORM # diff --git a/config/platform/oh/oh/oh_32/plat_cfg/plat_cfg.c b/config/platform/oh/oh/oh_32/plat_cfg/plat_cfg.c index 60ada947..2e1306cb 100644 --- a/config/platform/oh/oh/oh_32/plat_cfg/plat_cfg.c +++ b/config/platform/oh/oh/oh_32/plat_cfg/plat_cfg.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: plat_cfg defines - * Create: 2022-01-04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "plat_cfg.h" diff --git a/config/platform/oh/oh/oh_32/plat_cfg/plat_cfg.h b/config/platform/oh/oh/oh_32/plat_cfg/plat_cfg.h index 3af403c3..0c50aaff 100644 --- a/config/platform/oh/oh/oh_32/plat_cfg/plat_cfg.h +++ b/config/platform/oh/oh/oh_32/plat_cfg/plat_cfg.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: plat_cfg defines - * Create: 2022-01-04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PLAT_CFG_H #define PLAT_CFG_H diff --git a/config/platform/oh/oh/oh_64/plat_cfg/plat_cfg.c b/config/platform/oh/oh/oh_64/plat_cfg/plat_cfg.c index 888121b2..f8f74639 100644 --- a/config/platform/oh/oh/oh_64/plat_cfg/plat_cfg.c +++ b/config/platform/oh/oh/oh_64/plat_cfg/plat_cfg.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: plat_cfg defines - * Create: 2022-01-04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "plat_cfg.h" #include "plat_cfg_public.h" diff --git a/config/platform/oh/oh/oh_64/plat_cfg/plat_cfg.h b/config/platform/oh/oh/oh_64/plat_cfg/plat_cfg.h index 38ceae69..b176c663 100644 --- a/config/platform/oh/oh/oh_64/plat_cfg/plat_cfg.h +++ b/config/platform/oh/oh/oh_64/plat_cfg/plat_cfg.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: plat_cfg defines - * Create: 2022-01-04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PLAT_CFG_H #define PLAT_CFG_H diff --git a/config/release_config/oh_32_release_config b/config/release_config/oh_32_release_config index 2f55233a..de8f64bc 100644 --- a/config/release_config/oh_32_release_config +++ b/config/release_config/oh_32_release_config @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # # PLATFORM # diff --git a/config/release_config/oh_64_release_config b/config/release_config/oh_64_release_config index 3fb69fe4..5f1148cc 100644 --- a/config/release_config/oh_64_release_config +++ b/config/release_config/oh_64_release_config @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # # PLATFORM # diff --git a/drivers/crypto_mgr/Makefile b/drivers/crypto_mgr/Makefile index 7c58f3b7..842f3890 100644 --- a/drivers/crypto_mgr/Makefile +++ b/drivers/crypto_mgr/Makefile @@ -1,4 +1,12 @@ -# Copyright Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. DRIVER := crypto_mgr.elf diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_driver_adaptor_ops.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_driver_adaptor_ops.h index 0d83c450..069282cd 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_driver_adaptor_ops.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_driver_adaptor_ops.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: Crypto API at driver adaptor. - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_DRIVER_ADAPTOR_OPS_H #define CRYPTO_DRIVER_ADAPTOR_OPS_H diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_mgr_syscall.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_mgr_syscall.h index 62b27ed3..7047b13a 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_mgr_syscall.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_mgr_syscall.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: Crypto API at driver adaptor. - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_MGR_SYSCALL_H #define CRYPTO_MGR_SYSCALL_H diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall.c b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall.c index c624c88a..75e38e1c 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall.c +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto hal syscall - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_syscall_common.h" #include diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ae.c b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ae.c index e7c1c8de..030183fe 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ae.c +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ae.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto syscall ae - * Create: 2022-01-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_syscall_common.h" #include diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ae.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ae.h index 63319e6d..3e77b743 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ae.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ae.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto syscall ae - * Create: 2022-01-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_SYSCALL_AE_H #define CRYPTO_SYSCALL_AE_H diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_cipher.c b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_cipher.c index 64daee32..d33210c7 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_cipher.c +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_cipher.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto syscall cipher - * Create: 2022-01-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_syscall_common.h" #include diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_cipher.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_cipher.h index 47885772..7446ce12 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_cipher.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_cipher.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto syscall cipher - * Create: 2022-01-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_SYSCALL_CIPHER_H #define CRYPTO_SYSCALL_CIPHER_H diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_common.c b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_common.c index 9fe0cda9..b3fe778e 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_common.c +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_common.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto syscall common - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_syscall_common.h" #include diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_common.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_common.h index 3906ee95..b6cf99c0 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_common.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_common.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto syscall common - * Create: 2022-01-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_SYSCALL_COMMON_H #define CRYPTO_SYSCALL_COMMON_H diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_derive_key.c b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_derive_key.c index 71d67e6e..70458da1 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_derive_key.c +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_derive_key.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto syscall deriver key - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_syscall_common.h" #include diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_derive_key.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_derive_key.h index 399ddb5b..b1d3c046 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_derive_key.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_derive_key.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto syscall derive key - * Create: 2022-01-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_SYSCALL_DERIVE_KEY_H #define CRYPTO_SYSCALL_DERIVE_KEY_H diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ec.c b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ec.c index 078e04a3..c4521cd0 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ec.c +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ec.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto ec syscall - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_syscall_ec.h" #include diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ec.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ec.h index cf229d16..50339ed0 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ec.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_ec.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: Crypto API at driver adaptor. - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_SYSCALL_EC_H #define CRYPTO_SYSCALL_EC_H diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hash.c b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hash.c index da992b49..0a5c6903 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hash.c +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hash.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto hash syscall - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_syscall_hash.h" #include diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hash.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hash.h index b887b59d..27eb32ce 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hash.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hash.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: Crypto API at driver adaptor. - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_SYSCALL_HASH_H #define CRYPTO_SYSCALL_HASH_H diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hmac.c b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hmac.c index 8032079a..65bd7da4 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hmac.c +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hmac.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto hmac syscall - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_syscall_hmac.h" #include diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hmac.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hmac.h index 52bb14d7..c9959701 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hmac.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_hmac.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: Crypto API at driver adaptor. - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_SYSCALL_HMAC_H #define CRYPTO_SYSCALL_HMAC_H diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_oemkey.c b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_oemkey.c index d7a2fc8b..79617d23 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_oemkey.c +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_oemkey.c @@ -1,65 +1,71 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto oemkey syscall - * Create: 2022-01-13 - */ -#include "crypto_syscall_oemkey.h" -#include -#include "tee_driver_module.h" -#include -#include "drv_param_ops.h" - -static int32_t get_oemkey_ops(const struct crypto_drv_ops_t *ops, struct memref_t *buf_arg) -{ - if (ops->get_oemkey == NULL) { - hm_error("hardware engine get oemkey fun is null\n"); - return CRYPTO_NOT_SUPPORTED; - } - - void *buffer = NULL; - size_t size; - - buffer = (void *)(uintptr_t)buf_arg->buffer; - size = buf_arg->size; - - int32_t ret = do_power_on(ops); - if (ret != CRYPTO_SUCCESS) - return ret; - - ret = ops->get_oemkey(buffer, size); - if (ret != CRYPTO_SUCCESS) - hm_error("get oemkey failed\n"); - - do_power_off(ops); - - return ret; -} - -int32_t get_oemkey_call(const struct drv_data *drv, unsigned long args, - uint32_t args_len, const struct crypto_drv_ops_t *ops) -{ - uint8_t *share_buf = NULL; - struct memref_t *buf_arg = NULL; - - if (check_hal_params_is_invalid(drv, args, args_len, ops)) - return CRYPTO_BAD_PARAMETERS; - - struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args; - - int32_t ret = prepare_hard_engine_params(drv->taskid, &share_buf, &buf_arg, ioctl_args); - if (ret != CRYPTO_SUCCESS) - return ret; - - ret = get_oemkey_ops(ops, buf_arg); - if (ret != CRYPTO_SUCCESS) - goto end; - - ret = copy_to_client((uintptr_t)share_buf, ioctl_args->buf_len, ioctl_args->buf, ioctl_args->buf_len); - if (ret != CRYPTO_SUCCESS) - hm_error("copy to client failed. ret = %d\n", ret); - -end: - driver_free_share_mem_and_buf_arg(share_buf, ioctl_args->buf_len, buf_arg, - ioctl_args->total_nums * sizeof(struct memref_t)); - return ret; -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include "crypto_syscall_oemkey.h" +#include +#include "tee_driver_module.h" +#include +#include "drv_param_ops.h" + +static int32_t get_oemkey_ops(const struct crypto_drv_ops_t *ops, struct memref_t *buf_arg) +{ + if (ops->get_oemkey == NULL) { + hm_error("hardware engine get oemkey fun is null\n"); + return CRYPTO_NOT_SUPPORTED; + } + + void *buffer = NULL; + size_t size; + + buffer = (void *)(uintptr_t)buf_arg->buffer; + size = buf_arg->size; + + int32_t ret = do_power_on(ops); + if (ret != CRYPTO_SUCCESS) + return ret; + + ret = ops->get_oemkey(buffer, size); + if (ret != CRYPTO_SUCCESS) + hm_error("get oemkey failed\n"); + + do_power_off(ops); + + return ret; +} + +int32_t get_oemkey_call(const struct drv_data *drv, unsigned long args, + uint32_t args_len, const struct crypto_drv_ops_t *ops) +{ + uint8_t *share_buf = NULL; + struct memref_t *buf_arg = NULL; + + if (check_hal_params_is_invalid(drv, args, args_len, ops)) + return CRYPTO_BAD_PARAMETERS; + + struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args; + + int32_t ret = prepare_hard_engine_params(drv->taskid, &share_buf, &buf_arg, ioctl_args); + if (ret != CRYPTO_SUCCESS) + return ret; + + ret = get_oemkey_ops(ops, buf_arg); + if (ret != CRYPTO_SUCCESS) + goto end; + + ret = copy_to_client((uintptr_t)share_buf, ioctl_args->buf_len, ioctl_args->buf, ioctl_args->buf_len); + if (ret != CRYPTO_SUCCESS) + hm_error("copy to client failed. ret = %d\n", ret); + +end: + driver_free_share_mem_and_buf_arg(share_buf, ioctl_args->buf_len, buf_arg, + ioctl_args->total_nums * sizeof(struct memref_t)); + return ret; +} diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_oemkey.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_oemkey.h index 1eae4dc1..3b26dbd4 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_oemkey.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_oemkey.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: Crypto API at driver adaptor. - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_SYSCALL_OEMKEY_H #define CRYPTO_SYSCALL_OEMKEY_H diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_pm.c b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_pm.c index abc42916..121a71e7 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_pm.c +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_pm.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto_mgr suspend and resume functions - * Create: 2022-05 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_syscall_pm.h" diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_pm.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_pm.h index 952e2691..6c935f88 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_pm.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_pm.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: crypto_mgr suspend and resume functions - * Create: 2022-05 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_SYSCALL_PM_H #define CRYPTO_SYSCALL_PM_H diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_random.c b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_random.c index 9c075aaf..6885ee0c 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_random.c +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_random.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto random syscall - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_syscall_random.h" #include diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_random.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_random.h index 94425679..7e28c635 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_random.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_random.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: Crypto API at driver adaptor. - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_SYSCALL_RANDOM_H #define CRYPTO_SYSCALL_RANDOM_H diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_rsa.c b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_rsa.c index 24c278e4..f8a34c45 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_rsa.c +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_rsa.c @@ -1,432 +1,438 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implement crypto rsa syscall - * Create: 2022-01-13 - */ -#include "crypto_syscall_rsa.h" -#include -#include "tee_driver_module.h" -#include -#include "drv_param_ops.h" - -static int32_t check_rsa_private_key_len(const struct rsa_priv_key_t *rsa_private_key) -{ - if (rsa_private_key == NULL) { - hm_error("rsa private key is NULL\n"); - return CRYPTO_BAD_PARAMETERS; - } - - bool check = (rsa_private_key->e_len > RSA_EXPONENT_LEN || - rsa_private_key->n_len > RSA_MAX_KEY_SIZE || rsa_private_key->d_len > RSA_MAX_KEY_SIZE || - rsa_private_key->p_len > RSA_MAX_KEY_SIZE_CRT || rsa_private_key->q_len > RSA_MAX_KEY_SIZE_CRT || - rsa_private_key->dp_len > RSA_MAX_KEY_SIZE_CRT || rsa_private_key->dq_len > RSA_MAX_KEY_SIZE_CRT || - rsa_private_key->qinv_len > RSA_MAX_KEY_SIZE_CRT); - if (check) { - hm_error("rsa private key size is invalid\n"); - return CRYPTO_BAD_PARAMETERS; - } - return CRYPTO_SUCCESS; -} - -static int32_t check_rsa_pub_key_len(const struct rsa_pub_key_t *rsa_pub_key) -{ - if (rsa_pub_key == NULL) { - hm_error("rsa pub key is NULL\n"); - return CRYPTO_BAD_PARAMETERS; - } - - if (rsa_pub_key->e_len > RSA_EXPONENT_LEN || rsa_pub_key->n_len > RSA_MAX_KEY_SIZE) { - hm_error("rsa pub key size is invalid\n"); - return CRYPTO_BAD_PARAMETERS; - } - return CRYPTO_SUCCESS; -} - -static int32_t rsa_generate_keypair_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, - uint32_t key_size, bool crt_mode) -{ - if (ops->rsa_generate_keypair == NULL) { - hm_error("hardware engine rsa generate keypair fun is null\n"); - return CRYPTO_NOT_SUPPORTED; - } - - int32_t ret = do_power_on(ops); - if (ret != CRYPTO_SUCCESS) - return ret; - - struct rsa_priv_key_t *key_pair = (struct rsa_priv_key_t *)(uintptr_t)crypto_arg->buffer; - ret = check_rsa_private_key_len(key_pair); - if (ret != CRYPTO_SUCCESS) - return ret; - - crypto_arg++; - struct memref_t e_value; - e_value.buffer = crypto_arg->buffer; - e_value.size = crypto_arg->size; - - ret = ops->rsa_generate_keypair(key_size, &e_value, crt_mode, key_pair); - do_power_off(ops); - if (ret != CRYPTO_SUCCESS) - hm_error("hardware engine do rsa generate keypair failed. ret = %d\n", ret); - - return ret; -} - -int32_t rsa_generate_keypair_call(const struct drv_data *drv, unsigned long args, - uint32_t args_len, const struct crypto_drv_ops_t *ops) -{ - uint8_t *rsa_gen_share_buf = NULL; - struct memref_t *buf_arg = NULL; - - if (check_hal_params_is_invalid(drv, args, args_len, ops)) - return CRYPTO_BAD_PARAMETERS; - - struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args; - - int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_gen_share_buf, &buf_arg, ioctl_args); - if (ret != CRYPTO_SUCCESS) - return ret; - - ret = rsa_generate_keypair_ops(ops, buf_arg, ioctl_args->arg1, (bool)ioctl_args->arg2); - if (ret != CRYPTO_SUCCESS) - goto end; - - ret = copy_to_client((uintptr_t)rsa_gen_share_buf, ioctl_args->buf_len, ioctl_args->buf, - ioctl_args->buf_len); - if (ret != CRYPTO_SUCCESS) - hm_error("copy to client failed. ret = %d\n", ret); -end: - driver_free_share_mem_and_buf_arg(rsa_gen_share_buf, ioctl_args->buf_len, buf_arg, - ioctl_args->total_nums * sizeof(struct memref_t)); - return ret; -} - -static int32_t rsa_encrypt_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type) -{ - if (ops->rsa_encrypt == NULL) { - hm_error("hardware engine rsa encrypt fun is null\n"); - return CRYPTO_NOT_SUPPORTED; - } - - int32_t ret = do_power_on(ops); - if (ret != CRYPTO_SUCCESS) - return ret; - - struct memref_t *rsa_encrypt_arg = crypto_arg; - struct memref_t data_out; - data_out.buffer = rsa_encrypt_arg->buffer; - data_out.size = rsa_encrypt_arg->size; - - rsa_encrypt_arg++; - struct memref_t data_in; - data_in.buffer = rsa_encrypt_arg->buffer; - data_in.size = rsa_encrypt_arg->size; - - rsa_encrypt_arg++; - struct rsa_pub_key_t *rsa_pub_key = (struct rsa_pub_key_t *)(uintptr_t)rsa_encrypt_arg->buffer; - ret = check_rsa_pub_key_len(rsa_pub_key); - if (ret != CRYPTO_SUCCESS) - return ret; - - rsa_encrypt_arg++; - struct asymmetric_params_t rsa_params; - ret = restore_attrs(&rsa_params, rsa_encrypt_arg); - if (ret != CRYPTO_SUCCESS) - return ret; - - ret = ops->rsa_encrypt(alg_type, rsa_pub_key, &rsa_params, &data_in, &data_out); - do_power_off(ops); - if (ret != CRYPTO_SUCCESS) { - hm_error("hardware engine do rsa encrypt failed. ret = %d\n", ret); - goto end; - } - - if (data_out.size > crypto_arg->size) { - hm_error("new data out size > origin size. origin size = %u, new size = %u\n", crypto_arg->size, data_out.size); - ret = CRYPTO_ERROR_OUT_OF_MEMORY; - goto end; - } - crypto_arg->size = data_out.size; - -end: - if (rsa_params.attribute != 0) - free((void *)(uintptr_t)rsa_params.attribute); - - return ret; -} - -int32_t rsa_encrypt_call(const struct drv_data *drv, unsigned long args, - uint32_t args_len, const struct crypto_drv_ops_t *ops) -{ - uint8_t *rsa_encrypt_share_buf = NULL; - struct memref_t *buf_arg = NULL; - - if (check_hal_params_is_invalid(drv, args, args_len, ops)) - return CRYPTO_BAD_PARAMETERS; - - struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args; - - int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_encrypt_share_buf, &buf_arg, ioctl_args); - if (ret != CRYPTO_SUCCESS) - return ret; - - ret = rsa_encrypt_ops(ops, buf_arg, ioctl_args->arg1); - if (ret != CRYPTO_SUCCESS) - goto end; - - ret = fill_share_mem(rsa_encrypt_share_buf, buf_arg, ioctl_args->total_nums); - if (ret != CRYPTO_SUCCESS) - goto end; - - ret = copy_to_client((uintptr_t)rsa_encrypt_share_buf, ioctl_args->buf_len, ioctl_args->buf, ioctl_args->buf_len); - if (ret != CRYPTO_SUCCESS) - hm_error("copy to client failed. ret = %d\n", ret); - -end: - driver_free_share_mem_and_buf_arg(rsa_encrypt_share_buf, ioctl_args->buf_len, buf_arg, - ioctl_args->total_nums * sizeof(struct memref_t)); - return ret; -} - -static int32_t rsa_decrypt_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type) -{ - if (ops->rsa_decrypt == NULL) { - hm_error("hardware engine rsa decrypt fun is null\n"); - return CRYPTO_NOT_SUPPORTED; - } - - int32_t ret = do_power_on(ops); - if (ret != CRYPTO_SUCCESS) - return ret; - - struct memref_t *rsa_decrypt_arg = crypto_arg; - struct memref_t data_out; - data_out.buffer = rsa_decrypt_arg->buffer; - data_out.size = rsa_decrypt_arg->size; - - rsa_decrypt_arg++; - struct memref_t data_in; - data_in.buffer = rsa_decrypt_arg->buffer; - data_in.size = rsa_decrypt_arg->size; - - rsa_decrypt_arg++; - struct rsa_priv_key_t *private_key = (struct rsa_priv_key_t *)(uintptr_t)rsa_decrypt_arg->buffer; - ret = check_rsa_private_key_len(private_key); - if (ret != CRYPTO_SUCCESS) - return ret; - - rsa_decrypt_arg++; - struct asymmetric_params_t rsa_params; - ret = restore_attrs(&rsa_params, rsa_decrypt_arg); - if (ret != CRYPTO_SUCCESS) - return ret; - - ret = ops->rsa_decrypt(alg_type, private_key, &rsa_params, &data_in, &data_out); - do_power_off(ops); - if (ret != CRYPTO_SUCCESS) { - hm_error("hardware engine do rsa decrypt failed. ret = %d\n", ret); - goto end; - } - - if (data_out.size > crypto_arg->size) { - hm_error("new data out size > origin size. origin size = %u, new size = %u\n", crypto_arg->size, data_out.size); - ret = CRYPTO_ERROR_OUT_OF_MEMORY; - goto end; - } - crypto_arg->size = data_out.size; - -end: - if (rsa_params.attribute != 0) - free((void *)(uintptr_t)rsa_params.attribute); - - return ret; -} - -int32_t rsa_decrypt_call(const struct drv_data *drv, unsigned long args, - uint32_t args_len, const struct crypto_drv_ops_t *ops) -{ - uint8_t *rsa_decrypt_share_buf = NULL; - struct memref_t *buf_arg = NULL; - - if (check_hal_params_is_invalid(drv, args, args_len, ops)) - return CRYPTO_BAD_PARAMETERS; - - struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args; - - int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_decrypt_share_buf, &buf_arg, ioctl_args); - if (ret != CRYPTO_SUCCESS) - return ret; - - ret = rsa_decrypt_ops(ops, buf_arg, ioctl_args->arg1); - if (ret != CRYPTO_SUCCESS) - goto end; - - ret = fill_share_mem(rsa_decrypt_share_buf, buf_arg, ioctl_args->total_nums); - if (ret != CRYPTO_SUCCESS) - goto end; - - ret = copy_to_client((uintptr_t)rsa_decrypt_share_buf, ioctl_args->buf_len, ioctl_args->buf, ioctl_args->buf_len); - if (ret != CRYPTO_SUCCESS) - hm_error("copy to client failed. ret = %d\n", ret); - -end: - driver_free_share_mem_and_buf_arg(rsa_decrypt_share_buf, ioctl_args->buf_len, buf_arg, - ioctl_args->total_nums * sizeof(struct memref_t)); - return ret; -} - -static int32_t rsa_sign_digest_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type) -{ - if (ops->rsa_sign_digest == NULL) { - hm_error("hardware engine rsa sign digest fun is null\n"); - return CRYPTO_NOT_SUPPORTED; - } - - int32_t ret = do_power_on(ops); - if (ret != CRYPTO_SUCCESS) - return ret; - - struct memref_t *rsa_sign_digest_arg = crypto_arg; - struct memref_t signature; - signature.buffer = rsa_sign_digest_arg->buffer; - signature.size = rsa_sign_digest_arg->size; - - rsa_sign_digest_arg++; - struct memref_t digest; - digest.buffer = rsa_sign_digest_arg->buffer; - digest.size = rsa_sign_digest_arg->size; - - rsa_sign_digest_arg++; - struct rsa_priv_key_t *private_key = (struct rsa_priv_key_t *)(uintptr_t)rsa_sign_digest_arg->buffer; - ret = check_rsa_private_key_len(private_key); - if (ret != CRYPTO_SUCCESS) - return ret; - - rsa_sign_digest_arg++; - struct asymmetric_params_t rsa_params; - ret = restore_attrs(&rsa_params, rsa_sign_digest_arg); - if (ret != CRYPTO_SUCCESS) - return ret; - - ret = ops->rsa_sign_digest(alg_type, private_key, &rsa_params, &digest, &signature); - do_power_off(ops); - if (ret != CRYPTO_SUCCESS) { - hm_error("hardware engine do rsa sign digest failed. ret = %d\n", ret); - goto end; - } - - if (signature.size > crypto_arg->size) { - hm_error("new signature > origin size. origin size = %u, new size = %u\n", crypto_arg->size, signature.size); - ret = CRYPTO_ERROR_OUT_OF_MEMORY; - goto end; - } - crypto_arg->size = signature.size; - -end: - if (rsa_params.attribute != 0) - free((void *)(uintptr_t)rsa_params.attribute); - - return ret; -} - -int32_t rsa_sign_digest_call(const struct drv_data *drv, unsigned long args, - uint32_t args_len, const struct crypto_drv_ops_t *ops) -{ - uint8_t *rsa_sign_share_buf = NULL; - struct memref_t *buf_arg = NULL; - - if (check_hal_params_is_invalid(drv, args, args_len, ops)) - return CRYPTO_BAD_PARAMETERS; - - struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args; - - int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_sign_share_buf, &buf_arg, ioctl_args); - if (ret != CRYPTO_SUCCESS) - return ret; - - ret = rsa_sign_digest_ops(ops, buf_arg, ioctl_args->arg1); - if (ret != CRYPTO_SUCCESS) - goto end; - - ret = fill_share_mem(rsa_sign_share_buf, buf_arg, ioctl_args->total_nums); - if (ret != CRYPTO_SUCCESS) - goto end; - - ret = copy_to_client((uintptr_t)rsa_sign_share_buf, ioctl_args->buf_len, ioctl_args->buf, - ioctl_args->buf_len); - if (ret != CRYPTO_SUCCESS) - hm_error("copy to client failed. ret = %d\n", ret); - -end: - driver_free_share_mem_and_buf_arg(rsa_sign_share_buf, ioctl_args->buf_len, buf_arg, - ioctl_args->total_nums * sizeof(struct memref_t)); - return ret; -} - -static int32_t rsa_verify_digest_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type) -{ - if (ops->rsa_verify_digest == NULL) { - hm_error("hardware engine rsa verify digest fun is null\n"); - return CRYPTO_NOT_SUPPORTED; - } - - int32_t ret = do_power_on(ops); - if (ret != CRYPTO_SUCCESS) - return ret; - - struct memref_t *rsa_verify_digest_arg = crypto_arg; - struct memref_t signature; - signature.buffer = rsa_verify_digest_arg->buffer; - signature.size = rsa_verify_digest_arg->size; - - rsa_verify_digest_arg++; - struct memref_t digest; - digest.buffer = rsa_verify_digest_arg->buffer; - digest.size = rsa_verify_digest_arg->size; - - rsa_verify_digest_arg++; - struct rsa_pub_key_t *rsa_pub_key = (struct rsa_pub_key_t *)(uintptr_t)rsa_verify_digest_arg->buffer; - ret = check_rsa_pub_key_len(rsa_pub_key); - if (ret != CRYPTO_SUCCESS) - return ret; - - rsa_verify_digest_arg++; - struct asymmetric_params_t rsa_params; - ret = restore_attrs(&rsa_params, rsa_verify_digest_arg); - if (ret != CRYPTO_SUCCESS) - return ret; - - ret = ops->rsa_verify_digest(alg_type, rsa_pub_key, &rsa_params, &digest, &signature); - do_power_off(ops); - if (ret != CRYPTO_SUCCESS) - hm_error("hardware engine do rsa verify digest failed. ret = %d\n", ret); - - if (rsa_params.attribute != 0) - free((void *)(uintptr_t)rsa_params.attribute); - - return ret; -} - -int32_t rsa_verify_digest_call(const struct drv_data *drv, unsigned long args, - uint32_t args_len, const struct crypto_drv_ops_t *ops) -{ - uint8_t *rsa_verify_share_buf = NULL; - struct memref_t *buf_arg = NULL; - - if (check_hal_params_is_invalid(drv, args, args_len, ops)) - return CRYPTO_BAD_PARAMETERS; - - struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args; - - int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_verify_share_buf, &buf_arg, ioctl_args); - if (ret != CRYPTO_SUCCESS) - return ret; - - ret = rsa_verify_digest_ops(ops, buf_arg, ioctl_args->arg1); - if (ret != CRYPTO_SUCCESS) - hm_error("rsa verify digest ops. ret = %d\n", ret); - - driver_free_share_mem_and_buf_arg(rsa_verify_share_buf, ioctl_args->buf_len, buf_arg, - ioctl_args->total_nums * sizeof(struct memref_t)); - return ret; -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include "crypto_syscall_rsa.h" +#include +#include "tee_driver_module.h" +#include +#include "drv_param_ops.h" + +static int32_t check_rsa_private_key_len(const struct rsa_priv_key_t *rsa_private_key) +{ + if (rsa_private_key == NULL) { + hm_error("rsa private key is NULL\n"); + return CRYPTO_BAD_PARAMETERS; + } + + bool check = (rsa_private_key->e_len > RSA_EXPONENT_LEN || + rsa_private_key->n_len > RSA_MAX_KEY_SIZE || rsa_private_key->d_len > RSA_MAX_KEY_SIZE || + rsa_private_key->p_len > RSA_MAX_KEY_SIZE_CRT || rsa_private_key->q_len > RSA_MAX_KEY_SIZE_CRT || + rsa_private_key->dp_len > RSA_MAX_KEY_SIZE_CRT || rsa_private_key->dq_len > RSA_MAX_KEY_SIZE_CRT || + rsa_private_key->qinv_len > RSA_MAX_KEY_SIZE_CRT); + if (check) { + hm_error("rsa private key size is invalid\n"); + return CRYPTO_BAD_PARAMETERS; + } + return CRYPTO_SUCCESS; +} + +static int32_t check_rsa_pub_key_len(const struct rsa_pub_key_t *rsa_pub_key) +{ + if (rsa_pub_key == NULL) { + hm_error("rsa pub key is NULL\n"); + return CRYPTO_BAD_PARAMETERS; + } + + if (rsa_pub_key->e_len > RSA_EXPONENT_LEN || rsa_pub_key->n_len > RSA_MAX_KEY_SIZE) { + hm_error("rsa pub key size is invalid\n"); + return CRYPTO_BAD_PARAMETERS; + } + return CRYPTO_SUCCESS; +} + +static int32_t rsa_generate_keypair_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, + uint32_t key_size, bool crt_mode) +{ + if (ops->rsa_generate_keypair == NULL) { + hm_error("hardware engine rsa generate keypair fun is null\n"); + return CRYPTO_NOT_SUPPORTED; + } + + int32_t ret = do_power_on(ops); + if (ret != CRYPTO_SUCCESS) + return ret; + + struct rsa_priv_key_t *key_pair = (struct rsa_priv_key_t *)(uintptr_t)crypto_arg->buffer; + ret = check_rsa_private_key_len(key_pair); + if (ret != CRYPTO_SUCCESS) + return ret; + + crypto_arg++; + struct memref_t e_value; + e_value.buffer = crypto_arg->buffer; + e_value.size = crypto_arg->size; + + ret = ops->rsa_generate_keypair(key_size, &e_value, crt_mode, key_pair); + do_power_off(ops); + if (ret != CRYPTO_SUCCESS) + hm_error("hardware engine do rsa generate keypair failed. ret = %d\n", ret); + + return ret; +} + +int32_t rsa_generate_keypair_call(const struct drv_data *drv, unsigned long args, + uint32_t args_len, const struct crypto_drv_ops_t *ops) +{ + uint8_t *rsa_gen_share_buf = NULL; + struct memref_t *buf_arg = NULL; + + if (check_hal_params_is_invalid(drv, args, args_len, ops)) + return CRYPTO_BAD_PARAMETERS; + + struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args; + + int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_gen_share_buf, &buf_arg, ioctl_args); + if (ret != CRYPTO_SUCCESS) + return ret; + + ret = rsa_generate_keypair_ops(ops, buf_arg, ioctl_args->arg1, (bool)ioctl_args->arg2); + if (ret != CRYPTO_SUCCESS) + goto end; + + ret = copy_to_client((uintptr_t)rsa_gen_share_buf, ioctl_args->buf_len, ioctl_args->buf, + ioctl_args->buf_len); + if (ret != CRYPTO_SUCCESS) + hm_error("copy to client failed. ret = %d\n", ret); +end: + driver_free_share_mem_and_buf_arg(rsa_gen_share_buf, ioctl_args->buf_len, buf_arg, + ioctl_args->total_nums * sizeof(struct memref_t)); + return ret; +} + +static int32_t rsa_encrypt_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type) +{ + if (ops->rsa_encrypt == NULL) { + hm_error("hardware engine rsa encrypt fun is null\n"); + return CRYPTO_NOT_SUPPORTED; + } + + int32_t ret = do_power_on(ops); + if (ret != CRYPTO_SUCCESS) + return ret; + + struct memref_t *rsa_encrypt_arg = crypto_arg; + struct memref_t data_out; + data_out.buffer = rsa_encrypt_arg->buffer; + data_out.size = rsa_encrypt_arg->size; + + rsa_encrypt_arg++; + struct memref_t data_in; + data_in.buffer = rsa_encrypt_arg->buffer; + data_in.size = rsa_encrypt_arg->size; + + rsa_encrypt_arg++; + struct rsa_pub_key_t *rsa_pub_key = (struct rsa_pub_key_t *)(uintptr_t)rsa_encrypt_arg->buffer; + ret = check_rsa_pub_key_len(rsa_pub_key); + if (ret != CRYPTO_SUCCESS) + return ret; + + rsa_encrypt_arg++; + struct asymmetric_params_t rsa_params; + ret = restore_attrs(&rsa_params, rsa_encrypt_arg); + if (ret != CRYPTO_SUCCESS) + return ret; + + ret = ops->rsa_encrypt(alg_type, rsa_pub_key, &rsa_params, &data_in, &data_out); + do_power_off(ops); + if (ret != CRYPTO_SUCCESS) { + hm_error("hardware engine do rsa encrypt failed. ret = %d\n", ret); + goto end; + } + + if (data_out.size > crypto_arg->size) { + hm_error("new data out size > origin size. origin size = %u, new size = %u\n", crypto_arg->size, data_out.size); + ret = CRYPTO_ERROR_OUT_OF_MEMORY; + goto end; + } + crypto_arg->size = data_out.size; + +end: + if (rsa_params.attribute != 0) + free((void *)(uintptr_t)rsa_params.attribute); + + return ret; +} + +int32_t rsa_encrypt_call(const struct drv_data *drv, unsigned long args, + uint32_t args_len, const struct crypto_drv_ops_t *ops) +{ + uint8_t *rsa_encrypt_share_buf = NULL; + struct memref_t *buf_arg = NULL; + + if (check_hal_params_is_invalid(drv, args, args_len, ops)) + return CRYPTO_BAD_PARAMETERS; + + struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args; + + int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_encrypt_share_buf, &buf_arg, ioctl_args); + if (ret != CRYPTO_SUCCESS) + return ret; + + ret = rsa_encrypt_ops(ops, buf_arg, ioctl_args->arg1); + if (ret != CRYPTO_SUCCESS) + goto end; + + ret = fill_share_mem(rsa_encrypt_share_buf, buf_arg, ioctl_args->total_nums); + if (ret != CRYPTO_SUCCESS) + goto end; + + ret = copy_to_client((uintptr_t)rsa_encrypt_share_buf, ioctl_args->buf_len, ioctl_args->buf, ioctl_args->buf_len); + if (ret != CRYPTO_SUCCESS) + hm_error("copy to client failed. ret = %d\n", ret); + +end: + driver_free_share_mem_and_buf_arg(rsa_encrypt_share_buf, ioctl_args->buf_len, buf_arg, + ioctl_args->total_nums * sizeof(struct memref_t)); + return ret; +} + +static int32_t rsa_decrypt_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type) +{ + if (ops->rsa_decrypt == NULL) { + hm_error("hardware engine rsa decrypt fun is null\n"); + return CRYPTO_NOT_SUPPORTED; + } + + int32_t ret = do_power_on(ops); + if (ret != CRYPTO_SUCCESS) + return ret; + + struct memref_t *rsa_decrypt_arg = crypto_arg; + struct memref_t data_out; + data_out.buffer = rsa_decrypt_arg->buffer; + data_out.size = rsa_decrypt_arg->size; + + rsa_decrypt_arg++; + struct memref_t data_in; + data_in.buffer = rsa_decrypt_arg->buffer; + data_in.size = rsa_decrypt_arg->size; + + rsa_decrypt_arg++; + struct rsa_priv_key_t *private_key = (struct rsa_priv_key_t *)(uintptr_t)rsa_decrypt_arg->buffer; + ret = check_rsa_private_key_len(private_key); + if (ret != CRYPTO_SUCCESS) + return ret; + + rsa_decrypt_arg++; + struct asymmetric_params_t rsa_params; + ret = restore_attrs(&rsa_params, rsa_decrypt_arg); + if (ret != CRYPTO_SUCCESS) + return ret; + + ret = ops->rsa_decrypt(alg_type, private_key, &rsa_params, &data_in, &data_out); + do_power_off(ops); + if (ret != CRYPTO_SUCCESS) { + hm_error("hardware engine do rsa decrypt failed. ret = %d\n", ret); + goto end; + } + + if (data_out.size > crypto_arg->size) { + hm_error("new data out size > origin size. origin size = %u, new size = %u\n", crypto_arg->size, data_out.size); + ret = CRYPTO_ERROR_OUT_OF_MEMORY; + goto end; + } + crypto_arg->size = data_out.size; + +end: + if (rsa_params.attribute != 0) + free((void *)(uintptr_t)rsa_params.attribute); + + return ret; +} + +int32_t rsa_decrypt_call(const struct drv_data *drv, unsigned long args, + uint32_t args_len, const struct crypto_drv_ops_t *ops) +{ + uint8_t *rsa_decrypt_share_buf = NULL; + struct memref_t *buf_arg = NULL; + + if (check_hal_params_is_invalid(drv, args, args_len, ops)) + return CRYPTO_BAD_PARAMETERS; + + struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args; + + int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_decrypt_share_buf, &buf_arg, ioctl_args); + if (ret != CRYPTO_SUCCESS) + return ret; + + ret = rsa_decrypt_ops(ops, buf_arg, ioctl_args->arg1); + if (ret != CRYPTO_SUCCESS) + goto end; + + ret = fill_share_mem(rsa_decrypt_share_buf, buf_arg, ioctl_args->total_nums); + if (ret != CRYPTO_SUCCESS) + goto end; + + ret = copy_to_client((uintptr_t)rsa_decrypt_share_buf, ioctl_args->buf_len, ioctl_args->buf, ioctl_args->buf_len); + if (ret != CRYPTO_SUCCESS) + hm_error("copy to client failed. ret = %d\n", ret); + +end: + driver_free_share_mem_and_buf_arg(rsa_decrypt_share_buf, ioctl_args->buf_len, buf_arg, + ioctl_args->total_nums * sizeof(struct memref_t)); + return ret; +} + +static int32_t rsa_sign_digest_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type) +{ + if (ops->rsa_sign_digest == NULL) { + hm_error("hardware engine rsa sign digest fun is null\n"); + return CRYPTO_NOT_SUPPORTED; + } + + int32_t ret = do_power_on(ops); + if (ret != CRYPTO_SUCCESS) + return ret; + + struct memref_t *rsa_sign_digest_arg = crypto_arg; + struct memref_t signature; + signature.buffer = rsa_sign_digest_arg->buffer; + signature.size = rsa_sign_digest_arg->size; + + rsa_sign_digest_arg++; + struct memref_t digest; + digest.buffer = rsa_sign_digest_arg->buffer; + digest.size = rsa_sign_digest_arg->size; + + rsa_sign_digest_arg++; + struct rsa_priv_key_t *private_key = (struct rsa_priv_key_t *)(uintptr_t)rsa_sign_digest_arg->buffer; + ret = check_rsa_private_key_len(private_key); + if (ret != CRYPTO_SUCCESS) + return ret; + + rsa_sign_digest_arg++; + struct asymmetric_params_t rsa_params; + ret = restore_attrs(&rsa_params, rsa_sign_digest_arg); + if (ret != CRYPTO_SUCCESS) + return ret; + + ret = ops->rsa_sign_digest(alg_type, private_key, &rsa_params, &digest, &signature); + do_power_off(ops); + if (ret != CRYPTO_SUCCESS) { + hm_error("hardware engine do rsa sign digest failed. ret = %d\n", ret); + goto end; + } + + if (signature.size > crypto_arg->size) { + hm_error("new signature > origin size. origin size = %u, new size = %u\n", crypto_arg->size, signature.size); + ret = CRYPTO_ERROR_OUT_OF_MEMORY; + goto end; + } + crypto_arg->size = signature.size; + +end: + if (rsa_params.attribute != 0) + free((void *)(uintptr_t)rsa_params.attribute); + + return ret; +} + +int32_t rsa_sign_digest_call(const struct drv_data *drv, unsigned long args, + uint32_t args_len, const struct crypto_drv_ops_t *ops) +{ + uint8_t *rsa_sign_share_buf = NULL; + struct memref_t *buf_arg = NULL; + + if (check_hal_params_is_invalid(drv, args, args_len, ops)) + return CRYPTO_BAD_PARAMETERS; + + struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args; + + int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_sign_share_buf, &buf_arg, ioctl_args); + if (ret != CRYPTO_SUCCESS) + return ret; + + ret = rsa_sign_digest_ops(ops, buf_arg, ioctl_args->arg1); + if (ret != CRYPTO_SUCCESS) + goto end; + + ret = fill_share_mem(rsa_sign_share_buf, buf_arg, ioctl_args->total_nums); + if (ret != CRYPTO_SUCCESS) + goto end; + + ret = copy_to_client((uintptr_t)rsa_sign_share_buf, ioctl_args->buf_len, ioctl_args->buf, + ioctl_args->buf_len); + if (ret != CRYPTO_SUCCESS) + hm_error("copy to client failed. ret = %d\n", ret); + +end: + driver_free_share_mem_and_buf_arg(rsa_sign_share_buf, ioctl_args->buf_len, buf_arg, + ioctl_args->total_nums * sizeof(struct memref_t)); + return ret; +} + +static int32_t rsa_verify_digest_ops(const struct crypto_drv_ops_t *ops, struct memref_t *crypto_arg, uint32_t alg_type) +{ + if (ops->rsa_verify_digest == NULL) { + hm_error("hardware engine rsa verify digest fun is null\n"); + return CRYPTO_NOT_SUPPORTED; + } + + int32_t ret = do_power_on(ops); + if (ret != CRYPTO_SUCCESS) + return ret; + + struct memref_t *rsa_verify_digest_arg = crypto_arg; + struct memref_t signature; + signature.buffer = rsa_verify_digest_arg->buffer; + signature.size = rsa_verify_digest_arg->size; + + rsa_verify_digest_arg++; + struct memref_t digest; + digest.buffer = rsa_verify_digest_arg->buffer; + digest.size = rsa_verify_digest_arg->size; + + rsa_verify_digest_arg++; + struct rsa_pub_key_t *rsa_pub_key = (struct rsa_pub_key_t *)(uintptr_t)rsa_verify_digest_arg->buffer; + ret = check_rsa_pub_key_len(rsa_pub_key); + if (ret != CRYPTO_SUCCESS) + return ret; + + rsa_verify_digest_arg++; + struct asymmetric_params_t rsa_params; + ret = restore_attrs(&rsa_params, rsa_verify_digest_arg); + if (ret != CRYPTO_SUCCESS) + return ret; + + ret = ops->rsa_verify_digest(alg_type, rsa_pub_key, &rsa_params, &digest, &signature); + do_power_off(ops); + if (ret != CRYPTO_SUCCESS) + hm_error("hardware engine do rsa verify digest failed. ret = %d\n", ret); + + if (rsa_params.attribute != 0) + free((void *)(uintptr_t)rsa_params.attribute); + + return ret; +} + +int32_t rsa_verify_digest_call(const struct drv_data *drv, unsigned long args, + uint32_t args_len, const struct crypto_drv_ops_t *ops) +{ + uint8_t *rsa_verify_share_buf = NULL; + struct memref_t *buf_arg = NULL; + + if (check_hal_params_is_invalid(drv, args, args_len, ops)) + return CRYPTO_BAD_PARAMETERS; + + struct crypto_ioctl *ioctl_args = (struct crypto_ioctl *)(uintptr_t)args; + + int32_t ret = prepare_hard_engine_params(drv->taskid, &rsa_verify_share_buf, &buf_arg, ioctl_args); + if (ret != CRYPTO_SUCCESS) + return ret; + + ret = rsa_verify_digest_ops(ops, buf_arg, ioctl_args->arg1); + if (ret != CRYPTO_SUCCESS) + hm_error("rsa verify digest ops. ret = %d\n", ret); + + driver_free_share_mem_and_buf_arg(rsa_verify_share_buf, ioctl_args->buf_len, buf_arg, + ioctl_args->total_nums * sizeof(struct memref_t)); + return ret; +} diff --git a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_rsa.h b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_rsa.h index 853b4a60..f035c036 100644 --- a/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_rsa.h +++ b/drivers/crypto_mgr/src/crypto_ioctl/crypto_syscall_rsa.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: Crypto API at driver adaptor. - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_SYSCALL_RSA_H #define CRYPTO_SYSCALL_RSA_H diff --git a/drivers/crypto_mgr/src/crypto_mgr.c b/drivers/crypto_mgr/src/crypto_mgr.c index 288cc8f5..e6434bb8 100644 --- a/drivers/crypto_mgr/src/crypto_mgr.c +++ b/drivers/crypto_mgr/src/crypto_mgr.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: define drv main function - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/drivers/include/boot_sharedmem.h b/drivers/include/boot_sharedmem.h index beaae8cb..0872fb36 100644 --- a/drivers/include/boot_sharedmem.h +++ b/drivers/include/boot_sharedmem.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: shared mem API, usually copied in booting period - * Create: 2020-06 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRIVERS_BOOT_SHAREDMEM_H #define DRIVERS_BOOT_SHAREDMEM_H diff --git a/drivers/include/drv_module.h b/drivers/include/drv_module.h index 897fb6a8..27ce35c8 100644 --- a/drivers/include/drv_module.h +++ b/drivers/include/drv_module.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: moved from teeos, driver module init function and structure - * Create: 2019-11-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRIVERS_DRV_MODULE_H #define DRIVERS_DRV_MODULE_H diff --git a/drivers/include/drv_param_type.h b/drivers/include/drv_param_type.h index c6c96674..62a80b5e 100644 --- a/drivers/include/drv_param_type.h +++ b/drivers/include/drv_param_type.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Header file for driver params - * Create: 2020-04-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PLATDRV_INCLUDE_DRV_PARAM_TYPE_H #define PLATDRV_INCLUDE_DRV_PARAM_TYPE_H diff --git a/drivers/include/register_ops.h b/drivers/include/register_ops.h index 991a5cbb..618cbdc2 100755 --- a/drivers/include/register_ops.h +++ b/drivers/include/register_ops.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: moved from teeos, register operation marco definition - * Create: 2019-11-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRIVERS_REGISTER_OPS_H #define DRIVERS_REGISTER_OPS_H diff --git a/drivers/include/secure_gic_common.h b/drivers/include/secure_gic_common.h index 045f55b8..1a7bb88f 100644 --- a/drivers/include/secure_gic_common.h +++ b/drivers/include/secure_gic_common.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: moved from teeos, interrupt type marco definition - * Create: 2019-11-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRIVERS_SECURE_GIC_COMMON_H #define DRIVERS_SECURE_GIC_COMMON_H diff --git a/drivers/include/sre_debug.h b/drivers/include/sre_debug.h index ae6189a7..5e2bcf08 100755 --- a/drivers/include/sre_debug.h +++ b/drivers/include/sre_debug.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: moved from teeos, debug print function - * Create: 2019-11-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRIVERS_SRE_DEBUG_H #define DRIVERS_SRE_DEBUG_H diff --git a/drivers/include/sre_log.h b/drivers/include/sre_log.h index 083a676b..a2d3e9b7 100644 --- a/drivers/include/sre_log.h +++ b/drivers/include/sre_log.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: moved from teeos, print function and macro definition - * Create: 2019-11-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRIVERS_SRE_LOG_H #define DRIVERS_SRE_LOG_H diff --git a/drivers/include/sre_msg.h b/drivers/include/sre_msg.h index 2f9fa6d2..d8991478 100644 --- a/drivers/include/sre_msg.h +++ b/drivers/include/sre_msg.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: moved from teeos, old msg function, should change - * Create: 2019-11-14 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRIVER_SRE_MSG_H #define DRIVER_SRE_MSG_H diff --git a/drivers/include/sre_task.h b/drivers/include/sre_task.h index 9fd60b41..a996e90d 100644 --- a/drivers/include/sre_task.h +++ b/drivers/include/sre_task.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: task definition used by gtask and platdrv - * Create: 2022-05-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTEEOS_SRE_TASK_H #define LIBTEEOS_SRE_TASK_H diff --git a/drivers/include/tee_driver_module.h b/drivers/include/tee_driver_module.h index 15e4681f..f672553b 100644 --- a/drivers/include/tee_driver_module.h +++ b/drivers/include/tee_driver_module.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: tee driver module structure, export to driver developer - * Create: 2021-03-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_DRIVER_MODULE_H #define TEE_DRIVER_MODULE_H diff --git a/drivers/misc_driver/Makefile b/drivers/misc_driver/Makefile index a0cdf847..a5896512 100644 --- a/drivers/misc_driver/Makefile +++ b/drivers/misc_driver/Makefile @@ -1,5 +1,12 @@ -# misc_driver compile rule -# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. DRIVER := misc_driver.elf SCRAMBLE_ME := diff --git a/drivers/misc_driver/src/drv_sharedmem.c b/drivers/misc_driver/src/drv_sharedmem.c index f463e28a..68e9adf4 100644 --- a/drivers/misc_driver/src/drv_sharedmem.c +++ b/drivers/misc_driver/src/drv_sharedmem.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: shared mem API - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "drv_sharedmem.h" #include diff --git a/drivers/misc_driver/src/drv_sharedmem.h b/drivers/misc_driver/src/drv_sharedmem.h index e060a0e7..17c220ed 100644 --- a/drivers/misc_driver/src/drv_sharedmem.h +++ b/drivers/misc_driver/src/drv_sharedmem.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: shared mem API - * Create: 2022-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRIVERS_SHAREDMEM_H #define DRIVERS_SHAREDMEM_H diff --git a/drivers/misc_driver/src/misc_driver.c b/drivers/misc_driver/src/misc_driver.c index 45e10ea8..2850a70f 100644 --- a/drivers/misc_driver/src/misc_driver.c +++ b/drivers/misc_driver/src/misc_driver.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: shared mem API - * Create: 2022-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include "tee_log.h" diff --git a/drivers/misc_driver/src/oemkey_driver.c b/drivers/misc_driver/src/oemkey_driver.c index f1302519..dd143571 100644 --- a/drivers/misc_driver/src/oemkey_driver.c +++ b/drivers/misc_driver/src/oemkey_driver.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: get oemkey from shared mem - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "oemkey_driver.h" #include diff --git a/drivers/misc_driver/src/oemkey_driver.h b/drivers/misc_driver/src/oemkey_driver.h index 32a661a1..1f042785 100644 --- a/drivers/misc_driver/src/oemkey_driver.h +++ b/drivers/misc_driver/src/oemkey_driver.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: get oemkey from shared mem - - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef KUNPENG_DRV_SECUREBOOT_H #define KUNPENG_DRV_SECUREBOOT_H diff --git a/drivers/tee_misc_driver/Makefile b/drivers/tee_misc_driver/Makefile index 4f6364eb..fe4f10dc 100644 --- a/drivers/tee_misc_driver/Makefile +++ b/drivers/tee_misc_driver/Makefile @@ -1,5 +1,12 @@ -# tee_misc_driver compile rule -# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. DRIVER := tee_misc_driver.elf diff --git a/drivers/tee_misc_driver/src/drv_sharedmem.c b/drivers/tee_misc_driver/src/drv_sharedmem.c index f463e28a..68e9adf4 100644 --- a/drivers/tee_misc_driver/src/drv_sharedmem.c +++ b/drivers/tee_misc_driver/src/drv_sharedmem.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: shared mem API - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "drv_sharedmem.h" #include diff --git a/drivers/tee_misc_driver/src/drv_sharedmem.h b/drivers/tee_misc_driver/src/drv_sharedmem.h index e060a0e7..17c220ed 100644 --- a/drivers/tee_misc_driver/src/drv_sharedmem.h +++ b/drivers/tee_misc_driver/src/drv_sharedmem.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: shared mem API - * Create: 2022-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRIVERS_SHAREDMEM_H #define DRIVERS_SHAREDMEM_H diff --git a/drivers/tee_misc_driver/src/tee_misc_driver.c b/drivers/tee_misc_driver/src/tee_misc_driver.c index 63092dc8..9648d308 100644 --- a/drivers/tee_misc_driver/src/tee_misc_driver.c +++ b/drivers/tee_misc_driver/src/tee_misc_driver.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: shared mem API - * Create: 2022-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include "tee_log.h" diff --git a/drivers/tee_misc_driver/src/tee_oemkey_driver.c b/drivers/tee_misc_driver/src/tee_oemkey_driver.c index cf32cb53..25bede47 100644 --- a/drivers/tee_misc_driver/src/tee_oemkey_driver.c +++ b/drivers/tee_misc_driver/src/tee_oemkey_driver.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: get oemkey from shared mem - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_oemkey_driver.h" #include diff --git a/drivers/tee_misc_driver/src/tee_oemkey_driver.h b/drivers/tee_misc_driver/src/tee_oemkey_driver.h index 32a661a1..1f042785 100644 --- a/drivers/tee_misc_driver/src/tee_oemkey_driver.h +++ b/drivers/tee_misc_driver/src/tee_oemkey_driver.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: get oemkey from shared mem - - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef KUNPENG_DRV_SECUREBOOT_H #define KUNPENG_DRV_SECUREBOOT_H diff --git a/framework/drvmgr/Makefile b/framework/drvmgr/Makefile index 06fbd8f6..7b79d489 100644 --- a/framework/drvmgr/Makefile +++ b/framework/drvmgr/Makefile @@ -1,5 +1,12 @@ -# drvmgr compile rule -# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. DRIVER := drvmgr.elf diff --git a/framework/drvmgr/src/base_drv_node.c b/framework/drvmgr/src/base_drv_node.c index 1e72d7fc..8336ac15 100644 --- a/framework/drvmgr/src/base_drv_node.c +++ b/framework/drvmgr/src/base_drv_node.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: define register and init base driver node function - * Create: 2022-01-07 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "base_drv_node.h" #include diff --git a/framework/drvmgr/src/base_drv_node.h b/framework/drvmgr/src/base_drv_node.h index 9f10a022..57627013 100644 --- a/framework/drvmgr/src/base_drv_node.h +++ b/framework/drvmgr/src/base_drv_node.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: drvcaller and drv node structure - * Create: 2022-01-07 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef BASE_DRV_NODE_H #define BASE_DRV_NODE_H diff --git a/framework/drvmgr/src/drv_auth.c b/framework/drvmgr/src/drv_auth.c index 06510a8a..2015ddb8 100644 --- a/framework/drvmgr/src/drv_auth.c +++ b/framework/drvmgr/src/drv_auth.c @@ -1,105 +1,111 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: define auth function - * Create: 2021-03-17 - */ -#include "drv_auth.h" -#include -#include -#include -#include -#include -#include "drv_dyn_conf_mgr.h" -#include "drvcall_dyn_conf_mgr.h" - -static int32_t get_mac_perm_by_uuid(const struct drv_conf_t *drv_conf, const struct tee_uuid *srv_uuid, - uint64_t *mac_perm) -{ - uint32_t i; - - for (i = 0; i < drv_conf->mac_info_list_size; i++) { - struct drv_mac_info_t drv_mac_info = drv_conf->mac_info_list[i]; - - if (memcmp(&drv_mac_info.uuid, srv_uuid, sizeof(struct tee_uuid)) == 0) { - if (mac_perm != NULL) - *mac_perm = drv_mac_info.perm; - return TEE_SUCCESS; - } - } - tloge("cannot find uuid %08x-%04x-%04x in mac list\n", - srv_uuid->timeLow, srv_uuid->timeMid, srv_uuid->timeHiAndVersion); - return TEE_ERROR_GENERIC; -} - -static int32_t get_perm_by_service_name_in_perm_apply_list(const struct task_tlv *tlv, - const char *service_name, uint32_t service_name_size, - uint64_t *perm) -{ - uint32_t i; - - for (i = 0; i < tlv->drvcall_perm_apply_list_size; i++) { - struct drvcall_perm_apply_item_t item = tlv->drvcall_perm_apply_list[i]; - if (item.name_size != service_name_size) - continue; - - if (strncmp(item.name, service_name, item.name_size) == 0) { - if (perm != NULL) - *perm = item.perm; - return TEE_SUCCESS; - } - } - - tloge("cannot find service name %s in perm apply list\n", service_name); - return TEE_ERROR_GENERIC; -} - -bool caller_open_auth_check(const struct task_node *call_node, const char *drv_name, uint32_t name_len) -{ - if (call_node == NULL || drv_name == NULL || name_len == 0) { - tloge("invalid param\n"); - return false; - } - - /* check if TA have registed drv name in perm apply list */ - if (get_perm_by_service_name_in_perm_apply_list(&call_node->tlv, drv_name, name_len, NULL) != TEE_SUCCESS) - return false; - - return true; -} - -bool drv_mac_open_auth_check(const struct drv_conf_t *drv_conf, const struct tee_uuid *uuid) -{ - if (uuid == NULL || drv_conf == NULL) { - tloge("invalid uuid or drv_conf\n"); - return false; - } - - /* if drv not have mac list, all TA can open */ - if (drv_conf->mac_info_list_size == 0) - return true; - - /* check if TA in drv's mac list */ - if (get_mac_perm_by_uuid(drv_conf, uuid, NULL) == TEE_SUCCESS) - return true; - - return false; -} - -int32_t get_drvcaller_cmd_perm(const struct task_node *call_node, const struct task_node *dnode, uint64_t *perm) -{ - if (call_node == NULL || dnode == NULL || dnode->tlv.drv_conf == NULL || perm == NULL) { - tloge("invalid param\n"); - return -1; - } - - int32_t ret; - if (dnode->tlv.drv_conf->mac_info_list_size == 0) { - tlogd("no mac perm, use drvcaller perm\n"); - ret = get_perm_by_service_name_in_perm_apply_list(&call_node->tlv, - dnode->tlv.drv_conf->mani.service_name, dnode->tlv.drv_conf->mani.service_name_size, perm); - return ret; - } - - ret = get_mac_perm_by_uuid(dnode->tlv.drv_conf, &call_node->tlv.uuid, perm); - return ret; -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include "drv_auth.h" +#include +#include +#include +#include +#include +#include "drv_dyn_conf_mgr.h" +#include "drvcall_dyn_conf_mgr.h" + +static int32_t get_mac_perm_by_uuid(const struct drv_conf_t *drv_conf, const struct tee_uuid *srv_uuid, + uint64_t *mac_perm) +{ + uint32_t i; + + for (i = 0; i < drv_conf->mac_info_list_size; i++) { + struct drv_mac_info_t drv_mac_info = drv_conf->mac_info_list[i]; + + if (memcmp(&drv_mac_info.uuid, srv_uuid, sizeof(struct tee_uuid)) == 0) { + if (mac_perm != NULL) + *mac_perm = drv_mac_info.perm; + return TEE_SUCCESS; + } + } + tloge("cannot find uuid %08x-%04x-%04x in mac list\n", + srv_uuid->timeLow, srv_uuid->timeMid, srv_uuid->timeHiAndVersion); + return TEE_ERROR_GENERIC; +} + +static int32_t get_perm_by_service_name_in_perm_apply_list(const struct task_tlv *tlv, + const char *service_name, uint32_t service_name_size, + uint64_t *perm) +{ + uint32_t i; + + for (i = 0; i < tlv->drvcall_perm_apply_list_size; i++) { + struct drvcall_perm_apply_item_t item = tlv->drvcall_perm_apply_list[i]; + if (item.name_size != service_name_size) + continue; + + if (strncmp(item.name, service_name, item.name_size) == 0) { + if (perm != NULL) + *perm = item.perm; + return TEE_SUCCESS; + } + } + + tloge("cannot find service name %s in perm apply list\n", service_name); + return TEE_ERROR_GENERIC; +} + +bool caller_open_auth_check(const struct task_node *call_node, const char *drv_name, uint32_t name_len) +{ + if (call_node == NULL || drv_name == NULL || name_len == 0) { + tloge("invalid param\n"); + return false; + } + + /* check if TA have registed drv name in perm apply list */ + if (get_perm_by_service_name_in_perm_apply_list(&call_node->tlv, drv_name, name_len, NULL) != TEE_SUCCESS) + return false; + + return true; +} + +bool drv_mac_open_auth_check(const struct drv_conf_t *drv_conf, const struct tee_uuid *uuid) +{ + if (uuid == NULL || drv_conf == NULL) { + tloge("invalid uuid or drv_conf\n"); + return false; + } + + /* if drv not have mac list, all TA can open */ + if (drv_conf->mac_info_list_size == 0) + return true; + + /* check if TA in drv's mac list */ + if (get_mac_perm_by_uuid(drv_conf, uuid, NULL) == TEE_SUCCESS) + return true; + + return false; +} + +int32_t get_drvcaller_cmd_perm(const struct task_node *call_node, const struct task_node *dnode, uint64_t *perm) +{ + if (call_node == NULL || dnode == NULL || dnode->tlv.drv_conf == NULL || perm == NULL) { + tloge("invalid param\n"); + return -1; + } + + int32_t ret; + if (dnode->tlv.drv_conf->mac_info_list_size == 0) { + tlogd("no mac perm, use drvcaller perm\n"); + ret = get_perm_by_service_name_in_perm_apply_list(&call_node->tlv, + dnode->tlv.drv_conf->mani.service_name, dnode->tlv.drv_conf->mani.service_name_size, perm); + return ret; + } + + ret = get_mac_perm_by_uuid(dnode->tlv.drv_conf, &call_node->tlv.uuid, perm); + return ret; +} diff --git a/framework/drvmgr/src/drv_auth.h b/framework/drvmgr/src/drv_auth.h index ca273d1f..1f4f3656 100644 --- a/framework/drvmgr/src/drv_auth.h +++ b/framework/drvmgr/src/drv_auth.h @@ -1,19 +1,25 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: define auth function - * Create: 2021-03-17 - */ -#ifndef DRVMGR_SRC_DRV_AUTH_H -#define DRVMGR_SRC_DRV_AUTH_H -#include -#include -#include -#include "drvcall_dyn_conf_mgr.h" -#include "drv_dyn_conf_mgr.h" -#include "task_mgr.h" - -bool drv_mac_open_auth_check(const struct drv_conf_t *drv_conf, const struct tee_uuid *uuid); -bool caller_open_auth_check(const struct task_node *call_node, const char *drv_name, uint32_t name_len); -int32_t get_drvcaller_cmd_perm(const struct task_node *call_node, const struct task_node *dnode, uint64_t *perm); - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef DRVMGR_SRC_DRV_AUTH_H +#define DRVMGR_SRC_DRV_AUTH_H +#include +#include +#include +#include "drvcall_dyn_conf_mgr.h" +#include "drv_dyn_conf_mgr.h" +#include "task_mgr.h" + +bool drv_mac_open_auth_check(const struct drv_conf_t *drv_conf, const struct tee_uuid *uuid); +bool caller_open_auth_check(const struct task_node *call_node, const char *drv_name, uint32_t name_len); +int32_t get_drvcaller_cmd_perm(const struct task_node *call_node, const struct task_node *dnode, uint64_t *perm); + +#endif diff --git a/framework/drvmgr/src/drv_dispatch.c b/framework/drvmgr/src/drv_dispatch.c index 6c2554c0..92240f6f 100644 --- a/framework/drvmgr/src/drv_dispatch.c +++ b/framework/drvmgr/src/drv_dispatch.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: drvmgr dispatch function define when receive cmd - * Create: 2021-03-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "drv_dispatch.h" #include diff --git a/framework/drvmgr/src/drv_dispatch.h b/framework/drvmgr/src/drv_dispatch.h index 47c48664..764a1a19 100644 --- a/framework/drvmgr/src/drv_dispatch.h +++ b/framework/drvmgr/src/drv_dispatch.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: declare drvmgr dispatch function when receive cmd - * Create: 2021-03-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRVMGR_SRC_DRV_DISPATCH_H #define DRVMGR_SRC_DRV_DISPATCH_H diff --git a/framework/drvmgr/src/drv_dyn_conf_mgr.c b/framework/drvmgr/src/drv_dyn_conf_mgr.c index f5b96a03..78c3f316 100644 --- a/framework/drvmgr/src/drv_dyn_conf_mgr.c +++ b/framework/drvmgr/src/drv_dyn_conf_mgr.c @@ -1,345 +1,351 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: handle drv dyn perm info - * Create: 2021-02-03 - */ - -#include "drv_dyn_conf_mgr.h" -#include -#include -#include -#include -#include -#include -#include "drv_fd_ops.h" -#include "drv_param_ops.h" -#include "drv_process_mgr.h" - -void free_drv_conf_list(struct drv_conf_t *drv_conf, uint32_t receive_flag) -{ - if (drv_conf == NULL) { - tloge("invalid drv conf\n"); - return; - } - - if (receive_flag >= RECEIVE_IO_MAP_LIST && drv_conf->io_map_list != NULL) { - free(drv_conf->io_map_list); - drv_conf->io_map_list = NULL; - drv_conf->io_map_list_size = 0; - } - - if (receive_flag >= RECEIVE_IRQ_LIST && drv_conf->irq_list != NULL) { - free(drv_conf->irq_list); - drv_conf->irq_list = NULL; - drv_conf->irq_list_size = 0; - } - - if (receive_flag >= RECEIVE_MAP_SECURE_LIST && drv_conf->map_secure_list != NULL) { - free(drv_conf->map_secure_list); - drv_conf->map_secure_list = NULL; - drv_conf->map_secure_list_size = 0; - } - - if (receive_flag >= RECEIVE_MAP_NOSECURE_LIST && drv_conf->map_nosecure_list != NULL) { - free(drv_conf->map_nosecure_list); - drv_conf->map_nosecure_list = NULL; - drv_conf->map_nosecure_list_size = 0; - } - - if (receive_flag >= RECEIVE_MAC_INFO_LIST && drv_conf->mac_info_list != NULL) { - free(drv_conf->mac_info_list); - drv_conf->mac_info_list = NULL; - drv_conf->mac_info_list_size = 0; - } - - if (receive_flag >= RECEIVE_CMD_PERM_LIST && drv_conf->cmd_perm_list != NULL) { - free(drv_conf->cmd_perm_list); - drv_conf->cmd_perm_list = NULL; - drv_conf->cmd_perm_list_size = 0; - } -} - -#ifdef TEE_SUPPORT_DYN_CONF_DEBUG -static void dump_drv_basic_info(const struct drv_basic_info_t *drv_basic_info) -{ - if (drv_basic_info->upgrade) - tlogi("[drv dyn conf] upgrade: true\n"); - else - tlogi("[drv dyn conf] upgrade: false\n"); - - if (drv_basic_info->virt2phys) - tlogi("[drv dyn conf] virt2phys: true\n"); - else - tlogi("[drv dyn conf] virtphys: false\n"); - - tlogi("[drv dyn conf] thread_limit: %u\n", drv_basic_info->thread_limit); - - if (drv_basic_info->exception_mode == DYN_CONF_SYSCRASH_TAG) - tlogi("[drv dyn conf] exception_mode: syscrash\n"); - else if (drv_basic_info->exception_mode == DYN_CONF_RESTART_TAG) - tlogi("[drv dyn conf] exception_mode: restart\n"); - else if (drv_basic_info->exception_mode == DYN_CONF_DDOS_TAG) - tlogi("[drv dyn conf] exception_mode: ddos\n"); - else - tlogi("[drv dyn conf] exception_mode: unknown\n"); -} - -static void dump_drv_mani(const struct drv_mani_t *mani) -{ - tlogi("[drv dyn conf] UUID %x\n", mani->srv_uuid.timeLow); - tlogi("[drv dyn conf] service name %s\n", mani->service_name); - - if (mani->keep_alive) - tlogi("[drv dyn conf] keep_alive is true\n"); - else - tlogi("[drv dyn conf] keep_alive is false\n"); - - tlogi("[drv dyn conf] data size 0x%x\n", mani->data_size); - tlogi("[drv dyn conf] stack size 0x%x\n", mani->stack_size); -} - -static void dump_drv_io_map_list(const struct drv_conf_t *drv_conf) -{ - tlogi("[drv dyn conf] io map list size %u\n", drv_conf->io_map_list_size); - uint32_t i; - for (i = 0; i < drv_conf->io_map_list_size; i++) - tlogi("[drv dyn conf] iomap region size %llx\n", - (unsigned long long)(drv_conf->io_map_list[i].end - - drv_conf->io_map_list[i].start)); -} - -static void dump_drv_irq_list(const struct drv_conf_t *drv_conf) -{ - tlogi("[drv dyn conf] irq list size %u\n", drv_conf->irq_list_size); - uint32_t i; - for (i = 0; i < drv_conf->irq_list_size; i++) - tlogi("[drv dyn conf] irq %llu\n", (unsigned long long)drv_conf->irq_list[i]); -} - -static void dump_drv_map_secure_list(const struct drv_conf_t *drv_conf) -{ - tlogi("[drv dyn conf] map secure list size %u\n", drv_conf->map_secure_list_size); - uint32_t i; - for (i = 0; i < drv_conf->map_secure_list_size; i++) { - struct tee_uuid uuid = drv_conf->map_secure_list[i].uuid; - tlogi("[drv dyn conf] map_secure uuid %08x-%04x-%04x\n", - uuid.timeLow, uuid.timeMid, uuid.timeHiAndVersion); - tlogi("[drv dyn conf] map_secure region size %llx\n", - (unsigned long long)(drv_conf->map_secure_list[i].region.end - - drv_conf->map_secure_list[i].region.start)); - } -} - -static void dump_drv_map_nosecure_list(const struct drv_conf_t *drv_conf) -{ - tlogi("[drv dyn conf] map nosecure list size %u\n", drv_conf->map_nosecure_list_size); - uint32_t i; - for (i = 0; i < drv_conf->map_nosecure_list_size; i++) { - struct tee_uuid uuid = drv_conf->map_nosecure_list[i].uuid; - tlogi("[drv dyn conf] map_nosecure uuid %08x-%04x-%04x\n", - uuid.timeLow, uuid.timeMid, uuid.timeHiAndVersion); - } -} - -static void dump_drv_mac_info(const struct drv_conf_t *drv_conf) -{ - tlogi("[drv dyn conf] drv mac list size %u\n", drv_conf->mac_info_list_size); - uint32_t i; - for (i = 0; i < drv_conf->mac_info_list_size; i++) { - struct tee_uuid uuid = drv_conf->mac_info_list[i].uuid; - tlogi("[drv dyn conf] mac info uuid %08x-%04x-%04x perm %llx\n", - uuid.timeLow, uuid.timeMid, uuid.timeHiAndVersion, - (unsigned long long)drv_conf->mac_info_list[i].perm); - } -} - -static void dump_drv_cmd_perm_info(const struct drv_conf_t *drv_conf) -{ - tlogi("[drv dyn conf] drv cmd perm list size %u\n", drv_conf->cmd_perm_list_size); - uint32_t i; - for (i = 0; i < drv_conf->cmd_perm_list_size; i++) - tlogi("[drv dyn conf] cmd %llx permission %llx\n", - (unsigned long long)drv_conf->cmd_perm_list[i].cmd, - (unsigned long long)drv_conf->cmd_perm_list[i].perm); -} - -void dump_drv_conf(const struct drv_conf_t *drv_conf) -{ - if (drv_conf == NULL) { - tloge("invalid drv conf\n"); - return; - } - - dump_drv_mani(&drv_conf->mani); - dump_drv_basic_info(&drv_conf->drv_basic_info); - dump_drv_io_map_list(drv_conf); - dump_drv_irq_list(drv_conf); - dump_drv_map_secure_list(drv_conf); - dump_drv_map_nosecure_list(drv_conf); - dump_drv_mac_info(drv_conf); - dump_drv_cmd_perm_info(drv_conf); -} -#endif - -static int32_t receive_drv_conf_list(void **list, uint16_t list_size, uint32_t item_size) -{ - if (list == NULL || item_size == 0 || item_size >= MAX_IMAGE_LEN) { - tloge("invalied params while receive drv conf list\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (*list == NULL || list_size == 0) - return TEE_SUCCESS; - - /* list_size < 0xffff means tmp_size cannot larger than 0xFFFFFFFF */ - uint32_t tmp_size = list_size * item_size; - if (tmp_size >= MAX_IMAGE_LEN || list_size * item_size < item_size) { - tloge("tmp size is too large or overflow while receive drv conf list %u\n", item_size); - return TEE_ERROR_BAD_PARAMETERS; - } - - void *tmp_list = malloc(tmp_size); - if (tmp_list == NULL) { - tloge("malloc tmp_list failed\n"); - return TEE_ERROR_GENERIC; - } - - if (copy_from_client((uint64_t)(uintptr_t)(*list), tmp_size, (uintptr_t)tmp_list, tmp_size) != TEE_SUCCESS) { - tloge("copy_from_client tmp_list failed\n"); - free(tmp_list); - return TEE_ERROR_GENERIC; - } - - *list = tmp_list; - - return TEE_SUCCESS; -} - -int32_t do_receive_drv_conf(struct drv_conf_t *drv_conf) -{ - uint32_t receive_flag = 0; - if (drv_conf == NULL) { - tloge("invalid receive param\n"); - return -1; - } - - /* receive drv_conf iomap list */ - if (receive_drv_conf_list((void **)&drv_conf->io_map_list, - drv_conf->io_map_list_size, sizeof(struct addr_region_t)) != 0) - goto err_out; - receive_flag = RECEIVE_IO_MAP_LIST; - - /* receive irq list */ - if (receive_drv_conf_list((void **)&drv_conf->irq_list, - drv_conf->irq_list_size, sizeof(uint64_t)) != 0) - goto err_out; - receive_flag = RECEIVE_IRQ_LIST; - - /* receive map secure list */ - if (receive_drv_conf_list((void **)&drv_conf->map_secure_list, - drv_conf->map_secure_list_size, sizeof(struct drv_map_secure_t)) != 0) - goto err_out; - receive_flag = RECEIVE_MAP_SECURE_LIST; - - /* receive map nosecure list */ - if (receive_drv_conf_list((void **)&drv_conf->map_nosecure_list, - drv_conf->map_nosecure_list_size, sizeof(struct drv_map_nosecure_t)) != 0) - goto err_out; - receive_flag = RECEIVE_MAP_NOSECURE_LIST; - - /* receive mac info list */ - if (receive_drv_conf_list((void **)&drv_conf->mac_info_list, - drv_conf->mac_info_list_size, sizeof(struct drv_mac_info_t)) != 0) - goto err_out; - receive_flag = RECEIVE_MAC_INFO_LIST; - - /* receive cmd perm list */ - if (receive_drv_conf_list((void **)&drv_conf->cmd_perm_list, - drv_conf->cmd_perm_list_size, sizeof(struct drv_cmd_perm_info_t)) != 0) - goto err_out; - - return 0; - -err_out: - free_drv_conf_list(drv_conf, receive_flag); - return -1; -} - -int32_t check_drv_node_state(struct task_node *node) -{ - int32_t func_ret = DRV_FAIL; - - if (node == NULL || node->tlv.drv_conf == NULL) { - tloge("invalid node\n"); - return DRV_FAIL; - } - - int32_t ret = drv_robust_mutex_lock(&node->state_mtx); - if (ret != 0) { - tloge("get state mtx fail\n"); - return DRV_FAIL; - } - - switch (node->state) { - case TASK_LOAD: - node->state = TASK_SPAWN; - func_ret = DRV_NEED_SPAWN; - break; - case TASK_SPAWN: - while (node->state == TASK_SPAWN) { - tloge("drv:%s is spawn by other thread, just wait\n", node->tlv.drv_conf->mani.service_name); - ret = pthread_cond_wait(&node->state_cond, &node->state_mtx); - if (ret != 0) { - tloge("something wrong, drv:%s cond wait fail:0x%x\n", node->tlv.drv_conf->mani.service_name, ret); - goto unlock_mtx; - } - } - - if (node->state == TASK_NORMAL) - func_ret = DRV_SUCC; - else - tloge("something wrong, wait spawn fail state:0x%x\n", node->state); - break; - case TASK_NORMAL: - func_ret = DRV_SUCC; - break; - default: - /* when drv spawn fail, just return fail */ - tloge("something wrong, drv:%s state:%d\n", node->tlv.drv_conf->mani.service_name, node->state); - } - -unlock_mtx: - ret = pthread_mutex_unlock(&node->state_mtx); - if (ret != 0) - tloge("something wrong, unlock mtx in drv state fail\n"); - - return func_ret; -} - -void broadcast_drv_state(struct task_node *node, bool spawn_succ) -{ - if (node == NULL) { - tloge("invalid node\n"); - return; - } - - int32_t ret = drv_robust_mutex_lock(&node->state_mtx); - if (ret != 0) { - tloge("get state mtx fail\n"); - return; - } - - if (node->state != TASK_SPAWN) - tloge("something wrong, node->state:%d not DRV_SPAWN\n", node->state); - - if (spawn_succ) - node->state = TASK_NORMAL; - else - node->state = TASK_SPAWN_FAIL; - - pthread_cond_broadcast(&node->state_cond); - - ret = pthread_mutex_unlock(&node->state_mtx); - if (ret != 0) - tloge("something wrong, unlock stat mtx fail\n"); -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#include "drv_dyn_conf_mgr.h" +#include +#include +#include +#include +#include +#include +#include "drv_fd_ops.h" +#include "drv_param_ops.h" +#include "drv_process_mgr.h" + +void free_drv_conf_list(struct drv_conf_t *drv_conf, uint32_t receive_flag) +{ + if (drv_conf == NULL) { + tloge("invalid drv conf\n"); + return; + } + + if (receive_flag >= RECEIVE_IO_MAP_LIST && drv_conf->io_map_list != NULL) { + free(drv_conf->io_map_list); + drv_conf->io_map_list = NULL; + drv_conf->io_map_list_size = 0; + } + + if (receive_flag >= RECEIVE_IRQ_LIST && drv_conf->irq_list != NULL) { + free(drv_conf->irq_list); + drv_conf->irq_list = NULL; + drv_conf->irq_list_size = 0; + } + + if (receive_flag >= RECEIVE_MAP_SECURE_LIST && drv_conf->map_secure_list != NULL) { + free(drv_conf->map_secure_list); + drv_conf->map_secure_list = NULL; + drv_conf->map_secure_list_size = 0; + } + + if (receive_flag >= RECEIVE_MAP_NOSECURE_LIST && drv_conf->map_nosecure_list != NULL) { + free(drv_conf->map_nosecure_list); + drv_conf->map_nosecure_list = NULL; + drv_conf->map_nosecure_list_size = 0; + } + + if (receive_flag >= RECEIVE_MAC_INFO_LIST && drv_conf->mac_info_list != NULL) { + free(drv_conf->mac_info_list); + drv_conf->mac_info_list = NULL; + drv_conf->mac_info_list_size = 0; + } + + if (receive_flag >= RECEIVE_CMD_PERM_LIST && drv_conf->cmd_perm_list != NULL) { + free(drv_conf->cmd_perm_list); + drv_conf->cmd_perm_list = NULL; + drv_conf->cmd_perm_list_size = 0; + } +} + +#ifdef TEE_SUPPORT_DYN_CONF_DEBUG +static void dump_drv_basic_info(const struct drv_basic_info_t *drv_basic_info) +{ + if (drv_basic_info->upgrade) + tlogi("[drv dyn conf] upgrade: true\n"); + else + tlogi("[drv dyn conf] upgrade: false\n"); + + if (drv_basic_info->virt2phys) + tlogi("[drv dyn conf] virt2phys: true\n"); + else + tlogi("[drv dyn conf] virtphys: false\n"); + + tlogi("[drv dyn conf] thread_limit: %u\n", drv_basic_info->thread_limit); + + if (drv_basic_info->exception_mode == DYN_CONF_SYSCRASH_TAG) + tlogi("[drv dyn conf] exception_mode: syscrash\n"); + else if (drv_basic_info->exception_mode == DYN_CONF_RESTART_TAG) + tlogi("[drv dyn conf] exception_mode: restart\n"); + else if (drv_basic_info->exception_mode == DYN_CONF_DDOS_TAG) + tlogi("[drv dyn conf] exception_mode: ddos\n"); + else + tlogi("[drv dyn conf] exception_mode: unknown\n"); +} + +static void dump_drv_mani(const struct drv_mani_t *mani) +{ + tlogi("[drv dyn conf] UUID %x\n", mani->srv_uuid.timeLow); + tlogi("[drv dyn conf] service name %s\n", mani->service_name); + + if (mani->keep_alive) + tlogi("[drv dyn conf] keep_alive is true\n"); + else + tlogi("[drv dyn conf] keep_alive is false\n"); + + tlogi("[drv dyn conf] data size 0x%x\n", mani->data_size); + tlogi("[drv dyn conf] stack size 0x%x\n", mani->stack_size); +} + +static void dump_drv_io_map_list(const struct drv_conf_t *drv_conf) +{ + tlogi("[drv dyn conf] io map list size %u\n", drv_conf->io_map_list_size); + uint32_t i; + for (i = 0; i < drv_conf->io_map_list_size; i++) + tlogi("[drv dyn conf] iomap region size %llx\n", + (unsigned long long)(drv_conf->io_map_list[i].end - + drv_conf->io_map_list[i].start)); +} + +static void dump_drv_irq_list(const struct drv_conf_t *drv_conf) +{ + tlogi("[drv dyn conf] irq list size %u\n", drv_conf->irq_list_size); + uint32_t i; + for (i = 0; i < drv_conf->irq_list_size; i++) + tlogi("[drv dyn conf] irq %llu\n", (unsigned long long)drv_conf->irq_list[i]); +} + +static void dump_drv_map_secure_list(const struct drv_conf_t *drv_conf) +{ + tlogi("[drv dyn conf] map secure list size %u\n", drv_conf->map_secure_list_size); + uint32_t i; + for (i = 0; i < drv_conf->map_secure_list_size; i++) { + struct tee_uuid uuid = drv_conf->map_secure_list[i].uuid; + tlogi("[drv dyn conf] map_secure uuid %08x-%04x-%04x\n", + uuid.timeLow, uuid.timeMid, uuid.timeHiAndVersion); + tlogi("[drv dyn conf] map_secure region size %llx\n", + (unsigned long long)(drv_conf->map_secure_list[i].region.end - + drv_conf->map_secure_list[i].region.start)); + } +} + +static void dump_drv_map_nosecure_list(const struct drv_conf_t *drv_conf) +{ + tlogi("[drv dyn conf] map nosecure list size %u\n", drv_conf->map_nosecure_list_size); + uint32_t i; + for (i = 0; i < drv_conf->map_nosecure_list_size; i++) { + struct tee_uuid uuid = drv_conf->map_nosecure_list[i].uuid; + tlogi("[drv dyn conf] map_nosecure uuid %08x-%04x-%04x\n", + uuid.timeLow, uuid.timeMid, uuid.timeHiAndVersion); + } +} + +static void dump_drv_mac_info(const struct drv_conf_t *drv_conf) +{ + tlogi("[drv dyn conf] drv mac list size %u\n", drv_conf->mac_info_list_size); + uint32_t i; + for (i = 0; i < drv_conf->mac_info_list_size; i++) { + struct tee_uuid uuid = drv_conf->mac_info_list[i].uuid; + tlogi("[drv dyn conf] mac info uuid %08x-%04x-%04x perm %llx\n", + uuid.timeLow, uuid.timeMid, uuid.timeHiAndVersion, + (unsigned long long)drv_conf->mac_info_list[i].perm); + } +} + +static void dump_drv_cmd_perm_info(const struct drv_conf_t *drv_conf) +{ + tlogi("[drv dyn conf] drv cmd perm list size %u\n", drv_conf->cmd_perm_list_size); + uint32_t i; + for (i = 0; i < drv_conf->cmd_perm_list_size; i++) + tlogi("[drv dyn conf] cmd %llx permission %llx\n", + (unsigned long long)drv_conf->cmd_perm_list[i].cmd, + (unsigned long long)drv_conf->cmd_perm_list[i].perm); +} + +void dump_drv_conf(const struct drv_conf_t *drv_conf) +{ + if (drv_conf == NULL) { + tloge("invalid drv conf\n"); + return; + } + + dump_drv_mani(&drv_conf->mani); + dump_drv_basic_info(&drv_conf->drv_basic_info); + dump_drv_io_map_list(drv_conf); + dump_drv_irq_list(drv_conf); + dump_drv_map_secure_list(drv_conf); + dump_drv_map_nosecure_list(drv_conf); + dump_drv_mac_info(drv_conf); + dump_drv_cmd_perm_info(drv_conf); +} +#endif + +static int32_t receive_drv_conf_list(void **list, uint16_t list_size, uint32_t item_size) +{ + if (list == NULL || item_size == 0 || item_size >= MAX_IMAGE_LEN) { + tloge("invalied params while receive drv conf list\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (*list == NULL || list_size == 0) + return TEE_SUCCESS; + + /* list_size < 0xffff means tmp_size cannot larger than 0xFFFFFFFF */ + uint32_t tmp_size = list_size * item_size; + if (tmp_size >= MAX_IMAGE_LEN || list_size * item_size < item_size) { + tloge("tmp size is too large or overflow while receive drv conf list %u\n", item_size); + return TEE_ERROR_BAD_PARAMETERS; + } + + void *tmp_list = malloc(tmp_size); + if (tmp_list == NULL) { + tloge("malloc tmp_list failed\n"); + return TEE_ERROR_GENERIC; + } + + if (copy_from_client((uint64_t)(uintptr_t)(*list), tmp_size, (uintptr_t)tmp_list, tmp_size) != TEE_SUCCESS) { + tloge("copy_from_client tmp_list failed\n"); + free(tmp_list); + return TEE_ERROR_GENERIC; + } + + *list = tmp_list; + + return TEE_SUCCESS; +} + +int32_t do_receive_drv_conf(struct drv_conf_t *drv_conf) +{ + uint32_t receive_flag = 0; + if (drv_conf == NULL) { + tloge("invalid receive param\n"); + return -1; + } + + /* receive drv_conf iomap list */ + if (receive_drv_conf_list((void **)&drv_conf->io_map_list, + drv_conf->io_map_list_size, sizeof(struct addr_region_t)) != 0) + goto err_out; + receive_flag = RECEIVE_IO_MAP_LIST; + + /* receive irq list */ + if (receive_drv_conf_list((void **)&drv_conf->irq_list, + drv_conf->irq_list_size, sizeof(uint64_t)) != 0) + goto err_out; + receive_flag = RECEIVE_IRQ_LIST; + + /* receive map secure list */ + if (receive_drv_conf_list((void **)&drv_conf->map_secure_list, + drv_conf->map_secure_list_size, sizeof(struct drv_map_secure_t)) != 0) + goto err_out; + receive_flag = RECEIVE_MAP_SECURE_LIST; + + /* receive map nosecure list */ + if (receive_drv_conf_list((void **)&drv_conf->map_nosecure_list, + drv_conf->map_nosecure_list_size, sizeof(struct drv_map_nosecure_t)) != 0) + goto err_out; + receive_flag = RECEIVE_MAP_NOSECURE_LIST; + + /* receive mac info list */ + if (receive_drv_conf_list((void **)&drv_conf->mac_info_list, + drv_conf->mac_info_list_size, sizeof(struct drv_mac_info_t)) != 0) + goto err_out; + receive_flag = RECEIVE_MAC_INFO_LIST; + + /* receive cmd perm list */ + if (receive_drv_conf_list((void **)&drv_conf->cmd_perm_list, + drv_conf->cmd_perm_list_size, sizeof(struct drv_cmd_perm_info_t)) != 0) + goto err_out; + + return 0; + +err_out: + free_drv_conf_list(drv_conf, receive_flag); + return -1; +} + +int32_t check_drv_node_state(struct task_node *node) +{ + int32_t func_ret = DRV_FAIL; + + if (node == NULL || node->tlv.drv_conf == NULL) { + tloge("invalid node\n"); + return DRV_FAIL; + } + + int32_t ret = drv_robust_mutex_lock(&node->state_mtx); + if (ret != 0) { + tloge("get state mtx fail\n"); + return DRV_FAIL; + } + + switch (node->state) { + case TASK_LOAD: + node->state = TASK_SPAWN; + func_ret = DRV_NEED_SPAWN; + break; + case TASK_SPAWN: + while (node->state == TASK_SPAWN) { + tloge("drv:%s is spawn by other thread, just wait\n", node->tlv.drv_conf->mani.service_name); + ret = pthread_cond_wait(&node->state_cond, &node->state_mtx); + if (ret != 0) { + tloge("something wrong, drv:%s cond wait fail:0x%x\n", node->tlv.drv_conf->mani.service_name, ret); + goto unlock_mtx; + } + } + + if (node->state == TASK_NORMAL) + func_ret = DRV_SUCC; + else + tloge("something wrong, wait spawn fail state:0x%x\n", node->state); + break; + case TASK_NORMAL: + func_ret = DRV_SUCC; + break; + default: + /* when drv spawn fail, just return fail */ + tloge("something wrong, drv:%s state:%d\n", node->tlv.drv_conf->mani.service_name, node->state); + } + +unlock_mtx: + ret = pthread_mutex_unlock(&node->state_mtx); + if (ret != 0) + tloge("something wrong, unlock mtx in drv state fail\n"); + + return func_ret; +} + +void broadcast_drv_state(struct task_node *node, bool spawn_succ) +{ + if (node == NULL) { + tloge("invalid node\n"); + return; + } + + int32_t ret = drv_robust_mutex_lock(&node->state_mtx); + if (ret != 0) { + tloge("get state mtx fail\n"); + return; + } + + if (node->state != TASK_SPAWN) + tloge("something wrong, node->state:%d not DRV_SPAWN\n", node->state); + + if (spawn_succ) + node->state = TASK_NORMAL; + else + node->state = TASK_SPAWN_FAIL; + + pthread_cond_broadcast(&node->state_cond); + + ret = pthread_mutex_unlock(&node->state_mtx); + if (ret != 0) + tloge("something wrong, unlock stat mtx fail\n"); +} diff --git a/framework/drvmgr/src/drv_dyn_conf_mgr.h b/framework/drvmgr/src/drv_dyn_conf_mgr.h index e569c607..384db0a5 100644 --- a/framework/drvmgr/src/drv_dyn_conf_mgr.h +++ b/framework/drvmgr/src/drv_dyn_conf_mgr.h @@ -1,128 +1,134 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: drv dyn perm info mgr - * Create: 2021-02-03 - */ - -#ifndef DRVMGR_DRV_DYN_CONF_MGR_H -#define DRVMGR_DRV_DYN_CONF_MGR_H - -#include -#include -#include -#include -#include -#include -#include "dyn_conf_common.h" -#include "task_mgr.h" - -struct task_node; - -#define MAX_UUID_SIZE 36 -#define MAX_CMD_SIZE 40 -#define CMD_SET_FLAG 1 - -enum drv_receive_list_tag { - RECEIVE_IO_MAP_LIST = 1, - RECEIVE_IRQ_LIST, - RECEIVE_MAP_SECURE_LIST, - RECEIVE_MAP_NOSECURE_LIST, - RECEIVE_MAC_INFO_LIST, - RECEIVE_CMD_PERM_LIST, - RECEIVE_MAX_TAG -}; - -struct addr_region_t { - uint64_t start; - uint64_t end; -}; - -struct drv_basic_info_t { - uint32_t thread_limit; - bool upgrade; - bool virt2phys; - uint8_t exception_mode; -}; - -struct drv_map_secure_t { - struct tee_uuid uuid; - struct addr_region_t region; -}; - -struct drv_map_nosecure_t { - struct tee_uuid uuid; -}; - -struct drv_mac_info_t { - struct tee_uuid uuid; - uint64_t perm; -}; - -struct drv_conf_t { - struct drv_mani_t mani; - struct drv_basic_info_t drv_basic_info; - union { - struct addr_region_t *io_map_list; - uint64_t tmp_io_map; - }; - union { - uint64_t *irq_list; - uint64_t tmp_irq; - }; - union { - struct drv_map_secure_t *map_secure_list; - uint64_t tmp_map_secure; - }; - union { - struct drv_map_nosecure_t *map_nosecure_list; - uint64_t tmp_nosecure; - }; - union { - struct drv_mac_info_t *mac_info_list; - uint64_t tmp_mac_info; - }; - union { - struct drv_cmd_perm_info_t *cmd_perm_list; - uint64_t tmp_cmd_perm; - }; - uint16_t io_map_list_size; - uint16_t io_map_list_index; - uint16_t irq_list_size; - uint16_t irq_list_index; - uint16_t map_secure_list_size; - uint16_t map_nosecure_list_size; - uint16_t map_nosecure_list_index; - uint16_t mac_info_list_size; - uint16_t mac_info_list_index; /* the index of the newest ava mac */ - uint16_t cmd_perm_list_size; - uint16_t cmd_perm_list_index; /* the index of the newest cmd perm */ -}; - -struct drv_conf_list_t { - struct dlist_node list; - pthread_mutex_t lock; -}; - -struct drv_tlv { - struct tee_uuid uuid; - struct drvcall_perm_apply_t drvcall_perm_apply; - struct drv_conf_t drv_conf; -}; - -enum drv_error { - DRV_FAIL = -1, - DRV_SUCC = 0, - DRV_NEED_SPAWN, - DRV_WAIT, -}; - -#ifdef TEE_SUPPORT_DYN_CONF_DEBUG -void dump_drv_conf(const struct drv_conf_t *drv_conf); -#endif - -void broadcast_drv_state(struct task_node *node, bool spawn_succ); -int32_t check_drv_node_state(struct task_node *node); -int32_t do_receive_drv_conf(struct drv_conf_t *drv_conf); -void free_drv_conf_list(struct drv_conf_t *drv_conf, uint32_t receive_flag); - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#ifndef DRVMGR_DRV_DYN_CONF_MGR_H +#define DRVMGR_DRV_DYN_CONF_MGR_H + +#include +#include +#include +#include +#include +#include +#include "dyn_conf_common.h" +#include "task_mgr.h" + +struct task_node; + +#define MAX_UUID_SIZE 36 +#define MAX_CMD_SIZE 40 +#define CMD_SET_FLAG 1 + +enum drv_receive_list_tag { + RECEIVE_IO_MAP_LIST = 1, + RECEIVE_IRQ_LIST, + RECEIVE_MAP_SECURE_LIST, + RECEIVE_MAP_NOSECURE_LIST, + RECEIVE_MAC_INFO_LIST, + RECEIVE_CMD_PERM_LIST, + RECEIVE_MAX_TAG +}; + +struct addr_region_t { + uint64_t start; + uint64_t end; +}; + +struct drv_basic_info_t { + uint32_t thread_limit; + bool upgrade; + bool virt2phys; + uint8_t exception_mode; +}; + +struct drv_map_secure_t { + struct tee_uuid uuid; + struct addr_region_t region; +}; + +struct drv_map_nosecure_t { + struct tee_uuid uuid; +}; + +struct drv_mac_info_t { + struct tee_uuid uuid; + uint64_t perm; +}; + +struct drv_conf_t { + struct drv_mani_t mani; + struct drv_basic_info_t drv_basic_info; + union { + struct addr_region_t *io_map_list; + uint64_t tmp_io_map; + }; + union { + uint64_t *irq_list; + uint64_t tmp_irq; + }; + union { + struct drv_map_secure_t *map_secure_list; + uint64_t tmp_map_secure; + }; + union { + struct drv_map_nosecure_t *map_nosecure_list; + uint64_t tmp_nosecure; + }; + union { + struct drv_mac_info_t *mac_info_list; + uint64_t tmp_mac_info; + }; + union { + struct drv_cmd_perm_info_t *cmd_perm_list; + uint64_t tmp_cmd_perm; + }; + uint16_t io_map_list_size; + uint16_t io_map_list_index; + uint16_t irq_list_size; + uint16_t irq_list_index; + uint16_t map_secure_list_size; + uint16_t map_nosecure_list_size; + uint16_t map_nosecure_list_index; + uint16_t mac_info_list_size; + uint16_t mac_info_list_index; /* the index of the newest ava mac */ + uint16_t cmd_perm_list_size; + uint16_t cmd_perm_list_index; /* the index of the newest cmd perm */ +}; + +struct drv_conf_list_t { + struct dlist_node list; + pthread_mutex_t lock; +}; + +struct drv_tlv { + struct tee_uuid uuid; + struct drvcall_perm_apply_t drvcall_perm_apply; + struct drv_conf_t drv_conf; +}; + +enum drv_error { + DRV_FAIL = -1, + DRV_SUCC = 0, + DRV_NEED_SPAWN, + DRV_WAIT, +}; + +#ifdef TEE_SUPPORT_DYN_CONF_DEBUG +void dump_drv_conf(const struct drv_conf_t *drv_conf); +#endif + +void broadcast_drv_state(struct task_node *node, bool spawn_succ); +int32_t check_drv_node_state(struct task_node *node); +int32_t do_receive_drv_conf(struct drv_conf_t *drv_conf); +void free_drv_conf_list(struct drv_conf_t *drv_conf, uint32_t receive_flag); + +#endif diff --git a/framework/drvmgr/src/drv_dyn_policy_mgr.c b/framework/drvmgr/src/drv_dyn_policy_mgr.c index a5cd00f3..cfcac6bc 100644 --- a/framework/drvmgr/src/drv_dyn_policy_mgr.c +++ b/framework/drvmgr/src/drv_dyn_policy_mgr.c @@ -1,334 +1,340 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: register drv dyn policy - * Create: 2021-07-22 - */ - -#include "drv_dyn_policy_mgr.h" -#include -#include -#include -#include -#include -#include -#include "task_mgr.h" -#include "dyn_conf_dispatch_inf.h" - -const char g_policy_drv_no_obj[] = -"op:1\n" -"get_uuid:1\n" -"AC_SID_ME:0\n" -; - -static uint32_t get_policy_num(const struct drv_conf_t *drv_conf) -{ - uint32_t ret = 0; - - if (drv_conf == NULL) - return 0; - - if (drv_conf->drv_basic_info.virt2phys) - ret++; - if (drv_conf->io_map_list_size > 0) - ret++; - if (drv_conf->irq_list_size > 0) - ret++; - if (drv_conf->map_secure_list_size > 0) - ret++; - if (drv_conf->map_nosecure_list_size > 0) - ret++; - - return ret; -} - -static void free_dynamic_policy(struct dynamic_policy *policy, uint32_t policy_num) -{ - uint32_t i; - for (i = 0; i < policy_num; i++) { - if (policy[i].objects != NULL) { - free(policy[i].objects); - policy[i].objects = NULL; - } - } - free(policy); -} - -static int32_t do_trans_dynamic_policy_iomap(uint32_t list_size, const void *list, struct dynamic_policy *policy) -{ - uint32_t i; - const struct addr_region_t *io_map_list = (const struct addr_region_t *)list; - for (i = 0; i < list_size; i++) { - policy->objects[i].im_obj.paddr = io_map_list[i].start; - if (io_map_list[i].end <= io_map_list[i].start) { - tloge("io map invalid while trans dynamic policy iomap\n"); - return -1; - } - policy->objects[i].im_obj.size = io_map_list[i].end - io_map_list[i].start; - } - - return 0; -} - -static int32_t do_trans_dynamic_policy_irq(uint32_t list_size, const void *list, struct dynamic_policy *policy) -{ - uint32_t i; - - const uint64_t *irq_list = (const uint64_t *)list; - for (i = 0; i < list_size; i++) { - if (irq_list[i] < IRQ_MIN) { - tloge("irq invalid while trans dynamic policy irq\n"); - return -1; - } - policy->objects[i].ia_obj.irq_no = irq_list[i]; - } - - return 0; -} - -static int32_t do_trans_dynamic_policy_map_secure(uint32_t list_size, const void *list, struct dynamic_policy *policy) -{ - uint32_t i; - const struct drv_map_secure_t *map_secure_list = (const struct drv_map_secure_t *)list; - for (i = 0; i < list_size; i++) { - if (memcpy_s(&policy->objects[i].ms_obj.uuid, sizeof(policy->objects[i].ms_obj.uuid), - &map_secure_list[i].uuid, sizeof(map_secure_list[i].uuid)) != 0) { - tloge("memcpy for uuid failed\n"); - return -1; - } - policy->objects[i].ms_obj.paddr_start = map_secure_list[i].region.start; - policy->objects[i].ms_obj.size = map_secure_list[i].region.end - map_secure_list[i].region.start; - } - - return 0; -} - -static int32_t do_trans_dynamic_policy_map_nosecure(uint32_t list_size, const void *list, struct dynamic_policy *policy) -{ - uint32_t i; - const struct drv_map_nosecure_t *map_nosecure_list = (const struct drv_map_nosecure_t *)list; - for (i = 0; i < list_size; i++) { - if (memcpy_s(&policy->objects[i].mn_obj.uuid, sizeof(policy->objects[i].mn_obj.uuid), - &map_nosecure_list[i].uuid, sizeof(map_nosecure_list[i].uuid)) != 0) { - tloge("memcpy for uuid failed\n"); - return -1; - } - } - - return 0; -} - -static int32_t do_trans_drv_conf_to_dynamic_policy(struct tee_uuid subj_uuid, uint32_t type, - uint32_t list_size, const void *list, - struct dynamic_policy *policy) -{ - if (list == NULL) { - tloge("invalid param in trans to dynamic policy\n"); - return -1; - } - - if (memcpy_s(&policy->subj_uuid, sizeof(policy->subj_uuid), &subj_uuid, sizeof(subj_uuid)) != 0) { - tloge("memcpy for uuid failed\n"); - return -1; - } - - policy->type = type; - policy->obj_cnt = list_size; - - if (list_size >= (MAX_IMAGE_LEN / sizeof(union obj_type))) { - tloge("invalid list size\n"); - return -1; - } - - policy->objects = malloc(list_size * sizeof(union obj_type)); - if (policy->objects == NULL) { - tloge("malloc for uuid failed\n"); - return -1; - } - - switch (type) { - case IO_MAP_TYPE: - if (do_trans_dynamic_policy_iomap(list_size, list, policy) != 0) - goto err_out; - break; - case IRQ_ACQ_TYPE: - if (do_trans_dynamic_policy_irq(list_size, list, policy) != 0) - goto err_out; - break; - case MAP_SEC_TYPE: - if (do_trans_dynamic_policy_map_secure(list_size, list, policy) != 0) - goto err_out; - break; - case MAP_NONSEC_TYPE: - if (do_trans_dynamic_policy_map_nosecure(list_size, list, policy) != 0) - goto err_out; - break; - default: - tloge("unknown type %u\n", type); - goto err_out; - } - - return 0; - -err_out: - free(policy->objects); - policy->objects = NULL; - return -1; -} - -static int32_t do_add_virt2phys_dynamic_policy(struct tee_uuid subj_uuid, uint32_t type, struct dynamic_policy *policy) -{ - if (memcpy_s(&policy->subj_uuid, sizeof(policy->subj_uuid), &subj_uuid, sizeof(subj_uuid)) != 0) { - tloge("memcpy for uuid failed\n"); - return -1; - } - - policy->type = type; - policy->obj_cnt = 0; - policy->objects = NULL; - - return 0; -} - -static int32_t trans_drv_conf_to_dynamic_policy_ex(struct tee_uuid uuid, const struct drv_conf_t *drv_conf, - struct dynamic_policy *policy, uint32_t policy_num) -{ - uint32_t idx = 0; - if (drv_conf->drv_basic_info.virt2phys) { - if (do_add_virt2phys_dynamic_policy(uuid, VIRT2PHY_TYPE, &policy[idx]) != 0) - return -1; - idx++; - } - - if (drv_conf->io_map_list_size > 0 && idx < policy_num) { - if (do_trans_drv_conf_to_dynamic_policy(uuid, IO_MAP_TYPE, drv_conf->io_map_list_size, - drv_conf->io_map_list, &policy[idx]) != 0) - return -1; - idx++; - } - - if (drv_conf->irq_list_size > 0 && idx < policy_num) { - if (do_trans_drv_conf_to_dynamic_policy(uuid, IRQ_ACQ_TYPE, drv_conf->irq_list_size, - drv_conf->irq_list, &policy[idx]) != 0) - return -1; - idx++; - } - - if (drv_conf->map_secure_list_size > 0 && idx < policy_num) { - if (do_trans_drv_conf_to_dynamic_policy(uuid, MAP_SEC_TYPE, drv_conf->map_secure_list_size, - drv_conf->map_secure_list, &policy[idx]) != 0) - return -1; - idx++; - } - - if (drv_conf->map_nosecure_list_size > 0 && idx < policy_num) { - if (do_trans_drv_conf_to_dynamic_policy(uuid, MAP_NONSEC_TYPE, drv_conf->map_nosecure_list_size, - drv_conf->map_nosecure_list, &policy[idx]) != 0) - return -1; - } - - return 0; -} - -static struct dynamic_policy *trans_drv_conf_to_dynamic_policy(const struct task_tlv *tlv, uint32_t policy_num) -{ - uint32_t size = sizeof(struct dynamic_policy) * policy_num; - - if (size >= MAX_IMAGE_LEN) { - tloge("invalid policy num %u\n", policy_num); - return NULL; - } - - struct dynamic_policy *policy = malloc(size); - if (policy == NULL) { - tloge("malloc for policy failed\n"); - return NULL; - } - - if (memset_s(policy, size, 0, size) != 0) { - tloge("memset for policy failed\n"); - free(policy); - return NULL; - } - - if (trans_drv_conf_to_dynamic_policy_ex(tlv->uuid, tlv->drv_conf, policy, policy_num) != 0) { - tloge("trans for dyn policy failed\n"); - goto out; - } - - return policy; - -out: - free_dynamic_policy(policy, policy_num); - return NULL; -} - -int32_t add_dynamic_policy_to_drv(const struct task_tlv *tlv) -{ - if (tlv == NULL) { - tloge("invalid policy tlv param\n"); - return -1; - } - - struct tee_uuid uuid = tlv->uuid; - int32_t ret = ac_add_dynamic_policy(&uuid, g_policy_drv_no_obj, sizeof(g_policy_drv_no_obj) - 1, 0); - if (ret != 0) { - tloge("add policy:%s to drv:0x%x fail:0x%x\n", g_policy_drv_no_obj, uuid.timeLow, ret); - return -1; - } - - tlogd("add policy:%s to drv:0x%x succ\n", g_policy_drv_no_obj, uuid.timeLow); - - uint32_t policy_num = get_policy_num(tlv->drv_conf); - if (policy_num > 0) { - struct dynamic_policy *policy = trans_drv_conf_to_dynamic_policy(tlv, policy_num); - if (policy == NULL) { - tloge("trans drv conf to dynamic policy failed uuid:0x%x fail:0x%x\n", uuid.timeLow, ret); - del_dynamic_policy_to_drv(&tlv->uuid); - return -1; - } - - ret = ac_add_dynamic_policy_ex(policy, policy_num); - if (ret != 0) { - tloge("add policy ex to drv:0x%x fail:0x%x\n", uuid.timeLow, ret); - del_dynamic_policy_to_drv(&tlv->uuid); - } - free_dynamic_policy(policy, policy_num); - } - - return ret; -} - -void del_dynamic_policy_to_drv(const struct tee_uuid *uuid) -{ - if (uuid == NULL) { - tloge("invalid uuid\n"); - return; - } - - int32_t ret = ac_del_dynamic_policy(uuid); - if (ret != 0) - tloge("del drv:0x%x policy fail:0x%x\n", uuid->timeLow, ret); - else - tlogd("release drv:0x%x policy succ\n", uuid->timeLow); -} - -int32_t register_drv_policy(struct task_node *node) -{ - if (node == NULL) { - tloge("register invalid node\n"); - return -1; - } - - if (node->target_type != DRV_TARGET_TYPE) { - tloge("target_type: %d invalid\n", node->target_type); - return -1; - } - - int32_t ret = add_dynamic_policy_to_drv(&node->tlv); - if (ret != 0) - return -1; - - node->drv_task.register_policy = true; - - return 0; -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#include "drv_dyn_policy_mgr.h" +#include +#include +#include +#include +#include +#include +#include "task_mgr.h" +#include "dyn_conf_dispatch_inf.h" + +const char g_policy_drv_no_obj[] = +"op:1\n" +"get_uuid:1\n" +"AC_SID_ME:0\n" +; + +static uint32_t get_policy_num(const struct drv_conf_t *drv_conf) +{ + uint32_t ret = 0; + + if (drv_conf == NULL) + return 0; + + if (drv_conf->drv_basic_info.virt2phys) + ret++; + if (drv_conf->io_map_list_size > 0) + ret++; + if (drv_conf->irq_list_size > 0) + ret++; + if (drv_conf->map_secure_list_size > 0) + ret++; + if (drv_conf->map_nosecure_list_size > 0) + ret++; + + return ret; +} + +static void free_dynamic_policy(struct dynamic_policy *policy, uint32_t policy_num) +{ + uint32_t i; + for (i = 0; i < policy_num; i++) { + if (policy[i].objects != NULL) { + free(policy[i].objects); + policy[i].objects = NULL; + } + } + free(policy); +} + +static int32_t do_trans_dynamic_policy_iomap(uint32_t list_size, const void *list, struct dynamic_policy *policy) +{ + uint32_t i; + const struct addr_region_t *io_map_list = (const struct addr_region_t *)list; + for (i = 0; i < list_size; i++) { + policy->objects[i].im_obj.paddr = io_map_list[i].start; + if (io_map_list[i].end <= io_map_list[i].start) { + tloge("io map invalid while trans dynamic policy iomap\n"); + return -1; + } + policy->objects[i].im_obj.size = io_map_list[i].end - io_map_list[i].start; + } + + return 0; +} + +static int32_t do_trans_dynamic_policy_irq(uint32_t list_size, const void *list, struct dynamic_policy *policy) +{ + uint32_t i; + + const uint64_t *irq_list = (const uint64_t *)list; + for (i = 0; i < list_size; i++) { + if (irq_list[i] < IRQ_MIN) { + tloge("irq invalid while trans dynamic policy irq\n"); + return -1; + } + policy->objects[i].ia_obj.irq_no = irq_list[i]; + } + + return 0; +} + +static int32_t do_trans_dynamic_policy_map_secure(uint32_t list_size, const void *list, struct dynamic_policy *policy) +{ + uint32_t i; + const struct drv_map_secure_t *map_secure_list = (const struct drv_map_secure_t *)list; + for (i = 0; i < list_size; i++) { + if (memcpy_s(&policy->objects[i].ms_obj.uuid, sizeof(policy->objects[i].ms_obj.uuid), + &map_secure_list[i].uuid, sizeof(map_secure_list[i].uuid)) != 0) { + tloge("memcpy for uuid failed\n"); + return -1; + } + policy->objects[i].ms_obj.paddr_start = map_secure_list[i].region.start; + policy->objects[i].ms_obj.size = map_secure_list[i].region.end - map_secure_list[i].region.start; + } + + return 0; +} + +static int32_t do_trans_dynamic_policy_map_nosecure(uint32_t list_size, const void *list, struct dynamic_policy *policy) +{ + uint32_t i; + const struct drv_map_nosecure_t *map_nosecure_list = (const struct drv_map_nosecure_t *)list; + for (i = 0; i < list_size; i++) { + if (memcpy_s(&policy->objects[i].mn_obj.uuid, sizeof(policy->objects[i].mn_obj.uuid), + &map_nosecure_list[i].uuid, sizeof(map_nosecure_list[i].uuid)) != 0) { + tloge("memcpy for uuid failed\n"); + return -1; + } + } + + return 0; +} + +static int32_t do_trans_drv_conf_to_dynamic_policy(struct tee_uuid subj_uuid, uint32_t type, + uint32_t list_size, const void *list, + struct dynamic_policy *policy) +{ + if (list == NULL) { + tloge("invalid param in trans to dynamic policy\n"); + return -1; + } + + if (memcpy_s(&policy->subj_uuid, sizeof(policy->subj_uuid), &subj_uuid, sizeof(subj_uuid)) != 0) { + tloge("memcpy for uuid failed\n"); + return -1; + } + + policy->type = type; + policy->obj_cnt = list_size; + + if (list_size >= (MAX_IMAGE_LEN / sizeof(union obj_type))) { + tloge("invalid list size\n"); + return -1; + } + + policy->objects = malloc(list_size * sizeof(union obj_type)); + if (policy->objects == NULL) { + tloge("malloc for uuid failed\n"); + return -1; + } + + switch (type) { + case IO_MAP_TYPE: + if (do_trans_dynamic_policy_iomap(list_size, list, policy) != 0) + goto err_out; + break; + case IRQ_ACQ_TYPE: + if (do_trans_dynamic_policy_irq(list_size, list, policy) != 0) + goto err_out; + break; + case MAP_SEC_TYPE: + if (do_trans_dynamic_policy_map_secure(list_size, list, policy) != 0) + goto err_out; + break; + case MAP_NONSEC_TYPE: + if (do_trans_dynamic_policy_map_nosecure(list_size, list, policy) != 0) + goto err_out; + break; + default: + tloge("unknown type %u\n", type); + goto err_out; + } + + return 0; + +err_out: + free(policy->objects); + policy->objects = NULL; + return -1; +} + +static int32_t do_add_virt2phys_dynamic_policy(struct tee_uuid subj_uuid, uint32_t type, struct dynamic_policy *policy) +{ + if (memcpy_s(&policy->subj_uuid, sizeof(policy->subj_uuid), &subj_uuid, sizeof(subj_uuid)) != 0) { + tloge("memcpy for uuid failed\n"); + return -1; + } + + policy->type = type; + policy->obj_cnt = 0; + policy->objects = NULL; + + return 0; +} + +static int32_t trans_drv_conf_to_dynamic_policy_ex(struct tee_uuid uuid, const struct drv_conf_t *drv_conf, + struct dynamic_policy *policy, uint32_t policy_num) +{ + uint32_t idx = 0; + if (drv_conf->drv_basic_info.virt2phys) { + if (do_add_virt2phys_dynamic_policy(uuid, VIRT2PHY_TYPE, &policy[idx]) != 0) + return -1; + idx++; + } + + if (drv_conf->io_map_list_size > 0 && idx < policy_num) { + if (do_trans_drv_conf_to_dynamic_policy(uuid, IO_MAP_TYPE, drv_conf->io_map_list_size, + drv_conf->io_map_list, &policy[idx]) != 0) + return -1; + idx++; + } + + if (drv_conf->irq_list_size > 0 && idx < policy_num) { + if (do_trans_drv_conf_to_dynamic_policy(uuid, IRQ_ACQ_TYPE, drv_conf->irq_list_size, + drv_conf->irq_list, &policy[idx]) != 0) + return -1; + idx++; + } + + if (drv_conf->map_secure_list_size > 0 && idx < policy_num) { + if (do_trans_drv_conf_to_dynamic_policy(uuid, MAP_SEC_TYPE, drv_conf->map_secure_list_size, + drv_conf->map_secure_list, &policy[idx]) != 0) + return -1; + idx++; + } + + if (drv_conf->map_nosecure_list_size > 0 && idx < policy_num) { + if (do_trans_drv_conf_to_dynamic_policy(uuid, MAP_NONSEC_TYPE, drv_conf->map_nosecure_list_size, + drv_conf->map_nosecure_list, &policy[idx]) != 0) + return -1; + } + + return 0; +} + +static struct dynamic_policy *trans_drv_conf_to_dynamic_policy(const struct task_tlv *tlv, uint32_t policy_num) +{ + uint32_t size = sizeof(struct dynamic_policy) * policy_num; + + if (size >= MAX_IMAGE_LEN) { + tloge("invalid policy num %u\n", policy_num); + return NULL; + } + + struct dynamic_policy *policy = malloc(size); + if (policy == NULL) { + tloge("malloc for policy failed\n"); + return NULL; + } + + if (memset_s(policy, size, 0, size) != 0) { + tloge("memset for policy failed\n"); + free(policy); + return NULL; + } + + if (trans_drv_conf_to_dynamic_policy_ex(tlv->uuid, tlv->drv_conf, policy, policy_num) != 0) { + tloge("trans for dyn policy failed\n"); + goto out; + } + + return policy; + +out: + free_dynamic_policy(policy, policy_num); + return NULL; +} + +int32_t add_dynamic_policy_to_drv(const struct task_tlv *tlv) +{ + if (tlv == NULL) { + tloge("invalid policy tlv param\n"); + return -1; + } + + struct tee_uuid uuid = tlv->uuid; + int32_t ret = ac_add_dynamic_policy(&uuid, g_policy_drv_no_obj, sizeof(g_policy_drv_no_obj) - 1, 0); + if (ret != 0) { + tloge("add policy:%s to drv:0x%x fail:0x%x\n", g_policy_drv_no_obj, uuid.timeLow, ret); + return -1; + } + + tlogd("add policy:%s to drv:0x%x succ\n", g_policy_drv_no_obj, uuid.timeLow); + + uint32_t policy_num = get_policy_num(tlv->drv_conf); + if (policy_num > 0) { + struct dynamic_policy *policy = trans_drv_conf_to_dynamic_policy(tlv, policy_num); + if (policy == NULL) { + tloge("trans drv conf to dynamic policy failed uuid:0x%x fail:0x%x\n", uuid.timeLow, ret); + del_dynamic_policy_to_drv(&tlv->uuid); + return -1; + } + + ret = ac_add_dynamic_policy_ex(policy, policy_num); + if (ret != 0) { + tloge("add policy ex to drv:0x%x fail:0x%x\n", uuid.timeLow, ret); + del_dynamic_policy_to_drv(&tlv->uuid); + } + free_dynamic_policy(policy, policy_num); + } + + return ret; +} + +void del_dynamic_policy_to_drv(const struct tee_uuid *uuid) +{ + if (uuid == NULL) { + tloge("invalid uuid\n"); + return; + } + + int32_t ret = ac_del_dynamic_policy(uuid); + if (ret != 0) + tloge("del drv:0x%x policy fail:0x%x\n", uuid->timeLow, ret); + else + tlogd("release drv:0x%x policy succ\n", uuid->timeLow); +} + +int32_t register_drv_policy(struct task_node *node) +{ + if (node == NULL) { + tloge("register invalid node\n"); + return -1; + } + + if (node->target_type != DRV_TARGET_TYPE) { + tloge("target_type: %d invalid\n", node->target_type); + return -1; + } + + int32_t ret = add_dynamic_policy_to_drv(&node->tlv); + if (ret != 0) + return -1; + + node->drv_task.register_policy = true; + + return 0; +} diff --git a/framework/drvmgr/src/drv_dyn_policy_mgr.h b/framework/drvmgr/src/drv_dyn_policy_mgr.h index 484ece24..49af1625 100644 --- a/framework/drvmgr/src/drv_dyn_policy_mgr.h +++ b/framework/drvmgr/src/drv_dyn_policy_mgr.h @@ -1,16 +1,22 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: register drv dyn policy - * Create: 2021-07-22 - */ - -#ifndef DRVMGR_SRC_DRV_DYN_POLICY_MGR_H -#define DRVMGR_SRC_DRV_DYN_POLICY_MGR_H - -#include "task_mgr.h" - -int32_t register_drv_policy(struct task_node *node); -void del_dynamic_policy_to_drv(const struct tee_uuid *uuid); -int32_t add_dynamic_policy_to_drv(const struct task_tlv *tlv); - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#ifndef DRVMGR_SRC_DRV_DYN_POLICY_MGR_H +#define DRVMGR_SRC_DRV_DYN_POLICY_MGR_H + +#include "task_mgr.h" + +int32_t register_drv_policy(struct task_node *node); +void del_dynamic_policy_to_drv(const struct tee_uuid *uuid); +int32_t add_dynamic_policy_to_drv(const struct task_tlv *tlv); + +#endif diff --git a/framework/drvmgr/src/drv_fd_ops.c b/framework/drvmgr/src/drv_fd_ops.c index f804ba2e..81e404c0 100644 --- a/framework/drvmgr/src/drv_fd_ops.c +++ b/framework/drvmgr/src/drv_fd_ops.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: define drv fd manager function - * Create: 2021-07-17 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "drv_fd_ops.h" #include diff --git a/framework/drvmgr/src/drv_fd_ops.h b/framework/drvmgr/src/drv_fd_ops.h index 71d2bd36..184c54f1 100644 --- a/framework/drvmgr/src/drv_fd_ops.h +++ b/framework/drvmgr/src/drv_fd_ops.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: declare drv fd manager function - * Create: 2021-07-17 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRVMGR_SRC_DRV_FD_OPS_H #define DRVMGR_SRC_DRV_FD_OPS_H diff --git a/framework/drvmgr/src/drv_index_mgr.c b/framework/drvmgr/src/drv_index_mgr.c index 6cf1ba35..957284da 100644 --- a/framework/drvmgr/src/drv_index_mgr.c +++ b/framework/drvmgr/src/drv_index_mgr.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: define driver index function - * Create: 2021-07-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "drv_index_mgr.h" #include diff --git a/framework/drvmgr/src/drv_index_mgr.h b/framework/drvmgr/src/drv_index_mgr.h index 34067f00..8a268add 100644 --- a/framework/drvmgr/src/drv_index_mgr.h +++ b/framework/drvmgr/src/drv_index_mgr.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: declare driver index function - * Create: 2021-07-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRVMGR_SRC_DRV_INDEX_MGR_H #define DRVMGR_SRC_DRV_INDEX_MGR_H diff --git a/framework/drvmgr/src/drv_ipc_mgr.c b/framework/drvmgr/src/drv_ipc_mgr.c index fcd1d187..a87753df 100644 --- a/framework/drvmgr/src/drv_ipc_mgr.c +++ b/framework/drvmgr/src/drv_ipc_mgr.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: define function send msg to driver process - * Create: 2021-07-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "drv_ipc_mgr.h" #include diff --git a/framework/drvmgr/src/drv_ipc_mgr.h b/framework/drvmgr/src/drv_ipc_mgr.h index c88e86b4..e019d786 100644 --- a/framework/drvmgr/src/drv_ipc_mgr.h +++ b/framework/drvmgr/src/drv_ipc_mgr.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: declare funtion send msg to driver process - * Create: 2021-07-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRVMGR_SRC_DRV_IPC_MGR_H #define DRVMGR_SRC_DRV_IPC_MGR_H diff --git a/framework/drvmgr/src/drv_process_mgr.c b/framework/drvmgr/src/drv_process_mgr.c index 825abd28..61932193 100644 --- a/framework/drvmgr/src/drv_process_mgr.c +++ b/framework/drvmgr/src/drv_process_mgr.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: define driver process spawn or kill function - * Create: 2021-07-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "drv_process_mgr.h" #include diff --git a/framework/drvmgr/src/drv_process_mgr.h b/framework/drvmgr/src/drv_process_mgr.h index c66b90a8..70aeb24d 100644 --- a/framework/drvmgr/src/drv_process_mgr.h +++ b/framework/drvmgr/src/drv_process_mgr.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: define driver so structure and function - * Create: 2021-07-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRVMGR_SRC_DRV_PROCESS_MGR_H #define DRVMGR_SRC_DRV_PROCESS_MGR_H diff --git a/framework/drvmgr/src/drvcall_dyn_conf_mgr.c b/framework/drvmgr/src/drvcall_dyn_conf_mgr.c index b311a828..bb8405cd 100644 --- a/framework/drvmgr/src/drvcall_dyn_conf_mgr.c +++ b/framework/drvmgr/src/drvcall_dyn_conf_mgr.c @@ -1,53 +1,59 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: drv dynamic permission dispatch interface implementation - * Create: 2021-02-03 - */ - -#include "drvcall_dyn_conf_mgr.h" -#include -#include -#include -#include -#include -#include -#include -#include "drv_fd_ops.h" -#include "drv_param_ops.h" -#include "task_mgr.h" - -int32_t receive_perm_apply_list(struct drvcall_perm_apply_t *drvcall_perm_apply) -{ - if (drvcall_perm_apply == NULL) { - tloge("invalid drvcall perm param\n"); - return -1; - } - - if (drvcall_perm_apply->base_perm) - return TEE_SUCCESS; - - if (drvcall_perm_apply->drvcall_perm_apply_list_size == 0 || - drvcall_perm_apply->drvcall_perm_apply_list_size >= MAX_IMAGE_LEN) { - tloge("invalied params while receive perm apply list\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - /* drvcall_perm_apply->drvcall_perm_apply_list_size < MAX_IMAGE_LEN means tmp_size cannot larger than 0xFFFFFFFF */ - uint32_t tmp_size = drvcall_perm_apply->drvcall_perm_apply_list_size * sizeof(struct drvcall_perm_apply_item_t); - struct drvcall_perm_apply_item_t *drvcall_perm_apply_list = malloc(tmp_size); - if (drvcall_perm_apply_list == NULL) { - tloge("malloc drvcall_perm_apply_list failed\n"); - return TEE_ERROR_GENERIC; - } - - if (copy_from_client((uint64_t)(uintptr_t)drvcall_perm_apply->drvcall_perm_apply_list, tmp_size, - (uintptr_t)drvcall_perm_apply_list, tmp_size) != 0) { - tloge("copy_from_client drvcall_perm_apply_list failed\n"); - free(drvcall_perm_apply_list); - return TEE_ERROR_GENERIC; - } - - drvcall_perm_apply->drvcall_perm_apply_list = drvcall_perm_apply_list; - - return TEE_SUCCESS; -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#include "drvcall_dyn_conf_mgr.h" +#include +#include +#include +#include +#include +#include +#include +#include "drv_fd_ops.h" +#include "drv_param_ops.h" +#include "task_mgr.h" + +int32_t receive_perm_apply_list(struct drvcall_perm_apply_t *drvcall_perm_apply) +{ + if (drvcall_perm_apply == NULL) { + tloge("invalid drvcall perm param\n"); + return -1; + } + + if (drvcall_perm_apply->base_perm) + return TEE_SUCCESS; + + if (drvcall_perm_apply->drvcall_perm_apply_list_size == 0 || + drvcall_perm_apply->drvcall_perm_apply_list_size >= MAX_IMAGE_LEN) { + tloge("invalied params while receive perm apply list\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + /* drvcall_perm_apply->drvcall_perm_apply_list_size < MAX_IMAGE_LEN means tmp_size cannot larger than 0xFFFFFFFF */ + uint32_t tmp_size = drvcall_perm_apply->drvcall_perm_apply_list_size * sizeof(struct drvcall_perm_apply_item_t); + struct drvcall_perm_apply_item_t *drvcall_perm_apply_list = malloc(tmp_size); + if (drvcall_perm_apply_list == NULL) { + tloge("malloc drvcall_perm_apply_list failed\n"); + return TEE_ERROR_GENERIC; + } + + if (copy_from_client((uint64_t)(uintptr_t)drvcall_perm_apply->drvcall_perm_apply_list, tmp_size, + (uintptr_t)drvcall_perm_apply_list, tmp_size) != 0) { + tloge("copy_from_client drvcall_perm_apply_list failed\n"); + free(drvcall_perm_apply_list); + return TEE_ERROR_GENERIC; + } + + drvcall_perm_apply->drvcall_perm_apply_list = drvcall_perm_apply_list; + + return TEE_SUCCESS; +} diff --git a/framework/drvmgr/src/drvcall_dyn_conf_mgr.h b/framework/drvmgr/src/drvcall_dyn_conf_mgr.h index 9d3c6641..907c77dc 100644 --- a/framework/drvmgr/src/drvcall_dyn_conf_mgr.h +++ b/framework/drvmgr/src/drvcall_dyn_conf_mgr.h @@ -1,36 +1,42 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: handle drvcall dyn perm info - * Create: 2021-02-03 - */ - -#ifndef DRVMGR_DRVCALL_DYN_CONF_MGR_H -#define DRVMGR_DRVCALL_DYN_CONF_MGR_H - -#include -#include -#include -#include -#include -#include "drv_dispatch.h" -#include "dyn_conf_common.h" - -#define DRVCALL_DEC_CNT_INCLUDE_REGISTER_ONE 2U - -struct drvcall_conf_t { - struct tee_uuid uuid; - struct drvcall_perm_apply_t drvcall_perm_apply; -}; - -struct fd_node { - struct dlist_node data_list; - int64_t fd; - struct task_node *drv; - bool close_flag; -}; - -void dump_all_drvcall_conf(void); - -int32_t receive_perm_apply_list(struct drvcall_perm_apply_t *drvcall_perm_apply); - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#ifndef DRVMGR_DRVCALL_DYN_CONF_MGR_H +#define DRVMGR_DRVCALL_DYN_CONF_MGR_H + +#include +#include +#include +#include +#include +#include "drv_dispatch.h" +#include "dyn_conf_common.h" + +#define DRVCALL_DEC_CNT_INCLUDE_REGISTER_ONE 2U + +struct drvcall_conf_t { + struct tee_uuid uuid; + struct drvcall_perm_apply_t drvcall_perm_apply; +}; + +struct fd_node { + struct dlist_node data_list; + int64_t fd; + struct task_node *drv; + bool close_flag; +}; + +void dump_all_drvcall_conf(void); + +int32_t receive_perm_apply_list(struct drvcall_perm_apply_t *drvcall_perm_apply); + +#endif diff --git a/framework/drvmgr/src/dyn_conf_common.h b/framework/drvmgr/src/dyn_conf_common.h index 3093ea60..a904fb9f 100644 --- a/framework/drvmgr/src/dyn_conf_common.h +++ b/framework/drvmgr/src/dyn_conf_common.h @@ -1,38 +1,44 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: drv and drvcall dynamic permission common header - * Create: 2021-02-03 - */ -#ifndef DRVMGR_DYN_CONF_COMMON_H -#define DRVMGR_DYN_CONF_COMMON_H - -#include -#include -#include - -struct drv_mani_t { - struct tee_uuid srv_uuid; - char service_name[DRV_NAME_MAX_LEN + 1]; - uint32_t service_name_size; - bool keep_alive; - uint32_t data_size; - uint32_t stack_size; - uint16_t hardware_type; -}; - -struct drvcall_perm_apply_item_t { - char name[DRV_NAME_MAX_LEN + 1]; - uint32_t name_size; - uint64_t perm; -}; - -struct drvcall_perm_apply_t { - union { - struct drvcall_perm_apply_item_t *drvcall_perm_apply_list; /* drvcall_perm_apply items list */ - uint64_t temp_drvcall_perm_list; - }; - uint32_t drvcall_perm_apply_list_size; - bool base_perm; -}; - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef DRVMGR_DYN_CONF_COMMON_H +#define DRVMGR_DYN_CONF_COMMON_H + +#include +#include +#include + +struct drv_mani_t { + struct tee_uuid srv_uuid; + char service_name[DRV_NAME_MAX_LEN + 1]; + uint32_t service_name_size; + bool keep_alive; + uint32_t data_size; + uint32_t stack_size; + uint16_t hardware_type; +}; + +struct drvcall_perm_apply_item_t { + char name[DRV_NAME_MAX_LEN + 1]; + uint32_t name_size; + uint64_t perm; +}; + +struct drvcall_perm_apply_t { + union { + struct drvcall_perm_apply_item_t *drvcall_perm_apply_list; /* drvcall_perm_apply items list */ + uint64_t temp_drvcall_perm_list; + }; + uint32_t drvcall_perm_apply_list_size; + bool base_perm; +}; + +#endif diff --git a/framework/drvmgr/src/main.c b/framework/drvmgr/src/main.c index 5c8a5490..fd3e9536 100644 --- a/framework/drvmgr/src/main.c +++ b/framework/drvmgr/src/main.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: define drv main function - * Create: 2021-03-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/framework/drvmgr/src/task_mgr.c b/framework/drvmgr/src/task_mgr.c index d3cf6ba2..2039c9b7 100644 --- a/framework/drvmgr/src/task_mgr.c +++ b/framework/drvmgr/src/task_mgr.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: drvcaller and drv node operation - * Create: 2021-12-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "task_mgr.h" diff --git a/framework/drvmgr/src/task_mgr.h b/framework/drvmgr/src/task_mgr.h index 1a34d2ea..1b3c9353 100644 --- a/framework/drvmgr/src/task_mgr.h +++ b/framework/drvmgr/src/task_mgr.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: drvcaller and drv node structure - * Create: 2021-12-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRVMGR_TASK_MGR_H diff --git a/framework/gtask/Makefile b/framework/gtask/Makefile index 47376852..ccd7c057 100644 --- a/framework/gtask/Makefile +++ b/framework/gtask/Makefile @@ -1,4 +1,12 @@ -# Copyright Huawei Technologies Co., Ltd. 2010-2019. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # TARGET is an app diff --git a/framework/gtask/src/app_load/dynload.c b/framework/gtask/src/app_load/dynload.c index c9a0d1eb..5b975665 100644 --- a/framework/gtask/src/app_load/dynload.c +++ b/framework/gtask/src/app_load/dynload.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: TEE enviroment's agent manager of framework Implemention - * Author: Zhangdeyao zhangdeyao@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "dynload.h" #include diff --git a/framework/gtask/src/app_load/dynload.h b/framework/gtask/src/app_load/dynload.h index b490c048..d808ce78 100644 --- a/framework/gtask/src/app_load/dynload.h +++ b/framework/gtask/src/app_load/dynload.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: DYNLOAD function declaration. - * Author: yangjing y00416812 - * Create: 2019-04-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __DYN_LOAD_H_ diff --git a/framework/gtask/src/app_load/initlib.c b/framework/gtask/src/app_load/initlib.c index 8325466a..a1988a83 100644 --- a/framework/gtask/src/app_load/initlib.c +++ b/framework/gtask/src/app_load/initlib.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: init libs for gtask - * Author: QiShuai qishuai@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/framework/gtask/src/app_load/initlib.h b/framework/gtask/src/app_load/initlib.h index 1f06c5ca..ab0b69ec 100644 --- a/framework/gtask/src/app_load/initlib.h +++ b/framework/gtask/src/app_load/initlib.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: for global task unpack internal tasks. - * Author: Zhangdeyao zhangdeyao@huawei.com - * Create: 2022-8-10 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef _TEE_INITLIB_H diff --git a/framework/gtask/src/app_load/load_app_comm.c b/framework/gtask/src/app_load/load_app_comm.c index 7e21ed05..73a4c17a 100644 --- a/framework/gtask/src/app_load/load_app_comm.c +++ b/framework/gtask/src/app_load/load_app_comm.c @@ -1,13 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app image common interface load service - * Create: 2022.8.10 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "load_app_comm.h" #include diff --git a/framework/gtask/src/app_load/load_app_comm.h b/framework/gtask/src/app_load/load_app_comm.h index d9cf52f6..75aab8a4 100644 --- a/framework/gtask/src/app_load/load_app_comm.h +++ b/framework/gtask/src/app_load/load_app_comm.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: load app common interface. - * Create: 2022-08-10 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef APP_LOAD_SRV_SUPPORT_COMMON_H #define APP_LOAD_SRV_SUPPORT_COMMON_H diff --git a/framework/gtask/src/app_load/load_v3_app.c b/framework/gtask/src/app_load/load_v3_app.c index 6dcedf2c..9e18296b 100644 --- a/framework/gtask/src/app_load/load_v3_app.c +++ b/framework/gtask/src/app_load/load_v3_app.c @@ -1,13 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app image version3 load service - * Create: 2022.8.10 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "load_v3_app.h" #include diff --git a/framework/gtask/src/app_load/load_v3_app.h b/framework/gtask/src/app_load/load_v3_app.h index 9058489d..69c2c0cf 100644 --- a/framework/gtask/src/app_load/load_v3_app.h +++ b/framework/gtask/src/app_load/load_v3_app.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: load app version3 interface. - * Create: 2022-08-10 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef APP_LOAD_SRV_SUPPORT_V3_H #define APP_LOAD_SRV_SUPPORT_V3_H diff --git a/framework/gtask/src/app_load/tee_app_load_srv.c b/framework/gtask/src/app_load/tee_app_load_srv.c index 5e89b7be..26239f9d 100644 --- a/framework/gtask/src/app_load/tee_app_load_srv.c +++ b/framework/gtask/src/app_load/tee_app_load_srv.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved. - * Description: tee app image load service - * Author: Li Mingjuan limingjuan@huawei.com - * Create: 2012.5.20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_app_load_srv.h" #include diff --git a/framework/gtask/src/app_load/tee_app_load_srv.h b/framework/gtask/src/app_load/tee_app_load_srv.h index 0287b47b..058a1af3 100644 --- a/framework/gtask/src/app_load/tee_app_load_srv.h +++ b/framework/gtask/src/app_load/tee_app_load_srv.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved. - * Description: tee app image load service head file - * Author: Lu Chenggang luchenggang@huawei.com - * Create: 2012.5.20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TEE_APP_LOAD_SRV_H #define GTASK_TEE_APP_LOAD_SRV_H diff --git a/framework/gtask/src/app_load/tee_load_lib.c b/framework/gtask/src/app_load/tee_load_lib.c index 36ac3718..c12ccb4e 100644 --- a/framework/gtask/src/app_load/tee_load_lib.c +++ b/framework/gtask/src/app_load/tee_load_lib.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: Tee-load-lib function declaration. - * Author: yangjing y00416812 - * Create: 2019-04-04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_load_lib.h" #include diff --git a/framework/gtask/src/app_load/tee_load_lib.h b/framework/gtask/src/app_load/tee_load_lib.h index a080fc7e..87d064fd 100644 --- a/framework/gtask/src/app_load/tee_load_lib.h +++ b/framework/gtask/src/app_load/tee_load_lib.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: Tee-load-lib function declaration. - * Author: yangjing y00416812 - * Create: 2019-04-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TEE_LOAD_LIB_H diff --git a/framework/gtask/src/framework/ext_interface.c b/framework/gtask/src/framework/ext_interface.c index 180e7b10..f2afd8a0 100644 --- a/framework/gtask/src/framework/ext_interface.c +++ b/framework/gtask/src/framework/ext_interface.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: TEE enviroment's ext interface of framework Implemention - * Author: Zhangdeyao zhangdeyao@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/framework/gtask/src/framework/ext_interface.h b/framework/gtask/src/framework/ext_interface.h index 318a3e72..98e2b10f 100644 --- a/framework/gtask/src/framework/ext_interface.h +++ b/framework/gtask/src/framework/ext_interface.h @@ -1,13 +1,19 @@ -/* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: used by ext_interface. - * Author: yangboyu y30022050 - * Create: 2022-04-24 - */ -#ifndef GTASK_EXT_INTERFACE_H -#define GTASK_EXT_INTERFACE_H - -TEE_Result map_rdr_mem(const smc_cmd_t *cmd); -int32_t handle_info_query(uint32_t cmd_id, uint32_t task_id, - const uint8_t *msg_buf, uint32_t msg_size); - -#endif /* GTASK_EXT_INTERFACE_H */ +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef GTASK_EXT_INTERFACE_H +#define GTASK_EXT_INTERFACE_H + +TEE_Result map_rdr_mem(const smc_cmd_t *cmd); +int32_t handle_info_query(uint32_t cmd_id, uint32_t task_id, + const uint8_t *msg_buf, uint32_t msg_size); + +#endif /* GTASK_EXT_INTERFACE_H */ diff --git a/framework/gtask/src/framework/global_task.c b/framework/gtask/src/framework/global_task.c index 9fa0ed57..33b01e55 100644 --- a/framework/gtask/src/framework/global_task.c +++ b/framework/gtask/src/framework/global_task.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: TEE's dispatch service - * Author: Zhangdeyao zhangdeyao@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/framework/gtask/src/framework/global_task.h b/framework/gtask/src/framework/global_task.h index f1167312..089ba7af 100644 --- a/framework/gtask/src/framework/global_task.h +++ b/framework/gtask/src/framework/global_task.h @@ -1,25 +1,30 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: TEE's dispatch service - * Author: QiShuai qishuai@huawei.com - * Create: 2019-12-20 - */ - -#ifndef GLOBAL_TASK_H -#define GLOBAL_TASK_H - -#include "ta_framework.h" -#include "gtask_inner.h" - -void gtask_main(void); -int put_last_out_cmd(const smc_cmd_t *cmd); -TEE_Result get_tee_version(const smc_cmd_t *cmd); -TEE_Result process_load_image(smc_cmd_t *cmd, bool *async); -TEE_Result process_ta_common_cmd(smc_cmd_t *cmd, uint32_t cmd_type, uint32_t task_id, bool *async, - const struct ta2ta_info_t *ta2ta_info); -TEE_Result handle_time_adjust(const smc_cmd_t *cmd); -void ns_cmd_response(smc_cmd_t *cmd); -bool is_abort_cmd(const smc_cmd_t *cmd); -void restore_cmd_in(const smc_cmd_t *cmd); - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#ifndef GLOBAL_TASK_H +#define GLOBAL_TASK_H + +#include "ta_framework.h" +#include "gtask_inner.h" + +void gtask_main(void); +int put_last_out_cmd(const smc_cmd_t *cmd); +TEE_Result get_tee_version(const smc_cmd_t *cmd); +TEE_Result process_load_image(smc_cmd_t *cmd, bool *async); +TEE_Result process_ta_common_cmd(smc_cmd_t *cmd, uint32_t cmd_type, uint32_t task_id, bool *async, + const struct ta2ta_info_t *ta2ta_info); +TEE_Result handle_time_adjust(const smc_cmd_t *cmd); +void ns_cmd_response(smc_cmd_t *cmd); +bool is_abort_cmd(const smc_cmd_t *cmd); +void restore_cmd_in(const smc_cmd_t *cmd); + +#endif diff --git a/framework/gtask/src/framework/gtask_adapt.c b/framework/gtask/src/framework/gtask_adapt.c index bc1bbb20..22b42ca3 100644 --- a/framework/gtask/src/framework/gtask_adapt.c +++ b/framework/gtask/src/framework/gtask_adapt.c @@ -1,13 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ -/* Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: Make gtask be compatible to handle 64bit TA and 32bit TA. - * Author: heyanhong h00424236 - * Create: 2019-04-12 +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "gtask_adapt.h" #include diff --git a/framework/gtask/src/framework/tee_compat_check.c b/framework/gtask/src/framework/tee_compat_check.c index 5af8ab5c..4f110a7a 100644 --- a/framework/gtask/src/framework/tee_compat_check.c +++ b/framework/gtask/src/framework/tee_compat_check.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: for check compatibility between tzdriver and tee - * Author: lipeng - * Create: 2021-7-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_compat_check.h" diff --git a/framework/gtask/src/framework/tee_compat_check.h b/framework/gtask/src/framework/tee_compat_check.h index 5922a990..dd3906e7 100644 --- a/framework/gtask/src/framework/tee_compat_check.h +++ b/framework/gtask/src/framework/tee_compat_check.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: for check compatibility between tzdriver and tee - * Author: lipeng - * Create: 2021-7-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_COMPAT_CHECK_H diff --git a/framework/gtask/src/framework/tee_ns_cmd_dispatch.c b/framework/gtask/src/framework/tee_ns_cmd_dispatch.c index 98bf2c3c..cf15f3da 100644 --- a/framework/gtask/src/framework/tee_ns_cmd_dispatch.c +++ b/framework/gtask/src/framework/tee_ns_cmd_dispatch.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: dispatch cmd from ree - * Author: lipeng - * Create: 2020-12-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_ns_cmd_dispatch.h" #include "tee_common.h" diff --git a/framework/gtask/src/framework/tee_ns_cmd_dispatch.h b/framework/gtask/src/framework/tee_ns_cmd_dispatch.h index 0e2d6588..f268b34d 100644 --- a/framework/gtask/src/framework/tee_ns_cmd_dispatch.h +++ b/framework/gtask/src/framework/tee_ns_cmd_dispatch.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: dispatch cmd from ree - * Author: lipeng - * Create: 2020-12-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_NS_CMD_DISPATCH_H diff --git a/framework/gtask/src/framework/tee_s_cmd_dispatch.c b/framework/gtask/src/framework/tee_s_cmd_dispatch.c index 5333d752..e1410664 100644 --- a/framework/gtask/src/framework/tee_s_cmd_dispatch.c +++ b/framework/gtask/src/framework/tee_s_cmd_dispatch.c @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. - * Description: dispatch secure cmd from TA or tee service - * Author: lipeng - * Create: 2022-4-24 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_s_cmd_dispatch.h" #include diff --git a/framework/gtask/src/framework/tee_s_cmd_dispatch.h b/framework/gtask/src/framework/tee_s_cmd_dispatch.h index 76fc414e..990046ad 100644 --- a/framework/gtask/src/framework/tee_s_cmd_dispatch.h +++ b/framework/gtask/src/framework/tee_s_cmd_dispatch.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. - * Description: dispatch secure cmd from TA or tee service - * Author: lipeng - * Create: 2022-4-24 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_S_CMD_DISPATCH_H diff --git a/framework/gtask/src/framework/tee_task.c b/framework/gtask/src/framework/tee_task.c index eaabf30c..c227a7ab 100644 --- a/framework/gtask/src/framework/tee_task.c +++ b/framework/gtask/src/framework/tee_task.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: tee task runtime - * Author: QiShuai qishuai@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_task.h" diff --git a/framework/gtask/src/framework/tee_task.h b/framework/gtask/src/framework/tee_task.h index 1022f680..8e12cc2f 100644 --- a/framework/gtask/src/framework/tee_task.h +++ b/framework/gtask/src/framework/tee_task.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: gtask task operation - * Create: 2019-11-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TEE_TAK_H #define GTASK_TEE_TAK_H diff --git a/framework/gtask/src/framework/tee_task_exception.c b/framework/gtask/src/framework/tee_task_exception.c index ef889bd0..72dd564d 100644 --- a/framework/gtask/src/framework/tee_task_exception.c +++ b/framework/gtask/src/framework/tee_task_exception.c @@ -1,14 +1,13 @@ -/* $$$!!Warning: Huawei key information asset. No spread without permission.$$$ */ -/* CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==# */ -/* $$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$ */ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: process tee task exception, include TA & internal service - * Author: lipeng - * Create: 2020-09-30 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_task_exception.h" #include diff --git a/framework/gtask/src/framework/tee_task_exception.h b/framework/gtask/src/framework/tee_task_exception.h index ecf0f8af..32767177 100644 --- a/framework/gtask/src/framework/tee_task_exception.h +++ b/framework/gtask/src/framework/tee_task_exception.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: process tee task exception, include TA & internal service - * Author: lipeng - * Create: 2020-09-30 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_TASK_EXCEPTION_H diff --git a/framework/gtask/src/framework/uuid2path.c b/framework/gtask/src/framework/uuid2path.c index d4a4101f..9021ae34 100644 --- a/framework/gtask/src/framework/uuid2path.c +++ b/framework/gtask/src/framework/uuid2path.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: change uuid to path - * Author: QiShuai qishuai@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/framework/gtask/src/framework/uuid2path.h b/framework/gtask/src/framework/uuid2path.h index 139763a2..72cb6bec 100644 --- a/framework/gtask/src/framework/uuid2path.h +++ b/framework/gtask/src/framework/uuid2path.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: uuid2path function declaration. - * Author: yangjing y00416812 - * Create: 2019-04-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __UUID_TO_PATH_H_ diff --git a/framework/gtask/src/gtask_config.c b/framework/gtask/src/gtask_config.c index db86b81e..b51287ec 100644 --- a/framework/gtask/src/gtask_config.c +++ b/framework/gtask/src/gtask_config.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: gtask configs - * Create: 2022-04-27 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "gtask_config.h" #include "tee_config.h" diff --git a/framework/gtask/src/gtask_config.h b/framework/gtask/src/gtask_config.h index 36a692cc..8cb39d1c 100644 --- a/framework/gtask/src/gtask_config.h +++ b/framework/gtask/src/gtask_config.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: some functions declaration in config - * Create: 2022-04-27 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_CONFIG_H #define GTASK_CONFIG_H diff --git a/framework/gtask/src/gtask_config_hal.c b/framework/gtask/src/gtask_config_hal.c index 759f8ccc..317c4d26 100644 --- a/framework/gtask/src/gtask_config_hal.c +++ b/framework/gtask/src/gtask_config_hal.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: gtask config implementation - * Create: 2022-04-27 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "gtask_config_hal.h" #include "gtask_config.h" diff --git a/framework/gtask/src/gtask_config_hal.h b/framework/gtask/src/gtask_config_hal.h index 56de3df1..f9308dff 100644 --- a/framework/gtask/src/gtask_config_hal.h +++ b/framework/gtask/src/gtask_config_hal.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: some functions declaration in config - * Create: 2022-04-21 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_CONFIG_HAL_H diff --git a/framework/gtask/src/gtask_para_config.c b/framework/gtask/src/gtask_para_config.c index c886e986..2bb53f51 100644 --- a/framework/gtask/src/gtask_para_config.c +++ b/framework/gtask/src/gtask_para_config.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: gtask config API - * Create: 2020-09 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "gtask_para_config.h" diff --git a/framework/gtask/src/gtask_para_config.h b/framework/gtask/src/gtask_para_config.h index e07fd7cf..95d47ff9 100644 --- a/framework/gtask/src/gtask_para_config.h +++ b/framework/gtask/src/gtask_para_config.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: gtask config API - * Create: 2020-09 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_PARA_CONFIG_H #define GTASK_PARA_CONFIG_H diff --git a/framework/gtask/src/include/gtask_adapt.h b/framework/gtask/src/include/gtask_adapt.h index 09e9e008..f8547c32 100644 --- a/framework/gtask/src/include/gtask_adapt.h +++ b/framework/gtask/src/include/gtask_adapt.h @@ -1,7 +1,13 @@ -/* Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: Make gtask be compatible to handle 64bit TA and 32bit TA. - * Author: heyanhong h00424236 - * Create: 2019-04-12 +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __GTASK_ADAPT_H diff --git a/framework/gtask/src/include/gtask_core.h b/framework/gtask/src/include/gtask_core.h index dc7b8f02..8205b041 100644 --- a/framework/gtask/src/include/gtask_core.h +++ b/framework/gtask/src/include/gtask_core.h @@ -1,7 +1,13 @@ -/* Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: Make gtask be compatible to handle 64bit TA and 32bit TA. - * Author: heyanhong h00424236 - * Create: 2019-04-12 +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __GTASK_CORE_H_ #define __GTASK_CORE_H_ diff --git a/framework/gtask/src/include/gtask_inner.h b/framework/gtask/src/include/gtask_inner.h index b83692d3..55d84d08 100644 --- a/framework/gtask/src/include/gtask_inner.h +++ b/framework/gtask/src/include/gtask_inner.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: only used by gtask - * Author: h00424236 - * Create: 2019-09-09 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_CORE_GTASK_INNER_H #define GTASK_CORE_GTASK_INNER_H diff --git a/framework/gtask/src/include/gtask_msg.h b/framework/gtask/src/include/gtask_msg.h index e19dac48..e8e86b51 100644 --- a/framework/gtask/src/include/gtask_msg.h +++ b/framework/gtask/src/include/gtask_msg.h @@ -1,7 +1,13 @@ -/* Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: Make gtask be compatible to handle 64bit TA and 32bit TA. - * Author: heyanhong h00424236 - * Create: 2019-04-12 +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __GTASK_MSG_H_ #define __GTASK_MSG_H_ diff --git a/framework/gtask/src/init/init.c b/framework/gtask/src/init/init.c index 07f11da4..c2b10683 100644 --- a/framework/gtask/src/init/init.c +++ b/framework/gtask/src/init/init.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: init for gtask - * Author: QiShuai qishuai@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "init.h" diff --git a/framework/gtask/src/init/init.h b/framework/gtask/src/init/init.h index d1c0108c..595bd416 100644 --- a/framework/gtask/src/init/init.h +++ b/framework/gtask/src/init/init.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Reference of TEE internal api and internal definitions - * Author: Zhangdeyao zhangdeyao@huawei.com - * Create: 2020-01-06 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_INIT_H diff --git a/framework/gtask/src/init/main.c b/framework/gtask/src/init/main.c index dce79316..2212ffd8 100644 --- a/framework/gtask/src/init/main.c +++ b/framework/gtask/src/init/main.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: main for gtask - * Author: QiShuai qishuai@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/framework/gtask/src/manager/agent_manager.c b/framework/gtask/src/manager/agent_manager.c index 0f28a41a..580a099b 100644 --- a/framework/gtask/src/manager/agent_manager.c +++ b/framework/gtask/src/manager/agent_manager.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: TEE enviroment's agent manager of framework Implemention - * Author: Zhangdeyao zhangdeyao@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/framework/gtask/src/manager/agent_manager.h b/framework/gtask/src/manager/agent_manager.h index 6101e733..17228838 100644 --- a/framework/gtask/src/manager/agent_manager.h +++ b/framework/gtask/src/manager/agent_manager.h @@ -1,27 +1,33 @@ -/* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: used by agent_manager. - * Author: yangboyu y30022050 - * Create: 2022-04-24 - */ -#ifndef GTASK_AGENT_MANAGER_H -#define GTASK_AGENT_MANAGER_H - -#include -#include "gtask_core.h" - -TEE_Result register_agent(const smc_cmd_t *cmd); -TEE_Result unregister_agent(const smc_cmd_t *cmd); -TEE_Result agent_late_init(const smc_cmd_t *cmd); -TEE_Result tee_get_agent_buffer(uint32_t agent_id, paddr_t *buffer, uint32_t *length); -void tee_unlock_agents(struct session_struct *session); -void agent_manager_init(void); -void register_agent_buffer_to_task(uint32_t agent_id, uint32_t dest_task_id); -TEE_Result set_service_thread_cmd(const smc_cmd_t *cmd, bool *async); -bool service_thread_request_dequeue(const smc_cmd_t *in, smc_cmd_t *out); - -int32_t handle_agent_request(uint32_t cmd_id, uint32_t task_id, - const uint8_t *msg_buf, uint32_t msg_size); -int32_t handle_service_agent_back_cmd(const smc_cmd_t *cmd); -int32_t handle_ta_agent_back_cmd(smc_cmd_t *cmd); - -#endif /* GTASK_AGENT_MANAGER_H */ +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef GTASK_AGENT_MANAGER_H +#define GTASK_AGENT_MANAGER_H + +#include +#include "gtask_core.h" + +TEE_Result register_agent(const smc_cmd_t *cmd); +TEE_Result unregister_agent(const smc_cmd_t *cmd); +TEE_Result agent_late_init(const smc_cmd_t *cmd); +TEE_Result tee_get_agent_buffer(uint32_t agent_id, paddr_t *buffer, uint32_t *length); +void tee_unlock_agents(struct session_struct *session); +void agent_manager_init(void); +void register_agent_buffer_to_task(uint32_t agent_id, uint32_t dest_task_id); +TEE_Result set_service_thread_cmd(const smc_cmd_t *cmd, bool *async); +bool service_thread_request_dequeue(const smc_cmd_t *in, smc_cmd_t *out); + +int32_t handle_agent_request(uint32_t cmd_id, uint32_t task_id, + const uint8_t *msg_buf, uint32_t msg_size); +int32_t handle_service_agent_back_cmd(const smc_cmd_t *cmd); +int32_t handle_ta_agent_back_cmd(smc_cmd_t *cmd); + +#endif /* GTASK_AGENT_MANAGER_H */ diff --git a/framework/gtask/src/manager/mem_manager.c b/framework/gtask/src/manager/mem_manager.c index 97cd111a..42634629 100644 --- a/framework/gtask/src/manager/mem_manager.c +++ b/framework/gtask/src/manager/mem_manager.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: TEE enviroment's memory manager of framework Implemention - * Author: Zhangdeyao zhangdeyao@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/framework/gtask/src/manager/mem_manager.h b/framework/gtask/src/manager/mem_manager.h index eca7d0c5..eaee018d 100644 --- a/framework/gtask/src/manager/mem_manager.h +++ b/framework/gtask/src/manager/mem_manager.h @@ -1,37 +1,43 @@ -/* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: used by mem_manager. - * Author: yangboyu y30022050 - * Create: 2022-04-24 - */ -#ifndef GTASK_MEM_MANAGER_H -#define GTASK_MEM_MANAGER_H - -#include -#include "gtask_core.h" - -TEE_Result cmd_ns_get_params(uint32_t task_id, const smc_cmd_t *cmd, uint32_t *param_type, uint64_t *params); -TEE_Result cmd_secure_get_params(uint32_t task_id, const smc_cmd_t *cmd, uint32_t *param_type, uint64_t *params); -TEE_Result cmd_global_ns_get_params(const smc_cmd_t *cmd, uint32_t *param_type, TEE_Param **params); -TEE_Result map_ns_operation(const smc_cmd_t *cmd); -TEE_Result unmap_ns_operation(smc_cmd_t *cmd); -void *map_ns_cmd(paddr_t cmd_phy); -TEE_Result map_secure_operation(uint64_t tacmd, smc_cmd_t *out_cmd, uint32_t task_id); -TEE_Result unmap_secure_operation(const smc_cmd_t *cmd); -void mem_manager_init(void); -TEE_Result store_s_cmd(const smc_cmd_t *cmd); -TEE_Result copy_pam_to_src(uint32_t cmd_id, bool ta2ta); -TEE_Result register_mailbox(const smc_cmd_t *cmd); -bool in_mailbox_range(paddr_t addr, uint32_t size); -TEE_Result check_cmd_in_mailbox_range(const smc_cmd_t *cmd); -void *mailbox_phys_to_virt(paddr_t phys); -TEE_Result register_res_mem(const smc_cmd_t *cmd); -bool in_res_mem_range(paddr_t addr, uint64_t size); -void *res_mem_phys_to_virt(paddr_t phys); -TEE_Result dump_statmeminfo(const smc_cmd_t *cmd); -void task_del_mem_region(struct dlist_node *mem_list, bool is_service_dead); - -bool is_opensession_cmd(const smc_cmd_t *cmd); -void release_pam_node(struct pam_node *node); -bool check_short_buffer(void); - -#endif /* GTASK_MEM_MANAGER_H */ +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef GTASK_MEM_MANAGER_H +#define GTASK_MEM_MANAGER_H + +#include +#include "gtask_core.h" + +TEE_Result cmd_ns_get_params(uint32_t task_id, const smc_cmd_t *cmd, uint32_t *param_type, uint64_t *params); +TEE_Result cmd_secure_get_params(uint32_t task_id, const smc_cmd_t *cmd, uint32_t *param_type, uint64_t *params); +TEE_Result cmd_global_ns_get_params(const smc_cmd_t *cmd, uint32_t *param_type, TEE_Param **params); +TEE_Result map_ns_operation(const smc_cmd_t *cmd); +TEE_Result unmap_ns_operation(smc_cmd_t *cmd); +void *map_ns_cmd(paddr_t cmd_phy); +TEE_Result map_secure_operation(uint64_t tacmd, smc_cmd_t *out_cmd, uint32_t task_id); +TEE_Result unmap_secure_operation(const smc_cmd_t *cmd); +void mem_manager_init(void); +TEE_Result store_s_cmd(const smc_cmd_t *cmd); +TEE_Result copy_pam_to_src(uint32_t cmd_id, bool ta2ta); +TEE_Result register_mailbox(const smc_cmd_t *cmd); +bool in_mailbox_range(paddr_t addr, uint32_t size); +TEE_Result check_cmd_in_mailbox_range(const smc_cmd_t *cmd); +void *mailbox_phys_to_virt(paddr_t phys); +TEE_Result register_res_mem(const smc_cmd_t *cmd); +bool in_res_mem_range(paddr_t addr, uint64_t size); +void *res_mem_phys_to_virt(paddr_t phys); +TEE_Result dump_statmeminfo(const smc_cmd_t *cmd); +void task_del_mem_region(struct dlist_node *mem_list, bool is_service_dead); + +bool is_opensession_cmd(const smc_cmd_t *cmd); +void release_pam_node(struct pam_node *node); +bool check_short_buffer(void); + +#endif /* GTASK_MEM_MANAGER_H */ diff --git a/framework/gtask/src/manager/notify_manager.c b/framework/gtask/src/manager/notify_manager.c index 80ac755e..bf1caa04 100644 --- a/framework/gtask/src/manager/notify_manager.c +++ b/framework/gtask/src/manager/notify_manager.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: TEE enviroment's notify manager of framework Implemention - * Author: Zhangdeyao zhangdeyao@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/framework/gtask/src/manager/notify_manager.h b/framework/gtask/src/manager/notify_manager.h index f4d5b375..fc9a5beb 100644 --- a/framework/gtask/src/manager/notify_manager.h +++ b/framework/gtask/src/manager/notify_manager.h @@ -1,16 +1,22 @@ -/* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: used by notify_manager. - * Author: yangboyu y30022050 - * Create: 2022-04-24 - */ -#ifndef GTASK_NOTIFY_MANAGER_H -#define GTASK_NOTIFY_MANAGER_H - -#include "sys_timer.h" // timer_private_data_kernel - -#define NOTIFY_MEM_SIZE (4 * 1024) - -TEE_Result register_notify_memery(const smc_cmd_t *cmd); -struct notify_data_struct *get_notify_data(void); - -#endif /* GTASK_NOTIFY_MANAGER_H */ +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef GTASK_NOTIFY_MANAGER_H +#define GTASK_NOTIFY_MANAGER_H + +#include "sys_timer.h" // timer_private_data_kernel + +#define NOTIFY_MEM_SIZE (4 * 1024) + +TEE_Result register_notify_memery(const smc_cmd_t *cmd); +struct notify_data_struct *get_notify_data(void); + +#endif /* GTASK_NOTIFY_MANAGER_H */ diff --git a/framework/gtask/src/manager/service_manager.c b/framework/gtask/src/manager/service_manager.c index a6d4efc4..e0d9aecd 100644 --- a/framework/gtask/src/manager/service_manager.c +++ b/framework/gtask/src/manager/service_manager.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: TEE enviroment's service manager of framework Implemention - * Author: Zhangdeyao zhangdeyao@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/framework/gtask/src/manager/service_manager.h b/framework/gtask/src/manager/service_manager.h index 2adeebd5..1bda5763 100644 --- a/framework/gtask/src/manager/service_manager.h +++ b/framework/gtask/src/manager/service_manager.h @@ -1,41 +1,47 @@ -/* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: used by service_manager. - * Author: yangboyu y30022050 - * Create: 2022-04-24 - */ -#ifndef GTASK_SERVICE_MANAGER_H -#define GTASK_SERVICE_MANAGER_H - -#include -#include - -#define INVALID_SERVICE_INDEX (-1) - -bool dynamic_service_exist(const TEE_UUID *uuid, bool build_in); -TEE_Result register_service(const char *name, const TEE_UUID *uuid, bool dyn_conf_registed, - const struct service_attr *service_attr); -TEE_Result ta_framework_init(void); -void init_service_property(const TEE_UUID *uuid, uint32_t stack, uint32_t heap, - bool single_instance, bool multi_session, bool keep_alive, - bool ssa_enum_enable, bool mem_page_align, const char *other_buff, - uint32_t other_len); -bool need_load_srv(const TEE_UUID *uuid); -TEE_Result start_internal_task(const TEE_UUID *uuid, uint16_t task_prio, const char *task_name, uint32_t *task_id); -bool is_gtask_by_uuid(const TEE_UUID *task_uuid); -struct dlist_node *get_service_head_ptr(void); -#ifdef CONFIG_ENABLE_DUMP_SRV_SESS -TEE_Result dump_service_session_info(const smc_cmd_t *cmd); -#endif - -struct service_struct *find_service_dead(const TEE_UUID *uuid, uint32_t service_index); -bool find_task(uint32_t task_id, struct service_struct **entry, struct session_struct **session); -bool find_task_dead(uint32_t task_id, struct service_struct **entry, struct session_struct **session); -bool is_system_service(const struct service_struct *service); -void process_release_service(struct service_struct *service, uint32_t if_reuse_elf); -void recycle_srvc_thread(struct service_struct *service); -TEE_Result age_service(void); -void decr_ref_cnt(struct service_struct *service); -void get_interval(const TEE_Time *cur, const TEE_Time *base, uint64_t *interval); -void age_timeout_lib(void); - -#endif /* GTASK_SERVICE_MANAGER_H */ +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef GTASK_SERVICE_MANAGER_H +#define GTASK_SERVICE_MANAGER_H + +#include +#include + +#define INVALID_SERVICE_INDEX (-1) + +bool dynamic_service_exist(const TEE_UUID *uuid, bool build_in); +TEE_Result register_service(const char *name, const TEE_UUID *uuid, bool dyn_conf_registed, + const struct service_attr *service_attr); +TEE_Result ta_framework_init(void); +void init_service_property(const TEE_UUID *uuid, uint32_t stack, uint32_t heap, + bool single_instance, bool multi_session, bool keep_alive, + bool ssa_enum_enable, bool mem_page_align, const char *other_buff, + uint32_t other_len); +bool need_load_srv(const TEE_UUID *uuid); +TEE_Result start_internal_task(const TEE_UUID *uuid, uint16_t task_prio, const char *task_name, uint32_t *task_id); +bool is_gtask_by_uuid(const TEE_UUID *task_uuid); +struct dlist_node *get_service_head_ptr(void); +#ifdef CONFIG_ENABLE_DUMP_SRV_SESS +TEE_Result dump_service_session_info(const smc_cmd_t *cmd); +#endif + +struct service_struct *find_service_dead(const TEE_UUID *uuid, uint32_t service_index); +bool find_task(uint32_t task_id, struct service_struct **entry, struct session_struct **session); +bool find_task_dead(uint32_t task_id, struct service_struct **entry, struct session_struct **session); +bool is_system_service(const struct service_struct *service); +void process_release_service(struct service_struct *service, uint32_t if_reuse_elf); +void recycle_srvc_thread(struct service_struct *service); +TEE_Result age_service(void); +void decr_ref_cnt(struct service_struct *service); +void get_interval(const TEE_Time *cur, const TEE_Time *base, uint64_t *interval); +void age_timeout_lib(void); + +#endif /* GTASK_SERVICE_MANAGER_H */ diff --git a/framework/gtask/src/manager/session_manager.c b/framework/gtask/src/manager/session_manager.c index aa3a1b43..27f28157 100644 --- a/framework/gtask/src/manager/session_manager.c +++ b/framework/gtask/src/manager/session_manager.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: TEE enviroment's session manager of framework Implemention - * Author: Zhangdeyao zhangdeyao@huawei.com - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/framework/gtask/src/manager/session_manager.h b/framework/gtask/src/manager/session_manager.h index ea84eb0e..8aca2501 100644 --- a/framework/gtask/src/manager/session_manager.h +++ b/framework/gtask/src/manager/session_manager.h @@ -1,47 +1,53 @@ -/* Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: used by session_manager. - * Author: yangboyu y30022050 - * Create: 2022-04-24 - */ -#ifndef GTASK_SESSION_MANAGER_H -#define GTASK_SESSION_MANAGER_H - -#include "gtask_core.h" - -void reset_ta_context(void); -void set_tee_return_origin(smc_cmd_t *cmd, TEE_Result ret_origin); -void set_tee_return(smc_cmd_t *cmd, TEE_Result ret_val); -void set_tee_processed(bool processed); -TEE_Result proceed_return_code(smc_cmd_t *cmd); -bool is_command_processed(void); -TEE_Result start_ta_task(const smc_cmd_t *cmd, uint32_t cmd_type); -TEE_Result init_ta_context(const smc_cmd_t *cmd); -TEE_Result init_ta2ta_agent_context(smc_cmd_t *out_cmd); -TEE_Result init_ta2ta_context(smc_cmd_t *out_cmd, uint64_t ta_cmd, uint32_t task_id); -TEE_Result init_session_context(uint32_t task_id, - struct service_struct **service, struct session_struct **session); -TEE_Result open_session(smc_cmd_t *cmd, uint32_t cmd_type, uint32_t task_id, - const struct ta2ta_info_t *ta2ta_info); -TEE_Result close_session(const smc_cmd_t *cmd, uint32_t cmd_type, bool *sync); -TEE_Result async_call_ta_entry(const smc_cmd_t *cmd, uint32_t cmd_type, uint32_t cmd_id); -TEE_Result process_open_session(const smc_cmd_t *cmd, uint32_t cmd_type); -void process_open_session_error(void); -TEE_Result process_close_session(); -void session_set_cancelable(bool cancelable); -bool process_init_session(void); -void set_session_context(smc_cmd_t *cmd, uint32_t service_index, uint32_t session_id); -int32_t get_session_id(void); - -int32_t find_service(const TEE_UUID *uuid, uint32_t service_index, struct service_struct **entry); -struct service_struct *find_service_by_task_id(uint32_t task_id); -int join_session_task_name(const char *service_name, struct session_struct *session); -struct session_struct *find_session_with_dev_file_id(uint32_t session_id, uint32_t dev_file_id, - const struct service_struct *srv); -struct session_struct *get_cur_session(); -struct service_struct *get_cur_service(); -TEE_Result add_new_session_into_list(struct session_struct **session, uint32_t *session_id, - uint32_t ta2ta_level); -int32_t release_session(struct service_struct *service, struct session_struct *session); -TEE_Result close_session_async(struct session_struct *sess); - -#endif /* GTASK_SESSION_MANAGER_H */ +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef GTASK_SESSION_MANAGER_H +#define GTASK_SESSION_MANAGER_H + +#include "gtask_core.h" + +void reset_ta_context(void); +void set_tee_return_origin(smc_cmd_t *cmd, TEE_Result ret_origin); +void set_tee_return(smc_cmd_t *cmd, TEE_Result ret_val); +void set_tee_processed(bool processed); +TEE_Result proceed_return_code(smc_cmd_t *cmd); +bool is_command_processed(void); +TEE_Result start_ta_task(const smc_cmd_t *cmd, uint32_t cmd_type); +TEE_Result init_ta_context(const smc_cmd_t *cmd); +TEE_Result init_ta2ta_agent_context(smc_cmd_t *out_cmd); +TEE_Result init_ta2ta_context(smc_cmd_t *out_cmd, uint64_t ta_cmd, uint32_t task_id); +TEE_Result init_session_context(uint32_t task_id, + struct service_struct **service, struct session_struct **session); +TEE_Result open_session(smc_cmd_t *cmd, uint32_t cmd_type, uint32_t task_id, + const struct ta2ta_info_t *ta2ta_info); +TEE_Result close_session(const smc_cmd_t *cmd, uint32_t cmd_type, bool *sync); +TEE_Result async_call_ta_entry(const smc_cmd_t *cmd, uint32_t cmd_type, uint32_t cmd_id); +TEE_Result process_open_session(const smc_cmd_t *cmd, uint32_t cmd_type); +void process_open_session_error(void); +TEE_Result process_close_session(); +void session_set_cancelable(bool cancelable); +bool process_init_session(void); +void set_session_context(smc_cmd_t *cmd, uint32_t service_index, uint32_t session_id); +int32_t get_session_id(void); + +int32_t find_service(const TEE_UUID *uuid, uint32_t service_index, struct service_struct **entry); +struct service_struct *find_service_by_task_id(uint32_t task_id); +int join_session_task_name(const char *service_name, struct session_struct *session); +struct session_struct *find_session_with_dev_file_id(uint32_t session_id, uint32_t dev_file_id, + const struct service_struct *srv); +struct session_struct *get_cur_session(); +struct service_struct *get_cur_service(); +TEE_Result add_new_session_into_list(struct session_struct **session, uint32_t *session_id, + uint32_t ta2ta_level); +int32_t release_session(struct service_struct *service, struct session_struct *session); +TEE_Result close_session_async(struct session_struct *sess); + +#endif /* GTASK_SESSION_MANAGER_H */ diff --git a/framework/gtask/src/task_adaptor/task_adaptor.c b/framework/gtask/src/task_adaptor/task_adaptor.c index 52f675ce..89b2bc63 100644 --- a/framework/gtask/src/task_adaptor/task_adaptor.c +++ b/framework/gtask/src/task_adaptor/task_adaptor.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: interfaces for gtask communicate with internal task - * Author: l00238133 - * Create: 2019-10-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "task_adaptor.h" diff --git a/framework/gtask/src/task_adaptor/task_adaptor.h b/framework/gtask/src/task_adaptor/task_adaptor.h index f942eccd..2d2bf036 100644 --- a/framework/gtask/src/task_adaptor/task_adaptor.h +++ b/framework/gtask/src/task_adaptor/task_adaptor.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: Structure definition && interface declaration for internal task - * Author: l00238133 - * Create: 2019-10-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TASK_ADAPTOR_H diff --git a/framework/gtask/src/task_adaptor/task_adaptor_pub.h b/framework/gtask/src/task_adaptor/task_adaptor_pub.h index 6e0f7713..35e1e007 100644 --- a/framework/gtask/src/task_adaptor/task_adaptor_pub.h +++ b/framework/gtask/src/task_adaptor/task_adaptor_pub.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: interface declaration for gtask framework - * Author: l00238133 - * Create: 2019-10-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TASK_ADAPTOR_PUB_H diff --git a/framework/gtask/src/task_adaptor/task_dynamic_adaptor.c b/framework/gtask/src/task_adaptor/task_dynamic_adaptor.c index 46b4f5a5..f3523bca 100644 --- a/framework/gtask/src/task_adaptor/task_dynamic_adaptor.c +++ b/framework/gtask/src/task_adaptor/task_dynamic_adaptor.c @@ -1,13 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:knJl3i1vSJR3B11HHgaQUyMxVZ7YF2mXmJBJXafiwfEs59bNINKE4aT2ZyfjUO++hnUknpLS -KrZqNSjXv5btbjZB41ALX/s8G+a/gng1xtekyjC2OOoYK6B5mVnNBXMPWJommtEQRqy4lCSE -qBg8bbeQOp3k9uQRR+MhLH7sEZU=#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ - /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved. - * Description: interfaces for gtask to communicate with agent - * Create: 2021-12-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "task_dynamic_adaptor.h" diff --git a/framework/gtask/src/task_adaptor/task_dynamic_adaptor.h b/framework/gtask/src/task_adaptor/task_dynamic_adaptor.h index 7450bacf..2b2aa5ff 100644 --- a/framework/gtask/src/task_adaptor/task_dynamic_adaptor.h +++ b/framework/gtask/src/task_adaptor/task_dynamic_adaptor.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2022. All rights reserved. - * Description: interface declaration for ssa task adaptor - * Create: 2019-10-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TASK_DYNAMIC_ADAPTOR_H diff --git a/framework/gtask/src/task_adaptor/task_perm_service_adaptor.c b/framework/gtask/src/task_adaptor/task_perm_service_adaptor.c index 556eb23e..8aa8c62c 100644 --- a/framework/gtask/src/task_adaptor/task_perm_service_adaptor.c +++ b/framework/gtask/src/task_adaptor/task_perm_service_adaptor.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: interfaces for gtask to communicate with perm service - * Author: l00238133 - * Create: 2019-10-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "task_perm_service_adaptor.h" diff --git a/framework/gtask/src/task_adaptor/task_perm_service_adaptor.h b/framework/gtask/src/task_adaptor/task_perm_service_adaptor.h index c82801ef..46e946fc 100644 --- a/framework/gtask/src/task_adaptor/task_perm_service_adaptor.h +++ b/framework/gtask/src/task_adaptor/task_perm_service_adaptor.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: interface declaration for perm service task adaptor - * Author: l00238133 - * Create: 2019-10-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TASK_PERM_SERV_ADAPTOR_H diff --git a/framework/gtask/src/task_adaptor/task_se_service_adaptor.c b/framework/gtask/src/task_adaptor/task_se_service_adaptor.c index e1c67b19..60150428 100644 --- a/framework/gtask/src/task_adaptor/task_se_service_adaptor.c +++ b/framework/gtask/src/task_adaptor/task_se_service_adaptor.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: Interfaces for gtask to communicate with se service. - * Author: He Muyang hemuyang1@huawei.com - * Create: 2019-12-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "task_se_service_adaptor.h" #include diff --git a/framework/gtask/src/task_adaptor/task_se_service_adaptor.h b/framework/gtask/src/task_adaptor/task_se_service_adaptor.h index e46f5622..a2724fe9 100644 --- a/framework/gtask/src/task_adaptor/task_se_service_adaptor.h +++ b/framework/gtask/src/task_adaptor/task_se_service_adaptor.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: Interface declaration for se service task adaptor. - * Author: He Muyang hemuyang1@huawei.com - * Create: 2019-12-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TASK_SE_SERVICE_ADAPTOR_H #define GTASK_TASK_SE_SERVICE_ADAPTOR_H diff --git a/framework/gtask/src/task_adaptor/task_ssa_adaptor.c b/framework/gtask/src/task_adaptor/task_ssa_adaptor.c index a7092b29..37491ebd 100644 --- a/framework/gtask/src/task_adaptor/task_ssa_adaptor.c +++ b/framework/gtask/src/task_adaptor/task_ssa_adaptor.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: interfaces for gtask to communicate with ssagent - * Author: l00238133 - * Create: 2019-10-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "task_ssa_adaptor.h" diff --git a/framework/gtask/src/task_adaptor/task_ssa_adaptor.h b/framework/gtask/src/task_adaptor/task_ssa_adaptor.h index 48199dc2..66d02f10 100644 --- a/framework/gtask/src/task_adaptor/task_ssa_adaptor.h +++ b/framework/gtask/src/task_adaptor/task_ssa_adaptor.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: interface declaration for ssa task adaptor - * Author: l00238133 - * Create: 2019-10-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TASK_SSA_ADAPTOR_H diff --git a/framework/gtask/src/task_register.c b/framework/gtask/src/task_register.c index 450194e5..1d4a26fe 100644 --- a/framework/gtask/src/task_register.c +++ b/framework/gtask/src/task_register.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: register task to gtask - * Create: 2022-01-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "task_register.h" diff --git a/framework/gtask/src/task_register.h b/framework/gtask/src/task_register.h index 96a110cb..039c9688 100644 --- a/framework/gtask/src/task_register.h +++ b/framework/gtask/src/task_register.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: register task header file - * Create: 2022-01-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TASK_REGISTER_H diff --git a/framework/gtask/src/tee_task_config.c b/framework/gtask/src/tee_task_config.c index f0a918d6..a95d6e3b 100644 --- a/framework/gtask/src/tee_task_config.c +++ b/framework/gtask/src/tee_task_config.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: internal task enable flag for gtask - * Create: 2019-10-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_task_config.h" diff --git a/framework/gtask/src/tee_task_config.h b/framework/gtask/src/tee_task_config.h index e2b25d2c..3bb2fe0d 100644 --- a/framework/gtask/src/tee_task_config.h +++ b/framework/gtask/src/tee_task_config.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: internal task enable flag for gtask - * Create: 2019-10-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_TASK_CONFIG_H diff --git a/framework/tarunner/Makefile b/framework/tarunner/Makefile index 798a9a59..93149bf2 100644 --- a/framework/tarunner/Makefile +++ b/framework/tarunner/Makefile @@ -1,4 +1,12 @@ -# Copyright Huawei Technologies Co., Ltd. 2010-2019. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # DRIVER is a driver diff --git a/framework/tarunner/src/get_spawn_env.c b/framework/tarunner/src/get_spawn_env.c index ff8f9eda..b9dcb824 100644 --- a/framework/tarunner/src/get_spawn_env.c +++ b/framework/tarunner/src/get_spawn_env.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: get spawn environment. - * Create: 2021-07-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "get_spawn_env.h" #include diff --git a/framework/tarunner/src/get_spawn_env.h b/framework/tarunner/src/get_spawn_env.h index 040b03c4..44943f01 100644 --- a/framework/tarunner/src/get_spawn_env.h +++ b/framework/tarunner/src/get_spawn_env.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: get spawn environment. - * Create: 2021-07-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TARUNNER_SRC_GET_SPAWN_ENV_H #define TARUNNER_SRC_GET_SPAWN_ENV_H diff --git a/framework/tarunner/src/load_init.c b/framework/tarunner/src/load_init.c index 1f0ced8a..095dced6 100644 --- a/framework/tarunner/src/load_init.c +++ b/framework/tarunner/src/load_init.c @@ -1,104 +1,103 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: the functions to init library and tee hanle - * Author: qishuai 00528667 - * Create: 2021-01-16 - */ - -#include "load_init.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void *g_libtee = NULL; - -int32_t get_priority(void) -{ - char *prio_var = getenv("priority"); - int32_t priority; - - if (prio_var != NULL) { - errno = 0; - priority = strtol(prio_var, NULL, 10); /* Convert priority to decimal */ - if ((errno != 0) || (priority < HM_PRIO_TEE_MIN) || (priority > HM_PRIO_TEE_MAX)) { - hm_warning("bad priority set, use default HM_PRIO_TEE_TA\n"); - priority = HM_PRIO_TEE_TA; - } - } else { - hm_warning("no priority set, use default HM_PRIO_TEE_TA\n"); - priority = HM_PRIO_TEE_TA; - } - - return priority; -} - -int32_t extend_utables(void) -{ - int32_t i; - int32_t cnt = 1; - - for (i = 0; i < cnt; i++) { - if (hmapi_extend_utable() != 0) { - hm_error("extend utable failed %d\n", i); - return HM_ERROR; - } - } - - return HM_OK; -} - -void clear_libtee(void) -{ - if (g_libtee == NULL) { - hm_error("libtee handle is NULL\n"); - return; - } - - dlclose(g_libtee); - g_libtee = NULL; -} - -void *get_libtee_handle(void) -{ - if (g_libtee == NULL) { - hm_error("libtee handle is NULL\n"); - return NULL; - } - - return g_libtee; -} - -void *ta_mt_dlopen(const char *name, int32_t flag) -{ - if (name == NULL) { - hm_error("dlopen name is invalied\n"); - return NULL; - } - - size_t length = strnlen(name, LIB_NAME_MAX); - if (length == 0 || length >= LIB_NAME_MAX) { - hm_error("dlopen name length is invalied\n"); - return NULL; - } - - g_libtee = dlopen(name, flag); - if (g_libtee == NULL) { - hm_error("load library failed: %s\n", dlerror()); - return NULL; - } - - return g_libtee; -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#include "load_init.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void *g_libtee = NULL; + +int32_t get_priority(void) +{ + char *prio_var = getenv("priority"); + int32_t priority; + + if (prio_var != NULL) { + errno = 0; + priority = strtol(prio_var, NULL, 10); /* Convert priority to decimal */ + if ((errno != 0) || (priority < HM_PRIO_TEE_MIN) || (priority > HM_PRIO_TEE_MAX)) { + hm_warning("bad priority set, use default HM_PRIO_TEE_TA\n"); + priority = HM_PRIO_TEE_TA; + } + } else { + hm_warning("no priority set, use default HM_PRIO_TEE_TA\n"); + priority = HM_PRIO_TEE_TA; + } + + return priority; +} + +int32_t extend_utables(void) +{ + int32_t i; + int32_t cnt = 1; + + for (i = 0; i < cnt; i++) { + if (hmapi_extend_utable() != 0) { + hm_error("extend utable failed %d\n", i); + return HM_ERROR; + } + } + + return HM_OK; +} + +void clear_libtee(void) +{ + if (g_libtee == NULL) { + hm_error("libtee handle is NULL\n"); + return; + } + + dlclose(g_libtee); + g_libtee = NULL; +} + +void *get_libtee_handle(void) +{ + if (g_libtee == NULL) { + hm_error("libtee handle is NULL\n"); + return NULL; + } + + return g_libtee; +} + +void *ta_mt_dlopen(const char *name, int32_t flag) +{ + if (name == NULL) { + hm_error("dlopen name is invalied\n"); + return NULL; + } + + size_t length = strnlen(name, LIB_NAME_MAX); + if (length == 0 || length >= LIB_NAME_MAX) { + hm_error("dlopen name length is invalied\n"); + return NULL; + } + + g_libtee = dlopen(name, flag); + if (g_libtee == NULL) { + hm_error("load library failed: %s\n", dlerror()); + return NULL; + } + + return g_libtee; +} diff --git a/framework/tarunner/src/load_init.h b/framework/tarunner/src/load_init.h index 9c471440..16df2978 100644 --- a/framework/tarunner/src/load_init.h +++ b/framework/tarunner/src/load_init.h @@ -1,19 +1,25 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: the functions to init library and tee hanle - * Create: 2021-01-16 - */ -#ifndef TA_MT_LOAD_INIT_H -#define TA_MT_LOAD_INIT_H - -#include - -#define DECIMAL_BASE 10 - -int32_t get_priority(void); -int32_t extend_utables(void); -void clear_libtee(void); -void *get_libtee_handle(void); -void *ta_mt_dlopen(const char *name, int32_t flag); - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef TA_MT_LOAD_INIT_H +#define TA_MT_LOAD_INIT_H + +#include + +#define DECIMAL_BASE 10 + +int32_t get_priority(void); +int32_t extend_utables(void); +void clear_libtee(void); +void *get_libtee_handle(void); +void *ta_mt_dlopen(const char *name, int32_t flag); + +#endif diff --git a/framework/tarunner/src/main.c b/framework/tarunner/src/main.c index ba361424..0edadfe0 100644 --- a/framework/tarunner/src/main.c +++ b/framework/tarunner/src/main.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: TA work thread function. - * Create: 2019-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "main.h" diff --git a/framework/tarunner/src/main.h b/framework/tarunner/src/main.h index eadb1367..e97ccc55 100644 --- a/framework/tarunner/src/main.h +++ b/framework/tarunner/src/main.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: TA work thread function. - * Create: 2019-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TARUNNER_MAIN_H diff --git a/framework/tarunner/src/ta_mt.c b/framework/tarunner/src/ta_mt.c index d0f5f577..87281b3d 100644 --- a/framework/tarunner/src/ta_mt.c +++ b/framework/tarunner/src/ta_mt.c @@ -1,14 +1,13 @@ -/* $$$!!Warning: Huawei key information asset. No spread without permission.$$$ */ -/* CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/# */ -/* $$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$ */ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: TA work thread function. - * Author: zhaoxuqiang z00446068 - * Create: 2019-05-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ta_mt.h" #include diff --git a/framework/tarunner/src/ta_mt.h b/framework/tarunner/src/ta_mt.h index ceee85a6..a1bde6fb 100644 --- a/framework/tarunner/src/ta_mt.h +++ b/framework/tarunner/src/ta_mt.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: TA work thread function. - * Create: 2019-06-03 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TA_MT_TA_MT_H #define TA_MT_TA_MT_H diff --git a/framework/teesmcmgr/Makefile b/framework/teesmcmgr/Makefile index 1d2d2834..5e39768b 100644 --- a/framework/teesmcmgr/Makefile +++ b/framework/teesmcmgr/Makefile @@ -1,5 +1,12 @@ -# teesmcmgr compile rule. -# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # Targets TARGET := teesmcmgr.elf diff --git a/framework/teesmcmgr/src/idle.c b/framework/teesmcmgr/src/idle.c index 8f6574d6..4d468b4b 100644 --- a/framework/teesmcmgr/src/idle.c +++ b/framework/teesmcmgr/src/idle.c @@ -1,13 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: idle thread functions - * Create: 2020-05-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/framework/teesmcmgr/src/main.c b/framework/teesmcmgr/src/main.c index f7fe8f19..9118d0e8 100644 --- a/framework/teesmcmgr/src/main.c +++ b/framework/teesmcmgr/src/main.c @@ -1,13 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: main functions of hmsmcmgr - * Create: 2020-05-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/framework/teesmcmgr/src/teesmc.c b/framework/teesmcmgr/src/teesmc.c index 60a6611e..9c8a615b 100644 --- a/framework/teesmcmgr/src/teesmc.c +++ b/framework/teesmcmgr/src/teesmc.c @@ -1,13 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: smc thread functions - * Create: 2020-05-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/framework/teesmcmgr/src/teesmcmgr.h b/framework/teesmcmgr/src/teesmcmgr.h index b7fdc2d3..020f5f49 100644 --- a/framework/teesmcmgr/src/teesmcmgr.h +++ b/framework/teesmcmgr/src/teesmcmgr.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: some functions declaration of hmsmcmgr - * Create: 2020-05-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEESMCMGR_H #define TEESMCMGR_H diff --git a/framework/teesmcmgr/src/utils.c b/framework/teesmcmgr/src/utils.c index b3666e4d..33550125 100644 --- a/framework/teesmcmgr/src/utils.c +++ b/framework/teesmcmgr/src/utils.c @@ -1,13 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: acquire gtask channel functions - * Create: 2020-05-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/drvlib/common/libdrv_frame/Makefile b/lib/drvlib/common/libdrv_frame/Makefile index 73293eb2..5fe5e4d3 100644 --- a/lib/drvlib/common/libdrv_frame/Makefile +++ b/lib/drvlib/common/libdrv_frame/Makefile @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. MODULE := libdrv_frame${TARG}.a include $(BUILD_CONFIG)/var.mk diff --git a/lib/drvlib/common/libdrv_frame/include/drv_dyn_module.h b/lib/drvlib/common/libdrv_frame/include/drv_dyn_module.h index 0ce2891a..365e43ea 100644 --- a/lib/drvlib/common/libdrv_frame/include/drv_dyn_module.h +++ b/lib/drvlib/common/libdrv_frame/include/drv_dyn_module.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: dyn driver module init function and structure - * Create: 2020-09-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRIVERS_DRV_DYN_MODULE_H #define DRIVERS_DRV_DYN_MODULE_H diff --git a/lib/drvlib/common/libdrv_frame/include/drv_param_ops.h b/lib/drvlib/common/libdrv_frame/include/drv_param_ops.h index 9b71d729..4d2da0bb 100644 --- a/lib/drvlib/common/libdrv_frame/include/drv_param_ops.h +++ b/lib/drvlib/common/libdrv_frame/include/drv_param_ops.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Provide parameter transportation buffer between drivers and frame. - * Create: 2020-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRV_PARAM_OPS_H #define DRV_PARAM_OPS_H diff --git a/lib/drvlib/common/libdrv_frame/include/drv_thread.h b/lib/drvlib/common/libdrv_frame/include/drv_thread.h index 10a51528..387b437d 100644 --- a/lib/drvlib/common/libdrv_frame/include/drv_thread.h +++ b/lib/drvlib/common/libdrv_frame/include/drv_thread.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: define struct and declare interface related driver thread. - * Create: 2020-06-24 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PLATDRV_DRV_THREAD_H #define PLATDRV_DRV_THREAD_H diff --git a/lib/drvlib/common/libdrv_frame/include/libdrv_frame.h b/lib/drvlib/common/libdrv_frame/include/libdrv_frame.h index 6258fabc..3a780a31 100644 --- a/lib/drvlib/common/libdrv_frame/include/libdrv_frame.h +++ b/lib/drvlib/common/libdrv_frame/include/libdrv_frame.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: drv frame function declarement - * Create: 2020-04-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBDRV_FRAME_DRV_FRAME_H #define LIBDRV_FRAME_DRV_FRAME_H diff --git a/lib/drvlib/common/libdrv_frame/src/drv_param_ops.c b/lib/drvlib/common/libdrv_frame/src/drv_param_ops.c index 62a3075c..58dc6b99 100644 --- a/lib/drvlib/common/libdrv_frame/src/drv_param_ops.c +++ b/lib/drvlib/common/libdrv_frame/src/drv_param_ops.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: define driver shared memory api - * Create: 2022-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "drv_param_ops.h" diff --git a/lib/drvlib/common/libdrv_frame/src/drv_thread.c b/lib/drvlib/common/libdrv_frame/src/drv_thread.c index 05ecb49e..984a9ac7 100644 --- a/lib/drvlib/common/libdrv_frame/src/drv_thread.c +++ b/lib/drvlib/common/libdrv_frame/src/drv_thread.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: define functions related driver thread. - * Create: 2020-06-24 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "drv_thread.h" #include diff --git a/lib/drvlib/common/libdrv_frame/src/libdrv_frame.c b/lib/drvlib/common/libdrv_frame/src/libdrv_frame.c index d5d7a8cd..8bd46abf 100644 --- a/lib/drvlib/common/libdrv_frame/src/libdrv_frame.c +++ b/lib/drvlib/common/libdrv_frame/src/libdrv_frame.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: drv frame function setting - * Create: 2020-04-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "libdrv_frame.h" #include diff --git a/lib/drvlib/libdrv_shared/Makefile b/lib/drvlib/libdrv_shared/Makefile index 2f9c761c..e11c6dc5 100644 --- a/lib/drvlib/libdrv_shared/Makefile +++ b/lib/drvlib/libdrv_shared/Makefile @@ -1,5 +1,12 @@ -# drv_shared compile rule -# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. SONAME := libdrv_shared$(TARG).so diff --git a/lib/drvlib/libdrv_shared/include/drv_addr_share.h b/lib/drvlib/libdrv_shared/include/drv_addr_share.h index 93e2b8c8..d6c88c0b 100644 --- a/lib/drvlib/libdrv_shared/include/drv_addr_share.h +++ b/lib/drvlib/libdrv_shared/include/drv_addr_share.h @@ -1,13 +1,19 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: This file is the header file for driver dynamic lib - * Create: 2021-04 - */ -#ifndef LIBDRV_ADDR_SHARED_H -#define LIBDRV_ADDR_SHARED_H - -#include - -uint64_t drv_virt_to_phys(uintptr_t addr); - +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef LIBDRV_ADDR_SHARED_H +#define LIBDRV_ADDR_SHARED_H + +#include + +uint64_t drv_virt_to_phys(uintptr_t addr); + #endif \ No newline at end of file diff --git a/lib/drvlib/libdrv_shared/include/drv_io_share.h b/lib/drvlib/libdrv_shared/include/drv_io_share.h index 2000c2c9..fe67f5d5 100644 --- a/lib/drvlib/libdrv_shared/include/drv_io_share.h +++ b/lib/drvlib/libdrv_shared/include/drv_io_share.h @@ -1,14 +1,20 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: This file is the header file for driver dynamic lib - * Create: 2021-04 - */ -#ifndef LIBDRV_IO_SHARED_H -#define LIBDRV_IO_SHARED_H - -#include - -void *ioremap(uintptr_t phys_addr, unsigned long size, int32_t prot); -int32_t iounmap(uintptr_t pddr, const void *addr); - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef LIBDRV_IO_SHARED_H +#define LIBDRV_IO_SHARED_H + +#include + +void *ioremap(uintptr_t phys_addr, unsigned long size, int32_t prot); +int32_t iounmap(uintptr_t pddr, const void *addr); + +#endif diff --git a/lib/drvlib/libdrv_shared/include/io_operations.h b/lib/drvlib/libdrv_shared/include/io_operations.h index dd79baa3..2ab1beee 100644 --- a/lib/drvlib/libdrv_shared/include/io_operations.h +++ b/lib/drvlib/libdrv_shared/include/io_operations.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: This file is for io memory copy - * Create: 2021-04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PLATDRV_IO_OPERATION_H diff --git a/lib/drvlib/libdrv_shared/src/drv_dispatch.c b/lib/drvlib/libdrv_shared/src/drv_dispatch.c index 9c23c99b..fe801913 100644 --- a/lib/drvlib/libdrv_shared/src/drv_dispatch.c +++ b/lib/drvlib/libdrv_shared/src/drv_dispatch.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: drvmgr dispatch function define when receive cmd - * Create: 2021-03-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "drv_dispatch.h" #include diff --git a/lib/drvlib/libdrv_shared/src/drv_dispatch.h b/lib/drvlib/libdrv_shared/src/drv_dispatch.h index 9c25d8b9..191d799c 100644 --- a/lib/drvlib/libdrv_shared/src/drv_dispatch.h +++ b/lib/drvlib/libdrv_shared/src/drv_dispatch.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: declare drvmgr dispatch function when receive cmd - * Create: 2021-03-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRVMGR_SRC_DRV_DISPATCH_H #define DRVMGR_SRC_DRV_DISPATCH_H diff --git a/lib/drvlib/libdrv_shared/src/drv_operations.c b/lib/drvlib/libdrv_shared/src/drv_operations.c index 1e03dcd2..5fe02585 100644 --- a/lib/drvlib/libdrv_shared/src/drv_operations.c +++ b/lib/drvlib/libdrv_shared/src/drv_operations.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: define drv fd manager function - * Create: 2021-03-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "drv_operations.h" #include diff --git a/lib/drvlib/libdrv_shared/src/drv_operations.h b/lib/drvlib/libdrv_shared/src/drv_operations.h index 78cc4539..20c6c5d4 100644 --- a/lib/drvlib/libdrv_shared/src/drv_operations.h +++ b/lib/drvlib/libdrv_shared/src/drv_operations.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: declare drv fd manager function - * Create: 2021-03-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRVMGR_SRC_DRV_FD_MANAGER_H #define DRVMGR_SRC_DRV_FD_MANAGER_H diff --git a/lib/drvlib/libdrv_shared/src/drv_random.c b/lib/drvlib/libdrv_shared/src/drv_random.c index 87d18522..ae75bc1c 100644 --- a/lib/drvlib/libdrv_shared/src/drv_random.c +++ b/lib/drvlib/libdrv_shared/src/drv_random.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implament sysmgr get random - * Create: 2022-01-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "drv_random.h" #include diff --git a/lib/drvlib/libdrv_shared/src/drv_random.h b/lib/drvlib/libdrv_shared/src/drv_random.h index 7c428ccc..673ae2ea 100644 --- a/lib/drvlib/libdrv_shared/src/drv_random.h +++ b/lib/drvlib/libdrv_shared/src/drv_random.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: declare funtion send msg to driver process - * Create: 2022-01-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRVMGR_SRC_DRV_RANDOM_H #define DRVMGR_SRC_DRV_RANDOM_H diff --git a/lib/drvlib/libdrv_shared/src/drv_share.c b/lib/drvlib/libdrv_shared/src/drv_share.c index 870b438f..ebdddecc 100644 --- a/lib/drvlib/libdrv_shared/src/drv_share.c +++ b/lib/drvlib/libdrv_shared/src/drv_share.c @@ -1,27 +1,33 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: This file is the file for driver dynamic lib - * Create: 2021-04 - */ - -#include "drv_io_share.h" -#include "drv_addr_share.h" -#include "iomgr_ext.h" -#include "mem_ops_ext.h" -#include -#include "drv_thread.h" - -void *ioremap(uintptr_t phys_addr, unsigned long size, int32_t prot) -{ - return hm_io_remap((uintptr_t)phys_addr, NULL, size, prot); -} - -int32_t iounmap(uintptr_t pddr, const void *addr) -{ - return hm_io_unmap(pddr, addr); -} - -uint64_t drv_virt_to_phys(uintptr_t addr) -{ - return tee_virt_to_phys(addr); -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#include "drv_io_share.h" +#include "drv_addr_share.h" +#include "iomgr_ext.h" +#include "mem_ops_ext.h" +#include +#include "drv_thread.h" + +void *ioremap(uintptr_t phys_addr, unsigned long size, int32_t prot) +{ + return hm_io_remap((uintptr_t)phys_addr, NULL, size, prot); +} + +int32_t iounmap(uintptr_t pddr, const void *addr) +{ + return hm_io_unmap(pddr, addr); +} + +uint64_t drv_virt_to_phys(uintptr_t addr) +{ + return tee_virt_to_phys(addr); +} diff --git a/lib/drvlib/libdrv_shared/src/io_operations.c b/lib/drvlib/libdrv_shared/src/io_operations.c index 451328ba..fb57d51c 100644 --- a/lib/drvlib/libdrv_shared/src/io_operations.c +++ b/lib/drvlib/libdrv_shared/src/io_operations.c @@ -1,8 +1,14 @@ /* -* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. -* Description: This file is for io memory copy -* Create: 2021-04 -*/ + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ #include "io_operations.h" #include "register_ops.h" #include diff --git a/lib/drvlib/libdrv_shared/src/tee_drv_entry.c b/lib/drvlib/libdrv_shared/src/tee_drv_entry.c index 745c9fa4..00f58a94 100644 --- a/lib/drvlib/libdrv_shared/src/tee_drv_entry.c +++ b/lib/drvlib/libdrv_shared/src/tee_drv_entry.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: define drv main function - * Create: 2021-07-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_drv_entry.h" #include diff --git a/lib/drvlib/libdrv_shared/src/tee_drv_entry.h b/lib/drvlib/libdrv_shared/src/tee_drv_entry.h index c0b0b466..9c459d1a 100644 --- a/lib/drvlib/libdrv_shared/src/tee_drv_entry.h +++ b/lib/drvlib/libdrv_shared/src/tee_drv_entry.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: define drv main function - * Create: 2021-07-23 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBDRV_SHARED_SRC_TEE_DRV_ENTRY_H #define LIBDRV_SHARED_SRC_TEE_DRV_ENTRY_H diff --git a/lib/syslib/libdynconfbuilder/Makefile b/lib/syslib/libdynconfbuilder/Makefile index a51d900a..855fa274 100644 --- a/lib/syslib/libdynconfbuilder/Makefile +++ b/lib/syslib/libdynconfbuilder/Makefile @@ -1,5 +1,12 @@ -# libdynconfbuilder compile rule. -# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # MODULE MODULE := libdynconfbuilder${TARG}.a diff --git a/lib/syslib/libdynconfbuilder/include/drv_dyn_conf_builder.h b/lib/syslib/libdynconfbuilder/include/drv_dyn_conf_builder.h index 1541f7de..1b5c4b25 100644 --- a/lib/syslib/libdynconfbuilder/include/drv_dyn_conf_builder.h +++ b/lib/syslib/libdynconfbuilder/include/drv_dyn_conf_builder.h @@ -1,24 +1,29 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: handle drv dyn perm info - * Author: qishuai qishuai6@huawei.com - * Create: 2021-02-03 - */ - -#ifndef DYN_CONG_BUILDED_DRV_DYN_CONF_BUILDER_H -#define DYN_CONG_BUILDED_DRV_DYN_CONF_BUILDER_H - -#include "dyn_conf_dispatch_inf.h" - -struct tag_crew { - uint32_t item_tag; - uint32_t data_tag; - uint32_t type_tag; - char split_tag; -}; - -int32_t install_drv_permission(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue); -void uninstall_drv_permission(const void *obj, uint32_t obj_size); -void dump_drv_conf(void); - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#ifndef DYN_CONG_BUILDED_DRV_DYN_CONF_BUILDER_H +#define DYN_CONG_BUILDED_DRV_DYN_CONF_BUILDER_H + +#include "dyn_conf_dispatch_inf.h" + +struct tag_crew { + uint32_t item_tag; + uint32_t data_tag; + uint32_t type_tag; + char split_tag; +}; + +int32_t install_drv_permission(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue); +void uninstall_drv_permission(const void *obj, uint32_t obj_size); +void dump_drv_conf(void); + +#endif diff --git a/lib/syslib/libdynconfbuilder/include/drvcall_dyn_conf_builder.h b/lib/syslib/libdynconfbuilder/include/drvcall_dyn_conf_builder.h index 18be7c05..8d6a3d53 100644 --- a/lib/syslib/libdynconfbuilder/include/drvcall_dyn_conf_builder.h +++ b/lib/syslib/libdynconfbuilder/include/drvcall_dyn_conf_builder.h @@ -1,65 +1,70 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: handle drvcall dyn perm info - * Author: qishuai qishuai6@huawei.com - * Create: 2021-02-03 - */ - -#ifndef DYN_CONG_BUILDED_DRVCALL_DYN_CONF_BUILDER_H -#define DYN_CONG_BUILDED_DRVCALL_DYN_CONF_BUILDER_H - -#include -#include "dyn_conf_dispatch_inf.h" - -enum drv_perm_tags { - DRV_PERM = 0x0, - DRV_PERM_DRVCALL_PERM_APPLY = 0x1, - DRV_PERM_DRVCALL_PERM_APPLY_ITEM, - DRV_PERM_DRVCALL_PERM_APPLY_ITEM_NAME, - DRV_PERM_DRVCALL_PERM_APPLY_ITEM_PERMISSION, - DRV_PERM_DRV_BASIC_INFO, - DRV_PERM_DRV_BASIC_INFO_THREAD_LIMIT, - DRV_PERM_DRV_BASIC_INFO_UPGRADE, - DRV_PERM_DRV_BASIC_INFO_VIRT2PHYS, - DRV_PERM_DRV_BASIC_INFO_EXCEPTION_MODE, - DRV_PERM_DRV_IO_MAP, - DRV_PERM_DRV_IO_MAP_ITEM, - DRV_PERM_DRV_IO_MAP_ITEM_CHIP_TYPE, - DRV_PERM_DRV_IO_MAP_ITEM_IOMAP, - DRV_PERM_IRQ, - DRV_PERM_IRQ_ITEM, - DRV_PERM_IRQ_ITEM_CHIP_TYPE, - DRV_PERM_IRQ_ITEM_IRQ, - DRV_PERM_MAP_SECURE, - DRV_PERM_MAP_SECURE_ITEM, - DRV_PERM_MAP_SECURE_ITEM_CHIP_TYPE, - DRV_PERM_MAP_SECURE_ITEM_UUID, - DRV_PERM_MAP_SECURE_ITEM_REGION, - DRV_PERM_MAP_NOSECURE, - DRV_PERM_MAP_NOSECURE_ITEM, - DRV_PERM_MAP_NOSECURE_ITEM_CHIP_TYPE, - DRV_PERM_MAP_NOSECURE_ITEM_UUID, - DRV_PERM_DRV_CMD_PERM_INFO, - DRV_PERM_DRV_CMD_PERM_INFO_ITEM, - DRV_PERM_DRV_CMD_PERM_INFO_ITEM_CMD, - DRV_PERM_DRV_CMD_PERM_INFO_ITEM_PERMISSION, - DRV_PERM_DRV_MAC_INFO, - DRV_PERM_DRV_MAC_INFO_ITEM, - DRV_PERM_DRV_MAC_INFO_ITEM_UUID, - DRV_PERM_DRV_MAC_INFO_ITEM_PERMISSION, - DRV_PERM_UNUSED, -}; - -int32_t install_drvcall_permission(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue); -void uninstall_drvcall_permission(const void *obj, uint32_t obj_size); -void dump_drvcall_conf(void); -int32_t combine_perms(uint64_t *perm, uint32_t size, const char *value); - -int32_t init_drvcall_conf(struct drvcall_perm_apply_t *drvcall_perm_apply, - const struct conf_queue_t *conf_queue); - -void free_drvcall_perm(struct drvcall_perm_apply_t *drvcall_perm); - -int32_t build_drvcall_perm_apply(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size); -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#ifndef DYN_CONG_BUILDED_DRVCALL_DYN_CONF_BUILDER_H +#define DYN_CONG_BUILDED_DRVCALL_DYN_CONF_BUILDER_H + +#include +#include "dyn_conf_dispatch_inf.h" + +enum drv_perm_tags { + DRV_PERM = 0x0, + DRV_PERM_DRVCALL_PERM_APPLY = 0x1, + DRV_PERM_DRVCALL_PERM_APPLY_ITEM, + DRV_PERM_DRVCALL_PERM_APPLY_ITEM_NAME, + DRV_PERM_DRVCALL_PERM_APPLY_ITEM_PERMISSION, + DRV_PERM_DRV_BASIC_INFO, + DRV_PERM_DRV_BASIC_INFO_THREAD_LIMIT, + DRV_PERM_DRV_BASIC_INFO_UPGRADE, + DRV_PERM_DRV_BASIC_INFO_VIRT2PHYS, + DRV_PERM_DRV_BASIC_INFO_EXCEPTION_MODE, + DRV_PERM_DRV_IO_MAP, + DRV_PERM_DRV_IO_MAP_ITEM, + DRV_PERM_DRV_IO_MAP_ITEM_CHIP_TYPE, + DRV_PERM_DRV_IO_MAP_ITEM_IOMAP, + DRV_PERM_IRQ, + DRV_PERM_IRQ_ITEM, + DRV_PERM_IRQ_ITEM_CHIP_TYPE, + DRV_PERM_IRQ_ITEM_IRQ, + DRV_PERM_MAP_SECURE, + DRV_PERM_MAP_SECURE_ITEM, + DRV_PERM_MAP_SECURE_ITEM_CHIP_TYPE, + DRV_PERM_MAP_SECURE_ITEM_UUID, + DRV_PERM_MAP_SECURE_ITEM_REGION, + DRV_PERM_MAP_NOSECURE, + DRV_PERM_MAP_NOSECURE_ITEM, + DRV_PERM_MAP_NOSECURE_ITEM_CHIP_TYPE, + DRV_PERM_MAP_NOSECURE_ITEM_UUID, + DRV_PERM_DRV_CMD_PERM_INFO, + DRV_PERM_DRV_CMD_PERM_INFO_ITEM, + DRV_PERM_DRV_CMD_PERM_INFO_ITEM_CMD, + DRV_PERM_DRV_CMD_PERM_INFO_ITEM_PERMISSION, + DRV_PERM_DRV_MAC_INFO, + DRV_PERM_DRV_MAC_INFO_ITEM, + DRV_PERM_DRV_MAC_INFO_ITEM_UUID, + DRV_PERM_DRV_MAC_INFO_ITEM_PERMISSION, + DRV_PERM_UNUSED, +}; + +int32_t install_drvcall_permission(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue); +void uninstall_drvcall_permission(const void *obj, uint32_t obj_size); +void dump_drvcall_conf(void); +int32_t combine_perms(uint64_t *perm, uint32_t size, const char *value); + +int32_t init_drvcall_conf(struct drvcall_perm_apply_t *drvcall_perm_apply, + const struct conf_queue_t *conf_queue); + +void free_drvcall_perm(struct drvcall_perm_apply_t *drvcall_perm); + +int32_t build_drvcall_perm_apply(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size); +#endif diff --git a/lib/syslib/libdynconfbuilder/include/ta_config_builder.h b/lib/syslib/libdynconfbuilder/include/ta_config_builder.h index cc09d624..6983af06 100644 --- a/lib/syslib/libdynconfbuilder/include/ta_config_builder.h +++ b/lib/syslib/libdynconfbuilder/include/ta_config_builder.h @@ -1,124 +1,129 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: v3.1 ta config builder - * Author: qishuai qishuai6@huawei.com - * Create: 2022-02-07 - */ - -#ifndef TA_CONFIG_BUILDER_H -#define TA_CONFIG_BUILDER_H - -#include -#include "dyn_conf_dispatch_inf.h" - -enum ta_config_tags { - CONFIGINFO = 0x0, - CONFIGINFO_TA_BASIC_INFO = 0x1, - CONFIGINFO_TA_BASIC_INFO_SERVICE_NAME, - CONFIGINFO_TA_BASIC_INFO_SERVICE_NAME_SERVICE_NAME, - CONFIGINFO_TA_BASIC_INFO_UUID, - CONFIGINFO_TA_BASIC_INFO_UUID_UUID, - CONFIGINFO_TA_MANIFEST_INFO, - CONFIGINFO_TA_MANIFEST_INFO_INSTANCE_KEEP_ALIVE, - CONFIGINFO_TA_MANIFEST_INFO_INSTANCE_KEEP_ALIVE_INSTANCE_KEEP_ALIVE, - CONFIGINFO_TA_MANIFEST_INFO_STACK_SIZE, - CONFIGINFO_TA_MANIFEST_INFO_STACK_SIZE_STACK_SIZE, - CONFIGINFO_TA_MANIFEST_INFO_HEAP_SIZE, - CONFIGINFO_TA_MANIFEST_INFO_HEAP_SIZE_HEAP_SIZE, - CONFIGINFO_TA_MANIFEST_INFO_TARGET_TYPE, - CONFIGINFO_TA_MANIFEST_INFO_TARGET_TYPE_TARGET_TYPE, - CONFIGINFO_TA_MANIFEST_INFO_MULTI_COMMAND, - CONFIGINFO_TA_MANIFEST_INFO_MULTI_COMMAND_MULTI_COMMAND, - CONFIGINFO_TA_MANIFEST_INFO_MULTI_SESSION, - CONFIGINFO_TA_MANIFEST_INFO_MULTI_SESSION_MULTI_SESSION, - CONFIGINFO_TA_MANIFEST_INFO_SINGLE_INSTANCE, - CONFIGINFO_TA_MANIFEST_INFO_SINGLE_INSTANCE_SINGLE_INSTANCE, - CONFIGINFO_TA_CONTROL_INFO, -#if defined(CONFIG_APP_TEE_SE) - CONFIGINFO_TA_CONTROL_INFO_SE_INFO, - CONFIGINFO_TA_CONTROL_INFO_SE_INFO_SE_OPEN_SESSION, - CONFIGINFO_TA_CONTROL_INFO_SE_INFO_SE_OPEN_SESSION_SE_OPEN_SESSION, -#endif - CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO, - CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_STATUS, - CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_STATUS_DEBUG_STATUS, - CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_DEVICE_ID, - CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_DEVICE_ID_DEBUG_DEVICE_ID, - CONFIGINFO_UNUSED, -}; - -#define SE_OPEN_SESSION_PERMISSION 0x01U -#define CERT_GENERAL_PERMISSION 0x01U - -/* CN format in TA's certificate: "uuid string" + "_" + "service name" */ -#define TA_CERT_MAX_CN_INFO_LEN 64 -#define TA_CERT_CN_UNDERLINE_SIZE 1 -#define UUID_STR_LEN 36 -#define TLV_DEVICE_ID_LEN 64U -#define POLICY_OLD_VERSION 0 -#define POLICY_VERSION_ONE 1 -#define MAX_CALLEE_TA_COUNT 100 -#define MAX_CALLEE_COMMAND_COUNT 100 -#define DEVICE_ID_LEN 32 -#define LEN_OFFSET_VALUE 4U -#define MAX_SERVICE_NAME_LEN 40 - -struct ta_manifest_info { - bool single_instance; - bool multi_session; - bool multi_command; - bool instance_keep_alive; - uint32_t heap_size; - uint32_t stack_size; - bool mem_page_align; - uint32_t target_type; - bool sys_verify_ta; -}; - -struct ta_sfs_info { - uint64_t permissions; -}; - -struct ta_se_info { - uint64_t permissions; -}; - -struct ta_cert_perm_info { - uint64_t permissions; -}; - -struct ta_debug_info { - bool status; - bool valid_device; -}; - -struct callee_ta_info { - struct callee_ta_info *next; - TEE_UUID uuid; - uint32_t command_num; - uint32_t *command_id; -}; - -struct ta_control_info { - struct ta_sfs_info sfs_info; - struct ta_se_info se_info; - struct ta_cert_perm_info cert_info; - uint32_t ta_manager; - struct callee_ta_info *callee_info; - struct ta_debug_info debug_info; -}; - -struct config_info { - struct dlist_node head; - TEE_UUID uuid; - char service_name[MAX_SERVICE_NAME_LEN]; - uint32_t service_name_len; - uint32_t version; - struct ta_manifest_info manifest_info; - struct ta_control_info control_info; -}; - -int32_t install_ta_config(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue); -TEE_Result check_device_id(struct config_info *config, const uint8_t *buff, uint32_t len); - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#ifndef TA_CONFIG_BUILDER_H +#define TA_CONFIG_BUILDER_H + +#include +#include "dyn_conf_dispatch_inf.h" + +enum ta_config_tags { + CONFIGINFO = 0x0, + CONFIGINFO_TA_BASIC_INFO = 0x1, + CONFIGINFO_TA_BASIC_INFO_SERVICE_NAME, + CONFIGINFO_TA_BASIC_INFO_SERVICE_NAME_SERVICE_NAME, + CONFIGINFO_TA_BASIC_INFO_UUID, + CONFIGINFO_TA_BASIC_INFO_UUID_UUID, + CONFIGINFO_TA_MANIFEST_INFO, + CONFIGINFO_TA_MANIFEST_INFO_INSTANCE_KEEP_ALIVE, + CONFIGINFO_TA_MANIFEST_INFO_INSTANCE_KEEP_ALIVE_INSTANCE_KEEP_ALIVE, + CONFIGINFO_TA_MANIFEST_INFO_STACK_SIZE, + CONFIGINFO_TA_MANIFEST_INFO_STACK_SIZE_STACK_SIZE, + CONFIGINFO_TA_MANIFEST_INFO_HEAP_SIZE, + CONFIGINFO_TA_MANIFEST_INFO_HEAP_SIZE_HEAP_SIZE, + CONFIGINFO_TA_MANIFEST_INFO_TARGET_TYPE, + CONFIGINFO_TA_MANIFEST_INFO_TARGET_TYPE_TARGET_TYPE, + CONFIGINFO_TA_MANIFEST_INFO_MULTI_COMMAND, + CONFIGINFO_TA_MANIFEST_INFO_MULTI_COMMAND_MULTI_COMMAND, + CONFIGINFO_TA_MANIFEST_INFO_MULTI_SESSION, + CONFIGINFO_TA_MANIFEST_INFO_MULTI_SESSION_MULTI_SESSION, + CONFIGINFO_TA_MANIFEST_INFO_SINGLE_INSTANCE, + CONFIGINFO_TA_MANIFEST_INFO_SINGLE_INSTANCE_SINGLE_INSTANCE, + CONFIGINFO_TA_CONTROL_INFO, +#if defined(CONFIG_APP_TEE_SE) + CONFIGINFO_TA_CONTROL_INFO_SE_INFO, + CONFIGINFO_TA_CONTROL_INFO_SE_INFO_SE_OPEN_SESSION, + CONFIGINFO_TA_CONTROL_INFO_SE_INFO_SE_OPEN_SESSION_SE_OPEN_SESSION, +#endif + CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO, + CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_STATUS, + CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_STATUS_DEBUG_STATUS, + CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_DEVICE_ID, + CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_DEVICE_ID_DEBUG_DEVICE_ID, + CONFIGINFO_UNUSED, +}; + +#define SE_OPEN_SESSION_PERMISSION 0x01U +#define CERT_GENERAL_PERMISSION 0x01U + +/* CN format in TA's certificate: "uuid string" + "_" + "service name" */ +#define TA_CERT_MAX_CN_INFO_LEN 64 +#define TA_CERT_CN_UNDERLINE_SIZE 1 +#define UUID_STR_LEN 36 +#define TLV_DEVICE_ID_LEN 64U +#define POLICY_OLD_VERSION 0 +#define POLICY_VERSION_ONE 1 +#define MAX_CALLEE_TA_COUNT 100 +#define MAX_CALLEE_COMMAND_COUNT 100 +#define DEVICE_ID_LEN 32 +#define LEN_OFFSET_VALUE 4U +#define MAX_SERVICE_NAME_LEN 40 + +struct ta_manifest_info { + bool single_instance; + bool multi_session; + bool multi_command; + bool instance_keep_alive; + uint32_t heap_size; + uint32_t stack_size; + bool mem_page_align; + uint32_t target_type; + bool sys_verify_ta; +}; + +struct ta_sfs_info { + uint64_t permissions; +}; + +struct ta_se_info { + uint64_t permissions; +}; + +struct ta_cert_perm_info { + uint64_t permissions; +}; + +struct ta_debug_info { + bool status; + bool valid_device; +}; + +struct callee_ta_info { + struct callee_ta_info *next; + TEE_UUID uuid; + uint32_t command_num; + uint32_t *command_id; +}; + +struct ta_control_info { + struct ta_sfs_info sfs_info; + struct ta_se_info se_info; + struct ta_cert_perm_info cert_info; + uint32_t ta_manager; + struct callee_ta_info *callee_info; + struct ta_debug_info debug_info; +}; + +struct config_info { + struct dlist_node head; + TEE_UUID uuid; + char service_name[MAX_SERVICE_NAME_LEN]; + uint32_t service_name_len; + uint32_t version; + struct ta_manifest_info manifest_info; + struct ta_control_info control_info; +}; + +int32_t install_ta_config(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue); +TEE_Result check_device_id(struct config_info *config, const uint8_t *buff, uint32_t len); + +#endif diff --git a/lib/syslib/libdynconfbuilder/src/drv_dyn_conf_builder.c b/lib/syslib/libdynconfbuilder/src/drv_dyn_conf_builder.c index 671b0abb..0aae8625 100644 --- a/lib/syslib/libdynconfbuilder/src/drv_dyn_conf_builder.c +++ b/lib/syslib/libdynconfbuilder/src/drv_dyn_conf_builder.c @@ -1,1570 +1,1575 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: drv dyn conf builder - * Author: qishuai qishuai6@huawei.com - * Create: 2021-02-03 - */ - -#include "drv_dyn_conf_builder.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "drvcall_dyn_conf_builder.h" -#include "tee_inner_uuid.h" - -#ifdef TEE_SUPPORT_DYN_CONF - -static struct tee_uuid g_drv_server_uuid = DRVMGR; - -static int32_t check_uuid_valid(struct tee_uuid uuid) -{ - char *buff[sizeof(uuid)] = { 0 }; - - if (memcmp(buff, &uuid, sizeof(uuid)) == 0) - return TEE_ERROR_GENERIC; - - return TEE_SUCCESS; -} - -/* - * free section - * the func that free all things you have malloced - */ -static void do_free_drv_conf(void **list, uint16_t *list_size, uint32_t st_size) -{ - if (*list != NULL && (*list_size) != 0) { - tee_free_sharemem(*list, (*list_size) * st_size); - *list = NULL; - *list_size = 0; - } -} - -static void free_drv_conf(struct drv_conf_t *drv_conf) -{ - if (drv_conf == NULL) - return; - - do_free_drv_conf((void **)&(drv_conf->io_map_list), - &(drv_conf->io_map_list_size), sizeof(struct addr_region_t)); - do_free_drv_conf((void **)&(drv_conf->irq_list), &(drv_conf->irq_list_size), sizeof(uint64_t)); - do_free_drv_conf((void **)&(drv_conf->map_secure_list), - &(drv_conf->map_secure_list_size), sizeof(struct drv_map_secure_t)); - do_free_drv_conf((void **)&(drv_conf->map_nosecure_list), - &(drv_conf->map_nosecure_list_size), sizeof(struct drv_map_nosecure_t)); - do_free_drv_conf((void **)&(drv_conf->mac_info_list), - &(drv_conf->mac_info_list_size), sizeof(struct drv_mac_info_t)); - do_free_drv_conf((void **)&(drv_conf->cmd_perm_list), - &(drv_conf->cmd_perm_list_size), sizeof(struct drv_cmd_perm_info_t)); -} - -static void free_drv_tlv(struct drv_tlv *drv) -{ - free_drv_conf(&drv->drv_conf); - free_drvcall_perm(&drv->drvcall_perm_apply); - free(drv); -} - -/* - * init section - * init all objs that you want to use - */ -static int32_t init_drv_conf_mani(const struct drv_mani_t *mani, struct drv_conf_t *drv_conf) -{ - if (mani->service_name_size >= DRV_NAME_MAX_LEN) { - hm_error("service name is too long %u\n", mani->service_name_size); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (memcpy_s(drv_conf->mani.service_name, DRV_NAME_MAX_LEN, mani->service_name, mani->service_name_size) != 0) { - hm_error("memcpy service name to drv conf failed\n"); - return TEE_ERROR_GENERIC; - } - drv_conf->mani.service_name[mani->service_name_size] = '\0'; - drv_conf->mani.service_name_size = mani->service_name_size; - drv_conf->mani.keep_alive = mani->keep_alive; - drv_conf->mani.data_size = mani->data_size; - drv_conf->mani.stack_size = mani->stack_size; - drv_conf->mani.hardware_type = mani->hardware_type; - - return TEE_SUCCESS; -} - -/* - * scan the conf_queue from start - * when we find item_tag, then we will check it's chip_type - * if chip type is invalid, it will be set DRV_PERM_UNUSED - */ -static int32_t init_drv_conf_filter_chip_type(const struct conf_queue_t *conf_queue, struct tag_crew tags, - void **list, uint16_t *list_size, uint32_t size) -{ - struct dlist_node *pos = NULL; - uint32_t count = 0; - uint8_t flag = 0; - - dlist_for_each(pos, &conf_queue->queue) { - struct conf_node_t *conf_node = dlist_entry(pos, struct conf_node_t, head); - if (conf_node->tag != tags.item_tag && conf_node->tag != tags.data_tag) - continue; - - /* check if chip type is valid */ - if (conf_node->tag == tags.item_tag) { - if (check_item_chip_type(pos, tags.type_tag) != TEE_SUCCESS) { - flag = 0; - conf_node->tag = DRV_PERM_UNUSED; - continue; - } - flag = 1; - continue; - } - - /* if chip type is invalid, then ignore it */ - if (conf_node->tag == tags.data_tag && flag == 0) - continue; - - /* if value is not NULL, means at least has one region */ - if (conf_node->size > 0) - count++; - - /* each split_tag means a new region */ - for (uint32_t i = 0; i < conf_node->size; i++) { - if (conf_node->value[i] == tags.split_tag) - count++; - } - flag = 0; - } - - /* count is 0 means xml don't contain this tag, so it is no need to init */ - if (count == 0) - return TEE_SUCCESS; - - uint32_t tmp_size = count * size; - if (size == 0 || count >= (MAX_IMAGE_LEN / size)) { - hm_error("tmp size is invalid %u\n", tmp_size); - return TEE_ERROR_GENERIC; - } - - *list = tee_alloc_sharemem_aux(&g_drv_server_uuid, tmp_size); - if (*list == NULL) { - hm_error("malloc for tlv list failed\n"); - return TEE_ERROR_GENERIC; - } - - if (memset_s(*list, tmp_size, 0, tmp_size) != 0) { - hm_error("memset for tlv list failed\n"); - (void)tee_free_sharemem(*list, tmp_size); - *list = NULL; - return TEE_ERROR_GENERIC; - } - - *list_size = count; - - return TEE_SUCCESS; -} - -static int32_t init_drv_io_map(struct drv_conf_t *drv_conf, const struct conf_queue_t *conf_queue) -{ - drv_conf->io_map_list_index = 0; - struct tag_crew tags; - tags.item_tag = DRV_PERM_DRV_IO_MAP_ITEM; - tags.data_tag = DRV_PERM_DRV_IO_MAP_ITEM_IOMAP; - tags.type_tag = DRV_PERM_DRV_IO_MAP_ITEM_CHIP_TYPE; - tags.split_tag = ';'; - - return init_drv_conf_filter_chip_type(conf_queue, tags, (void **)&(drv_conf->io_map_list), - &(drv_conf->io_map_list_size), sizeof(struct addr_region_t)); -} - -static int32_t init_drv_irq(struct drv_conf_t *drv_conf, const struct conf_queue_t *conf_queue) -{ - drv_conf->irq_list_index = 0; - struct tag_crew tags; - tags.item_tag = DRV_PERM_IRQ_ITEM; - tags.data_tag = DRV_PERM_IRQ_ITEM_IRQ; - tags.type_tag = DRV_PERM_IRQ_ITEM_CHIP_TYPE; - tags.split_tag = ','; - - return init_drv_conf_filter_chip_type(conf_queue, tags, (void **)&(drv_conf->irq_list), - &(drv_conf->irq_list_size), sizeof(uint64_t)); -} - -static int32_t init_drv_map_secure(struct drv_conf_t *drv_conf, const struct conf_queue_t *conf_queue) -{ - struct tag_crew tags; - tags.item_tag = DRV_PERM_MAP_SECURE_ITEM; - tags.data_tag = DRV_PERM_MAP_SECURE_ITEM_REGION; - tags.type_tag = DRV_PERM_MAP_SECURE_ITEM_CHIP_TYPE; - tags.split_tag = ';'; - - return init_drv_conf_filter_chip_type(conf_queue, tags, (void **)&(drv_conf->map_secure_list), - &(drv_conf->map_secure_list_size), sizeof(struct drv_map_secure_t)); -} - -static int32_t init_drv_map_nosecure(struct drv_conf_t *drv_conf, const struct conf_queue_t *conf_queue) -{ - struct tag_crew tags; - tags.item_tag = DRV_PERM_MAP_NOSECURE_ITEM; - tags.data_tag = DRV_PERM_MAP_NOSECURE_ITEM_UUID; - tags.type_tag = DRV_PERM_MAP_NOSECURE_ITEM_CHIP_TYPE; - tags.split_tag = ','; - - return init_drv_conf_filter_chip_type(conf_queue, tags, (void **)&(drv_conf->map_nosecure_list), - &(drv_conf->map_nosecure_list_size), sizeof(struct drv_map_nosecure_t)); -} - -static int32_t init_drv_mac_info(struct drv_conf_t *drv_conf, const struct conf_queue_t *conf_queue) -{ - drv_conf->mac_info_list_index = 0; - drv_conf->mac_info_list_size = get_num_of_tag(conf_queue, DRV_PERM_DRV_MAC_INFO_ITEM); - - if (drv_conf->mac_info_list_size == 0) - return TEE_SUCCESS; - - /* drv_conf->mac_info_list_size <= 0xffff means tmp_size cannot larger than 0xFFFFFFFF */ - uint32_t tmp_size = drv_conf->mac_info_list_size * sizeof(struct drv_mac_info_t); - if (tmp_size >= MAX_IMAGE_LEN) { - hm_error("mac info tmp size is invalid %u\n", tmp_size); - return TEE_ERROR_GENERIC; - } - - drv_conf->mac_info_list = tee_alloc_sharemem_aux(&g_drv_server_uuid, tmp_size); - if (drv_conf->mac_info_list == NULL) { - hm_error("malloc for mac list failed\n"); - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static int32_t init_drv_cmd_perm(struct drv_conf_t *drv_conf, const struct conf_queue_t *conf_queue) -{ - drv_conf->cmd_perm_list_index = 0; - drv_conf->cmd_perm_list_size = get_num_of_tag(conf_queue, DRV_PERM_DRV_CMD_PERM_INFO_ITEM); - - if (drv_conf->cmd_perm_list_size == 0) - return TEE_SUCCESS; - - /* drv_conf->cmd_perm_list_size < 0xffff means tmp_size cannot larger than 0xFFFFFFFF */ - uint32_t tmp_size = drv_conf->cmd_perm_list_size * sizeof(struct drv_cmd_perm_info_t); - if (tmp_size >= MAX_IMAGE_LEN) { - hm_error("cmd perm tmp size is invalid %u\n", tmp_size); - return TEE_ERROR_GENERIC; - } - - drv_conf->cmd_perm_list = tee_alloc_sharemem_aux(&g_drv_server_uuid, tmp_size); - if (drv_conf->cmd_perm_list == NULL) { - hm_error("malloc for cmd_perm list failed\n"); - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static int32_t init_drv_conf(const struct drv_mani_t *mani, struct drv_conf_t *drv_conf, - const struct conf_queue_t *conf_queue) -{ - if (memset_s(drv_conf, sizeof(*drv_conf), 0, sizeof(*drv_conf)) != 0) { - hm_error("memset for init drv conf failed\n"); - return TEE_ERROR_GENERIC; - } - - /* init drv conf manifest by manifest.txt */ - if (init_drv_conf_mani(mani, drv_conf) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - - if (init_drv_io_map(drv_conf, conf_queue) != TEE_SUCCESS || - init_drv_irq(drv_conf, conf_queue) != TEE_SUCCESS || - init_drv_map_secure(drv_conf, conf_queue) != TEE_SUCCESS || - init_drv_map_nosecure(drv_conf, conf_queue) != TEE_SUCCESS || - init_drv_mac_info(drv_conf, conf_queue) != TEE_SUCCESS || - init_drv_cmd_perm(drv_conf, conf_queue) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - - /* init drv basic info */ - drv_conf->drv_basic_info.thread_limit = 1; - drv_conf->drv_basic_info.exception_mode = DYN_CONF_SYSCRASH_TAG; - drv_conf->drv_basic_info.virt2phys = false; - - return TEE_SUCCESS; -} - -static int32_t handle_drv_basic_info_thread_limit(uint32_t *thread_limit, uint32_t size, const char *value) -{ - uint64_t tmp_limit; - - if (value == NULL || size > MAX_UINT32_LEN || size == 0) { - hm_error("invalid parm\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - char buff[MAX_UINT32_LEN + 1]; - if (memcpy_s(buff, sizeof(buff), value, size) != 0) { - hm_error("memcpy failed\n"); - return TEE_ERROR_GENERIC; - } - buff[size] = '\0'; - - if (trans_str_to_int(buff, size, BASE_OF_TEN, &tmp_limit) != TEE_SUCCESS) { - hm_error("get thread limit failed, and thread_limit\n"); - return TEE_ERROR_GENERIC; - } - - if (tmp_limit > THREAD_LIMIT_MAX) { - hm_info("get thread limit %llu larger than THREAD_LIMIT_MAX %u\n", - (unsigned long long)tmp_limit, THREAD_LIMIT_MAX); - *thread_limit = THREAD_LIMIT_MAX; - return TEE_SUCCESS; - } - - *thread_limit = (uint32_t)tmp_limit; - if (*thread_limit == 0) { - hm_error("get thread limit should not be 0\n"); - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static int32_t handle_drv_basic_info_exception_mode(uint8_t *exception_mode, uint32_t size, const char *value) -{ - if (value == NULL || size >= MAX_IMAGE_LEN) { - hm_error("invalid parm\n"); - return TEE_ERROR_GENERIC; - } - - char buff[size + 1]; - if (memcpy_s(buff, size + 1, value, size) != 0) { - hm_error("memcpy failed\n"); - return TEE_ERROR_GENERIC; - } - buff[size] = '\0'; - - if (strncmp(buff, "restart", size + 1) == 0) { - *exception_mode = DYN_CONF_RESTART_TAG; - return TEE_SUCCESS; - } - - if (strncmp(buff, "ddos", size + 1) == 0) { - *exception_mode = DYN_CONF_DDOS_TAG; - return TEE_SUCCESS; - } - - if (strncmp(buff, "syscrash", size + 1) == 0) { - *exception_mode = DYN_CONF_SYSCRASH_TAG; - return TEE_SUCCESS; - } - - hm_error("cannot handle exception_mode %s\n", buff); - return TEE_ERROR_GENERIC; -} - -static int32_t build_drv_basic_info(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct drv_tlv *drv = NULL; - - if (obj_size != sizeof(*drv)) { - hm_error("obj size is invalid while build drv basic info\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv = (struct drv_tlv *)obj; - struct drv_conf_t *drv_conf = &drv->drv_conf; - - switch (node->tag) { - case DRV_PERM_DRV_BASIC_INFO_UPGRADE: - if (node->size == 1 && node->value[0] == '1') - drv_conf->drv_basic_info.upgrade = true; - break; - case DRV_PERM_DRV_BASIC_INFO_VIRT2PHYS: - if (node->size == 1 && node->value[0] == '1') - drv_conf->drv_basic_info.virt2phys = true; - break; - case DRV_PERM_DRV_BASIC_INFO_THREAD_LIMIT: - /* thread_limit has been checked in handle_drv_basic_info_thread_limit */ - if (handle_drv_basic_info_thread_limit(&drv_conf->drv_basic_info.thread_limit, node->size, node->value) != 0) - return TEE_ERROR_GENERIC; - break; - case DRV_PERM_DRV_BASIC_INFO_EXCEPTION_MODE: - if (handle_drv_basic_info_exception_mode(&drv_conf->drv_basic_info.exception_mode, - node->size, node->value) != 0) - return TEE_ERROR_GENERIC; - break; - default: - break; - } - - return TEE_SUCCESS; -} - -/* build io map */ -static int32_t tlv_to_iomap_region(const char *iomap_buff, uint32_t buff_len, struct addr_region_t *list, - uint32_t list_size, uint16_t *count) -{ - uint32_t i; - char buff[MAX_UINT64_LEN + 1] = { 0 }; - const char *head = iomap_buff; - - if (buff_len == 0) { - hm_error("iomap buff len is 0\n"); - return TEE_ERROR_GENERIC; - } - - for (i = 0; i <= buff_len; i++) { - (void)memset_s(buff, MAX_UINT64_LEN + 1, 0, MAX_UINT64_LEN + 1); - - if (iomap_buff[i] == ',' || iomap_buff[i] == ';' || iomap_buff[i] == '\0') { - uint64_t offset = (uint64_t)(uintptr_t)(&iomap_buff[i] - head); - if (offset > MAX_UINT64_LEN || offset == 0) { - hm_error("get iomap range offset failed %llu\n", (unsigned long long)offset); - return TEE_ERROR_GENERIC; - } - - if (memcpy_s(buff, MAX_UINT64_LEN, head, (size_t)offset) != 0) { - hm_error("memcpy for iomap buff failed\n"); - return TEE_ERROR_GENERIC; - } - buff[(uint32_t)offset] = '\0'; - if (i < buff_len) - head = (const char *)&iomap_buff[i + 1]; - } - - if (*count >= list_size) { - hm_error("io map region list overflow\n"); - return TEE_ERROR_GENERIC; - } - - if (iomap_buff[i] == ',') { - if (trans_str_to_int(buff, strnlen(buff, MAX_UINT64_LEN), - BASE_OF_HEX, &list[*count].start) != TEE_SUCCESS) { - hm_error("get iomap region start failed\n"); - return TEE_ERROR_GENERIC; - } - } else if (iomap_buff[i] == ';' || iomap_buff[i] == '\0') { - if (trans_str_to_int(buff, strnlen(buff, MAX_UINT64_LEN), - BASE_OF_HEX, &list[*count].end) != TEE_SUCCESS) { - hm_error("get iomap region end failed\n"); - return TEE_ERROR_GENERIC; - } - *count = *count + 1; - } - } - - return TEE_SUCCESS; -} - -static int32_t check_drv_io_map_invalid(const void *obj) -{ - const struct drv_conf_t *drv_conf = (const struct drv_conf_t *)obj; - if (drv_conf == NULL) { - hm_error("invalid drv conf\n"); - return TEE_ERROR_GENERIC; - } - - uint32_t i; - for (i = 0; i < drv_conf->io_map_list_size; i++) { - if (drv_conf->io_map_list[i].start % 0x1000 != 0 || - drv_conf->io_map_list[i].end % 0x1000 != 0) { - hm_error("io map region should be aligned by 0x1000\n"); - return TEE_ERROR_GENERIC; - } - - if (drv_conf->io_map_list[i].end <= drv_conf->io_map_list[i].start) { - hm_error("io map region end must larger than start\n"); - return TEE_ERROR_GENERIC; - } - } - - return TEE_SUCCESS; -} - -static int32_t handle_drv_io_map_item_iomap(struct drv_conf_t *drv_conf, uint32_t size, const char *value) -{ - if (size == 0 || value == NULL || size >= MAX_IMAGE_LEN) { - hm_error("invalid params\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - char *iomap_buff = NULL; - /* size has been checked in handle_conf_node_to_obj, size is smaller than MAX_IMAGE_LEN */ - iomap_buff = malloc(size + 1); - if (iomap_buff == NULL) { - hm_error("malloc for iomap buff failed\n"); - return TEE_ERROR_GENERIC; - } - - /* if walk in this func, iomap list size couldn't be zero */ - if (memcpy_s(iomap_buff, size + 1, value, size) != 0) { - hm_error("memcpy for iomap buff failed\n"); - free(iomap_buff); - return TEE_ERROR_GENERIC; - } - iomap_buff[size] = '\0'; - - if (tlv_to_iomap_region(iomap_buff, strnlen(iomap_buff, MAX_IMAGE_LEN), - drv_conf->io_map_list, drv_conf->io_map_list_size, - &drv_conf->io_map_list_index) != 0) { - hm_error("tlv to iomap region failed \n"); - free(iomap_buff); - return TEE_ERROR_GENERIC; - } - - free(iomap_buff); - return TEE_SUCCESS; -} - -static int32_t build_drv_io_map_item(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct drv_conf_t *drv_conf = NULL; - - if (obj_size != sizeof(*drv_conf)) { - hm_error("obj size is invalid while build drv io map item\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv_conf = (struct drv_conf_t *)obj; - - switch (node->tag) { - case DRV_PERM_DRV_IO_MAP_ITEM_IOMAP: - if (handle_drv_io_map_item_iomap(drv_conf, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle drv io map item iomap failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_drv_io_map(struct dlist_node **pos, const struct conf_node_t *node, void *obj, uint32_t obj_size) -{ - struct drv_tlv *drv = NULL; - - if (obj_size != sizeof(*drv)) { - hm_error("obj size is invalid while build drv io map\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv = (struct drv_tlv *)obj; - struct drv_conf_t *drv_conf = &drv->drv_conf; - - switch (node->tag) { - case DRV_PERM_DRV_IO_MAP_ITEM: - if (handle_conf_node_to_obj(pos, build_drv_io_map_item, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) { - hm_error("build drv io map item failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - hm_debug("skip in build iomap\n"); - if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} - -/* build drv irq */ -static int32_t handle_drv_irq_item_irq(struct drv_conf_t *drv_conf, uint32_t size, const char *value) -{ - int32_t ret = TEE_SUCCESS; - char buff[MAX_UINT64_LEN + 1]; - - if (size == 0 || value == NULL || size >= MAX_IMAGE_LEN) { - hm_error("size is invalid\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - char *irq_buff = malloc(size + 1); - if (irq_buff == NULL) { - hm_error("malloc for irq buff failed\n"); - return TEE_ERROR_GENERIC; - } - - if (memcpy_s(irq_buff, size + 1, value, size) != 0) { - ret = TEE_ERROR_GENERIC; - goto out; - } - irq_buff[size] = '\0'; - - char *head = irq_buff; - for (uint32_t i = 0; i <= size; i++) { - (void)memset_s(buff, MAX_UINT64_LEN + 1, 0, MAX_UINT64_LEN + 1); - - if (irq_buff[i] == ',' || irq_buff[i] == '\0') { - uint64_t offset = (uint64_t)(uintptr_t)(&irq_buff[i] - head); - if (offset > MAX_UINT64_LEN || offset == 0) { - hm_error("get irq offset failed %llu\n", (unsigned long long)offset); - ret = TEE_ERROR_GENERIC; - goto out; - } - - if (memcpy_s(buff, MAX_UINT64_LEN, head, (size_t)offset) != 0) { - hm_error("memcpy for irq buff failed\n"); - ret = TEE_ERROR_GENERIC; - goto out; - } - buff[(uint32_t)offset] = '\0'; - if (i < size) - head = &irq_buff[i + 1]; - - if (drv_conf->irq_list_index >= drv_conf->irq_list_size || - trans_str_to_int(buff, strnlen(buff, MAX_UINT64_LEN), BASE_OF_TEN, - &drv_conf->irq_list[drv_conf->irq_list_index]) != TEE_SUCCESS) { - hm_error("get irq failed\n"); - ret = TEE_ERROR_GENERIC; - goto out; - } - drv_conf->irq_list_index = drv_conf->irq_list_index + 1; - } - } - -out: - free(irq_buff); - return ret; -} - -static int32_t build_drv_irq_item(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct drv_conf_t *drv_conf = NULL; - - if (obj_size != sizeof(*drv_conf)) { - hm_error("obj size is invalid while build drv irq item\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv_conf = (struct drv_conf_t *)obj; - - switch (node->tag) { - case DRV_PERM_IRQ_ITEM_IRQ: - if (handle_drv_irq_item_irq(drv_conf, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle drv irq item irq failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t check_drv_irq_invalid(const void *obj) -{ - const struct drv_conf_t *drv_conf = (const struct drv_conf_t *)obj; - - uint32_t i; - for (i = 0; i < drv_conf->irq_list_size; i++) { - if (drv_conf->irq_list[i] < IRQ_MIN) { - hm_error("invalid irq %llu\n", (unsigned long long)drv_conf->irq_list[i]); - return TEE_ERROR_GENERIC; - } - } - return TEE_SUCCESS; -} - -static int32_t build_drv_irq(struct dlist_node **pos, const struct conf_node_t *node, void *obj, uint32_t obj_size) -{ - struct drv_tlv *drv = NULL; - - if (obj_size != sizeof(*drv)) { - hm_error("obj size is invalid while build drv irq\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv = (struct drv_tlv *)obj; - struct drv_conf_t *drv_conf = &drv->drv_conf; - - switch (node->tag) { - case DRV_PERM_IRQ_ITEM: - if (handle_conf_node_to_obj(pos, build_drv_irq_item, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) { - hm_error("build drv irq item failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - hm_debug("skip drv irq\n"); - if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} - -/* build map secure */ -static int32_t tlv_to_map_secure_region(const char *secure_buff, uint32_t secure_buff_len, - struct drv_map_secure_t *list, uint32_t list_size, uint16_t *count) -{ - if (secure_buff_len == 0) { - hm_error("secure buff len is 0\n"); - return TEE_ERROR_GENERIC; - } - - uint32_t i; - char buff[MAX_UINT64_LEN + 1] = { 0 }; - const char *head = secure_buff; - for (i = 0; i <= secure_buff_len; i++) { - (void)memset_s(buff, MAX_UINT64_LEN + 1, 0, MAX_UINT64_LEN + 1); - - if (secure_buff[i] == ',' || secure_buff[i] == ';' || secure_buff[i] == '\0') { - uint64_t offset = (uint64_t)(uintptr_t)(&secure_buff[i] - head); - if (offset > MAX_UINT64_LEN || offset == 0) { - hm_error("get map_secure range offset failed %llu\n", (unsigned long long)offset); - return TEE_ERROR_GENERIC; - } - - if (memcpy_s(buff, MAX_UINT64_LEN, head, (size_t)offset) != 0) { - hm_error("memcpy for map_secure buff failed\n"); - return TEE_ERROR_GENERIC; - } - buff[(uint32_t)offset] = '\0'; - if (i < secure_buff_len) - head = (const char *)&secure_buff[i + 1]; - } - - if (*count >= list_size) { - hm_error("map_secure region list overflow\n"); - return TEE_ERROR_GENERIC; - } - - if (secure_buff[i] == ',') { - if (trans_str_to_int(buff, strnlen(buff, MAX_UINT64_LEN), - BASE_OF_HEX, &list[*count].region.start) != TEE_SUCCESS) { - hm_error("get map_secure region start failed\n"); - return TEE_ERROR_GENERIC; - } - } else if (secure_buff[i] == ';' || secure_buff[i] == '\0') { - if (trans_str_to_int(buff, strnlen(buff, MAX_UINT64_LEN), - BASE_OF_HEX, &list[*count].region.end) != TEE_SUCCESS) { - hm_error("get map_secure region end failed\n"); - return TEE_ERROR_GENERIC; - } - *count = *count + 1; - } - } - - return TEE_SUCCESS; -} - -static int32_t get_ava_pos_in_map_secure(const struct drv_conf_t *drv_conf, uint16_t *uuid_pos, uint16_t *region_pos) -{ - uint32_t i; - for (i = 0; i < drv_conf->map_secure_list_size; i++) { - if (check_uuid_valid(drv_conf->map_secure_list[i].uuid) != TEE_SUCCESS) - break; - } - *uuid_pos = i; - - for (i = 0; i < drv_conf->map_secure_list_size; i++) { - if (drv_conf->map_secure_list[i].region.start == 0 && - drv_conf->map_secure_list[i].region.end == 0) - break; - } - *region_pos = i; - - return TEE_SUCCESS; -} - -static int32_t handle_drv_map_secure_item_uuid(struct drv_conf_t *drv_conf, uint32_t size, const char *value) -{ - struct tee_uuid uuid; - - int32_t ret = tlv_to_uuid(value, size, &uuid); - if (ret != TEE_SUCCESS) - return ret; - - uint32_t i; - uint16_t uuid_pos; - uint16_t region_pos; - if (get_ava_pos_in_map_secure(drv_conf, &uuid_pos, ®ion_pos) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - - if (uuid_pos == region_pos) { - if (region_pos < drv_conf->map_secure_list_size && - memcpy_s(&drv_conf->map_secure_list[region_pos].uuid, sizeof(drv_conf->map_secure_list[region_pos].uuid), - &uuid, sizeof(uuid)) != 0) { - hm_error("memcpy for uuid in map secure list failed\n"); - return TEE_ERROR_GENERIC; - } - } else if (region_pos > uuid_pos) { - for (i = uuid_pos; i < region_pos; i++) { - if (i < drv_conf->map_secure_list_size && - memcpy_s(&drv_conf->map_secure_list[i].uuid, sizeof(drv_conf->map_secure_list[i].uuid), - &uuid, sizeof(uuid)) != 0) { - hm_error("memcpy for uuid in map sercure list failed\n"); - return TEE_ERROR_GENERIC; - } - } - } else { - hm_error("uuid pos cannot larger than region pos, someting wrong happeds\n"); - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static int32_t handle_drv_map_secure_item_region(struct drv_conf_t *drv_conf, uint32_t size, const char *value) -{ - if (size >= MAX_IMAGE_LEN) { - hm_error("param is invalid %u\n", size); - return TEE_ERROR_BAD_PARAMETERS; - } - - int32_t ret = TEE_ERROR_GENERIC; - uint16_t uuid_pos; - uint16_t region_pos; - if (get_ava_pos_in_map_secure(drv_conf, &uuid_pos, ®ion_pos) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - - char *iomap_buff = malloc(size + 1); - if (iomap_buff == NULL) { - hm_error("malloc for iomap buff failed\n"); - return TEE_ERROR_GENERIC; - } - - if (memset_s(iomap_buff, size + 1, 0, size + 1) != 0 || memcpy_s(iomap_buff, size + 1, value, size) != 0) { - hm_error("memset or memcpy for iomap buff failed\n"); - goto out; - } - - if (uuid_pos == region_pos) { - if (tlv_to_map_secure_region(iomap_buff, strnlen(iomap_buff, MAX_IMAGE_LEN), - drv_conf->map_secure_list, drv_conf->map_secure_list_size, ®ion_pos) != 0) - goto out; - } else if (uuid_pos > region_pos) { - if (tlv_to_map_secure_region(iomap_buff, strnlen(iomap_buff, MAX_IMAGE_LEN), - drv_conf->map_secure_list, drv_conf->map_secure_list_size, ®ion_pos) != 0) - goto out; - - for (uint32_t i = uuid_pos; i < region_pos; i++) { - if (i < drv_conf->map_secure_list_size && - memcpy_s(&drv_conf->map_secure_list[i].uuid, sizeof(drv_conf->map_secure_list[i].uuid), - &drv_conf->map_secure_list[uuid_pos - 1].uuid, - sizeof(drv_conf->map_secure_list[uuid_pos - 1].uuid)) != 0) { - hm_error("memcpy map secure region uuid failed\n"); - goto out; - } - } - } else { - hm_error("region pos cannot larger than uuid pos, someting wrong happeds\n"); - goto out; - } - - ret = TEE_SUCCESS; -out: - free(iomap_buff); - return ret; -} - -static int32_t build_drv_map_secure_item(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct drv_conf_t *drv_conf = NULL; - - if (obj_size != sizeof(*drv_conf)) { - hm_error("obj size is invalid while build drv map secure item\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv_conf = (struct drv_conf_t *)obj; - - switch (node->tag) { - case DRV_PERM_MAP_SECURE_ITEM_UUID: - if (handle_drv_map_secure_item_uuid(drv_conf, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle drv map secure item uuid failed\n"); - return TEE_ERROR_GENERIC; - } - break; - case DRV_PERM_MAP_SECURE_ITEM_REGION: - if (handle_drv_map_secure_item_region(drv_conf, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle drv map secure item region failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t check_drv_map_secure_invalid(const void *obj) -{ - const struct drv_conf_t *drv_conf = (const struct drv_conf_t *)obj; - - uint32_t i; - for (i = 0; i < drv_conf->map_secure_list_size; i++) { - if (drv_conf->map_secure_list[i].region.start % 0x1000 != 0 || - drv_conf->map_secure_list[i].region.end % 0x1000 != 0) { - hm_error("map secure region should be aligned by 4K\n"); - return TEE_ERROR_GENERIC; - } - - if (drv_conf->map_secure_list[i].region.end <= drv_conf->map_secure_list[i].region.start) { - hm_error("map secure region end must larger than start\n"); - return TEE_ERROR_GENERIC; - } - - if (check_uuid_valid(drv_conf->map_secure_list[i].uuid) != TEE_SUCCESS) { - hm_error("map secure uuid is invalid\n"); - return TEE_ERROR_GENERIC; - } - } - - return TEE_SUCCESS; -} - -static int32_t build_drv_map_secure(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - struct drv_tlv *drv = NULL; - - if (obj_size != sizeof(*drv)) { - hm_error("obj size is invalid while build drv map secure\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv = (struct drv_tlv *)obj; - struct drv_conf_t *drv_conf = &drv->drv_conf; - - switch (node->tag) { - case DRV_PERM_MAP_SECURE_ITEM: - if (handle_conf_node_to_obj(pos, build_drv_map_secure_item, - drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) { - hm_error("build drv map secure item failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - hm_debug("skip drv map secure\n"); - if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} - -/* build map nosecure */ -static int32_t check_drv_map_nosecure_invalid(const void *obj) -{ - const struct drv_conf_t *drv_conf = (const struct drv_conf_t *)obj; - - uint32_t i; - for (i = 0; i < drv_conf->map_nosecure_list_size; i++) { - if (check_uuid_valid(drv_conf->map_nosecure_list[i].uuid) != TEE_SUCCESS) { - hm_error("map nosecure uuid is invalid\n"); - return TEE_ERROR_GENERIC; - } - } - - return TEE_SUCCESS; -} - -static int32_t handle_drv_map_nosecure_item_uuid(struct drv_conf_t *drv_conf, uint32_t size, const char *value) -{ - if (size >= MAX_IMAGE_LEN) { - hm_error("size is invalid\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - char *buff = malloc(size + 1); - if (buff == NULL) { - hm_error("malloc for nosecure item failed\n"); - return TEE_ERROR_GENERIC; - } - - int32_t ret = TEE_SUCCESS; - if (memcpy_s(buff, size + 1, value, size) != 0) { - hm_error("memcpy for nosecure item failed\n"); - ret = TEE_ERROR_GENERIC; - goto out; - } - buff[size] = '\0'; - - char *head = buff; - uint32_t i; - for (i = 0; i <= size; i++) { - if (buff[i] == ',' || buff[i] == '\0') { - uint32_t offset = (uint32_t)(uintptr_t)(&buff[i] - head); - if (drv_conf->map_nosecure_list_index >= drv_conf->map_nosecure_list_size) { - hm_error("map nosecure list index overflow\n"); - ret = TEE_ERROR_GENERIC; - goto out; - } - - ret = tlv_to_uuid(head, offset, &drv_conf->map_nosecure_list[drv_conf->map_nosecure_list_index].uuid); - if (ret != TEE_SUCCESS) - goto out; - - drv_conf->map_nosecure_list_index++; - if (i < size) - head = &buff[i + 1]; - } - } - -out: - /* buff cannot be NULL */ - free(buff); - return ret; -} - -static int32_t build_drv_map_nosecure_item(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct drv_conf_t *drv_conf = NULL; - - if (obj_size != sizeof(*drv_conf)) { - hm_error("obj size is invalid while build drv map nosecure item\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv_conf = (struct drv_conf_t *)obj; - - switch (node->tag) { - case DRV_PERM_MAP_NOSECURE_ITEM_UUID: - if (handle_drv_map_nosecure_item_uuid(drv_conf, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle drv map nosecure item uuid failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_drv_map_nosecure(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - struct drv_tlv *drv = NULL; - - if (obj_size != sizeof(*drv)) { - hm_error("obj size is invalid while build drv map nonsecure\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv = (struct drv_tlv *)obj; - struct drv_conf_t *drv_conf = &drv->drv_conf; - - switch (node->tag) { - case DRV_PERM_MAP_NOSECURE_ITEM: - if (handle_conf_node_to_obj(pos, build_drv_map_nosecure_item, - drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) { - hm_error("build drv map nosecure item failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} - -/* build mac info */ -static int32_t check_drv_mac_info_invalid(const void *obj) -{ - const struct drv_conf_t *drv_conf = (const struct drv_conf_t *)obj; - - uint32_t i, j; - for (i = 0; i < drv_conf->mac_info_list_size; i++) { - if (check_uuid_valid(drv_conf->mac_info_list[i].uuid) != TEE_SUCCESS) { - hm_error("mac info uuid is invalid\n"); - return TEE_ERROR_GENERIC; - } - for (j = i + 1; j < drv_conf->mac_info_list_size; j++) { - if (memcmp(&drv_conf->mac_info_list[i].uuid, &drv_conf->mac_info_list[j].uuid, - sizeof(drv_conf->mac_info_list[i].uuid)) == 0) { - hm_error("mac info uuid %08x-%04x-%04x set more than one time\n", - drv_conf->mac_info_list[i].uuid.timeLow, drv_conf->mac_info_list[i].uuid.timeMid, - drv_conf->mac_info_list[i].uuid.timeHiAndVersion); - return TEE_ERROR_GENERIC; - } - } - } - - return TEE_SUCCESS; -} - -static int32_t handle_drv_mac_info_item_permission(struct drv_conf_t *drv_conf, uint32_t size, const char *value) -{ - if (drv_conf->mac_info_list_index >= drv_conf->mac_info_list_size) { - hm_error("mac_info_list_index is invalid\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - int32_t ret = combine_perms(&drv_conf->mac_info_list[drv_conf->mac_info_list_index].perm, size, value); - - return ret; -} - -static int32_t handle_drv_mac_info_item_uuid(struct drv_conf_t *drv_conf, uint32_t size, const char *value) -{ - struct tee_uuid uuid; - uint32_t count = drv_conf->mac_info_list_index; - - if (count >= drv_conf->mac_info_list_size) { - hm_error("mac_info_list_index is overflow %u\n", count); - return TEE_ERROR_GENERIC; - } - - int32_t ret = tlv_to_uuid(value, size, &uuid); - if (ret != TEE_SUCCESS) - return ret; - - if (memcpy_s(&drv_conf->mac_info_list[count].uuid, sizeof(drv_conf->mac_info_list[count].uuid), - &uuid, sizeof(struct tee_uuid)) != 0) { - hm_error("memcpy for uuid in mac info list failed\n"); - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static int32_t build_drv_mac_info_item(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct drv_conf_t *drv_conf = NULL; - if (obj_size != sizeof(*drv_conf)) { - hm_error("obj size is invalid while build drv mac info item\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv_conf = (struct drv_conf_t *)obj; - - switch (node->tag) { - case DRV_PERM_DRV_MAC_INFO_ITEM_UUID: - if (handle_drv_mac_info_item_uuid(drv_conf, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle drv mac info item uuid failed\n"); - return TEE_ERROR_GENERIC; - } - break; - case DRV_PERM_DRV_MAC_INFO_ITEM_PERMISSION: - if (handle_drv_mac_info_item_permission(drv_conf, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle drv mac info item permission failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_drv_mac_info(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - struct drv_tlv *drv = NULL; - - if (obj_size != sizeof(*drv)) { - hm_error("obj size is invalid while build drv mac info\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv = (struct drv_tlv *)obj; - struct drv_conf_t *drv_conf = &drv->drv_conf; - - switch (node->tag) { - case DRV_PERM_DRV_MAC_INFO_ITEM: - if (handle_conf_node_to_obj(pos, build_drv_mac_info_item, - drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) { - hm_error("build drv mac info item failed\n"); - return TEE_ERROR_GENERIC; - } - drv_conf->mac_info_list_index = drv_conf->mac_info_list_index + 1; - break; - default: - hm_debug("skip in build drv mac info\n"); - if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} - -/* build cmd perm info */ -static int32_t check_drv_cmd_perm_invalid(const void *obj) -{ - const struct drv_conf_t *drv_conf = (const struct drv_conf_t *)obj; - - uint32_t i, j; - for (i = 0; i < drv_conf->cmd_perm_list_size; i++) { - if (drv_conf->cmd_perm_list[i].perm == 0) { - hm_error("cmd perm is invalid\n"); - return TEE_ERROR_GENERIC; - } - for (j = i + 1; j < drv_conf->cmd_perm_list_size; j++) { - if (drv_conf->cmd_perm_list[i].cmd == drv_conf->cmd_perm_list[j].cmd) { - hm_error("cmd %llx has been set more than one time in cmd perm\n", - (unsigned long long)drv_conf->cmd_perm_list[i].cmd); - return TEE_ERROR_GENERIC; - } - } - } - - return TEE_SUCCESS; -} - -static int32_t handle_drv_cmd_perm_info_item_cmd(struct drv_conf_t *drv_conf, uint32_t size, const char *value) -{ - uint64_t tmp_cmd = 0; - if (size == 0 || size > MAX_UINT32_LEN) { - hm_error("param invalid while handle cmd perm info item cmd\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - char buff[MAX_UINT32_LEN + 1]; - if (memcpy_s(buff, sizeof(buff), value, size) != 0) { - hm_error("memcpy failed while handle cmd perm info item cmd\n"); - return TEE_ERROR_GENERIC; - } - buff[size] = '\0'; - - if (trans_str_to_int(buff, size, BASE_OF_HEX, &tmp_cmd) != TEE_SUCCESS) { - hm_error("get cmd failed\n"); - return TEE_ERROR_GENERIC; - } - - if (tmp_cmd > DRV_CMD_MAX) { - hm_error("get cmd %llu is larger than DRV_CMD_MAX\n", (unsigned long long)tmp_cmd); - return TEE_ERROR_GENERIC; - } - - if (drv_conf->cmd_perm_list_index >= drv_conf->cmd_perm_list_size) { - hm_error("cmd_perm_list_index is overflow %u\n", drv_conf->cmd_perm_list_index); - return TEE_ERROR_GENERIC; - } - - drv_conf->cmd_perm_list[drv_conf->cmd_perm_list_index].cmd = (uint32_t)tmp_cmd; - - return TEE_SUCCESS; -} - -static int32_t handle_drv_cmd_perm_info_item_permission(struct drv_conf_t *drv_conf, uint32_t size, const char *value) -{ - if (size == 0 || size > MAX_UINT32_LEN) { - hm_error("param invalid while handle cmd perm info item permission\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - char buff[MAX_UINT32_LEN + 1]; - if (memcpy_s(buff, sizeof(buff), value, size) != 0) { - hm_error("memcpy failed while handle cmd perm info item permission\n"); - return TEE_ERROR_GENERIC; - } - buff[size] = '\0'; - - uint64_t off = 0; - if (trans_str_to_int(buff, size, BASE_OF_TEN, &off) != TEE_SUCCESS) { - hm_error("get perm failed\n"); - return TEE_ERROR_GENERIC; - } - - if (off == 0 || off > BIT_NUM_OF_UINT64) { - hm_error("cmd permssion must in range of [1, 64]\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (drv_conf->cmd_perm_list_index >= drv_conf->cmd_perm_list_size) { - hm_error("cmd_perm_list_index is overflow %u\n", drv_conf->cmd_perm_list_index); - return TEE_ERROR_GENERIC; - } - - drv_conf->cmd_perm_list[drv_conf->cmd_perm_list_index].perm = (1 << (off - 1)); - - return TEE_SUCCESS; -} - -static int32_t build_drv_cmd_perm_info_item(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct drv_conf_t *drv_conf = NULL; - if (obj_size != sizeof(*drv_conf)) { - hm_error("obj size is invalid while build drv cmd perm info item\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv_conf = (struct drv_conf_t *)obj; - - switch (node->tag) { - case DRV_PERM_DRV_CMD_PERM_INFO_ITEM_CMD: - if (handle_drv_cmd_perm_info_item_cmd(drv_conf, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle drv cmd perm info item cmd failed\n"); - return TEE_ERROR_GENERIC; - } - break; - case DRV_PERM_DRV_CMD_PERM_INFO_ITEM_PERMISSION: - if (handle_drv_cmd_perm_info_item_permission(drv_conf, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle drv cmd perm info item permission failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_drv_cmd_perm_info(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - struct drv_tlv *drv = NULL; - - if (obj_size != sizeof(*drv)) { - hm_error("obj size is invalid while build drv cmd perm info\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv = (struct drv_tlv *)obj; - struct drv_conf_t *drv_conf = &drv->drv_conf; - - switch (node->tag) { - case DRV_PERM_DRV_CMD_PERM_INFO_ITEM: - if (handle_conf_node_to_obj(pos, build_drv_cmd_perm_info_item, - drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) { - hm_error("build drv cmd perm info item failed\n"); - return TEE_ERROR_GENERIC; - } - drv_conf->cmd_perm_list_index = drv_conf->cmd_perm_list_index + 1; - break; - default: - hm_debug("skip in build drv cmd perm info\n"); - if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_drv_drvcall_conf(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - struct drv_tlv *drv = NULL; - - if (obj_size != sizeof(*drv)) { - hm_error("obj size is invalid while build drv drvcall conf\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv = (struct drv_tlv *)obj; - struct drvcall_perm_apply_t *drvcall_perm = &drv->drvcall_perm_apply; - int32_t ret = build_drvcall_perm_apply(pos, node, drvcall_perm, sizeof(*drvcall_perm)); - if (ret != 0) { - hm_error("drv build drvcall conf fail\n"); - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static struct dyn_conf_build_func dyn_conf_funcs[] = { - { DRV_PERM_DRV_BASIC_INFO, build_drv_basic_info, NULL }, - { DRV_PERM_DRV_IO_MAP, build_drv_io_map, check_drv_io_map_invalid }, - { DRV_PERM_IRQ, build_drv_irq, check_drv_irq_invalid }, - { DRV_PERM_MAP_SECURE, build_drv_map_secure, check_drv_map_secure_invalid }, - { DRV_PERM_MAP_NOSECURE, build_drv_map_nosecure, check_drv_map_nosecure_invalid }, - { DRV_PERM_DRV_CMD_PERM_INFO, build_drv_cmd_perm_info, check_drv_cmd_perm_invalid }, - { DRV_PERM_DRV_MAC_INFO, build_drv_mac_info, check_drv_mac_info_invalid }, - { DRV_PERM_DRVCALL_PERM_APPLY, build_drv_drvcall_conf, NULL }, -}; - -/* build drv conf */ -static int32_t build_drv_conf(struct dlist_node **pos, const struct conf_node_t *node, void *obj, uint32_t obj_size) -{ - struct drv_tlv *drv = NULL; - - if (obj_size != sizeof(*drv)) { - hm_error("obj size is invalid while build drv conf\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drv = (struct drv_tlv *)obj; - struct drv_conf_t *drv_conf = &drv->drv_conf; - - uint32_t dyn_conf_funcs_size = sizeof(dyn_conf_funcs) / sizeof(dyn_conf_funcs[0]); - uint32_t i; - for (i = 0; i < dyn_conf_funcs_size; i++) { - if (node->tag != dyn_conf_funcs[i].tag) - continue; - - if (dyn_conf_funcs[i].handle != NULL && - handle_conf_node_to_obj(pos, dyn_conf_funcs[i].handle, drv, sizeof(*drv)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - - if (dyn_conf_funcs[i].checker != NULL && dyn_conf_funcs[i].checker(drv_conf) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - - break; - } - - if (i == dyn_conf_funcs_size) { - hm_debug("skip in build drv conf\n"); - if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static int32_t send_drv_conf(const struct drv_tlv *drv_conf, uint32_t drv_conf_size) -{ - uint64_t args[] = { - (uintptr_t)drv_conf, - drv_conf_size, - }; - - uint32_t lens[] = { - drv_conf_size, - 0, - }; - - /* the main thread just handle register cmd */ - return hm_drv_call_new("drvmgr", REGISTER_DRV_CONF, args, lens, ARRAY_SIZE(args)); -} - -void dump_drv_conf(void) -{ - uint64_t args[] = {}; - uint32_t lens[] = {}; - - (void)hm_drv_call_new("drvmgr_multi", DUMP_DRV_CONF, args, lens, ARRAY_SIZE(args)); -} - -static int32_t send_drv_service_name(const char *service_name, uint32_t name_size) -{ - uint64_t args[] = { - (uintptr_t)service_name, - name_size, - }; - - uint32_t lens[] = { - name_size, - 0, - }; - - return hm_drv_call_new("drvmgr_multi", UNREGISTER_DRV_CONF, args, lens, ARRAY_SIZE(args)); -} - -void uninstall_drv_permission(const void *obj, uint32_t obj_size) -{ - if (obj == NULL) { - hm_error("obj is invalid while uninstall drv permission\n"); - return; - } - - if (obj_size == 0 || obj_size >= DRV_NAME_MAX_LEN) { - hm_error("obj size is invalid while uninstall drv permission\n"); - return; - } - - const char *service_name = (const char *)obj; - if (send_drv_service_name(service_name, obj_size) != 0) - hm_error("uninstall drv permission failed"); -} - -int32_t install_drv_permission(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue) -{ - /* 1. check the param */ - if (obj == NULL || conf_queue == NULL) { - hm_error("param is invalid while install drv permission\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (obj_size != sizeof(struct drv_mani_t)) { - hm_error("obj size is invalid while install drv permission\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - /* 2. parse the obj to what you want */ - struct drv_mani_t *mani = (struct drv_mani_t *)obj; - - /* 3.create new obj */ - struct drv_tlv *drv = (struct drv_tlv *)malloc(sizeof(struct drv_tlv)); - if (drv == NULL) { - hm_error("drv malloc failed\n"); - return TEE_ERROR_GENERIC; - } - - /* 4.init new obj */ - (void)memset_s(drv, sizeof(*drv), 0, sizeof(*drv)); - - int32_t ret = -1; - if (memcpy_s(&drv->uuid, sizeof(drv->uuid), &mani->srv_uuid, sizeof(mani->srv_uuid)) != 0) { - hm_error("set uuid to drv fail\n"); - goto out; - } - - ret = init_drv_conf(mani, &drv->drv_conf, conf_queue); - if (ret != TEE_SUCCESS) - goto out; - - if (init_drvcall_conf(&drv->drvcall_perm_apply, conf_queue) != 0) - goto out; - - /* 5.handle new obj */ - if (!dlist_empty(&conf_queue->queue)) { - struct dlist_node *pos = dlist_get_next(&conf_queue->queue); - ret = handle_conf_node_to_obj(&pos, build_drv_conf, drv, sizeof(*drv)); - if (ret != TEE_SUCCESS) { - hm_error("handle drv conf failed\n"); - goto out; - } - } - - /* 6.do something else */ - ret = send_drv_conf(drv, sizeof(*drv)); - -out: - /* 7.err handle, free obj */ - free_drv_tlv(drv); - return ret; -} - -#else -int32_t install_drv_permission(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue) -{ - (void)obj; - (void)obj_size; - (void)conf_queue; - return TEE_SUCCESS; -} - -void uninstall_drv_permission(const void *obj, uint32_t obj_size) -{ - (void)obj; - (void)obj_size; -} - -void dump_drv_conf(void) -{ - return; -} - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#include "drv_dyn_conf_builder.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "drvcall_dyn_conf_builder.h" +#include "tee_inner_uuid.h" + +#ifdef TEE_SUPPORT_DYN_CONF + +static struct tee_uuid g_drv_server_uuid = DRVMGR; + +static int32_t check_uuid_valid(struct tee_uuid uuid) +{ + char *buff[sizeof(uuid)] = { 0 }; + + if (memcmp(buff, &uuid, sizeof(uuid)) == 0) + return TEE_ERROR_GENERIC; + + return TEE_SUCCESS; +} + +/* + * free section + * the func that free all things you have malloced + */ +static void do_free_drv_conf(void **list, uint16_t *list_size, uint32_t st_size) +{ + if (*list != NULL && (*list_size) != 0) { + tee_free_sharemem(*list, (*list_size) * st_size); + *list = NULL; + *list_size = 0; + } +} + +static void free_drv_conf(struct drv_conf_t *drv_conf) +{ + if (drv_conf == NULL) + return; + + do_free_drv_conf((void **)&(drv_conf->io_map_list), + &(drv_conf->io_map_list_size), sizeof(struct addr_region_t)); + do_free_drv_conf((void **)&(drv_conf->irq_list), &(drv_conf->irq_list_size), sizeof(uint64_t)); + do_free_drv_conf((void **)&(drv_conf->map_secure_list), + &(drv_conf->map_secure_list_size), sizeof(struct drv_map_secure_t)); + do_free_drv_conf((void **)&(drv_conf->map_nosecure_list), + &(drv_conf->map_nosecure_list_size), sizeof(struct drv_map_nosecure_t)); + do_free_drv_conf((void **)&(drv_conf->mac_info_list), + &(drv_conf->mac_info_list_size), sizeof(struct drv_mac_info_t)); + do_free_drv_conf((void **)&(drv_conf->cmd_perm_list), + &(drv_conf->cmd_perm_list_size), sizeof(struct drv_cmd_perm_info_t)); +} + +static void free_drv_tlv(struct drv_tlv *drv) +{ + free_drv_conf(&drv->drv_conf); + free_drvcall_perm(&drv->drvcall_perm_apply); + free(drv); +} + +/* + * init section + * init all objs that you want to use + */ +static int32_t init_drv_conf_mani(const struct drv_mani_t *mani, struct drv_conf_t *drv_conf) +{ + if (mani->service_name_size >= DRV_NAME_MAX_LEN) { + hm_error("service name is too long %u\n", mani->service_name_size); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (memcpy_s(drv_conf->mani.service_name, DRV_NAME_MAX_LEN, mani->service_name, mani->service_name_size) != 0) { + hm_error("memcpy service name to drv conf failed\n"); + return TEE_ERROR_GENERIC; + } + drv_conf->mani.service_name[mani->service_name_size] = '\0'; + drv_conf->mani.service_name_size = mani->service_name_size; + drv_conf->mani.keep_alive = mani->keep_alive; + drv_conf->mani.data_size = mani->data_size; + drv_conf->mani.stack_size = mani->stack_size; + drv_conf->mani.hardware_type = mani->hardware_type; + + return TEE_SUCCESS; +} + +/* + * scan the conf_queue from start + * when we find item_tag, then we will check it's chip_type + * if chip type is invalid, it will be set DRV_PERM_UNUSED + */ +static int32_t init_drv_conf_filter_chip_type(const struct conf_queue_t *conf_queue, struct tag_crew tags, + void **list, uint16_t *list_size, uint32_t size) +{ + struct dlist_node *pos = NULL; + uint32_t count = 0; + uint8_t flag = 0; + + dlist_for_each(pos, &conf_queue->queue) { + struct conf_node_t *conf_node = dlist_entry(pos, struct conf_node_t, head); + if (conf_node->tag != tags.item_tag && conf_node->tag != tags.data_tag) + continue; + + /* check if chip type is valid */ + if (conf_node->tag == tags.item_tag) { + if (check_item_chip_type(pos, tags.type_tag) != TEE_SUCCESS) { + flag = 0; + conf_node->tag = DRV_PERM_UNUSED; + continue; + } + flag = 1; + continue; + } + + /* if chip type is invalid, then ignore it */ + if (conf_node->tag == tags.data_tag && flag == 0) + continue; + + /* if value is not NULL, means at least has one region */ + if (conf_node->size > 0) + count++; + + /* each split_tag means a new region */ + for (uint32_t i = 0; i < conf_node->size; i++) { + if (conf_node->value[i] == tags.split_tag) + count++; + } + flag = 0; + } + + /* count is 0 means xml don't contain this tag, so it is no need to init */ + if (count == 0) + return TEE_SUCCESS; + + uint32_t tmp_size = count * size; + if (size == 0 || count >= (MAX_IMAGE_LEN / size)) { + hm_error("tmp size is invalid %u\n", tmp_size); + return TEE_ERROR_GENERIC; + } + + *list = tee_alloc_sharemem_aux(&g_drv_server_uuid, tmp_size); + if (*list == NULL) { + hm_error("malloc for tlv list failed\n"); + return TEE_ERROR_GENERIC; + } + + if (memset_s(*list, tmp_size, 0, tmp_size) != 0) { + hm_error("memset for tlv list failed\n"); + (void)tee_free_sharemem(*list, tmp_size); + *list = NULL; + return TEE_ERROR_GENERIC; + } + + *list_size = count; + + return TEE_SUCCESS; +} + +static int32_t init_drv_io_map(struct drv_conf_t *drv_conf, const struct conf_queue_t *conf_queue) +{ + drv_conf->io_map_list_index = 0; + struct tag_crew tags; + tags.item_tag = DRV_PERM_DRV_IO_MAP_ITEM; + tags.data_tag = DRV_PERM_DRV_IO_MAP_ITEM_IOMAP; + tags.type_tag = DRV_PERM_DRV_IO_MAP_ITEM_CHIP_TYPE; + tags.split_tag = ';'; + + return init_drv_conf_filter_chip_type(conf_queue, tags, (void **)&(drv_conf->io_map_list), + &(drv_conf->io_map_list_size), sizeof(struct addr_region_t)); +} + +static int32_t init_drv_irq(struct drv_conf_t *drv_conf, const struct conf_queue_t *conf_queue) +{ + drv_conf->irq_list_index = 0; + struct tag_crew tags; + tags.item_tag = DRV_PERM_IRQ_ITEM; + tags.data_tag = DRV_PERM_IRQ_ITEM_IRQ; + tags.type_tag = DRV_PERM_IRQ_ITEM_CHIP_TYPE; + tags.split_tag = ','; + + return init_drv_conf_filter_chip_type(conf_queue, tags, (void **)&(drv_conf->irq_list), + &(drv_conf->irq_list_size), sizeof(uint64_t)); +} + +static int32_t init_drv_map_secure(struct drv_conf_t *drv_conf, const struct conf_queue_t *conf_queue) +{ + struct tag_crew tags; + tags.item_tag = DRV_PERM_MAP_SECURE_ITEM; + tags.data_tag = DRV_PERM_MAP_SECURE_ITEM_REGION; + tags.type_tag = DRV_PERM_MAP_SECURE_ITEM_CHIP_TYPE; + tags.split_tag = ';'; + + return init_drv_conf_filter_chip_type(conf_queue, tags, (void **)&(drv_conf->map_secure_list), + &(drv_conf->map_secure_list_size), sizeof(struct drv_map_secure_t)); +} + +static int32_t init_drv_map_nosecure(struct drv_conf_t *drv_conf, const struct conf_queue_t *conf_queue) +{ + struct tag_crew tags; + tags.item_tag = DRV_PERM_MAP_NOSECURE_ITEM; + tags.data_tag = DRV_PERM_MAP_NOSECURE_ITEM_UUID; + tags.type_tag = DRV_PERM_MAP_NOSECURE_ITEM_CHIP_TYPE; + tags.split_tag = ','; + + return init_drv_conf_filter_chip_type(conf_queue, tags, (void **)&(drv_conf->map_nosecure_list), + &(drv_conf->map_nosecure_list_size), sizeof(struct drv_map_nosecure_t)); +} + +static int32_t init_drv_mac_info(struct drv_conf_t *drv_conf, const struct conf_queue_t *conf_queue) +{ + drv_conf->mac_info_list_index = 0; + drv_conf->mac_info_list_size = get_num_of_tag(conf_queue, DRV_PERM_DRV_MAC_INFO_ITEM); + + if (drv_conf->mac_info_list_size == 0) + return TEE_SUCCESS; + + /* drv_conf->mac_info_list_size <= 0xffff means tmp_size cannot larger than 0xFFFFFFFF */ + uint32_t tmp_size = drv_conf->mac_info_list_size * sizeof(struct drv_mac_info_t); + if (tmp_size >= MAX_IMAGE_LEN) { + hm_error("mac info tmp size is invalid %u\n", tmp_size); + return TEE_ERROR_GENERIC; + } + + drv_conf->mac_info_list = tee_alloc_sharemem_aux(&g_drv_server_uuid, tmp_size); + if (drv_conf->mac_info_list == NULL) { + hm_error("malloc for mac list failed\n"); + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +static int32_t init_drv_cmd_perm(struct drv_conf_t *drv_conf, const struct conf_queue_t *conf_queue) +{ + drv_conf->cmd_perm_list_index = 0; + drv_conf->cmd_perm_list_size = get_num_of_tag(conf_queue, DRV_PERM_DRV_CMD_PERM_INFO_ITEM); + + if (drv_conf->cmd_perm_list_size == 0) + return TEE_SUCCESS; + + /* drv_conf->cmd_perm_list_size < 0xffff means tmp_size cannot larger than 0xFFFFFFFF */ + uint32_t tmp_size = drv_conf->cmd_perm_list_size * sizeof(struct drv_cmd_perm_info_t); + if (tmp_size >= MAX_IMAGE_LEN) { + hm_error("cmd perm tmp size is invalid %u\n", tmp_size); + return TEE_ERROR_GENERIC; + } + + drv_conf->cmd_perm_list = tee_alloc_sharemem_aux(&g_drv_server_uuid, tmp_size); + if (drv_conf->cmd_perm_list == NULL) { + hm_error("malloc for cmd_perm list failed\n"); + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +static int32_t init_drv_conf(const struct drv_mani_t *mani, struct drv_conf_t *drv_conf, + const struct conf_queue_t *conf_queue) +{ + if (memset_s(drv_conf, sizeof(*drv_conf), 0, sizeof(*drv_conf)) != 0) { + hm_error("memset for init drv conf failed\n"); + return TEE_ERROR_GENERIC; + } + + /* init drv conf manifest by manifest.txt */ + if (init_drv_conf_mani(mani, drv_conf) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + + if (init_drv_io_map(drv_conf, conf_queue) != TEE_SUCCESS || + init_drv_irq(drv_conf, conf_queue) != TEE_SUCCESS || + init_drv_map_secure(drv_conf, conf_queue) != TEE_SUCCESS || + init_drv_map_nosecure(drv_conf, conf_queue) != TEE_SUCCESS || + init_drv_mac_info(drv_conf, conf_queue) != TEE_SUCCESS || + init_drv_cmd_perm(drv_conf, conf_queue) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + + /* init drv basic info */ + drv_conf->drv_basic_info.thread_limit = 1; + drv_conf->drv_basic_info.exception_mode = DYN_CONF_SYSCRASH_TAG; + drv_conf->drv_basic_info.virt2phys = false; + + return TEE_SUCCESS; +} + +static int32_t handle_drv_basic_info_thread_limit(uint32_t *thread_limit, uint32_t size, const char *value) +{ + uint64_t tmp_limit; + + if (value == NULL || size > MAX_UINT32_LEN || size == 0) { + hm_error("invalid parm\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + char buff[MAX_UINT32_LEN + 1]; + if (memcpy_s(buff, sizeof(buff), value, size) != 0) { + hm_error("memcpy failed\n"); + return TEE_ERROR_GENERIC; + } + buff[size] = '\0'; + + if (trans_str_to_int(buff, size, BASE_OF_TEN, &tmp_limit) != TEE_SUCCESS) { + hm_error("get thread limit failed, and thread_limit\n"); + return TEE_ERROR_GENERIC; + } + + if (tmp_limit > THREAD_LIMIT_MAX) { + hm_info("get thread limit %llu larger than THREAD_LIMIT_MAX %u\n", + (unsigned long long)tmp_limit, THREAD_LIMIT_MAX); + *thread_limit = THREAD_LIMIT_MAX; + return TEE_SUCCESS; + } + + *thread_limit = (uint32_t)tmp_limit; + if (*thread_limit == 0) { + hm_error("get thread limit should not be 0\n"); + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +static int32_t handle_drv_basic_info_exception_mode(uint8_t *exception_mode, uint32_t size, const char *value) +{ + if (value == NULL || size >= MAX_IMAGE_LEN) { + hm_error("invalid parm\n"); + return TEE_ERROR_GENERIC; + } + + char buff[size + 1]; + if (memcpy_s(buff, size + 1, value, size) != 0) { + hm_error("memcpy failed\n"); + return TEE_ERROR_GENERIC; + } + buff[size] = '\0'; + + if (strncmp(buff, "restart", size + 1) == 0) { + *exception_mode = DYN_CONF_RESTART_TAG; + return TEE_SUCCESS; + } + + if (strncmp(buff, "ddos", size + 1) == 0) { + *exception_mode = DYN_CONF_DDOS_TAG; + return TEE_SUCCESS; + } + + if (strncmp(buff, "syscrash", size + 1) == 0) { + *exception_mode = DYN_CONF_SYSCRASH_TAG; + return TEE_SUCCESS; + } + + hm_error("cannot handle exception_mode %s\n", buff); + return TEE_ERROR_GENERIC; +} + +static int32_t build_drv_basic_info(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct drv_tlv *drv = NULL; + + if (obj_size != sizeof(*drv)) { + hm_error("obj size is invalid while build drv basic info\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv = (struct drv_tlv *)obj; + struct drv_conf_t *drv_conf = &drv->drv_conf; + + switch (node->tag) { + case DRV_PERM_DRV_BASIC_INFO_UPGRADE: + if (node->size == 1 && node->value[0] == '1') + drv_conf->drv_basic_info.upgrade = true; + break; + case DRV_PERM_DRV_BASIC_INFO_VIRT2PHYS: + if (node->size == 1 && node->value[0] == '1') + drv_conf->drv_basic_info.virt2phys = true; + break; + case DRV_PERM_DRV_BASIC_INFO_THREAD_LIMIT: + /* thread_limit has been checked in handle_drv_basic_info_thread_limit */ + if (handle_drv_basic_info_thread_limit(&drv_conf->drv_basic_info.thread_limit, node->size, node->value) != 0) + return TEE_ERROR_GENERIC; + break; + case DRV_PERM_DRV_BASIC_INFO_EXCEPTION_MODE: + if (handle_drv_basic_info_exception_mode(&drv_conf->drv_basic_info.exception_mode, + node->size, node->value) != 0) + return TEE_ERROR_GENERIC; + break; + default: + break; + } + + return TEE_SUCCESS; +} + +/* build io map */ +static int32_t tlv_to_iomap_region(const char *iomap_buff, uint32_t buff_len, struct addr_region_t *list, + uint32_t list_size, uint16_t *count) +{ + uint32_t i; + char buff[MAX_UINT64_LEN + 1] = { 0 }; + const char *head = iomap_buff; + + if (buff_len == 0) { + hm_error("iomap buff len is 0\n"); + return TEE_ERROR_GENERIC; + } + + for (i = 0; i <= buff_len; i++) { + (void)memset_s(buff, MAX_UINT64_LEN + 1, 0, MAX_UINT64_LEN + 1); + + if (iomap_buff[i] == ',' || iomap_buff[i] == ';' || iomap_buff[i] == '\0') { + uint64_t offset = (uint64_t)(uintptr_t)(&iomap_buff[i] - head); + if (offset > MAX_UINT64_LEN || offset == 0) { + hm_error("get iomap range offset failed %llu\n", (unsigned long long)offset); + return TEE_ERROR_GENERIC; + } + + if (memcpy_s(buff, MAX_UINT64_LEN, head, (size_t)offset) != 0) { + hm_error("memcpy for iomap buff failed\n"); + return TEE_ERROR_GENERIC; + } + buff[(uint32_t)offset] = '\0'; + if (i < buff_len) + head = (const char *)&iomap_buff[i + 1]; + } + + if (*count >= list_size) { + hm_error("io map region list overflow\n"); + return TEE_ERROR_GENERIC; + } + + if (iomap_buff[i] == ',') { + if (trans_str_to_int(buff, strnlen(buff, MAX_UINT64_LEN), + BASE_OF_HEX, &list[*count].start) != TEE_SUCCESS) { + hm_error("get iomap region start failed\n"); + return TEE_ERROR_GENERIC; + } + } else if (iomap_buff[i] == ';' || iomap_buff[i] == '\0') { + if (trans_str_to_int(buff, strnlen(buff, MAX_UINT64_LEN), + BASE_OF_HEX, &list[*count].end) != TEE_SUCCESS) { + hm_error("get iomap region end failed\n"); + return TEE_ERROR_GENERIC; + } + *count = *count + 1; + } + } + + return TEE_SUCCESS; +} + +static int32_t check_drv_io_map_invalid(const void *obj) +{ + const struct drv_conf_t *drv_conf = (const struct drv_conf_t *)obj; + if (drv_conf == NULL) { + hm_error("invalid drv conf\n"); + return TEE_ERROR_GENERIC; + } + + uint32_t i; + for (i = 0; i < drv_conf->io_map_list_size; i++) { + if (drv_conf->io_map_list[i].start % 0x1000 != 0 || + drv_conf->io_map_list[i].end % 0x1000 != 0) { + hm_error("io map region should be aligned by 0x1000\n"); + return TEE_ERROR_GENERIC; + } + + if (drv_conf->io_map_list[i].end <= drv_conf->io_map_list[i].start) { + hm_error("io map region end must larger than start\n"); + return TEE_ERROR_GENERIC; + } + } + + return TEE_SUCCESS; +} + +static int32_t handle_drv_io_map_item_iomap(struct drv_conf_t *drv_conf, uint32_t size, const char *value) +{ + if (size == 0 || value == NULL || size >= MAX_IMAGE_LEN) { + hm_error("invalid params\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + char *iomap_buff = NULL; + /* size has been checked in handle_conf_node_to_obj, size is smaller than MAX_IMAGE_LEN */ + iomap_buff = malloc(size + 1); + if (iomap_buff == NULL) { + hm_error("malloc for iomap buff failed\n"); + return TEE_ERROR_GENERIC; + } + + /* if walk in this func, iomap list size couldn't be zero */ + if (memcpy_s(iomap_buff, size + 1, value, size) != 0) { + hm_error("memcpy for iomap buff failed\n"); + free(iomap_buff); + return TEE_ERROR_GENERIC; + } + iomap_buff[size] = '\0'; + + if (tlv_to_iomap_region(iomap_buff, strnlen(iomap_buff, MAX_IMAGE_LEN), + drv_conf->io_map_list, drv_conf->io_map_list_size, + &drv_conf->io_map_list_index) != 0) { + hm_error("tlv to iomap region failed \n"); + free(iomap_buff); + return TEE_ERROR_GENERIC; + } + + free(iomap_buff); + return TEE_SUCCESS; +} + +static int32_t build_drv_io_map_item(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct drv_conf_t *drv_conf = NULL; + + if (obj_size != sizeof(*drv_conf)) { + hm_error("obj size is invalid while build drv io map item\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv_conf = (struct drv_conf_t *)obj; + + switch (node->tag) { + case DRV_PERM_DRV_IO_MAP_ITEM_IOMAP: + if (handle_drv_io_map_item_iomap(drv_conf, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle drv io map item iomap failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_drv_io_map(struct dlist_node **pos, const struct conf_node_t *node, void *obj, uint32_t obj_size) +{ + struct drv_tlv *drv = NULL; + + if (obj_size != sizeof(*drv)) { + hm_error("obj size is invalid while build drv io map\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv = (struct drv_tlv *)obj; + struct drv_conf_t *drv_conf = &drv->drv_conf; + + switch (node->tag) { + case DRV_PERM_DRV_IO_MAP_ITEM: + if (handle_conf_node_to_obj(pos, build_drv_io_map_item, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) { + hm_error("build drv io map item failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + hm_debug("skip in build iomap\n"); + if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} + +/* build drv irq */ +static int32_t handle_drv_irq_item_irq(struct drv_conf_t *drv_conf, uint32_t size, const char *value) +{ + int32_t ret = TEE_SUCCESS; + char buff[MAX_UINT64_LEN + 1]; + + if (size == 0 || value == NULL || size >= MAX_IMAGE_LEN) { + hm_error("size is invalid\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + char *irq_buff = malloc(size + 1); + if (irq_buff == NULL) { + hm_error("malloc for irq buff failed\n"); + return TEE_ERROR_GENERIC; + } + + if (memcpy_s(irq_buff, size + 1, value, size) != 0) { + ret = TEE_ERROR_GENERIC; + goto out; + } + irq_buff[size] = '\0'; + + char *head = irq_buff; + for (uint32_t i = 0; i <= size; i++) { + (void)memset_s(buff, MAX_UINT64_LEN + 1, 0, MAX_UINT64_LEN + 1); + + if (irq_buff[i] == ',' || irq_buff[i] == '\0') { + uint64_t offset = (uint64_t)(uintptr_t)(&irq_buff[i] - head); + if (offset > MAX_UINT64_LEN || offset == 0) { + hm_error("get irq offset failed %llu\n", (unsigned long long)offset); + ret = TEE_ERROR_GENERIC; + goto out; + } + + if (memcpy_s(buff, MAX_UINT64_LEN, head, (size_t)offset) != 0) { + hm_error("memcpy for irq buff failed\n"); + ret = TEE_ERROR_GENERIC; + goto out; + } + buff[(uint32_t)offset] = '\0'; + if (i < size) + head = &irq_buff[i + 1]; + + if (drv_conf->irq_list_index >= drv_conf->irq_list_size || + trans_str_to_int(buff, strnlen(buff, MAX_UINT64_LEN), BASE_OF_TEN, + &drv_conf->irq_list[drv_conf->irq_list_index]) != TEE_SUCCESS) { + hm_error("get irq failed\n"); + ret = TEE_ERROR_GENERIC; + goto out; + } + drv_conf->irq_list_index = drv_conf->irq_list_index + 1; + } + } + +out: + free(irq_buff); + return ret; +} + +static int32_t build_drv_irq_item(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct drv_conf_t *drv_conf = NULL; + + if (obj_size != sizeof(*drv_conf)) { + hm_error("obj size is invalid while build drv irq item\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv_conf = (struct drv_conf_t *)obj; + + switch (node->tag) { + case DRV_PERM_IRQ_ITEM_IRQ: + if (handle_drv_irq_item_irq(drv_conf, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle drv irq item irq failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t check_drv_irq_invalid(const void *obj) +{ + const struct drv_conf_t *drv_conf = (const struct drv_conf_t *)obj; + + uint32_t i; + for (i = 0; i < drv_conf->irq_list_size; i++) { + if (drv_conf->irq_list[i] < IRQ_MIN) { + hm_error("invalid irq %llu\n", (unsigned long long)drv_conf->irq_list[i]); + return TEE_ERROR_GENERIC; + } + } + return TEE_SUCCESS; +} + +static int32_t build_drv_irq(struct dlist_node **pos, const struct conf_node_t *node, void *obj, uint32_t obj_size) +{ + struct drv_tlv *drv = NULL; + + if (obj_size != sizeof(*drv)) { + hm_error("obj size is invalid while build drv irq\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv = (struct drv_tlv *)obj; + struct drv_conf_t *drv_conf = &drv->drv_conf; + + switch (node->tag) { + case DRV_PERM_IRQ_ITEM: + if (handle_conf_node_to_obj(pos, build_drv_irq_item, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) { + hm_error("build drv irq item failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + hm_debug("skip drv irq\n"); + if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} + +/* build map secure */ +static int32_t tlv_to_map_secure_region(const char *secure_buff, uint32_t secure_buff_len, + struct drv_map_secure_t *list, uint32_t list_size, uint16_t *count) +{ + if (secure_buff_len == 0) { + hm_error("secure buff len is 0\n"); + return TEE_ERROR_GENERIC; + } + + uint32_t i; + char buff[MAX_UINT64_LEN + 1] = { 0 }; + const char *head = secure_buff; + for (i = 0; i <= secure_buff_len; i++) { + (void)memset_s(buff, MAX_UINT64_LEN + 1, 0, MAX_UINT64_LEN + 1); + + if (secure_buff[i] == ',' || secure_buff[i] == ';' || secure_buff[i] == '\0') { + uint64_t offset = (uint64_t)(uintptr_t)(&secure_buff[i] - head); + if (offset > MAX_UINT64_LEN || offset == 0) { + hm_error("get map_secure range offset failed %llu\n", (unsigned long long)offset); + return TEE_ERROR_GENERIC; + } + + if (memcpy_s(buff, MAX_UINT64_LEN, head, (size_t)offset) != 0) { + hm_error("memcpy for map_secure buff failed\n"); + return TEE_ERROR_GENERIC; + } + buff[(uint32_t)offset] = '\0'; + if (i < secure_buff_len) + head = (const char *)&secure_buff[i + 1]; + } + + if (*count >= list_size) { + hm_error("map_secure region list overflow\n"); + return TEE_ERROR_GENERIC; + } + + if (secure_buff[i] == ',') { + if (trans_str_to_int(buff, strnlen(buff, MAX_UINT64_LEN), + BASE_OF_HEX, &list[*count].region.start) != TEE_SUCCESS) { + hm_error("get map_secure region start failed\n"); + return TEE_ERROR_GENERIC; + } + } else if (secure_buff[i] == ';' || secure_buff[i] == '\0') { + if (trans_str_to_int(buff, strnlen(buff, MAX_UINT64_LEN), + BASE_OF_HEX, &list[*count].region.end) != TEE_SUCCESS) { + hm_error("get map_secure region end failed\n"); + return TEE_ERROR_GENERIC; + } + *count = *count + 1; + } + } + + return TEE_SUCCESS; +} + +static int32_t get_ava_pos_in_map_secure(const struct drv_conf_t *drv_conf, uint16_t *uuid_pos, uint16_t *region_pos) +{ + uint32_t i; + for (i = 0; i < drv_conf->map_secure_list_size; i++) { + if (check_uuid_valid(drv_conf->map_secure_list[i].uuid) != TEE_SUCCESS) + break; + } + *uuid_pos = i; + + for (i = 0; i < drv_conf->map_secure_list_size; i++) { + if (drv_conf->map_secure_list[i].region.start == 0 && + drv_conf->map_secure_list[i].region.end == 0) + break; + } + *region_pos = i; + + return TEE_SUCCESS; +} + +static int32_t handle_drv_map_secure_item_uuid(struct drv_conf_t *drv_conf, uint32_t size, const char *value) +{ + struct tee_uuid uuid; + + int32_t ret = tlv_to_uuid(value, size, &uuid); + if (ret != TEE_SUCCESS) + return ret; + + uint32_t i; + uint16_t uuid_pos; + uint16_t region_pos; + if (get_ava_pos_in_map_secure(drv_conf, &uuid_pos, ®ion_pos) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + + if (uuid_pos == region_pos) { + if (region_pos < drv_conf->map_secure_list_size && + memcpy_s(&drv_conf->map_secure_list[region_pos].uuid, sizeof(drv_conf->map_secure_list[region_pos].uuid), + &uuid, sizeof(uuid)) != 0) { + hm_error("memcpy for uuid in map secure list failed\n"); + return TEE_ERROR_GENERIC; + } + } else if (region_pos > uuid_pos) { + for (i = uuid_pos; i < region_pos; i++) { + if (i < drv_conf->map_secure_list_size && + memcpy_s(&drv_conf->map_secure_list[i].uuid, sizeof(drv_conf->map_secure_list[i].uuid), + &uuid, sizeof(uuid)) != 0) { + hm_error("memcpy for uuid in map sercure list failed\n"); + return TEE_ERROR_GENERIC; + } + } + } else { + hm_error("uuid pos cannot larger than region pos, someting wrong happeds\n"); + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +static int32_t handle_drv_map_secure_item_region(struct drv_conf_t *drv_conf, uint32_t size, const char *value) +{ + if (size >= MAX_IMAGE_LEN) { + hm_error("param is invalid %u\n", size); + return TEE_ERROR_BAD_PARAMETERS; + } + + int32_t ret = TEE_ERROR_GENERIC; + uint16_t uuid_pos; + uint16_t region_pos; + if (get_ava_pos_in_map_secure(drv_conf, &uuid_pos, ®ion_pos) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + + char *iomap_buff = malloc(size + 1); + if (iomap_buff == NULL) { + hm_error("malloc for iomap buff failed\n"); + return TEE_ERROR_GENERIC; + } + + if (memset_s(iomap_buff, size + 1, 0, size + 1) != 0 || memcpy_s(iomap_buff, size + 1, value, size) != 0) { + hm_error("memset or memcpy for iomap buff failed\n"); + goto out; + } + + if (uuid_pos == region_pos) { + if (tlv_to_map_secure_region(iomap_buff, strnlen(iomap_buff, MAX_IMAGE_LEN), + drv_conf->map_secure_list, drv_conf->map_secure_list_size, ®ion_pos) != 0) + goto out; + } else if (uuid_pos > region_pos) { + if (tlv_to_map_secure_region(iomap_buff, strnlen(iomap_buff, MAX_IMAGE_LEN), + drv_conf->map_secure_list, drv_conf->map_secure_list_size, ®ion_pos) != 0) + goto out; + + for (uint32_t i = uuid_pos; i < region_pos; i++) { + if (i < drv_conf->map_secure_list_size && + memcpy_s(&drv_conf->map_secure_list[i].uuid, sizeof(drv_conf->map_secure_list[i].uuid), + &drv_conf->map_secure_list[uuid_pos - 1].uuid, + sizeof(drv_conf->map_secure_list[uuid_pos - 1].uuid)) != 0) { + hm_error("memcpy map secure region uuid failed\n"); + goto out; + } + } + } else { + hm_error("region pos cannot larger than uuid pos, someting wrong happeds\n"); + goto out; + } + + ret = TEE_SUCCESS; +out: + free(iomap_buff); + return ret; +} + +static int32_t build_drv_map_secure_item(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct drv_conf_t *drv_conf = NULL; + + if (obj_size != sizeof(*drv_conf)) { + hm_error("obj size is invalid while build drv map secure item\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv_conf = (struct drv_conf_t *)obj; + + switch (node->tag) { + case DRV_PERM_MAP_SECURE_ITEM_UUID: + if (handle_drv_map_secure_item_uuid(drv_conf, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle drv map secure item uuid failed\n"); + return TEE_ERROR_GENERIC; + } + break; + case DRV_PERM_MAP_SECURE_ITEM_REGION: + if (handle_drv_map_secure_item_region(drv_conf, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle drv map secure item region failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t check_drv_map_secure_invalid(const void *obj) +{ + const struct drv_conf_t *drv_conf = (const struct drv_conf_t *)obj; + + uint32_t i; + for (i = 0; i < drv_conf->map_secure_list_size; i++) { + if (drv_conf->map_secure_list[i].region.start % 0x1000 != 0 || + drv_conf->map_secure_list[i].region.end % 0x1000 != 0) { + hm_error("map secure region should be aligned by 4K\n"); + return TEE_ERROR_GENERIC; + } + + if (drv_conf->map_secure_list[i].region.end <= drv_conf->map_secure_list[i].region.start) { + hm_error("map secure region end must larger than start\n"); + return TEE_ERROR_GENERIC; + } + + if (check_uuid_valid(drv_conf->map_secure_list[i].uuid) != TEE_SUCCESS) { + hm_error("map secure uuid is invalid\n"); + return TEE_ERROR_GENERIC; + } + } + + return TEE_SUCCESS; +} + +static int32_t build_drv_map_secure(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + struct drv_tlv *drv = NULL; + + if (obj_size != sizeof(*drv)) { + hm_error("obj size is invalid while build drv map secure\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv = (struct drv_tlv *)obj; + struct drv_conf_t *drv_conf = &drv->drv_conf; + + switch (node->tag) { + case DRV_PERM_MAP_SECURE_ITEM: + if (handle_conf_node_to_obj(pos, build_drv_map_secure_item, + drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) { + hm_error("build drv map secure item failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + hm_debug("skip drv map secure\n"); + if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} + +/* build map nosecure */ +static int32_t check_drv_map_nosecure_invalid(const void *obj) +{ + const struct drv_conf_t *drv_conf = (const struct drv_conf_t *)obj; + + uint32_t i; + for (i = 0; i < drv_conf->map_nosecure_list_size; i++) { + if (check_uuid_valid(drv_conf->map_nosecure_list[i].uuid) != TEE_SUCCESS) { + hm_error("map nosecure uuid is invalid\n"); + return TEE_ERROR_GENERIC; + } + } + + return TEE_SUCCESS; +} + +static int32_t handle_drv_map_nosecure_item_uuid(struct drv_conf_t *drv_conf, uint32_t size, const char *value) +{ + if (size >= MAX_IMAGE_LEN) { + hm_error("size is invalid\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + char *buff = malloc(size + 1); + if (buff == NULL) { + hm_error("malloc for nosecure item failed\n"); + return TEE_ERROR_GENERIC; + } + + int32_t ret = TEE_SUCCESS; + if (memcpy_s(buff, size + 1, value, size) != 0) { + hm_error("memcpy for nosecure item failed\n"); + ret = TEE_ERROR_GENERIC; + goto out; + } + buff[size] = '\0'; + + char *head = buff; + uint32_t i; + for (i = 0; i <= size; i++) { + if (buff[i] == ',' || buff[i] == '\0') { + uint32_t offset = (uint32_t)(uintptr_t)(&buff[i] - head); + if (drv_conf->map_nosecure_list_index >= drv_conf->map_nosecure_list_size) { + hm_error("map nosecure list index overflow\n"); + ret = TEE_ERROR_GENERIC; + goto out; + } + + ret = tlv_to_uuid(head, offset, &drv_conf->map_nosecure_list[drv_conf->map_nosecure_list_index].uuid); + if (ret != TEE_SUCCESS) + goto out; + + drv_conf->map_nosecure_list_index++; + if (i < size) + head = &buff[i + 1]; + } + } + +out: + /* buff cannot be NULL */ + free(buff); + return ret; +} + +static int32_t build_drv_map_nosecure_item(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct drv_conf_t *drv_conf = NULL; + + if (obj_size != sizeof(*drv_conf)) { + hm_error("obj size is invalid while build drv map nosecure item\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv_conf = (struct drv_conf_t *)obj; + + switch (node->tag) { + case DRV_PERM_MAP_NOSECURE_ITEM_UUID: + if (handle_drv_map_nosecure_item_uuid(drv_conf, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle drv map nosecure item uuid failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_drv_map_nosecure(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + struct drv_tlv *drv = NULL; + + if (obj_size != sizeof(*drv)) { + hm_error("obj size is invalid while build drv map nonsecure\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv = (struct drv_tlv *)obj; + struct drv_conf_t *drv_conf = &drv->drv_conf; + + switch (node->tag) { + case DRV_PERM_MAP_NOSECURE_ITEM: + if (handle_conf_node_to_obj(pos, build_drv_map_nosecure_item, + drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) { + hm_error("build drv map nosecure item failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} + +/* build mac info */ +static int32_t check_drv_mac_info_invalid(const void *obj) +{ + const struct drv_conf_t *drv_conf = (const struct drv_conf_t *)obj; + + uint32_t i, j; + for (i = 0; i < drv_conf->mac_info_list_size; i++) { + if (check_uuid_valid(drv_conf->mac_info_list[i].uuid) != TEE_SUCCESS) { + hm_error("mac info uuid is invalid\n"); + return TEE_ERROR_GENERIC; + } + for (j = i + 1; j < drv_conf->mac_info_list_size; j++) { + if (memcmp(&drv_conf->mac_info_list[i].uuid, &drv_conf->mac_info_list[j].uuid, + sizeof(drv_conf->mac_info_list[i].uuid)) == 0) { + hm_error("mac info uuid %08x-%04x-%04x set more than one time\n", + drv_conf->mac_info_list[i].uuid.timeLow, drv_conf->mac_info_list[i].uuid.timeMid, + drv_conf->mac_info_list[i].uuid.timeHiAndVersion); + return TEE_ERROR_GENERIC; + } + } + } + + return TEE_SUCCESS; +} + +static int32_t handle_drv_mac_info_item_permission(struct drv_conf_t *drv_conf, uint32_t size, const char *value) +{ + if (drv_conf->mac_info_list_index >= drv_conf->mac_info_list_size) { + hm_error("mac_info_list_index is invalid\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + int32_t ret = combine_perms(&drv_conf->mac_info_list[drv_conf->mac_info_list_index].perm, size, value); + + return ret; +} + +static int32_t handle_drv_mac_info_item_uuid(struct drv_conf_t *drv_conf, uint32_t size, const char *value) +{ + struct tee_uuid uuid; + uint32_t count = drv_conf->mac_info_list_index; + + if (count >= drv_conf->mac_info_list_size) { + hm_error("mac_info_list_index is overflow %u\n", count); + return TEE_ERROR_GENERIC; + } + + int32_t ret = tlv_to_uuid(value, size, &uuid); + if (ret != TEE_SUCCESS) + return ret; + + if (memcpy_s(&drv_conf->mac_info_list[count].uuid, sizeof(drv_conf->mac_info_list[count].uuid), + &uuid, sizeof(struct tee_uuid)) != 0) { + hm_error("memcpy for uuid in mac info list failed\n"); + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +static int32_t build_drv_mac_info_item(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct drv_conf_t *drv_conf = NULL; + if (obj_size != sizeof(*drv_conf)) { + hm_error("obj size is invalid while build drv mac info item\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv_conf = (struct drv_conf_t *)obj; + + switch (node->tag) { + case DRV_PERM_DRV_MAC_INFO_ITEM_UUID: + if (handle_drv_mac_info_item_uuid(drv_conf, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle drv mac info item uuid failed\n"); + return TEE_ERROR_GENERIC; + } + break; + case DRV_PERM_DRV_MAC_INFO_ITEM_PERMISSION: + if (handle_drv_mac_info_item_permission(drv_conf, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle drv mac info item permission failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_drv_mac_info(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + struct drv_tlv *drv = NULL; + + if (obj_size != sizeof(*drv)) { + hm_error("obj size is invalid while build drv mac info\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv = (struct drv_tlv *)obj; + struct drv_conf_t *drv_conf = &drv->drv_conf; + + switch (node->tag) { + case DRV_PERM_DRV_MAC_INFO_ITEM: + if (handle_conf_node_to_obj(pos, build_drv_mac_info_item, + drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) { + hm_error("build drv mac info item failed\n"); + return TEE_ERROR_GENERIC; + } + drv_conf->mac_info_list_index = drv_conf->mac_info_list_index + 1; + break; + default: + hm_debug("skip in build drv mac info\n"); + if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} + +/* build cmd perm info */ +static int32_t check_drv_cmd_perm_invalid(const void *obj) +{ + const struct drv_conf_t *drv_conf = (const struct drv_conf_t *)obj; + + uint32_t i, j; + for (i = 0; i < drv_conf->cmd_perm_list_size; i++) { + if (drv_conf->cmd_perm_list[i].perm == 0) { + hm_error("cmd perm is invalid\n"); + return TEE_ERROR_GENERIC; + } + for (j = i + 1; j < drv_conf->cmd_perm_list_size; j++) { + if (drv_conf->cmd_perm_list[i].cmd == drv_conf->cmd_perm_list[j].cmd) { + hm_error("cmd %llx has been set more than one time in cmd perm\n", + (unsigned long long)drv_conf->cmd_perm_list[i].cmd); + return TEE_ERROR_GENERIC; + } + } + } + + return TEE_SUCCESS; +} + +static int32_t handle_drv_cmd_perm_info_item_cmd(struct drv_conf_t *drv_conf, uint32_t size, const char *value) +{ + uint64_t tmp_cmd = 0; + if (size == 0 || size > MAX_UINT32_LEN) { + hm_error("param invalid while handle cmd perm info item cmd\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + char buff[MAX_UINT32_LEN + 1]; + if (memcpy_s(buff, sizeof(buff), value, size) != 0) { + hm_error("memcpy failed while handle cmd perm info item cmd\n"); + return TEE_ERROR_GENERIC; + } + buff[size] = '\0'; + + if (trans_str_to_int(buff, size, BASE_OF_HEX, &tmp_cmd) != TEE_SUCCESS) { + hm_error("get cmd failed\n"); + return TEE_ERROR_GENERIC; + } + + if (tmp_cmd > DRV_CMD_MAX) { + hm_error("get cmd %llu is larger than DRV_CMD_MAX\n", (unsigned long long)tmp_cmd); + return TEE_ERROR_GENERIC; + } + + if (drv_conf->cmd_perm_list_index >= drv_conf->cmd_perm_list_size) { + hm_error("cmd_perm_list_index is overflow %u\n", drv_conf->cmd_perm_list_index); + return TEE_ERROR_GENERIC; + } + + drv_conf->cmd_perm_list[drv_conf->cmd_perm_list_index].cmd = (uint32_t)tmp_cmd; + + return TEE_SUCCESS; +} + +static int32_t handle_drv_cmd_perm_info_item_permission(struct drv_conf_t *drv_conf, uint32_t size, const char *value) +{ + if (size == 0 || size > MAX_UINT32_LEN) { + hm_error("param invalid while handle cmd perm info item permission\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + char buff[MAX_UINT32_LEN + 1]; + if (memcpy_s(buff, sizeof(buff), value, size) != 0) { + hm_error("memcpy failed while handle cmd perm info item permission\n"); + return TEE_ERROR_GENERIC; + } + buff[size] = '\0'; + + uint64_t off = 0; + if (trans_str_to_int(buff, size, BASE_OF_TEN, &off) != TEE_SUCCESS) { + hm_error("get perm failed\n"); + return TEE_ERROR_GENERIC; + } + + if (off == 0 || off > BIT_NUM_OF_UINT64) { + hm_error("cmd permssion must in range of [1, 64]\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (drv_conf->cmd_perm_list_index >= drv_conf->cmd_perm_list_size) { + hm_error("cmd_perm_list_index is overflow %u\n", drv_conf->cmd_perm_list_index); + return TEE_ERROR_GENERIC; + } + + drv_conf->cmd_perm_list[drv_conf->cmd_perm_list_index].perm = (1 << (off - 1)); + + return TEE_SUCCESS; +} + +static int32_t build_drv_cmd_perm_info_item(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct drv_conf_t *drv_conf = NULL; + if (obj_size != sizeof(*drv_conf)) { + hm_error("obj size is invalid while build drv cmd perm info item\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv_conf = (struct drv_conf_t *)obj; + + switch (node->tag) { + case DRV_PERM_DRV_CMD_PERM_INFO_ITEM_CMD: + if (handle_drv_cmd_perm_info_item_cmd(drv_conf, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle drv cmd perm info item cmd failed\n"); + return TEE_ERROR_GENERIC; + } + break; + case DRV_PERM_DRV_CMD_PERM_INFO_ITEM_PERMISSION: + if (handle_drv_cmd_perm_info_item_permission(drv_conf, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle drv cmd perm info item permission failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_drv_cmd_perm_info(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + struct drv_tlv *drv = NULL; + + if (obj_size != sizeof(*drv)) { + hm_error("obj size is invalid while build drv cmd perm info\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv = (struct drv_tlv *)obj; + struct drv_conf_t *drv_conf = &drv->drv_conf; + + switch (node->tag) { + case DRV_PERM_DRV_CMD_PERM_INFO_ITEM: + if (handle_conf_node_to_obj(pos, build_drv_cmd_perm_info_item, + drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) { + hm_error("build drv cmd perm info item failed\n"); + return TEE_ERROR_GENERIC; + } + drv_conf->cmd_perm_list_index = drv_conf->cmd_perm_list_index + 1; + break; + default: + hm_debug("skip in build drv cmd perm info\n"); + if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_drv_drvcall_conf(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + struct drv_tlv *drv = NULL; + + if (obj_size != sizeof(*drv)) { + hm_error("obj size is invalid while build drv drvcall conf\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv = (struct drv_tlv *)obj; + struct drvcall_perm_apply_t *drvcall_perm = &drv->drvcall_perm_apply; + int32_t ret = build_drvcall_perm_apply(pos, node, drvcall_perm, sizeof(*drvcall_perm)); + if (ret != 0) { + hm_error("drv build drvcall conf fail\n"); + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +static struct dyn_conf_build_func dyn_conf_funcs[] = { + { DRV_PERM_DRV_BASIC_INFO, build_drv_basic_info, NULL }, + { DRV_PERM_DRV_IO_MAP, build_drv_io_map, check_drv_io_map_invalid }, + { DRV_PERM_IRQ, build_drv_irq, check_drv_irq_invalid }, + { DRV_PERM_MAP_SECURE, build_drv_map_secure, check_drv_map_secure_invalid }, + { DRV_PERM_MAP_NOSECURE, build_drv_map_nosecure, check_drv_map_nosecure_invalid }, + { DRV_PERM_DRV_CMD_PERM_INFO, build_drv_cmd_perm_info, check_drv_cmd_perm_invalid }, + { DRV_PERM_DRV_MAC_INFO, build_drv_mac_info, check_drv_mac_info_invalid }, + { DRV_PERM_DRVCALL_PERM_APPLY, build_drv_drvcall_conf, NULL }, +}; + +/* build drv conf */ +static int32_t build_drv_conf(struct dlist_node **pos, const struct conf_node_t *node, void *obj, uint32_t obj_size) +{ + struct drv_tlv *drv = NULL; + + if (obj_size != sizeof(*drv)) { + hm_error("obj size is invalid while build drv conf\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drv = (struct drv_tlv *)obj; + struct drv_conf_t *drv_conf = &drv->drv_conf; + + uint32_t dyn_conf_funcs_size = sizeof(dyn_conf_funcs) / sizeof(dyn_conf_funcs[0]); + uint32_t i; + for (i = 0; i < dyn_conf_funcs_size; i++) { + if (node->tag != dyn_conf_funcs[i].tag) + continue; + + if (dyn_conf_funcs[i].handle != NULL && + handle_conf_node_to_obj(pos, dyn_conf_funcs[i].handle, drv, sizeof(*drv)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + + if (dyn_conf_funcs[i].checker != NULL && dyn_conf_funcs[i].checker(drv_conf) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + + break; + } + + if (i == dyn_conf_funcs_size) { + hm_debug("skip in build drv conf\n"); + if (handle_conf_node_to_obj(pos, NULL, drv_conf, sizeof(*drv_conf)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +static int32_t send_drv_conf(const struct drv_tlv *drv_conf, uint32_t drv_conf_size) +{ + uint64_t args[] = { + (uintptr_t)drv_conf, + drv_conf_size, + }; + + uint32_t lens[] = { + drv_conf_size, + 0, + }; + + /* the main thread just handle register cmd */ + return hm_drv_call_new("drvmgr", REGISTER_DRV_CONF, args, lens, ARRAY_SIZE(args)); +} + +void dump_drv_conf(void) +{ + uint64_t args[] = {}; + uint32_t lens[] = {}; + + (void)hm_drv_call_new("drvmgr_multi", DUMP_DRV_CONF, args, lens, ARRAY_SIZE(args)); +} + +static int32_t send_drv_service_name(const char *service_name, uint32_t name_size) +{ + uint64_t args[] = { + (uintptr_t)service_name, + name_size, + }; + + uint32_t lens[] = { + name_size, + 0, + }; + + return hm_drv_call_new("drvmgr_multi", UNREGISTER_DRV_CONF, args, lens, ARRAY_SIZE(args)); +} + +void uninstall_drv_permission(const void *obj, uint32_t obj_size) +{ + if (obj == NULL) { + hm_error("obj is invalid while uninstall drv permission\n"); + return; + } + + if (obj_size == 0 || obj_size >= DRV_NAME_MAX_LEN) { + hm_error("obj size is invalid while uninstall drv permission\n"); + return; + } + + const char *service_name = (const char *)obj; + if (send_drv_service_name(service_name, obj_size) != 0) + hm_error("uninstall drv permission failed"); +} + +int32_t install_drv_permission(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue) +{ + /* 1. check the param */ + if (obj == NULL || conf_queue == NULL) { + hm_error("param is invalid while install drv permission\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (obj_size != sizeof(struct drv_mani_t)) { + hm_error("obj size is invalid while install drv permission\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + /* 2. parse the obj to what you want */ + struct drv_mani_t *mani = (struct drv_mani_t *)obj; + + /* 3.create new obj */ + struct drv_tlv *drv = (struct drv_tlv *)malloc(sizeof(struct drv_tlv)); + if (drv == NULL) { + hm_error("drv malloc failed\n"); + return TEE_ERROR_GENERIC; + } + + /* 4.init new obj */ + (void)memset_s(drv, sizeof(*drv), 0, sizeof(*drv)); + + int32_t ret = -1; + if (memcpy_s(&drv->uuid, sizeof(drv->uuid), &mani->srv_uuid, sizeof(mani->srv_uuid)) != 0) { + hm_error("set uuid to drv fail\n"); + goto out; + } + + ret = init_drv_conf(mani, &drv->drv_conf, conf_queue); + if (ret != TEE_SUCCESS) + goto out; + + if (init_drvcall_conf(&drv->drvcall_perm_apply, conf_queue) != 0) + goto out; + + /* 5.handle new obj */ + if (!dlist_empty(&conf_queue->queue)) { + struct dlist_node *pos = dlist_get_next(&conf_queue->queue); + ret = handle_conf_node_to_obj(&pos, build_drv_conf, drv, sizeof(*drv)); + if (ret != TEE_SUCCESS) { + hm_error("handle drv conf failed\n"); + goto out; + } + } + + /* 6.do something else */ + ret = send_drv_conf(drv, sizeof(*drv)); + +out: + /* 7.err handle, free obj */ + free_drv_tlv(drv); + return ret; +} + +#else +int32_t install_drv_permission(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue) +{ + (void)obj; + (void)obj_size; + (void)conf_queue; + return TEE_SUCCESS; +} + +void uninstall_drv_permission(const void *obj, uint32_t obj_size) +{ + (void)obj; + (void)obj_size; +} + +void dump_drv_conf(void) +{ + return; +} + +#endif diff --git a/lib/syslib/libdynconfbuilder/src/drvcall_dyn_conf_builder.c b/lib/syslib/libdynconfbuilder/src/drvcall_dyn_conf_builder.c index 750378ca..8840a39c 100644 --- a/lib/syslib/libdynconfbuilder/src/drvcall_dyn_conf_builder.c +++ b/lib/syslib/libdynconfbuilder/src/drvcall_dyn_conf_builder.c @@ -1,393 +1,398 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: drv dynamic permission dispatch interface implementation - * Author: qishuai qishuai6@huawei.com - * Create: 2021-02-03 - */ -#include "drvcall_dyn_conf_builder.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "tee_inner_uuid.h" - -#ifdef TEE_SUPPORT_DYN_CONF -void free_drvcall_perm(struct drvcall_perm_apply_t *drvcall_perm) -{ - if (drvcall_perm == NULL) { - hm_error("invalid drvcall perm\n"); - return; - } - - if (drvcall_perm->drvcall_perm_apply_list != NULL) { - uint32_t size = drvcall_perm->drvcall_perm_apply_list_size * - sizeof(struct drvcall_perm_apply_item_t); - tee_free_sharemem(drvcall_perm->drvcall_perm_apply_list, size); - drvcall_perm->drvcall_perm_apply_list = NULL; - } -} - -static void free_drvcall_conf(struct drvcall_conf_t *drvcall_conf) -{ - free_drvcall_perm(&drvcall_conf->drvcall_perm_apply); - free(drvcall_conf); -} - -int32_t init_drvcall_conf(struct drvcall_perm_apply_t *drvcall_perm_apply, - const struct conf_queue_t *conf_queue) -{ - struct tee_uuid drv_server_uuid = DRVMGR; - - if (drvcall_perm_apply == NULL || conf_queue == NULL) { - hm_error("invalid drvcall perm or conf queue\n"); - return TEE_ERROR_GENERIC; - } - - uint16_t num = get_num_of_tag(conf_queue, DRV_PERM_DRVCALL_PERM_APPLY_ITEM); - /* num < 0xffff means size cannot larger than 0xFFFFFFFF */ - uint32_t size = num * sizeof(struct drvcall_perm_apply_item_t); - if (size == 0) - return TEE_SUCCESS; - - drvcall_perm_apply->drvcall_perm_apply_list_size = 0; - drvcall_perm_apply->drvcall_perm_apply_list = tee_alloc_sharemem_aux(&drv_server_uuid, size); - if (drvcall_perm_apply->drvcall_perm_apply_list == NULL) { - hm_error("malloc share mem for drvcall perm apply list failed\n"); - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static int32_t handle_perm_apply_item_name(struct drvcall_perm_apply_item_t *drvcall_perm_apply_item, - uint32_t size, const char *value) -{ - if (size == 0 || size >= DRV_NAME_MAX_LEN) { - hm_error("the drv name in drvcall's perm apply list is invalied\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (memcpy_s(drvcall_perm_apply_item->name, DRV_NAME_MAX_LEN, value, size) != 0) { - hm_error("memcpy for drvcall perm apply item failed\n"); - return TEE_ERROR_GENERIC; - } - drvcall_perm_apply_item->name[size] = '\0'; - drvcall_perm_apply_item->name_size = size; - - return TEE_SUCCESS; -} - -int32_t combine_perms(uint64_t *perm, uint32_t size, const char *value) -{ - if (perm == NULL || value == NULL || size == 0 || size >= MAX_IMAGE_LEN) { - hm_error("invalied params\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - char *buff = malloc(size + 1); - if (buff == NULL) { - hm_error("malloc for buff failed\n"); - return TEE_ERROR_GENERIC; - } - - int32_t ret = memcpy_s(buff, size + 1, value, size); - if (ret != 0) { - hm_error("memcpy for buff failed\n"); - goto out; - } - buff[size] = '\0'; - - *perm = 0; - char *target = buff; - char *rest = NULL; - while (1) { - target = strtok_r(target, "|", &rest); - if (target == NULL) - break; - - uint64_t target_size = strlen(target); - if (target_size > MAX_UINT32_LEN) { - hm_error("target size cannot larger than MAX_UINT32_LEN\n"); - ret = TEE_ERROR_BAD_PARAMETERS; - goto out; - } - - uint64_t off = 0; - if (trans_str_to_int(target, (uint32_t)target_size, BASE_OF_TEN, &off) != TEE_SUCCESS) { - hm_error("get perms failed while combine perms\n"); - ret = TEE_ERROR_BAD_PARAMETERS; - goto out; - } - - if (off == 0 || off > BIT_NUM_OF_UINT64) { - hm_error("cmd permission must in range of [1, 64]\n"); - ret = TEE_ERROR_BAD_PARAMETERS; - goto out; - } - - *perm = *perm | (1 << (off - 1)); - - target = NULL; - } - -out: - free(buff); - return ret; -} - -static int32_t handle_perm_apply_item_perm(uint64_t *perm, uint32_t size, const char *value) -{ - return combine_perms(perm, size, value); -} - -static int32_t build_drvcall_perm_apply_item(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - struct drvcall_perm_apply_item_t *drvcall_perm_apply_item = NULL; - (void)pos; - - if (obj_size != sizeof(*drvcall_perm_apply_item)) { - hm_error("invalied params while build drvcall perm apply item\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drvcall_perm_apply_item = (struct drvcall_perm_apply_item_t *)obj; - - switch (node->tag) { - case DRV_PERM_DRVCALL_PERM_APPLY_ITEM_NAME: - if (handle_perm_apply_item_name(drvcall_perm_apply_item, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle perm apply item name failed\n"); - return TEE_ERROR_GENERIC; - } - break; - case DRV_PERM_DRVCALL_PERM_APPLY_ITEM_PERMISSION: - if (handle_perm_apply_item_perm(&drvcall_perm_apply_item->perm, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle perm apply item perm failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - hm_debug("skip in build drvcall perm apply item\n"); - if (handle_conf_node_to_obj(pos, NULL, drvcall_perm_apply_item, - sizeof(*drvcall_perm_apply_item)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} - -static int32_t check_perm_apply_list(struct drvcall_perm_apply_item_t drvcall_perm_apply_item) -{ - if (drvcall_perm_apply_item.name_size == 0 || drvcall_perm_apply_item.name_size >= DRV_NAME_MAX_LEN) { - hm_error("drv's name size is invalied in perm apply list\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - return TEE_SUCCESS; -} - -int32_t build_drvcall_perm_apply(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - struct drvcall_perm_apply_t *drvcall_perm_apply = NULL; - - if (pos == NULL || node == NULL || obj == NULL || obj_size != sizeof(*drvcall_perm_apply)) { - hm_error("invalied params while build drvcall perm apply\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drvcall_perm_apply = (struct drvcall_perm_apply_t *)obj; - uint32_t index = drvcall_perm_apply->drvcall_perm_apply_list_size; - - switch (node->tag) { - case DRV_PERM_DRVCALL_PERM_APPLY_ITEM: - /* - * drvcall_perm_apply_list malloc by the num of tag DRV_PERM_DRVCALL_PERM_APPLY_ITEM - * so index will never over the bound of drvcall_perm_apply_list - */ - if (handle_conf_node_to_obj(pos, build_drvcall_perm_apply_item, - &drvcall_perm_apply->drvcall_perm_apply_list[index], - sizeof(drvcall_perm_apply->drvcall_perm_apply_list[index])) != TEE_SUCCESS) { - hm_error("build drvcall perm apply failed\n"); - return TEE_ERROR_GENERIC; - } - - if (check_perm_apply_list(drvcall_perm_apply->drvcall_perm_apply_list[index]) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - - drvcall_perm_apply->drvcall_perm_apply_list_size++; - - break; - default: - break; - } - - return TEE_SUCCESS; -} - -int32_t build_drvcall_conf(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - struct drvcall_perm_apply_t *drvcall_perm = NULL; - - if (pos == NULL || node == NULL || obj == NULL || obj_size != sizeof(*drvcall_perm)) { - hm_error("invalied params while build drvcall conf\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - drvcall_perm = (struct drvcall_perm_apply_t *)obj; - - switch (node->tag) { - case DRV_PERM_DRVCALL_PERM_APPLY: - if (handle_conf_node_to_obj(pos, build_drvcall_perm_apply, drvcall_perm, - sizeof(*drvcall_perm)) != TEE_SUCCESS) { - hm_error("build drvcall perm apply failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - hm_debug("skip in build drvcall conf\n"); - if (handle_conf_node_to_obj(pos, NULL, drvcall_perm, sizeof(*drvcall_perm)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} - -static int32_t send_drvcall_conf(const struct drvcall_conf_t *drvcall_conf, uint32_t drvcall_conf_size) -{ - uint64_t args[] = { - (uintptr_t)drvcall_conf, - drvcall_conf_size, - }; - - uint32_t lens[] = { - drvcall_conf_size, - 0, - }; - - /* the main thread just handle register cmd */ - return hm_drv_call_new("drvmgr", REGISTER_DRVCALL_CONF, args, lens, ARRAY_SIZE(args)); -} - -static int32_t send_drvcall_uuid(const struct tee_uuid *uuid, uint32_t uuid_size) -{ - uint64_t args[] = { - (uintptr_t)uuid, - uuid_size, - }; - - uint32_t lens[] = { - uuid_size, - 0, - }; - - return hm_drv_call_new("drvmgr_multi", UNREGISTER_DRVCALL_CONF, args, lens, ARRAY_SIZE(args)); -} - -void dump_drvcall_conf(void) -{ - uint64_t args[] = {}; - uint32_t lens[] = {}; - - (void)hm_drv_call_new("drvmgr_multi", DUMP_DRVCALL_CONF, args, lens, ARRAY_SIZE(args)); -} - -void uninstall_drvcall_permission(const void *obj, uint32_t obj_size) -{ - if (obj == NULL) { - hm_error("obj is NULL while uninstall drvcall permission\n"); - return; - } - - if (obj_size != sizeof(struct tee_uuid)) { - hm_error("obj size is invalied while uninstall drvcall permission\n"); - return; - } - - const struct tee_uuid *uuid = (const struct tee_uuid *)obj; - if (send_drvcall_uuid(uuid, obj_size) != 0) - hm_error("uninstall drvcall permission failed\n"); -} - -int32_t install_drvcall_permission(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue) -{ - /* 1. check the params */ - if (obj == NULL || conf_queue == NULL || dlist_empty(&conf_queue->queue)) { - hm_error("params is NULL while install drvcall permission\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (obj_size != sizeof(struct tee_uuid)) { - hm_error("obj size is invalied while install drvcall permission\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - /* 2. parse the obj to what you want */ - struct tee_uuid *uuid = (struct tee_uuid *)obj; - - /* 3.create new obj */ - struct drvcall_conf_t *drvcall_conf = (struct drvcall_conf_t *)malloc(sizeof(struct drvcall_conf_t)); - if (drvcall_conf == NULL) { - hm_error("drvcall_conf malloc failed\n"); - return TEE_ERROR_GENERIC; - } - - /* 4.init new obj */ - (void)memset_s(drvcall_conf, sizeof(*drvcall_conf), 0, sizeof(*drvcall_conf)); - int32_t ret = -1; - if (memcpy_s(&drvcall_conf->uuid, sizeof(drvcall_conf->uuid), uuid, sizeof(*uuid)) != 0) { - hm_error("set uuid to drv conf fail\n"); - goto out; - } - - ret = init_drvcall_conf(&drvcall_conf->drvcall_perm_apply, conf_queue); - if (ret != TEE_SUCCESS) - goto out; - - /* 5.handle new obj */ - struct dlist_node *pos = dlist_get_next(&conf_queue->queue); - ret = handle_conf_node_to_obj(&pos, build_drvcall_conf, &drvcall_conf->drvcall_perm_apply, - sizeof(drvcall_conf->drvcall_perm_apply)); - if (ret != TEE_SUCCESS) { - hm_error("handle drvcall conf failed\n"); - goto out; - } - - /* 6.do something else */ - ret = send_drvcall_conf(drvcall_conf, sizeof(*drvcall_conf)); - -out: - /* 7. free obj and return */ - free_drvcall_conf(drvcall_conf); - return ret; -} - -#else - -int32_t install_drvcall_permission(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue) -{ - (void)obj; - (void)obj_size; - (void)conf_queue; - return TEE_SUCCESS; -} - -void uninstall_drvcall_permission(const void *obj, uint32_t obj_size) -{ - (void)obj; - (void)obj_size; -} - -void dump_drvcall_conf(void) -{ - return; -} -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include "drvcall_dyn_conf_builder.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "tee_inner_uuid.h" + +#ifdef TEE_SUPPORT_DYN_CONF +void free_drvcall_perm(struct drvcall_perm_apply_t *drvcall_perm) +{ + if (drvcall_perm == NULL) { + hm_error("invalid drvcall perm\n"); + return; + } + + if (drvcall_perm->drvcall_perm_apply_list != NULL) { + uint32_t size = drvcall_perm->drvcall_perm_apply_list_size * + sizeof(struct drvcall_perm_apply_item_t); + tee_free_sharemem(drvcall_perm->drvcall_perm_apply_list, size); + drvcall_perm->drvcall_perm_apply_list = NULL; + } +} + +static void free_drvcall_conf(struct drvcall_conf_t *drvcall_conf) +{ + free_drvcall_perm(&drvcall_conf->drvcall_perm_apply); + free(drvcall_conf); +} + +int32_t init_drvcall_conf(struct drvcall_perm_apply_t *drvcall_perm_apply, + const struct conf_queue_t *conf_queue) +{ + struct tee_uuid drv_server_uuid = DRVMGR; + + if (drvcall_perm_apply == NULL || conf_queue == NULL) { + hm_error("invalid drvcall perm or conf queue\n"); + return TEE_ERROR_GENERIC; + } + + uint16_t num = get_num_of_tag(conf_queue, DRV_PERM_DRVCALL_PERM_APPLY_ITEM); + /* num < 0xffff means size cannot larger than 0xFFFFFFFF */ + uint32_t size = num * sizeof(struct drvcall_perm_apply_item_t); + if (size == 0) + return TEE_SUCCESS; + + drvcall_perm_apply->drvcall_perm_apply_list_size = 0; + drvcall_perm_apply->drvcall_perm_apply_list = tee_alloc_sharemem_aux(&drv_server_uuid, size); + if (drvcall_perm_apply->drvcall_perm_apply_list == NULL) { + hm_error("malloc share mem for drvcall perm apply list failed\n"); + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +static int32_t handle_perm_apply_item_name(struct drvcall_perm_apply_item_t *drvcall_perm_apply_item, + uint32_t size, const char *value) +{ + if (size == 0 || size >= DRV_NAME_MAX_LEN) { + hm_error("the drv name in drvcall's perm apply list is invalied\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (memcpy_s(drvcall_perm_apply_item->name, DRV_NAME_MAX_LEN, value, size) != 0) { + hm_error("memcpy for drvcall perm apply item failed\n"); + return TEE_ERROR_GENERIC; + } + drvcall_perm_apply_item->name[size] = '\0'; + drvcall_perm_apply_item->name_size = size; + + return TEE_SUCCESS; +} + +int32_t combine_perms(uint64_t *perm, uint32_t size, const char *value) +{ + if (perm == NULL || value == NULL || size == 0 || size >= MAX_IMAGE_LEN) { + hm_error("invalied params\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + char *buff = malloc(size + 1); + if (buff == NULL) { + hm_error("malloc for buff failed\n"); + return TEE_ERROR_GENERIC; + } + + int32_t ret = memcpy_s(buff, size + 1, value, size); + if (ret != 0) { + hm_error("memcpy for buff failed\n"); + goto out; + } + buff[size] = '\0'; + + *perm = 0; + char *target = buff; + char *rest = NULL; + while (1) { + target = strtok_r(target, "|", &rest); + if (target == NULL) + break; + + uint64_t target_size = strlen(target); + if (target_size > MAX_UINT32_LEN) { + hm_error("target size cannot larger than MAX_UINT32_LEN\n"); + ret = TEE_ERROR_BAD_PARAMETERS; + goto out; + } + + uint64_t off = 0; + if (trans_str_to_int(target, (uint32_t)target_size, BASE_OF_TEN, &off) != TEE_SUCCESS) { + hm_error("get perms failed while combine perms\n"); + ret = TEE_ERROR_BAD_PARAMETERS; + goto out; + } + + if (off == 0 || off > BIT_NUM_OF_UINT64) { + hm_error("cmd permission must in range of [1, 64]\n"); + ret = TEE_ERROR_BAD_PARAMETERS; + goto out; + } + + *perm = *perm | (1 << (off - 1)); + + target = NULL; + } + +out: + free(buff); + return ret; +} + +static int32_t handle_perm_apply_item_perm(uint64_t *perm, uint32_t size, const char *value) +{ + return combine_perms(perm, size, value); +} + +static int32_t build_drvcall_perm_apply_item(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + struct drvcall_perm_apply_item_t *drvcall_perm_apply_item = NULL; + (void)pos; + + if (obj_size != sizeof(*drvcall_perm_apply_item)) { + hm_error("invalied params while build drvcall perm apply item\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drvcall_perm_apply_item = (struct drvcall_perm_apply_item_t *)obj; + + switch (node->tag) { + case DRV_PERM_DRVCALL_PERM_APPLY_ITEM_NAME: + if (handle_perm_apply_item_name(drvcall_perm_apply_item, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle perm apply item name failed\n"); + return TEE_ERROR_GENERIC; + } + break; + case DRV_PERM_DRVCALL_PERM_APPLY_ITEM_PERMISSION: + if (handle_perm_apply_item_perm(&drvcall_perm_apply_item->perm, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle perm apply item perm failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + hm_debug("skip in build drvcall perm apply item\n"); + if (handle_conf_node_to_obj(pos, NULL, drvcall_perm_apply_item, + sizeof(*drvcall_perm_apply_item)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} + +static int32_t check_perm_apply_list(struct drvcall_perm_apply_item_t drvcall_perm_apply_item) +{ + if (drvcall_perm_apply_item.name_size == 0 || drvcall_perm_apply_item.name_size >= DRV_NAME_MAX_LEN) { + hm_error("drv's name size is invalied in perm apply list\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + return TEE_SUCCESS; +} + +int32_t build_drvcall_perm_apply(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + struct drvcall_perm_apply_t *drvcall_perm_apply = NULL; + + if (pos == NULL || node == NULL || obj == NULL || obj_size != sizeof(*drvcall_perm_apply)) { + hm_error("invalied params while build drvcall perm apply\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drvcall_perm_apply = (struct drvcall_perm_apply_t *)obj; + uint32_t index = drvcall_perm_apply->drvcall_perm_apply_list_size; + + switch (node->tag) { + case DRV_PERM_DRVCALL_PERM_APPLY_ITEM: + /* + * drvcall_perm_apply_list malloc by the num of tag DRV_PERM_DRVCALL_PERM_APPLY_ITEM + * so index will never over the bound of drvcall_perm_apply_list + */ + if (handle_conf_node_to_obj(pos, build_drvcall_perm_apply_item, + &drvcall_perm_apply->drvcall_perm_apply_list[index], + sizeof(drvcall_perm_apply->drvcall_perm_apply_list[index])) != TEE_SUCCESS) { + hm_error("build drvcall perm apply failed\n"); + return TEE_ERROR_GENERIC; + } + + if (check_perm_apply_list(drvcall_perm_apply->drvcall_perm_apply_list[index]) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + + drvcall_perm_apply->drvcall_perm_apply_list_size++; + + break; + default: + break; + } + + return TEE_SUCCESS; +} + +int32_t build_drvcall_conf(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + struct drvcall_perm_apply_t *drvcall_perm = NULL; + + if (pos == NULL || node == NULL || obj == NULL || obj_size != sizeof(*drvcall_perm)) { + hm_error("invalied params while build drvcall conf\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + drvcall_perm = (struct drvcall_perm_apply_t *)obj; + + switch (node->tag) { + case DRV_PERM_DRVCALL_PERM_APPLY: + if (handle_conf_node_to_obj(pos, build_drvcall_perm_apply, drvcall_perm, + sizeof(*drvcall_perm)) != TEE_SUCCESS) { + hm_error("build drvcall perm apply failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + hm_debug("skip in build drvcall conf\n"); + if (handle_conf_node_to_obj(pos, NULL, drvcall_perm, sizeof(*drvcall_perm)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} + +static int32_t send_drvcall_conf(const struct drvcall_conf_t *drvcall_conf, uint32_t drvcall_conf_size) +{ + uint64_t args[] = { + (uintptr_t)drvcall_conf, + drvcall_conf_size, + }; + + uint32_t lens[] = { + drvcall_conf_size, + 0, + }; + + /* the main thread just handle register cmd */ + return hm_drv_call_new("drvmgr", REGISTER_DRVCALL_CONF, args, lens, ARRAY_SIZE(args)); +} + +static int32_t send_drvcall_uuid(const struct tee_uuid *uuid, uint32_t uuid_size) +{ + uint64_t args[] = { + (uintptr_t)uuid, + uuid_size, + }; + + uint32_t lens[] = { + uuid_size, + 0, + }; + + return hm_drv_call_new("drvmgr_multi", UNREGISTER_DRVCALL_CONF, args, lens, ARRAY_SIZE(args)); +} + +void dump_drvcall_conf(void) +{ + uint64_t args[] = {}; + uint32_t lens[] = {}; + + (void)hm_drv_call_new("drvmgr_multi", DUMP_DRVCALL_CONF, args, lens, ARRAY_SIZE(args)); +} + +void uninstall_drvcall_permission(const void *obj, uint32_t obj_size) +{ + if (obj == NULL) { + hm_error("obj is NULL while uninstall drvcall permission\n"); + return; + } + + if (obj_size != sizeof(struct tee_uuid)) { + hm_error("obj size is invalied while uninstall drvcall permission\n"); + return; + } + + const struct tee_uuid *uuid = (const struct tee_uuid *)obj; + if (send_drvcall_uuid(uuid, obj_size) != 0) + hm_error("uninstall drvcall permission failed\n"); +} + +int32_t install_drvcall_permission(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue) +{ + /* 1. check the params */ + if (obj == NULL || conf_queue == NULL || dlist_empty(&conf_queue->queue)) { + hm_error("params is NULL while install drvcall permission\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (obj_size != sizeof(struct tee_uuid)) { + hm_error("obj size is invalied while install drvcall permission\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + /* 2. parse the obj to what you want */ + struct tee_uuid *uuid = (struct tee_uuid *)obj; + + /* 3.create new obj */ + struct drvcall_conf_t *drvcall_conf = (struct drvcall_conf_t *)malloc(sizeof(struct drvcall_conf_t)); + if (drvcall_conf == NULL) { + hm_error("drvcall_conf malloc failed\n"); + return TEE_ERROR_GENERIC; + } + + /* 4.init new obj */ + (void)memset_s(drvcall_conf, sizeof(*drvcall_conf), 0, sizeof(*drvcall_conf)); + int32_t ret = -1; + if (memcpy_s(&drvcall_conf->uuid, sizeof(drvcall_conf->uuid), uuid, sizeof(*uuid)) != 0) { + hm_error("set uuid to drv conf fail\n"); + goto out; + } + + ret = init_drvcall_conf(&drvcall_conf->drvcall_perm_apply, conf_queue); + if (ret != TEE_SUCCESS) + goto out; + + /* 5.handle new obj */ + struct dlist_node *pos = dlist_get_next(&conf_queue->queue); + ret = handle_conf_node_to_obj(&pos, build_drvcall_conf, &drvcall_conf->drvcall_perm_apply, + sizeof(drvcall_conf->drvcall_perm_apply)); + if (ret != TEE_SUCCESS) { + hm_error("handle drvcall conf failed\n"); + goto out; + } + + /* 6.do something else */ + ret = send_drvcall_conf(drvcall_conf, sizeof(*drvcall_conf)); + +out: + /* 7. free obj and return */ + free_drvcall_conf(drvcall_conf); + return ret; +} + +#else + +int32_t install_drvcall_permission(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue) +{ + (void)obj; + (void)obj_size; + (void)conf_queue; + return TEE_SUCCESS; +} + +void uninstall_drvcall_permission(const void *obj, uint32_t obj_size) +{ + (void)obj; + (void)obj_size; +} + +void dump_drvcall_conf(void) +{ + return; +} +#endif diff --git a/lib/syslib/libdynconfbuilder/src/ta_config_builder.c b/lib/syslib/libdynconfbuilder/src/ta_config_builder.c index 4d41e661..d6c5e1c9 100644 --- a/lib/syslib/libdynconfbuilder/src/ta_config_builder.c +++ b/lib/syslib/libdynconfbuilder/src/ta_config_builder.c @@ -1,819 +1,824 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: v3.1 ta config builder - * Author: qishuai qishuai6@huawei.com - * Create: 2022-02-07 - */ - -#include "ta_config_builder.h" -#include -#include -#include -#include - -static bool check_multiply_overflow(uint32_t a, uint32_t b) -{ - uint32_t p = a * b; - if (a != 0 && (p / a != b)) { - hm_error("the result is over flow"); - return true; - } - - return false; -} -#define HEX_TO_STR_LEN_VALUE 2 - -static void hex2str(uint8_t *dest, uint32_t dest_len, const uint8_t *source, uint32_t source_len) -{ - if (check_multiply_overflow(source_len, HEX_TO_STR_LEN_VALUE)) - return; - - uint32_t len_max = source_len * HEX_TO_STR_LEN_VALUE; - - bool check = (dest == NULL || source == NULL || dest_len < len_max + 1); - if (check) - return; - - uint8_t ch[] = "0123456789ABCDEF"; - uint8_t *p = dest; - uint32_t i; - - for (i = 0; i < source_len; i++) { - *(p++) = ch[source[i] >> LEN_OFFSET_VALUE]; - *(p++) = ch[source[i] & 0xf]; /* get low bits nums */ - } - *p = '\0'; -} - -/* TODO: need replace this function by new ways */ -static TEE_Result tee_ext_get_device_unique_id(uint8_t *device_unique_id, uint32_t *length) -{ - (void)device_unique_id; - (void)length; - hm_error("device id not support\n"); - return TEE_ERROR_GENERIC; -} - -TEE_Result check_device_id(struct config_info *config, const uint8_t *buff, uint32_t len) -{ - bool is_invalid = (config == NULL || buff == NULL || len == 0); - if (is_invalid) - return TEE_ERROR_BAD_PARAMETERS; - - if (config->control_info.debug_info.valid_device) - return TEE_SUCCESS; - - if (len != TLV_DEVICE_ID_LEN) { - hm_error("config tlv parser::device id len invalid should be: %u\n", TLV_DEVICE_ID_LEN); - config->control_info.debug_info.valid_device = false; - return TEE_ERROR_GENERIC; - } - - uint8_t unique_id[DEVICE_ID_LEN] = { 0 }; - uint32_t id_len = sizeof(unique_id); - uint8_t tlv_device_id[DEVICE_ID_LEN * 2 + 1] = { 0 }; /* 2 is double */ - - if (tee_ext_get_device_unique_id(unique_id, &id_len) != TEE_SUCCESS) { - hm_error("get device id failed\n"); - config->control_info.debug_info.valid_device = false; - return TEE_ERROR_GENERIC; - } - - hex2str(tlv_device_id, sizeof(tlv_device_id), unique_id, sizeof(unique_id)); - if (TEE_MemCompare(tlv_device_id, buff, len) == 0) - config->control_info.debug_info.valid_device = true; - - return TEE_SUCCESS; -} - -#ifdef TEE_SUPPORT_DYN_CONF - -/* build drv conf */ -static int32_t handle_ta_basic_info_service_name(struct config_info *cfg_info, - uint32_t size, const char *value) -{ - if (size == 0 || size >= MAX_SERVICE_NAME_LEN) { - hm_error("param invalid while handle config info ta basic info service name\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (memcpy_s(cfg_info->service_name, MAX_SERVICE_NAME_LEN, value, size) != 0) { - hm_error("memcpy failed while handle config info ta basic info service name\n"); - return TEE_ERROR_GENERIC; - } - cfg_info->service_name[size] = '\0'; - cfg_info->service_name_len = size; - - return TEE_SUCCESS; -} - -static int32_t build_ta_basic_info_service_name(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta basic info service name\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_BASIC_INFO_SERVICE_NAME_SERVICE_NAME: - if (handle_ta_basic_info_service_name(cfg_info, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle ta basic info service name failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t handle_ta_basic_info_uuid(struct config_info *cfg_info, uint32_t size, const char *value) -{ - if (size == 0 || size > MAX_UUID_SIZE) { - hm_error("param invalid while handle config info ta basic info uuid\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - int32_t ret = tlv_to_uuid(value, size, &cfg_info->uuid); - if (ret != TEE_SUCCESS) { - hm_error("param invalid while handle config info ta basic info trans uuid failed\n"); - return ret; - } - - return TEE_SUCCESS; -} - -static int32_t build_ta_basic_info_uuid(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta basic info uuid\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_BASIC_INFO_UUID_UUID: - if (handle_ta_basic_info_uuid(cfg_info, node->size, node->value) != TEE_SUCCESS) { - hm_error("handle ta basic info uuid\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_ta_basic_info(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta basic info\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_BASIC_INFO_SERVICE_NAME: - if (handle_conf_node_to_obj(pos, build_ta_basic_info_service_name, - cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { - hm_error("build ta basic info service name failed\n"); - return TEE_ERROR_GENERIC; - } - break; - case CONFIGINFO_TA_BASIC_INFO_UUID: - if (handle_conf_node_to_obj(pos, build_ta_basic_info_uuid, - cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { - hm_error("build ta basic info service name failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - hm_debug("skip in build ta basic info\n"); - if (handle_conf_node_to_obj(pos, NULL, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_ta_mani_info_instance_keep_alive(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta manifest info instance keep alive\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_MANIFEST_INFO_INSTANCE_KEEP_ALIVE_INSTANCE_KEEP_ALIVE: - if (node->size == 1 && node->value[0] == TLV_TRUE) - cfg_info->manifest_info.instance_keep_alive = true; - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_ta_mani_info_multi_command(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta manifest info multi command\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_MANIFEST_INFO_MULTI_COMMAND_MULTI_COMMAND: - if (node->size == 1 && node->value[0] == TLV_TRUE) - cfg_info->manifest_info.multi_command = true; - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_ta_mani_info_multi_session(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta manifest info multi session\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_MANIFEST_INFO_MULTI_SESSION_MULTI_SESSION: - if (node->size == 1 && node->value[0] == TLV_TRUE) - cfg_info->manifest_info.multi_session = true; - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t handle_ta_mani_info_stack_size(uint32_t *stack_size, uint32_t size, const char *value) -{ - uint64_t tmp_stack_size; - - if (value == NULL || size > MAX_UINT32_LEN || size == 0) { - hm_error("invalid parm while handle stack size\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - char buff[MAX_UINT32_LEN + 1]; - if (memcpy_s(buff, sizeof(buff), value, size) != 0) { - hm_error("memcpy failed while handle stack size\n"); - return TEE_ERROR_GENERIC; - } - buff[size] = '\0'; - - if (trans_str_to_int(buff, size, BASE_OF_TEN, &tmp_stack_size) != TEE_SUCCESS) { - hm_error("get stack size failed\n"); - return TEE_ERROR_GENERIC; - } - - if (tmp_stack_size > UINT32_MAX) { - hm_error("stack size is invalied %llx\n", (unsigned long long)tmp_stack_size); - return TEE_ERROR_GENERIC; - } - - *stack_size = (uint32_t)tmp_stack_size; - - return TEE_SUCCESS; -} - -static int32_t build_ta_mani_info_stack_size(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta manifest info stack size\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_MANIFEST_INFO_STACK_SIZE_STACK_SIZE: - if (handle_ta_mani_info_stack_size(&cfg_info->manifest_info.stack_size, - node->size, node->value) != TEE_SUCCESS) { - hm_error("build ta manifest info stack size failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t handle_ta_mani_info_heap_size(uint32_t *heap_size, uint32_t size, const char *value) -{ - uint64_t tmp_heap_size; - - if (value == NULL || size > MAX_UINT32_LEN || size == 0) { - hm_error("invalid parm while handle heap size\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - char buff[MAX_UINT32_LEN + 1]; - if (memcpy_s(buff, sizeof(buff), value, size) != 0) { - hm_error("memcpy failed while handle heap size\n"); - return TEE_ERROR_GENERIC; - } - buff[size] = '\0'; - - if (trans_str_to_int(buff, size, BASE_OF_TEN, &tmp_heap_size) != TEE_SUCCESS) { - hm_error("get heap size failed\n"); - return TEE_ERROR_GENERIC; - } - - if (tmp_heap_size > UINT32_MAX) { - hm_error("heap size is invalied %llx\n", (unsigned long long)tmp_heap_size); - return TEE_ERROR_GENERIC; - } - - *heap_size = (uint32_t)tmp_heap_size; - - return TEE_SUCCESS; -} - -static int32_t build_ta_mani_info_heap_size(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta manifest info heap size\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_MANIFEST_INFO_HEAP_SIZE_HEAP_SIZE: - if (handle_ta_mani_info_heap_size(&cfg_info->manifest_info.heap_size, - node->size, node->value) != TEE_SUCCESS) { - hm_error("build ta manifest info heap size failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t handle_ta_mani_info_target_type(uint32_t *target_type, uint32_t size, const char *value) -{ - uint64_t tmp_target_type; - - if (value == NULL || size > MAX_UINT32_LEN || size == 0) { - hm_error("invalid parm while handle target type\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - char buff[MAX_UINT32_LEN + 1]; - if (memcpy_s(buff, sizeof(buff), value, size) != 0) { - hm_error("memcpy failed while handle target type\n"); - return TEE_ERROR_GENERIC; - } - buff[size] = '\0'; - - if (trans_str_to_int(buff, size, BASE_OF_TEN, &tmp_target_type) != TEE_SUCCESS) { - hm_error("get heap size failed\n"); - return TEE_ERROR_GENERIC; - } - - if (tmp_target_type > UINT32_MAX) { - hm_error("target type is invalied %llx\n", (unsigned long long)tmp_target_type); - return TEE_ERROR_GENERIC; - } - - *target_type = (uint32_t)tmp_target_type; - - return TEE_SUCCESS; -} - -static int32_t build_ta_mani_info_target_type(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta manifest info target type\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_MANIFEST_INFO_TARGET_TYPE_TARGET_TYPE: - if (handle_ta_mani_info_target_type(&cfg_info->manifest_info.target_type, - node->size, node->value) != TEE_SUCCESS) { - hm_error("build ta manifest info target type failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_ta_mani_info_single_instance(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta manifest info single instance\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_MANIFEST_INFO_SINGLE_INSTANCE_SINGLE_INSTANCE: - if (node->size == 1 && node->value[0] == TLV_TRUE) - cfg_info->manifest_info.single_instance = true; - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static struct dyn_conf_build_func ta_mani_funcs[] = { - { CONFIGINFO_TA_MANIFEST_INFO_INSTANCE_KEEP_ALIVE, build_ta_mani_info_instance_keep_alive, NULL }, - { CONFIGINFO_TA_MANIFEST_INFO_STACK_SIZE, build_ta_mani_info_stack_size, NULL }, - { CONFIGINFO_TA_MANIFEST_INFO_HEAP_SIZE, build_ta_mani_info_heap_size, NULL }, - { CONFIGINFO_TA_MANIFEST_INFO_TARGET_TYPE, build_ta_mani_info_target_type, NULL }, - { CONFIGINFO_TA_MANIFEST_INFO_MULTI_COMMAND, build_ta_mani_info_multi_command, NULL }, - { CONFIGINFO_TA_MANIFEST_INFO_MULTI_SESSION, build_ta_mani_info_multi_session, NULL }, - { CONFIGINFO_TA_MANIFEST_INFO_SINGLE_INSTANCE, build_ta_mani_info_single_instance, NULL }, -}; - -static int32_t build_ta_mani_info(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta manifest info\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - uint32_t ta_mani_funcs_size = sizeof(ta_mani_funcs) / sizeof(ta_mani_funcs[0]); - uint32_t i; - for (i = 0; i < ta_mani_funcs_size; i++) { - if (node->tag != ta_mani_funcs[i].tag) - continue; - - if (ta_mani_funcs[i].handle != NULL && - handle_conf_node_to_obj(pos, ta_mani_funcs[i].handle, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - - if (ta_mani_funcs[i].checker != NULL && ta_mani_funcs[i].checker(cfg_info) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - - break; - } - - if (i == ta_mani_funcs_size) { - hm_debug("skip in build ta manifest info\n"); - if (handle_conf_node_to_obj(pos, NULL, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -#if defined(CONFIG_APP_TEE_SE) -static int32_t build_ta_control_info_se_open_session(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build se open session\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_CONTROL_INFO_SE_INFO_SE_OPEN_SESSION_SE_OPEN_SESSION: - if (node->size == 1 && node->value[0] == TLV_TRUE) - cfg_info->control_info.se_info.permissions |= SE_OPEN_SESSION_PERMISSION; - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_ta_control_info_se_info(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build se info\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_CONTROL_INFO_SE_INFO_SE_OPEN_SESSION: - if (handle_conf_node_to_obj(pos, build_ta_control_info_se_open_session, - cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { - hm_error("build ta control info se info se open session failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - hm_debug("skip in build ta control info se info\n"); - if (handle_conf_node_to_obj(pos, NULL, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} -#endif - -static int32_t build_ta_control_info_debug_status(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build debug status\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_STATUS_DEBUG_STATUS: - if (node->size == 1 && node->value[0] == TLV_TRUE) - cfg_info->control_info.debug_info.status = true; - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t handle_ta_control_info_debug_device_id(struct config_info *cfg_info, const struct conf_node_t *node) -{ - if (cfg_info == NULL || node == NULL || node->size != TLV_DEVICE_ID_LEN) { - hm_error("bad param\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - uint8_t buff[TLV_DEVICE_ID_LEN + 1] = { 0 }; - if (memcpy_s(buff, TLV_DEVICE_ID_LEN, node->value, node->size) != 0) { - hm_error("memcpy for debug device id failed\n"); - return TEE_ERROR_GENERIC; - } - buff[node->size] = '\0'; - - if (check_device_id(cfg_info, buff, node->size) != TEE_SUCCESS) { - hm_error("check device id failed\n"); - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static int32_t build_ta_control_info_debug_device_id(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build debug device id\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_DEVICE_ID_DEBUG_DEVICE_ID: - if (handle_ta_control_info_debug_device_id(cfg_info, node) != TEE_SUCCESS) { - hm_error("check device id failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_ta_control_info_debug_info(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = NULL; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build debug info\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_STATUS: - if (handle_conf_node_to_obj(pos, build_ta_control_info_debug_status, - cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { - hm_error("build ta control info debug info debug status failed\n"); - return TEE_ERROR_GENERIC; - } - break; - case CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_DEVICE_ID: - if (handle_conf_node_to_obj(pos, build_ta_control_info_debug_device_id, - cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { - hm_error("build ta control info debug info debug status failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - hm_debug("skip in build ta control info debug info\n"); - if (handle_conf_node_to_obj(pos, NULL, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_ta_control_info(struct dlist_node **pos, const struct conf_node_t *node, - void *obj, uint32_t obj_size) -{ - (void)pos; - struct config_info *cfg_info = (struct config_info *)obj; - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta control info\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - switch (node->tag) { -#if defined(CONFIG_APP_TEE_SE) - case CONFIGINFO_TA_CONTROL_INFO_SE_INFO: - if (handle_conf_node_to_obj(pos, build_ta_control_info_se_info, - cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { - hm_error("build ta control info rpmb info failed\n"); - return TEE_ERROR_GENERIC; - } - break; -#endif - case CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO: - if (handle_conf_node_to_obj(pos, build_ta_control_info_debug_info, - cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { - hm_error("build ta control info rpmb info failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - hm_debug("skip in build ta control info\n"); - if (handle_conf_node_to_obj(pos, NULL, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} - -static int32_t build_ta_config(struct dlist_node **pos, const struct conf_node_t *node, void *obj, uint32_t obj_size) -{ - struct config_info *cfg_info = NULL; - - if (obj_size != sizeof(*cfg_info)) { - hm_error("obj size is invalid while build ta config\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - cfg_info = (struct config_info *)obj; - - switch (node->tag) { - case CONFIGINFO_TA_BASIC_INFO: - if (handle_conf_node_to_obj(pos, build_ta_basic_info, - cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { - hm_error("build ta basic info failed\n"); - return TEE_ERROR_GENERIC; - } - break; - case CONFIGINFO_TA_MANIFEST_INFO: - if (handle_conf_node_to_obj(pos, build_ta_mani_info, - cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { - hm_error("build ta basic info failed\n"); - return TEE_ERROR_GENERIC; - } - break; - case CONFIGINFO_TA_CONTROL_INFO: - if (handle_conf_node_to_obj(pos, build_ta_control_info, - cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { - hm_error("build ta basic info failed\n"); - return TEE_ERROR_GENERIC; - } - break; - default: - hm_debug("skip in build ta config\n"); - if (handle_conf_node_to_obj(pos, NULL, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - break; - } - - return TEE_SUCCESS; -} - -int32_t install_ta_config(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue) -{ - if (conf_queue == NULL || obj == NULL) { - hm_error("param is invalid while install ta config\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (obj_size != sizeof(struct config_info)) { - hm_error("obj size is invalied while install ta config\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - struct config_info *cfg_info = (struct config_info *)obj; - - /* init ta config info */ - if (memset_s(cfg_info, sizeof(*cfg_info), 0, sizeof(*cfg_info)) != 0) { - hm_error("memset for ta config info failed\n"); - return TEE_ERROR_GENERIC; - } - - if (!dlist_empty(&conf_queue->queue)) { - struct dlist_node *pos = dlist_get_next(&conf_queue->queue); - int32_t ret = handle_conf_node_to_obj(&pos, build_ta_config, cfg_info, sizeof(*cfg_info)); - if (ret != TEE_SUCCESS) { - hm_error("handle ta config failed\n"); - return ret; - } - } - - return TEE_SUCCESS; -} - -#else - -int32_t install_ta_config(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue) -{ - (void)obj; - (void)obj_size; - (void)conf_queue; - return TEE_SUCCESS; -} - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#include "ta_config_builder.h" +#include +#include +#include +#include + +static bool check_multiply_overflow(uint32_t a, uint32_t b) +{ + uint32_t p = a * b; + if (a != 0 && (p / a != b)) { + hm_error("the result is over flow"); + return true; + } + + return false; +} +#define HEX_TO_STR_LEN_VALUE 2 + +static void hex2str(uint8_t *dest, uint32_t dest_len, const uint8_t *source, uint32_t source_len) +{ + if (check_multiply_overflow(source_len, HEX_TO_STR_LEN_VALUE)) + return; + + uint32_t len_max = source_len * HEX_TO_STR_LEN_VALUE; + + bool check = (dest == NULL || source == NULL || dest_len < len_max + 1); + if (check) + return; + + uint8_t ch[] = "0123456789ABCDEF"; + uint8_t *p = dest; + uint32_t i; + + for (i = 0; i < source_len; i++) { + *(p++) = ch[source[i] >> LEN_OFFSET_VALUE]; + *(p++) = ch[source[i] & 0xf]; /* get low bits nums */ + } + *p = '\0'; +} + +/* TODO: need replace this function by new ways */ +static TEE_Result tee_ext_get_device_unique_id(uint8_t *device_unique_id, uint32_t *length) +{ + (void)device_unique_id; + (void)length; + hm_error("device id not support\n"); + return TEE_ERROR_GENERIC; +} + +TEE_Result check_device_id(struct config_info *config, const uint8_t *buff, uint32_t len) +{ + bool is_invalid = (config == NULL || buff == NULL || len == 0); + if (is_invalid) + return TEE_ERROR_BAD_PARAMETERS; + + if (config->control_info.debug_info.valid_device) + return TEE_SUCCESS; + + if (len != TLV_DEVICE_ID_LEN) { + hm_error("config tlv parser::device id len invalid should be: %u\n", TLV_DEVICE_ID_LEN); + config->control_info.debug_info.valid_device = false; + return TEE_ERROR_GENERIC; + } + + uint8_t unique_id[DEVICE_ID_LEN] = { 0 }; + uint32_t id_len = sizeof(unique_id); + uint8_t tlv_device_id[DEVICE_ID_LEN * 2 + 1] = { 0 }; /* 2 is double */ + + if (tee_ext_get_device_unique_id(unique_id, &id_len) != TEE_SUCCESS) { + hm_error("get device id failed\n"); + config->control_info.debug_info.valid_device = false; + return TEE_ERROR_GENERIC; + } + + hex2str(tlv_device_id, sizeof(tlv_device_id), unique_id, sizeof(unique_id)); + if (TEE_MemCompare(tlv_device_id, buff, len) == 0) + config->control_info.debug_info.valid_device = true; + + return TEE_SUCCESS; +} + +#ifdef TEE_SUPPORT_DYN_CONF + +/* build drv conf */ +static int32_t handle_ta_basic_info_service_name(struct config_info *cfg_info, + uint32_t size, const char *value) +{ + if (size == 0 || size >= MAX_SERVICE_NAME_LEN) { + hm_error("param invalid while handle config info ta basic info service name\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (memcpy_s(cfg_info->service_name, MAX_SERVICE_NAME_LEN, value, size) != 0) { + hm_error("memcpy failed while handle config info ta basic info service name\n"); + return TEE_ERROR_GENERIC; + } + cfg_info->service_name[size] = '\0'; + cfg_info->service_name_len = size; + + return TEE_SUCCESS; +} + +static int32_t build_ta_basic_info_service_name(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta basic info service name\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_BASIC_INFO_SERVICE_NAME_SERVICE_NAME: + if (handle_ta_basic_info_service_name(cfg_info, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle ta basic info service name failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t handle_ta_basic_info_uuid(struct config_info *cfg_info, uint32_t size, const char *value) +{ + if (size == 0 || size > MAX_UUID_SIZE) { + hm_error("param invalid while handle config info ta basic info uuid\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + int32_t ret = tlv_to_uuid(value, size, &cfg_info->uuid); + if (ret != TEE_SUCCESS) { + hm_error("param invalid while handle config info ta basic info trans uuid failed\n"); + return ret; + } + + return TEE_SUCCESS; +} + +static int32_t build_ta_basic_info_uuid(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta basic info uuid\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_BASIC_INFO_UUID_UUID: + if (handle_ta_basic_info_uuid(cfg_info, node->size, node->value) != TEE_SUCCESS) { + hm_error("handle ta basic info uuid\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_ta_basic_info(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta basic info\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_BASIC_INFO_SERVICE_NAME: + if (handle_conf_node_to_obj(pos, build_ta_basic_info_service_name, + cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { + hm_error("build ta basic info service name failed\n"); + return TEE_ERROR_GENERIC; + } + break; + case CONFIGINFO_TA_BASIC_INFO_UUID: + if (handle_conf_node_to_obj(pos, build_ta_basic_info_uuid, + cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { + hm_error("build ta basic info service name failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + hm_debug("skip in build ta basic info\n"); + if (handle_conf_node_to_obj(pos, NULL, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_ta_mani_info_instance_keep_alive(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta manifest info instance keep alive\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_MANIFEST_INFO_INSTANCE_KEEP_ALIVE_INSTANCE_KEEP_ALIVE: + if (node->size == 1 && node->value[0] == TLV_TRUE) + cfg_info->manifest_info.instance_keep_alive = true; + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_ta_mani_info_multi_command(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta manifest info multi command\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_MANIFEST_INFO_MULTI_COMMAND_MULTI_COMMAND: + if (node->size == 1 && node->value[0] == TLV_TRUE) + cfg_info->manifest_info.multi_command = true; + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_ta_mani_info_multi_session(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta manifest info multi session\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_MANIFEST_INFO_MULTI_SESSION_MULTI_SESSION: + if (node->size == 1 && node->value[0] == TLV_TRUE) + cfg_info->manifest_info.multi_session = true; + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t handle_ta_mani_info_stack_size(uint32_t *stack_size, uint32_t size, const char *value) +{ + uint64_t tmp_stack_size; + + if (value == NULL || size > MAX_UINT32_LEN || size == 0) { + hm_error("invalid parm while handle stack size\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + char buff[MAX_UINT32_LEN + 1]; + if (memcpy_s(buff, sizeof(buff), value, size) != 0) { + hm_error("memcpy failed while handle stack size\n"); + return TEE_ERROR_GENERIC; + } + buff[size] = '\0'; + + if (trans_str_to_int(buff, size, BASE_OF_TEN, &tmp_stack_size) != TEE_SUCCESS) { + hm_error("get stack size failed\n"); + return TEE_ERROR_GENERIC; + } + + if (tmp_stack_size > UINT32_MAX) { + hm_error("stack size is invalied %llx\n", (unsigned long long)tmp_stack_size); + return TEE_ERROR_GENERIC; + } + + *stack_size = (uint32_t)tmp_stack_size; + + return TEE_SUCCESS; +} + +static int32_t build_ta_mani_info_stack_size(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta manifest info stack size\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_MANIFEST_INFO_STACK_SIZE_STACK_SIZE: + if (handle_ta_mani_info_stack_size(&cfg_info->manifest_info.stack_size, + node->size, node->value) != TEE_SUCCESS) { + hm_error("build ta manifest info stack size failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t handle_ta_mani_info_heap_size(uint32_t *heap_size, uint32_t size, const char *value) +{ + uint64_t tmp_heap_size; + + if (value == NULL || size > MAX_UINT32_LEN || size == 0) { + hm_error("invalid parm while handle heap size\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + char buff[MAX_UINT32_LEN + 1]; + if (memcpy_s(buff, sizeof(buff), value, size) != 0) { + hm_error("memcpy failed while handle heap size\n"); + return TEE_ERROR_GENERIC; + } + buff[size] = '\0'; + + if (trans_str_to_int(buff, size, BASE_OF_TEN, &tmp_heap_size) != TEE_SUCCESS) { + hm_error("get heap size failed\n"); + return TEE_ERROR_GENERIC; + } + + if (tmp_heap_size > UINT32_MAX) { + hm_error("heap size is invalied %llx\n", (unsigned long long)tmp_heap_size); + return TEE_ERROR_GENERIC; + } + + *heap_size = (uint32_t)tmp_heap_size; + + return TEE_SUCCESS; +} + +static int32_t build_ta_mani_info_heap_size(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta manifest info heap size\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_MANIFEST_INFO_HEAP_SIZE_HEAP_SIZE: + if (handle_ta_mani_info_heap_size(&cfg_info->manifest_info.heap_size, + node->size, node->value) != TEE_SUCCESS) { + hm_error("build ta manifest info heap size failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t handle_ta_mani_info_target_type(uint32_t *target_type, uint32_t size, const char *value) +{ + uint64_t tmp_target_type; + + if (value == NULL || size > MAX_UINT32_LEN || size == 0) { + hm_error("invalid parm while handle target type\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + char buff[MAX_UINT32_LEN + 1]; + if (memcpy_s(buff, sizeof(buff), value, size) != 0) { + hm_error("memcpy failed while handle target type\n"); + return TEE_ERROR_GENERIC; + } + buff[size] = '\0'; + + if (trans_str_to_int(buff, size, BASE_OF_TEN, &tmp_target_type) != TEE_SUCCESS) { + hm_error("get heap size failed\n"); + return TEE_ERROR_GENERIC; + } + + if (tmp_target_type > UINT32_MAX) { + hm_error("target type is invalied %llx\n", (unsigned long long)tmp_target_type); + return TEE_ERROR_GENERIC; + } + + *target_type = (uint32_t)tmp_target_type; + + return TEE_SUCCESS; +} + +static int32_t build_ta_mani_info_target_type(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta manifest info target type\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_MANIFEST_INFO_TARGET_TYPE_TARGET_TYPE: + if (handle_ta_mani_info_target_type(&cfg_info->manifest_info.target_type, + node->size, node->value) != TEE_SUCCESS) { + hm_error("build ta manifest info target type failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_ta_mani_info_single_instance(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta manifest info single instance\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_MANIFEST_INFO_SINGLE_INSTANCE_SINGLE_INSTANCE: + if (node->size == 1 && node->value[0] == TLV_TRUE) + cfg_info->manifest_info.single_instance = true; + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static struct dyn_conf_build_func ta_mani_funcs[] = { + { CONFIGINFO_TA_MANIFEST_INFO_INSTANCE_KEEP_ALIVE, build_ta_mani_info_instance_keep_alive, NULL }, + { CONFIGINFO_TA_MANIFEST_INFO_STACK_SIZE, build_ta_mani_info_stack_size, NULL }, + { CONFIGINFO_TA_MANIFEST_INFO_HEAP_SIZE, build_ta_mani_info_heap_size, NULL }, + { CONFIGINFO_TA_MANIFEST_INFO_TARGET_TYPE, build_ta_mani_info_target_type, NULL }, + { CONFIGINFO_TA_MANIFEST_INFO_MULTI_COMMAND, build_ta_mani_info_multi_command, NULL }, + { CONFIGINFO_TA_MANIFEST_INFO_MULTI_SESSION, build_ta_mani_info_multi_session, NULL }, + { CONFIGINFO_TA_MANIFEST_INFO_SINGLE_INSTANCE, build_ta_mani_info_single_instance, NULL }, +}; + +static int32_t build_ta_mani_info(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta manifest info\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + uint32_t ta_mani_funcs_size = sizeof(ta_mani_funcs) / sizeof(ta_mani_funcs[0]); + uint32_t i; + for (i = 0; i < ta_mani_funcs_size; i++) { + if (node->tag != ta_mani_funcs[i].tag) + continue; + + if (ta_mani_funcs[i].handle != NULL && + handle_conf_node_to_obj(pos, ta_mani_funcs[i].handle, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + + if (ta_mani_funcs[i].checker != NULL && ta_mani_funcs[i].checker(cfg_info) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + + break; + } + + if (i == ta_mani_funcs_size) { + hm_debug("skip in build ta manifest info\n"); + if (handle_conf_node_to_obj(pos, NULL, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +#if defined(CONFIG_APP_TEE_SE) +static int32_t build_ta_control_info_se_open_session(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build se open session\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_CONTROL_INFO_SE_INFO_SE_OPEN_SESSION_SE_OPEN_SESSION: + if (node->size == 1 && node->value[0] == TLV_TRUE) + cfg_info->control_info.se_info.permissions |= SE_OPEN_SESSION_PERMISSION; + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_ta_control_info_se_info(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build se info\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_CONTROL_INFO_SE_INFO_SE_OPEN_SESSION: + if (handle_conf_node_to_obj(pos, build_ta_control_info_se_open_session, + cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { + hm_error("build ta control info se info se open session failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + hm_debug("skip in build ta control info se info\n"); + if (handle_conf_node_to_obj(pos, NULL, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} +#endif + +static int32_t build_ta_control_info_debug_status(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build debug status\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_STATUS_DEBUG_STATUS: + if (node->size == 1 && node->value[0] == TLV_TRUE) + cfg_info->control_info.debug_info.status = true; + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t handle_ta_control_info_debug_device_id(struct config_info *cfg_info, const struct conf_node_t *node) +{ + if (cfg_info == NULL || node == NULL || node->size != TLV_DEVICE_ID_LEN) { + hm_error("bad param\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + uint8_t buff[TLV_DEVICE_ID_LEN + 1] = { 0 }; + if (memcpy_s(buff, TLV_DEVICE_ID_LEN, node->value, node->size) != 0) { + hm_error("memcpy for debug device id failed\n"); + return TEE_ERROR_GENERIC; + } + buff[node->size] = '\0'; + + if (check_device_id(cfg_info, buff, node->size) != TEE_SUCCESS) { + hm_error("check device id failed\n"); + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +static int32_t build_ta_control_info_debug_device_id(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build debug device id\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_DEVICE_ID_DEBUG_DEVICE_ID: + if (handle_ta_control_info_debug_device_id(cfg_info, node) != TEE_SUCCESS) { + hm_error("check device id failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_ta_control_info_debug_info(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = NULL; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build debug info\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_STATUS: + if (handle_conf_node_to_obj(pos, build_ta_control_info_debug_status, + cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { + hm_error("build ta control info debug info debug status failed\n"); + return TEE_ERROR_GENERIC; + } + break; + case CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO_DEBUG_DEVICE_ID: + if (handle_conf_node_to_obj(pos, build_ta_control_info_debug_device_id, + cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { + hm_error("build ta control info debug info debug status failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + hm_debug("skip in build ta control info debug info\n"); + if (handle_conf_node_to_obj(pos, NULL, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_ta_control_info(struct dlist_node **pos, const struct conf_node_t *node, + void *obj, uint32_t obj_size) +{ + (void)pos; + struct config_info *cfg_info = (struct config_info *)obj; + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta control info\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + switch (node->tag) { +#if defined(CONFIG_APP_TEE_SE) + case CONFIGINFO_TA_CONTROL_INFO_SE_INFO: + if (handle_conf_node_to_obj(pos, build_ta_control_info_se_info, + cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { + hm_error("build ta control info rpmb info failed\n"); + return TEE_ERROR_GENERIC; + } + break; +#endif + case CONFIGINFO_TA_CONTROL_INFO_DEBUG_INFO: + if (handle_conf_node_to_obj(pos, build_ta_control_info_debug_info, + cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { + hm_error("build ta control info rpmb info failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + hm_debug("skip in build ta control info\n"); + if (handle_conf_node_to_obj(pos, NULL, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} + +static int32_t build_ta_config(struct dlist_node **pos, const struct conf_node_t *node, void *obj, uint32_t obj_size) +{ + struct config_info *cfg_info = NULL; + + if (obj_size != sizeof(*cfg_info)) { + hm_error("obj size is invalid while build ta config\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + cfg_info = (struct config_info *)obj; + + switch (node->tag) { + case CONFIGINFO_TA_BASIC_INFO: + if (handle_conf_node_to_obj(pos, build_ta_basic_info, + cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { + hm_error("build ta basic info failed\n"); + return TEE_ERROR_GENERIC; + } + break; + case CONFIGINFO_TA_MANIFEST_INFO: + if (handle_conf_node_to_obj(pos, build_ta_mani_info, + cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { + hm_error("build ta basic info failed\n"); + return TEE_ERROR_GENERIC; + } + break; + case CONFIGINFO_TA_CONTROL_INFO: + if (handle_conf_node_to_obj(pos, build_ta_control_info, + cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) { + hm_error("build ta basic info failed\n"); + return TEE_ERROR_GENERIC; + } + break; + default: + hm_debug("skip in build ta config\n"); + if (handle_conf_node_to_obj(pos, NULL, cfg_info, sizeof(*cfg_info)) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + break; + } + + return TEE_SUCCESS; +} + +int32_t install_ta_config(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue) +{ + if (conf_queue == NULL || obj == NULL) { + hm_error("param is invalid while install ta config\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (obj_size != sizeof(struct config_info)) { + hm_error("obj size is invalied while install ta config\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + struct config_info *cfg_info = (struct config_info *)obj; + + /* init ta config info */ + if (memset_s(cfg_info, sizeof(*cfg_info), 0, sizeof(*cfg_info)) != 0) { + hm_error("memset for ta config info failed\n"); + return TEE_ERROR_GENERIC; + } + + if (!dlist_empty(&conf_queue->queue)) { + struct dlist_node *pos = dlist_get_next(&conf_queue->queue); + int32_t ret = handle_conf_node_to_obj(&pos, build_ta_config, cfg_info, sizeof(*cfg_info)); + if (ret != TEE_SUCCESS) { + hm_error("handle ta config failed\n"); + return ret; + } + } + + return TEE_SUCCESS; +} + +#else + +int32_t install_ta_config(void *obj, uint32_t obj_size, const struct conf_queue_t *conf_queue) +{ + (void)obj; + (void)obj_size; + (void)conf_queue; + return TEE_SUCCESS; +} + +#endif diff --git a/lib/syslib/libdynconfmgr/Makefile b/lib/syslib/libdynconfmgr/Makefile index 23b77825..1585bdac 100644 --- a/lib/syslib/libdynconfmgr/Makefile +++ b/lib/syslib/libdynconfmgr/Makefile @@ -1,5 +1,12 @@ -# libdynconfmgr compile rule. -# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # MODULE MODULE := libdynconfmgr${TARG}.a diff --git a/lib/syslib/libdynconfmgr/include/dyn_conf_dispatch_inf.h b/lib/syslib/libdynconfmgr/include/dyn_conf_dispatch_inf.h index 11a7e1bb..bd7e6c8b 100644 --- a/lib/syslib/libdynconfmgr/include/dyn_conf_dispatch_inf.h +++ b/lib/syslib/libdynconfmgr/include/dyn_conf_dispatch_inf.h @@ -1,106 +1,111 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: dynamic config dispatch interface - * Author: qishuai qishuai6@huawei.com - * Create: 2021-02-03 - */ -#ifndef DYN_CONF_MGR_DYN_CONF_DISPATCH_INF_H -#define DYN_CONF_MGR_DYN_CONF_DISPATCH_INF_H - -#include -#include -#include -#include - -#define MAX_IMAGE_LEN 0x800000 -/* tag(DYN_CONF_TAG_LEN) | type(DYN_CONF_TYPE_LEN) | len(DYN_CONF_LEN_LEN) | value */ -#define DYN_CONF_TAG_LEN 3 -#define DYN_CONF_TYPE_LEN 1 -#define DYN_CONF_LEN_LEN 4 -#define DYN_CONF_TAG_MAX 0xffffffff -#define DYN_CONF_TYPE_MAX 0xffffffff -/* dyn conf must start with gpd.ta.dynConf */ -#define DYN_CONF_START "gpd.ta.dynConf" -/* the types dyn conf support */ -#define TYPE_CLASS 0 -#define TYPE_BOOL 1 -#define TYPE_INT 2 -#define TYPE_CHAR 3 -/* use to parse str special sym */ -#define LEN_OF_HEX_TRIM 2 /* the length of 0x */ -#define BIT_NUM_OF_UINT64 64 -#define BASE_OF_TEN 10 -#define BASE_OF_HEX 16 -#define MAX_UINT64_LEN 20 /* the max length of an uint64 num str */ -#define MAX_UINT32_LEN 10 /* the max length of an uint32 num str */ - -#define MAX_UINT64_HEX_LEN 16 /* the max length of an uint64 hex num str */ - -#define THREAD_LIMIT_MAX 8 -#define DRV_CMD_MAX 0xffffffff -#define IRQ_MIN 32 - -#define MAX_UUID_SIZE 36 - -#define UUID_TIMELOW_LEN 8 -#define UUID_TIMEMID_LEN 4 -#define UUID_HIVERSION_LEN 4 -#define UUID_SEQ_LEN 2 - -#define UUID_STRUCT_LEN 11 -#define TIMELOW_MAX 0xFFFFFFFF -#define TIMEMID_MAX 0xFFFF -#define TIMESEQ_MAX 0xFF -#define UUID_SEQ_SIZE 8 -#define TLV_TRUE '1' - -enum dyn_conf_exception_modes { - DYN_CONF_SYSCRASH_TAG = 0, - DYN_CONF_RESTART_TAG, - DYN_CONF_DDOS_TAG, -}; - -enum dyn_conf_data_nums { - DATA_TIMELOW_IDX = 0, - DATA_TIMEMID_IDX, - DATA_HVER_IDX, -}; - -/* the struct we use in queue */ -struct conf_node_t { - struct dlist_node head; - uint32_t tag; - uint32_t type; - uint32_t size; - const char *value; -}; - -struct conf_queue_t { - struct dlist_node queue; -}; - -/* load the dyn conf from mani_ext section in sec file */ -struct dyn_conf_t { - uint32_t dyn_conf_size; - char *dyn_conf_buffer; -}; - -typedef int32_t (*handler_conf_to_obj)(struct dlist_node **, const struct conf_node_t *, void *, uint32_t); -typedef int32_t (*handler_install_obj)(void *, uint32_t, const struct conf_queue_t *); -typedef void (*handler_uninstall_obj)(const void *, uint32_t); -typedef int32_t (*handler_check_obj)(const void *); - -int32_t register_conf(const struct dyn_conf_t *dyn_conf, handler_install_obj handle, void *obj, uint32_t obj_size); -void unregister_conf(handler_uninstall_obj uninstall_obj_func, void *obj, uint32_t obj_size); -uint16_t get_num_of_tag(const struct conf_queue_t *conf_queue, uint32_t tag); -int32_t handle_conf_node_to_obj(struct dlist_node **pos, handler_conf_to_obj handle, void *obj, uint32_t obj_size); -int32_t trans_str_to_int(const char *buff, uint32_t len, uint32_t base, uint64_t *num); -int32_t check_item_chip_type(const struct dlist_node *now, uint32_t chip_type_tag); -int32_t tlv_to_uuid(const char *uuid_buff, uint32_t size, struct tee_uuid *uuid); - -struct dyn_conf_build_func { - uint32_t tag; - handler_conf_to_obj handle; - handler_check_obj checker; -}; -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef DYN_CONF_MGR_DYN_CONF_DISPATCH_INF_H +#define DYN_CONF_MGR_DYN_CONF_DISPATCH_INF_H + +#include +#include +#include +#include + +#define MAX_IMAGE_LEN 0x800000 +/* tag(DYN_CONF_TAG_LEN) | type(DYN_CONF_TYPE_LEN) | len(DYN_CONF_LEN_LEN) | value */ +#define DYN_CONF_TAG_LEN 3 +#define DYN_CONF_TYPE_LEN 1 +#define DYN_CONF_LEN_LEN 4 +#define DYN_CONF_TAG_MAX 0xffffffff +#define DYN_CONF_TYPE_MAX 0xffffffff +/* dyn conf must start with gpd.ta.dynConf */ +#define DYN_CONF_START "gpd.ta.dynConf" +/* the types dyn conf support */ +#define TYPE_CLASS 0 +#define TYPE_BOOL 1 +#define TYPE_INT 2 +#define TYPE_CHAR 3 +/* use to parse str special sym */ +#define LEN_OF_HEX_TRIM 2 /* the length of 0x */ +#define BIT_NUM_OF_UINT64 64 +#define BASE_OF_TEN 10 +#define BASE_OF_HEX 16 +#define MAX_UINT64_LEN 20 /* the max length of an uint64 num str */ +#define MAX_UINT32_LEN 10 /* the max length of an uint32 num str */ + +#define MAX_UINT64_HEX_LEN 16 /* the max length of an uint64 hex num str */ + +#define THREAD_LIMIT_MAX 8 +#define DRV_CMD_MAX 0xffffffff +#define IRQ_MIN 32 + +#define MAX_UUID_SIZE 36 + +#define UUID_TIMELOW_LEN 8 +#define UUID_TIMEMID_LEN 4 +#define UUID_HIVERSION_LEN 4 +#define UUID_SEQ_LEN 2 + +#define UUID_STRUCT_LEN 11 +#define TIMELOW_MAX 0xFFFFFFFF +#define TIMEMID_MAX 0xFFFF +#define TIMESEQ_MAX 0xFF +#define UUID_SEQ_SIZE 8 +#define TLV_TRUE '1' + +enum dyn_conf_exception_modes { + DYN_CONF_SYSCRASH_TAG = 0, + DYN_CONF_RESTART_TAG, + DYN_CONF_DDOS_TAG, +}; + +enum dyn_conf_data_nums { + DATA_TIMELOW_IDX = 0, + DATA_TIMEMID_IDX, + DATA_HVER_IDX, +}; + +/* the struct we use in queue */ +struct conf_node_t { + struct dlist_node head; + uint32_t tag; + uint32_t type; + uint32_t size; + const char *value; +}; + +struct conf_queue_t { + struct dlist_node queue; +}; + +/* load the dyn conf from mani_ext section in sec file */ +struct dyn_conf_t { + uint32_t dyn_conf_size; + char *dyn_conf_buffer; +}; + +typedef int32_t (*handler_conf_to_obj)(struct dlist_node **, const struct conf_node_t *, void *, uint32_t); +typedef int32_t (*handler_install_obj)(void *, uint32_t, const struct conf_queue_t *); +typedef void (*handler_uninstall_obj)(const void *, uint32_t); +typedef int32_t (*handler_check_obj)(const void *); + +int32_t register_conf(const struct dyn_conf_t *dyn_conf, handler_install_obj handle, void *obj, uint32_t obj_size); +void unregister_conf(handler_uninstall_obj uninstall_obj_func, void *obj, uint32_t obj_size); +uint16_t get_num_of_tag(const struct conf_queue_t *conf_queue, uint32_t tag); +int32_t handle_conf_node_to_obj(struct dlist_node **pos, handler_conf_to_obj handle, void *obj, uint32_t obj_size); +int32_t trans_str_to_int(const char *buff, uint32_t len, uint32_t base, uint64_t *num); +int32_t check_item_chip_type(const struct dlist_node *now, uint32_t chip_type_tag); +int32_t tlv_to_uuid(const char *uuid_buff, uint32_t size, struct tee_uuid *uuid); + +struct dyn_conf_build_func { + uint32_t tag; + handler_conf_to_obj handle; + handler_check_obj checker; +}; +#endif diff --git a/lib/syslib/libdynconfmgr/src/dyn_conf_dispatch_inf.c b/lib/syslib/libdynconfmgr/src/dyn_conf_dispatch_inf.c index d1ebfac3..08ecc667 100644 --- a/lib/syslib/libdynconfmgr/src/dyn_conf_dispatch_inf.c +++ b/lib/syslib/libdynconfmgr/src/dyn_conf_dispatch_inf.c @@ -1,452 +1,457 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: dynamic conf dispatch interface implementation - * Author: qishuai qishuai6@huawei.com - * Create: 2021-02-03 - */ -#include "dyn_conf_dispatch_inf.h" -#include -#include -#include -#include -#include -#include - -#ifdef TEE_SUPPORT_DYN_CONF -int32_t handle_conf_node_to_obj(struct dlist_node **pos, handler_conf_to_obj handle, void *obj, uint32_t obj_size) -{ - struct conf_node_t *node = NULL; - uint64_t total_size; - uint64_t tmp_size = 0; - int32_t ret; - - if (pos == NULL || *pos == NULL || obj_size == 0 || - obj == NULL || obj_size >= MAX_IMAGE_LEN) { - tloge("params invalied while handle conf node to obj\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - node = dlist_entry(*pos, struct conf_node_t, head); - if (node == NULL || node->size >= MAX_IMAGE_LEN || node->size == 0) { - tloge("node is invalied\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - total_size = node->size; - - *pos = dlist_get_next(*pos); - while (1) { - node = dlist_entry(*pos, struct conf_node_t, head); - if (node == NULL || node->size >= MAX_IMAGE_LEN || node->size == 0) { - tloge("node is invalied\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (handle != NULL) - ret = handle(pos, node, obj, obj_size); - else - ret = TEE_SUCCESS; - if (ret != TEE_SUCCESS) - return ret; - - tmp_size += DYN_CONF_TAG_LEN + DYN_CONF_TYPE_LEN + DYN_CONF_LEN_LEN + node->size; - if (tmp_size >= total_size) - break; - - *pos = dlist_get_next(*pos); - } - - return TEE_SUCCESS; -} - -int32_t trans_str_to_int(const char *buff, uint32_t len, uint32_t base, uint64_t *num) -{ - char *endptr = NULL; - char tmp_buff[MAX_UINT64_HEX_LEN + LEN_OF_HEX_TRIM + 1] = { 0 }; - - if (buff == NULL || len == 0 || (base != BASE_OF_HEX && base != BASE_OF_TEN) || num == NULL) { - tloge("invalied params\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - /* if the base is 16, the length cannot larger than the len of '0xffffffffffffffff' */ - if (base == BASE_OF_HEX && len > MAX_UINT64_HEX_LEN + LEN_OF_HEX_TRIM) { - tloge("trans hex num, len %u should not larger than MAX_UINT64_HEX_LEN + LEN_OF_HEX_TRIM\n", len); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (base == BASE_OF_TEN && len > MAX_UINT64_LEN) { - tloge("trans num, len %u should not larger than MAX_UINT64_LEN\n", len); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (memcpy_s(tmp_buff, MAX_UINT64_HEX_LEN + LEN_OF_HEX_TRIM, buff, len) != 0) { - tloge("trans num memcpy failed\n"); - return TEE_ERROR_GENERIC; - } - tmp_buff[len] = '\0'; - - errno = 0; - *num = strtoull(tmp_buff, &endptr, base); - /* if endptr <= tmp_buff, means endptr == NULL or some other invalied situations */ - if (errno != 0 || endptr <= tmp_buff || *endptr != '\0') { - tloge("trans buff failed\n"); - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - -static uint32_t get_conf_len(const char *buff) -{ - int32_t ret; - char len_buff[DYN_CONF_LEN_LEN + LEN_OF_HEX_TRIM + 1] = { 0 }; - uint64_t num = 0; - - ret = snprintf_s(len_buff, DYN_CONF_LEN_LEN + LEN_OF_HEX_TRIM + 1, DYN_CONF_LEN_LEN + LEN_OF_HEX_TRIM, - "0x%s", buff); - if (ret < 0) { - tloge("get len buff error\n"); - return 0; - } - - ret = trans_str_to_int(len_buff, DYN_CONF_LEN_LEN + LEN_OF_HEX_TRIM, BASE_OF_HEX, &num); - if (ret != 0) - return 0; - - if (num > MAX_IMAGE_LEN) { - tloge("get len buff larger than MAX_IMAGE_LEN\n"); - return 0; - } - - return (uint32_t)num; -} - -static int32_t push_conf_queue(struct conf_queue_t *conf_queue, uint32_t tag, uint32_t type, - uint32_t size, const char *value) -{ - struct conf_node_t *conf_node = NULL; - - conf_node = (struct conf_node_t *)malloc(sizeof(*conf_node)); - if (conf_node == NULL) { - tloge("conf_node malloc failed\n"); - return TEE_ERROR_GENERIC; - } - - (void)memset_s(conf_node, sizeof(*conf_node), 0, sizeof(*conf_node)); - conf_node->tag = tag; - conf_node->type = type; - conf_node->size = size; - conf_node->value = value; - - dlist_insert_tail(&conf_node->head, &conf_queue->queue); - - return TEE_SUCCESS; -} - -static int32_t parse_dyn_conf(struct conf_queue_t *conf_queue, const char *start, uint32_t size) -{ - /* tag(DYN_CONF_TAG_LEN) | type(DYN_CONF_TYPE_LEN) | len(DYN_CONF_LEN_LEN) | value */ - char tag_buff[DYN_CONF_TAG_LEN + 1] = { 0 }; - char type_buff[DYN_CONF_TYPE_LEN + 1] = { 0 }; - char len_buff[DYN_CONF_LEN_LEN + 1] = { 0 }; - uint32_t index = 0; - uint32_t len; - uint64_t tag; - uint64_t type; - - while ((index < size) && (size > DYN_CONF_TAG_LEN + DYN_CONF_TYPE_LEN + DYN_CONF_LEN_LEN)) { - /* 1. handle tag */ - if (memcpy_s(tag_buff, DYN_CONF_TAG_LEN + 1, start + index, DYN_CONF_TAG_LEN) != 0) { - tloge("set tag buff failed\n"); - return TEE_ERROR_GENERIC; - } - - if (trans_str_to_int(tag_buff, DYN_CONF_TAG_LEN, BASE_OF_TEN, &tag) != TEE_SUCCESS || - tag > DYN_CONF_TAG_MAX) { - tloge("set tag failed\n"); - return TEE_ERROR_GENERIC; - } - - index += DYN_CONF_TAG_LEN; - /* 2. handle type */ - if (index >= size || memcpy_s(type_buff, DYN_CONF_TYPE_LEN + 1, start + index, DYN_CONF_TYPE_LEN) != 0) { - tloge("set type buff failed\n"); - return TEE_ERROR_GENERIC; - } - - if (trans_str_to_int(type_buff, DYN_CONF_TYPE_LEN, BASE_OF_TEN, &type) != TEE_SUCCESS || - type > DYN_CONF_TYPE_MAX) { - tloge("set type failed\n"); - return TEE_ERROR_GENERIC; - } - index += DYN_CONF_TYPE_LEN; - /* 3. handle length */ - if (index >= size || memcpy_s(len_buff, DYN_CONF_LEN_LEN + 1, start + index, DYN_CONF_LEN_LEN) != 0) { - tloge("set len buff failed\n"); - return TEE_ERROR_GENERIC; - } - - len = get_conf_len(len_buff); - if (len == 0 || len >= MAX_IMAGE_LEN || index + len + DYN_CONF_LEN_LEN > size) { - tloge("the attr's len is invalied\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - index += DYN_CONF_LEN_LEN; - /* 4. push the node into queue */ - if (push_conf_queue(conf_queue, (uint32_t)tag, (uint32_t)type, len, start + index) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - - /* 5. if the type is class, means that we must parse its childs */ - if (type == TYPE_CLASS) { - if (parse_dyn_conf(conf_queue, start + index, len) != TEE_SUCCESS) - return TEE_ERROR_GENERIC; - } - - index += len; - } - - return TEE_SUCCESS; -} - -static void free_conf_queue(const struct conf_queue_t *conf_queue) -{ - struct dlist_node *pos = NULL; - struct dlist_node *n = NULL; - - dlist_for_each_safe(pos, n, &conf_queue->queue) { - struct conf_node_t *conf_node = dlist_entry(pos, struct conf_node_t, head); - dlist_delete(&conf_node->head); - free(conf_node); - } -} - -void unregister_conf(handler_uninstall_obj uninstall_obj_func, void *obj, uint32_t obj_size) -{ - if (obj == NULL || obj_size == 0 || obj_size >= MAX_IMAGE_LEN || uninstall_obj_func == NULL) { - tloge("valid params while unregister conf\n"); - return; - } - - uninstall_obj_func(obj, obj_size); -} - -uint16_t get_num_of_tag(const struct conf_queue_t *conf_queue, uint32_t tag) -{ - struct dlist_node *pos = NULL; - uint32_t count = 0; - - if (conf_queue == NULL) { - tloge("valid params while get num of tag\n"); - return 0; - } - - dlist_for_each(pos, &conf_queue->queue) { - struct conf_node_t *conf_node = dlist_entry(pos, struct conf_node_t, head); - if (conf_node->tag == tag) - count++; - } - - return count; -} - -/* - * build section - * build all objs that you want to use from tlv - */ -static int32_t check_target_type_invalied(uint32_t size, const char *value) -{ - if (value == NULL || size > MAX_IMAGE_LEN) { - tloge("target type invalied param\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - char buff[CHIP_TYPE_LEN_MAX] = { 0 }; - if (tee_get_chip_type(buff, CHIP_TYPE_LEN_MAX) != 0) - return TEE_ERROR_GENERIC; - - char *origin = malloc(size + 1); - if (origin == NULL) { - tloge("malloc for chip type value failed\n"); - return TEE_ERROR_GENERIC; - } - - if (memset_s(origin, size + 1, 0, size + 1) != 0 || memcpy_s(origin, size + 1, value, size) != 0) { - free(origin); - tloge("mem opera for chip type value failed\n"); - return TEE_ERROR_GENERIC; - } - - char *target = origin; - char *rest = NULL; - while (1) { - target = strtok_r(target, ",", &rest); - if (target == NULL) - break; - - if (strlen(target) == strlen(buff) && memcmp(target, buff, strlen(buff)) == 0) { - free(origin); - return TEE_SUCCESS; - } - target = NULL; - } - - free(origin); - return TEE_ERROR_GENERIC; -} - -int32_t check_item_chip_type(const struct dlist_node *now, uint32_t chip_type_tag) -{ - if (now == NULL) { - tloge("valid params while check item chip type\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - struct dlist_node *tmp = NULL; - dlist_for_each(tmp, now) { - struct conf_node_t *conf_node = dlist_entry(tmp, struct conf_node_t, head); - if (conf_node == NULL) - break; - - /* if chip type is not set, means all platform can regist */ - if (conf_node->type == 0) - return TEE_SUCCESS; - - if (conf_node->tag == chip_type_tag) - return check_target_type_invalied(conf_node->size, conf_node->value); - } - - return TEE_ERROR_GENERIC; -} - -int32_t tlv_to_uuid(const char *uuid_buff, uint32_t size, struct tee_uuid *uuid) -{ - if (uuid_buff == NULL || size > MAX_UUID_SIZE || uuid == NULL || strlen(uuid_buff) < size) { - tloge("invalied param while tlv to uuid\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - uint32_t i; - uint64_t data[UUID_STRUCT_LEN] = { 0 }; - - const char *ptr = uuid_buff; - uint8_t flag = 0; - flag |= (uint8_t)(trans_str_to_int(ptr, UUID_TIMELOW_LEN, BASE_OF_HEX, &data[DATA_TIMELOW_IDX]) != 0); - ptr = ptr + UUID_TIMELOW_LEN + 1; - flag |= (uint8_t)(trans_str_to_int(ptr, UUID_TIMEMID_LEN, BASE_OF_HEX, &data[DATA_TIMEMID_IDX]) != 0); - ptr = ptr + UUID_TIMEMID_LEN + 1; - flag |= (uint8_t)(trans_str_to_int(ptr, UUID_HIVERSION_LEN, BASE_OF_HEX, &data[DATA_HVER_IDX]) != 0); - ptr = ptr + UUID_HIVERSION_LEN + 1; - - for (i = 0; i < UUID_SEQ_SIZE; i++) { - flag |= (uint8_t)(trans_str_to_int(ptr, UUID_SEQ_LEN, BASE_OF_HEX, &data[i + DATA_HVER_IDX + 1]) != 0); - ptr = ptr + UUID_SEQ_LEN; - if (i == 1) - ptr = ptr + 1; - } - - if (flag != 0) { - tloge("get uuid failed\n"); - return TEE_ERROR_GENERIC; - } - - flag = (uint8_t)(data[DATA_TIMELOW_IDX] > TIMELOW_MAX || data[DATA_TIMEMID_IDX] > TIMEMID_MAX || - data[DATA_HVER_IDX] > TIMEMID_MAX); - for (i = 0; i < UUID_SEQ_SIZE; i++) - flag |= (uint8_t)(data[i + DATA_HVER_IDX + 1] > TIMESEQ_MAX); - - if (flag != 0) { - tloge("uuid parse invalied\n"); - return TEE_ERROR_GENERIC; - } - - uuid->timeLow = data[DATA_TIMELOW_IDX]; - uuid->timeMid = data[DATA_TIMEMID_IDX]; - uuid->timeHiAndVersion = data[DATA_HVER_IDX]; - for (i = 0; i < UUID_SEQ_SIZE; i++) - uuid->clockSeqAndNode[i] = data[i + DATA_HVER_IDX + 1]; - - return TEE_SUCCESS; -} - -int32_t register_conf(const struct dyn_conf_t *dyn_conf, handler_install_obj install_obj_func, - void *obj, uint32_t obj_size) -{ - int32_t ret; - char *buff = NULL; - struct conf_queue_t conf_queue = { - .queue = dlist_head_init(conf_queue.queue), - }; - - if (obj == NULL || dyn_conf == NULL || - dyn_conf->dyn_conf_size > MAX_IMAGE_LEN - 1 || - dyn_conf->dyn_conf_size == 0 || - install_obj_func == NULL) { - tloge("valid params while register conf\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - buff = malloc(dyn_conf->dyn_conf_size); - if (buff == NULL) { - tloge("malloc buff for dyn conf failed\n"); - return TEE_ERROR_GENERIC; - } - - if (memcpy_s(buff, dyn_conf->dyn_conf_size, dyn_conf->dyn_conf_buffer, dyn_conf->dyn_conf_size) != EOK) { - tloge("Failed to copy extension\n"); - ret = TEE_ERROR_GENERIC; - goto out; - } - - ret = parse_dyn_conf(&conf_queue, buff, dyn_conf->dyn_conf_size); - if (ret != TEE_SUCCESS) { - tloge("Failed to parse dyn conf\n"); - goto out; - } - - ret = install_obj_func(obj, obj_size, &conf_queue); - if (ret != TEE_SUCCESS) - tloge("Failed to load dyn conf\n"); - -out: - if (buff != NULL) - free(buff); - - free_conf_queue(&conf_queue); - return ret; -} - -#else -int32_t register_conf(const struct dyn_conf_t *dyn_conf, handler_install_obj handle, void *obj, uint32_t obj_size) -{ - (void)dyn_conf; - (void)handle; - (void)obj; - (void)obj_size; - return TEE_SUCCESS; -} - -void unregister_conf(handler_uninstall_obj uninstall_obj_func, void *obj, uint32_t obj_size) -{ - (void)uninstall_obj_func; - (void)obj; - (void)obj_size; -} - -uint16_t get_num_of_tag(const struct conf_queue_t *conf_queue, uint32_t tag) -{ - (void)conf_queue; - (void)tag; - return 0; -} - -int32_t handle_conf_node_to_obj(struct dlist_node **pos, handler_conf_to_obj handle, void *obj, uint32_t obj_size) -{ - (void)pos; - (void)handle; - (void)obj; - (void)obj_size; - return TEE_SUCCESS; -} -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include "dyn_conf_dispatch_inf.h" +#include +#include +#include +#include +#include +#include + +#ifdef TEE_SUPPORT_DYN_CONF +int32_t handle_conf_node_to_obj(struct dlist_node **pos, handler_conf_to_obj handle, void *obj, uint32_t obj_size) +{ + struct conf_node_t *node = NULL; + uint64_t total_size; + uint64_t tmp_size = 0; + int32_t ret; + + if (pos == NULL || *pos == NULL || obj_size == 0 || + obj == NULL || obj_size >= MAX_IMAGE_LEN) { + tloge("params invalied while handle conf node to obj\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + node = dlist_entry(*pos, struct conf_node_t, head); + if (node == NULL || node->size >= MAX_IMAGE_LEN || node->size == 0) { + tloge("node is invalied\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + total_size = node->size; + + *pos = dlist_get_next(*pos); + while (1) { + node = dlist_entry(*pos, struct conf_node_t, head); + if (node == NULL || node->size >= MAX_IMAGE_LEN || node->size == 0) { + tloge("node is invalied\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (handle != NULL) + ret = handle(pos, node, obj, obj_size); + else + ret = TEE_SUCCESS; + if (ret != TEE_SUCCESS) + return ret; + + tmp_size += DYN_CONF_TAG_LEN + DYN_CONF_TYPE_LEN + DYN_CONF_LEN_LEN + node->size; + if (tmp_size >= total_size) + break; + + *pos = dlist_get_next(*pos); + } + + return TEE_SUCCESS; +} + +int32_t trans_str_to_int(const char *buff, uint32_t len, uint32_t base, uint64_t *num) +{ + char *endptr = NULL; + char tmp_buff[MAX_UINT64_HEX_LEN + LEN_OF_HEX_TRIM + 1] = { 0 }; + + if (buff == NULL || len == 0 || (base != BASE_OF_HEX && base != BASE_OF_TEN) || num == NULL) { + tloge("invalied params\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + /* if the base is 16, the length cannot larger than the len of '0xffffffffffffffff' */ + if (base == BASE_OF_HEX && len > MAX_UINT64_HEX_LEN + LEN_OF_HEX_TRIM) { + tloge("trans hex num, len %u should not larger than MAX_UINT64_HEX_LEN + LEN_OF_HEX_TRIM\n", len); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (base == BASE_OF_TEN && len > MAX_UINT64_LEN) { + tloge("trans num, len %u should not larger than MAX_UINT64_LEN\n", len); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (memcpy_s(tmp_buff, MAX_UINT64_HEX_LEN + LEN_OF_HEX_TRIM, buff, len) != 0) { + tloge("trans num memcpy failed\n"); + return TEE_ERROR_GENERIC; + } + tmp_buff[len] = '\0'; + + errno = 0; + *num = strtoull(tmp_buff, &endptr, base); + /* if endptr <= tmp_buff, means endptr == NULL or some other invalied situations */ + if (errno != 0 || endptr <= tmp_buff || *endptr != '\0') { + tloge("trans buff failed\n"); + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + +static uint32_t get_conf_len(const char *buff) +{ + int32_t ret; + char len_buff[DYN_CONF_LEN_LEN + LEN_OF_HEX_TRIM + 1] = { 0 }; + uint64_t num = 0; + + ret = snprintf_s(len_buff, DYN_CONF_LEN_LEN + LEN_OF_HEX_TRIM + 1, DYN_CONF_LEN_LEN + LEN_OF_HEX_TRIM, + "0x%s", buff); + if (ret < 0) { + tloge("get len buff error\n"); + return 0; + } + + ret = trans_str_to_int(len_buff, DYN_CONF_LEN_LEN + LEN_OF_HEX_TRIM, BASE_OF_HEX, &num); + if (ret != 0) + return 0; + + if (num > MAX_IMAGE_LEN) { + tloge("get len buff larger than MAX_IMAGE_LEN\n"); + return 0; + } + + return (uint32_t)num; +} + +static int32_t push_conf_queue(struct conf_queue_t *conf_queue, uint32_t tag, uint32_t type, + uint32_t size, const char *value) +{ + struct conf_node_t *conf_node = NULL; + + conf_node = (struct conf_node_t *)malloc(sizeof(*conf_node)); + if (conf_node == NULL) { + tloge("conf_node malloc failed\n"); + return TEE_ERROR_GENERIC; + } + + (void)memset_s(conf_node, sizeof(*conf_node), 0, sizeof(*conf_node)); + conf_node->tag = tag; + conf_node->type = type; + conf_node->size = size; + conf_node->value = value; + + dlist_insert_tail(&conf_node->head, &conf_queue->queue); + + return TEE_SUCCESS; +} + +static int32_t parse_dyn_conf(struct conf_queue_t *conf_queue, const char *start, uint32_t size) +{ + /* tag(DYN_CONF_TAG_LEN) | type(DYN_CONF_TYPE_LEN) | len(DYN_CONF_LEN_LEN) | value */ + char tag_buff[DYN_CONF_TAG_LEN + 1] = { 0 }; + char type_buff[DYN_CONF_TYPE_LEN + 1] = { 0 }; + char len_buff[DYN_CONF_LEN_LEN + 1] = { 0 }; + uint32_t index = 0; + uint32_t len; + uint64_t tag; + uint64_t type; + + while ((index < size) && (size > DYN_CONF_TAG_LEN + DYN_CONF_TYPE_LEN + DYN_CONF_LEN_LEN)) { + /* 1. handle tag */ + if (memcpy_s(tag_buff, DYN_CONF_TAG_LEN + 1, start + index, DYN_CONF_TAG_LEN) != 0) { + tloge("set tag buff failed\n"); + return TEE_ERROR_GENERIC; + } + + if (trans_str_to_int(tag_buff, DYN_CONF_TAG_LEN, BASE_OF_TEN, &tag) != TEE_SUCCESS || + tag > DYN_CONF_TAG_MAX) { + tloge("set tag failed\n"); + return TEE_ERROR_GENERIC; + } + + index += DYN_CONF_TAG_LEN; + /* 2. handle type */ + if (index >= size || memcpy_s(type_buff, DYN_CONF_TYPE_LEN + 1, start + index, DYN_CONF_TYPE_LEN) != 0) { + tloge("set type buff failed\n"); + return TEE_ERROR_GENERIC; + } + + if (trans_str_to_int(type_buff, DYN_CONF_TYPE_LEN, BASE_OF_TEN, &type) != TEE_SUCCESS || + type > DYN_CONF_TYPE_MAX) { + tloge("set type failed\n"); + return TEE_ERROR_GENERIC; + } + index += DYN_CONF_TYPE_LEN; + /* 3. handle length */ + if (index >= size || memcpy_s(len_buff, DYN_CONF_LEN_LEN + 1, start + index, DYN_CONF_LEN_LEN) != 0) { + tloge("set len buff failed\n"); + return TEE_ERROR_GENERIC; + } + + len = get_conf_len(len_buff); + if (len == 0 || len >= MAX_IMAGE_LEN || index + len + DYN_CONF_LEN_LEN > size) { + tloge("the attr's len is invalied\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + index += DYN_CONF_LEN_LEN; + /* 4. push the node into queue */ + if (push_conf_queue(conf_queue, (uint32_t)tag, (uint32_t)type, len, start + index) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + + /* 5. if the type is class, means that we must parse its childs */ + if (type == TYPE_CLASS) { + if (parse_dyn_conf(conf_queue, start + index, len) != TEE_SUCCESS) + return TEE_ERROR_GENERIC; + } + + index += len; + } + + return TEE_SUCCESS; +} + +static void free_conf_queue(const struct conf_queue_t *conf_queue) +{ + struct dlist_node *pos = NULL; + struct dlist_node *n = NULL; + + dlist_for_each_safe(pos, n, &conf_queue->queue) { + struct conf_node_t *conf_node = dlist_entry(pos, struct conf_node_t, head); + dlist_delete(&conf_node->head); + free(conf_node); + } +} + +void unregister_conf(handler_uninstall_obj uninstall_obj_func, void *obj, uint32_t obj_size) +{ + if (obj == NULL || obj_size == 0 || obj_size >= MAX_IMAGE_LEN || uninstall_obj_func == NULL) { + tloge("valid params while unregister conf\n"); + return; + } + + uninstall_obj_func(obj, obj_size); +} + +uint16_t get_num_of_tag(const struct conf_queue_t *conf_queue, uint32_t tag) +{ + struct dlist_node *pos = NULL; + uint32_t count = 0; + + if (conf_queue == NULL) { + tloge("valid params while get num of tag\n"); + return 0; + } + + dlist_for_each(pos, &conf_queue->queue) { + struct conf_node_t *conf_node = dlist_entry(pos, struct conf_node_t, head); + if (conf_node->tag == tag) + count++; + } + + return count; +} + +/* + * build section + * build all objs that you want to use from tlv + */ +static int32_t check_target_type_invalied(uint32_t size, const char *value) +{ + if (value == NULL || size > MAX_IMAGE_LEN) { + tloge("target type invalied param\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + char buff[CHIP_TYPE_LEN_MAX] = { 0 }; + if (tee_get_chip_type(buff, CHIP_TYPE_LEN_MAX) != 0) + return TEE_ERROR_GENERIC; + + char *origin = malloc(size + 1); + if (origin == NULL) { + tloge("malloc for chip type value failed\n"); + return TEE_ERROR_GENERIC; + } + + if (memset_s(origin, size + 1, 0, size + 1) != 0 || memcpy_s(origin, size + 1, value, size) != 0) { + free(origin); + tloge("mem opera for chip type value failed\n"); + return TEE_ERROR_GENERIC; + } + + char *target = origin; + char *rest = NULL; + while (1) { + target = strtok_r(target, ",", &rest); + if (target == NULL) + break; + + if (strlen(target) == strlen(buff) && memcmp(target, buff, strlen(buff)) == 0) { + free(origin); + return TEE_SUCCESS; + } + target = NULL; + } + + free(origin); + return TEE_ERROR_GENERIC; +} + +int32_t check_item_chip_type(const struct dlist_node *now, uint32_t chip_type_tag) +{ + if (now == NULL) { + tloge("valid params while check item chip type\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + struct dlist_node *tmp = NULL; + dlist_for_each(tmp, now) { + struct conf_node_t *conf_node = dlist_entry(tmp, struct conf_node_t, head); + if (conf_node == NULL) + break; + + /* if chip type is not set, means all platform can regist */ + if (conf_node->type == 0) + return TEE_SUCCESS; + + if (conf_node->tag == chip_type_tag) + return check_target_type_invalied(conf_node->size, conf_node->value); + } + + return TEE_ERROR_GENERIC; +} + +int32_t tlv_to_uuid(const char *uuid_buff, uint32_t size, struct tee_uuid *uuid) +{ + if (uuid_buff == NULL || size > MAX_UUID_SIZE || uuid == NULL || strlen(uuid_buff) < size) { + tloge("invalied param while tlv to uuid\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + uint32_t i; + uint64_t data[UUID_STRUCT_LEN] = { 0 }; + + const char *ptr = uuid_buff; + uint8_t flag = 0; + flag |= (uint8_t)(trans_str_to_int(ptr, UUID_TIMELOW_LEN, BASE_OF_HEX, &data[DATA_TIMELOW_IDX]) != 0); + ptr = ptr + UUID_TIMELOW_LEN + 1; + flag |= (uint8_t)(trans_str_to_int(ptr, UUID_TIMEMID_LEN, BASE_OF_HEX, &data[DATA_TIMEMID_IDX]) != 0); + ptr = ptr + UUID_TIMEMID_LEN + 1; + flag |= (uint8_t)(trans_str_to_int(ptr, UUID_HIVERSION_LEN, BASE_OF_HEX, &data[DATA_HVER_IDX]) != 0); + ptr = ptr + UUID_HIVERSION_LEN + 1; + + for (i = 0; i < UUID_SEQ_SIZE; i++) { + flag |= (uint8_t)(trans_str_to_int(ptr, UUID_SEQ_LEN, BASE_OF_HEX, &data[i + DATA_HVER_IDX + 1]) != 0); + ptr = ptr + UUID_SEQ_LEN; + if (i == 1) + ptr = ptr + 1; + } + + if (flag != 0) { + tloge("get uuid failed\n"); + return TEE_ERROR_GENERIC; + } + + flag = (uint8_t)(data[DATA_TIMELOW_IDX] > TIMELOW_MAX || data[DATA_TIMEMID_IDX] > TIMEMID_MAX || + data[DATA_HVER_IDX] > TIMEMID_MAX); + for (i = 0; i < UUID_SEQ_SIZE; i++) + flag |= (uint8_t)(data[i + DATA_HVER_IDX + 1] > TIMESEQ_MAX); + + if (flag != 0) { + tloge("uuid parse invalied\n"); + return TEE_ERROR_GENERIC; + } + + uuid->timeLow = data[DATA_TIMELOW_IDX]; + uuid->timeMid = data[DATA_TIMEMID_IDX]; + uuid->timeHiAndVersion = data[DATA_HVER_IDX]; + for (i = 0; i < UUID_SEQ_SIZE; i++) + uuid->clockSeqAndNode[i] = data[i + DATA_HVER_IDX + 1]; + + return TEE_SUCCESS; +} + +int32_t register_conf(const struct dyn_conf_t *dyn_conf, handler_install_obj install_obj_func, + void *obj, uint32_t obj_size) +{ + int32_t ret; + char *buff = NULL; + struct conf_queue_t conf_queue = { + .queue = dlist_head_init(conf_queue.queue), + }; + + if (obj == NULL || dyn_conf == NULL || + dyn_conf->dyn_conf_size > MAX_IMAGE_LEN - 1 || + dyn_conf->dyn_conf_size == 0 || + install_obj_func == NULL) { + tloge("valid params while register conf\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + buff = malloc(dyn_conf->dyn_conf_size); + if (buff == NULL) { + tloge("malloc buff for dyn conf failed\n"); + return TEE_ERROR_GENERIC; + } + + if (memcpy_s(buff, dyn_conf->dyn_conf_size, dyn_conf->dyn_conf_buffer, dyn_conf->dyn_conf_size) != EOK) { + tloge("Failed to copy extension\n"); + ret = TEE_ERROR_GENERIC; + goto out; + } + + ret = parse_dyn_conf(&conf_queue, buff, dyn_conf->dyn_conf_size); + if (ret != TEE_SUCCESS) { + tloge("Failed to parse dyn conf\n"); + goto out; + } + + ret = install_obj_func(obj, obj_size, &conf_queue); + if (ret != TEE_SUCCESS) + tloge("Failed to load dyn conf\n"); + +out: + if (buff != NULL) + free(buff); + + free_conf_queue(&conf_queue); + return ret; +} + +#else +int32_t register_conf(const struct dyn_conf_t *dyn_conf, handler_install_obj handle, void *obj, uint32_t obj_size) +{ + (void)dyn_conf; + (void)handle; + (void)obj; + (void)obj_size; + return TEE_SUCCESS; +} + +void unregister_conf(handler_uninstall_obj uninstall_obj_func, void *obj, uint32_t obj_size) +{ + (void)uninstall_obj_func; + (void)obj; + (void)obj_size; +} + +uint16_t get_num_of_tag(const struct conf_queue_t *conf_queue, uint32_t tag) +{ + (void)conf_queue; + (void)tag; + return 0; +} + +int32_t handle_conf_node_to_obj(struct dlist_node **pos, handler_conf_to_obj handle, void *obj, uint32_t obj_size) +{ + (void)pos; + (void)handle; + (void)obj; + (void)obj_size; + return TEE_SUCCESS; +} +#endif diff --git a/lib/syslib/libelf_verify/Makefile b/lib/syslib/libelf_verify/Makefile index 55630b2d..7902d4b3 100644 --- a/lib/syslib/libelf_verify/Makefile +++ b/lib/syslib/libelf_verify/Makefile @@ -1,5 +1,12 @@ -# libelf_verify compile rule, modified by yuanhao34@huawei.com -# Copyright Huawei Technologies Co., Ltd. 2010-2021. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # Targets MODULE := libelf_verify${TARG}.a diff --git a/lib/syslib/libelf_verify/include/ta_lib_img_unpack.h b/lib/syslib/libelf_verify/include/ta_lib_img_unpack.h index 82f834cb..7f1526f0 100644 --- a/lib/syslib/libelf_verify/include/ta_lib_img_unpack.h +++ b/lib/syslib/libelf_verify/include/ta_lib_img_unpack.h @@ -1,277 +1,282 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: permission service implementation - * Author: YuanHao yuanhao34@huawei.com - * Create: 2021-03-15 - */ -#ifndef TA_LIB_IMG_UNPACK_H -#define TA_LIB_IMG_UNPACK_H -#include "tee_defines.h" -#include "ta_framework.h" - -#define KEY_VER_BITE 0X8U -#define KEY_VER_MASK 0XFFU -#define SEC_IMG_TA_KEY_VERSION 2U -/* ta's sec file only signature not encrypt */ -#define KEY_VER_NOT_ENCRYPT 0 -#define PERMSRV_FILE_OPT ".rtosck.permsrv_file_operation" -#define PERMSRV_SAVE_FILE ".rtosck.permsrv_save_file" -#define INVALID_OFFSET (-1) -#define MAX_TAFS_NAME_LEN 64 -#define RWRIGHT 0600 -#define COUNTER_STEP_SIZE 0x1010101 -#define SERVICE_NAME_MAX_IN_MANIFEST 48 -#define RET_KEEP_LOADING 3 -#define SIGN_ALG_MASK 0x0000FFFF -#define RWRIGHT 0600 -#define LOAD_TA_TMP_FILE "%s/gt_elf_%u.msec" - -#define DECIMAL_BASE 10 -#define HEX_BASE 16 -#define MIN_MANIFEST_SIZE 128 -#define MAX_MANIFEST_SIZE 512 -#define ADDITIONAL_BUF_SIZE 4096 -#define TEE_RSA1024_BYTE_LEN 128 -#define TEE_RSA2048_BYTE_LEN 256 -#define TEE_RSA4096_BYTE_LEN 512 -#define DECRY_OFFSET 10 - -#define CIPHER_HDR_8_BYTE 8 -#define CIPHER_HDR_16_BYTE 16 -#define CIPHER_HDR_32_BYTE 32 -#define CIPHER_HDR_64_BYTE 64 -#define SIGN_ALGO_RSA_2048 0x00002048 -#define SIGN_ALGO_RSA_4096 0x00004096 -#define SIGN_ALGO_ECC_256 0x00000256 - -#define SIGN_ALG_KEY_STYLE_MASK 0x10000000 /* 0: debug, 1: release */ -#define SIGN_ALG_PADD_MASK 0x08000000 /* 0: pkcs1v5, 1: pss */ -#define SIGN_ALG_HASH_MASK 0x04000000 /* 0: sha256, 1: sha512 */ -#define SIGN_ALG_KEY_LEN_MASK 0x0000ffff /* only support 2048/4096bits */ - -#define SIGN_TA_ALG_BITS 20 -#define SIGN_ALG_TA_ALG_MASK 0xF - -#define RSA2048_SIGNATURE_SIZE 256 -#define RSA4096_SIGNATURE_SIZE 512 -#define ECC256_SIGNATURE_SIZE 72 -#define MAX_SIGNATURE_SIZE 512 - -#define OUTPUT_MEM_REF_INDEX 2 -#define INPUT_VALUE_INDEX 3 - -#define SIGNATURE_SIZE_INVALID 0 - -#define TA_HEAD_MAGIC1 0xA5A55A5A -#define TA_HEAD_MAGIC2 0x55AA - -#define IMAGE_BUF_EXTRA 4096 -#define SHA1_LEN 20 -#define SHA256_LEN 32 /* now use sha256 hash alg */ -#define SHA512_LEN 64 /* now use sha256 hash alg */ -#define HASH_UPDATA_LEN 1024 /* modify from 64 to 1024, reduce elf-load time */ - -#define TEE_ERROR_IMG_DECRYPTO_FAIL 0xFF01 /* *< Image decryption failed */ -#define TEE_ERROR_IMG_VERIFY_FAIL 0xFF02 /* *< Image verification failed */ -#define TEE_ERROR_IMG_ELF_LOAD_FAIL 0xFF03 /* *< Image loading failed */ -#define TEE_ERROR_IMG_NEED_LOAD_FAIL 0xFF04 /* *< Image loading judgement failed */ -#define TEE_ERROR_IMG_PARSE_FAIL 0xFF05 /* *< Image parse failed */ - -#define KEY_SIZE_MAX 64 - -#define ELF_HEAD_SIZE 0x36 -#define MANIFEST_PLAIN_LEN 116 -#define RSA_SIGN_LEN 256 -#define MIN_CRYPTO_LEN 128 -#define AES_CIPHER_PAD(p) (16 - (p) % 16) -#define SIZE_ALIGN(p) (4 - (p) % 4) -#define RLEN 32 -#define E_KEY_SIZE 65 -#define KEY_HASH_MAX 32 -#define RSA_DIGEST_LEN KEY_HASH_MAX - -#define RSA_PUB_D_SIZE 384 -#define RSA_PRIV_ORIG_LEN 193 -#define RSA_PUB_E_SIZE 3 - -#define TA_LOAD_PERM_ALLOW 1 -#define TA_LOAD_PERM_DENY 0 - -#define UINT32_MAX_VALUE 0xFFFFFFFF - -typedef enum { - IMG_TYPE_APP = 1, - IMG_TYPE_LIB = 2, - IMG_TYPE_DYNAMIC_DRV = 3, - IMG_TYPE_CRYPTO_DRV = 4, - IMG_TYPE_DYNAMIC_SRV = 5, - IMG_TYPE_DYNAMIC_CLIENT = 6, - IMG_TYPE_MAX = 7, -} tee_img_type_t; - -enum { - HARDWARE_ENGINE_CRYPTO = 1, - HARDWARE_ENGINE_MAX, -}; - -/* Version 1, 2 have the same image head */ -typedef struct { - uint32_t context_len; /* manifest_crypto_len + cipher_bin_len */ - uint32_t manifest_crypto_len; /* manifest crypto len */ - uint32_t manifest_plain_len; /* manfiest extension + manifest binary */ - uint32_t manifest_str_len; /* manifest extension len */ - uint32_t cipher_bin_len; - uint32_t sign_len; /* sign file len, now rsa 2048 this len is 256 */ -} teec_image_head; - -typedef struct { - uint32_t magic_num1; - uint16_t magic_num2; - uint16_t version_num; -} teec_image_identity; - -typedef struct { - teec_image_head img_hd; -} teec_ta_head_v1; - -/* V2 & V3 have the same TA HEADER */ -typedef struct { - teec_image_identity img_identity; - teec_image_head img_hd; - uint8_t reserved[16]; // Reserve 16 bytes for further extension -} teec_ta_head_v2; - -typedef struct { - int32_t single_instance; - int32_t multi_session; - int32_t multi_command; - uint32_t heap_size; - uint32_t stack_size; - int32_t instance_keep_alive; -} ta_property_t; - -typedef struct { - ta_property_t ta_property; - uint32_t elf_hash_len; - uint32_t elf_cryptkey_len; - uint32_t service_name_len; -} manifest_info_t; - -typedef struct { - uint16_t distribution; - uint16_t api_level; - uint16_t sdk_version; - bool is_lib; - bool ssa_enum_enable; - bool mem_page_align; - bool sys_verify_ta; - uint16_t target_type; - uint16_t target_version; - uint16_t hardware_type; - bool is_need_release_ta_res; - bool crash_callback; - bool is_need_create_msg; - bool is_need_release_msg; -} manifest_extension_t; - -typedef struct { - TEE_UUID srv_uuid; - manifest_info_t mani_info; - int8_t *hash_val; - int8_t *key_val; - int8_t *service_name; - manifest_extension_t ext; -} manifest_t; - -typedef struct { - manifest_t manifest; /* save manifest info */ - int8_t *manifest_buf; /* use malloc, save manifest extension */ - int8_t *img_buf; /* use rtosck mem, save image */ - uint32_t img_offset; - uint32_t img_size; - uint32_t img_version; - bool dyn_conf_registed; /* using for dyn perm */ -} load_img_info; - -typedef struct { - uint32_t key_size; - uint32_t iv_size; - uint32_t signature_alg; -} ta_cipher_hdr_t; - -typedef struct { - ta_cipher_hdr_t cipher_hdr; - uint8_t *key; - uint8_t *iv; -} ta_cipher_layer_t; - -typedef struct { - uint32_t format_version; - uint32_t mani_info_size; - uint32_t mani_ext_size; - uint32_t ta_elf_size; - uint32_t ta_conf_size; -} ta_payload_hdr_t; - -typedef struct { - ta_payload_hdr_t payload_hdr; - uint8_t *ta_elf; - uint8_t *ta_conf; - bool conf_registed; -} ta_payload_layer_t; - -typedef struct { - teec_image_identity img_identity; - uint32_t context_len; - uint32_t ta_key_version; -} ta_image_hdr_v3_t; - -#define MAX_HEADER_SIZE 0x400 -#define MANIFEST_RESERVE_SIZE 128 - -typedef struct { - uint32_t img_version; - uint32_t identity_len; - uint32_t header_len; - uint32_t image_len; - uint32_t total_len; - TEE_UUID srv_uuid; - int8_t *service_name; - uint32_t service_name_len; - int32_t multi_instance; - int32_t multi_session; - int32_t multi_command; - uint32_t heap_size; - uint32_t stack_size; - int32_t instance_keep_alive; - uint8_t *manifest_buf; - uint8_t manifest_str_len; - int8_t *img_buf; - uint32_t img_buf_len; - uint32_t img_buf_offset; -} teec_image_info; - -enum cipher_layer_len_ver { - CIPHER_LAYER_LEN_256 = 256, - CIPHER_LAYER_LEN_384 = 384, -}; - -enum cipher_layer_key_ver { - CIPHER_LAYER_KEY_V1 = 1, /* 2048 bits key, default is also 2048 bits */ - CIPHER_LAYER_KEY_V2 = 2, /* 3072 bits key */ -}; - -typedef struct { - int8_t *ptr_manifest_buf; - int8_t *ptr_ta_elf; - int8_t *img_buf; - uint32_t img_offset; - uint32_t img_size; - uint32_t img_version; - int32_t img_fp; /* fp here means a special fd */ - uint32_t aligned_img_size; - char tmp_file_name[MAX_TAFS_NAME_LEN]; - bool tmp_file_exist; -} elf_image_info; - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef TA_LIB_IMG_UNPACK_H +#define TA_LIB_IMG_UNPACK_H +#include "tee_defines.h" +#include "ta_framework.h" + +#define KEY_VER_BITE 0X8U +#define KEY_VER_MASK 0XFFU +#define SEC_IMG_TA_KEY_VERSION 2U +/* ta's sec file only signature not encrypt */ +#define KEY_VER_NOT_ENCRYPT 0 +#define PERMSRV_FILE_OPT ".rtosck.permsrv_file_operation" +#define PERMSRV_SAVE_FILE ".rtosck.permsrv_save_file" +#define INVALID_OFFSET (-1) +#define MAX_TAFS_NAME_LEN 64 +#define RWRIGHT 0600 +#define COUNTER_STEP_SIZE 0x1010101 +#define SERVICE_NAME_MAX_IN_MANIFEST 48 +#define RET_KEEP_LOADING 3 +#define SIGN_ALG_MASK 0x0000FFFF +#define RWRIGHT 0600 +#define LOAD_TA_TMP_FILE "%s/gt_elf_%u.msec" + +#define DECIMAL_BASE 10 +#define HEX_BASE 16 +#define MIN_MANIFEST_SIZE 128 +#define MAX_MANIFEST_SIZE 512 +#define ADDITIONAL_BUF_SIZE 4096 +#define TEE_RSA1024_BYTE_LEN 128 +#define TEE_RSA2048_BYTE_LEN 256 +#define TEE_RSA4096_BYTE_LEN 512 +#define DECRY_OFFSET 10 + +#define CIPHER_HDR_8_BYTE 8 +#define CIPHER_HDR_16_BYTE 16 +#define CIPHER_HDR_32_BYTE 32 +#define CIPHER_HDR_64_BYTE 64 +#define SIGN_ALGO_RSA_2048 0x00002048 +#define SIGN_ALGO_RSA_4096 0x00004096 +#define SIGN_ALGO_ECC_256 0x00000256 + +#define SIGN_ALG_KEY_STYLE_MASK 0x10000000 /* 0: debug, 1: release */ +#define SIGN_ALG_PADD_MASK 0x08000000 /* 0: pkcs1v5, 1: pss */ +#define SIGN_ALG_HASH_MASK 0x04000000 /* 0: sha256, 1: sha512 */ +#define SIGN_ALG_KEY_LEN_MASK 0x0000ffff /* only support 2048/4096bits */ + +#define SIGN_TA_ALG_BITS 20 +#define SIGN_ALG_TA_ALG_MASK 0xF + +#define RSA2048_SIGNATURE_SIZE 256 +#define RSA4096_SIGNATURE_SIZE 512 +#define ECC256_SIGNATURE_SIZE 72 +#define MAX_SIGNATURE_SIZE 512 + +#define OUTPUT_MEM_REF_INDEX 2 +#define INPUT_VALUE_INDEX 3 + +#define SIGNATURE_SIZE_INVALID 0 + +#define TA_HEAD_MAGIC1 0xA5A55A5A +#define TA_HEAD_MAGIC2 0x55AA + +#define IMAGE_BUF_EXTRA 4096 +#define SHA1_LEN 20 +#define SHA256_LEN 32 /* now use sha256 hash alg */ +#define SHA512_LEN 64 /* now use sha256 hash alg */ +#define HASH_UPDATA_LEN 1024 /* modify from 64 to 1024, reduce elf-load time */ + +#define TEE_ERROR_IMG_DECRYPTO_FAIL 0xFF01 /* *< Image decryption failed */ +#define TEE_ERROR_IMG_VERIFY_FAIL 0xFF02 /* *< Image verification failed */ +#define TEE_ERROR_IMG_ELF_LOAD_FAIL 0xFF03 /* *< Image loading failed */ +#define TEE_ERROR_IMG_NEED_LOAD_FAIL 0xFF04 /* *< Image loading judgement failed */ +#define TEE_ERROR_IMG_PARSE_FAIL 0xFF05 /* *< Image parse failed */ + +#define KEY_SIZE_MAX 64 + +#define ELF_HEAD_SIZE 0x36 +#define MANIFEST_PLAIN_LEN 116 +#define RSA_SIGN_LEN 256 +#define MIN_CRYPTO_LEN 128 +#define AES_CIPHER_PAD(p) (16 - (p) % 16) +#define SIZE_ALIGN(p) (4 - (p) % 4) +#define RLEN 32 +#define E_KEY_SIZE 65 +#define KEY_HASH_MAX 32 +#define RSA_DIGEST_LEN KEY_HASH_MAX + +#define RSA_PUB_D_SIZE 384 +#define RSA_PRIV_ORIG_LEN 193 +#define RSA_PUB_E_SIZE 3 + +#define TA_LOAD_PERM_ALLOW 1 +#define TA_LOAD_PERM_DENY 0 + +#define UINT32_MAX_VALUE 0xFFFFFFFF + +typedef enum { + IMG_TYPE_APP = 1, + IMG_TYPE_LIB = 2, + IMG_TYPE_DYNAMIC_DRV = 3, + IMG_TYPE_CRYPTO_DRV = 4, + IMG_TYPE_DYNAMIC_SRV = 5, + IMG_TYPE_DYNAMIC_CLIENT = 6, + IMG_TYPE_MAX = 7, +} tee_img_type_t; + +enum { + HARDWARE_ENGINE_CRYPTO = 1, + HARDWARE_ENGINE_MAX, +}; + +/* Version 1, 2 have the same image head */ +typedef struct { + uint32_t context_len; /* manifest_crypto_len + cipher_bin_len */ + uint32_t manifest_crypto_len; /* manifest crypto len */ + uint32_t manifest_plain_len; /* manfiest extension + manifest binary */ + uint32_t manifest_str_len; /* manifest extension len */ + uint32_t cipher_bin_len; + uint32_t sign_len; /* sign file len, now rsa 2048 this len is 256 */ +} teec_image_head; + +typedef struct { + uint32_t magic_num1; + uint16_t magic_num2; + uint16_t version_num; +} teec_image_identity; + +typedef struct { + teec_image_head img_hd; +} teec_ta_head_v1; + +/* V2 & V3 have the same TA HEADER */ +typedef struct { + teec_image_identity img_identity; + teec_image_head img_hd; + uint8_t reserved[16]; // Reserve 16 bytes for further extension +} teec_ta_head_v2; + +typedef struct { + int32_t single_instance; + int32_t multi_session; + int32_t multi_command; + uint32_t heap_size; + uint32_t stack_size; + int32_t instance_keep_alive; +} ta_property_t; + +typedef struct { + ta_property_t ta_property; + uint32_t elf_hash_len; + uint32_t elf_cryptkey_len; + uint32_t service_name_len; +} manifest_info_t; + +typedef struct { + uint16_t distribution; + uint16_t api_level; + uint16_t sdk_version; + bool is_lib; + bool ssa_enum_enable; + bool mem_page_align; + bool sys_verify_ta; + uint16_t target_type; + uint16_t target_version; + uint16_t hardware_type; + bool is_need_release_ta_res; + bool crash_callback; + bool is_need_create_msg; + bool is_need_release_msg; +} manifest_extension_t; + +typedef struct { + TEE_UUID srv_uuid; + manifest_info_t mani_info; + int8_t *hash_val; + int8_t *key_val; + int8_t *service_name; + manifest_extension_t ext; +} manifest_t; + +typedef struct { + manifest_t manifest; /* save manifest info */ + int8_t *manifest_buf; /* use malloc, save manifest extension */ + int8_t *img_buf; /* use rtosck mem, save image */ + uint32_t img_offset; + uint32_t img_size; + uint32_t img_version; + bool dyn_conf_registed; /* using for dyn perm */ +} load_img_info; + +typedef struct { + uint32_t key_size; + uint32_t iv_size; + uint32_t signature_alg; +} ta_cipher_hdr_t; + +typedef struct { + ta_cipher_hdr_t cipher_hdr; + uint8_t *key; + uint8_t *iv; +} ta_cipher_layer_t; + +typedef struct { + uint32_t format_version; + uint32_t mani_info_size; + uint32_t mani_ext_size; + uint32_t ta_elf_size; + uint32_t ta_conf_size; +} ta_payload_hdr_t; + +typedef struct { + ta_payload_hdr_t payload_hdr; + uint8_t *ta_elf; + uint8_t *ta_conf; + bool conf_registed; +} ta_payload_layer_t; + +typedef struct { + teec_image_identity img_identity; + uint32_t context_len; + uint32_t ta_key_version; +} ta_image_hdr_v3_t; + +#define MAX_HEADER_SIZE 0x400 +#define MANIFEST_RESERVE_SIZE 128 + +typedef struct { + uint32_t img_version; + uint32_t identity_len; + uint32_t header_len; + uint32_t image_len; + uint32_t total_len; + TEE_UUID srv_uuid; + int8_t *service_name; + uint32_t service_name_len; + int32_t multi_instance; + int32_t multi_session; + int32_t multi_command; + uint32_t heap_size; + uint32_t stack_size; + int32_t instance_keep_alive; + uint8_t *manifest_buf; + uint8_t manifest_str_len; + int8_t *img_buf; + uint32_t img_buf_len; + uint32_t img_buf_offset; +} teec_image_info; + +enum cipher_layer_len_ver { + CIPHER_LAYER_LEN_256 = 256, + CIPHER_LAYER_LEN_384 = 384, +}; + +enum cipher_layer_key_ver { + CIPHER_LAYER_KEY_V1 = 1, /* 2048 bits key, default is also 2048 bits */ + CIPHER_LAYER_KEY_V2 = 2, /* 3072 bits key */ +}; + +typedef struct { + int8_t *ptr_manifest_buf; + int8_t *ptr_ta_elf; + int8_t *img_buf; + uint32_t img_offset; + uint32_t img_size; + uint32_t img_version; + int32_t img_fp; /* fp here means a special fd */ + uint32_t aligned_img_size; + char tmp_file_name[MAX_TAFS_NAME_LEN]; + bool tmp_file_exist; +} elf_image_info; + +#endif diff --git a/lib/syslib/libelf_verify/include/tee_elf_verify.h b/lib/syslib/libelf_verify/include/tee_elf_verify.h index 86efbf36..267de098 100644 --- a/lib/syslib/libelf_verify/include/tee_elf_verify.h +++ b/lib/syslib/libelf_verify/include/tee_elf_verify.h @@ -1,45 +1,50 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: tee app image load service head file - * Author: yuanhao34@huawei.com - * Create: 2021.7.1 - */ -#ifndef TEE_ELF_VERIFY_H -#define TEE_ELF_VERIFY_H - -#include -#include "tee_defines.h" -#include "ta_framework.h" - -typedef struct { - uint32_t version; - uint32_t img_size; - char tmp_file[MAX_TAFS_NAME_LEN]; -} __attribute__((__packed__)) elf_verify_req; - -typedef struct { - char service_name[SERVICE_NAME_MAX_IN_MANIFEST]; - uint32_t service_name_len; - TEE_UUID srv_uuid; - manifest_extension_t mani_ext; - ta_property_t ta_property; - ta_payload_hdr_t payload_hdr; - int32_t off_manifest_buf; - int32_t off_ta_elf; - TEE_Result verify_result; - bool conf_registed; - bool dyn_conf_registed; -} elf_verify_reply; - -typedef struct { - uint8_t *elf_hash; - uint32_t hash_size; -} elf_hash_data; -#define MAX_IMAGE_HASH_SIZE 64 - -TEE_Result secure_elf_verify(const elf_verify_req *req, elf_verify_reply *rep); - -TEE_Result tee_secure_img_parse_manifest_v3(const uint8_t *manifest_ext, uint32_t *ext_size, - bool control, const uint32_t config_target_type); - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef TEE_ELF_VERIFY_H +#define TEE_ELF_VERIFY_H + +#include +#include "tee_defines.h" +#include "ta_framework.h" + +typedef struct { + uint32_t version; + uint32_t img_size; + char tmp_file[MAX_TAFS_NAME_LEN]; +} __attribute__((__packed__)) elf_verify_req; + +typedef struct { + char service_name[SERVICE_NAME_MAX_IN_MANIFEST]; + uint32_t service_name_len; + TEE_UUID srv_uuid; + manifest_extension_t mani_ext; + ta_property_t ta_property; + ta_payload_hdr_t payload_hdr; + int32_t off_manifest_buf; + int32_t off_ta_elf; + TEE_Result verify_result; + bool conf_registed; + bool dyn_conf_registed; +} elf_verify_reply; + +typedef struct { + uint8_t *elf_hash; + uint32_t hash_size; +} elf_hash_data; +#define MAX_IMAGE_HASH_SIZE 64 + +TEE_Result secure_elf_verify(const elf_verify_req *req, elf_verify_reply *rep); + +TEE_Result tee_secure_img_parse_manifest_v3(const uint8_t *manifest_ext, uint32_t *ext_size, + bool control, const uint32_t config_target_type); + +#endif diff --git a/lib/syslib/libelf_verify/include/tee_load_ext_mf.h b/lib/syslib/libelf_verify/include/tee_load_ext_mf.h index 92589625..fb5124ae 100644 --- a/lib/syslib/libelf_verify/include/tee_load_ext_mf.h +++ b/lib/syslib/libelf_verify/include/tee_load_ext_mf.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: Tee-load-extension-manifest function declaration. - * Author: yuanhao34@huawei.com - * Create: 2021-7-7 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TEE_LOAD_EXT_MF_H #define GTASK_TEE_LOAD_EXT_MF_H diff --git a/lib/syslib/libelf_verify/include/tee_load_key_ops.h b/lib/syslib/libelf_verify/include/tee_load_key_ops.h index 97bf727c..f201265e 100644 --- a/lib/syslib/libelf_verify/include/tee_load_key_ops.h +++ b/lib/syslib/libelf_verify/include/tee_load_key_ops.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: Tee-load-extension-manifest function declaration. - * Author: yuanhao34@huawei.com - * Create: 2021-7-7 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TEE_LOAD_KEYOPS_H #define GTASK_TEE_LOAD_KEYOPS_H diff --git a/lib/syslib/libelf_verify/src/tee_cms_signature.h b/lib/syslib/libelf_verify/src/tee_cms_signature.h index 729fb5c1..26f7c46f 100644 --- a/lib/syslib/libelf_verify/src/tee_cms_signature.h +++ b/lib/syslib/libelf_verify/src/tee_cms_signature.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app image load service head file - * Create: 2022.04.15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_CMS_SIGNATURE_H #define TEE_CMS_SIGNATURE_H diff --git a/lib/syslib/libelf_verify/src/tee_comm_elf_verify.c b/lib/syslib/libelf_verify/src/tee_comm_elf_verify.c index 90a2d0a1..69a8e5cb 100644 --- a/lib/syslib/libelf_verify/src/tee_comm_elf_verify.c +++ b/lib/syslib/libelf_verify/src/tee_comm_elf_verify.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app image load service head file - * Create: 2022.04.15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_comm_elf_verify.h" #include "tee_log.h" diff --git a/lib/syslib/libelf_verify/src/tee_comm_elf_verify.h b/lib/syslib/libelf_verify/src/tee_comm_elf_verify.h index b4c408bf..e31d9c20 100644 --- a/lib/syslib/libelf_verify/src/tee_comm_elf_verify.h +++ b/lib/syslib/libelf_verify/src/tee_comm_elf_verify.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app image load service head file - * Create: 2022.04.15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_COMM_ELF_VERIFY_H #define TEE_COMM_ELF_VERIFY_H diff --git a/lib/syslib/libelf_verify/src/tee_elf_verify.c b/lib/syslib/libelf_verify/src/tee_elf_verify.c index 9f8ec286..606d5c79 100644 --- a/lib/syslib/libelf_verify/src/tee_elf_verify.c +++ b/lib/syslib/libelf_verify/src/tee_elf_verify.c @@ -1,383 +1,382 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: tee app image load service head file - * Author: yuanhao34@huawei.com - * Create: 2021.7.1 - */ -#include "tee_elf_verify.h" -#include -#include -#include "tee_elf_verify.h" -#include "tee_mem_mgmt_api.h" -#include "mem_ops_ext.h" -#include "tamgr_ext.h" -#include "tee_inner_uuid.h" -#include "tee_log.h" -#include "tee_crypto_api.h" -#include "securec.h" -#include "permission_service.h" -#include "tee_crypto_hal.h" -#include "tee_load_ext_mf.h" -#include "ta_verify_key.h" -#include "tee_elf_verify_openssl.h" -#include "tee_perm_img.h" -#include "tee_comm_elf_verify.h" -#include "tee_v3_elf_verify.h" -#include "tee_elf_verify_inner.h" - -/* - * use g_img_info&g_image_hd save the infomation - * when loading the image - */ -static load_img_info g_img_info = { { { 0 }, { 0 }, NULL, NULL, NULL, { 0 } }, - NULL, NULL, 0, 0, 0, false }; -static ta_property_t *g_ta_property_ptr = NULL; - -static ta_payload_layer_t g_ta_payload = { { 0 }, NULL, NULL, 0 }; -static uint32_t g_img_size = 0; - -ta_property_t *get_ta_property_ptr(void) -{ - return g_ta_property_ptr; -} - -load_img_info *get_img_info(void) -{ - return &g_img_info; -} - -ta_payload_layer_t *get_ta_payload(void) -{ - return &g_ta_payload; -} - -uint32_t get_img_size(void) -{ - return g_img_size; -} - -bool overflow_check(uint32_t a, uint32_t b) -{ - if (a > UINT32_MAX_VALUE - b) - return true; - return false; -} - -void copy_hash_data(elf_hash_data *hash_data, uint8_t *hash_src, uint32_t hash_src_size) -{ - if (hash_data == NULL || hash_src == NULL) - return; - - if (hash_data != NULL && hash_data->hash_size >= MAX_IMAGE_HASH_SIZE) { - if (memcpy_s(hash_data->elf_hash, hash_data->hash_size, hash_src, hash_src_size) != 0) { - tloge("copy hash data fail\n"); - hash_data->hash_size = 0; - return; - } - hash_data->hash_size = hash_src_size; - } -} - -bool boundary_check(uint32_t max_size, uint32_t input_size) -{ - if (input_size > max_size) { - tloge("Failed to pass boundary check, max: 0x%x, size: 0x%x\n", max_size, input_size); - return true; - } - return false; -} - -TEE_Result tee_secure_img_duplicate_buff(const uint8_t *src, uint32_t src_size, uint8_t **dst) -{ - if (src == NULL || dst == NULL || src_size == 0) - return TEE_ERROR_BAD_PARAMETERS; - - *dst = TEE_Malloc(src_size, 0); - if (*dst == NULL) { - tloge(" Failed to malloc buffer for dst\n"); - return TEE_ERROR_OUT_OF_MEMORY; - } - - errno_t rc = memcpy_s(*dst, src_size, src, src_size); - if (rc != EOK) { - tloge(" Failed to copy from src to dst\n"); - TEE_Free(*dst); - *dst = NULL; - return TEE_ERROR_SECURITY; - } - - return TEE_SUCCESS; -} - -TEE_Result tee_secure_img_manifest_extention_process(const uint8_t *extension, uint32_t extension_size, - manifest_extension_t *mani_ext, struct dyn_conf_t *dyn_conf) -{ - if (extension_size == 0) - return TEE_SUCCESS; - if (extension == NULL) - return TEE_ERROR_BAD_PARAMETERS; - - g_img_info.manifest_buf = (int8_t *)extension; - TEE_Result ret = tee_secure_img_parse_manifest_extension((char *)g_img_info.manifest_buf, - extension_size, mani_ext, dyn_conf); - if (ret != TEE_SUCCESS) { - tloge("Failed to parse manifest extension\n"); - return ret; - } - - return TEE_SUCCESS; -} - -/* - * 1.process_header func's TA header format is inconsistent in v1 & v2 - * 2.others funcs v1 & v2 is the same, so process_header is not in the struct - */ -static const struct process_version g_process_header[] = { -#ifdef DYN_TA_SUPPORT_V3 - { CIPHER_LAYER_VERSION, free_verify_v3, secure_img_copy_rsp_v3, tee_secure_img_unpack_v3, 0, 0 }, -#endif -}; - -static TEE_Result process_header(const uint8_t *share_buf, uint32_t buf_len, uint32_t img_version) -{ - TEE_Result ret = TEE_SUCCESS; - - switch (img_version) { -#ifdef DYN_TA_SUPPORT_V3 - case CIPHER_LAYER_VERSION: - ret = process_header_v3(share_buf, buf_len); - break; -#endif - default: - tloge("Unknown image version error\n"); - return TEE_ERROR_NOT_SUPPORTED; - } - if (ret != TEE_SUCCESS) - tloge("process header failed, ret=0x%x, img version=%u\n", ret, img_version); - - return ret; -} - -static TEE_Result secure_img_load_unpack(const elf_verify_req *req, - elf_hash_data *hash_data) -{ - TEE_Result ret; - int32_t fp = -1; - - (void)hash_data; - fp = open(req->tmp_file, O_RDWR, RWRIGHT, (uint64_t)0); - if (fp < 0) { - tloge("reopen file fail\n"); - goto unpack_error; - } - - void *file_buf = (int8_t *)vfs_mmap(fp, g_img_size, 0); - if (file_buf == NULL) { - tloge("remap fail, size %u\n", (uint32_t)g_img_size); - goto unpack_error; - } - - close(fp); - fp = -1; - - g_img_info.img_buf = (int8_t *)file_buf; - g_img_info.img_offset = 0; - g_img_info.img_size = req->img_size; - - ret = process_header((const uint8_t *)g_img_info.img_buf, g_img_info.img_size, g_img_info.img_version); - if (ret != TEE_SUCCESS) - return ret; - - for (uint32_t i = 0; i < ARRAY_SIZE(g_process_header); ++i) { - if (g_process_header[i].tee_secure_img_unpack != NULL && - g_img_info.img_version == g_process_header[i].version) { - ret = g_process_header[i].tee_secure_img_unpack(g_process_header[i].rsa_algo_len, - g_process_header[i].ta_hd_len, (uint8_t *)(g_img_info.img_buf), - g_img_info.img_size, hash_data); - if (ret != TEE_SUCCESS) - tloge("process header failed, ret=0x%x, img version=%u\n", ret, g_img_info.img_version); - - return ret; - } - } - -unpack_error: - if (fp >= 0) - close(fp); - return TEE_ERROR_BAD_PARAMETERS; -} - -static TEE_Result unpack_copy_check_params(const elf_verify_req *req) -{ - g_img_info.img_version = req->version; - g_img_size = PAGE_ALIGN_UP(req->img_size + ADDITIONAL_BUF_SIZE); - if (g_img_size < req->img_size) - return TEE_ERROR_BAD_PARAMETERS; /* overflow_check */ - - uint32_t filename_len = strnlen(req->tmp_file, MAX_TAFS_NAME_LEN); - if (filename_len == 0 || filename_len >= MAX_TAFS_NAME_LEN) - return TEE_ERROR_BAD_PARAMETERS; - - return TEE_SUCCESS; -} - -static TEE_Result free_verify(void) -{ - for (uint32_t i = 0; i < ARRAY_SIZE(g_process_header); ++i) { - if (g_process_header[i].tee_free_func != NULL && g_img_info.img_version == g_process_header[i].version) { - g_process_header[i].tee_free_func(); - return TEE_SUCCESS; - } - } - - tloge("Unsupported ver: %d\n", g_img_info.img_version); - return TEE_ERROR_BAD_PARAMETERS; -} - -static TEE_Result secure_img_copy_rsp(elf_verify_reply *rep) -{ - rep->conf_registed = g_ta_payload.conf_registed; - - for (uint32_t i = 0; i < ARRAY_SIZE(g_process_header); ++i) { - if (g_process_header[i].img_copy_rsp != NULL && g_img_info.img_version == g_process_header[i].version) { - TEE_Result ret = g_process_header[i].img_copy_rsp(rep); - if (ret != TEE_SUCCESS) - tloge("process header failed, ret=0x%x, img version=%u\n", ret, g_img_info.img_version); - - return ret; - } - } - tloge("Unsupported vers: %d\n", g_img_info.img_version); - return TEE_ERROR_BAD_PARAMETERS; -} - -#define HEX_BYTE_STR_LEN 2 -#define UUID_STR_FORMAT_LEN 37 - -static TEE_Result get_uuid_str(const TEE_UUID *uuid, char *buff, uint32_t len) -{ - if (uuid == NULL || buff == NULL || len < UUID_STR_FORMAT_LEN) { - tloge("invalid parameter\n"); - return TEE_ERROR_GENERIC; - } - - int ret = snprintf_s(buff, len, UUID_STR_FORMAT_LEN - 1, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion, uuid->clockSeqAndNode[0], - uuid->clockSeqAndNode[1], uuid->clockSeqAndNode[2], uuid->clockSeqAndNode[3], - uuid->clockSeqAndNode[4], uuid->clockSeqAndNode[5], uuid->clockSeqAndNode[6], - uuid->clockSeqAndNode[7]); // refer uuid format definitions - if (ret <= 0) { - tloge("convert uuid to string failed\n"); - return TEE_ERROR_GENERIC; - } - return TEE_SUCCESS; -} - -static void print_uuid_and_hash(TEE_UUID *uuid, uint8_t *hash_data, size_t size) -{ - if (uuid == NULL || hash_data == NULL || size > MAX_IMAGE_HASH_SIZE) { - tloge("bad params of print_uuid_hash\n"); - return; - } - size_t str_buffer_len = size * HEX_BYTE_STR_LEN + 1; - char *str_buffer = NULL; - char *str_uuid = NULL; - TEE_Result ret; - str_buffer = (char*)TEE_Malloc(str_buffer_len, 0); - if (str_buffer == NULL) { - tloge("out of mem\n"); - goto clear; - } - str_uuid = (char*)TEE_Malloc(UUID_STR_FORMAT_LEN, 0); - if (str_uuid == NULL) { - tloge("out of mem\n"); - goto clear; - } - - ret = get_uuid_str(uuid, str_uuid, UUID_STR_FORMAT_LEN); - if (ret != TEE_SUCCESS) { - tloge("get_uuid_str failed\n"); - goto clear; - } - - str_buffer[0] = '\0'; - /* the initial len value makes sure the first loop can run normally */ - int len = 1; - for (uint32_t i = 0; i < size; i++) { - if (len <= 0 || str_buffer_len - strlen(str_buffer) <= 1) { - tloge("str_buffer is too short for hash data left\n"); - goto clear; - } - len = snprintf_s(str_buffer + strlen(str_buffer), str_buffer_len - strlen(str_buffer), - str_buffer_len - strlen(str_buffer) - 1, "%02x", hash_data[i]); - } - if (len <= 0) { - tloge("write hash data failed\n"); - goto clear; - } - /* make sure the string buffer has a '\0' */ - str_buffer[str_buffer_len - 1] = '\0'; - tlogi("[TA_UUID]%s[TA_UUID];[IMAGE_HASH]%s[IMAGE_HASH]\n", str_uuid, str_buffer); -clear: - if (str_uuid != NULL) - TEE_Free(str_uuid); - if (str_buffer != NULL) - TEE_Free(str_buffer); -} - -TEE_Result secure_elf_verify(const elf_verify_req *req, elf_verify_reply *rep) -{ - TEE_Result ret, tee_ret; - elf_hash_data hash_data; - (void)memset_s(&hash_data, sizeof(hash_data), 0, sizeof(hash_data)); - - if (req == NULL || rep == NULL) { - tloge("bad parameter\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - if (unpack_copy_check_params(req) != TEE_SUCCESS) { - tloge("check req params failed\n"); - ret = TEE_ERROR_BAD_PARAMETERS; - goto reply; - } - g_ta_property_ptr = &(g_img_info.manifest.mani_info.ta_property); - - hash_data.elf_hash = (uint8_t*)TEE_Malloc(MAX_IMAGE_HASH_SIZE, 0); - hash_data.hash_size = MAX_IMAGE_HASH_SIZE; - if (hash_data.elf_hash == NULL) { - hash_data.hash_size = 0; - tloge("malloc for hash data failed!\n"); - } - - ret = secure_img_load_unpack(req, &hash_data); - if (ret != TEE_SUCCESS) { - tloge("img unpack fail 0x%x\n", ret); - if (g_img_info.dyn_conf_registed || g_ta_payload.conf_registed) - (void)secure_img_copy_rsp(rep); - goto reply; - } - - ret = secure_img_copy_rsp(rep); - if (ret != TEE_SUCCESS) - tloge("copy elf verify response failed 0x%x\n", ret); - if (hash_data.hash_size != 0 && rep != NULL) - print_uuid_and_hash(&(rep->srv_uuid), hash_data.elf_hash, hash_data.hash_size); - -reply: - tee_ret = free_verify(); - if (hash_data.elf_hash != NULL) - TEE_Free(hash_data.elf_hash); - if (tee_ret != TEE_SUCCESS) - tlogd("free verify fail\n"); - - if (ret != TEE_SUCCESS) - return ret; - - return tee_ret; -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include "tee_elf_verify.h" +#include +#include +#include "tee_elf_verify.h" +#include "tee_mem_mgmt_api.h" +#include "mem_ops_ext.h" +#include "tamgr_ext.h" +#include "tee_inner_uuid.h" +#include "tee_log.h" +#include "tee_crypto_api.h" +#include "securec.h" +#include "permission_service.h" +#include "tee_crypto_hal.h" +#include "tee_load_ext_mf.h" +#include "ta_verify_key.h" +#include "tee_elf_verify_openssl.h" +#include "tee_perm_img.h" +#include "tee_comm_elf_verify.h" +#include "tee_v3_elf_verify.h" +#include "tee_elf_verify_inner.h" + +/* + * use g_img_info&g_image_hd save the infomation + * when loading the image + */ +static load_img_info g_img_info = { { { 0 }, { 0 }, NULL, NULL, NULL, { 0 } }, + NULL, NULL, 0, 0, 0, false }; +static ta_property_t *g_ta_property_ptr = NULL; + +static ta_payload_layer_t g_ta_payload = { { 0 }, NULL, NULL, 0 }; +static uint32_t g_img_size = 0; + +ta_property_t *get_ta_property_ptr(void) +{ + return g_ta_property_ptr; +} + +load_img_info *get_img_info(void) +{ + return &g_img_info; +} + +ta_payload_layer_t *get_ta_payload(void) +{ + return &g_ta_payload; +} + +uint32_t get_img_size(void) +{ + return g_img_size; +} + +bool overflow_check(uint32_t a, uint32_t b) +{ + if (a > UINT32_MAX_VALUE - b) + return true; + return false; +} + +void copy_hash_data(elf_hash_data *hash_data, uint8_t *hash_src, uint32_t hash_src_size) +{ + if (hash_data == NULL || hash_src == NULL) + return; + + if (hash_data != NULL && hash_data->hash_size >= MAX_IMAGE_HASH_SIZE) { + if (memcpy_s(hash_data->elf_hash, hash_data->hash_size, hash_src, hash_src_size) != 0) { + tloge("copy hash data fail\n"); + hash_data->hash_size = 0; + return; + } + hash_data->hash_size = hash_src_size; + } +} + +bool boundary_check(uint32_t max_size, uint32_t input_size) +{ + if (input_size > max_size) { + tloge("Failed to pass boundary check, max: 0x%x, size: 0x%x\n", max_size, input_size); + return true; + } + return false; +} + +TEE_Result tee_secure_img_duplicate_buff(const uint8_t *src, uint32_t src_size, uint8_t **dst) +{ + if (src == NULL || dst == NULL || src_size == 0) + return TEE_ERROR_BAD_PARAMETERS; + + *dst = TEE_Malloc(src_size, 0); + if (*dst == NULL) { + tloge(" Failed to malloc buffer for dst\n"); + return TEE_ERROR_OUT_OF_MEMORY; + } + + errno_t rc = memcpy_s(*dst, src_size, src, src_size); + if (rc != EOK) { + tloge(" Failed to copy from src to dst\n"); + TEE_Free(*dst); + *dst = NULL; + return TEE_ERROR_SECURITY; + } + + return TEE_SUCCESS; +} + +TEE_Result tee_secure_img_manifest_extention_process(const uint8_t *extension, uint32_t extension_size, + manifest_extension_t *mani_ext, struct dyn_conf_t *dyn_conf) +{ + if (extension_size == 0) + return TEE_SUCCESS; + if (extension == NULL) + return TEE_ERROR_BAD_PARAMETERS; + + g_img_info.manifest_buf = (int8_t *)extension; + TEE_Result ret = tee_secure_img_parse_manifest_extension((char *)g_img_info.manifest_buf, + extension_size, mani_ext, dyn_conf); + if (ret != TEE_SUCCESS) { + tloge("Failed to parse manifest extension\n"); + return ret; + } + + return TEE_SUCCESS; +} + +/* + * 1.process_header func's TA header format is inconsistent in v1 & v2 + * 2.others funcs v1 & v2 is the same, so process_header is not in the struct + */ +static const struct process_version g_process_header[] = { +#ifdef DYN_TA_SUPPORT_V3 + { CIPHER_LAYER_VERSION, free_verify_v3, secure_img_copy_rsp_v3, tee_secure_img_unpack_v3, 0, 0 }, +#endif +}; + +static TEE_Result process_header(const uint8_t *share_buf, uint32_t buf_len, uint32_t img_version) +{ + TEE_Result ret = TEE_SUCCESS; + + switch (img_version) { +#ifdef DYN_TA_SUPPORT_V3 + case CIPHER_LAYER_VERSION: + ret = process_header_v3(share_buf, buf_len); + break; +#endif + default: + tloge("Unknown image version error\n"); + return TEE_ERROR_NOT_SUPPORTED; + } + if (ret != TEE_SUCCESS) + tloge("process header failed, ret=0x%x, img version=%u\n", ret, img_version); + + return ret; +} + +static TEE_Result secure_img_load_unpack(const elf_verify_req *req, + elf_hash_data *hash_data) +{ + TEE_Result ret; + int32_t fp = -1; + + (void)hash_data; + fp = open(req->tmp_file, O_RDWR, RWRIGHT, (uint64_t)0); + if (fp < 0) { + tloge("reopen file fail\n"); + goto unpack_error; + } + + void *file_buf = (int8_t *)vfs_mmap(fp, g_img_size, 0); + if (file_buf == NULL) { + tloge("remap fail, size %u\n", (uint32_t)g_img_size); + goto unpack_error; + } + + close(fp); + fp = -1; + + g_img_info.img_buf = (int8_t *)file_buf; + g_img_info.img_offset = 0; + g_img_info.img_size = req->img_size; + + ret = process_header((const uint8_t *)g_img_info.img_buf, g_img_info.img_size, g_img_info.img_version); + if (ret != TEE_SUCCESS) + return ret; + + for (uint32_t i = 0; i < ARRAY_SIZE(g_process_header); ++i) { + if (g_process_header[i].tee_secure_img_unpack != NULL && + g_img_info.img_version == g_process_header[i].version) { + ret = g_process_header[i].tee_secure_img_unpack(g_process_header[i].rsa_algo_len, + g_process_header[i].ta_hd_len, (uint8_t *)(g_img_info.img_buf), + g_img_info.img_size, hash_data); + if (ret != TEE_SUCCESS) + tloge("process header failed, ret=0x%x, img version=%u\n", ret, g_img_info.img_version); + + return ret; + } + } + +unpack_error: + if (fp >= 0) + close(fp); + return TEE_ERROR_BAD_PARAMETERS; +} + +static TEE_Result unpack_copy_check_params(const elf_verify_req *req) +{ + g_img_info.img_version = req->version; + g_img_size = PAGE_ALIGN_UP(req->img_size + ADDITIONAL_BUF_SIZE); + if (g_img_size < req->img_size) + return TEE_ERROR_BAD_PARAMETERS; /* overflow_check */ + + uint32_t filename_len = strnlen(req->tmp_file, MAX_TAFS_NAME_LEN); + if (filename_len == 0 || filename_len >= MAX_TAFS_NAME_LEN) + return TEE_ERROR_BAD_PARAMETERS; + + return TEE_SUCCESS; +} + +static TEE_Result free_verify(void) +{ + for (uint32_t i = 0; i < ARRAY_SIZE(g_process_header); ++i) { + if (g_process_header[i].tee_free_func != NULL && g_img_info.img_version == g_process_header[i].version) { + g_process_header[i].tee_free_func(); + return TEE_SUCCESS; + } + } + + tloge("Unsupported ver: %d\n", g_img_info.img_version); + return TEE_ERROR_BAD_PARAMETERS; +} + +static TEE_Result secure_img_copy_rsp(elf_verify_reply *rep) +{ + rep->conf_registed = g_ta_payload.conf_registed; + + for (uint32_t i = 0; i < ARRAY_SIZE(g_process_header); ++i) { + if (g_process_header[i].img_copy_rsp != NULL && g_img_info.img_version == g_process_header[i].version) { + TEE_Result ret = g_process_header[i].img_copy_rsp(rep); + if (ret != TEE_SUCCESS) + tloge("process header failed, ret=0x%x, img version=%u\n", ret, g_img_info.img_version); + + return ret; + } + } + tloge("Unsupported vers: %d\n", g_img_info.img_version); + return TEE_ERROR_BAD_PARAMETERS; +} + +#define HEX_BYTE_STR_LEN 2 +#define UUID_STR_FORMAT_LEN 37 + +static TEE_Result get_uuid_str(const TEE_UUID *uuid, char *buff, uint32_t len) +{ + if (uuid == NULL || buff == NULL || len < UUID_STR_FORMAT_LEN) { + tloge("invalid parameter\n"); + return TEE_ERROR_GENERIC; + } + + int ret = snprintf_s(buff, len, UUID_STR_FORMAT_LEN - 1, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + uuid->timeLow, uuid->timeMid, uuid->timeHiAndVersion, uuid->clockSeqAndNode[0], + uuid->clockSeqAndNode[1], uuid->clockSeqAndNode[2], uuid->clockSeqAndNode[3], + uuid->clockSeqAndNode[4], uuid->clockSeqAndNode[5], uuid->clockSeqAndNode[6], + uuid->clockSeqAndNode[7]); // refer uuid format definitions + if (ret <= 0) { + tloge("convert uuid to string failed\n"); + return TEE_ERROR_GENERIC; + } + return TEE_SUCCESS; +} + +static void print_uuid_and_hash(TEE_UUID *uuid, uint8_t *hash_data, size_t size) +{ + if (uuid == NULL || hash_data == NULL || size > MAX_IMAGE_HASH_SIZE) { + tloge("bad params of print_uuid_hash\n"); + return; + } + size_t str_buffer_len = size * HEX_BYTE_STR_LEN + 1; + char *str_buffer = NULL; + char *str_uuid = NULL; + TEE_Result ret; + str_buffer = (char*)TEE_Malloc(str_buffer_len, 0); + if (str_buffer == NULL) { + tloge("out of mem\n"); + goto clear; + } + str_uuid = (char*)TEE_Malloc(UUID_STR_FORMAT_LEN, 0); + if (str_uuid == NULL) { + tloge("out of mem\n"); + goto clear; + } + + ret = get_uuid_str(uuid, str_uuid, UUID_STR_FORMAT_LEN); + if (ret != TEE_SUCCESS) { + tloge("get_uuid_str failed\n"); + goto clear; + } + + str_buffer[0] = '\0'; + /* the initial len value makes sure the first loop can run normally */ + int len = 1; + for (uint32_t i = 0; i < size; i++) { + if (len <= 0 || str_buffer_len - strlen(str_buffer) <= 1) { + tloge("str_buffer is too short for hash data left\n"); + goto clear; + } + len = snprintf_s(str_buffer + strlen(str_buffer), str_buffer_len - strlen(str_buffer), + str_buffer_len - strlen(str_buffer) - 1, "%02x", hash_data[i]); + } + if (len <= 0) { + tloge("write hash data failed\n"); + goto clear; + } + /* make sure the string buffer has a '\0' */ + str_buffer[str_buffer_len - 1] = '\0'; + tlogi("[TA_UUID]%s[TA_UUID];[IMAGE_HASH]%s[IMAGE_HASH]\n", str_uuid, str_buffer); +clear: + if (str_uuid != NULL) + TEE_Free(str_uuid); + if (str_buffer != NULL) + TEE_Free(str_buffer); +} + +TEE_Result secure_elf_verify(const elf_verify_req *req, elf_verify_reply *rep) +{ + TEE_Result ret, tee_ret; + elf_hash_data hash_data; + (void)memset_s(&hash_data, sizeof(hash_data), 0, sizeof(hash_data)); + + if (req == NULL || rep == NULL) { + tloge("bad parameter\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + if (unpack_copy_check_params(req) != TEE_SUCCESS) { + tloge("check req params failed\n"); + ret = TEE_ERROR_BAD_PARAMETERS; + goto reply; + } + g_ta_property_ptr = &(g_img_info.manifest.mani_info.ta_property); + + hash_data.elf_hash = (uint8_t*)TEE_Malloc(MAX_IMAGE_HASH_SIZE, 0); + hash_data.hash_size = MAX_IMAGE_HASH_SIZE; + if (hash_data.elf_hash == NULL) { + hash_data.hash_size = 0; + tloge("malloc for hash data failed!\n"); + } + + ret = secure_img_load_unpack(req, &hash_data); + if (ret != TEE_SUCCESS) { + tloge("img unpack fail 0x%x\n", ret); + if (g_img_info.dyn_conf_registed || g_ta_payload.conf_registed) + (void)secure_img_copy_rsp(rep); + goto reply; + } + + ret = secure_img_copy_rsp(rep); + if (ret != TEE_SUCCESS) + tloge("copy elf verify response failed 0x%x\n", ret); + if (hash_data.hash_size != 0 && rep != NULL) + print_uuid_and_hash(&(rep->srv_uuid), hash_data.elf_hash, hash_data.hash_size); + +reply: + tee_ret = free_verify(); + if (hash_data.elf_hash != NULL) + TEE_Free(hash_data.elf_hash); + if (tee_ret != TEE_SUCCESS) + tlogd("free verify fail\n"); + + if (ret != TEE_SUCCESS) + return ret; + + return tee_ret; +} diff --git a/lib/syslib/libelf_verify/src/tee_elf_verify_inner.h b/lib/syslib/libelf_verify/src/tee_elf_verify_inner.h index 6e797bb5..2ea0a6af 100644 --- a/lib/syslib/libelf_verify/src/tee_elf_verify_inner.h +++ b/lib/syslib/libelf_verify/src/tee_elf_verify_inner.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app image load service head file - * Create: 2022.04.15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_ELF_VERIFY_INNER_H #define TEE_ELF_VERIFY_INNER_H diff --git a/lib/syslib/libelf_verify/src/tee_elf_verify_mbedtls.c b/lib/syslib/libelf_verify/src/tee_elf_verify_mbedtls.c index 8ff29520..67467e16 100644 --- a/lib/syslib/libelf_verify/src/tee_elf_verify_mbedtls.c +++ b/lib/syslib/libelf_verify/src/tee_elf_verify_mbedtls.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app support mbedtls - * Create: 2022.04.15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_elf_verify_openssl.h" #include diff --git a/lib/syslib/libelf_verify/src/tee_elf_verify_openssl.c b/lib/syslib/libelf_verify/src/tee_elf_verify_openssl.c index 680287ad..23ce03d1 100644 --- a/lib/syslib/libelf_verify/src/tee_elf_verify_openssl.c +++ b/lib/syslib/libelf_verify/src/tee_elf_verify_openssl.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee support boringssl and openssl - * Create: 2022.04.15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_elf_verify_openssl.h" #include "tee_log.h" diff --git a/lib/syslib/libelf_verify/src/tee_elf_verify_openssl.h b/lib/syslib/libelf_verify/src/tee_elf_verify_openssl.h index 02f753f8..c29ca7e3 100644 --- a/lib/syslib/libelf_verify/src/tee_elf_verify_openssl.h +++ b/lib/syslib/libelf_verify/src/tee_elf_verify_openssl.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app image load service head file - * Create: 2022.04.15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_ELF_VERIFY_OPENSSL_H #define TEE_ELF_VERIFY_OPENSSL_H diff --git a/lib/syslib/libelf_verify/src/tee_load_ext_mf.c b/lib/syslib/libelf_verify/src/tee_load_ext_mf.c index 3c76edc1..982f3a8e 100644 --- a/lib/syslib/libelf_verify/src/tee_load_ext_mf.c +++ b/lib/syslib/libelf_verify/src/tee_load_ext_mf.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: load app ta code - * Author: yuanhao34@huawei.com - * Create: 2021-7-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_load_ext_mf.h" #include diff --git a/lib/syslib/libelf_verify/src/tee_load_key_ops.c b/lib/syslib/libelf_verify/src/tee_load_key_ops.c index 25579aee..038e4994 100644 --- a/lib/syslib/libelf_verify/src/tee_load_key_ops.c +++ b/lib/syslib/libelf_verify/src/tee_load_key_ops.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: load app ta code - * Author: yuanhao34@huawei.com - * Create: 2021-7-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_load_key_ops.h" #include diff --git a/lib/syslib/libelf_verify/src/tee_perm_img.c b/lib/syslib/libelf_verify/src/tee_perm_img.c index 184b9b01..e4371d53 100644 --- a/lib/syslib/libelf_verify/src/tee_perm_img.c +++ b/lib/syslib/libelf_verify/src/tee_perm_img.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app image load service head file - * Create: 2022.04.15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_perm_img.h" #include "handle_config.h" diff --git a/lib/syslib/libelf_verify/src/tee_perm_img.h b/lib/syslib/libelf_verify/src/tee_perm_img.h index 0aa12d6a..223f742e 100644 --- a/lib/syslib/libelf_verify/src/tee_perm_img.h +++ b/lib/syslib/libelf_verify/src/tee_perm_img.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app image load service head file - * Create: 2022.04.15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_PERM_IMG_H #define TEE_PERM_IMG_H diff --git a/lib/syslib/libelf_verify/src/tee_perm_img_stub.c b/lib/syslib/libelf_verify/src/tee_perm_img_stub.c index 0bab1d54..b3c97425 100644 --- a/lib/syslib/libelf_verify/src/tee_perm_img_stub.c +++ b/lib/syslib/libelf_verify/src/tee_perm_img_stub.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app image load service head file - * Create: 2022.04.15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "handle_config.h" #include "tee_log.h" diff --git a/lib/syslib/libelf_verify/src/tee_v3_elf_verify.c b/lib/syslib/libelf_verify/src/tee_v3_elf_verify.c index 6df46cec..0a4f0fc9 100644 --- a/lib/syslib/libelf_verify/src/tee_v3_elf_verify.c +++ b/lib/syslib/libelf_verify/src/tee_v3_elf_verify.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app image load service head file - * Create: 2022.04.15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_v3_elf_verify.h" #include "securec.h" diff --git a/lib/syslib/libelf_verify/src/tee_v3_elf_verify.h b/lib/syslib/libelf_verify/src/tee_v3_elf_verify.h index 3960109a..54178d11 100644 --- a/lib/syslib/libelf_verify/src/tee_v3_elf_verify.h +++ b/lib/syslib/libelf_verify/src/tee_v3_elf_verify.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee app image load service head file - * Create: 2022.04.15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_V3_ELF_VERIFY_H #define TEE_V3_ELF_VERIFY_H diff --git a/lib/syslib/libelf_verify_key/Makefile b/lib/syslib/libelf_verify_key/Makefile index e020946f..839ca76a 100644 --- a/lib/syslib/libelf_verify_key/Makefile +++ b/lib/syslib/libelf_verify_key/Makefile @@ -1,5 +1,12 @@ -# libload_key -# Copyright Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # TARGET is a lib MODULE := libelf_verify_key${TARG}.a diff --git a/lib/syslib/libelf_verify_key/src/check_ta_version.c b/lib/syslib/libelf_verify_key/src/check_ta_version.c index a2d02210..8e975d4c 100644 --- a/lib/syslib/libelf_verify_key/src/check_ta_version.c +++ b/lib/syslib/libelf_verify_key/src/check_ta_version.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: root cert info for checking TA image validation - * Create: 2021-02-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "check_ta_version.h" diff --git a/lib/syslib/libelf_verify_key/src/check_ta_version.h b/lib/syslib/libelf_verify_key/src/check_ta_version.h index 096540d0..1262dcf0 100644 --- a/lib/syslib/libelf_verify_key/src/check_ta_version.h +++ b/lib/syslib/libelf_verify_key/src/check_ta_version.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: ta permission check function defines - * Create: 2021-02-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CHECK_TA_VERSION_H #define CHECK_TA_VERSION_H diff --git a/lib/syslib/libelf_verify_key/src/common/openharmony/ta_key_data.c b/lib/syslib/libelf_verify_key/src/common/openharmony/ta_key_data.c index d8ef588e..56d1f30e 100644 --- a/lib/syslib/libelf_verify_key/src/common/openharmony/ta_key_data.c +++ b/lib/syslib/libelf_verify_key/src/common/openharmony/ta_key_data.c @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: tee key data code - * Author: Li Mingjuan limingjuan@huawei.com - * Create: 2020.06.09 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/syslib/libelf_verify_key/src/common/openharmony/ta_verify_key.c b/lib/syslib/libelf_verify_key/src/common/openharmony/ta_verify_key.c index 401474e7..00e80b39 100644 --- a/lib/syslib/libelf_verify_key/src/common/openharmony/ta_verify_key.c +++ b/lib/syslib/libelf_verify_key/src/common/openharmony/ta_verify_key.c @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: get key for verifying TA's singature - * Author: Wang Lian - * Create: 2022.01.13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ta_verify_key.h" #include "ta_load_key.h" diff --git a/lib/syslib/libelf_verify_key/src/common/ta_load_key.c b/lib/syslib/libelf_verify_key/src/common/ta_load_key.c index ae17006c..3696332f 100644 --- a/lib/syslib/libelf_verify_key/src/common/ta_load_key.c +++ b/lib/syslib/libelf_verify_key/src/common/ta_load_key.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. - * Description: tee load key code - * Create: 2020.03.04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ta_load_key.h" diff --git a/lib/syslib/libelf_verify_key/src/sharemem/ta_key_data.c b/lib/syslib/libelf_verify_key/src/sharemem/ta_key_data.c index 9d5ab6f8..10e3996a 100644 --- a/lib/syslib/libelf_verify_key/src/sharemem/ta_key_data.c +++ b/lib/syslib/libelf_verify_key/src/sharemem/ta_key_data.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: tee key data code - * Create: 2021.08.17 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/syslib/libelf_verify_key/src/sharemem/ta_load_key.c b/lib/syslib/libelf_verify_key/src/sharemem/ta_load_key.c index 349606eb..46688b59 100644 --- a/lib/syslib/libelf_verify_key/src/sharemem/ta_load_key.c +++ b/lib/syslib/libelf_verify_key/src/sharemem/ta_load_key.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. - * Description: tee load key code - * Create: 2020.03.04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ta_load_key.h" diff --git a/lib/syslib/libelf_verify_key/src/sharemem/ta_verify_key.c b/lib/syslib/libelf_verify_key/src/sharemem/ta_verify_key.c index d6c39aba..12812ebd 100644 --- a/lib/syslib/libelf_verify_key/src/sharemem/ta_verify_key.c +++ b/lib/syslib/libelf_verify_key/src/sharemem/ta_verify_key.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: get key for verifying TA's singature - * Create: 2021.08.17 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ta_verify_key.h" #include "ta_load_key.h" diff --git a/lib/syslib/libelf_verify_key/src/ta_load_config.c b/lib/syslib/libelf_verify_key/src/ta_load_config.c index 4d697d09..e76f3bc9 100644 --- a/lib/syslib/libelf_verify_key/src/ta_load_config.c +++ b/lib/syslib/libelf_verify_key/src/ta_load_config.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: ta load config - * Create: 2022-1-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ta_load_config.h" #include diff --git a/lib/syslib/libelf_verify_key/src/ta_load_config.h b/lib/syslib/libelf_verify_key/src/ta_load_config.h index bca17819..97889373 100644 --- a/lib/syslib/libelf_verify_key/src/ta_load_config.h +++ b/lib/syslib/libelf_verify_key/src/ta_load_config.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: ta load config - * Create: 2022-1-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TA_LOAD_CONFIG_H #define TA_LOAD_CONFIG_H diff --git a/lib/syslib/libelf_verify_key/src/ta_load_key.h b/lib/syslib/libelf_verify_key/src/ta_load_key.h index c6168379..c36b3834 100644 --- a/lib/syslib/libelf_verify_key/src/ta_load_key.h +++ b/lib/syslib/libelf_verify_key/src/ta_load_key.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: tee load key head file - * Create: 2020.03.04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TA_LOAD_KEY_H #define GTASK_TA_LOAD_KEY_H diff --git a/lib/syslib/libelf_verify_key/src/ta_verify_key.h b/lib/syslib/libelf_verify_key/src/ta_verify_key.h index 2826dbac..d65902a1 100644 --- a/lib/syslib/libelf_verify_key/src/ta_verify_key.h +++ b/lib/syslib/libelf_verify_key/src/ta_verify_key.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. - * Description: get key for verifying TA's singature header file - * Create: 2020.04.27 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TA_VERIFY_KEY_H #define GTASK_TA_VERIFY_KEY_H diff --git a/lib/syslib/libelf_verify_key/src/ti/ta_key_data.c b/lib/syslib/libelf_verify_key/src/ti/ta_key_data.c index ab6eb0e0..f1cc4fb1 100644 --- a/lib/syslib/libelf_verify_key/src/ti/ta_key_data.c +++ b/lib/syslib/libelf_verify_key/src/ti/ta_key_data.c @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee key data code - * Author: Li Mingjuan limingjuan@huawei.com - * Create: 2022-04-23 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/syslib/libelf_verify_key/src/ti/ta_verify_key.c b/lib/syslib/libelf_verify_key/src/ti/ta_verify_key.c index 3e5a3e3b..68f91bf2 100644 --- a/lib/syslib/libelf_verify_key/src/ti/ta_verify_key.c +++ b/lib/syslib/libelf_verify_key/src/ti/ta_verify_key.c @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: get key for verifying TA's singature - * Author: zhoulele zhoulele1@huawei.com - * Create: 2022-04-23 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ta_verify_key.h" #include diff --git a/lib/syslib/libelf_verify_key/src/ti/wb_key.h b/lib/syslib/libelf_verify_key/src/ti/wb_key.h index bfaf8628..5f65d55d 100644 --- a/lib/syslib/libelf_verify_key/src/ti/wb_key.h +++ b/lib/syslib/libelf_verify_key/src/ti/wb_key.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee wb key type head file - * Author: Li Mingjuan limingjuan@huawei.com - * Create: 2022-04-23 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_WB_KEY_H #define GTASK_WB_KEY_H diff --git a/lib/syslib/libelf_verify_key/src/wb_tool_root_key.c b/lib/syslib/libelf_verify_key/src/wb_tool_root_key.c index 41fe8648..4119af8f 100644 --- a/lib/syslib/libelf_verify_key/src/wb_tool_root_key.c +++ b/lib/syslib/libelf_verify_key/src/wb_tool_root_key.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. - * Description: tee load key code - * Create: 2020.03.04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ta_load_key.h" diff --git a/lib/syslib/libelf_verify_key/src/wb_tool_root_key.h b/lib/syslib/libelf_verify_key/src/wb_tool_root_key.h index 2ad5c495..6843c3cc 100644 --- a/lib/syslib/libelf_verify_key/src/wb_tool_root_key.h +++ b/lib/syslib/libelf_verify_key/src/wb_tool_root_key.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: whitebox tool key head file for 256 bytes root key - * Create: 2020-03-28 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_WB_TOOL_256_ROOT_KEY_H diff --git a/lib/syslib/libspawn_common/Makefile b/lib/syslib/libspawn_common/Makefile index f8e72846..1bbd2b29 100644 --- a/lib/syslib/libspawn_common/Makefile +++ b/lib/syslib/libspawn_common/Makefile @@ -1,5 +1,12 @@ -# libspawn_common compile rule. -# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. MODULE := libspawn_common$(TARG).a diff --git a/lib/syslib/libspawn_common/include/get_elf_info.h b/lib/syslib/libspawn_common/include/get_elf_info.h index d58d6d2a..83879a69 100644 --- a/lib/syslib/libspawn_common/include/get_elf_info.h +++ b/lib/syslib/libspawn_common/include/get_elf_info.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: declare get load elf info - * Create: 2021-07-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBSPAWN_COMMON_INCLUDE_GET_ELF_INFO_H #define LIBSPAWN_COMMON_INCLUDE_GET_ELF_INFO_H diff --git a/lib/syslib/libspawn_common/include/spawn_init.h b/lib/syslib/libspawn_common/include/spawn_init.h index 144c57b1..ee76176e 100644 --- a/lib/syslib/libspawn_common/include/spawn_init.h +++ b/lib/syslib/libspawn_common/include/spawn_init.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: structure and function defined for spawn process - * Create: 2021-07-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBSPAWN_COMMON_INCLUDE_SPAWN_INIT_H diff --git a/lib/syslib/libspawn_common/include/target_type.h b/lib/syslib/libspawn_common/include/target_type.h index 02f71675..d7261159 100644 --- a/lib/syslib/libspawn_common/include/target_type.h +++ b/lib/syslib/libspawn_common/include/target_type.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: structure for target_type defined in manifest.txt - * Create: 2021-07-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBSPAWN_COMMON_INCLUDE_TARGET_TYPE_H diff --git a/lib/syslib/libspawn_common/src/get_elf_info.c b/lib/syslib/libspawn_common/src/get_elf_info.c index 5f4562ae..b362fc44 100644 --- a/lib/syslib/libspawn_common/src/get_elf_info.c +++ b/lib/syslib/libspawn_common/src/get_elf_info.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: function used to get load elf info - * Create: 2021-07-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "get_elf_info.h" #include diff --git a/lib/syslib/libspawn_common/src/spawn_init.c b/lib/syslib/libspawn_common/src/spawn_init.c index 1d163802..92f9c3aa 100644 --- a/lib/syslib/libspawn_common/src/spawn_init.c +++ b/lib/syslib/libspawn_common/src/spawn_init.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: init function used for set spawn environment - * Create: 2021-07-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "spawn_init.h" diff --git a/lib/teelib/libagent/Makefile b/lib/teelib/libagent/Makefile index 382ff946..545c3124 100644 --- a/lib/teelib/libagent/Makefile +++ b/lib/teelib/libagent/Makefile @@ -1,5 +1,12 @@ -# libagent compile rule, modified by y00416812 -# Copyright Huawei Technologies Co., Ltd. 2010-2020. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # Targets MODULE := libagent${TARG}.a diff --git a/lib/teelib/libagent/include/tee_misc.h b/lib/teelib/libagent/include/tee_misc.h index fdc6361d..3e18d7ed 100644 --- a/lib/teelib/libagent/include/tee_misc.h +++ b/lib/teelib/libagent/include/tee_misc.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: misc-agent function declaration. - * Create: 2020-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBAGENT_TEE_MISC_H #define LIBAGENT_TEE_MISC_H diff --git a/lib/teelib/libagent/src/tee_misc.c b/lib/teelib/libagent/src/tee_misc.c index 71a477d5..26de9fa8 100644 --- a/lib/teelib/libagent/src/tee_misc.c +++ b/lib/teelib/libagent/src/tee_misc.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: misc-agent function implement. - * Author: yangjing y00416812 - * Create: 2020-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_misc.h" #include diff --git a/lib/teelib/libagent_base/Makefile b/lib/teelib/libagent_base/Makefile index 340f1655..8cb8bfe5 100644 --- a/lib/teelib/libagent_base/Makefile +++ b/lib/teelib/libagent_base/Makefile @@ -1,5 +1,12 @@ -# libagent_base compile rule, modified by y00416812 -# Copyright Huawei Technologies Co., Ltd. 2010-2020. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # Targets MODULE := libagent_base${TARG}.a diff --git a/lib/teelib/libagent_base/include/tee_agent.h b/lib/teelib/libagent_base/include/tee_agent.h index 83441798..cea84fd6 100644 --- a/lib/teelib/libagent_base/include/tee_agent.h +++ b/lib/teelib/libagent_base/include/tee_agent.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: tee agent function declaration. - * Create: 2020-01-14 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBAGENT_BASE_TEE_AGENT_H #define LIBAGENT_BASE_TEE_AGENT_H diff --git a/lib/teelib/libagent_base/include/tee_secfile_load_agent.h b/lib/teelib/libagent_base/include/tee_secfile_load_agent.h index 3ad0c045..8d6a71f9 100644 --- a/lib/teelib/libagent_base/include/tee_secfile_load_agent.h +++ b/lib/teelib/libagent_base/include/tee_secfile_load_agent.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: Tee-secfile load agent base function declaration. - * Create: 2019-04-04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBAGENT_BASE_SECFILE_LOAD_AGENT_H #define LIBAGENT_BASE_SECFILE_LOAD_AGENT_H diff --git a/lib/teelib/libagent_base/src/tee_agent.c b/lib/teelib/libagent_base/src/tee_agent.c index e359cd2e..70fd4933 100644 --- a/lib/teelib/libagent_base/src/tee_agent.c +++ b/lib/teelib/libagent_base/src/tee_agent.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: tee-agent base function declaration. - * Author: yangjing y00416812 - * Create: 2019-04-04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_agent.h" #include diff --git a/lib/teelib/libcrypto/Makefile b/lib/teelib/libcrypto/Makefile index 823995bd..0b2d3c33 100644 --- a/lib/teelib/libcrypto/Makefile +++ b/lib/teelib/libcrypto/Makefile @@ -1,8 +1,12 @@ -# -# Copyright 2019, Huawei Co. Ltd. -# -# See "HUAWEI_LICENSE" for details. -# +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # Targets MODULE := libcrypto${TARG}.a diff --git a/lib/teelib/libcrypto/include/tee_arith_api.h b/lib/teelib/libcrypto/include/tee_arith_api.h index f1c4fab1..534970c3 100644 --- a/lib/teelib/libcrypto/include/tee_arith_api.h +++ b/lib/teelib/libcrypto/include/tee_arith_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved. - * Create: 2012-01-20 - * Description: tee crypto definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_ARITH_API_H diff --git a/lib/teelib/libcrypto/include/tee_boringssl_err.h b/lib/teelib/libcrypto/include/tee_boringssl_err.h index 1e1b881a..c79dab4e 100644 --- a/lib/teelib/libcrypto/include/tee_boringssl_err.h +++ b/lib/teelib/libcrypto/include/tee_boringssl_err.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Create: 2021-03-09 - * Description: tee crypto boringssl definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_BORINGSSL_ERR_H diff --git a/lib/teelib/libcrypto/include/tee_crypto_api.h b/lib/teelib/libcrypto/include/tee_crypto_api.h index 91c080ca..b3dffa15 100644 --- a/lib/teelib/libcrypto/include/tee_crypto_api.h +++ b/lib/teelib/libcrypto/include/tee_crypto_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Create: 2018-12-13 - * Description: tee crypto definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_CRYPTO_API_H diff --git a/lib/teelib/libcrypto/include/tee_crypto_err.h b/lib/teelib/libcrypto/include/tee_crypto_err.h index a41b488e..3fb5273b 100644 --- a/lib/teelib/libcrypto/include/tee_crypto_err.h +++ b/lib/teelib/libcrypto/include/tee_crypto_err.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Create: 2021-03-09 - * Description: tee crypto err definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_CRYPTO_ERR_H diff --git a/lib/teelib/libcrypto/include/tee_crypto_hal.h b/lib/teelib/libcrypto/include/tee_crypto_hal.h index 6e10aa31..e4e55f74 100755 --- a/lib/teelib/libcrypto/include/tee_crypto_hal.h +++ b/lib/teelib/libcrypto/include/tee_crypto_hal.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Create: 2019-01-20 - * Description: crypto hal info function + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_CRYPTO_HAL_H diff --git a/lib/teelib/libcrypto/include/tee_crypto_signature_verify.h b/lib/teelib/libcrypto/include/tee_crypto_signature_verify.h index 5a29526a..5d4eafb6 100644 --- a/lib/teelib/libcrypto/include/tee_crypto_signature_verify.h +++ b/lib/teelib/libcrypto/include/tee_crypto_signature_verify.h @@ -1,19 +1,25 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved. - * Description: For signature verify - * Create: 2021-07-31 - */ - -#ifndef TEE_CRYPTO_SIGNATURE_VERIFY_H -#define TEE_CRYPTO_SIGNATURE_VERIFY_H - -#include -#include -#include - -uint32_t get_effective_size(const uint8_t *buff, uint32_t len); -TEE_Result tee_secure_img_release_verify(const uint8_t *hash, uint32_t hash_size, const uint8_t *signature, - uint32_t signature_size, RSA *pub_key); -RSA *rsa_build_public_key(const rsa_pub_key_t *pub_key); - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#ifndef TEE_CRYPTO_SIGNATURE_VERIFY_H +#define TEE_CRYPTO_SIGNATURE_VERIFY_H + +#include +#include +#include + +uint32_t get_effective_size(const uint8_t *buff, uint32_t len); +TEE_Result tee_secure_img_release_verify(const uint8_t *hash, uint32_t hash_size, const uint8_t *signature, + uint32_t signature_size, RSA *pub_key); +RSA *rsa_build_public_key(const rsa_pub_key_t *pub_key); + +#endif diff --git a/lib/teelib/libcrypto/include/tee_crypto_signature_verify_mbedtls.h b/lib/teelib/libcrypto/include/tee_crypto_signature_verify_mbedtls.h index 7cd900c3..8e53c0ce 100644 --- a/lib/teelib/libcrypto/include/tee_crypto_signature_verify_mbedtls.h +++ b/lib/teelib/libcrypto/include/tee_crypto_signature_verify_mbedtls.h @@ -1,16 +1,22 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: For signature verify - * Create: 2022-04-14 - */ - -#ifndef TEE_CRYPTO_SIGNATURE_VERIFY_MBEDTLS_H -#define TEE_CRYPTO_SIGNATURE_VERIFY_MBEDTLS_H - -#include -#include - -TEE_Result tee_secure_img_release_verify(const uint8_t *hash, uint32_t hash_size, const uint8_t *signature, - uint32_t signature_size, const rsa_pub_key_t *pub_key); - -#endif +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#ifndef TEE_CRYPTO_SIGNATURE_VERIFY_MBEDTLS_H +#define TEE_CRYPTO_SIGNATURE_VERIFY_MBEDTLS_H + +#include +#include + +TEE_Result tee_secure_img_release_verify(const uint8_t *hash, uint32_t hash_size, const uint8_t *signature, + uint32_t signature_size, const rsa_pub_key_t *pub_key); + +#endif diff --git a/lib/teelib/libcrypto/include/tee_openssl_err.h b/lib/teelib/libcrypto/include/tee_openssl_err.h index e27eff1a..2555afa0 100644 --- a/lib/teelib/libcrypto/include/tee_openssl_err.h +++ b/lib/teelib/libcrypto/include/tee_openssl_err.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Create: 2021-03-09 - * Description: tee crypto err definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_OPENSSL_ERR_H diff --git a/lib/teelib/libcrypto/src/aarch64/tee_crypto_api_asm_a64.S b/lib/teelib/libcrypto/src/aarch64/tee_crypto_api_asm_a64.S index 31f6d132..29bcd85c 100644 --- a/lib/teelib/libcrypto/src/aarch64/tee_crypto_api_asm_a64.S +++ b/lib/teelib/libcrypto/src/aarch64/tee_crypto_api_asm_a64.S @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: GP compatibility implementation - * Author: hujianchao - * Create: 2019-07-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #define API_LEVEL1_1_1 2 #define API_LEVEL1_2 3 diff --git a/lib/teelib/libcrypto/src/arm/tee_crypto_api_asm.S b/lib/teelib/libcrypto/src/arm/tee_crypto_api_asm.S index 2127afa4..6916f678 100755 --- a/lib/teelib/libcrypto/src/arm/tee_crypto_api_asm.S +++ b/lib/teelib/libcrypto/src/arm/tee_crypto_api_asm.S @@ -1,9 +1,14 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: GP compatibility implementation - * Author: hujianchao - * Create: 2019-07-08 - */ + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ #define API_LEVEL1_1_1 2 #define API_LEVEL1_2 3 diff --git a/lib/teelib/libcrypto/src/tee_arith_api.c b/lib/teelib/libcrypto/src/tee_arith_api.c index f8286976..e534b3f5 100755 --- a/lib/teelib/libcrypto/src/tee_arith_api.c +++ b/lib/teelib/libcrypto/src/tee_arith_api.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved. - * Description: Tee arith api implementation file - * Author: Jia Lingyu jialingyu@huawei.com - * Create: 2012-01-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_arith_api.h" #include diff --git a/lib/teelib/libcrypto/src/tee_crypto_api.c b/lib/teelib/libcrypto/src/tee_crypto_api.c index 82ef8a17..d6c59980 100644 --- a/lib/teelib/libcrypto/src/tee_crypto_api.c +++ b/lib/teelib/libcrypto/src/tee_crypto_api.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: tee crypto api implementation - * Author: Jia Lingyu jialingyu@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_crypto_api.h" #include diff --git a/lib/teelib/libcrypto/src/tee_crypto_api_ae.c b/lib/teelib/libcrypto/src/tee_crypto_api_ae.c index af076ad4..83facd01 100755 --- a/lib/teelib/libcrypto/src/tee_crypto_api_ae.c +++ b/lib/teelib/libcrypto/src/tee_crypto_api_ae.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: tee crypto api ae algorithm implementation - * Author: Jia Lingyu jialingyu@huawei.com - * Create: 2020-10-14 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_crypto_api.h" #include diff --git a/lib/teelib/libcrypto/src/tee_crypto_api_asymmetric.c b/lib/teelib/libcrypto/src/tee_crypto_api_asymmetric.c index 004653ab..638b080f 100644 --- a/lib/teelib/libcrypto/src/tee_crypto_api_asymmetric.c +++ b/lib/teelib/libcrypto/src/tee_crypto_api_asymmetric.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: tee crypto api asymmetric algorithm implementation - * Author: Jia Lingyu jialingyu@huawei.com - * Create: 2020-10-14 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_crypto_api.h" #include diff --git a/lib/teelib/libcrypto/src/tee_crypto_api_cipher.c b/lib/teelib/libcrypto/src/tee_crypto_api_cipher.c index b700d56b..09d749b0 100644 --- a/lib/teelib/libcrypto/src/tee_crypto_api_cipher.c +++ b/lib/teelib/libcrypto/src/tee_crypto_api_cipher.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: tee crypto api cipher algorithm implementation - * Author: Jia Lingyu jialingyu@huawei.com - * Create: 2020-10-14 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_crypto_api.h" #include diff --git a/lib/teelib/libcrypto/src/tee_crypto_api_derive_key.c b/lib/teelib/libcrypto/src/tee_crypto_api_derive_key.c index e626e4bf..7e6f9605 100644 --- a/lib/teelib/libcrypto/src/tee_crypto_api_derive_key.c +++ b/lib/teelib/libcrypto/src/tee_crypto_api_derive_key.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: tee crypto api asymmetric algorithm implementation - * Author: Jia Lingyu jialingyu@huawei.com - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_crypto_api.h" diff --git a/lib/teelib/libcrypto/src/tee_crypto_api_hash.c b/lib/teelib/libcrypto/src/tee_crypto_api_hash.c index f7c50a4e..519441fe 100644 --- a/lib/teelib/libcrypto/src/tee_crypto_api_hash.c +++ b/lib/teelib/libcrypto/src/tee_crypto_api_hash.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: tee crypto api hash algorithm implementation - * Author: Jia Lingyu jialingyu@huawei.com - * Create: 2020-10-14 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_crypto_api.h" #include diff --git a/lib/teelib/libcrypto/src/tee_crypto_api_hmac.c b/lib/teelib/libcrypto/src/tee_crypto_api_hmac.c index 080cceb8..2402f708 100644 --- a/lib/teelib/libcrypto/src/tee_crypto_api_hmac.c +++ b/lib/teelib/libcrypto/src/tee_crypto_api_hmac.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: tee crypto api hmac algorithm implementation - * Author: Jia Lingyu jialingyu@huawei.com - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_crypto_api.h" #include diff --git a/lib/teelib/libcrypto/src/tee_crypto_common_hash.c b/lib/teelib/libcrypto/src/tee_crypto_common_hash.c index 5f265283..29141bea 100644 --- a/lib/teelib/libcrypto/src/tee_crypto_common_hash.c +++ b/lib/teelib/libcrypto/src/tee_crypto_common_hash.c @@ -1,13 +1,13 @@ -/* $$$!!Warning: Huawei key information asset. No spread without permission.$$$ */ -/* CODEMARK:G45B5tAhAurX3Fjv5w5YrnvEBsxawGU4sQTa6eXHOFkC1Mfvbai6ssLiuF4skCy23hW+xgyXJaVN -2jIjipr/cpauHINx1FQyMyereaY2ZKz1AEk16KBYT3zrrVcV/zYZa+SM7KtAIjQaXRQOuxkCVCHR -djsuW3qvWZbQ3ZjHygm+9Z7Zon2QkYjMt+j1ajp+5u25sy0tND3u8XRRTFLYIcPN3a00GwLwzcWQ -hFfZjUw=# */ -/* $$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$ */ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee crypto api hash algorithm implementation - * Create: 2022-04-06 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_crypto_common_hash.h" #include diff --git a/lib/teelib/libcrypto/src/tee_crypto_common_hash.h b/lib/teelib/libcrypto/src/tee_crypto_common_hash.h index 21e2c214..ed8a20a0 100644 --- a/lib/teelib/libcrypto/src/tee_crypto_common_hash.h +++ b/lib/teelib/libcrypto/src/tee_crypto_common_hash.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Create: 2022-04-06 - * Description: tee crypto definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_CRYPTO_COMMON_HASH_H diff --git a/lib/teelib/libcrypto/src/tee_crypto_gp_hash.c b/lib/teelib/libcrypto/src/tee_crypto_gp_hash.c index ff31edbe..b4444526 100644 --- a/lib/teelib/libcrypto/src/tee_crypto_gp_hash.c +++ b/lib/teelib/libcrypto/src/tee_crypto_gp_hash.c @@ -1,13 +1,13 @@ -/* $$$!!Warning: Huawei key information asset. No spread without permission.$$$ */ -/* CODEMARK:G45B5tAhAurX3Fjv5w5YrnvEBsxawGU4sQTa6eXHOFkC1Mfvbai6ssLiuF4skCy23hW+xgyXJaVN -2jIjipr/cpauHINx1FQyMyereaY2ZKz1AEk16KBYT3zrrVcV/zYZa+SM7KtAIjQaXRQOuxkCVCHR -djsuW3qvWZbQ3ZjHygm+9Z7Zon2QkYjMt+j1ajp+5u25sy0tND3u8XRRTFLYIcPN3a00GwLwzcWQ -hFfZjUw=# */ -/* $$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$ */ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee crypto api hash algorithm implementation - * Create: 2022-04-06 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_crypto_api.h" #include diff --git a/lib/teelib/libcrypto/src/tee_crypto_gp_hmac.c b/lib/teelib/libcrypto/src/tee_crypto_gp_hmac.c index 11b53887..1938087a 100644 --- a/lib/teelib/libcrypto/src/tee_crypto_gp_hmac.c +++ b/lib/teelib/libcrypto/src/tee_crypto_gp_hmac.c @@ -1,13 +1,13 @@ -/* $$$!!Warning: Huawei key information asset. No spread without permission.$$$ */ -/* CODEMARK:G45B5tAhAurX3Fjv5w5YrnvEBsxawGU4sQTa6eXHOFkC1Mfvbai6ssLiuF4skCy23hW+xgyXJaVN -2jIjipr/cpauHINx1FQyMyereaY2ZKz1AEk16KBYT3zrrVcV/zYZa+SM7KtAIjQaXRQOuxkCVCHR -djsuW3qvWZbQ3ZjHygm+9Z7Zon2QkYjMt+j1ajp+5u25sy0tND3u8XRRTFLYIcPN3a00GwLwzcWQ -hFfZjUw=# */ -/* $$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$ */ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee crypto api hmac algorithm implementation - * Create: 2022-04-06 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_crypto_api.h" #include diff --git a/lib/teelib/libcrypto/src/tee_crypto_hal.c b/lib/teelib/libcrypto/src/tee_crypto_hal.c index 516dbf7e..5d12193b 100644 --- a/lib/teelib/libcrypto/src/tee_crypto_hal.c +++ b/lib/teelib/libcrypto/src/tee_crypto_hal.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: For crypto hal - * Author: Jialingyu j00430229 - * Create: 2019-01-31 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_crypto_hal.h" #include diff --git a/lib/teelib/libcrypto/src/tee_crypto_signature_verify.c b/lib/teelib/libcrypto/src/tee_crypto_signature_verify.c index e1548b5b..19270325 100644 --- a/lib/teelib/libcrypto/src/tee_crypto_signature_verify.c +++ b/lib/teelib/libcrypto/src/tee_crypto_signature_verify.c @@ -1,116 +1,115 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: For signature verify - * Author: yuanhao34@huawei.com - * Create: 2021-07-31 - */ - -#include "tee_crypto_signature_verify.h" -#ifdef OPENSSL_ENABLE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif -#include "ta_lib_img_unpack.h" -#include "tee_log.h" - -uint32_t get_effective_size(const uint8_t *buff, uint32_t len) -{ - if (buff == NULL) - return 0; - - while (len != 0) { - if (buff[len - 1] == 0) - len--; - else - break; - } - return len; -} - -static void free_rsa_bn_n(BIGNUM *bn_n, BIGNUM *bn_e, BIGNUM *bn_d, BIGNUM *bn_p) -{ - BN_free(bn_n); - BN_free(bn_p); - BN_free(bn_e); - BN_free(bn_d); -} - -RSA *rsa_build_public_key(const rsa_pub_key_t *pub_key) -{ - if (pub_key == NULL) - return NULL; - - BIGNUM *bn_n = BN_bin2bn(pub_key->n, get_effective_size(pub_key->n, pub_key->n_len), NULL); - BIGNUM *bn_e = BN_bin2bn(pub_key->e, get_effective_size(pub_key->e, pub_key->e_len), NULL); - if ((bn_n == NULL) || (bn_e == NULL)) { - tloge("Change pub buffer num to big num failed\n"); - free_rsa_bn_n(bn_n, bn_e, NULL, NULL); - return NULL; - } - RSA *rsa_key = RSA_new(); - if (rsa_key == NULL) { - tloge("Malloc memory for rsa key failed\n"); - free_rsa_bn_n(bn_n, bn_e, NULL, NULL); - return NULL; - } - int32_t ret = RSA_set0_key(rsa_key, bn_n, bn_e, NULL); - if (ret != 1) { - tloge("Set rsa key failed\n"); - free_rsa_bn_n(bn_n, bn_e, NULL, NULL); - RSA_free(rsa_key); - return NULL; - } - return rsa_key; -} - -/* Process steps: - * 1, Get public key, - * 2, Verify the signature using the public key, - */ -TEE_Result tee_secure_img_release_verify(const uint8_t *hash, uint32_t hash_size, const uint8_t *signature, - uint32_t signature_size, RSA *pub_key) -{ - bool check = (hash == NULL || signature == NULL || signature_size == 0 || hash_size == 0); - if (check) - return TEE_ERROR_BAD_PARAMETERS; - - if (pub_key == NULL) { - tloge("get public key fail"); - return TEE_ERROR_GENERIC; - } - /* the sign len should equals rsa pub key's n size */ - uint32_t modulus_size = RSA_size(pub_key); - if (signature_size < modulus_size) { - tloge("Invalid signature size: 0x%x\n", signature_size); - RSA_free(pub_key); - pub_key = NULL; - return TEE_ERROR_BAD_PARAMETERS; - } - - int32_t result = RSA_verify(NID_sha256, hash, RSA_DIGEST_LEN, signature, signature_size, pub_key); - RSA_free(pub_key); - pub_key = NULL; - - /* GCC complain about pragma optimize */ - if (result != 1) { - tloge("signature VerifyDigest fail\n"); - return TEE_ERROR_GENERIC; - } - - return TEE_SUCCESS; -} - +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#include "tee_crypto_signature_verify.h" +#ifdef OPENSSL_ENABLE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif +#include "ta_lib_img_unpack.h" +#include "tee_log.h" + +uint32_t get_effective_size(const uint8_t *buff, uint32_t len) +{ + if (buff == NULL) + return 0; + + while (len != 0) { + if (buff[len - 1] == 0) + len--; + else + break; + } + return len; +} + +static void free_rsa_bn_n(BIGNUM *bn_n, BIGNUM *bn_e, BIGNUM *bn_d, BIGNUM *bn_p) +{ + BN_free(bn_n); + BN_free(bn_p); + BN_free(bn_e); + BN_free(bn_d); +} + +RSA *rsa_build_public_key(const rsa_pub_key_t *pub_key) +{ + if (pub_key == NULL) + return NULL; + + BIGNUM *bn_n = BN_bin2bn(pub_key->n, get_effective_size(pub_key->n, pub_key->n_len), NULL); + BIGNUM *bn_e = BN_bin2bn(pub_key->e, get_effective_size(pub_key->e, pub_key->e_len), NULL); + if ((bn_n == NULL) || (bn_e == NULL)) { + tloge("Change pub buffer num to big num failed\n"); + free_rsa_bn_n(bn_n, bn_e, NULL, NULL); + return NULL; + } + RSA *rsa_key = RSA_new(); + if (rsa_key == NULL) { + tloge("Malloc memory for rsa key failed\n"); + free_rsa_bn_n(bn_n, bn_e, NULL, NULL); + return NULL; + } + int32_t ret = RSA_set0_key(rsa_key, bn_n, bn_e, NULL); + if (ret != 1) { + tloge("Set rsa key failed\n"); + free_rsa_bn_n(bn_n, bn_e, NULL, NULL); + RSA_free(rsa_key); + return NULL; + } + return rsa_key; +} + +/* Process steps: + * 1, Get public key, + * 2, Verify the signature using the public key, + */ +TEE_Result tee_secure_img_release_verify(const uint8_t *hash, uint32_t hash_size, const uint8_t *signature, + uint32_t signature_size, RSA *pub_key) +{ + bool check = (hash == NULL || signature == NULL || signature_size == 0 || hash_size == 0); + if (check) + return TEE_ERROR_BAD_PARAMETERS; + + if (pub_key == NULL) { + tloge("get public key fail"); + return TEE_ERROR_GENERIC; + } + /* the sign len should equals rsa pub key's n size */ + uint32_t modulus_size = RSA_size(pub_key); + if (signature_size < modulus_size) { + tloge("Invalid signature size: 0x%x\n", signature_size); + RSA_free(pub_key); + pub_key = NULL; + return TEE_ERROR_BAD_PARAMETERS; + } + + int32_t result = RSA_verify(NID_sha256, hash, RSA_DIGEST_LEN, signature, signature_size, pub_key); + RSA_free(pub_key); + pub_key = NULL; + + /* GCC complain about pragma optimize */ + if (result != 1) { + tloge("signature VerifyDigest fail\n"); + return TEE_ERROR_GENERIC; + } + + return TEE_SUCCESS; +} + diff --git a/lib/teelib/libcrypto/src/tee_operation.c b/lib/teelib/libcrypto/src/tee_operation.c index d5897b8b..dc779e32 100755 --- a/lib/teelib/libcrypto/src/tee_operation.c +++ b/lib/teelib/libcrypto/src/tee_operation.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: tee operation valid implemetion - * Author: gaobo gaobo794@huawei.com - * Create: 2019-10-11 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_operation.h" diff --git a/lib/teelib/libcrypto/src/tee_operation.h b/lib/teelib/libcrypto/src/tee_operation.h index 55e5e60b..07587175 100755 --- a/lib/teelib/libcrypto/src/tee_operation.h +++ b/lib/teelib/libcrypto/src/tee_operation.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: tee operation valid implemetion - * Create: 2019-10-11 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef SRC_TEE_TEE_OPERATION_H diff --git a/lib/teelib/libcrypto_hal/Makefile b/lib/teelib/libcrypto_hal/Makefile index d731cc4f..8077d78d 100644 --- a/lib/teelib/libcrypto_hal/Makefile +++ b/lib/teelib/libcrypto_hal/Makefile @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. MODULE := libcrypto_hal${TARG}.a include $(BUILD_CONFIG)/feature-macro.mk diff --git a/lib/teelib/libcrypto_hal/include/chinadrm.h b/lib/teelib/libcrypto_hal/include/chinadrm.h index d380b374..2d9f3023 100644 --- a/lib/teelib/libcrypto_hal/include/chinadrm.h +++ b/lib/teelib/libcrypto_hal/include/chinadrm.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Create: 2018-12-13 - * Description: Reference of ChinaDRM type definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CHINADRM_SRE_CHINADRM_H #define CHINADRM_SRE_CHINADRM_H diff --git a/lib/teelib/libcrypto_hal/include/crypto_alg_config.h b/lib/teelib/libcrypto_hal/include/crypto_alg_config.h index c9f2708c..499a6f79 100644 --- a/lib/teelib/libcrypto_hal/include/crypto_alg_config.h +++ b/lib/teelib/libcrypto_hal/include/crypto_alg_config.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: algorithm configration - * Create: 2020-06-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_ALG_CONFIG_H #define CRYPTO_ALG_CONFIG_H diff --git a/lib/teelib/libcrypto_hal/include/crypto_default_engine.h b/lib/teelib/libcrypto_hal/include/crypto_default_engine.h index 77616789..f939a75d 100755 --- a/lib/teelib/libcrypto_hal/include/crypto_default_engine.h +++ b/lib/teelib/libcrypto_hal/include/crypto_default_engine.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Crypto API at driver adaptor. - * Create: 2020-04-10 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_DEFAULT_ENGINE_H #define CRYPTO_DEFAULT_ENGINE_H diff --git a/lib/teelib/libcrypto_hal/include/crypto_driver_adaptor.h b/lib/teelib/libcrypto_hal/include/crypto_driver_adaptor.h index 9fd78dd1..4f7f9875 100644 --- a/lib/teelib/libcrypto_hal/include/crypto_driver_adaptor.h +++ b/lib/teelib/libcrypto_hal/include/crypto_driver_adaptor.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Crypto API at driver adaptor. - * Create: 2020-03-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_DRIVER_ADAPTOR_H #define CRYPTO_DRIVER_ADAPTOR_H diff --git a/lib/teelib/libcrypto_hal/include/crypto_hal.h b/lib/teelib/libcrypto_hal/include/crypto_hal.h index 91ff52c8..18dda14f 100644 --- a/lib/teelib/libcrypto_hal/include/crypto_hal.h +++ b/lib/teelib/libcrypto_hal/include/crypto_hal.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Crypto API at driver adaptor. - * Create: 2020-03-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_HAL_H #define CRYPTO_HAL_H diff --git a/lib/teelib/libcrypto_hal/include/crypto_hal_ae.h b/lib/teelib/libcrypto_hal/include/crypto_hal_ae.h index eae9df24..0e6db2da 100644 --- a/lib/teelib/libcrypto_hal/include/crypto_hal_ae.h +++ b/lib/teelib/libcrypto_hal/include/crypto_hal_ae.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: AE Crypto API at driver adaptor. - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_HAL_AE_H #define CRYPTO_HAL_AE_H diff --git a/lib/teelib/libcrypto_hal/include/crypto_hal_cipher.h b/lib/teelib/libcrypto_hal/include/crypto_hal_cipher.h index d71c14c2..9c87fe69 100644 --- a/lib/teelib/libcrypto_hal/include/crypto_hal_cipher.h +++ b/lib/teelib/libcrypto_hal/include/crypto_hal_cipher.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Cipher Crypto API at driver adaptor. - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_HAL_CIPHER_H #define CRYPTO_HAL_CIPHER_H diff --git a/lib/teelib/libcrypto_hal/include/crypto_hal_derive_key.h b/lib/teelib/libcrypto_hal/include/crypto_hal_derive_key.h index 2411535f..385d3418 100644 --- a/lib/teelib/libcrypto_hal/include/crypto_hal_derive_key.h +++ b/lib/teelib/libcrypto_hal/include/crypto_hal_derive_key.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Derive key Crypto API at driver adaptor. - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_HAL_DERIVE_KEY_H diff --git a/lib/teelib/libcrypto_hal/include/crypto_hal_ec.h b/lib/teelib/libcrypto_hal/include/crypto_hal_ec.h index 3748aec3..4df58fc8 100644 --- a/lib/teelib/libcrypto_hal/include/crypto_hal_ec.h +++ b/lib/teelib/libcrypto_hal/include/crypto_hal_ec.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: EC Crypto API at driver adaptor. - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_HAL_EC_H_ diff --git a/lib/teelib/libcrypto_hal/include/crypto_hal_hash.h b/lib/teelib/libcrypto_hal/include/crypto_hal_hash.h index 9bb2eb18..443316b7 100644 --- a/lib/teelib/libcrypto_hal/include/crypto_hal_hash.h +++ b/lib/teelib/libcrypto_hal/include/crypto_hal_hash.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Hash Crypto API at driver adaptor. - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_HAL_HASH_H diff --git a/lib/teelib/libcrypto_hal/include/crypto_hal_hmac.h b/lib/teelib/libcrypto_hal/include/crypto_hal_hmac.h index a8b5c6ba..bcbf6b3c 100644 --- a/lib/teelib/libcrypto_hal/include/crypto_hal_hmac.h +++ b/lib/teelib/libcrypto_hal/include/crypto_hal_hmac.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: HMAC Crypto API at driver adaptor. - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_HAL_HMAC_H #define CRYPTO_HAL_HMAC_H diff --git a/lib/teelib/libcrypto_hal/include/crypto_hal_rsa.h b/lib/teelib/libcrypto_hal/include/crypto_hal_rsa.h index 8f42a430..9b5baaae 100644 --- a/lib/teelib/libcrypto_hal/include/crypto_hal_rsa.h +++ b/lib/teelib/libcrypto_hal/include/crypto_hal_rsa.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: RSA Crypto API at driver adaptor. - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_HAL_RSA_H_ diff --git a/lib/teelib/libcrypto_hal/include/crypto_inner_defines.h b/lib/teelib/libcrypto_hal/include/crypto_inner_defines.h index 98625e9d..a1c5fb43 100644 --- a/lib/teelib/libcrypto_hal/include/crypto_inner_defines.h +++ b/lib/teelib/libcrypto_hal/include/crypto_inner_defines.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Crypto structures and macros used internally - * Create: 2020-03-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __CRYPTO_INNER_DEFINES_H_ diff --git a/lib/teelib/libcrypto_hal/include/crypto_manager.h b/lib/teelib/libcrypto_hal/include/crypto_manager.h index b46a6b2a..871d521d 100644 --- a/lib/teelib/libcrypto_hal/include/crypto_manager.h +++ b/lib/teelib/libcrypto_hal/include/crypto_manager.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Crypto API at driver manager. - * Create: 2020-03-25 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_MANAGER_H #define CRYPTO_MANAGER_H diff --git a/lib/teelib/libcrypto_hal/include/soft_ae.h b/lib/teelib/libcrypto_hal/include/soft_ae.h index 2ebc3d1f..569d855c 100644 --- a/lib/teelib/libcrypto_hal/include/soft_ae.h +++ b/lib/teelib/libcrypto_hal/include/soft_ae.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: implament GP API using boringssl - * Create: 2020-06-02 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef _SOFT_AE_H #define _SOFT_AE_H diff --git a/lib/teelib/libcrypto_hal/include/soft_cipher.h b/lib/teelib/libcrypto_hal/include/soft_cipher.h index 2e83364e..2f228aa8 100644 --- a/lib/teelib/libcrypto_hal/include/soft_cipher.h +++ b/lib/teelib/libcrypto_hal/include/soft_cipher.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: soft crypto implementation - * Create: 2020-10-27 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef _SOFT_CIPHER_H #define _SOFT_CIPHER_H diff --git a/lib/teelib/libcrypto_hal/include/soft_common_api.h b/lib/teelib/libcrypto_hal/include/soft_common_api.h index 3cee0558..79541045 100644 --- a/lib/teelib/libcrypto_hal/include/soft_common_api.h +++ b/lib/teelib/libcrypto_hal/include/soft_common_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: implament GP API using boringssl - * Create: 2020-10-27 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef _SOFT_COMMON_API_H #define _SOFT_COMMON_API_H diff --git a/lib/teelib/libcrypto_hal/include/soft_derive_key_api.h b/lib/teelib/libcrypto_hal/include/soft_derive_key_api.h index 99e12078..574a0aec 100644 --- a/lib/teelib/libcrypto_hal/include/soft_derive_key_api.h +++ b/lib/teelib/libcrypto_hal/include/soft_derive_key_api.h @@ -1,8 +1,14 @@ /* -* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. -* Description: implament GP API using boringssl -* Create: 2020-06-02 -*/ + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ #ifndef _SOFT_DERIVE_KEY_API_H #define _SOFT_DERIVE_KEY_API_H diff --git a/lib/teelib/libcrypto_hal/include/soft_ec_api.h b/lib/teelib/libcrypto_hal/include/soft_ec_api.h index 8039e702..fff0145b 100644 --- a/lib/teelib/libcrypto_hal/include/soft_ec_api.h +++ b/lib/teelib/libcrypto_hal/include/soft_ec_api.h @@ -1,8 +1,14 @@ /* -* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. -* Description: implament GP API using boringssl -* Create: 2020-06-02 -*/ + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ #ifndef _SOFT_EC_API_H #define _SOFT_EC_API_H diff --git a/lib/teelib/libcrypto_hal/include/soft_hash.h b/lib/teelib/libcrypto_hal/include/soft_hash.h index 3149c127..a2ea8b8b 100644 --- a/lib/teelib/libcrypto_hal/include/soft_hash.h +++ b/lib/teelib/libcrypto_hal/include/soft_hash.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: soft crypto implementation - * Create: 2020-10-27 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef _SOFT_HASH_H #define _SOFT_HASH_H diff --git a/lib/teelib/libcrypto_hal/include/soft_hmac.h b/lib/teelib/libcrypto_hal/include/soft_hmac.h index e13281ac..6b4b59af 100644 --- a/lib/teelib/libcrypto_hal/include/soft_hmac.h +++ b/lib/teelib/libcrypto_hal/include/soft_hmac.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: soft crypto implementation - * Create: 2020-10-27 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef _SOFT_HMAC_H #define _SOFT_HMAC_H diff --git a/lib/teelib/libcrypto_hal/include/soft_rsa_api.h b/lib/teelib/libcrypto_hal/include/soft_rsa_api.h index 1d6c5abc..cfef73a4 100644 --- a/lib/teelib/libcrypto_hal/include/soft_rsa_api.h +++ b/lib/teelib/libcrypto_hal/include/soft_rsa_api.h @@ -1,8 +1,14 @@ /* -* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. -* Description: implament GP API using boringssl -* Create: 2020-12-22 -*/ + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ #ifndef _SOFT_RSA_API_H #define _SOFT_RSA_API_H diff --git a/lib/teelib/libcrypto_hal/include/tee_gmssl_err.h b/lib/teelib/libcrypto_hal/include/tee_gmssl_err.h index 1c311979..b4ac5e0a 100644 --- a/lib/teelib/libcrypto_hal/include/tee_gmssl_err.h +++ b/lib/teelib/libcrypto_hal/include/tee_gmssl_err.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Create: 2021-03-09 - * Description: tee crypto gmssl err definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_GMSSL_ERR_H diff --git a/lib/teelib/libcrypto_hal/src/boringssl/ae_common.h b/lib/teelib/libcrypto_hal/src/boringssl/ae_common.h index bce9ea96..265da52c 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/ae_common.h +++ b/lib/teelib/libcrypto_hal/src/boringssl/ae_common.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. - * Description: ae common struct - * Author: Yan Ruiqing - * Create: 2020-11-27 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef _AE_COMMON_H #define _AE_COMMON_H diff --git a/lib/teelib/libcrypto_hal/src/boringssl/gmssl_internal.h b/lib/teelib/libcrypto_hal/src/boringssl/gmssl_internal.h index 3771ebf0..31b1d1cc 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/gmssl_internal.h +++ b/lib/teelib/libcrypto_hal/src/boringssl/gmssl_internal.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: tee gmssl api implementation - * Author: Wang Lian - * Create: 2021-10-11 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __GMSSL_INTERNAL_H__ #define __GMSSL_INTERNAL_H__ diff --git a/lib/teelib/libcrypto_hal/src/boringssl/soft_ae.c b/lib/teelib/libcrypto_hal/src/boringssl/soft_ae.c index a28881e2..63e9d90f 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/soft_ae.c +++ b/lib/teelib/libcrypto_hal/src/boringssl/soft_ae.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: implament GP API using boringssl - * Create: 2020-06-02 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "soft_ae.h" diff --git a/lib/teelib/libcrypto_hal/src/boringssl/soft_cipher.c b/lib/teelib/libcrypto_hal/src/boringssl/soft_cipher.c index d44f8c53..361497c6 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/soft_cipher.c +++ b/lib/teelib/libcrypto_hal/src/boringssl/soft_cipher.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: implament GP API using boringssl - * Create: 2020-06-02 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "soft_cipher.h" diff --git a/lib/teelib/libcrypto_hal/src/boringssl/soft_common_api.c b/lib/teelib/libcrypto_hal/src/boringssl/soft_common_api.c index 0c47e98a..8b20484e 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/soft_common_api.c +++ b/lib/teelib/libcrypto_hal/src/boringssl/soft_common_api.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: implament GP API using boringssl - * Create: 2020-06-02 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "soft_common_api.h" diff --git a/lib/teelib/libcrypto_hal/src/boringssl/soft_derive_key_api.c b/lib/teelib/libcrypto_hal/src/boringssl/soft_derive_key_api.c index 329ec52f..ccdcd3fe 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/soft_derive_key_api.c +++ b/lib/teelib/libcrypto_hal/src/boringssl/soft_derive_key_api.c @@ -1,8 +1,14 @@ /* -* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. -* Description: implament GP API using boringssl -* Create: 2020-06-02 -*/ + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ #include "soft_derive_key_api.h" #include diff --git a/lib/teelib/libcrypto_hal/src/boringssl/soft_ec_api.c b/lib/teelib/libcrypto_hal/src/boringssl/soft_ec_api.c index d7e1811e..dc7e4cc7 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/soft_ec_api.c +++ b/lib/teelib/libcrypto_hal/src/boringssl/soft_ec_api.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: implament GP API using boringssl - * Create: 2020-06-02 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "soft_ec_api.h" diff --git a/lib/teelib/libcrypto_hal/src/boringssl/soft_err.c b/lib/teelib/libcrypto_hal/src/boringssl/soft_err.c index c135621f..1b51a1f6 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/soft_err.c +++ b/lib/teelib/libcrypto_hal/src/boringssl/soft_err.c @@ -1,8 +1,14 @@ /* -* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. -* Description: crypto soft engine error code for openssl or boringssl lib -* Create: 2021-03-01 -*/ + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ #include #include #include diff --git a/lib/teelib/libcrypto_hal/src/boringssl/soft_err.h b/lib/teelib/libcrypto_hal/src/boringssl/soft_err.h index f35ff0cd..b0ed20bf 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/soft_err.h +++ b/lib/teelib/libcrypto_hal/src/boringssl/soft_err.h @@ -1,12 +1,18 @@ /* -* Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. -* Description: crypto soft engine error. -* Create: 2021-03-01 -*/ + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ #ifndef SOFT_ERR_H #define SOFT_ERR_H #include int32_t get_soft_crypto_error(int32_t tee_error); -#endif \ No newline at end of file +#endif diff --git a/lib/teelib/libcrypto_hal/src/boringssl/soft_gmssl.c b/lib/teelib/libcrypto_hal/src/boringssl/soft_gmssl.c index 5bd5f4c2..a0523fab 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/soft_gmssl.c +++ b/lib/teelib/libcrypto_hal/src/boringssl/soft_gmssl.c @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved. - * Description: tee gmssl api implementation - * Author: Wang Lian - * Create: 2021-10-11 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "soft_gmssl.h" diff --git a/lib/teelib/libcrypto_hal/src/boringssl/soft_gmssl.h b/lib/teelib/libcrypto_hal/src/boringssl/soft_gmssl.h index 59f352dd..205865f0 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/soft_gmssl.h +++ b/lib/teelib/libcrypto_hal/src/boringssl/soft_gmssl.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved. - * Description: tee gmssl api implementation - * Author: Wang Lian - * Create: 2021-10-11 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __SOFT_GMSSL_H__ #define __SOFT_GMSSL_H__ diff --git a/lib/teelib/libcrypto_hal/src/boringssl/soft_hash.c b/lib/teelib/libcrypto_hal/src/boringssl/soft_hash.c index e6bad7b9..9834ebb4 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/soft_hash.c +++ b/lib/teelib/libcrypto_hal/src/boringssl/soft_hash.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: implament GP API using boringssl - * Create: 2020-06-02 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "soft_hash.h" #include diff --git a/lib/teelib/libcrypto_hal/src/boringssl/soft_hmac.c b/lib/teelib/libcrypto_hal/src/boringssl/soft_hmac.c index 18684094..9f808b97 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/soft_hmac.c +++ b/lib/teelib/libcrypto_hal/src/boringssl/soft_hmac.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: implament GP API using boringssl - * Create: 2020-06-02 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "soft_hmac.h" #include diff --git a/lib/teelib/libcrypto_hal/src/boringssl/soft_rsa_api.c b/lib/teelib/libcrypto_hal/src/boringssl/soft_rsa_api.c index e008bead..7f6f4805 100644 --- a/lib/teelib/libcrypto_hal/src/boringssl/soft_rsa_api.c +++ b/lib/teelib/libcrypto_hal/src/boringssl/soft_rsa_api.c @@ -1,8 +1,14 @@ /* -* Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. -* Description: implament GP API using boringssl -* Create: 2020-12-22 -*/ + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ #include "soft_rsa_api.h" #include diff --git a/lib/teelib/libcrypto_hal/src/crypto_alg_config.c b/lib/teelib/libcrypto_hal/src/crypto_alg_config.c index 933e529d..0ed093b1 100644 --- a/lib/teelib/libcrypto_hal/src/crypto_alg_config.c +++ b/lib/teelib/libcrypto_hal/src/crypto_alg_config.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: algorithm configration - * Create: 2020-06-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_alg_config.h" #include diff --git a/lib/teelib/libcrypto_hal/src/crypto_hal.c b/lib/teelib/libcrypto_hal/src/crypto_hal.c index 53baba32..0d57ffba 100644 --- a/lib/teelib/libcrypto_hal/src/crypto_hal.c +++ b/lib/teelib/libcrypto_hal/src/crypto_hal.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Crypto API at driver adaptor. - * Create: 2020-03-24 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_hal.h" #include diff --git a/lib/teelib/libcrypto_hal/src/crypto_hal_ae.c b/lib/teelib/libcrypto_hal/src/crypto_hal_ae.c index 17e35327..5142e281 100644 --- a/lib/teelib/libcrypto_hal/src/crypto_hal_ae.c +++ b/lib/teelib/libcrypto_hal/src/crypto_hal_ae.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: AE Crypto API at driver adaptor. - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_hal_ae.h" diff --git a/lib/teelib/libcrypto_hal/src/crypto_hal_cipher.c b/lib/teelib/libcrypto_hal/src/crypto_hal_cipher.c index 0dc11e58..5b0203c5 100644 --- a/lib/teelib/libcrypto_hal/src/crypto_hal_cipher.c +++ b/lib/teelib/libcrypto_hal/src/crypto_hal_cipher.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Cipher Crypto API at driver adaptor. - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_hal_cipher.h" diff --git a/lib/teelib/libcrypto_hal/src/crypto_hal_derive_key.c b/lib/teelib/libcrypto_hal/src/crypto_hal_derive_key.c index 683233f8..3c1db092 100644 --- a/lib/teelib/libcrypto_hal/src/crypto_hal_derive_key.c +++ b/lib/teelib/libcrypto_hal/src/crypto_hal_derive_key.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. - * Description: Derive key Crypto API at driver adaptor. -* Create: 2020-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_hal_derive_key.h" diff --git a/lib/teelib/libcrypto_hal/src/crypto_hal_ec.c b/lib/teelib/libcrypto_hal/src/crypto_hal_ec.c index d9e410ab..c31e8d53 100644 --- a/lib/teelib/libcrypto_hal/src/crypto_hal_ec.c +++ b/lib/teelib/libcrypto_hal/src/crypto_hal_ec.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Asymmetric Crypto API at driver adaptor. - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_hal_ec.h" diff --git a/lib/teelib/libcrypto_hal/src/crypto_hal_hash.c b/lib/teelib/libcrypto_hal/src/crypto_hal_hash.c index 9d9470bc..8c652d98 100644 --- a/lib/teelib/libcrypto_hal/src/crypto_hal_hash.c +++ b/lib/teelib/libcrypto_hal/src/crypto_hal_hash.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: Hash Crypto API at driver adaptor. - * Create: 2020-12-21 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_hal_hash.h" #include diff --git a/lib/teelib/libcrypto_hal/src/crypto_hal_hmac.c b/lib/teelib/libcrypto_hal/src/crypto_hal_hmac.c index 25f2401e..27db9ab3 100644 --- a/lib/teelib/libcrypto_hal/src/crypto_hal_hmac.c +++ b/lib/teelib/libcrypto_hal/src/crypto_hal_hmac.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: HMAC Crypto API at driver adaptor. - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_hal_hmac.h" #include diff --git a/lib/teelib/libcrypto_hal/src/crypto_hal_rsa.c b/lib/teelib/libcrypto_hal/src/crypto_hal_rsa.c index 3b8a4041..87e57f3c 100644 --- a/lib/teelib/libcrypto_hal/src/crypto_hal_rsa.c +++ b/lib/teelib/libcrypto_hal/src/crypto_hal_rsa.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: RSA Crypto API at driver adaptor. - * Create: 2020-12-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_hal_rsa.h" diff --git a/lib/teelib/libcrypto_hal/src/crypto_mgr_manager.c b/lib/teelib/libcrypto_hal/src/crypto_mgr_manager.c index 112ccb1c..2ceb4b66 100644 --- a/lib/teelib/libcrypto_hal/src/crypto_mgr_manager.c +++ b/lib/teelib/libcrypto_hal/src/crypto_mgr_manager.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: implament crypto driver manager - * Create: 2022-01-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_manager.h" #include diff --git a/lib/teelib/libhmdrv/Makefile b/lib/teelib/libhmdrv/Makefile index 40110b02..8eebe38d 100644 --- a/lib/teelib/libhmdrv/Makefile +++ b/lib/teelib/libhmdrv/Makefile @@ -1,5 +1,12 @@ -# libhmdrv compile flags. -# Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # Targets MODULE := libhmdrv${TARG}.a diff --git a/lib/teelib/libhmdrv/include/hmdrv.h b/lib/teelib/libhmdrv/include/hmdrv.h index 2b37b444..8c2dfb92 100644 --- a/lib/teelib/libhmdrv/include/hmdrv.h +++ b/lib/teelib/libhmdrv/include/hmdrv.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: drvmgr head file - * Create: 2018-03-31 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBHMDRV_HMDRV_H diff --git a/lib/teelib/libhmdrv/src/libhmdrv.c b/lib/teelib/libhmdrv/src/libhmdrv.c index 0436726a..998c0643 100644 --- a/lib/teelib/libhmdrv/src/libhmdrv.c +++ b/lib/teelib/libhmdrv/src/libhmdrv.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: Define HongmengOS driver calls - * Author: humin hhumin.hu@huawei.com - * Create: 2018-03-31 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "hmdrv.h" diff --git a/lib/teelib/libhuk/Makefile b/lib/teelib/libhuk/Makefile index 1cb1df75..e758d117 100755 --- a/lib/teelib/libhuk/Makefile +++ b/lib/teelib/libhuk/Makefile @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. MODULE := libhuk${TARG}.a CFILES += $(wildcard src/tee_huk_derive_key.c) diff --git a/lib/teelib/libhuk/include/huk_service_msg.h b/lib/teelib/libhuk/include/huk_service_msg.h index 5e1f90d0..d7b71074 100755 --- a/lib/teelib/libhuk/include/huk_service_msg.h +++ b/lib/teelib/libhuk/include/huk_service_msg.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: messages of HUK service. - * Create: 2020-05-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef HUK_SERVICE_HUK_SERVICE_MSG_H #define HUK_SERVICE_HUK_SERVICE_MSG_H diff --git a/lib/teelib/libhuk/include/huk_service_msg_call.h b/lib/teelib/libhuk/include/huk_service_msg_call.h index d8b1dad5..cfcdeff4 100644 --- a/lib/teelib/libhuk/include/huk_service_msg_call.h +++ b/lib/teelib/libhuk/include/huk_service_msg_call.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: HUK service message call - * Create: 2022-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef HUK_SERVICE_MSG_CALL_H #define HUK_SERVICE_MSG_CALL_H diff --git a/lib/teelib/libhuk/include/tee_huk_derive_key.h b/lib/teelib/libhuk/include/tee_huk_derive_key.h index cdf30cf9..40996cfd 100644 --- a/lib/teelib/libhuk/include/tee_huk_derive_key.h +++ b/lib/teelib/libhuk/include/tee_huk_derive_key.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: huk derive key - * Create: 2022-10-25 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_HUK_DERIVE_KEY_H #define TEE_HUK_DERIVE_KEY_H diff --git a/lib/teelib/libhuk/include/tee_huk_get_device_id.h b/lib/teelib/libhuk/include/tee_huk_get_device_id.h index 6e272c1b..68f457f5 100644 --- a/lib/teelib/libhuk/include/tee_huk_get_device_id.h +++ b/lib/teelib/libhuk/include/tee_huk_get_device_id.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: huk get device id - * Create: 2022-10-25 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_HUK_GET_DEVICE_ID_H #define TEE_HUK_GET_DEVICE_ID_H diff --git a/lib/teelib/libhuk/include/tee_internal_huk_api.h b/lib/teelib/libhuk/include/tee_internal_huk_api.h index 9eaf044f..4112d5ec 100644 --- a/lib/teelib/libhuk/include/tee_internal_huk_api.h +++ b/lib/teelib/libhuk/include/tee_internal_huk_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. - * Description: API of HUK service. - * Create: 2020-05-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_INTERNAL_HUK_API_H #define TEE_INTERNAL_HUK_API_H diff --git a/lib/teelib/libhuk/src/huk_service_msg_call.c b/lib/teelib/libhuk/src/huk_service_msg_call.c index 1dcaa8e9..c2508dd0 100644 --- a/lib/teelib/libhuk/src/huk_service_msg_call.c +++ b/lib/teelib/libhuk/src/huk_service_msg_call.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: TEE huk srv msg call API. - * Create: 2022-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libhuk/src/tee_huk_derive_key.c b/lib/teelib/libhuk/src/tee_huk_derive_key.c index 890d17a3..c88e754d 100644 --- a/lib/teelib/libhuk/src/tee_huk_derive_key.c +++ b/lib/teelib/libhuk/src/tee_huk_derive_key.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: huk derive key - * Create: 2022-10-25 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_huk_derive_key.h" #include diff --git a/lib/teelib/libhuk/src/tee_huk_get_device_id.c b/lib/teelib/libhuk/src/tee_huk_get_device_id.c index 5add7732..536211a1 100644 --- a/lib/teelib/libhuk/src/tee_huk_get_device_id.c +++ b/lib/teelib/libhuk/src/tee_huk_get_device_id.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: huk get device id - * Create: 2022-10-25 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_huk_get_device_id.h" #include "tee_huk_derive_key.h" diff --git a/lib/teelib/libpermission_service/Makefile b/lib/teelib/libpermission_service/Makefile index e6a5e285..c12a8ea6 100644 --- a/lib/teelib/libpermission_service/Makefile +++ b/lib/teelib/libpermission_service/Makefile @@ -1,8 +1,12 @@ -# -# Copyright 2022, Huawei Co. Ltd. -# -# See "HUAWEI_LICENSE" for details. -# +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # Targets MODULE := libpermission_service${TARG}.a diff --git a/lib/teelib/libpermission_service/include/permsrv_api.h b/lib/teelib/libpermission_service/include/permsrv_api.h index a668df0b..39da3351 100644 --- a/lib/teelib/libpermission_service/include/permsrv_api.h +++ b/lib/teelib/libpermission_service/include/permsrv_api.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: permsrv api interface head file - * Create: 2018-12-12 - * History: 2020-09-03 limingjuan limingjuan@huawei.com modify qis warning + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __PERSRV_API_H__ diff --git a/lib/teelib/libpermission_service/include/permsrv_api_cert.h b/lib/teelib/libpermission_service/include/permsrv_api_cert.h index d34238bb..1fed7a1d 100644 --- a/lib/teelib/libpermission_service/include/permsrv_api_cert.h +++ b/lib/teelib/libpermission_service/include/permsrv_api_cert.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: permsrv cert api interface head file - * Create: 2022-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __PERSRV_API_CERT_H__ diff --git a/lib/teelib/libpermission_service/include/permsrv_api_legacy.h b/lib/teelib/libpermission_service/include/permsrv_api_legacy.h index 7dc7aad1..a708a8e6 100644 --- a/lib/teelib/libpermission_service/include/permsrv_api_legacy.h +++ b/lib/teelib/libpermission_service/include/permsrv_api_legacy.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Create: 2022-04-17 - * Description: Functions in this header file are deprecated. Do not use + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __PERMSRV_API_LEGACY_H__ diff --git a/lib/teelib/libpermission_service/src/permission_service.h b/lib/teelib/libpermission_service/src/permission_service.h index 31f8bdcf..a3b7253b 100644 --- a/lib/teelib/libpermission_service/src/permission_service.h +++ b/lib/teelib/libpermission_service/src/permission_service.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: permission service implementation - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __PERSRV_H__ #define __PERSRV_H__ diff --git a/lib/teelib/libpermission_service/src/permsrv_api.c b/lib/teelib/libpermission_service/src/permsrv_api.c index e26206dc..75735176 100644 --- a/lib/teelib/libpermission_service/src/permsrv_api.c +++ b/lib/teelib/libpermission_service/src/permsrv_api.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: permission service implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_ext_api.h" #include "tee_log.h" diff --git a/lib/teelib/libpermission_service/src/permsrv_api_cert.c b/lib/teelib/libpermission_service/src/permsrv_api_cert.c index c7f9edeb..4c04687f 100644 --- a/lib/teelib/libpermission_service/src/permsrv_api_cert.c +++ b/lib/teelib/libpermission_service/src/permsrv_api_cert.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: permission service cert api - * Create: 2022-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include "securec.h" diff --git a/lib/teelib/libpermission_service/src/permsrv_api_imp.c b/lib/teelib/libpermission_service/src/permsrv_api_imp.c index fda75076..c2edcdb2 100644 --- a/lib/teelib/libpermission_service/src/permsrv_api_imp.c +++ b/lib/teelib/libpermission_service/src/permsrv_api_imp.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: permission service implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libpermission_service/src/permsrv_api_imp.h b/lib/teelib/libpermission_service/src/permsrv_api_imp.h index 2a42dd0f..293ace45 100644 --- a/lib/teelib/libpermission_service/src/permsrv_api_imp.h +++ b/lib/teelib/libpermission_service/src/permsrv_api_imp.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: permission service implementation - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __PERSRV_API_IMP_H__ #define __PERSRV_API_IMP_H__ diff --git a/lib/teelib/libpermission_service/src/stub/permsrv_api_cert_stub.c b/lib/teelib/libpermission_service/src/stub/permsrv_api_cert_stub.c index 8b426618..ac8f453c 100644 --- a/lib/teelib/libpermission_service/src/stub/permsrv_api_cert_stub.c +++ b/lib/teelib/libpermission_service/src/stub/permsrv_api_cert_stub.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: permission service implementation stub - * Create: 2022-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "permsrv_api_cert.h" diff --git a/lib/teelib/libssa/Makefile b/lib/teelib/libssa/Makefile index 090c8f8c..65e95404 100755 --- a/lib/teelib/libssa/Makefile +++ b/lib/teelib/libssa/Makefile @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. MODULE := libssa${TARG}.a CFILES := $(wildcard src/*.c) diff --git a/lib/teelib/libssa/include/ssa_snd_msg.h b/lib/teelib/libssa/include/ssa_snd_msg.h index fae35beb..9c516feb 100644 --- a/lib/teelib/libssa/include/ssa_snd_msg.h +++ b/lib/teelib/libssa/include/ssa_snd_msg.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: ssa embedded msg - * Create: 2021-01-09 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef SSA_MSG_H #define SSA_MSG_H diff --git a/lib/teelib/libssa/include/tee_ext_trusted_storage_api.h b/lib/teelib/libssa/include/tee_ext_trusted_storage_api.h index d57a221c..22ae941d 100755 --- a/lib/teelib/libssa/include/tee_ext_trusted_storage_api.h +++ b/lib/teelib/libssa/include/tee_ext_trusted_storage_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Create: 2018-12-13 - * Description: Secure storage expansion API + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_EXT_TRUSTED_STORAGE_API_H diff --git a/lib/teelib/libssa/include/tee_ext_trusted_storage_api_legacy.h b/lib/teelib/libssa/include/tee_ext_trusted_storage_api_legacy.h index 0f854439..41f90359 100644 --- a/lib/teelib/libssa/include/tee_ext_trusted_storage_api_legacy.h +++ b/lib/teelib/libssa/include/tee_ext_trusted_storage_api_legacy.h @@ -1,23 +1,29 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Create: 2022-04-25 - * Description: Secure storage expansion API, Functions in this header file are deprecated. Do not use them. - */ - -#ifndef __TEE_EXT_TRUSTED_STORAGE_API_LEGACY_H -#define __TEE_EXT_TRUSTED_STORAGE_API_LEGACY_H - -#include "tee_defines.h" - - -TEE_Result TEE_Ext_CreatePersistentObject(TEE_UUID target, uint32_t storageID, const void *objectID, size_t objectIDLen, - uint32_t flags, TEE_ObjectHandle attributes, const void *initialData, - size_t initialDataLen, TEE_ObjectHandle *object); - -TEE_Result TEE_Ext_OpenPersistentObject(TEE_UUID target, uint32_t storageID, const void *objectID, size_t objectIDLen, - uint32_t flags, TEE_ObjectHandle *object); - - -TEE_Result TEE_Ext_DeleteAllObjects(TEE_UUID target); - +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#ifndef __TEE_EXT_TRUSTED_STORAGE_API_LEGACY_H +#define __TEE_EXT_TRUSTED_STORAGE_API_LEGACY_H + +#include "tee_defines.h" + + +TEE_Result TEE_Ext_CreatePersistentObject(TEE_UUID target, uint32_t storageID, const void *objectID, size_t objectIDLen, + uint32_t flags, TEE_ObjectHandle attributes, const void *initialData, + size_t initialDataLen, TEE_ObjectHandle *object); + +TEE_Result TEE_Ext_OpenPersistentObject(TEE_UUID target, uint32_t storageID, const void *objectID, size_t objectIDLen, + uint32_t flags, TEE_ObjectHandle *object); + + +TEE_Result TEE_Ext_DeleteAllObjects(TEE_UUID target); + #endif \ No newline at end of file diff --git a/lib/teelib/libssa/include/tee_fs.h b/lib/teelib/libssa/include/tee_fs.h index 48048bdf..66172424 100755 --- a/lib/teelib/libssa/include/tee_fs.h +++ b/lib/teelib/libssa/include/tee_fs.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: tee fs implementation - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_FS_H #define __TEE_FS_H diff --git a/lib/teelib/libssa/include/tee_object_api.h b/lib/teelib/libssa/include/tee_object_api.h index cc4707a2..f7c953d7 100644 --- a/lib/teelib/libssa/include/tee_object_api.h +++ b/lib/teelib/libssa/include/tee_object_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Create: 2018-12-13 - * Description: Reference of TEE object api definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_OBJECT_API_H diff --git a/lib/teelib/libssa/include/tee_trusted_storage_api.h b/lib/teelib/libssa/include/tee_trusted_storage_api.h index dbeb3ee7..c7964af8 100644 --- a/lib/teelib/libssa/include/tee_trusted_storage_api.h +++ b/lib/teelib/libssa/include/tee_trusted_storage_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Create: 2018-12-13 - * Description: Reference of TEE trusted storage definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_TRUSTED_STORAGE_API_H diff --git a/lib/teelib/libssa/src/ssa_snd_msg.c b/lib/teelib/libssa/src/ssa_snd_msg.c index ea3ab9cb..53a39dd6 100644 --- a/lib/teelib/libssa/src/ssa_snd_msg.c +++ b/lib/teelib/libssa/src/ssa_snd_msg.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: ssa embedded msg - * Author: Lilianhui lilianhui1@huawei.com - * Create: 2021-01-09 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ssa_snd_msg.h" #include diff --git a/lib/teelib/libssa/src/tee_fs.c b/lib/teelib/libssa/src/tee_fs.c index f77a189a..07a4358b 100755 --- a/lib/teelib/libssa/src/tee_fs.c +++ b/lib/teelib/libssa/src/tee_fs.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: tui fs implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_defines.h" #include "tee_fs.h" diff --git a/lib/teelib/libssa/src/tee_generic_obj_api.c b/lib/teelib/libssa/src/tee_generic_obj_api.c index 63afa1f6..8ebaefe7 100644 --- a/lib/teelib/libssa/src/tee_generic_obj_api.c +++ b/lib/teelib/libssa/src/tee_generic_obj_api.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. - * Description: trusted stroage api for object - * Author: Limingjuan limingjuan@huawei.com - * Create: 2020-12-23 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_object_api.h" #include diff --git a/lib/teelib/libssa/src/tee_obj_attr.c b/lib/teelib/libssa/src/tee_obj_attr.c index c54562f8..874f559a 100644 --- a/lib/teelib/libssa/src/tee_obj_attr.c +++ b/lib/teelib/libssa/src/tee_obj_attr.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. - * Description: trusted object attr api code - * Author: Limingjuan limingjuan@huawei.com - * Create: 2020-12-23 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_obj_attr.h" #include "tee_log.h" diff --git a/lib/teelib/libssa/src/tee_obj_attr.h b/lib/teelib/libssa/src/tee_obj_attr.h index 0e1af1b2..50b36c08 100644 --- a/lib/teelib/libssa/src/tee_obj_attr.h +++ b/lib/teelib/libssa/src/tee_obj_attr.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. - * Description: trusted object attr api header - * Create: 2020-12-23 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_OBJ_ATTR_H #define __TEE_OBJ_ATTR_H diff --git a/lib/teelib/libssa/src/tee_persistent_obj_api.c b/lib/teelib/libssa/src/tee_persistent_obj_api.c index cbb7e2c3..f1f9547c 100644 --- a/lib/teelib/libssa/src/tee_persistent_obj_api.c +++ b/lib/teelib/libssa/src/tee_persistent_obj_api.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2015-2020. All rights reserved. - * Description: trusted stroage api for data and keys - * Author: Hanpeng earon.han@huawei.com - * Create: 2015-12-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_trusted_storage_api.h" #include "ta_framework.h" diff --git a/lib/teelib/libssa/src/tee_ss_agent_api.c b/lib/teelib/libssa/src/tee_ss_agent_api.c index 9579dfb4..3d7eb8a3 100644 --- a/lib/teelib/libssa/src/tee_ss_agent_api.c +++ b/lib/teelib/libssa/src/tee_ss_agent_api.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: tee ss agent implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libssa/src/tee_ss_agent_api.h b/lib/teelib/libssa/src/tee_ss_agent_api.h index a3fda2d4..2860a15f 100644 --- a/lib/teelib/libssa/src/tee_ss_agent_api.h +++ b/lib/teelib/libssa/src/tee_ss_agent_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: tee secure storage agent implementation - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_SS_AGENT_API_H_ #define TEE_SS_AGENT_API_H_ diff --git a/lib/teelib/libssa/src/tee_transient_obj_api.c b/lib/teelib/libssa/src/tee_transient_obj_api.c index 4c8a4edb..ba0581dc 100644 --- a/lib/teelib/libssa/src/tee_transient_obj_api.c +++ b/lib/teelib/libssa/src/tee_transient_obj_api.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: trusted stroage api for object - * Author: Limingjuan limingjuan@huawei.com - * Create: 2020-12-23 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_object_api.h" #include diff --git a/lib/teelib/libswcrypto_engine/Makefile b/lib/teelib/libswcrypto_engine/Makefile index 63693f10..38ede403 100755 --- a/lib/teelib/libswcrypto_engine/Makefile +++ b/lib/teelib/libswcrypto_engine/Makefile @@ -1,6 +1,12 @@ -# -# Copyright 2018, Huawei Co. Ltd. -# +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. MODULE := libswcrypto_engine${TARG}.a diff --git a/lib/teelib/libswcrypto_engine/include/crl_api.h b/lib/teelib/libswcrypto_engine/include/crl_api.h index bb02a652..05fb5c04 100644 --- a/lib/teelib/libswcrypto_engine/include/crl_api.h +++ b/lib/teelib/libswcrypto_engine/include/crl_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: swcrypto engine implementation - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef _CRL_API_H #define _CRL_API_H diff --git a/lib/teelib/libswcrypto_engine/include/crypto_aes_wrapper.h b/lib/teelib/libswcrypto_engine/include/crypto_aes_wrapper.h index 81ec16e6..763ff6c5 100644 --- a/lib/teelib/libswcrypto_engine/include/crypto_aes_wrapper.h +++ b/lib/teelib/libswcrypto_engine/include/crypto_aes_wrapper.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Create: 2022-04-01 - * Description: soft aes engine + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __CRYPTO_AES_WRAPPER_H__ #define __CRYPTO_AES_WRAPPER_H__ diff --git a/lib/teelib/libswcrypto_engine/include/crypto_cert_wrapper.h b/lib/teelib/libswcrypto_engine/include/crypto_cert_wrapper.h index 120bc561..fb262bc3 100644 --- a/lib/teelib/libswcrypto_engine/include/crypto_cert_wrapper.h +++ b/lib/teelib/libswcrypto_engine/include/crypto_cert_wrapper.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Create: 2022-04-01 - * Description: soft aes engine + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __CRYPTO_CERT_WRAPPER_H__ #define __CRYPTO_CERT_WRAPPER_H__ diff --git a/lib/teelib/libswcrypto_engine/include/crypto_ec_wrapper.h b/lib/teelib/libswcrypto_engine/include/crypto_ec_wrapper.h index dc224d64..ee903e55 100644 --- a/lib/teelib/libswcrypto_engine/include/crypto_ec_wrapper.h +++ b/lib/teelib/libswcrypto_engine/include/crypto_ec_wrapper.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Create: 2022-04-01 - * Description: soft ec engine + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __CRYPTO_EC_WRAPPER_H__ #define __CRYPTO_EC_WRAPPER_H__ diff --git a/lib/teelib/libswcrypto_engine/include/crypto_ec_x509_wrapper.h b/lib/teelib/libswcrypto_engine/include/crypto_ec_x509_wrapper.h index 46ef8aaf..bf6db9a4 100644 --- a/lib/teelib/libswcrypto_engine/include/crypto_ec_x509_wrapper.h +++ b/lib/teelib/libswcrypto_engine/include/crypto_ec_x509_wrapper.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Create: 2022-04-01 - * Description: soft ec x509 engine + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __CRYPTO_EC_X509_WRAPPER_H__ #define __CRYPTO_EC_X509_WRAPPER_H__ diff --git a/lib/teelib/libswcrypto_engine/include/crypto_inner_interface.h b/lib/teelib/libswcrypto_engine/include/crypto_inner_interface.h index e8f1f9b2..4055b49b 100755 --- a/lib/teelib/libswcrypto_engine/include/crypto_inner_interface.h +++ b/lib/teelib/libswcrypto_engine/include/crypto_inner_interface.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: soft engine in boringssl - * Create: 2019-06-14 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __CRYPTO_INNER_INTERFACE_H__ diff --git a/lib/teelib/libswcrypto_engine/include/crypto_inner_wrapper.h b/lib/teelib/libswcrypto_engine/include/crypto_inner_wrapper.h index a43e0519..d810d13f 100644 --- a/lib/teelib/libswcrypto_engine/include/crypto_inner_wrapper.h +++ b/lib/teelib/libswcrypto_engine/include/crypto_inner_wrapper.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Create: 2022-04-01 - * Description: soft inner engine + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __CRYPTO_INNER_WRAPPER_H__ #define __CRYPTO_INNER_WRAPPER_H__ diff --git a/lib/teelib/libswcrypto_engine/include/crypto_rsa_wrapper.h b/lib/teelib/libswcrypto_engine/include/crypto_rsa_wrapper.h index ef05ffc9..6c6ea371 100644 --- a/lib/teelib/libswcrypto_engine/include/crypto_rsa_wrapper.h +++ b/lib/teelib/libswcrypto_engine/include/crypto_rsa_wrapper.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Create: 2022-04-01 - * Description: soft rsa engine + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __CRYPTO_RSA_WRAPPER_H__ #define __CRYPTO_RSA_WRAPPER_H__ diff --git a/lib/teelib/libswcrypto_engine/include/crypto_wrapper.h b/lib/teelib/libswcrypto_engine/include/crypto_wrapper.h index 3d76451a..bffe91c8 100755 --- a/lib/teelib/libswcrypto_engine/include/crypto_wrapper.h +++ b/lib/teelib/libswcrypto_engine/include/crypto_wrapper.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Create: 2019-05-29 - * Description: soft engine in boringssl + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __CRYPTO_WRAPPER_H__ #define __CRYPTO_WRAPPER_H__ diff --git a/lib/teelib/libswcrypto_engine/include/crypto_x509_wrapper.h b/lib/teelib/libswcrypto_engine/include/crypto_x509_wrapper.h index db671847..6de1c56d 100644 --- a/lib/teelib/libswcrypto_engine/include/crypto_x509_wrapper.h +++ b/lib/teelib/libswcrypto_engine/include/crypto_x509_wrapper.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Create: 2022-04-01 - * Description: soft ec x509 engine + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __CRYPTO_X509_WRAPPER_H__ #define __CRYPTO_X509_WRAPPER_H__ diff --git a/lib/teelib/libswcrypto_engine/src/aes_wrapper.c b/lib/teelib/libswcrypto_engine/src/aes_wrapper.c index 2a003119..a8ca2809 100644 --- a/lib/teelib/libswcrypto_engine/src/aes_wrapper.c +++ b/lib/teelib/libswcrypto_engine/src/aes_wrapper.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved. - * Description: soft engine of boringssl - * Create: 2019-11-07 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libswcrypto_engine/src/create_cert_wrapper.c b/lib/teelib/libswcrypto_engine/src/create_cert_wrapper.c index 068e2a87..38ef9245 100644 --- a/lib/teelib/libswcrypto_engine/src/create_cert_wrapper.c +++ b/lib/teelib/libswcrypto_engine/src/create_cert_wrapper.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved. - * Description: soft engine of boringssl - * Create: 2019-05-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libswcrypto_engine/src/crl_api.c b/lib/teelib/libswcrypto_engine/src/crl_api.c index 9ed279e9..a26ee705 100755 --- a/lib/teelib/libswcrypto_engine/src/crl_api.c +++ b/lib/teelib/libswcrypto_engine/src/crl_api.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2021. All rights reserved. - * Description: crl certificate api implemation - * Create: 2018-12-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crl_api.h" #include diff --git a/lib/teelib/libswcrypto_engine/src/device_key_wrapper.c b/lib/teelib/libswcrypto_engine/src/device_key_wrapper.c index da2c86d9..6c9ba281 100644 --- a/lib/teelib/libswcrypto_engine/src/device_key_wrapper.c +++ b/lib/teelib/libswcrypto_engine/src/device_key_wrapper.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2021. All rights reserved. - * Description: device key wrapper implementation - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libswcrypto_engine/src/ec_wrapper.c b/lib/teelib/libswcrypto_engine/src/ec_wrapper.c index 9a94e781..c41a8eb2 100644 --- a/lib/teelib/libswcrypto_engine/src/ec_wrapper.c +++ b/lib/teelib/libswcrypto_engine/src/ec_wrapper.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved. - * Description: soft engine of boringssl - * Create: 2019-05-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libswcrypto_engine/src/ec_wrapper.h b/lib/teelib/libswcrypto_engine/src/ec_wrapper.h index e472b92a..838d5573 100644 --- a/lib/teelib/libswcrypto_engine/src/ec_wrapper.h +++ b/lib/teelib/libswcrypto_engine/src/ec_wrapper.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: swcrypto engine implementation - * Create: 2022-03-30 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef EC_WRAPPER_H #define EC_WRAPPER_H diff --git a/lib/teelib/libswcrypto_engine/src/ec_wrapper_x509.c b/lib/teelib/libswcrypto_engine/src/ec_wrapper_x509.c index 96ea884f..e6ac3663 100644 --- a/lib/teelib/libswcrypto_engine/src/ec_wrapper_x509.c +++ b/lib/teelib/libswcrypto_engine/src/ec_wrapper_x509.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: soft engine of boringssl - * Create: 2022-03-30 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libswcrypto_engine/src/rsa_wrapper.c b/lib/teelib/libswcrypto_engine/src/rsa_wrapper.c index 847620a4..210f2da6 100644 --- a/lib/teelib/libswcrypto_engine/src/rsa_wrapper.c +++ b/lib/teelib/libswcrypto_engine/src/rsa_wrapper.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved. - * Description: soft engine of boringssl - * Create: 2019-06-10 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_inner_interface.h" #include diff --git a/lib/teelib/libswcrypto_engine/src/stub/aes_wrapper_stub.c b/lib/teelib/libswcrypto_engine/src/stub/aes_wrapper_stub.c index 453f2df4..b217cdd1 100644 --- a/lib/teelib/libswcrypto_engine/src/stub/aes_wrapper_stub.c +++ b/lib/teelib/libswcrypto_engine/src/stub/aes_wrapper_stub.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: soft engine stub of boringssl - * Create: 2022-03-30 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libswcrypto_engine/src/stub/create_cert_wrapper_stub.c b/lib/teelib/libswcrypto_engine/src/stub/create_cert_wrapper_stub.c index a4638c45..17988019 100644 --- a/lib/teelib/libswcrypto_engine/src/stub/create_cert_wrapper_stub.c +++ b/lib/teelib/libswcrypto_engine/src/stub/create_cert_wrapper_stub.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: soft engine stub of boringssl - * Create: 2022-03-30 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libswcrypto_engine/src/stub/ec_wrapper_stub.c b/lib/teelib/libswcrypto_engine/src/stub/ec_wrapper_stub.c index 5d124963..a95731d7 100644 --- a/lib/teelib/libswcrypto_engine/src/stub/ec_wrapper_stub.c +++ b/lib/teelib/libswcrypto_engine/src/stub/ec_wrapper_stub.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: soft engine of boringssl - * Create: 2022-03-30 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libswcrypto_engine/src/stub/ec_wrapper_x509_stub.c b/lib/teelib/libswcrypto_engine/src/stub/ec_wrapper_x509_stub.c index f81125ff..d084fd5d 100644 --- a/lib/teelib/libswcrypto_engine/src/stub/ec_wrapper_x509_stub.c +++ b/lib/teelib/libswcrypto_engine/src/stub/ec_wrapper_x509_stub.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: soft engine of boringssl - * Create: 2022-03-30 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libswcrypto_engine/src/stub/rsa_wrapper_stub.c b/lib/teelib/libswcrypto_engine/src/stub/rsa_wrapper_stub.c index a78ecbb3..3f7c2f8d 100644 --- a/lib/teelib/libswcrypto_engine/src/stub/rsa_wrapper_stub.c +++ b/lib/teelib/libswcrypto_engine/src/stub/rsa_wrapper_stub.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: soft engine of boringssl - * Create: 2022-03-30 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "crypto_inner_interface.h" #include diff --git a/lib/teelib/libswcrypto_engine/src/stub/tee_ext_cert_api_stub.c b/lib/teelib/libswcrypto_engine/src/stub/tee_ext_cert_api_stub.c index 39c73688..f380214e 100644 --- a/lib/teelib/libswcrypto_engine/src/stub/tee_ext_cert_api_stub.c +++ b/lib/teelib/libswcrypto_engine/src/stub/tee_ext_cert_api_stub.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: extension certification api - * Create: 2022-03-30 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libswcrypto_engine/src/stub/x509_wrapper_stub.c b/lib/teelib/libswcrypto_engine/src/stub/x509_wrapper_stub.c index 7bf3ca17..2ba8acce 100644 --- a/lib/teelib/libswcrypto_engine/src/stub/x509_wrapper_stub.c +++ b/lib/teelib/libswcrypto_engine/src/stub/x509_wrapper_stub.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: x509 wrapper implementation - * Create: 2022-03-30 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libswcrypto_engine/src/tee_ext_cert_api.c b/lib/teelib/libswcrypto_engine/src/tee_ext_cert_api.c index 8f2ba040..7823cd83 100644 --- a/lib/teelib/libswcrypto_engine/src/tee_ext_cert_api.c +++ b/lib/teelib/libswcrypto_engine/src/tee_ext_cert_api.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. - * Description: extension certification api - * Create: 2020-06-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libswcrypto_engine/src/x509_wrapper.c b/lib/teelib/libswcrypto_engine/src/x509_wrapper.c index ae81f4db..e7b442a4 100644 --- a/lib/teelib/libswcrypto_engine/src/x509_wrapper.c +++ b/lib/teelib/libswcrypto_engine/src/x509_wrapper.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2021. All rights reserved. - * Description: x509 wrapper implementation - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libtaentry/Makefile b/lib/teelib/libtaentry/Makefile index fce317c6..d15f8c2c 100644 --- a/lib/teelib/libtaentry/Makefile +++ b/lib/teelib/libtaentry/Makefile @@ -1,5 +1,12 @@ -# libtaentry compile rule, modified by y00416812 -# Copyright Huawei Technologies Co., Ltd. 2010-2020. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. MODULE := libtaentry${TARG}.a diff --git a/lib/teelib/libtaentry/src/client_auth.c b/lib/teelib/libtaentry/src/client_auth.c index 3e072af2..7dfef57c 100644 --- a/lib/teelib/libtaentry/src/client_auth.c +++ b/lib/teelib/libtaentry/src/client_auth.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: client auth func definition for ta - * Author: yangjing y00416812 - * Create: 2020-02-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "client_auth.h" diff --git a/lib/teelib/libtaentry/src/client_auth.h b/lib/teelib/libtaentry/src/client_auth.h index 3c0e0abf..e8be8c5d 100644 --- a/lib/teelib/libtaentry/src/client_auth.h +++ b/lib/teelib/libtaentry/src/client_auth.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: client auth func statement for ta - * Create: 2020-02-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTAENTRY_CLIENT_AUTH_H #define LIBTAENTRY_CLIENT_AUTH_H diff --git a/lib/teelib/libtaentry/src/client_auth_pub_interfaces.c b/lib/teelib/libtaentry/src/client_auth_pub_interfaces.c index 807ad99d..00d7b79b 100644 --- a/lib/teelib/libtaentry/src/client_auth_pub_interfaces.c +++ b/lib/teelib/libtaentry/src/client_auth_pub_interfaces.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: client auth function for Public - * Author: luozhengyi l00575763 - * Create: 2022-03-29 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "client_auth_pub_interfaces.h" #include diff --git a/lib/teelib/libtaentry/src/client_auth_pub_interfaces.h b/lib/teelib/libtaentry/src/client_auth_pub_interfaces.h index 783590a7..407d55f6 100644 --- a/lib/teelib/libtaentry/src/client_auth_pub_interfaces.h +++ b/lib/teelib/libtaentry/src/client_auth_pub_interfaces.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: client auth func statement for ta - * Create: 2022-03-29 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CLIENT_AUTH_PUB_INTERFACES_H #define CLIENT_AUTH_PUB_INTERFACES_H diff --git a/lib/teelib/libtaentry/src/client_auth_uid.c b/lib/teelib/libtaentry/src/client_auth_uid.c index 5325135f..eb17411f 100644 --- a/lib/teelib/libtaentry/src/client_auth_uid.c +++ b/lib/teelib/libtaentry/src/client_auth_uid.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: client auth function for others feature except kunpeng - * Author: luozhengyi l00575763 - * Create: 2022-03-29 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "client_auth_pub_interfaces.h" #include "client_auth_uid.h" diff --git a/lib/teelib/libtaentry/src/client_auth_uid.h b/lib/teelib/libtaentry/src/client_auth_uid.h index a37c8ccc..6b4fcf7d 100644 --- a/lib/teelib/libtaentry/src/client_auth_uid.h +++ b/lib/teelib/libtaentry/src/client_auth_uid.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: client auth func statement for ta - * Create: 2022-03-29 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CLIENT_AUTH_UID_H #define CLIENT_AUTH_UID_H diff --git a/lib/teelib/libtaentry/src/client_auth_user_name.h b/lib/teelib/libtaentry/src/client_auth_user_name.h index 63b1f337..0631bebb 100644 --- a/lib/teelib/libtaentry/src/client_auth_user_name.h +++ b/lib/teelib/libtaentry/src/client_auth_user_name.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: client auth func statement for ta - * Create: 2022-03-29 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CLIENT_AUTH_USER_NAME_H #define CLIENT_AUTH_USER_NAME_H diff --git a/lib/teelib/libtaentry/src/elf_main_entry.c b/lib/teelib/libtaentry/src/elf_main_entry.c index 5fee2923..8e463e0a 100644 --- a/lib/teelib/libtaentry/src/elf_main_entry.c +++ b/lib/teelib/libtaentry/src/elf_main_entry.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: TEE's application elf entry - * Author: zhaoxuqiang z00415816 - * Create: 2018-04-07 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "elf_main_entry.h" #include diff --git a/lib/teelib/libtaentry/src/elf_main_entry.h b/lib/teelib/libtaentry/src/elf_main_entry.h index 07084807..bdcd51c9 100644 --- a/lib/teelib/libtaentry/src/elf_main_entry.h +++ b/lib/teelib/libtaentry/src/elf_main_entry.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: TEE's application elf entry statement - * Create: 2020-02-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTAENTRY_ELF_MAIN_ENTRY_H #define LIBTAENTRY_ELF_MAIN_ENTRY_H diff --git a/lib/teelib/libtee_shared/Makefile b/lib/teelib/libtee_shared/Makefile index 20d0afe2..fa184759 100644 --- a/lib/teelib/libtee_shared/Makefile +++ b/lib/teelib/libtee_shared/Makefile @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. SONAME := libtee_shared$(TARG).so diff --git a/lib/teelib/libtee_shared/include/oemkey.h b/lib/teelib/libtee_shared/include/oemkey.h index 718d67bc..d0417fdb 100644 --- a/lib/teelib/libtee_shared/include/oemkey.h +++ b/lib/teelib/libtee_shared/include/oemkey.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: declear functions to oemkey - * Create: 2021-7 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef OEMKEY_H #define OEMKEY_H diff --git a/lib/teelib/libtee_shared/include/tee_gk_auth_token.h b/lib/teelib/libtee_shared/include/tee_gk_auth_token.h index 58b07d27..f4eef90c 100644 --- a/lib/teelib/libtee_shared/include/tee_gk_auth_token.h +++ b/lib/teelib/libtee_shared/include/tee_gk_auth_token.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Create: 2021-12-12 - * Description: tee gatekeeper verify timestamp api head file + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_GK_AUTH_TOKEN_H diff --git a/lib/teelib/libtee_shared/src/extra_syms.c b/lib/teelib/libtee_shared/src/extra_syms.c index 22a47098..1b1cee5a 100644 --- a/lib/teelib/libtee_shared/src/extra_syms.c +++ b/lib/teelib/libtee_shared/src/extra_syms.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: symbles export for use - * Create: 2020-03-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifdef __aarch64__ diff --git a/lib/teelib/libtee_shared/src/gk_auth_token_stub.c b/lib/teelib/libtee_shared/src/gk_auth_token_stub.c index a2e5d51a..30859d55 100644 --- a/lib/teelib/libtee_shared/src/gk_auth_token_stub.c +++ b/lib/teelib/libtee_shared/src/gk_auth_token_stub.c @@ -1,14 +1,20 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: gatekeeper auth token api implementation code - * Create: 2022-04-12 - */ -#include "tee_gk_auth_token.h" - -TEE_Result tee_gatekeeper_get_verify_timestamp(uint32_t uid, uint64_t *timestamp) -{ - (void)uid; - (void)timestamp; - return TEE_ERROR_NOT_SUPPORTED; -} - +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include "tee_gk_auth_token.h" + +TEE_Result tee_gatekeeper_get_verify_timestamp(uint32_t uid, uint64_t *timestamp) +{ + (void)uid; + (void)timestamp; + return TEE_ERROR_NOT_SUPPORTED; +} + diff --git a/lib/teelib/libtee_shared/src/internal.h b/lib/teelib/libtee_shared/src/internal.h index e14ca1b7..f6520c4f 100644 --- a/lib/teelib/libtee_shared/src/internal.h +++ b/lib/teelib/libtee_shared/src/internal.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: internal symbles for use - * Create: 2020-03-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTEE_SHARED_INTERNAL_H #define LIBTEE_SHARED_INTERNAL_H diff --git a/lib/teelib/libtee_shared/src/oemkey.c b/lib/teelib/libtee_shared/src/oemkey.c index 8722b1b9..6c4fbd15 100644 --- a/lib/teelib/libtee_shared/src/oemkey.c +++ b/lib/teelib/libtee_shared/src/oemkey.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: oemkey interface - * Create: 2021-7-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/lib/teelib/libtee_shared/src/se_ext.c b/lib/teelib/libtee_shared/src/se_ext.c index 55812d24..0ae637ac 100644 --- a/lib/teelib/libtee_shared/src/se_ext.c +++ b/lib/teelib/libtee_shared/src/se_ext.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Create: 2019-05-08 - * Description: ese interface. + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "hmdrv.h" diff --git a/lib/teelib/libteeagentcommon_client/Makefile b/lib/teelib/libteeagentcommon_client/Makefile index 51a0f9c9..d6f181e2 100644 --- a/lib/teelib/libteeagentcommon_client/Makefile +++ b/lib/teelib/libteeagentcommon_client/Makefile @@ -1,4 +1,12 @@ -# Target is a TA app +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. MODULE := libteeagentcommon_client${TARG}.a diff --git a/lib/teelib/libteeagentcommon_client/include/tee_service_public.h b/lib/teelib/libteeagentcommon_client/include/tee_service_public.h index 8b99e550..0379e7d4 100644 --- a/lib/teelib/libteeagentcommon_client/include/tee_service_public.h +++ b/lib/teelib/libteeagentcommon_client/include/tee_service_public.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved. - * Description: tee service public function - * Create: 2019-08-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef _TEE_SERVICE_PUBLIC_H_ #define _TEE_SERVICE_PUBLIC_H_ diff --git a/lib/teelib/libteeagentcommon_client/src/tee_service_public.c b/lib/teelib/libteeagentcommon_client/src/tee_service_public.c index 4febdf0d..4794e2fd 100644 --- a/lib/teelib/libteeagentcommon_client/src/tee_service_public.c +++ b/lib/teelib/libteeagentcommon_client/src/tee_service_public.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee agent common implementation - * Create: 2022-01-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_service_public.h" #include diff --git a/lib/teelib/libteeconfig/Makefile b/lib/teelib/libteeconfig/Makefile index 22d207e4..e5f1eb18 100644 --- a/lib/teelib/libteeconfig/Makefile +++ b/lib/teelib/libteeconfig/Makefile @@ -1,4 +1,13 @@ -# MODULE is a lib +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. +# # Targets MODULE := libteeconfig$(TARG).a diff --git a/lib/teelib/libteeconfig/include/TEE_ext/sre_syscalls_ext.h b/lib/teelib/libteeconfig/include/TEE_ext/sre_syscalls_ext.h index 2e289852..3bee1b04 100644 --- a/lib/teelib/libteeconfig/include/TEE_ext/sre_syscalls_ext.h +++ b/lib/teelib/libteeconfig/include/TEE_ext/sre_syscalls_ext.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: tee syscalls implementation - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __SRE_SYSCASLL_EXT_H_ #define __SRE_SYSCASLL_EXT_H_ diff --git a/lib/teelib/libteeconfig/include/TEE_ext/sre_syscalls_id_ext.h b/lib/teelib/libteeconfig/include/TEE_ext/sre_syscalls_id_ext.h index 94a1851f..07dd266b 100644 --- a/lib/teelib/libteeconfig/include/TEE_ext/sre_syscalls_id_ext.h +++ b/lib/teelib/libteeconfig/include/TEE_ext/sre_syscalls_id_ext.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: sre syscalls implementation - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __SRE_SYSCASLLS_ID_EXT_H__ #define __SRE_SYSCASLLS_ID_EXT_H__ diff --git a/lib/teelib/libteeconfig/include/TEE_ext/tee_bit_ops.h b/lib/teelib/libteeconfig/include/TEE_ext/tee_bit_ops.h index 7979e8eb..30785f2c 100644 --- a/lib/teelib/libteeconfig/include/TEE_ext/tee_bit_ops.h +++ b/lib/teelib/libteeconfig/include/TEE_ext/tee_bit_ops.h @@ -1,6 +1,13 @@ -/* Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: add for MACRO. - * Create: 2019-10-09 +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_BIT_OPS_H_ #define __TEE_BIT_OPS_H_ diff --git a/lib/teelib/libteeconfig/include/chip_info.h b/lib/teelib/libteeconfig/include/chip_info.h index 1029cc17..b4b4a863 100644 --- a/lib/teelib/libteeconfig/include/chip_info.h +++ b/lib/teelib/libteeconfig/include/chip_info.h @@ -1,6 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved. - * Description: declear functions to get chip info + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CHIP_INFO_H #define CHIP_INFO_H diff --git a/lib/teelib/libteeconfig/include/crypto_syscal_types.h b/lib/teelib/libteeconfig/include/crypto_syscal_types.h index e36cd659..135d6ef7 100644 --- a/lib/teelib/libteeconfig/include/crypto_syscal_types.h +++ b/lib/teelib/libteeconfig/include/crypto_syscal_types.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: add structs for crypto syscall 64 bit - * Create: 2020-02-21 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CRYPTO_SYSCALL_TYPES_H #define CRYPTO_SYSCALL_TYPES_H diff --git a/lib/teelib/libteeconfig/include/kernel/sre_access_control.h b/lib/teelib/libteeconfig/include/kernel/sre_access_control.h index 4c8aab63..f47eeaeb 100644 --- a/lib/teelib/libteeconfig/include/kernel/sre_access_control.h +++ b/lib/teelib/libteeconfig/include/kernel/sre_access_control.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: sre access control implementation - * Create: 2018-05-06 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __SRE_ACCESS_CONTROL_ID_H_ #define __SRE_ACCESS_CONTROL_ID_H_ diff --git a/lib/teelib/libteeconfig/include/kernel/sre_rwroot.h b/lib/teelib/libteeconfig/include/kernel/sre_rwroot.h index 0fdf28e5..1322dfe3 100644 --- a/lib/teelib/libteeconfig/include/kernel/sre_rwroot.h +++ b/lib/teelib/libteeconfig/include/kernel/sre_rwroot.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: sre rwroot implementation - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __SRE_RWROOT_H #define __SRE_RWROOT_H diff --git a/lib/teelib/libteeconfig/include/root_status_ops.h b/lib/teelib/libteeconfig/include/root_status_ops.h index 6f6c22ff..c088ea15 100755 --- a/lib/teelib/libteeconfig/include/root_status_ops.h +++ b/lib/teelib/libteeconfig/include/root_status_ops.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: moved from teeos, root status function - * Create: 2019-11-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef ROOT_STATUS_OPS_H #define ROOT_STATUS_OPS_H diff --git a/lib/teelib/libteeconfig/include/sre_syscalls_id.h b/lib/teelib/libteeconfig/include/sre_syscalls_id.h index 65dfab10..7dccafcf 100644 --- a/lib/teelib/libteeconfig/include/sre_syscalls_id.h +++ b/lib/teelib/libteeconfig/include/sre_syscalls_id.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: moved from teeos, drivers cmd id - * Create: 2019-11-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef DRIVERS_SRE_SYSCALLS_ID_H #define DRIVERS_SRE_SYSCALLS_ID_H diff --git a/lib/teelib/libteeconfig/include/tee_config.h b/lib/teelib/libteeconfig/include/tee_config.h index 57d8c03e..230a83fc 100644 --- a/lib/teelib/libteeconfig/include/tee_config.h +++ b/lib/teelib/libteeconfig/include/tee_config.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: some functions declaration in config - * Create: 2020-02-19 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_CONFIG_H #define TEE_CONFIG_H diff --git a/lib/teelib/libteeconfig/include/tee_drv_client.h b/lib/teelib/libteeconfig/include/tee_drv_client.h index f631a9d6..e89400c1 100644 --- a/lib/teelib/libteeconfig/include/tee_drv_client.h +++ b/lib/teelib/libteeconfig/include/tee_drv_client.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: declare tee driver client api - * Create: 2021-03-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_DRV_CLIENT_H #define TEE_DRV_CLIENT_H diff --git a/lib/teelib/libteeconfig/include/tee_drv_errno.h b/lib/teelib/libteeconfig/include/tee_drv_errno.h index de9fbc70..dee9eda1 100644 --- a/lib/teelib/libteeconfig/include/tee_drv_errno.h +++ b/lib/teelib/libteeconfig/include/tee_drv_errno.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: declare tee driver return value marco - * Create: 2021-08-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_DRV_ERRNO_H #define TEE_DRV_ERRNO_H diff --git a/lib/teelib/libteeconfig/include/tee_drv_internal.h b/lib/teelib/libteeconfig/include/tee_drv_internal.h index a631310b..ce4a9def 100644 --- a/lib/teelib/libteeconfig/include/tee_drv_internal.h +++ b/lib/teelib/libteeconfig/include/tee_drv_internal.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: tee driver client api that not export to ta and some public tee driver macro/structure - * Create: 2021-03-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_DRV_INTERNAL_H #define TEE_DRV_INTERNAL_H diff --git a/lib/teelib/libteeconfig/include/tee_sharemem.h b/lib/teelib/libteeconfig/include/tee_sharemem.h index c0b2156f..6adfef8b 100644 --- a/lib/teelib/libteeconfig/include/tee_sharemem.h +++ b/lib/teelib/libteeconfig/include/tee_sharemem.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: tee sharemem api - * Create: 2021-08-16 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_SHAREMEM_H #define TEE_SHAREMEM_H diff --git a/lib/teelib/libteeconfig/src/drv_hal/drvcalls.c b/lib/teelib/libteeconfig/src/drv_hal/drvcalls.c index e3eee58f..11d0e9a5 100644 --- a/lib/teelib/libteeconfig/src/drv_hal/drvcalls.c +++ b/lib/teelib/libteeconfig/src/drv_hal/drvcalls.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2022. All rights reserved. - * Description: drv call interface for TA - * Create: 2018-11-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include diff --git a/lib/teelib/libteeconfig/src/drv_hal/tee_drv_client.c b/lib/teelib/libteeconfig/src/drv_hal/tee_drv_client.c index 1efadde5..7b0bbbc9 100644 --- a/lib/teelib/libteeconfig/src/drv_hal/tee_drv_client.c +++ b/lib/teelib/libteeconfig/src/drv_hal/tee_drv_client.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: define tee driver client api - * Create: 2021-03-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_drv_client.h" #include diff --git a/lib/teelib/libteeconfig/src/drv_hal/tee_misc_drv_hal.c b/lib/teelib/libteeconfig/src/drv_hal/tee_misc_drv_hal.c index 2017949e..7c771b37 100644 --- a/lib/teelib/libteeconfig/src/drv_hal/tee_misc_drv_hal.c +++ b/lib/teelib/libteeconfig/src/drv_hal/tee_misc_drv_hal.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: for get shared mem and oemkey from misc driver - * Create: 2022-01-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libteeconfig/src/tee_config/product_config_hal.c b/lib/teelib/libteeconfig/src/tee_config/product_config_hal.c index f538378b..1501d8d2 100644 --- a/lib/teelib/libteeconfig/src/tee_config/product_config_hal.c +++ b/lib/teelib/libteeconfig/src/tee_config/product_config_hal.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. - * Description: Declare the product interface that teeos depends on - * Create: 2022-04-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libteeconfig/src/tee_config/product_config_hal.h b/lib/teelib/libteeconfig/src/tee_config/product_config_hal.h index 54963cbc..f62ce40a 100644 --- a/lib/teelib/libteeconfig/src/tee_config/product_config_hal.h +++ b/lib/teelib/libteeconfig/src/tee_config/product_config_hal.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved. - * Description: Declare the product interface that teeos depends on - * Create: 2022-04-12 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PRODUCT_CONFIG_HAL_H #define PRODUCT_CONFIG_HAL_H diff --git a/lib/teelib/libteeconfig/src/tee_config/tee_config.c b/lib/teelib/libteeconfig/src/tee_config/tee_config.c index 82b39b19..4a281858 100644 --- a/lib/teelib/libteeconfig/src/tee_config/tee_config.c +++ b/lib/teelib/libteeconfig/src/tee_config/tee_config.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: teeos platform configs - * Create: 2020-03-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_config.h" #include diff --git a/lib/teelib/libteeconfig/src/tee_config/tee_config_hal.c b/lib/teelib/libteeconfig/src/tee_config/tee_config_hal.c index 0101d39c..5157c598 100644 --- a/lib/teelib/libteeconfig/src/tee_config/tee_config_hal.c +++ b/lib/teelib/libteeconfig/src/tee_config/tee_config_hal.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: functions to get configs - * Create: 2020-03-10 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_config.h" #include diff --git a/lib/teelib/libteeconfig/src/tee_test_config/tee_test_calist.c b/lib/teelib/libteeconfig/src/tee_test_config/tee_test_calist.c index 5133d1a9..d14729d7 100644 --- a/lib/teelib/libteeconfig/src/tee_test_config/tee_test_calist.c +++ b/lib/teelib/libteeconfig/src/tee_test_config/tee_test_calist.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: test ca blacklist - * Create: 2022-03-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifdef CONFIG_TEST_CA_CHECK diff --git a/lib/teelib/libteeconfig/src/tee_test_config/tee_test_calist.h b/lib/teelib/libteeconfig/src/tee_test_config/tee_test_calist.h index 2bb714da..9aa2b11d 100644 --- a/lib/teelib/libteeconfig/src/tee_test_config/tee_test_calist.h +++ b/lib/teelib/libteeconfig/src/tee_test_config/tee_test_calist.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: test ca blacklist - * Create: 2022-02-26 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_TEST_CALIST_H diff --git a/lib/teelib/libteedynsrv/Makefile b/lib/teelib/libteedynsrv/Makefile index ff11e39c..1a45126e 100644 --- a/lib/teelib/libteedynsrv/Makefile +++ b/lib/teelib/libteedynsrv/Makefile @@ -1,6 +1,12 @@ -#MODULE is a lib - -# Targets +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. MODULE := libteedynsrv${TARG}.a diff --git a/lib/teelib/libteedynsrv/include/tee_dynamic_srv.h b/lib/teelib/libteedynsrv/include/tee_dynamic_srv.h index da86ca91..31264998 100644 --- a/lib/teelib/libteedynsrv/include/tee_dynamic_srv.h +++ b/lib/teelib/libteedynsrv/include/tee_dynamic_srv.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee dynamic service function - * Create: 2022-01-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef _TEE_DYNAMIC_SRV_H_ #define _TEE_DYNAMIC_SRV_H_ diff --git a/lib/teelib/libteedynsrv/src/tee_dynamic_srv.c b/lib/teelib/libteedynsrv/src/tee_dynamic_srv.c index 8c298ed5..1c4aeec6 100644 --- a/lib/teelib/libteedynsrv/src/tee_dynamic_srv.c +++ b/lib/teelib/libteedynsrv/src/tee_dynamic_srv.c @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee common public service implementation - * Author:yanruiqing - * Create: 2022-01-07 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_dynamic_srv.h" diff --git a/lib/teelib/libteemem/Makefile b/lib/teelib/libteemem/Makefile index ac4f47c8..a9c07d84 100644 --- a/lib/teelib/libteemem/Makefile +++ b/lib/teelib/libteemem/Makefile @@ -1,3 +1,12 @@ +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. MODULE := libteemem${TARG}.a CPPFLAGS += -I$(TEELIB)/libteeos/include/tee diff --git a/lib/teelib/libteemem/include/mem_mode.h b/lib/teelib/libteemem/include/mem_mode.h index db555db8..717df956 100644 --- a/lib/teelib/libteemem/include/mem_mode.h +++ b/lib/teelib/libteemem/include/mem_mode.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: memory secure/cache/user mode macro definition - * Create: 2019-11-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTEEMEM_MEM_MODE_H #define LIBTEEMEM_MEM_MODE_H diff --git a/lib/teelib/libteemem/include/mem_ops.h b/lib/teelib/libteemem/include/mem_ops.h index 3bb3f319..6f56edb9 100644 --- a/lib/teelib/libteemem/include/mem_ops.h +++ b/lib/teelib/libteemem/include/mem_ops.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: memory operation that not be exported - * Create: 2019-11-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTEEMEM_MEM_OPS_H #define LIBTEEMEM_MEM_OPS_H diff --git a/lib/teelib/libteemem/include/mem_ops_ext.h b/lib/teelib/libteemem/include/mem_ops_ext.h index 50d616ce..92bd896d 100644 --- a/lib/teelib/libteemem/include/mem_ops_ext.h +++ b/lib/teelib/libteemem/include/mem_ops_ext.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: memory functions are exported by libtee_shared - * Create: 2019-11-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef MEM_OPS_EXT_H #define MEM_OPS_EXT_H diff --git a/lib/teelib/libteemem/include/mem_page_ops.h b/lib/teelib/libteemem/include/mem_page_ops.h index 38c1c8c6..6a84dfd4 100644 --- a/lib/teelib/libteemem/include/mem_page_ops.h +++ b/lib/teelib/libteemem/include/mem_page_ops.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: paddr definition and PAGE operation macro - * Create: 2019-11-29 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTEEMEM_MEM_PAGE_OPS_H #define LIBTEEMEM_MEM_PAGE_OPS_H diff --git a/lib/teelib/libteemem/include/tee_sharemem_ops.h b/lib/teelib/libteemem/include/tee_sharemem_ops.h index ae458d4f..fee36127 100644 --- a/lib/teelib/libteemem/include/tee_sharemem_ops.h +++ b/lib/teelib/libteemem/include/tee_sharemem_ops.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved. - * Description: memory functions are exported by libtee_shared - * Create: 2021-11-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_SHAREMEM_OPS_H #define TEE_SHAREMEM_OPS_H diff --git a/lib/teelib/libteemem/src/teemem_pub_fun.h b/lib/teelib/libteemem/src/teemem_pub_fun.h index c13c17c1..f294f26c 100644 --- a/lib/teelib/libteemem/src/teemem_pub_fun.h +++ b/lib/teelib/libteemem/src/teemem_pub_fun.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: teemem public func Interface - * Create: 2022-04-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef IBTEEMEM_TEEMEM_PUB_FUN_H diff --git a/lib/teelib/libteemem/src/teemem_syscall.c b/lib/teelib/libteemem/src/teemem_syscall.c index 30e55fc0..ae970004 100644 --- a/lib/teelib/libteemem/src/teemem_syscall.c +++ b/lib/teelib/libteemem/src/teemem_syscall.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: syscall functions for teemem - * Author: liuchunyan liuchunyan9@huawei.com - * Create: 2018-04-17 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/lib/teelib/libteeos/Makefile b/lib/teelib/libteeos/Makefile index 78145362..11b88ac6 100755 --- a/lib/teelib/libteeos/Makefile +++ b/lib/teelib/libteeos/Makefile @@ -1,8 +1,12 @@ -# -# Copyright 2017, Huawei Co. Ltd. -# -# See "HUAWEI_LICENSE" for details. -# +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # Targets MODULE := libteeos${TARG}.a diff --git a/lib/teelib/libteeos/include/legacy/sre_errno.h b/lib/teelib/libteeos/include/legacy/sre_errno.h index a1d424cb..721ea5a0 100644 --- a/lib/teelib/libteeos/include/legacy/sre_errno.h +++ b/lib/teelib/libteeos/include/legacy/sre_errno.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: arm error info api interface - * Create: 2020-01-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTEEOS_SRE_ERRNO_H #define LIBTEEOS_SRE_ERRNO_H diff --git a/lib/teelib/libteeos/include/legacy/sre_typedef.h b/lib/teelib/libteeos/include/legacy/sre_typedef.h index 65cb7728..166adb7d 100644 --- a/lib/teelib/libteeos/include/legacy/sre_typedef.h +++ b/lib/teelib/libteeos/include/legacy/sre_typedef.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: old type define, will not support - * Create: 2019-12-10 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTEEOS_SRE_TYPEDEF_H #define LIBTEEOS_SRE_TYPEDEF_H diff --git a/lib/teelib/libteeos/include/tee/ta_framework.h b/lib/teelib/libteeos/include/tee/ta_framework.h index 21a38ab4..aa2ae898 100644 --- a/lib/teelib/libteeos/include/tee/ta_framework.h +++ b/lib/teelib/libteeos/include/tee/ta_framework.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: ta framework definitions - * Create: 2018-12-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TA_FRAMWORK_H_ diff --git a/lib/teelib/libteeos/include/tee/ta_permission.h b/lib/teelib/libteeos/include/tee/ta_permission.h index 68e3dea7..258a3894 100644 --- a/lib/teelib/libteeos/include/tee/ta_permission.h +++ b/lib/teelib/libteeos/include/tee/ta_permission.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: headfile for ta permission - * Create: 2019-12-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TA_PERMISSION_H diff --git a/lib/teelib/libteeos/include/tee/ta_routine.h b/lib/teelib/libteeos/include/tee/ta_routine.h index a0756b1f..680536d6 100644 --- a/lib/teelib/libteeos/include/tee/ta_routine.h +++ b/lib/teelib/libteeos/include/tee/ta_routine.h @@ -1,6 +1,13 @@ -/* Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: add for elf_main_entry decouple - * Create: 2019-08-26 +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTEEOS_TA_ROUTINE_H #define LIBTEEOS_TA_ROUTINE_H diff --git a/lib/teelib/libteeos/include/tee/tee_c_env.h b/lib/teelib/libteeos/include/tee/tee_c_env.h index d258aa8c..2898ca6f 100644 --- a/lib/teelib/libteeos/include/tee/tee_c_env.h +++ b/lib/teelib/libteeos/include/tee/tee_c_env.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: TEE application c language environment initialization - * Create: 2018-12-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef _TEE_C_ENV_H diff --git a/lib/teelib/libteeos/include/tee/tee_common.h b/lib/teelib/libteeos/include/tee/tee_common.h index 2ce0acf6..a75d6a1f 100644 --- a/lib/teelib/libteeos/include/tee/tee_common.h +++ b/lib/teelib/libteeos/include/tee/tee_common.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved. - * Description: gtask cmd declaration - * Create: 2012-12-31 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_COMMON_H_ #define __TEE_COMMON_H_ diff --git a/lib/teelib/libteeos/include/tee/tee_core_api.h b/lib/teelib/libteeos/include/tee/tee_core_api.h index 957164a3..6319cf22 100644 --- a/lib/teelib/libteeos/include/tee/tee_core_api.h +++ b/lib/teelib/libteeos/include/tee/tee_core_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Create: 2018-12-13 - * Description: tee core api definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_CORE_API_H #define __TEE_CORE_API_H diff --git a/lib/teelib/libteeos/include/tee/tee_defines.h b/lib/teelib/libteeos/include/tee/tee_defines.h index b1573d03..c4050bfc 100644 --- a/lib/teelib/libteeos/include/tee/tee_defines.h +++ b/lib/teelib/libteeos/include/tee/tee_defines.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: Reference of TEE internal api and internal definitions - * Create: 2018-12-13 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_DEFINES_H diff --git a/lib/teelib/libteeos/include/tee/tee_err.h b/lib/teelib/libteeos/include/tee/tee_err.h index 505a6d86..7909caea 100644 --- a/lib/teelib/libteeos/include/tee/tee_err.h +++ b/lib/teelib/libteeos/include/tee/tee_err.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: Reference of TEE error definitions - * Create: 2021-03-09 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_ERROR_H diff --git a/lib/teelib/libteeos/include/tee/tee_ext_api.h b/lib/teelib/libteeos/include/tee/tee_ext_api.h index a1716d5d..d8dadd15 100644 --- a/lib/teelib/libteeos/include/tee/tee_ext_api.h +++ b/lib/teelib/libteeos/include/tee/tee_ext_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All rights reserved. - * Create: 2012-03-20 - * Description: Tee ext api header file + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_EXT_API_H diff --git a/lib/teelib/libteeos/include/tee/tee_hw_ext_api_legacy.h b/lib/teelib/libteeos/include/tee/tee_hw_ext_api_legacy.h index 19b83b40..5f2826cb 100644 --- a/lib/teelib/libteeos/include/tee/tee_hw_ext_api_legacy.h +++ b/lib/teelib/libteeos/include/tee/tee_hw_ext_api_legacy.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Create: 2022-04-17 - * Description: Functions in this header file are deprecated. Do not use + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_HW_EXT_API_LEGACY_H__ diff --git a/lib/teelib/libteeos/include/tee/tee_init.h b/lib/teelib/libteeos/include/tee/tee_init.h index bb591169..5634c4cb 100755 --- a/lib/teelib/libteeos/include/tee/tee_init.h +++ b/lib/teelib/libteeos/include/tee/tee_init.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All rights reserved. - * Description: Init base property header file for tee - * Create: 2012-01-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_INIT_H #define TEE_INIT_H diff --git a/lib/teelib/libteeos/include/tee/tee_inner_uuid.h b/lib/teelib/libteeos/include/tee/tee_inner_uuid.h index d906e710..29de39e4 100644 --- a/lib/teelib/libteeos/include/tee/tee_inner_uuid.h +++ b/lib/teelib/libteeos/include/tee/tee_inner_uuid.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: teeos uuid definitions, product uuid must not difine in this file - * Create: 2020-03-02 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_INNER_UUID_H #define TEE_INNER_UUID_H diff --git a/lib/teelib/libteeos/include/tee/tee_internal_api.h b/lib/teelib/libteeos/include/tee/tee_internal_api.h index 4c0769a3..4e088742 100644 --- a/lib/teelib/libteeos/include/tee/tee_internal_api.h +++ b/lib/teelib/libteeos/include/tee/tee_internal_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Create: 2018-12-13 - * Description: Reference of TEE internal api and internal definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_INTERNAL_API_H diff --git a/lib/teelib/libteeos/include/tee/tee_internal_task_pub.h b/lib/teelib/libteeos/include/tee/tee_internal_task_pub.h index caa5777b..9d1b4f8d 100644 --- a/lib/teelib/libteeos/include/tee/tee_internal_task_pub.h +++ b/lib/teelib/libteeos/include/tee/tee_internal_task_pub.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2022. All rights reserved. - * Description: public msg id and structure defination for tee internal task - * Create: 2019-11-07 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_INTERNAL_TASK_PUB_H diff --git a/lib/teelib/libteeos/include/tee/tee_log.h b/lib/teelib/libteeos/include/tee/tee_log.h index 3a1b0140..edbde268 100644 --- a/lib/teelib/libteeos/include/tee/tee_log.h +++ b/lib/teelib/libteeos/include/tee/tee_log.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Create: 2018-12-13 - * Description: Reference of TEE log api and internal definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_LOG_H diff --git a/lib/teelib/libteeos/include/tee/tee_log_legacy.h b/lib/teelib/libteeos/include/tee/tee_log_legacy.h index 105a162d..55ba4131 100644 --- a/lib/teelib/libteeos/include/tee/tee_log_legacy.h +++ b/lib/teelib/libteeos/include/tee/tee_log_legacy.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Create: 2018-12-13 - * Description: Reference of TEE log api and internal definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_LOG_LEGACY_H__ diff --git a/lib/teelib/libteeos/include/tee/tee_mem_mgmt_api.h b/lib/teelib/libteeos/include/tee/tee_mem_mgmt_api.h index 7329dbb6..c7b8cac1 100644 --- a/lib/teelib/libteeos/include/tee/tee_mem_mgmt_api.h +++ b/lib/teelib/libteeos/include/tee/tee_mem_mgmt_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved. - * Create: 2012-12-31 - * Description: Header file of memory management api + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_MEM_MGMT_API_H diff --git a/lib/teelib/libteeos/include/tee/tee_mem_monitoring_api.h b/lib/teelib/libteeos/include/tee/tee_mem_monitoring_api.h index 0ad448b2..a8d7a82a 100644 --- a/lib/teelib/libteeos/include/tee/tee_mem_monitoring_api.h +++ b/lib/teelib/libteeos/include/tee/tee_mem_monitoring_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved. - * Create: 2012-12-31 - * Description: Header file of memory management api + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_MEM_MONITORING_API_H diff --git a/lib/teelib/libteeos/include/tee/tee_private_api.h b/lib/teelib/libteeos/include/tee/tee_private_api.h index 1dfa74f5..9c68b247 100644 --- a/lib/teelib/libteeos/include/tee/tee_private_api.h +++ b/lib/teelib/libteeos/include/tee/tee_private_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. - * Description: Tee private api header file - * Create: 2020-01-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTEEOS_TEE_PRIVATE_API_H #define LIBTEEOS_TEE_PRIVATE_API_H diff --git a/lib/teelib/libteeos/include/tee/tee_property_api.h b/lib/teelib/libteeos/include/tee/tee_property_api.h index 87cd5faa..287b8f6b 100644 --- a/lib/teelib/libteeos/include/tee/tee_property_api.h +++ b/lib/teelib/libteeos/include/tee/tee_property_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All rights reserved. - * Create: 2012-01-20 - * Description: TEE property implementation header file + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_PROPERTY_API_H diff --git a/lib/teelib/libteeos/include/tee/tee_reserve.h b/lib/teelib/libteeos/include/tee/tee_reserve.h index d5e6a44f..21cc0b6d 100644 --- a/lib/teelib/libteeos/include/tee/tee_reserve.h +++ b/lib/teelib/libteeos/include/tee/tee_reserve.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: tee reserve implementation - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_RESERVE_H #define __TEE_RESERVE_H diff --git a/lib/teelib/libteeos/include/tee/tee_reserved_api.h b/lib/teelib/libteeos/include/tee/tee_reserved_api.h index 3bfb543c..1717d952 100755 --- a/lib/teelib/libteeos/include/tee/tee_reserved_api.h +++ b/lib/teelib/libteeos/include/tee/tee_reserved_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: tee_reserved_api.h - * Create: 2019-09-09 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_RESERVE_API_H #define __TEE_RESERVE_API_H diff --git a/lib/teelib/libteeos/include/tee/tee_rtc_time_api.h b/lib/teelib/libteeos/include/tee/tee_rtc_time_api.h index 4115a6b9..4191848b 100644 --- a/lib/teelib/libteeos/include/tee/tee_rtc_time_api.h +++ b/lib/teelib/libteeos/include/tee/tee_rtc_time_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2021. All rights reserved. - * Create: 2021-01-20 - * Description: Reference of TEE time api definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_RTC_TIME_API_H diff --git a/lib/teelib/libteeos/include/tee/tee_skytone_api.h b/lib/teelib/libteeos/include/tee/tee_skytone_api.h index df0dbd5e..0e822078 100644 --- a/lib/teelib/libteeos/include/tee/tee_skytone_api.h +++ b/lib/teelib/libteeos/include/tee/tee_skytone_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: Tee skytone api header file - * Create: 2020-01-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_SKYTONE_API_H #define TEE_SKYTONE_API_H diff --git a/lib/teelib/libteeos/include/tee/tee_ta2ta.h b/lib/teelib/libteeos/include/tee/tee_ta2ta.h index 23862916..06531f19 100755 --- a/lib/teelib/libteeos/include/tee/tee_ta2ta.h +++ b/lib/teelib/libteeos/include/tee/tee_ta2ta.h @@ -1,6 +1,13 @@ -/* Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: Make gtask be compatible to handle 64bit TA and 32bit TA. - * Create: 2019-04-12 +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_TA2TA_H_ diff --git a/lib/teelib/libteeos/include/tee/tee_time_api.h b/lib/teelib/libteeos/include/tee/tee_time_api.h index 608c538a..e91b9990 100644 --- a/lib/teelib/libteeos/include/tee/tee_time_api.h +++ b/lib/teelib/libteeos/include/tee/tee_time_api.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Create: 2018-12-13 - * Description: Reference of TEE time api definitions + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_TIME_API_H diff --git a/lib/teelib/libteeos/include/tee_bitmap.h b/lib/teelib/libteeos/include/tee_bitmap.h index efe5cb9b..3bda9183 100644 --- a/lib/teelib/libteeos/include/tee_bitmap.h +++ b/lib/teelib/libteeos/include/tee_bitmap.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: manage tee bitmap - * Create: 2019-01-31 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTEEOS_TEE_BITMAP_H #define LIBTEEOS_TEE_BITMAP_H diff --git a/lib/teelib/libteeos/include/tee_property_inner.h b/lib/teelib/libteeos/include/tee_property_inner.h index 3f5bf076..d048a959 100644 --- a/lib/teelib/libteeos/include/tee_property_inner.h +++ b/lib/teelib/libteeos/include/tee_property_inner.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All rights reserved. - * Description: Tee base property implementation header file used in inner - * Create: 2012-01-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_PROPERTY_INNER_H #define TEE_PROPERTY_INNER_H diff --git a/lib/teelib/libteeos/src/log/tee_log.c b/lib/teelib/libteeos/src/log/tee_log.c index 042d1f05..f88111cc 100644 --- a/lib/teelib/libteeos/src/log/tee_log.c +++ b/lib/teelib/libteeos/src/log/tee_log.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: log functions in libteeos - * Author: zhengxianyi zhengxianyi1@huawei.com - * Create: 2018-04-07 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_log.h" #include diff --git a/lib/teelib/libteeos/src/log/tee_tag.c b/lib/teelib/libteeos/src/log/tee_tag.c index 02e6c21a..18e53ea1 100644 --- a/lib/teelib/libteeos/src/log/tee_tag.c +++ b/lib/teelib/libteeos/src/log/tee_tag.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: tee process log tag code - * Author: Li Mingjuan limingjuan@huawei.com - * Create: 2020-02-04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_tag.h" diff --git a/lib/teelib/libteeos/src/log/tee_tag.h b/lib/teelib/libteeos/src/log/tee_tag.h index 4f3790c9..02fe1beb 100644 --- a/lib/teelib/libteeos/src/log/tee_tag.h +++ b/lib/teelib/libteeos/src/log/tee_tag.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: tee process log tag head file - * Create: 2020-02-04 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_TAG_H #define TEE_TAG_H diff --git a/lib/teelib/libteeos/src/tee/tee_bitmap.c b/lib/teelib/libteeos/src/tee/tee_bitmap.c index d9bfb9b2..b0ff31ed 100644 --- a/lib/teelib/libteeos/src/tee/tee_bitmap.c +++ b/lib/teelib/libteeos/src/tee/tee_bitmap.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: implementation of get_valid_bit in tee bitmap - * Author: Zhangzhangkai z00497210 - * Create: 2019-01-31 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_bitmap.h" diff --git a/lib/teelib/libteeos/src/tee/tee_core_api.c b/lib/teelib/libteeos/src/tee/tee_core_api.c index 8a08c88c..ffde79ff 100644 --- a/lib/teelib/libteeos/src/tee/tee_core_api.c +++ b/lib/teelib/libteeos/src/tee/tee_core_api.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: implament GP API of ta2ta - * Author: Zhangzhangkai z00497210 - * Create: 2019-01-31 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_core_api.h" diff --git a/lib/teelib/libteeos/src/tee/tee_ext_api.c b/lib/teelib/libteeos/src/tee/tee_ext_api.c index 08bd7397..63451c27 100755 --- a/lib/teelib/libteeos/src/tee/tee_ext_api.c +++ b/lib/teelib/libteeos/src/tee/tee_ext_api.c @@ -1,15 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2022. All rights reserved. - * Description: Tee ext api implementation file - * Author: h00471739 - * Create: 2012-03-20 - * History: 2019-09-09 h00471739 restruct + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_ext_api.h" #include diff --git a/lib/teelib/libteeos/src/tee/tee_init.c b/lib/teelib/libteeos/src/tee/tee_init.c index 7f1259c3..522d3233 100644 --- a/lib/teelib/libteeos/src/tee/tee_init.c +++ b/lib/teelib/libteeos/src/tee/tee_init.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved. - * Description: Tee initialization api implementation file - * Author: h00471739 - * Create: 2012-01-20 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_init.h" diff --git a/lib/teelib/libteeos/src/tee/tee_mem_mgmt_api.c b/lib/teelib/libteeos/src/tee/tee_mem_mgmt_api.c index 9d4e58f3..12d771b9 100755 --- a/lib/teelib/libteeos/src/tee/tee_mem_mgmt_api.c +++ b/lib/teelib/libteeos/src/tee/tee_mem_mgmt_api.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved. - * Description: Implemetion of memory management api - * Author: yaodongdong y00543778 - * Create: 2012-12-31 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_mem_mgmt_api.h" diff --git a/lib/teelib/libteeos/src/tee/tee_mem_monitoring_api.c b/lib/teelib/libteeos/src/tee/tee_mem_monitoring_api.c index 93f3a5cd..b9339d7c 100644 --- a/lib/teelib/libteeos/src/tee/tee_mem_monitoring_api.c +++ b/lib/teelib/libteeos/src/tee/tee_mem_monitoring_api.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: Implemetion of memory management not GP api - * Author: luozhengyi l00575763 - * Create: 2022-04-25 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_mem_mgmt_api.h" diff --git a/lib/teelib/libteeos/src/tee/tee_obj.c b/lib/teelib/libteeos/src/tee/tee_obj.c index 047fb2ad..5c09890c 100644 --- a/lib/teelib/libteeos/src/tee/tee_obj.c +++ b/lib/teelib/libteeos/src/tee/tee_obj.c @@ -1,15 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All rights reserved. - * Description: Tee object implemetion - * Author: huangjiankang@huawei.com - * Create: 2012-01-15 - * History: 2019-09-09 huangjiankang@huawei.com restruct + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_obj.h" #include diff --git a/lib/teelib/libteeos/src/tee/tee_obj.h b/lib/teelib/libteeos/src/tee/tee_obj.h index 11ca86bc..4a9b743d 100755 --- a/lib/teelib/libteeos/src/tee/tee_obj.h +++ b/lib/teelib/libteeos/src/tee/tee_obj.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All rights reserved. - * Description: Tee object header file - * Create: 2012-01-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_OBJ_H #define TEE_OBJ_H diff --git a/lib/teelib/libteeos/src/tee/tee_property_api.c b/lib/teelib/libteeos/src/tee/tee_property_api.c index d93b8261..d9a74f88 100644 --- a/lib/teelib/libteeos/src/tee/tee_property_api.c +++ b/lib/teelib/libteeos/src/tee/tee_property_api.c @@ -1,15 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2012-2019. All rights reserved. - * Description: Tee base property implementation - * Author: h00471739 - * Create: 2012-01-20 - * History: 2019-09-09 h00471739 restruct + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_property_api.h" diff --git a/lib/teelib/libteeos/src/tee_ext/ta_permission.c b/lib/teelib/libteeos/src/tee_ext/ta_permission.c index 002d74d6..616d7fe0 100644 --- a/lib/teelib/libteeos/src/tee_ext/ta_permission.c +++ b/lib/teelib/libteeos/src/tee_ext/ta_permission.c @@ -1,20 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ -/* $$$!!Warning: Huawei key information asset. No spread without permission.$$$ */ -/* CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM/7uADPX5kMIDR9EzlrKbowA2kAWPsptA/i1sp5YlH5sJzn7qOz2BwqIQ3tK -XogmsUvj68dRns2uMNggb+GEHlpiIoSMc0MeM1OucCUunEYhNj6M02xag9s3KxxEf6eyNruG -mhjleryGNh46uiRGSK0wVp36/VL8juVjE4JjPfzJVdKWEfo+kRQAZEcMJm1VZA==# */ -/* $$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$ */ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved. - * Description: ta permission - * Author: l00422637 - * Create: 2018-03-10 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ta_permission.h" #include diff --git a/lib/teelib/libtimer/Makefile b/lib/teelib/libtimer/Makefile index 43612982..c5444ae2 100644 --- a/lib/teelib/libtimer/Makefile +++ b/lib/teelib/libtimer/Makefile @@ -1,8 +1,12 @@ -# -# Copyright 2022, Huawei Co. Ltd -# -# See "HUAWEI_LICENSE" for details. -# +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # Targets MODULE := libtimer${TARG}.a diff --git a/lib/teelib/libtimer/include/aarch64/generic_timer.h b/lib/teelib/libtimer/include/aarch64/generic_timer.h index 0069f78a..0a785f9c 100644 --- a/lib/teelib/libtimer/include/aarch64/generic_timer.h +++ b/lib/teelib/libtimer/include/aarch64/generic_timer.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: access generic timer - * Create: 2022-04-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTIMER_GENERIC_TIMER_H #define LIBTIMER_GENERIC_TIMER_H diff --git a/lib/teelib/libtimer/include/arm/generic_timer.h b/lib/teelib/libtimer/include/arm/generic_timer.h index 6b71e142..6d2833d4 100644 --- a/lib/teelib/libtimer/include/arm/generic_timer.h +++ b/lib/teelib/libtimer/include/arm/generic_timer.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: access generic timer - * Create: 2022-04-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTIMER_GENERIC_TIMER_H #define LIBTIMER_GENERIC_TIMER_H diff --git a/lib/teelib/libtimer/include/lib_timer.h b/lib/teelib/libtimer/include/lib_timer.h index 3445183c..d60c2bde 100644 --- a/lib/teelib/libtimer/include/lib_timer.h +++ b/lib/teelib/libtimer/include/lib_timer.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: moved from teeos, timer function - * Create: 2022-04-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTIMER_LIB_TIMER_H #define LIBTIMER_LIB_TIMER_H diff --git a/lib/teelib/libtimer/include/sre_sys.h b/lib/teelib/libtimer/include/sre_sys.h index 3c8df2b5..cbc058b8 100644 --- a/lib/teelib/libtimer/include/sre_sys.h +++ b/lib/teelib/libtimer/include/sre_sys.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: moved from teeos, timer function - * Create: 2022-04-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTIMER_SRE_SYS_H #define LIBTIMER_SRE_SYS_H diff --git a/lib/teelib/libtimer/include/sys_timer.h b/lib/teelib/libtimer/include/sys_timer.h index d516173c..618044b0 100755 --- a/lib/teelib/libtimer/include/sys_timer.h +++ b/lib/teelib/libtimer/include/sys_timer.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: moved from teeos, timer function - * Create: 2022-04-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTIMER_SYS_TIMER_H #define LIBTIMER_SYS_TIMER_H diff --git a/lib/teelib/libtimer/include/tee_gp_time_api.h b/lib/teelib/libtimer/include/tee_gp_time_api.h index e55541de..963fb825 100644 --- a/lib/teelib/libtimer/include/tee_gp_time_api.h +++ b/lib/teelib/libtimer/include/tee_gp_time_api.h @@ -1,17 +1,23 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: Header of gp time api - * Create: 2022-04-22 - */ - -#ifndef SYS_LIBS_LIBTIMER_GP_TIME_API_H -#define SYS_LIBS_LIBTIMER_GP_TIME_API_H -#include - -void TEE_GetSystemTime(TEE_Time *time); -void TEE_GetREETime(TEE_Time *time); -TEE_Result TEE_Wait(uint32_t mill_second); -TEE_Result TEE_SetTAPersistentTime(TEE_Time *time); -TEE_Result TEE_GetTAPersistentTime(TEE_Time *time); - +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#ifndef SYS_LIBS_LIBTIMER_GP_TIME_API_H +#define SYS_LIBS_LIBTIMER_GP_TIME_API_H +#include + +void TEE_GetSystemTime(TEE_Time *time); +void TEE_GetREETime(TEE_Time *time); +TEE_Result TEE_Wait(uint32_t mill_second); +TEE_Result TEE_SetTAPersistentTime(TEE_Time *time); +TEE_Result TEE_GetTAPersistentTime(TEE_Time *time); + #endif \ No newline at end of file diff --git a/lib/teelib/libtimer/include/tee_time_adapt.h b/lib/teelib/libtimer/include/tee_time_adapt.h index f486c1ba..84c2a03e 100644 --- a/lib/teelib/libtimer/include/tee_time_adapt.h +++ b/lib/teelib/libtimer/include/tee_time_adapt.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: rtc timer function - * Create: 2022-04-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTIMER_TIMER_ADAPT_H #define LIBTIMER_TIMER_ADAPT_H diff --git a/lib/teelib/libtimer/include/tee_time_defines.h b/lib/teelib/libtimer/include/tee_time_defines.h index 1a5dd57a..646df8f1 100644 --- a/lib/teelib/libtimer/include/tee_time_defines.h +++ b/lib/teelib/libtimer/include/tee_time_defines.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: moved from teeos, timer function - * Create: 2022-04-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTIMER_TIMER_DEFINES_H #define LIBTIMER_TIMER_DEFINES_H diff --git a/lib/teelib/libtimer/include/tee_time_event.h b/lib/teelib/libtimer/include/tee_time_event.h index 5fd847a3..fd3eff3f 100644 --- a/lib/teelib/libtimer/include/tee_time_event.h +++ b/lib/teelib/libtimer/include/tee_time_event.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: rtc timer function - * Create: 2022-04-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTIMER_TIMER_EVENT_H #define LIBTIMER_TIMER_EVENT_H diff --git a/lib/teelib/libtimer/include/tee_time_sleep.h b/lib/teelib/libtimer/include/tee_time_sleep.h index ce7ce580..3564c4bb 100644 --- a/lib/teelib/libtimer/include/tee_time_sleep.h +++ b/lib/teelib/libtimer/include/tee_time_sleep.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: rtc timer function - * Create: 2022-04-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTIMER_TIMER_SLEEP_H #define LIBTIMER_TIMER_SLEEP_H diff --git a/lib/teelib/libtimer/include/tee_time_sys.h b/lib/teelib/libtimer/include/tee_time_sys.h index 2ab4d7b3..5e196e66 100644 --- a/lib/teelib/libtimer/include/tee_time_sys.h +++ b/lib/teelib/libtimer/include/tee_time_sys.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: rtc timer function - * Create: 2022-04-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef LIBTIMER_TEE_TIME_SYS_H #define LIBTIMER_TEE_TIME_SYS_H diff --git a/lib/teelib/libtimer/include/timer.h b/lib/teelib/libtimer/include/timer.h index 0cee7d3c..a7a3b24f 100644 --- a/lib/teelib/libtimer/include/timer.h +++ b/lib/teelib/libtimer/include/timer.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: Header of timer - * Create: 2022-04-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef SYS_LIBS_LIBTIMER_TIMER_H diff --git a/lib/teelib/libtimer/include/timer_export.h b/lib/teelib/libtimer/include/timer_export.h index fe365bd1..dd0c5b3b 100644 --- a/lib/teelib/libtimer/include/timer_export.h +++ b/lib/teelib/libtimer/include/timer_export.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: Header file about timer export. - * Create: 2022-04-22 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef SYS_LIBS_LIBTIMER_TIMER_EXPORT_H diff --git a/lib/teelib/libtimer/src/tee_gp_time_api.c b/lib/teelib/libtimer/src/tee_gp_time_api.c index f9d2fbe4..eac81259 100644 --- a/lib/teelib/libtimer/src/tee_gp_time_api.c +++ b/lib/teelib/libtimer/src/tee_gp_time_api.c @@ -1,193 +1,199 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: gp time api define in this file. - * Create: 2022-04-22 - */ -#include -#include -#include -#include -#include -#include - -#define PERSISTENT_TIME_BASE_FILE "sec_storage/persistent_time" -#define POSITIVE_DIR 1 -#define NEGATIVE_DIR (-1) -struct time_offset { - int16_t dir; - uint32_t offset; - uint32_t base_sys_time; -}; - -void TEE_GetSystemTime(TEE_Time *time) -{ - struct timer_ops_t *time_ops = NULL; - uint64_t time_stamp; - - if (time == NULL) - return; - - time_ops = get_time_ops(); - if (time_ops == NULL) - return; - - time_stamp = time_ops->read_time_stamp(); - time->seconds = UPPER_32_BITS(time_stamp); - time->millis = LOWER_32_BITS(time_stamp) / NS_PER_MSEC; -} - -void TEE_GetREETime(TEE_Time *time) -{ - int32_t ret; - if (time == NULL) { - hm_error("invalid param\n"); - return; - } - - ret = get_time_of_data(&time->seconds, &time->millis, NULL, 0); - if (ret != TMR_OK) { - hm_error("get time of data failed\n"); - return; - } -} - -TEE_Result TEE_Wait(uint32_t mill_second) -{ - struct timer_ops_t *time_ops = NULL; - time_ops = get_time_ops(); - if (time_ops == NULL) - return TMR_ERR; - - return time_ops->sleep(mill_second); -} - -static uint32_t get_rtc_time(void) -{ - struct timer_ops_t *time_ops = NULL; - time_ops = get_time_ops(); - if (time_ops == NULL) - return TIMER_INV_VALUE; - - return time_ops->get_rtc_seconds(); -} - -TEE_Result TEE_SetTAPersistentTime(TEE_Time *time) -{ - struct time_offset offset_val = { 0 }; - uint32_t seconds; - TEE_Result ret; - TEE_ObjectHandle object = NULL; - - if (time == NULL) { - hm_error("invalid param\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - /* - * Get sys time from RTC:always increase even if power off. - * Use TEE_SetTAPersistentTime and TEE_GetTAPersistentTime - * to get the true time that has past. A typical usecase in DRM. - */ - seconds = get_rtc_time(); - if (seconds == TIMER_INV_VALUE) { - hm_error("Failed to get rtc time\n"); - return TEE_ERROR_TIME_NEEDS_RESET; - } - - offset_val.base_sys_time = seconds; - if (time->seconds >= seconds) { - offset_val.dir = POSITIVE_DIR; - offset_val.offset = time->seconds - seconds; - } else { - offset_val.dir = NEGATIVE_DIR; - offset_val.offset = seconds - time->seconds; - } - - ret = TEE_CreatePersistentObject(TEE_OBJECT_STORAGE_PRIVATE, PERSISTENT_TIME_BASE_FILE, - strlen(PERSISTENT_TIME_BASE_FILE), TEE_DATA_FLAG_ACCESS_WRITE, TEE_HANDLE_NULL, - &offset_val, sizeof(offset_val), &object); - if (ret != TEE_SUCCESS) { - hm_error("set TA persistent time error: ret is 0x%x\n", ret); - return ret; - } - - TEE_CloseObject(object); - return ret; -} - -static TEE_Result persistent_time_check(TEE_Time *time, const struct time_offset *offset_val) -{ - uint32_t seconds; - seconds = get_rtc_time(); - if (seconds == TIMER_INV_VALUE) { - hm_error("failed to get rtc time\n"); - return TEE_ERROR_TIME_NEEDS_RESET; - } - - if (seconds < offset_val->base_sys_time) { - hm_error("time rollback\n"); - return TEE_ERROR_TIME_NEEDS_RESET; - } - - /* - * millis is always 0, because rtc accuracy is 1s. - * Depends on GP spec, even if time overflow we should return the actually time. - */ - time->millis = 0; - if (offset_val->dir == NEGATIVE_DIR) { - time->seconds = seconds - offset_val->offset; - if (time->seconds > seconds) { - hm_error("persistent time overflow\n"); - return TEE_ERROR_OVERFLOW; - } - } else { - time->seconds = seconds + offset_val->offset; - if (time->seconds < seconds) { - hm_error("persistent time overflow\n"); - return TEE_ERROR_OVERFLOW; - } - } - - return TEE_SUCCESS; -} - -TEE_Result TEE_GetTAPersistentTime(TEE_Time *time) -{ - struct time_offset offset_val = { 0 }; - TEE_ObjectHandle object = NULL; - uint32_t count = 0; - TEE_Result ret; - - if (time == NULL) { - hm_error("invalid param\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - /* - * For an error different - * from TEE_ERROR_OVERFLOW, this placeholder is filled with zeros. - */ - time->seconds = 0; - time->millis = 0; - ret = TEE_OpenPersistentObject(TEE_OBJECT_STORAGE_PRIVATE, PERSISTENT_TIME_BASE_FILE, - strlen(PERSISTENT_TIME_BASE_FILE), TEE_DATA_FLAG_ACCESS_READ, &object); - if (ret != TEE_SUCCESS) { - hm_error("failed to open persistent object\n"); - return TEE_ERROR_TIME_NOT_SET; - } - - ret = TEE_ReadObjectData(object, &offset_val, sizeof(offset_val), &count); - TEE_CloseObject(object); - if ((ret != TEE_SUCCESS) || (count != sizeof(offset_val))) { - hm_error("read failed\n"); - return TEE_ERROR_TIME_NOT_SET; - } - - ret = persistent_time_check(time, &offset_val); - if (ret != TEE_SUCCESS) { - hm_error("failed to check\n"); - return ret; - } - - return TEE_SUCCESS; -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include +#include +#include +#include +#include +#include + +#define PERSISTENT_TIME_BASE_FILE "sec_storage/persistent_time" +#define POSITIVE_DIR 1 +#define NEGATIVE_DIR (-1) +struct time_offset { + int16_t dir; + uint32_t offset; + uint32_t base_sys_time; +}; + +void TEE_GetSystemTime(TEE_Time *time) +{ + struct timer_ops_t *time_ops = NULL; + uint64_t time_stamp; + + if (time == NULL) + return; + + time_ops = get_time_ops(); + if (time_ops == NULL) + return; + + time_stamp = time_ops->read_time_stamp(); + time->seconds = UPPER_32_BITS(time_stamp); + time->millis = LOWER_32_BITS(time_stamp) / NS_PER_MSEC; +} + +void TEE_GetREETime(TEE_Time *time) +{ + int32_t ret; + if (time == NULL) { + hm_error("invalid param\n"); + return; + } + + ret = get_time_of_data(&time->seconds, &time->millis, NULL, 0); + if (ret != TMR_OK) { + hm_error("get time of data failed\n"); + return; + } +} + +TEE_Result TEE_Wait(uint32_t mill_second) +{ + struct timer_ops_t *time_ops = NULL; + time_ops = get_time_ops(); + if (time_ops == NULL) + return TMR_ERR; + + return time_ops->sleep(mill_second); +} + +static uint32_t get_rtc_time(void) +{ + struct timer_ops_t *time_ops = NULL; + time_ops = get_time_ops(); + if (time_ops == NULL) + return TIMER_INV_VALUE; + + return time_ops->get_rtc_seconds(); +} + +TEE_Result TEE_SetTAPersistentTime(TEE_Time *time) +{ + struct time_offset offset_val = { 0 }; + uint32_t seconds; + TEE_Result ret; + TEE_ObjectHandle object = NULL; + + if (time == NULL) { + hm_error("invalid param\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + /* + * Get sys time from RTC:always increase even if power off. + * Use TEE_SetTAPersistentTime and TEE_GetTAPersistentTime + * to get the true time that has past. A typical usecase in DRM. + */ + seconds = get_rtc_time(); + if (seconds == TIMER_INV_VALUE) { + hm_error("Failed to get rtc time\n"); + return TEE_ERROR_TIME_NEEDS_RESET; + } + + offset_val.base_sys_time = seconds; + if (time->seconds >= seconds) { + offset_val.dir = POSITIVE_DIR; + offset_val.offset = time->seconds - seconds; + } else { + offset_val.dir = NEGATIVE_DIR; + offset_val.offset = seconds - time->seconds; + } + + ret = TEE_CreatePersistentObject(TEE_OBJECT_STORAGE_PRIVATE, PERSISTENT_TIME_BASE_FILE, + strlen(PERSISTENT_TIME_BASE_FILE), TEE_DATA_FLAG_ACCESS_WRITE, TEE_HANDLE_NULL, + &offset_val, sizeof(offset_val), &object); + if (ret != TEE_SUCCESS) { + hm_error("set TA persistent time error: ret is 0x%x\n", ret); + return ret; + } + + TEE_CloseObject(object); + return ret; +} + +static TEE_Result persistent_time_check(TEE_Time *time, const struct time_offset *offset_val) +{ + uint32_t seconds; + seconds = get_rtc_time(); + if (seconds == TIMER_INV_VALUE) { + hm_error("failed to get rtc time\n"); + return TEE_ERROR_TIME_NEEDS_RESET; + } + + if (seconds < offset_val->base_sys_time) { + hm_error("time rollback\n"); + return TEE_ERROR_TIME_NEEDS_RESET; + } + + /* + * millis is always 0, because rtc accuracy is 1s. + * Depends on GP spec, even if time overflow we should return the actually time. + */ + time->millis = 0; + if (offset_val->dir == NEGATIVE_DIR) { + time->seconds = seconds - offset_val->offset; + if (time->seconds > seconds) { + hm_error("persistent time overflow\n"); + return TEE_ERROR_OVERFLOW; + } + } else { + time->seconds = seconds + offset_val->offset; + if (time->seconds < seconds) { + hm_error("persistent time overflow\n"); + return TEE_ERROR_OVERFLOW; + } + } + + return TEE_SUCCESS; +} + +TEE_Result TEE_GetTAPersistentTime(TEE_Time *time) +{ + struct time_offset offset_val = { 0 }; + TEE_ObjectHandle object = NULL; + uint32_t count = 0; + TEE_Result ret; + + if (time == NULL) { + hm_error("invalid param\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + /* + * For an error different + * from TEE_ERROR_OVERFLOW, this placeholder is filled with zeros. + */ + time->seconds = 0; + time->millis = 0; + ret = TEE_OpenPersistentObject(TEE_OBJECT_STORAGE_PRIVATE, PERSISTENT_TIME_BASE_FILE, + strlen(PERSISTENT_TIME_BASE_FILE), TEE_DATA_FLAG_ACCESS_READ, &object); + if (ret != TEE_SUCCESS) { + hm_error("failed to open persistent object\n"); + return TEE_ERROR_TIME_NOT_SET; + } + + ret = TEE_ReadObjectData(object, &offset_val, sizeof(offset_val), &count); + TEE_CloseObject(object); + if ((ret != TEE_SUCCESS) || (count != sizeof(offset_val))) { + hm_error("read failed\n"); + return TEE_ERROR_TIME_NOT_SET; + } + + ret = persistent_time_check(time, &offset_val); + if (ret != TEE_SUCCESS) { + hm_error("failed to check\n"); + return ret; + } + + return TEE_SUCCESS; +} diff --git a/lib/teelib/libtimer/src/tee_time_event.c b/lib/teelib/libtimer/src/tee_time_event.c index c69d71c8..6f9527eb 100644 --- a/lib/teelib/libtimer/src/tee_time_event.c +++ b/lib/teelib/libtimer/src/tee_time_event.c @@ -1,68 +1,74 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: tee time event api define in this file. - * Create: 2022-04-22 - */ -#include -#include -#include - -timer_event *tee_time_event_create(sw_timer_event_handler handler, int32_t timer_class, void *priv_data) -{ - struct timer_ops_t *time_ops = NULL; - time_ops = get_time_ops(); - if (time_ops == NULL) - return NULL; - - return time_ops->time_event_create(handler, timer_class, priv_data); -} - -uint32_t tee_time_event_start(timer_event *t_event, timeval_t *time) -{ - struct timer_ops_t *time_ops = NULL; - time_ops = get_time_ops(); - if (time_ops == NULL) - return TMR_ERR; - - return time_ops->time_event_start(t_event, time); -} - -uint32_t tee_time_event_stop(timer_event *t_event) -{ - struct timer_ops_t *time_ops = NULL; - time_ops = get_time_ops(); - if (time_ops == NULL) - return TMR_ERR; - - return time_ops->time_event_stop(t_event); -} - -uint32_t tee_time_event_check(timer_notify_data_kernel *timer_data) -{ - struct timer_ops_t *time_ops = NULL; - time_ops = get_time_ops(); - if (time_ops == NULL) - return TMR_ERR; - - return time_ops->time_event_check(timer_data); -} - -uint64_t tee_time_event_get_expire(timer_event *t_event) -{ - struct timer_ops_t *time_ops = NULL; - time_ops = get_time_ops(); - if (time_ops == NULL) - return TMR_ERR; - - return time_ops->time_event_get_expire(t_event); -} - -uint32_t tee_time_event_destroy(timer_event *t_event) -{ - struct timer_ops_t *time_ops = NULL; - time_ops = get_time_ops(); - if (time_ops == NULL) - return TMR_ERR; - - return time_ops->time_event_destroy(t_event); -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include +#include +#include + +timer_event *tee_time_event_create(sw_timer_event_handler handler, int32_t timer_class, void *priv_data) +{ + struct timer_ops_t *time_ops = NULL; + time_ops = get_time_ops(); + if (time_ops == NULL) + return NULL; + + return time_ops->time_event_create(handler, timer_class, priv_data); +} + +uint32_t tee_time_event_start(timer_event *t_event, timeval_t *time) +{ + struct timer_ops_t *time_ops = NULL; + time_ops = get_time_ops(); + if (time_ops == NULL) + return TMR_ERR; + + return time_ops->time_event_start(t_event, time); +} + +uint32_t tee_time_event_stop(timer_event *t_event) +{ + struct timer_ops_t *time_ops = NULL; + time_ops = get_time_ops(); + if (time_ops == NULL) + return TMR_ERR; + + return time_ops->time_event_stop(t_event); +} + +uint32_t tee_time_event_check(timer_notify_data_kernel *timer_data) +{ + struct timer_ops_t *time_ops = NULL; + time_ops = get_time_ops(); + if (time_ops == NULL) + return TMR_ERR; + + return time_ops->time_event_check(timer_data); +} + +uint64_t tee_time_event_get_expire(timer_event *t_event) +{ + struct timer_ops_t *time_ops = NULL; + time_ops = get_time_ops(); + if (time_ops == NULL) + return TMR_ERR; + + return time_ops->time_event_get_expire(t_event); +} + +uint32_t tee_time_event_destroy(timer_event *t_event) +{ + struct timer_ops_t *time_ops = NULL; + time_ops = get_time_ops(); + if (time_ops == NULL) + return TMR_ERR; + + return time_ops->time_event_destroy(t_event); +} diff --git a/lib/teelib/libtimer/src/tee_time_sleep.c b/lib/teelib/libtimer/src/tee_time_sleep.c index 8073c432..c8de487d 100644 --- a/lib/teelib/libtimer/src/tee_time_sleep.c +++ b/lib/teelib/libtimer/src/tee_time_sleep.c @@ -1,54 +1,60 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: sleep time api define in this file. - * Create: 2022-04-22 - */ -#include -#include -#include -#include -#include - -#define MAX_SECONDS 0xFFFFFFFF - -void delay_us(uint32_t microseconds) -{ - uint64_t counts = 0; - uint64_t time_stamp; - uint64_t start_time; - uint64_t cur_time; - - if (microseconds > US_PER_SECONDS) { - hm_error("The value of microseconds is extend the range\n"); - return; - } - - struct timer_ops_t *time_ops = NULL; - time_ops = get_time_ops(); - if (time_ops == NULL) - return; - - time_stamp = time_ops->read_time_stamp(); - while (counts < microseconds) { - start_time = (uint64_t)UPPER_32_BITS(time_stamp) * US_PER_SECONDS + LOWER_32_BITS(time_stamp) / NS_PER_USEC; - time_stamp = time_ops->read_time_stamp(); - cur_time = (uint64_t)UPPER_32_BITS(time_stamp) * US_PER_SECONDS + LOWER_32_BITS(time_stamp) / NS_PER_USEC; - counts += cur_time - start_time; - } -} - -void delay_ms(uint32_t msec) -{ - delay_us(msec * US_PER_MSEC); -} - -uint32_t tee_msleep(uint32_t msec) -{ - if (msec > MS_PER_SECONDS) { - hm_error("The value of microseconds is extend the range\n"); - return TMR_ERR; - } - - delay_ms(msec); - return TMR_OK; -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include +#include +#include +#include +#include + +#define MAX_SECONDS 0xFFFFFFFF + +void delay_us(uint32_t microseconds) +{ + uint64_t counts = 0; + uint64_t time_stamp; + uint64_t start_time; + uint64_t cur_time; + + if (microseconds > US_PER_SECONDS) { + hm_error("The value of microseconds is extend the range\n"); + return; + } + + struct timer_ops_t *time_ops = NULL; + time_ops = get_time_ops(); + if (time_ops == NULL) + return; + + time_stamp = time_ops->read_time_stamp(); + while (counts < microseconds) { + start_time = (uint64_t)UPPER_32_BITS(time_stamp) * US_PER_SECONDS + LOWER_32_BITS(time_stamp) / NS_PER_USEC; + time_stamp = time_ops->read_time_stamp(); + cur_time = (uint64_t)UPPER_32_BITS(time_stamp) * US_PER_SECONDS + LOWER_32_BITS(time_stamp) / NS_PER_USEC; + counts += cur_time - start_time; + } +} + +void delay_ms(uint32_t msec) +{ + delay_us(msec * US_PER_MSEC); +} + +uint32_t tee_msleep(uint32_t msec) +{ + if (msec > MS_PER_SECONDS) { + hm_error("The value of microseconds is extend the range\n"); + return TMR_ERR; + } + + delay_ms(msec); + return TMR_OK; +} diff --git a/lib/teelib/libtimer/src/tee_time_sys.c b/lib/teelib/libtimer/src/tee_time_sys.c index bc3d862e..52e77f87 100644 --- a/lib/teelib/libtimer/src/tee_time_sys.c +++ b/lib/teelib/libtimer/src/tee_time_sys.c @@ -1,274 +1,280 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: sys time api define in this file. - * Create: 2022-04-22 - */ -#include -#include -#include -#include -#include -#include - -#define is_leap_year(year) ((((year) % 4 == 0) && ((year) % 100 != 0)) || ((year) % 400 == 0)) -#define leap_days_get(year) (((year) / 4) - ((year) / 100) + ((year) / 400)) - -static const uint32_t g_mon_lengths[][MONSPERYEAR] = { - { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, - { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } -}; -static const uint32_t g_year_lengths[] = { DAYSPERNYEAR, DAYSPERLYEAR }; - -int hm_timer_init(void) -{ - struct timer_ops_t *time_ops = NULL; - time_ops = get_time_ops(); - if (time_ops == NULL || time_ops->hm_timer_init == NULL) - return TMR_OK; - - return time_ops->hm_timer_init(); -} - -static uint32_t increment_overflow(uint32_t *year, uint32_t carry) -{ - if (carry > (UINT_MAX - *year)) { - hm_error("overflow, year=%u, carry=%u\n", *year, carry); - return TMR_ERR; - } - - *year += carry; - return TMR_OK; -} - -static uint32_t get_days_and_year(uint32_t *days, uint32_t *year) -{ - uint32_t ret; - uint32_t new_year; - uint32_t leap_days; - uint32_t carry_over; - - while (*days >= g_year_lengths[is_leap_year(*year)]) { - carry_over = *days / DAYSPERLYEAR; - if (carry_over == 0) - carry_over = 1; - - new_year = *year; - ret = increment_overflow(&new_year, carry_over); - if (ret != TMR_OK) - return TMR_ERR; - - leap_days = leap_days_get(new_year - 1) - leap_days_get(*year - 1); - if (new_year < *year) - return TMR_ERR; - *days -= (new_year - *year) * DAYSPERNYEAR; - *days -= leap_days; - *year = new_year; - } - - return TMR_OK; -} - -void gen_sys_date_time(const uint32_t rtc_time, struct tee_date_t *time) -{ - uint32_t seconds; - uint32_t tdays; - uint32_t idays; - uint32_t rem_secs; - uint32_t year; - const uint32_t *ip = NULL; - uint32_t ret; - - if (time == NULL) { - hm_error("Error:time is null\n"); - return; - } - - seconds = rtc_time; - year = EPOCH_YEAR; - tdays = seconds / SECSPERDAY; - rem_secs = seconds - tdays * SECSPERDAY; - - ret = get_days_and_year(&tdays, &year); - if (ret != TMR_OK) { - hm_error("failed to get the day and year\n"); - return; - } - - time->month = 0; - idays = tdays; - time->year = (int32_t)year; - time->hour = (int32_t)(rem_secs / SECSPERHOUR); - rem_secs %= SECSPERHOUR; - time->min = (int32_t)(rem_secs / SECSPERMIN); - time->seconds = (int32_t)(rem_secs % SECSPERMIN); - ip = g_mon_lengths[is_leap_year(year)]; - - for (int i = 0; i < MONSPERYEAR; i++) { - time->month++; - if (idays < ip[i]) - break; - idays -= ip[i]; - } - - time->day = (int32_t)(idays + 1); -} - -struct tm *hm_localtime_r(const time_t *restrict t, struct tm *restrict value) -{ - tee_date_time_kernel date_time; - - if ((value == NULL) || (t == NULL)) - return NULL; - - gen_sys_date_time((uint32_t)*t, &date_time); - - /* - * Shift tee_date_time_kernel to libc struct tm - * tm_year: Year - 1900, that's why we minus 1900 here. - * tm_mon: Month (0-11), that's why we minus 1 here. - * tm_wday: Days of the week, has not implemented yet(could not get from date_time). - * tm_yday: Days in the year, has not implemented yet(could not get from date_time). - */ - if (date_time.year == 0 || date_time.month == 0) { - hm_error("invalid parameters, please check\n"); - return NULL; - } - - value->tm_year = date_time.year - 1900; /* start year 1900 */ - value->tm_mon = date_time.month - 1; - value->tm_mday = date_time.day; - value->tm_hour = date_time.hour; - value->tm_min = date_time.min; - value->tm_sec = date_time.seconds; - value->tm_wday = 0; - value->tm_yday = 0; - value->tm_isdst = 0; - value->__tm_gmtoff = 0; - value->__tm_zone = NULL; - - return value; -} - -struct tm *__localtime_r(const time_t *restrict t, struct tm *restrict value) -{ - struct tm *tmp = NULL; -#ifdef __LP64__ - /* - * Reject time_t values whose year would overflow int because - * __secs_to_zone cannot safely handle them. - */ - if ((t != NULL) && ((*t < INT_MIN * MAX_SECONDS_PER_YEAR) || (*t > INT_MAX * MAX_SECONDS_PER_YEAR))) - return NULL; -#endif - - if (t == NULL || value == NULL) - return NULL; - - tmp = hm_localtime_r(t, value); - if (tmp == NULL) { - hm_error("localtime: get value is NULL\n"); - return NULL; - } - return value; -} - -struct tm *localtime(const time_t *t) -{ - static struct tm value; - return __localtime_r(t, &value); -} - -void get_sys_rtc_time(TEE_Time *time) -{ - struct timer_ops_t *time_ops = NULL; - if (time == NULL) { - hm_error("invalid param\n"); - return; - } - - time_ops = get_time_ops(); - if (time_ops == NULL) - return; - - time_ops->get_sys_rtc_time(time); -} - -void get_sys_date_time(tee_date_time_kernel *time_date) -{ - TEE_Time time; - get_sys_rtc_time(&time); - time.seconds += TIME_ZONE_EIGHT * SECSPERHOUR; /* CST */ - if (time_date != NULL) { - gen_sys_date_time(time.seconds, time_date); - time_date->millis = time.millis; - } -} - -uint32_t adjust_sys_time(const struct tee_time_t *time) -{ - struct timer_ops_t *time_ops = NULL; - if (time == NULL) { - hm_error("invalid param\n"); - return TMR_ERR; - } - - time_ops = get_time_ops(); - if (time_ops == NULL) - return TMR_OK; - - return time_ops->adjust_sys_time(time); -} - -void release_timer_event(const TEE_UUID *uuid) -{ - struct timer_ops_t *time_ops = NULL; - if (uuid == NULL) { - hm_error("invalid param\n"); - return; - } - - time_ops = get_time_ops(); - if (time_ops == NULL) - return; - - return time_ops->release_timer_event(uuid); -} - -int32_t set_ta_timer_permission(const TEE_UUID *uuid, uint64_t permission) -{ - struct timer_ops_t *time_ops = NULL; - if (uuid == NULL) { - hm_error("invalid param\n"); - return TMR_ERR; - } - - time_ops = get_time_ops(); - if (time_ops == NULL) - return TMR_ERR; - - return time_ops->set_ta_timer_permission(uuid, permission); -} - -void get_ree_time_str(char *time_str, uint32_t time_str_len) -{ - int32_t ret; - - if ((time_str == NULL) || (time_str_len == 0)) { - hm_error("invalid param\n"); - return; - } - - ret = get_time_of_data(NULL, NULL, time_str, time_str_len); - if (ret != TMR_OK) - hm_error("get time of data failed\n"); -} - -uint64_t tee_read_time_stamp(void) -{ - struct timer_ops_t *time_ops = NULL; - time_ops = get_time_ops(); - if (time_ops == NULL) - return TMR_ERR; - - return time_ops->read_time_stamp(); -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include +#include +#include +#include +#include +#include + +#define is_leap_year(year) ((((year) % 4 == 0) && ((year) % 100 != 0)) || ((year) % 400 == 0)) +#define leap_days_get(year) (((year) / 4) - ((year) / 100) + ((year) / 400)) + +static const uint32_t g_mon_lengths[][MONSPERYEAR] = { + { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, + { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } +}; +static const uint32_t g_year_lengths[] = { DAYSPERNYEAR, DAYSPERLYEAR }; + +int hm_timer_init(void) +{ + struct timer_ops_t *time_ops = NULL; + time_ops = get_time_ops(); + if (time_ops == NULL || time_ops->hm_timer_init == NULL) + return TMR_OK; + + return time_ops->hm_timer_init(); +} + +static uint32_t increment_overflow(uint32_t *year, uint32_t carry) +{ + if (carry > (UINT_MAX - *year)) { + hm_error("overflow, year=%u, carry=%u\n", *year, carry); + return TMR_ERR; + } + + *year += carry; + return TMR_OK; +} + +static uint32_t get_days_and_year(uint32_t *days, uint32_t *year) +{ + uint32_t ret; + uint32_t new_year; + uint32_t leap_days; + uint32_t carry_over; + + while (*days >= g_year_lengths[is_leap_year(*year)]) { + carry_over = *days / DAYSPERLYEAR; + if (carry_over == 0) + carry_over = 1; + + new_year = *year; + ret = increment_overflow(&new_year, carry_over); + if (ret != TMR_OK) + return TMR_ERR; + + leap_days = leap_days_get(new_year - 1) - leap_days_get(*year - 1); + if (new_year < *year) + return TMR_ERR; + *days -= (new_year - *year) * DAYSPERNYEAR; + *days -= leap_days; + *year = new_year; + } + + return TMR_OK; +} + +void gen_sys_date_time(const uint32_t rtc_time, struct tee_date_t *time) +{ + uint32_t seconds; + uint32_t tdays; + uint32_t idays; + uint32_t rem_secs; + uint32_t year; + const uint32_t *ip = NULL; + uint32_t ret; + + if (time == NULL) { + hm_error("Error:time is null\n"); + return; + } + + seconds = rtc_time; + year = EPOCH_YEAR; + tdays = seconds / SECSPERDAY; + rem_secs = seconds - tdays * SECSPERDAY; + + ret = get_days_and_year(&tdays, &year); + if (ret != TMR_OK) { + hm_error("failed to get the day and year\n"); + return; + } + + time->month = 0; + idays = tdays; + time->year = (int32_t)year; + time->hour = (int32_t)(rem_secs / SECSPERHOUR); + rem_secs %= SECSPERHOUR; + time->min = (int32_t)(rem_secs / SECSPERMIN); + time->seconds = (int32_t)(rem_secs % SECSPERMIN); + ip = g_mon_lengths[is_leap_year(year)]; + + for (int i = 0; i < MONSPERYEAR; i++) { + time->month++; + if (idays < ip[i]) + break; + idays -= ip[i]; + } + + time->day = (int32_t)(idays + 1); +} + +struct tm *hm_localtime_r(const time_t *restrict t, struct tm *restrict value) +{ + tee_date_time_kernel date_time; + + if ((value == NULL) || (t == NULL)) + return NULL; + + gen_sys_date_time((uint32_t)*t, &date_time); + + /* + * Shift tee_date_time_kernel to libc struct tm + * tm_year: Year - 1900, that's why we minus 1900 here. + * tm_mon: Month (0-11), that's why we minus 1 here. + * tm_wday: Days of the week, has not implemented yet(could not get from date_time). + * tm_yday: Days in the year, has not implemented yet(could not get from date_time). + */ + if (date_time.year == 0 || date_time.month == 0) { + hm_error("invalid parameters, please check\n"); + return NULL; + } + + value->tm_year = date_time.year - 1900; /* start year 1900 */ + value->tm_mon = date_time.month - 1; + value->tm_mday = date_time.day; + value->tm_hour = date_time.hour; + value->tm_min = date_time.min; + value->tm_sec = date_time.seconds; + value->tm_wday = 0; + value->tm_yday = 0; + value->tm_isdst = 0; + value->__tm_gmtoff = 0; + value->__tm_zone = NULL; + + return value; +} + +struct tm *__localtime_r(const time_t *restrict t, struct tm *restrict value) +{ + struct tm *tmp = NULL; +#ifdef __LP64__ + /* + * Reject time_t values whose year would overflow int because + * __secs_to_zone cannot safely handle them. + */ + if ((t != NULL) && ((*t < INT_MIN * MAX_SECONDS_PER_YEAR) || (*t > INT_MAX * MAX_SECONDS_PER_YEAR))) + return NULL; +#endif + + if (t == NULL || value == NULL) + return NULL; + + tmp = hm_localtime_r(t, value); + if (tmp == NULL) { + hm_error("localtime: get value is NULL\n"); + return NULL; + } + return value; +} + +struct tm *localtime(const time_t *t) +{ + static struct tm value; + return __localtime_r(t, &value); +} + +void get_sys_rtc_time(TEE_Time *time) +{ + struct timer_ops_t *time_ops = NULL; + if (time == NULL) { + hm_error("invalid param\n"); + return; + } + + time_ops = get_time_ops(); + if (time_ops == NULL) + return; + + time_ops->get_sys_rtc_time(time); +} + +void get_sys_date_time(tee_date_time_kernel *time_date) +{ + TEE_Time time; + get_sys_rtc_time(&time); + time.seconds += TIME_ZONE_EIGHT * SECSPERHOUR; /* CST */ + if (time_date != NULL) { + gen_sys_date_time(time.seconds, time_date); + time_date->millis = time.millis; + } +} + +uint32_t adjust_sys_time(const struct tee_time_t *time) +{ + struct timer_ops_t *time_ops = NULL; + if (time == NULL) { + hm_error("invalid param\n"); + return TMR_ERR; + } + + time_ops = get_time_ops(); + if (time_ops == NULL) + return TMR_OK; + + return time_ops->adjust_sys_time(time); +} + +void release_timer_event(const TEE_UUID *uuid) +{ + struct timer_ops_t *time_ops = NULL; + if (uuid == NULL) { + hm_error("invalid param\n"); + return; + } + + time_ops = get_time_ops(); + if (time_ops == NULL) + return; + + return time_ops->release_timer_event(uuid); +} + +int32_t set_ta_timer_permission(const TEE_UUID *uuid, uint64_t permission) +{ + struct timer_ops_t *time_ops = NULL; + if (uuid == NULL) { + hm_error("invalid param\n"); + return TMR_ERR; + } + + time_ops = get_time_ops(); + if (time_ops == NULL) + return TMR_ERR; + + return time_ops->set_ta_timer_permission(uuid, permission); +} + +void get_ree_time_str(char *time_str, uint32_t time_str_len) +{ + int32_t ret; + + if ((time_str == NULL) || (time_str_len == 0)) { + hm_error("invalid param\n"); + return; + } + + ret = get_time_of_data(NULL, NULL, time_str, time_str_len); + if (ret != TMR_OK) + hm_error("get time of data failed\n"); +} + +uint64_t tee_read_time_stamp(void) +{ + struct timer_ops_t *time_ops = NULL; + time_ops = get_time_ops(); + if (time_ops == NULL) + return TMR_ERR; + + return time_ops->read_time_stamp(); +} diff --git a/lib/teelib/libtimer/src/timer_adapt/tee_generic_timer_adapt.c b/lib/teelib/libtimer/src/timer_adapt/tee_generic_timer_adapt.c index 92247da6..fe8f24a0 100644 --- a/lib/teelib/libtimer/src/timer_adapt/tee_generic_timer_adapt.c +++ b/lib/teelib/libtimer/src/timer_adapt/tee_generic_timer_adapt.c @@ -1,535 +1,541 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: arch timer adapt api define in this file. - * Create: 2022-04-22 - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -enum classic_timer_msg { - CREATE_TIMER, - START_TIMER, - STOP_TIMER, - DESTORY_TIMER, - TIMER_OPS_SUCCESS, - TIMER_OPS_FAIL, -}; - -struct timer_event_msg { - hm_msg_header hdr; -}; - -static struct tee_time_t g_rtc_offset; - -static uint64_t tee_read_time_stamp(void) -{ - uint64_t cur_count; - uint32_t freq; - uint64_t timestamp; - uint32_t sec; - uint32_t nsec; - - cur_count = get_cntpct_el0(); - freq = get_cntfrq_el0(); - if (freq == 0) - return TIMER_INV_VALUE; - - sec = cur_count / freq; - nsec = ((cur_count % freq) * NS_PER_SECONDS) / freq; - timestamp = ((uint64_t)sec << SHIFT_32) + nsec; - return timestamp; -} - -static uint32_t tee_sleep(msec) -{ - TEE_Result ret; - cref_t timer_ref; - - timer_ref = hm_create_timer(); - if (is_ref_err(timer_ref)) - return ref_to_err(timer_ref); - - ret = hm_timer_start(timer_ref, msec); - hm_delete_timer(timer_ref); - return ret; -} - -static int64_t timer_value_add(const timeval_t *time_val_1, const timeval_t *time_val_2) -{ - timeval_t time_val_sum; - - if (time_val_1 == NULL || time_val_2 == NULL) { - hm_error("invlid param\n"); - return TIMEVAL_MAX; - } - - if ((time_val_1->tval64 > 0 && time_val_2->tval64 > 0 && INT64_MAX - time_val_1->tval64 < time_val_2->tval64) || - (time_val_1->tval64 < 0 && time_val_2->tval64 < 0 && INT64_MIN - time_val_1->tval64 > time_val_2->tval64)) { - hm_error("Time value add result overflow\n"); - return TIMEVAL_MAX; - } - - if ((time_val_1->tval.nsec >= NS_PER_SECONDS) || (time_val_2->tval.nsec >= NS_PER_SECONDS)) { - hm_warn("timer value add:invalid nsec value\n"); - time_val_sum.tval.sec = time_val_1->tval.sec + time_val_2->tval.sec; - time_val_sum.tval.nsec = 0; - } else { - time_val_sum.tval64 = time_val_1->tval64 + time_val_2->tval64; - if (time_val_sum.tval.nsec > (NS_PER_SECONDS - 1)) { - time_val_sum.tval.nsec -= NS_PER_SECONDS; - time_val_sum.tval.sec += 1; - } - } - - return time_val_sum.tval64; -} - -static int64_t timer_value_sub(const timeval_t *time_val_1, const timeval_t *time_val_2) -{ - timeval_t time_val_sub; - - if ((time_val_1 == NULL) || (time_val_2 == NULL)) - return TIMER_INV_VALUE; - - if ((time_val_1->tval64 > 0 && time_val_2->tval64 < 0 && INT64_MAX + time_val_2->tval64 < time_val_1->tval64) || - (time_val_1->tval64 < 0 && time_val_2->tval64 > 0 && INT64_MIN + time_val_2->tval64 > time_val_1->tval64)) { - hm_error("Time value sub result overflow\n"); - return TIMER_INV_VALUE; - } - - if ((time_val_1->tval.nsec >= NS_PER_SECONDS) || (time_val_2->tval.nsec >= NS_PER_SECONDS)) { - hm_warn("timer value sub:invalid nsec value\n"); - time_val_sub.tval.sec = time_val_1->tval.sec - time_val_2->tval.sec; - time_val_sub.tval.nsec = 0; - } else { - time_val_sub.tval64 = time_val_1->tval64 - time_val_2->tval64; - if (time_val_sub.tval.nsec < 0) - time_val_sub.tval.nsec += NS_PER_SECONDS; - } - - return time_val_sub.tval64; -} - -static int32_t get_timeout_value(int32_t status, timer_event *t_event) -{ - int32_t mills = HM_NO_TIMEOUT; - timeval_t current_time; - timeval_t expire_time; - timeval_t diff_time; - - if (status == START_TIMER) { - t_event->state = TIMER_STATE_ACTIVE; - current_time.tval64 = tee_read_time_stamp(); - expire_time.tval64 = t_event->expires.tval64; - diff_time.tval64 = timer_value_sub(&expire_time, ¤t_time); - if (diff_time.tval.sec < 0) { - mills = 1; - } else { - mills = diff_time.tval.sec * MS_PER_SECONDS + diff_time.tval.nsec / NS_PER_MSEC; - mills = mills > 0 ? mills : HM_NO_TIMEOUT; - } - } - return mills; -} - -static void classic_thread_reply(int32_t status, const timer_event *t_event, cref_t msg_hdl) -{ - int32_t ret; - struct timer_event_msg rsp_msg = {{{ 0 }}}; - - rsp_msg.hdr.send.msg_id = TIMER_OPS_SUCCESS; - if (status == STOP_TIMER && t_event->state == TIMER_STATE_EXECUTING) - rsp_msg.hdr.send.msg_id = TIMER_OPS_FAIL; - - ret = hm_msg_reply(msg_hdl, &rsp_msg, sizeof(rsp_msg)); - if (ret != TMR_OK) - hm_error("classic timer reply fail\n"); -} - -static int32_t get_time_event_status(uint32_t state) -{ - int32_t status; - if (state == TIMER_STATE_ACTIVE) - status = START_TIMER; - else if (state == TIMER_STATE_INACTIVE) - status = STOP_TIMER; - else if (state == TIMER_STATE_DESTROY) - status = DESTORY_TIMER; - else - status = CREATE_TIMER; - return status; -} - -static void *classic_thread(void *arg) -{ - int32_t ret; - uint32_t mills = HM_NO_TIMEOUT; - int32_t status = CREATE_TIMER; - timer_event *t_event = (timer_event*)arg; - struct channel_ipc_args ipc_args = { 0 }; - struct timer_event_msg req_msg = {{{ 0 }}}; - - if (t_event == NULL) { - hm_error("invalid timer event\n"); - return NULL; - } - - cref_t msg_hdl = hmapi_create_message(); - if (is_ref_err(msg_hdl)) { - hm_error("create message failed\n"); - return NULL; - } - - t_event->pid = (int32_t)get_selfpid(); - ipc_args.channel = t_event->timer_channel; - ipc_args.recv_buf = &req_msg; - ipc_args.recv_len = sizeof(req_msg); - while (status != DESTORY_TIMER) { - ret = hmapi_recv_timeout(&ipc_args, &msg_hdl, CREF_NULL, mills, NULL); - if (ret != TMR_OK && ret != E_EX_TIMER_TIMEOUT) { - (void)hmapi_delete_obj(msg_hdl); - return NULL; - } - - if (ret == E_EX_TIMER_TIMEOUT && t_event->state == TIMER_STATE_ACTIVE && t_event->handler != NULL) { - t_event->state = TIMER_STATE_EXECUTING; - t_event->handler(t_event->data); - status = get_time_event_status(t_event->state); - } else if (ret == TMR_OK) { - status = req_msg.hdr.send.msg_id; - } - - mills = get_timeout_value(status, t_event); - if (status == START_TIMER) - t_event->state = TIMER_STATE_ACTIVE; - else if (status == STOP_TIMER && t_event->state != TIMER_STATE_EXECUTING) - t_event->state = TIMER_STATE_INACTIVE; - - if (ret == TMR_OK) - classic_thread_reply(status, t_event, msg_hdl); - } - - ret = hmapi_delete_obj(msg_hdl); - if (ret != TMR_OK) - hm_error("delete obj failed!\n"); - return NULL; -} - -static uint32_t classic_thread_create(timer_event *t_event) -{ - pthread_attr_t thread_attr; - int32_t ret; - pthread_t thread_id; - - ret = pthread_attr_init(&thread_attr); - if (ret != TMR_OK) { - hm_error("init failed %d\n", ret); - return ret; - } - - ret = pthread_create(&thread_id, &thread_attr, classic_thread, t_event); - if (ret != TMR_OK) { - (void)pthread_attr_destroy(&thread_attr); - hm_error("create failed %d\n", ret); - return ret; - } - - ret = pthread_attr_destroy(&thread_attr); - if (ret != TMR_OK) { - hm_error("destory failed: err=%d\n", ret); - return ret; - } - - return TMR_OK; -} - -static timer_event *tee_classic_timer_event_create(sw_timer_event_handler handler, - int32_t timer_class, void *priv_data) -{ - uint32_t ret; - timer_event *t_event = NULL; - cref_t timer_channel; - - if (handler == NULL) { - hm_error("bad parameters\n"); - return NULL; - } - - t_event = TEE_Malloc(sizeof(*t_event), 0); - if (t_event == NULL) { - hm_error("no enough memory\n"); - return NULL; - } - - timer_channel = hm_msg_channel_create(); - if (is_ref_err(timer_channel) != TMR_OK) { - TEE_Free(t_event); - return NULL; - } - - t_event->timer_class = timer_class; - t_event->state = TIMER_STATE_INACTIVE; - t_event->timer_channel = timer_channel; - t_event->expires.tval64 = 0; - t_event->handler = handler; - t_event->data = priv_data; - - ret = classic_thread_create(t_event); - if (ret != TMR_OK) { - (void)hm_msg_channel_remove(t_event->timer_channel); - TEE_Free(t_event); - hm_error("create classic thread fail\n"); - return NULL; - } - - return t_event; -} - -static timer_event *tee_time_event_create(sw_timer_event_handler handler, int32_t timer_class, void *priv_data) -{ - if (handler == NULL || timer_class != TIMER_CLASSIC) { - hm_error("bad param\n"); - return NULL; - } - - return tee_classic_timer_event_create(handler, TIMER_CLASSIC, priv_data); -} - -static uint32_t tee_classic_timer_event_start(timer_event *t_event, timeval_t *time) -{ - uint32_t ret; - timeval_t current_time; - timeval_t expire_time; - struct timer_event_msg req_msg = {{{ 0 }}}; - struct timer_event_msg rsp_msg = {{{ 0 }}}; - req_msg.hdr.send.msg_id = START_TIMER; - - if ((time->tval.nsec > (NS_PER_SECONDS - 1)) || (time->tval.nsec < 0) || - (time->tval.sec < 0) || - (time->tval.sec == 0 && time->tval.nsec == 0)) - return TMR_ERR; - - if (t_event->state == TIMER_STATE_ACTIVE) - return TMR_ERR; - - current_time.tval64 = tee_read_time_stamp(); - expire_time.tval64 = timer_value_add(¤t_time, time); - t_event->state = TIMER_STATE_ACTIVE; - t_event->expires.tval64 = expire_time.tval64; - - if (t_event->pid == (int32_t)get_selfpid()) - return TMR_OK; - - ret = hm_msg_call(t_event->timer_channel, &req_msg, sizeof(req_msg), &rsp_msg, sizeof(rsp_msg), 0, HM_NO_TIMEOUT); - if (ret != TMR_OK || rsp_msg.hdr.send.msg_id != TIMER_OPS_SUCCESS) { - ret = TMR_ERR; - hm_error("start timer event fail\n"); - } - - return ret; -} - -static uint32_t tee_time_event_start(timer_event *t_event, timeval_t *time) -{ - if (t_event == NULL || time == NULL) { - hm_error("bad parameters\n"); - return TMR_ERR; - } - - return tee_classic_timer_event_start(t_event, time); -} - -static uint32_t tee_classic_timer_event_stop(timer_event *t_event) -{ - uint32_t ret; - struct timer_event_msg req_msg = {{{ 0 }}}; - struct timer_event_msg rsp_msg = {{{ 0 }}}; - req_msg.hdr.send.msg_id = STOP_TIMER; - - if (t_event->state != TIMER_STATE_ACTIVE) - return TMR_ERR; - - t_event->state = TIMER_STATE_INACTIVE; - if (t_event->pid == (int32_t)get_selfpid()) - return TMR_OK; - - ret = hm_msg_call(t_event->timer_channel, &req_msg, sizeof(req_msg), &rsp_msg, sizeof(rsp_msg), 0, HM_NO_TIMEOUT); - if (ret != TMR_OK || rsp_msg.hdr.send.msg_id != TIMER_OPS_SUCCESS) { - ret = TMR_ERR; - hm_error("stop timer event fail\n"); - } - - return ret; -} - -static uint32_t tee_time_event_stop(timer_event *t_event) -{ - if (t_event == NULL) { - hm_error("bad parameters\n"); - return TMR_ERR; - } - - return tee_classic_timer_event_stop(t_event); -} - -static uint32_t tee_classic_timer_event_destroy(timer_event *t_event) -{ - int32_t ret; - struct timer_event_msg req_msg = {{{ 0 }}}; - struct timer_event_msg rsp_msg = {{{ 0 }}}; - req_msg.hdr.send.msg_id = DESTORY_TIMER; - - if (t_event->state != TIMER_STATE_INACTIVE && t_event->state != TIMER_STATE_EXECUTING) { - hm_error("invalid timer event state %d\n", t_event->state); - return TMR_ERR; - } - - if (t_event->pid == (int32_t)get_selfpid()) { - ret = TMR_OK; - } else { - ret = hm_msg_call(t_event->timer_channel, &req_msg, sizeof(req_msg), - &rsp_msg, sizeof(rsp_msg), 0, HM_NO_TIMEOUT); - if (ret != TMR_OK || rsp_msg.hdr.send.msg_id != TIMER_OPS_SUCCESS) - hm_error("stop timer event fail\n"); - } - - if (hm_msg_channel_remove(t_event->timer_channel)) - hm_error("channel remove failed\n"); - - (void)memset_s(t_event, sizeof(*t_event), 0, sizeof(*t_event)); - TEE_Free(t_event); - return ret; -} - -static uint32_t tee_time_event_destroy(timer_event *t_event) -{ - if (t_event == NULL) { - hm_error("bad parameters\n"); - return TMR_ERR; - } - - return tee_classic_timer_event_destroy(t_event); -} - -static uint64_t tee_time_event_get_expire(timer_event *t_event) -{ - if (t_event == NULL) { - hm_error("bad parameters\n"); - return TIMER_INV_VALUE; - } - - return t_event->expires.tval64; -} - -static uint32_t tee_time_event_check(timer_notify_data_kernel *timer_data) -{ - if (timer_data == NULL) { - hm_error("bad parameters\n"); - return TMR_ERR; - } - - return TMR_OK; -} - -static uint32_t tee_get_secure_rtc_time(void) -{ - timeval_t cur_time; - cur_time.tval64 = tee_read_time_stamp(); - return cur_time.tval.sec; -} - -static void tee_release_timer_event(const TEE_UUID *uuid) -{ - (void)uuid; - return; -} - -static int32_t tee_set_ta_timer_permission(const TEE_UUID *uuid, uint64_t permission) -{ - (void)uuid; - (void)permission; - return TMR_OK; -} - -static uint32_t tee_adjust_sys_time(const struct tee_time_t *time) -{ - if (time == NULL) { - hm_error("time is NULL\n"); - return TMR_ERR; - } - - return TMR_OK; -} - -static void tee_get_system_time(TEE_Time *time) -{ - uint64_t time_value; - - if (time == NULL) { - hm_error("invalid param\n"); - return; - } - - time_value = tee_read_time_stamp(); - if (time_value == 0) { - hm_error("time value is zero\n"); - return; - } - - time->seconds = UPPER_32_BITS(time_value); - time->millis = LOWER_32_BITS(time_value) / NS_PER_MSEC; -} - -static void tee_get_sys_rtc_time(TEE_Time *time) -{ - TEE_Time cur_time; - if (time == NULL) { - hm_error("invalid param\n"); - return; - } - - hm_timer_get_offset(&g_rtc_offset.seconds, &g_rtc_offset.millis); - tee_get_system_time(&cur_time); - - if (cur_time.millis + (uint32_t)g_rtc_offset.millis > MS_PER_SECONDS) { - cur_time.seconds += (uint32_t)(g_rtc_offset.seconds + 1); - cur_time.millis += (uint32_t)(g_rtc_offset.millis - MS_PER_SECONDS); - } else { - cur_time.seconds += (uint32_t)g_rtc_offset.seconds; - cur_time.millis += (uint32_t)g_rtc_offset.millis; - } - - time->seconds = (uint32_t)cur_time.seconds; - time->millis = (uint32_t)cur_time.millis; -} - -struct timer_ops_t g_timer_ops = { - tee_read_time_stamp, - tee_get_sys_rtc_time, - tee_get_secure_rtc_time, - tee_sleep, - tee_time_event_create, - tee_time_event_destroy, - tee_time_event_start, - tee_time_event_stop, - tee_time_event_get_expire, - tee_time_event_check, - tee_release_timer_event, - tee_set_ta_timer_permission, - tee_adjust_sys_time, - NULL, - NULL, -}; - -struct timer_ops_t *get_time_ops(void) -{ - return &g_timer_ops; -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum classic_timer_msg { + CREATE_TIMER, + START_TIMER, + STOP_TIMER, + DESTORY_TIMER, + TIMER_OPS_SUCCESS, + TIMER_OPS_FAIL, +}; + +struct timer_event_msg { + hm_msg_header hdr; +}; + +static struct tee_time_t g_rtc_offset; + +static uint64_t tee_read_time_stamp(void) +{ + uint64_t cur_count; + uint32_t freq; + uint64_t timestamp; + uint32_t sec; + uint32_t nsec; + + cur_count = get_cntpct_el0(); + freq = get_cntfrq_el0(); + if (freq == 0) + return TIMER_INV_VALUE; + + sec = cur_count / freq; + nsec = ((cur_count % freq) * NS_PER_SECONDS) / freq; + timestamp = ((uint64_t)sec << SHIFT_32) + nsec; + return timestamp; +} + +static uint32_t tee_sleep(msec) +{ + TEE_Result ret; + cref_t timer_ref; + + timer_ref = hm_create_timer(); + if (is_ref_err(timer_ref)) + return ref_to_err(timer_ref); + + ret = hm_timer_start(timer_ref, msec); + hm_delete_timer(timer_ref); + return ret; +} + +static int64_t timer_value_add(const timeval_t *time_val_1, const timeval_t *time_val_2) +{ + timeval_t time_val_sum; + + if (time_val_1 == NULL || time_val_2 == NULL) { + hm_error("invlid param\n"); + return TIMEVAL_MAX; + } + + if ((time_val_1->tval64 > 0 && time_val_2->tval64 > 0 && INT64_MAX - time_val_1->tval64 < time_val_2->tval64) || + (time_val_1->tval64 < 0 && time_val_2->tval64 < 0 && INT64_MIN - time_val_1->tval64 > time_val_2->tval64)) { + hm_error("Time value add result overflow\n"); + return TIMEVAL_MAX; + } + + if ((time_val_1->tval.nsec >= NS_PER_SECONDS) || (time_val_2->tval.nsec >= NS_PER_SECONDS)) { + hm_warn("timer value add:invalid nsec value\n"); + time_val_sum.tval.sec = time_val_1->tval.sec + time_val_2->tval.sec; + time_val_sum.tval.nsec = 0; + } else { + time_val_sum.tval64 = time_val_1->tval64 + time_val_2->tval64; + if (time_val_sum.tval.nsec > (NS_PER_SECONDS - 1)) { + time_val_sum.tval.nsec -= NS_PER_SECONDS; + time_val_sum.tval.sec += 1; + } + } + + return time_val_sum.tval64; +} + +static int64_t timer_value_sub(const timeval_t *time_val_1, const timeval_t *time_val_2) +{ + timeval_t time_val_sub; + + if ((time_val_1 == NULL) || (time_val_2 == NULL)) + return TIMER_INV_VALUE; + + if ((time_val_1->tval64 > 0 && time_val_2->tval64 < 0 && INT64_MAX + time_val_2->tval64 < time_val_1->tval64) || + (time_val_1->tval64 < 0 && time_val_2->tval64 > 0 && INT64_MIN + time_val_2->tval64 > time_val_1->tval64)) { + hm_error("Time value sub result overflow\n"); + return TIMER_INV_VALUE; + } + + if ((time_val_1->tval.nsec >= NS_PER_SECONDS) || (time_val_2->tval.nsec >= NS_PER_SECONDS)) { + hm_warn("timer value sub:invalid nsec value\n"); + time_val_sub.tval.sec = time_val_1->tval.sec - time_val_2->tval.sec; + time_val_sub.tval.nsec = 0; + } else { + time_val_sub.tval64 = time_val_1->tval64 - time_val_2->tval64; + if (time_val_sub.tval.nsec < 0) + time_val_sub.tval.nsec += NS_PER_SECONDS; + } + + return time_val_sub.tval64; +} + +static int32_t get_timeout_value(int32_t status, timer_event *t_event) +{ + int32_t mills = HM_NO_TIMEOUT; + timeval_t current_time; + timeval_t expire_time; + timeval_t diff_time; + + if (status == START_TIMER) { + t_event->state = TIMER_STATE_ACTIVE; + current_time.tval64 = tee_read_time_stamp(); + expire_time.tval64 = t_event->expires.tval64; + diff_time.tval64 = timer_value_sub(&expire_time, ¤t_time); + if (diff_time.tval.sec < 0) { + mills = 1; + } else { + mills = diff_time.tval.sec * MS_PER_SECONDS + diff_time.tval.nsec / NS_PER_MSEC; + mills = mills > 0 ? mills : HM_NO_TIMEOUT; + } + } + return mills; +} + +static void classic_thread_reply(int32_t status, const timer_event *t_event, cref_t msg_hdl) +{ + int32_t ret; + struct timer_event_msg rsp_msg = {{{ 0 }}}; + + rsp_msg.hdr.send.msg_id = TIMER_OPS_SUCCESS; + if (status == STOP_TIMER && t_event->state == TIMER_STATE_EXECUTING) + rsp_msg.hdr.send.msg_id = TIMER_OPS_FAIL; + + ret = hm_msg_reply(msg_hdl, &rsp_msg, sizeof(rsp_msg)); + if (ret != TMR_OK) + hm_error("classic timer reply fail\n"); +} + +static int32_t get_time_event_status(uint32_t state) +{ + int32_t status; + if (state == TIMER_STATE_ACTIVE) + status = START_TIMER; + else if (state == TIMER_STATE_INACTIVE) + status = STOP_TIMER; + else if (state == TIMER_STATE_DESTROY) + status = DESTORY_TIMER; + else + status = CREATE_TIMER; + return status; +} + +static void *classic_thread(void *arg) +{ + int32_t ret; + uint32_t mills = HM_NO_TIMEOUT; + int32_t status = CREATE_TIMER; + timer_event *t_event = (timer_event*)arg; + struct channel_ipc_args ipc_args = { 0 }; + struct timer_event_msg req_msg = {{{ 0 }}}; + + if (t_event == NULL) { + hm_error("invalid timer event\n"); + return NULL; + } + + cref_t msg_hdl = hmapi_create_message(); + if (is_ref_err(msg_hdl)) { + hm_error("create message failed\n"); + return NULL; + } + + t_event->pid = (int32_t)get_selfpid(); + ipc_args.channel = t_event->timer_channel; + ipc_args.recv_buf = &req_msg; + ipc_args.recv_len = sizeof(req_msg); + while (status != DESTORY_TIMER) { + ret = hmapi_recv_timeout(&ipc_args, &msg_hdl, CREF_NULL, mills, NULL); + if (ret != TMR_OK && ret != E_EX_TIMER_TIMEOUT) { + (void)hmapi_delete_obj(msg_hdl); + return NULL; + } + + if (ret == E_EX_TIMER_TIMEOUT && t_event->state == TIMER_STATE_ACTIVE && t_event->handler != NULL) { + t_event->state = TIMER_STATE_EXECUTING; + t_event->handler(t_event->data); + status = get_time_event_status(t_event->state); + } else if (ret == TMR_OK) { + status = req_msg.hdr.send.msg_id; + } + + mills = get_timeout_value(status, t_event); + if (status == START_TIMER) + t_event->state = TIMER_STATE_ACTIVE; + else if (status == STOP_TIMER && t_event->state != TIMER_STATE_EXECUTING) + t_event->state = TIMER_STATE_INACTIVE; + + if (ret == TMR_OK) + classic_thread_reply(status, t_event, msg_hdl); + } + + ret = hmapi_delete_obj(msg_hdl); + if (ret != TMR_OK) + hm_error("delete obj failed!\n"); + return NULL; +} + +static uint32_t classic_thread_create(timer_event *t_event) +{ + pthread_attr_t thread_attr; + int32_t ret; + pthread_t thread_id; + + ret = pthread_attr_init(&thread_attr); + if (ret != TMR_OK) { + hm_error("init failed %d\n", ret); + return ret; + } + + ret = pthread_create(&thread_id, &thread_attr, classic_thread, t_event); + if (ret != TMR_OK) { + (void)pthread_attr_destroy(&thread_attr); + hm_error("create failed %d\n", ret); + return ret; + } + + ret = pthread_attr_destroy(&thread_attr); + if (ret != TMR_OK) { + hm_error("destory failed: err=%d\n", ret); + return ret; + } + + return TMR_OK; +} + +static timer_event *tee_classic_timer_event_create(sw_timer_event_handler handler, + int32_t timer_class, void *priv_data) +{ + uint32_t ret; + timer_event *t_event = NULL; + cref_t timer_channel; + + if (handler == NULL) { + hm_error("bad parameters\n"); + return NULL; + } + + t_event = TEE_Malloc(sizeof(*t_event), 0); + if (t_event == NULL) { + hm_error("no enough memory\n"); + return NULL; + } + + timer_channel = hm_msg_channel_create(); + if (is_ref_err(timer_channel) != TMR_OK) { + TEE_Free(t_event); + return NULL; + } + + t_event->timer_class = timer_class; + t_event->state = TIMER_STATE_INACTIVE; + t_event->timer_channel = timer_channel; + t_event->expires.tval64 = 0; + t_event->handler = handler; + t_event->data = priv_data; + + ret = classic_thread_create(t_event); + if (ret != TMR_OK) { + (void)hm_msg_channel_remove(t_event->timer_channel); + TEE_Free(t_event); + hm_error("create classic thread fail\n"); + return NULL; + } + + return t_event; +} + +static timer_event *tee_time_event_create(sw_timer_event_handler handler, int32_t timer_class, void *priv_data) +{ + if (handler == NULL || timer_class != TIMER_CLASSIC) { + hm_error("bad param\n"); + return NULL; + } + + return tee_classic_timer_event_create(handler, TIMER_CLASSIC, priv_data); +} + +static uint32_t tee_classic_timer_event_start(timer_event *t_event, timeval_t *time) +{ + uint32_t ret; + timeval_t current_time; + timeval_t expire_time; + struct timer_event_msg req_msg = {{{ 0 }}}; + struct timer_event_msg rsp_msg = {{{ 0 }}}; + req_msg.hdr.send.msg_id = START_TIMER; + + if ((time->tval.nsec > (NS_PER_SECONDS - 1)) || (time->tval.nsec < 0) || + (time->tval.sec < 0) || + (time->tval.sec == 0 && time->tval.nsec == 0)) + return TMR_ERR; + + if (t_event->state == TIMER_STATE_ACTIVE) + return TMR_ERR; + + current_time.tval64 = tee_read_time_stamp(); + expire_time.tval64 = timer_value_add(¤t_time, time); + t_event->state = TIMER_STATE_ACTIVE; + t_event->expires.tval64 = expire_time.tval64; + + if (t_event->pid == (int32_t)get_selfpid()) + return TMR_OK; + + ret = hm_msg_call(t_event->timer_channel, &req_msg, sizeof(req_msg), &rsp_msg, sizeof(rsp_msg), 0, HM_NO_TIMEOUT); + if (ret != TMR_OK || rsp_msg.hdr.send.msg_id != TIMER_OPS_SUCCESS) { + ret = TMR_ERR; + hm_error("start timer event fail\n"); + } + + return ret; +} + +static uint32_t tee_time_event_start(timer_event *t_event, timeval_t *time) +{ + if (t_event == NULL || time == NULL) { + hm_error("bad parameters\n"); + return TMR_ERR; + } + + return tee_classic_timer_event_start(t_event, time); +} + +static uint32_t tee_classic_timer_event_stop(timer_event *t_event) +{ + uint32_t ret; + struct timer_event_msg req_msg = {{{ 0 }}}; + struct timer_event_msg rsp_msg = {{{ 0 }}}; + req_msg.hdr.send.msg_id = STOP_TIMER; + + if (t_event->state != TIMER_STATE_ACTIVE) + return TMR_ERR; + + t_event->state = TIMER_STATE_INACTIVE; + if (t_event->pid == (int32_t)get_selfpid()) + return TMR_OK; + + ret = hm_msg_call(t_event->timer_channel, &req_msg, sizeof(req_msg), &rsp_msg, sizeof(rsp_msg), 0, HM_NO_TIMEOUT); + if (ret != TMR_OK || rsp_msg.hdr.send.msg_id != TIMER_OPS_SUCCESS) { + ret = TMR_ERR; + hm_error("stop timer event fail\n"); + } + + return ret; +} + +static uint32_t tee_time_event_stop(timer_event *t_event) +{ + if (t_event == NULL) { + hm_error("bad parameters\n"); + return TMR_ERR; + } + + return tee_classic_timer_event_stop(t_event); +} + +static uint32_t tee_classic_timer_event_destroy(timer_event *t_event) +{ + int32_t ret; + struct timer_event_msg req_msg = {{{ 0 }}}; + struct timer_event_msg rsp_msg = {{{ 0 }}}; + req_msg.hdr.send.msg_id = DESTORY_TIMER; + + if (t_event->state != TIMER_STATE_INACTIVE && t_event->state != TIMER_STATE_EXECUTING) { + hm_error("invalid timer event state %d\n", t_event->state); + return TMR_ERR; + } + + if (t_event->pid == (int32_t)get_selfpid()) { + ret = TMR_OK; + } else { + ret = hm_msg_call(t_event->timer_channel, &req_msg, sizeof(req_msg), + &rsp_msg, sizeof(rsp_msg), 0, HM_NO_TIMEOUT); + if (ret != TMR_OK || rsp_msg.hdr.send.msg_id != TIMER_OPS_SUCCESS) + hm_error("stop timer event fail\n"); + } + + if (hm_msg_channel_remove(t_event->timer_channel)) + hm_error("channel remove failed\n"); + + (void)memset_s(t_event, sizeof(*t_event), 0, sizeof(*t_event)); + TEE_Free(t_event); + return ret; +} + +static uint32_t tee_time_event_destroy(timer_event *t_event) +{ + if (t_event == NULL) { + hm_error("bad parameters\n"); + return TMR_ERR; + } + + return tee_classic_timer_event_destroy(t_event); +} + +static uint64_t tee_time_event_get_expire(timer_event *t_event) +{ + if (t_event == NULL) { + hm_error("bad parameters\n"); + return TIMER_INV_VALUE; + } + + return t_event->expires.tval64; +} + +static uint32_t tee_time_event_check(timer_notify_data_kernel *timer_data) +{ + if (timer_data == NULL) { + hm_error("bad parameters\n"); + return TMR_ERR; + } + + return TMR_OK; +} + +static uint32_t tee_get_secure_rtc_time(void) +{ + timeval_t cur_time; + cur_time.tval64 = tee_read_time_stamp(); + return cur_time.tval.sec; +} + +static void tee_release_timer_event(const TEE_UUID *uuid) +{ + (void)uuid; + return; +} + +static int32_t tee_set_ta_timer_permission(const TEE_UUID *uuid, uint64_t permission) +{ + (void)uuid; + (void)permission; + return TMR_OK; +} + +static uint32_t tee_adjust_sys_time(const struct tee_time_t *time) +{ + if (time == NULL) { + hm_error("time is NULL\n"); + return TMR_ERR; + } + + return TMR_OK; +} + +static void tee_get_system_time(TEE_Time *time) +{ + uint64_t time_value; + + if (time == NULL) { + hm_error("invalid param\n"); + return; + } + + time_value = tee_read_time_stamp(); + if (time_value == 0) { + hm_error("time value is zero\n"); + return; + } + + time->seconds = UPPER_32_BITS(time_value); + time->millis = LOWER_32_BITS(time_value) / NS_PER_MSEC; +} + +static void tee_get_sys_rtc_time(TEE_Time *time) +{ + TEE_Time cur_time; + if (time == NULL) { + hm_error("invalid param\n"); + return; + } + + hm_timer_get_offset(&g_rtc_offset.seconds, &g_rtc_offset.millis); + tee_get_system_time(&cur_time); + + if (cur_time.millis + (uint32_t)g_rtc_offset.millis > MS_PER_SECONDS) { + cur_time.seconds += (uint32_t)(g_rtc_offset.seconds + 1); + cur_time.millis += (uint32_t)(g_rtc_offset.millis - MS_PER_SECONDS); + } else { + cur_time.seconds += (uint32_t)g_rtc_offset.seconds; + cur_time.millis += (uint32_t)g_rtc_offset.millis; + } + + time->seconds = (uint32_t)cur_time.seconds; + time->millis = (uint32_t)cur_time.millis; +} + +struct timer_ops_t g_timer_ops = { + tee_read_time_stamp, + tee_get_sys_rtc_time, + tee_get_secure_rtc_time, + tee_sleep, + tee_time_event_create, + tee_time_event_destroy, + tee_time_event_start, + tee_time_event_stop, + tee_time_event_get_expire, + tee_time_event_check, + tee_release_timer_event, + tee_set_ta_timer_permission, + tee_adjust_sys_time, + NULL, + NULL, +}; + +struct timer_ops_t *get_time_ops(void) +{ + return &g_timer_ops; +} diff --git a/lib/thirdparty/libhwsecurec_host/Makefile b/lib/thirdparty/libhwsecurec_host/Makefile index 8eef6e1e..5a167560 100755 --- a/lib/thirdparty/libhwsecurec_host/Makefile +++ b/lib/thirdparty/libhwsecurec_host/Makefile @@ -1,8 +1,12 @@ -# -# Copyright 2017, Huawei Co. Ltd. -# -# See "HUAWEI_LICENSE" for details. -# +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # Targets MODULE := libhwsecurec_host.a diff --git a/services/huk_service/Makefile b/services/huk_service/Makefile index 674aa3af..eaff9df0 100644 --- a/services/huk_service/Makefile +++ b/services/huk_service/Makefile @@ -1,4 +1,12 @@ -# Copyright Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # TARGET is an app TARGET := huk_service${TARG}.elf diff --git a/services/huk_service/include/huk_derive_takey.h b/services/huk_service/include/huk_derive_takey.h index 25d4932d..6592c822 100644 --- a/services/huk_service/include/huk_derive_takey.h +++ b/services/huk_service/include/huk_derive_takey.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: huk derive takey - * Create: 2022-10-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef HUK_DERIVE_TAKEY_H #define HUK_DERIVE_TAKEY_H diff --git a/services/huk_service/include/huk_get_deviceid.h b/services/huk_service/include/huk_get_deviceid.h index 26e1c2e0..665d3daf 100644 --- a/services/huk_service/include/huk_get_deviceid.h +++ b/services/huk_service/include/huk_get_deviceid.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: huk get deviceid - * Create: 2022-10-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef HUK_GET_DEVICEID_H #define HUK_GET_DEVICEID_H diff --git a/services/huk_service/src/huk_derive_takey.c b/services/huk_service/src/huk_derive_takey.c index 5a8417a3..0262d8af 100644 --- a/services/huk_service/src/huk_derive_takey.c +++ b/services/huk_service/src/huk_derive_takey.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: huk derive takey - * Create: 2022-10-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "huk_derive_takey.h" #include diff --git a/services/huk_service/src/huk_get_deviceid.c b/services/huk_service/src/huk_get_deviceid.c index d9b7e5d9..b94daeb1 100644 --- a/services/huk_service/src/huk_get_deviceid.c +++ b/services/huk_service/src/huk_get_deviceid.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: huk get deviceid - * Create: 2022-10-08 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "huk_get_deviceid.h" diff --git a/services/huk_service/src/main.c b/services/huk_service/src/main.c index 6fa0ac79..3038f0e9 100644 --- a/services/huk_service/src/main.c +++ b/services/huk_service/src/main.c @@ -1,170 +1,169 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: huk manager task. - * Author: PengShuai pengshuai@huawei.com - * Create: 2020-05-22 - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "huk_derive_takey.h" -#include "huk_get_deviceid.h" -#include "huk_service_msg.h" - -#define MAGIC_STR_LEN 20 - -#define WEAK __attribute__((weak)) - -#define BSS_START_MAGIC 0x12345678 -#define BSS_END_MAGIX 0x87654321 - -typedef TEE_Result (*cmd_func)(const struct huk_srv_msg *msg, struct huk_srv_rsp *rsp, - uint32_t sndr_pid, const TEE_UUID *uuid); - -struct cmd_operate_config_s { - uint32_t cmd_id; - cmd_func operate_func; -}; - -static cref_t huk_get_mymsghdl(void) -{ - struct hmapi_thread_local_storage *tls = NULL; - - tls = hmapi_tls_get(); - if (tls == NULL) - return CREF_NULL; - - if (tls->msghdl == 0) { - cref_t msghdl; - msghdl = hm_msg_create_hdl(); - if (is_ref_err(msghdl)) - return CREF_NULL; - - tls->msghdl = msghdl; - } - - return tls->msghdl; -} - -static const struct cmd_operate_config_s g_cmd_operate_config[] = { - { CMD_HUK_DERIVE_TAKEY, huk_task_derive_takey }, - { CMD_HUK_GET_DEVICEID, huk_task_get_deviceid }, -}; -#define CMD_COUNT (sizeof(g_cmd_operate_config) / sizeof(g_cmd_operate_config[0])) - -static void handle_cmd(const struct huk_srv_msg *msg, cref_t msghdl, uint32_t sndr_pid, - uint16_t msg_type, const TEE_UUID *uuid) -{ - uint32_t cmd_id; - uint32_t self_pid; - int32_t rc; - struct huk_srv_rsp rsp; - uint32_t i; - - (void)memset_s(&rsp, sizeof(rsp), 0, sizeof(rsp)); - rsp.data.ret = TEE_ERROR_GENERIC; - cmd_id = msg->header.send.msg_id; - self_pid = get_selfpid(); - if (self_pid == SRE_PID_ERR) { - tloge("huk service get self pid error\n"); - rsp.data.ret = TEE_ERROR_GENERIC; - goto ret_flow; - } - - for (i = 0; i < CMD_COUNT; i++) { - if ((cmd_id != g_cmd_operate_config[i].cmd_id) || (g_cmd_operate_config[i].operate_func == NULL)) - continue; - rsp.data.ret = g_cmd_operate_config[i].operate_func(msg, &rsp, sndr_pid, uuid); - if (rsp.data.ret != TEE_SUCCESS && rsp.data.ret != TEE_ERROR_NOT_SUPPORTED) - tloge("cmd 0x%x error, ret = 0x%x\n", cmd_id, rsp.data.ret); - break; - } - if (i == CMD_COUNT) - tloge("the cmd id 0x%x is not supported\n", cmd_id); - -ret_flow: - if (msg_type == HM_MSG_TYPE_CALL) { - rc = hm_msg_reply(msghdl, &rsp, sizeof(rsp)); - if (rc != 0) - tloge("reply error 0x%x\n", rc); - } -} - -__attribute__((visibility ("default"))) void tee_task_entry(int init_build) -{ - (void)init_build; - struct huk_srv_msg msg; - spawn_uuid_t uuid; - cref_t ch = 0; - msginfo_t info = {0}; - int32_t ret_hm; - struct channel_ipc_args ipc_args = {0}; - - (void)memset_s(&msg, sizeof(msg), 0, sizeof(msg)); - cref_t msghdl = huk_get_mymsghdl(); - if (is_ref_err(msghdl) != 0) { - tloge("Cannot create msg hdl, %s\n", hmapi_strerror((int)msghdl)); - hm_exit((int)msghdl); - } - - if (hm_create_ipc_native(HUK_PATH, &ch) != 0) { - tloge("create main thread native channel failed!\n"); - hm_exit(-1); - } - - if (ac_init_simple() != 0) { - tloge("ac init error\n"); - hm_exit(-1); - } - - ret_hm = hm_tamgr_register(HUK_TASK_NAME); - if (ret_hm != 0) { - tloge("hm tamgr register fail is %d!\n", ret_hm); - hm_exit(-1); - } - - ipc_args.channel = ch; - ipc_args.recv_buf = &msg; - ipc_args.recv_len = sizeof(msg); - while (1) { - ret_hm = hm_msg_receive(&ipc_args, msghdl, &info, 0, -1); - if (ret_hm < 0) { - tloge("huk service: message receive failed, %llx, %s\n", ret_hm, hmapi_strerror(ret_hm)); - continue; - } - - if (hm_getuuid((pid_t)info.src_cred.pid, &uuid) != 0) - tloge("huk service get uuid failed\n"); - - if (info.src_cred.pid == 0) - handle_cmd(&msg, msghdl, GLOBAL_HANDLE, info.msg_type, &(uuid.uuid)); - else - handle_cmd(&msg, msghdl, (uint32_t)hmpid_to_pid(TCBCREF2TID(info.src_tcb_cref), info.src_cred.pid), - info.msg_type, &(uuid.uuid)); - } - - tloge("huk service abort!\n"); -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "huk_derive_takey.h" +#include "huk_get_deviceid.h" +#include "huk_service_msg.h" + +#define MAGIC_STR_LEN 20 + +#define WEAK __attribute__((weak)) + +#define BSS_START_MAGIC 0x12345678 +#define BSS_END_MAGIX 0x87654321 + +typedef TEE_Result (*cmd_func)(const struct huk_srv_msg *msg, struct huk_srv_rsp *rsp, + uint32_t sndr_pid, const TEE_UUID *uuid); + +struct cmd_operate_config_s { + uint32_t cmd_id; + cmd_func operate_func; +}; + +static cref_t huk_get_mymsghdl(void) +{ + struct hmapi_thread_local_storage *tls = NULL; + + tls = hmapi_tls_get(); + if (tls == NULL) + return CREF_NULL; + + if (tls->msghdl == 0) { + cref_t msghdl; + msghdl = hm_msg_create_hdl(); + if (is_ref_err(msghdl)) + return CREF_NULL; + + tls->msghdl = msghdl; + } + + return tls->msghdl; +} + +static const struct cmd_operate_config_s g_cmd_operate_config[] = { + { CMD_HUK_DERIVE_TAKEY, huk_task_derive_takey }, + { CMD_HUK_GET_DEVICEID, huk_task_get_deviceid }, +}; +#define CMD_COUNT (sizeof(g_cmd_operate_config) / sizeof(g_cmd_operate_config[0])) + +static void handle_cmd(const struct huk_srv_msg *msg, cref_t msghdl, uint32_t sndr_pid, + uint16_t msg_type, const TEE_UUID *uuid) +{ + uint32_t cmd_id; + uint32_t self_pid; + int32_t rc; + struct huk_srv_rsp rsp; + uint32_t i; + + (void)memset_s(&rsp, sizeof(rsp), 0, sizeof(rsp)); + rsp.data.ret = TEE_ERROR_GENERIC; + cmd_id = msg->header.send.msg_id; + self_pid = get_selfpid(); + if (self_pid == SRE_PID_ERR) { + tloge("huk service get self pid error\n"); + rsp.data.ret = TEE_ERROR_GENERIC; + goto ret_flow; + } + + for (i = 0; i < CMD_COUNT; i++) { + if ((cmd_id != g_cmd_operate_config[i].cmd_id) || (g_cmd_operate_config[i].operate_func == NULL)) + continue; + rsp.data.ret = g_cmd_operate_config[i].operate_func(msg, &rsp, sndr_pid, uuid); + if (rsp.data.ret != TEE_SUCCESS && rsp.data.ret != TEE_ERROR_NOT_SUPPORTED) + tloge("cmd 0x%x error, ret = 0x%x\n", cmd_id, rsp.data.ret); + break; + } + if (i == CMD_COUNT) + tloge("the cmd id 0x%x is not supported\n", cmd_id); + +ret_flow: + if (msg_type == HM_MSG_TYPE_CALL) { + rc = hm_msg_reply(msghdl, &rsp, sizeof(rsp)); + if (rc != 0) + tloge("reply error 0x%x\n", rc); + } +} + +__attribute__((visibility ("default"))) void tee_task_entry(int init_build) +{ + (void)init_build; + struct huk_srv_msg msg; + spawn_uuid_t uuid; + cref_t ch = 0; + msginfo_t info = {0}; + int32_t ret_hm; + struct channel_ipc_args ipc_args = {0}; + + (void)memset_s(&msg, sizeof(msg), 0, sizeof(msg)); + cref_t msghdl = huk_get_mymsghdl(); + if (is_ref_err(msghdl) != 0) { + tloge("Cannot create msg hdl, %s\n", hmapi_strerror((int)msghdl)); + hm_exit((int)msghdl); + } + + if (hm_create_ipc_native(HUK_PATH, &ch) != 0) { + tloge("create main thread native channel failed!\n"); + hm_exit(-1); + } + + if (ac_init_simple() != 0) { + tloge("ac init error\n"); + hm_exit(-1); + } + + ret_hm = hm_tamgr_register(HUK_TASK_NAME); + if (ret_hm != 0) { + tloge("hm tamgr register fail is %d!\n", ret_hm); + hm_exit(-1); + } + + ipc_args.channel = ch; + ipc_args.recv_buf = &msg; + ipc_args.recv_len = sizeof(msg); + while (1) { + ret_hm = hm_msg_receive(&ipc_args, msghdl, &info, 0, -1); + if (ret_hm < 0) { + tloge("huk service: message receive failed, %llx, %s\n", ret_hm, hmapi_strerror(ret_hm)); + continue; + } + + if (hm_getuuid((pid_t)info.src_cred.pid, &uuid) != 0) + tloge("huk service get uuid failed\n"); + + if (info.src_cred.pid == 0) + handle_cmd(&msg, msghdl, GLOBAL_HANDLE, info.msg_type, &(uuid.uuid)); + else + handle_cmd(&msg, msghdl, (uint32_t)hmpid_to_pid(TCBCREF2TID(info.src_tcb_cref), info.src_cred.pid), + info.msg_type, &(uuid.uuid)); + } + + tloge("huk service abort!\n"); +} diff --git a/services/permission_service/Makefile b/services/permission_service/Makefile index e9a6d128..c4f5e15e 100644 --- a/services/permission_service/Makefile +++ b/services/permission_service/Makefile @@ -1,4 +1,12 @@ -# Copyright Huawei Technologies Co., Ltd. 2010-2022. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. # TARGET is an app TARGET := permission_service${TARG}.elf diff --git a/services/permission_service/src/auth/tee_auth_sign_cms.c b/services/permission_service/src/auth/tee_auth_sign_cms.c index 71653c29..46c1c257 100644 --- a/services/permission_service/src/auth/tee_auth_sign_cms.c +++ b/services/permission_service/src/auth/tee_auth_sign_cms.c @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: cms signature auth - * Author: wangchunxu1@huawei.com - * Create: 2020.06.18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_auth_sign_cms.h" diff --git a/services/permission_service/src/auth/tee_auth_sign_cms.h b/services/permission_service/src/auth/tee_auth_sign_cms.h index a47180f4..11f7d02c 100644 --- a/services/permission_service/src/auth/tee_auth_sign_cms.h +++ b/services/permission_service/src/auth/tee_auth_sign_cms.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: cms signature auth - * Author: wangchunxu1@huawei.com - * Create: 2020.06.18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TEE_AUTH_SIGN_CMS_H diff --git a/services/permission_service/src/auth/tee_auth_sign_rsa.c b/services/permission_service/src/auth/tee_auth_sign_rsa.c index f491c8cc..3774d208 100644 --- a/services/permission_service/src/auth/tee_auth_sign_rsa.c +++ b/services/permission_service/src/auth/tee_auth_sign_rsa.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. - * Description: cms signature auth - * Create: 2020.11.29 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_auth_sign_rsa.h" diff --git a/services/permission_service/src/auth/tee_auth_sign_rsa.h b/services/permission_service/src/auth/tee_auth_sign_rsa.h index 9bc505a3..177c99e9 100644 --- a/services/permission_service/src/auth/tee_auth_sign_rsa.h +++ b/services/permission_service/src/auth/tee_auth_sign_rsa.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. - * Description: cms signature auth - * Create: 2020.11.29 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef GTASK_TEE_AUTH_SIGN_RSA_H diff --git a/services/permission_service/src/ca_hashfile_config.c b/services/permission_service/src/ca_hashfile_config.c index dc3d0042..ee94dcd3 100644 --- a/services/permission_service/src/ca_hashfile_config.c +++ b/services/permission_service/src/ca_hashfile_config.c @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: ca hashfile config - * Author: liangshan - * Create: 2022-04-14 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ca_hashfile_config.h" diff --git a/services/permission_service/src/ca_hashfile_config.h b/services/permission_service/src/ca_hashfile_config.h index 53ff12e7..48d3082d 100644 --- a/services/permission_service/src/ca_hashfile_config.h +++ b/services/permission_service/src/ca_hashfile_config.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: ca hashfile config - * Author: liangshan - * Create: 2022-04-14 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef CA_HASH_FILE_CONFIG_H diff --git a/services/permission_service/src/config_tlv_parser.c b/services/permission_service/src/config_tlv_parser.c index 2f7fea78..3eabd6fc 100644 --- a/services/permission_service/src/config_tlv_parser.c +++ b/services/permission_service/src/config_tlv_parser.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2016-2020. All rights reserved. - * Description: permission tlv parser - * Author: TianJianliang tianjianliang@huawei.com - * Create: 2016-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "config_tlv_parser.h" #include diff --git a/services/permission_service/src/config_tlv_parser.h b/services/permission_service/src/config_tlv_parser.h index 902c758f..123ee8b7 100644 --- a/services/permission_service/src/config_tlv_parser.h +++ b/services/permission_service/src/config_tlv_parser.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2016-2020. All rights reserved. - * Description: permission config tlv parser - * Author: TianJianliang tianjianliang@huawei.com - * Create: 2016-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PERMISSION_SERVICE_CONFIG_TLV_PARSER_H #define PERMISSION_SERVICE_CONFIG_TLV_PARSER_H diff --git a/services/permission_service/src/handle_ca_hashfile_verify.c b/services/permission_service/src/handle_ca_hashfile_verify.c index 5452a033..1008857a 100644 --- a/services/permission_service/src/handle_ca_hashfile_verify.c +++ b/services/permission_service/src/handle_ca_hashfile_verify.c @@ -1,166 +1,171 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: perm service do ca hashfile verify - * Author: liangshan - * Create: 2022-04-14 - */ - -#include "handle_ca_hashfile_verify.h" -#include -#include /* tee_map_sharemem */ -#include -#include "tee_crypto_api.h" -#include "tee_crypto_hal.h" -#include "tee_log.h" -#include "ca_hashfile_config.h" -#include "tee_crypto_signature_verify.h" -#include "auth/tee_auth_sign_rsa.h" - -#define SHA256_HASH_LEN 32 -#define RESERVE_LEN 2 -struct ca_hash_file_s { - uint32_t total_len; - uint32_t file_ver; - uint32_t magic; - uint32_t xml_type; - uint32_t reserve[RESERVE_LEN]; - uint32_t sign_offset; - uint32_t sign_length; - uint32_t ca_num; - uint8_t data[1]; -}; - -static RSA *get_rsa_pub_key(void) -{ - const rsa_pub_key_t *cahash_pub_key = get_cahash_rsa_pub_key(); - if (cahash_pub_key == NULL) - return NULL; - - return rsa_build_public_key(cahash_pub_key); -} - -static TEE_Result calc_hash256(const uint8_t *src_data, uint32_t src_len, uint8_t *dest_data, size_t dest_len) -{ - if (src_data == NULL || dest_data == NULL || dest_len != SHA256_HASH_LEN) { - tloge("src data or dest data is null"); - return TEE_ERROR_BAD_PARAMETERS; - } - - TEE_OperationHandle crypto_ops = NULL; - TEE_Result ret = TEE_AllocateOperation(&crypto_ops, TEE_ALG_SHA256, TEE_MODE_DIGEST, 0); - if (ret != TEE_SUCCESS) { - tloge("allocate operation fail 0x%x\n", ret); - return ret; - } - ret = TEE_SetCryptoFlag(crypto_ops, SOFT_CRYPTO); - if (ret != TEE_SUCCESS) { - tloge("set soft engine failed ret=0x%x\n", ret); - goto free_operation; - } - ret = TEE_DigestDoFinal(crypto_ops, src_data, src_len, dest_data, &dest_len); - if (ret != TEE_SUCCESS) { - tloge("digest do final fail ret=0x%x, srclen=0x%x, dst_len=0x%x\n", ret, src_len, dest_len); - goto free_operation; - } - -free_operation: - TEE_FreeOperation(crypto_ops); - return ret; -} - -/* check ca hash file */ -static TEE_Result check_hash_file_params(const struct ca_hash_file_s *hash_file, uint32_t size) -{ - uint32_t hash_file_maxsize = get_hashfile_max_size(); - - if (size < sizeof(*hash_file)) { - tloge("hash file size is invalid, %u\n", size); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (hash_file->total_len > hash_file_maxsize || hash_file->total_len != size) { - tloge("hash file total len is invaild, %u\n", hash_file->total_len); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (hash_file->sign_offset > hash_file->total_len) { - tloge("hash file sign offset is invaild, %u, %u\n", hash_file->sign_offset, hash_file->total_len); - return TEE_ERROR_BAD_PARAMETERS; - } - - if ((hash_file->sign_offset + hash_file->sign_length) != hash_file->total_len) { - tloge("hash file invaild: total len:0x%x, sign offset:0x%x, sign length:0x%x\n", - hash_file->total_len, hash_file->sign_offset, hash_file->sign_length); - return TEE_ERROR_BAD_PARAMETERS; - } - - return TEE_SUCCESS; -} - -static TEE_Result ca_hashfile_verify_signature(const uint8_t *buf, uint32_t size) -{ - struct ca_hash_file_s *hash_file = (struct ca_hash_file_s *)buf; - - TEE_Result ret = check_hash_file_params(hash_file, size); - if (ret != TEE_SUCCESS) { - tloge("hash file is invaild\n"); - return ret; - } - - uint8_t verify_hash[SHA256_HASH_LEN] = {0}; - ret = calc_hash256(buf, hash_file->sign_offset, verify_hash, sizeof(verify_hash)); - if (ret != TEE_SUCCESS) { - tloge("calc hash file fail, ret %x\n", ret); - return ret; - } - - ret = tee_secure_img_release_verify(verify_hash, sizeof(verify_hash), buf + hash_file->sign_offset, - hash_file->sign_length, get_rsa_pub_key()); - if (ret != TEE_SUCCESS) { - tloge("hash file verify failed, 0x%x\n", ret); - return ret; - } - - return TEE_SUCCESS; -} - -TEE_Result perm_serv_ca_hashfile_verify(perm_srv_reply_msg_t *rsp, const perm_srv_req_msg_t *msg, uint32_t sender) -{ - TEE_Result ret; - - if (rsp == NULL || msg == NULL) { - tloge("rsp or msg is NULL\n"); - return TEE_ERROR_BAD_PARAMETERS; - } - - if (sender != GLOBAL_HANDLE) { - /* only gtask can call this interface */ - tloge("sender 0x%x no perm\n", sender); - ret = TEE_ERROR_ACCESS_DENIED; - goto out; - } - - uint64_t map_addr; - ret = tee_map_sharemem(sender, msg->req_msg.ca_hashfile_verify.buffer, msg->req_msg.ca_hashfile_verify.size, - &map_addr); - if (ret != TEE_SUCCESS) { - tloge("map from task 0(gtask) failed, ret 0x%x\n", ret); - goto out; - } - - /* verify ca hashfile */ - ret = ca_hashfile_verify_signature((uint8_t *)(uintptr_t)map_addr, msg->req_msg.ca_hashfile_verify.size); - if (ret != 0) - tloge("ca hashfile verify failed, ret 0x%x\n", ret); - - if (map_addr != 0) { - if (munmap((void *)(uintptr_t)map_addr, msg->req_msg.ca_hashfile_verify.size) != 0) { - tloge("perm unmap error\n"); - ret = TEE_ERROR_GENERIC; - } - } - -out: - rsp->reply.ret = ret; - return ret; -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ + +#include "handle_ca_hashfile_verify.h" +#include +#include /* tee_map_sharemem */ +#include +#include "tee_crypto_api.h" +#include "tee_crypto_hal.h" +#include "tee_log.h" +#include "ca_hashfile_config.h" +#include "tee_crypto_signature_verify.h" +#include "auth/tee_auth_sign_rsa.h" + +#define SHA256_HASH_LEN 32 +#define RESERVE_LEN 2 +struct ca_hash_file_s { + uint32_t total_len; + uint32_t file_ver; + uint32_t magic; + uint32_t xml_type; + uint32_t reserve[RESERVE_LEN]; + uint32_t sign_offset; + uint32_t sign_length; + uint32_t ca_num; + uint8_t data[1]; +}; + +static RSA *get_rsa_pub_key(void) +{ + const rsa_pub_key_t *cahash_pub_key = get_cahash_rsa_pub_key(); + if (cahash_pub_key == NULL) + return NULL; + + return rsa_build_public_key(cahash_pub_key); +} + +static TEE_Result calc_hash256(const uint8_t *src_data, uint32_t src_len, uint8_t *dest_data, size_t dest_len) +{ + if (src_data == NULL || dest_data == NULL || dest_len != SHA256_HASH_LEN) { + tloge("src data or dest data is null"); + return TEE_ERROR_BAD_PARAMETERS; + } + + TEE_OperationHandle crypto_ops = NULL; + TEE_Result ret = TEE_AllocateOperation(&crypto_ops, TEE_ALG_SHA256, TEE_MODE_DIGEST, 0); + if (ret != TEE_SUCCESS) { + tloge("allocate operation fail 0x%x\n", ret); + return ret; + } + ret = TEE_SetCryptoFlag(crypto_ops, SOFT_CRYPTO); + if (ret != TEE_SUCCESS) { + tloge("set soft engine failed ret=0x%x\n", ret); + goto free_operation; + } + ret = TEE_DigestDoFinal(crypto_ops, src_data, src_len, dest_data, &dest_len); + if (ret != TEE_SUCCESS) { + tloge("digest do final fail ret=0x%x, srclen=0x%x, dst_len=0x%x\n", ret, src_len, dest_len); + goto free_operation; + } + +free_operation: + TEE_FreeOperation(crypto_ops); + return ret; +} + +/* check ca hash file */ +static TEE_Result check_hash_file_params(const struct ca_hash_file_s *hash_file, uint32_t size) +{ + uint32_t hash_file_maxsize = get_hashfile_max_size(); + + if (size < sizeof(*hash_file)) { + tloge("hash file size is invalid, %u\n", size); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (hash_file->total_len > hash_file_maxsize || hash_file->total_len != size) { + tloge("hash file total len is invaild, %u\n", hash_file->total_len); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (hash_file->sign_offset > hash_file->total_len) { + tloge("hash file sign offset is invaild, %u, %u\n", hash_file->sign_offset, hash_file->total_len); + return TEE_ERROR_BAD_PARAMETERS; + } + + if ((hash_file->sign_offset + hash_file->sign_length) != hash_file->total_len) { + tloge("hash file invaild: total len:0x%x, sign offset:0x%x, sign length:0x%x\n", + hash_file->total_len, hash_file->sign_offset, hash_file->sign_length); + return TEE_ERROR_BAD_PARAMETERS; + } + + return TEE_SUCCESS; +} + +static TEE_Result ca_hashfile_verify_signature(const uint8_t *buf, uint32_t size) +{ + struct ca_hash_file_s *hash_file = (struct ca_hash_file_s *)buf; + + TEE_Result ret = check_hash_file_params(hash_file, size); + if (ret != TEE_SUCCESS) { + tloge("hash file is invaild\n"); + return ret; + } + + uint8_t verify_hash[SHA256_HASH_LEN] = {0}; + ret = calc_hash256(buf, hash_file->sign_offset, verify_hash, sizeof(verify_hash)); + if (ret != TEE_SUCCESS) { + tloge("calc hash file fail, ret %x\n", ret); + return ret; + } + + ret = tee_secure_img_release_verify(verify_hash, sizeof(verify_hash), buf + hash_file->sign_offset, + hash_file->sign_length, get_rsa_pub_key()); + if (ret != TEE_SUCCESS) { + tloge("hash file verify failed, 0x%x\n", ret); + return ret; + } + + return TEE_SUCCESS; +} + +TEE_Result perm_serv_ca_hashfile_verify(perm_srv_reply_msg_t *rsp, const perm_srv_req_msg_t *msg, uint32_t sender) +{ + TEE_Result ret; + + if (rsp == NULL || msg == NULL) { + tloge("rsp or msg is NULL\n"); + return TEE_ERROR_BAD_PARAMETERS; + } + + if (sender != GLOBAL_HANDLE) { + /* only gtask can call this interface */ + tloge("sender 0x%x no perm\n", sender); + ret = TEE_ERROR_ACCESS_DENIED; + goto out; + } + + uint64_t map_addr; + ret = tee_map_sharemem(sender, msg->req_msg.ca_hashfile_verify.buffer, msg->req_msg.ca_hashfile_verify.size, + &map_addr); + if (ret != TEE_SUCCESS) { + tloge("map from task 0(gtask) failed, ret 0x%x\n", ret); + goto out; + } + + /* verify ca hashfile */ + ret = ca_hashfile_verify_signature((uint8_t *)(uintptr_t)map_addr, msg->req_msg.ca_hashfile_verify.size); + if (ret != 0) + tloge("ca hashfile verify failed, ret 0x%x\n", ret); + + if (map_addr != 0) { + if (munmap((void *)(uintptr_t)map_addr, msg->req_msg.ca_hashfile_verify.size) != 0) { + tloge("perm unmap error\n"); + ret = TEE_ERROR_GENERIC; + } + } + +out: + rsp->reply.ret = ret; + return ret; +} diff --git a/services/permission_service/src/handle_ca_hashfile_verify.h b/services/permission_service/src/handle_ca_hashfile_verify.h index dff82548..5130297c 100644 --- a/services/permission_service/src/handle_ca_hashfile_verify.h +++ b/services/permission_service/src/handle_ca_hashfile_verify.h @@ -1,15 +1,20 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: perm service do ca hashfile verify - * Author: liangshan - * Create: 2022-04-14 - */ -#ifndef HANDLE_CA_HASHFILE_VERIFY_H -#define HANDLE_CA_HASHFILE_VERIFY_H - -#include -#include "permission_service.h" - -TEE_Result perm_serv_ca_hashfile_verify(perm_srv_reply_msg_t *rsp, const perm_srv_req_msg_t *msg, uint32_t sender); - +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#ifndef HANDLE_CA_HASHFILE_VERIFY_H +#define HANDLE_CA_HASHFILE_VERIFY_H + +#include +#include "permission_service.h" + +TEE_Result perm_serv_ca_hashfile_verify(perm_srv_reply_msg_t *rsp, const perm_srv_req_msg_t *msg, uint32_t sender); + #endif \ No newline at end of file diff --git a/services/permission_service/src/handle_cert_storage_io.c b/services/permission_service/src/handle_cert_storage_io.c index 7ceba1c8..2e661962 100644 --- a/services/permission_service/src/handle_cert_storage_io.c +++ b/services/permission_service/src/handle_cert_storage_io.c @@ -1,13 +1,13 @@ -/* $$$!!Warning: Huawei key information asset. No spread without permission.$$$ */ -/* CODEMARK:G45B5tAhAurX3Fjv5w5YrnvEBsxawGU4sQTa6eXHOFkC1Mfvbai6ssLiuF4skCy23hW+xgyXJaVN -2jIjipr/cpauHINx1FQyMyereaY2ZKz1AEk16KBYT3zrrVcV/zYZa+SM7KtAIjQaXRQOuxkCVCHR -djsuW3qvWZbQ3ZjHygm+9Z7Zon2QkYjMt+j1ajp+5u25sy0tND3u8XRRTFLYIcPN3a00GwLwzcWQ -hFfZjUw=# */ -/* $$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$ */ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved. - * Description: perm service do elf verify - * Create: 2021-03-11 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "handle_cert_storage_io.h" diff --git a/services/permission_service/src/handle_cert_storage_io.h b/services/permission_service/src/handle_cert_storage_io.h index d60f38eb..15a1b120 100644 --- a/services/permission_service/src/handle_cert_storage_io.h +++ b/services/permission_service/src/handle_cert_storage_io.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: perm service do elf verify - * Create: 2022-03-11 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef HANDLE_CERT_SSA_IO_H #define HANDLE_CERT_SSA_IO_H diff --git a/services/permission_service/src/handle_config.c b/services/permission_service/src/handle_config.c index 3cb9e9d4..4a23dea4 100644 --- a/services/permission_service/src/handle_config.c +++ b/services/permission_service/src/handle_config.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2016-2020. All rights reserved. - * Description: permission handle config - * Author: TianJianliang tianjianliang@huawei.com - * Create: 2016-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "handle_config.h" #include "handle_cert_storage_io.h" diff --git a/services/permission_service/src/handle_config.h b/services/permission_service/src/handle_config.h index f603dfb1..5dcf12fb 100644 --- a/services/permission_service/src/handle_config.h +++ b/services/permission_service/src/handle_config.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2016-2020. All rights reserved. - * Description: permission handle config - * Author: TianJianliang tianjianliang@huawei.com - * Create: 2016-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PERMISSION_SERVICE_HANDLE_CONFIG_H #define PERMISSION_SERVICE_HANDLE_CONFIG_H diff --git a/services/permission_service/src/handle_crl_cert.c b/services/permission_service/src/handle_crl_cert.c index 2241e8fc..1ff3e245 100644 --- a/services/permission_service/src/handle_crl_cert.c +++ b/services/permission_service/src/handle_crl_cert.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2016-2020. All rights reserved. - * Description: permission handle crl cert - * Author: TianJianliang tianjianliang@huawei.com - * Create: 2016-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "handle_crl_cert.h" #include diff --git a/services/permission_service/src/handle_crl_cert.h b/services/permission_service/src/handle_crl_cert.h index b793f54b..ea13132c 100644 --- a/services/permission_service/src/handle_crl_cert.h +++ b/services/permission_service/src/handle_crl_cert.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2016-2020. All rights reserved. - * Description: handle crl cert - * Author: TianJianliang tianjianliang@huawei.com - * Create: 2016-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PERMISSION_SERVICE_HANDLE_CRL_CERT_H #define PERMISSION_SERVICE_HANDLE_CRL_CERT_H diff --git a/services/permission_service/src/handle_elf_verify.c b/services/permission_service/src/handle_elf_verify.c index c6dacdf9..f0c2dacc 100644 --- a/services/permission_service/src/handle_elf_verify.c +++ b/services/permission_service/src/handle_elf_verify.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:c9SPtfxMWZMlOvcDia+6WHAr59HhILlflASQHv7o128+mg20phJTfOcfFn53MPjpO8GHRgax -tPhOXI1/WJ/LbjDIJ8+dAdseptkps6hvCJuKGe+mhDqxNCKx7bYzhqwCa9jqkJuZhopbxD/4 -0/1+I7yaQL7ITawf6zZtPiDNYPc=#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ - /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: perm service do elf verify - * Author: lipeng - * Create: 2021-08-11 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "handle_elf_verify.h" diff --git a/services/permission_service/src/handle_elf_verify.h b/services/permission_service/src/handle_elf_verify.h index b56e78e1..80d94293 100644 --- a/services/permission_service/src/handle_elf_verify.h +++ b/services/permission_service/src/handle_elf_verify.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. - * Description: perm service do elf verify - * Author: lipeng - * Create: 2021-08-11 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef HANDLE_ELF_VERIFY_H #define HANDLE_ELF_VERIFY_H diff --git a/services/permission_service/src/handle_file_op.c b/services/permission_service/src/handle_file_op.c index a010f53b..0efad791 100644 --- a/services/permission_service/src/handle_file_op.c +++ b/services/permission_service/src/handle_file_op.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2016-2020. All rights reserved. - * Description: permission handle file op - * Author: TianJianliang tianjianliang@huawei.com - * Create: 2016-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "handle_file_op.h" #include diff --git a/services/permission_service/src/handle_file_op.h b/services/permission_service/src/handle_file_op.h index f4c09186..295f8a41 100644 --- a/services/permission_service/src/handle_file_op.h +++ b/services/permission_service/src/handle_file_op.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2016-2020. All rights reserved. - * Description: handle file op - * Author: TianJianliang tianjianliang@huawei.com - * Create: 2016-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PERMISSION_SERVICE_HANDLE_FILE_OP_H #define PERMISSION_SERVICE_HANDLE_FILE_OP_H diff --git a/services/permission_service/src/handle_ta_ctrl_list.c b/services/permission_service/src/handle_ta_ctrl_list.c index 707ca7eb..d021dcb6 100644 --- a/services/permission_service/src/handle_ta_ctrl_list.c +++ b/services/permission_service/src/handle_ta_ctrl_list.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2016-2020. All rights reserved. - * Description: handle ta ctrl list - * Author: TianJianliang tianjianliang@huawei.com - * Create: 2016-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "handle_ta_ctrl_list.h" #include diff --git a/services/permission_service/src/handle_ta_ctrl_list.h b/services/permission_service/src/handle_ta_ctrl_list.h index e2b44a9e..265515a0 100644 --- a/services/permission_service/src/handle_ta_ctrl_list.h +++ b/services/permission_service/src/handle_ta_ctrl_list.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2016-2020. All rights reserved. - * Description: handle ta ctrl - * Author: TianJianliang tianjianliang@huawei.com - * Create: 2016-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PERMISSION_SERVICE_HANDLE_TA_CTRL_LIST_H #define PERMISSION_SERVICE_HANDLE_TA_CTRL_LIST_H diff --git a/services/permission_service/src/main.c b/services/permission_service/src/main.c index 3687545c..f9f712a2 100644 --- a/services/permission_service/src/main.c +++ b/services/permission_service/src/main.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2016-2020. All rights reserved. - * Description: permission main fun - * Author: TianJianliang tianjianliang@huawei.com - * Create: 2016-04-01 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include /* for thread */ diff --git a/services/permission_service/src/permission_config.h b/services/permission_service/src/permission_config.h index 6e65d5f4..b56fb6ee 100644 --- a/services/permission_service/src/permission_config.h +++ b/services/permission_service/src/permission_config.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. - * Description: ta permission check function defines - * Create: 2019-10-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PERMISSION_CONFIG #define PERMISSION_CONFIG diff --git a/services/permission_service/src/register_ssa_perm.c b/services/permission_service/src/register_ssa_perm.c index e393af19..4732908c 100644 --- a/services/permission_service/src/register_ssa_perm.c +++ b/services/permission_service/src/register_ssa_perm.c @@ -1,13 +1,13 @@ -/* $$$!!Warning: Huawei key information asset. No spread without permission.$$$ */ -/* CODEMARK:G45B5tAhAurX3Fjv5w5YrnvEBsxawGU4sQTa6eXHOFkC1Mfvbai6ssLiuF4skCy23hW+xgyXJaVN -2jIjipr/cpauHINx1FQyMyereaY2ZKz1AEk16KBYT3zrrVcV/zYZa+SM7KtAIjQaXRQOuxkCVCHR -djsuW3qvWZbQ3ZjHygm+9Z7Zon2QkYjMt+j1ajp+5u25sy0tND3u8XRRTFLYIcPN3a00GwLwzcWQ -hFfZjUw=# */ -/* $$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$ */ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: register or unregister permission to ssa - * Create: 2022-03-11 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "register_ssa_perm.h" diff --git a/services/permission_service/src/register_ssa_perm.h b/services/permission_service/src/register_ssa_perm.h index e602029d..4f44143a 100644 --- a/services/permission_service/src/register_ssa_perm.h +++ b/services/permission_service/src/register_ssa_perm.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: register or unregister permission to ssa - * Create: 2022-03-11 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef REGISTER_SSA_PERM_H #define REGISTER_SSA_PERM_H diff --git a/services/permission_service/src/root_cert_info.c b/services/permission_service/src/root_cert_info.c index e2c6e36b..bf590621 100644 --- a/services/permission_service/src/root_cert_info.c +++ b/services/permission_service/src/root_cert_info.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2020-2021. All rights reserved. - * Description: root cert info for checking TA image validation - * Create: 2020-03-05 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/services/permission_service/src/ta_permission_config.c b/services/permission_service/src/ta_permission_config.c index 3fb911c2..15e835f4 100644 --- a/services/permission_service/src/ta_permission_config.c +++ b/services/permission_service/src/ta_permission_config.c @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: permission check functions - * Create: 2019-12-23 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ta_permission_config.h" #include "tee_mem_mgmt_api.h" diff --git a/services/permission_service/src/ta_permission_config.h b/services/permission_service/src/ta_permission_config.h index fac6f7a0..ddacd254 100644 --- a/services/permission_service/src/ta_permission_config.h +++ b/services/permission_service/src/ta_permission_config.h @@ -1,7 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: ta permission check function defines - * Create: 2019-10-15 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef PERMSRV_TA_PERMISSION_CONFIG #define PERMSRV_TA_PERMISSION_CONFIG diff --git a/services/ssa/Makefile b/services/ssa/Makefile index 5e468708..2708ebea 100644 --- a/services/ssa/Makefile +++ b/services/ssa/Makefile @@ -1,4 +1,12 @@ -# Copyright Huawei Technologies Co., Ltd. 2010-2022. All rights reserved. +# Copyright (C) 2022 Huawei Technologies Co., Ltd. +# 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. DRIVER := ssa${TARG}.elf CFILES := $(wildcard src/*/*.c) diff --git a/services/ssa/src/secure_storage_agent/agent.c b/services/ssa/src/secure_storage_agent/agent.c index 6ec39eaf..cc64fb1b 100644 --- a/services/ssa/src/secure_storage_agent/agent.c +++ b/services/ssa/src/secure_storage_agent/agent.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: permission service implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include "ta_framework.h" diff --git a/services/ssa/src/secure_storage_agent/agent.h b/services/ssa/src/secure_storage_agent/agent.h index e3138f96..75f01371 100644 --- a/services/ssa/src/secure_storage_agent/agent.h +++ b/services/ssa/src/secure_storage_agent/agent.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: secure storage agent implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __SSAGENT_AGENT_H #define __SSAGENT_AGENT_H diff --git a/services/ssa/src/secure_storage_agent/secure_storage_agent.c b/services/ssa/src/secure_storage_agent/secure_storage_agent.c index 8e3522a1..35be8bf4 100644 --- a/services/ssa/src/secure_storage_agent/secure_storage_agent.c +++ b/services/ssa/src/secure_storage_agent/secure_storage_agent.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: secure storage agent implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/services/ssa/src/secure_storage_agent/secure_storage_msg.c b/services/ssa/src/secure_storage_agent/secure_storage_msg.c index 9e4d162f..64a9339a 100644 --- a/services/ssa/src/secure_storage_agent/secure_storage_msg.c +++ b/services/ssa/src/secure_storage_agent/secure_storage_msg.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: permission service implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include #include diff --git a/services/ssa/src/secure_storage_agent/sfs.c b/services/ssa/src/secure_storage_agent/sfs.c index fbf786c3..4b740b40 100644 --- a/services/ssa/src/secure_storage_agent/sfs.c +++ b/services/ssa/src/secure_storage_agent/sfs.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: secure storage agent implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_defines.h" #include "sfs.h" diff --git a/services/ssa/src/secure_storage_agent/sfs.h b/services/ssa/src/secure_storage_agent/sfs.h index 130f2241..429e0a61 100644 --- a/services/ssa/src/secure_storage_agent/sfs.h +++ b/services/ssa/src/secure_storage_agent/sfs.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: secure storage agent implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __TEE_SFS_H #define __TEE_SFS_H diff --git a/services/ssa/src/secure_storage_agent/sfs_internal.c b/services/ssa/src/secure_storage_agent/sfs_internal.c index f1646282..309a7ee3 100644 --- a/services/ssa/src/secure_storage_agent/sfs_internal.c +++ b/services/ssa/src/secure_storage_agent/sfs_internal.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: permission service implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_trusted_storage_api.h" #include "tee_mem_mgmt_api.h" diff --git a/services/ssa/src/secure_storage_agent/sfs_internal.h b/services/ssa/src/secure_storage_agent/sfs_internal.h index ef920dbc..42416ccc 100644 --- a/services/ssa/src/secure_storage_agent/sfs_internal.h +++ b/services/ssa/src/secure_storage_agent/sfs_internal.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: secure storage agent implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef TEE_SFS_INTERNAL_H #define TEE_SFS_INTERNAL_H diff --git a/services/ssa/src/secure_storage_agent/ssa_crypto.c b/services/ssa/src/secure_storage_agent/ssa_crypto.c index 3169c32b..4837d324 100644 --- a/services/ssa/src/secure_storage_agent/ssa_crypto.c +++ b/services/ssa/src/secure_storage_agent/ssa_crypto.c @@ -1,277 +1,283 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. - * Description: ssa encryption and decryption - * Create: 2022-04-18 - */ -#include "tee_defines.h" -#include "sfs.h" -#include "tee_mem_mgmt_api.h" -#include "tee_log.h" -#include "ta_framework.h" -#include "tee_ext_api.h" -#include "sfs_internal.h" -#include "securec.h" -#include "string.h" -#include "tee_crypto_hal.h" -#include "ssa_fs.h" - - -static TEE_Result aes_xts_crypto_check(const struct sfd_t *sfd, const struct memref_t *tweak, - const struct memref_t *data_in, struct memref_t *data_out) -{ - if (sfd == NULL || tweak == NULL || data_in == NULL || data_out == NULL) - return TEE_ERROR_BAD_PARAMETERS; - - if (sfd->meta_data == NULL) - return TEE_ERROR_BAD_PARAMETERS; - - if ((void *)(uintptr_t)tweak->buffer == NULL || (void *)(uintptr_t)data_in->buffer == NULL - || (void *)(uintptr_t)data_out->buffer == NULL) - return TEE_ERROR_BAD_PARAMETERS; - - if (data_in->size % AES_XTS_SINGLE_UNIT != 0) { - tloge("data size not supported, size=%u\n", data_in->size); - return TEE_ERROR_BAD_PARAMETERS; - } - - return TEE_SUCCESS; -} - -static TEE_Result aes_xts_crypto_init(TEE_ObjectHandleVar *key_obj1, TEE_ObjectHandleVar *key_obj2, - const struct sfd_t *sfd) -{ - /* set key */ - (void)memset_s((void *)key_obj1, sizeof(*key_obj1), 0, sizeof(*key_obj1)); - (void)memset_s((void *)key_obj2, sizeof(*key_obj2), 0, sizeof(*key_obj2)); - - key_obj1->Attribute = (TEE_Attribute *)TEE_Malloc(sizeof(TEE_Attribute), 0); - key_obj2->Attribute = (TEE_Attribute *)TEE_Malloc(sizeof(TEE_Attribute), 0); - if (key_obj1->Attribute == NULL || key_obj2->Attribute == NULL) { - tloge("cipher alloc key attr failed\n"); - return TEE_ERROR_OUT_OF_MEMORY; - } - key_obj1->Attribute->content.ref.length = sizeof(sfd->meta_data->xts_key1); - key_obj1->Attribute->content.ref.buffer = sfd->meta_data->xts_key1; - key_obj2->Attribute->content.ref.length = sizeof(sfd->meta_data->xts_key2); - key_obj2->Attribute->content.ref.buffer = sfd->meta_data->xts_key2; - - return TEE_SUCCESS; -} - -static void aes_xts_crypto_clean(TEE_OperationHandle handle, - TEE_ObjectHandleVar *key_obj1, TEE_ObjectHandleVar *key_obj2) -{ - if (handle != NULL) { - TEE_FreeOperation(handle); - handle = NULL; - } - - if (key_obj1->Attribute != NULL) { - TEE_Free(key_obj1->Attribute); - key_obj1->Attribute = NULL; - } - if (key_obj2->Attribute != NULL) { - TEE_Free(key_obj2->Attribute); - key_obj2->Attribute = NULL; - } -} - -TEE_Result aes_xts_crypto(uint32_t mode, const struct sfd_t *sfd, const struct memref_t *tweak, - const struct memref_t *data_in, struct memref_t *data_out) -{ - TEE_Result ret; - TEE_OperationHandle handle = NULL; - TEE_ObjectHandleVar key_obj1, key_obj2; - uint32_t i; - uint32_t data_offset; - - ret = aes_xts_crypto_check(sfd, tweak, data_in, data_out); - if (ret != TEE_SUCCESS) { - tloge("aes xts crypto check failed, ret 0x%x\n", ret); - return ret; - } - - ret = aes_xts_crypto_init(&key_obj1, &key_obj2, sfd); - if (ret != TEE_SUCCESS) { - tloge("aes xts crypto init failed, ret 0x%x\n", ret); - goto clean; - } - - uint32_t cipher_times = data_in->size / AES_XTS_SINGLE_UNIT; - for (i = 0; i < cipher_times; i++) { - ret = TEE_AllocateOperation(&handle, TEE_ALG_AES_XTS, mode, TEE_MAX_KEY_SIZE_IN_BITS); - if (ret != TEE_SUCCESS) { - tloge("alloc crypto operation failed, ret=0x%x\n", ret); - goto clean; - } - - ret = TEE_SetCryptoFlag(handle, SOFT_CRYPTO); - if (ret != TEE_SUCCESS) - goto clean; - - ret = TEE_SetOperationKey2(handle, &key_obj1, &key_obj2); - if (ret != TEE_SUCCESS) { - tloge("cipher setkey2 failed, ret=0x%x\n", ret); - goto clean; - } - - /* cipher init */ - TEE_CipherInit(handle, (void *)(uintptr_t)tweak->buffer, tweak->size); - - data_out->size = AES_XTS_SINGLE_UNIT; - data_offset = i * AES_XTS_SINGLE_UNIT; - ret = TEE_CipherDoFinal(handle, (void *)(uintptr_t)(data_in->buffer + data_offset), AES_XTS_SINGLE_UNIT, - (void *)(uintptr_t)(data_out->buffer + data_offset), (size_t *)&data_out->size); - if (ret != TEE_SUCCESS) { - tloge("cipher dofinal failed, ret=0x%x\n", ret); - goto clean; - } - - TEE_FreeOperation(handle); - handle = NULL; - } - -clean: - aes_xts_crypto_clean(handle, &key_obj1, &key_obj2); - return ret; -} - -TEE_Result calc_hmac256(struct key_info_t *key_info, const uint8_t *src, int32_t length, - uint8_t *dest, uint32_t *dest_len) -{ - TEE_OperationHandle mac_ops = NULL; - TEE_Result ret; - size_t out_len; - - if (key_info == NULL || src == NULL || dest == NULL || dest_len == NULL || length < 0) - return TEE_ERROR_BAD_PARAMETERS; - - ret = TEE_AllocateOperation(&mac_ops, TEE_ALG_HMAC_SHA256, TEE_MODE_MAC, key_info->key_len); - if (ret != TEE_SUCCESS) - return ret; - - ret = TEE_SetCryptoFlag(mac_ops, SOFT_CRYPTO); - if (ret != TEE_SUCCESS) - goto clean; - - TEE_ObjectHandleVar key_obj; - (void)memset_s((void *)&key_obj, sizeof(key_obj), 0, sizeof(key_obj)); - key_obj.Attribute = TEE_Malloc(sizeof(TEE_Attribute), 0); - if (key_obj.Attribute == NULL) { - tloge("alloc key attr failed\n"); - ret = TEE_ERROR_OUT_OF_MEMORY; - goto clean; - } - - key_obj.Attribute->content.ref.length = key_info->key_len; - key_obj.Attribute->content.ref.buffer = key_info->key; - ret = TEE_SetOperationKey(mac_ops, &key_obj); - if (ret != TEE_SUCCESS) { - tloge("set operation key fail, ret:0x%x", ret); - goto clean; - } - - TEE_MACInit(mac_ops, NULL, 0); - out_len = *dest_len; - ret = TEE_MACComputeFinal(mac_ops, src, (size_t)length, dest, &out_len); - if (ret != 0) { - tloge("TEE MAC error! %x\n", ret); - goto clean; - } - *dest_len = out_len; - ret = TEE_SUCCESS; - -clean: - TEE_FreeOperation(mac_ops); - TEE_Free(key_obj.Attribute); - return ret; -} - -#define BLOCK_SIZE_MAX 0x7D000 /* 500K */ - -TEE_Result cmd_hash(const uint8_t *src_data, uint32_t src_len, uint8_t *dest_data, size_t dest_len) -{ - TEE_OperationHandle crypto_ops = NULL; - uint32_t i, block_count; - TEE_Result ret; - - if ((src_data == NULL) || (dest_data == NULL)) { - tloge("src data or dest data is null"); - return TEE_ERROR_BAD_PARAMETERS; - } - - ret = TEE_AllocateOperation(&crypto_ops, TEE_ALG_SHA256, TEE_MODE_DIGEST, 0); - if (ret != TEE_SUCCESS) { - tloge("TEE_AllocateOperation, fail %x\n", ret); - return ret; - } - - block_count = src_len / BLOCK_SIZE_MAX; - for (i = 0; i < block_count; i++) { - ret = TEE_DigestUpdate(crypto_ops, (void *)(src_data + (uint32_t)(i * BLOCK_SIZE_MAX)), BLOCK_SIZE_MAX); - if (ret != TEE_SUCCESS) { - tloge("TEE_DigestUpdate, fail ret=%x\n", ret); - TEE_FreeOperation(crypto_ops); - return ret; - } - } - - ret = TEE_DigestDoFinal(crypto_ops, (void *)(src_data + (uint32_t)(block_count * BLOCK_SIZE_MAX)), - (src_len % BLOCK_SIZE_MAX), dest_data, &dest_len); - if (ret != TEE_SUCCESS) { - tloge("TEE_DigestDoFinal, fail ret=%x, srclen=%x, dst_len=%x\n", ret, (src_len % BLOCK_SIZE_MAX), dest_len); - TEE_FreeOperation(crypto_ops); - return ret; - } - - TEE_FreeOperation(crypto_ops); - - return TEE_SUCCESS; -} - -#define AES_IV_LEN 16 -TEE_Result aes_cbc_crypto(uint32_t mode, uint8_t *key_value, uint32_t key_size, const uint8_t *iv, - uint32_t iv_size, const uint8_t *data_in, uint32_t data_in_size, uint8_t *data_out) -{ - (void)iv_size; - if (key_value == NULL || iv == NULL || data_in == NULL || data_out == NULL) - return -1; - - TEE_ObjectHandleVar object = { 0 }; - TEE_OperationHandle operation = NULL; - - object.Attribute = TEE_Malloc(sizeof(TEE_Attribute), 0); - if (object.Attribute == NULL) { - tloge("allocate key failed!"); - return TEE_ERROR_OUT_OF_MEMORY; - } - - object.Attribute->content.ref.length = key_size; - object.Attribute->content.ref.buffer = key_value; - - TEE_Result ret = TEE_AllocateOperation(&operation, TEE_ALG_AES_CBC_NOPAD, mode, key_size); - if (ret != TEE_SUCCESS) { - tloge("allocate operation failed, ret = 0x%x", ret); - TEE_Free(object.Attribute); - return ret; - } - - ret = TEE_SetOperationKey(operation, &object); - if (ret != TEE_SUCCESS) { - tloge("set operation key failed, ret = 0x%x", ret); - TEE_Free(object.Attribute); - TEE_FreeOperation(operation); - return ret; - } - - TEE_CipherInit(operation, iv, AES_IV_LEN); - - size_t data_out_size = data_in_size; - ret = TEE_CipherDoFinal(operation, data_in, data_in_size, data_out, &data_out_size); - TEE_Free(object.Attribute); - object.Attribute = NULL; - TEE_FreeOperation(operation); - if (ret != TEE_SUCCESS) - tloge("aes do final failed, ret = 0x%x", ret); - return ret; -} +/* + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. + */ +#include "tee_defines.h" +#include "sfs.h" +#include "tee_mem_mgmt_api.h" +#include "tee_log.h" +#include "ta_framework.h" +#include "tee_ext_api.h" +#include "sfs_internal.h" +#include "securec.h" +#include "string.h" +#include "tee_crypto_hal.h" +#include "ssa_fs.h" + + +static TEE_Result aes_xts_crypto_check(const struct sfd_t *sfd, const struct memref_t *tweak, + const struct memref_t *data_in, struct memref_t *data_out) +{ + if (sfd == NULL || tweak == NULL || data_in == NULL || data_out == NULL) + return TEE_ERROR_BAD_PARAMETERS; + + if (sfd->meta_data == NULL) + return TEE_ERROR_BAD_PARAMETERS; + + if ((void *)(uintptr_t)tweak->buffer == NULL || (void *)(uintptr_t)data_in->buffer == NULL + || (void *)(uintptr_t)data_out->buffer == NULL) + return TEE_ERROR_BAD_PARAMETERS; + + if (data_in->size % AES_XTS_SINGLE_UNIT != 0) { + tloge("data size not supported, size=%u\n", data_in->size); + return TEE_ERROR_BAD_PARAMETERS; + } + + return TEE_SUCCESS; +} + +static TEE_Result aes_xts_crypto_init(TEE_ObjectHandleVar *key_obj1, TEE_ObjectHandleVar *key_obj2, + const struct sfd_t *sfd) +{ + /* set key */ + (void)memset_s((void *)key_obj1, sizeof(*key_obj1), 0, sizeof(*key_obj1)); + (void)memset_s((void *)key_obj2, sizeof(*key_obj2), 0, sizeof(*key_obj2)); + + key_obj1->Attribute = (TEE_Attribute *)TEE_Malloc(sizeof(TEE_Attribute), 0); + key_obj2->Attribute = (TEE_Attribute *)TEE_Malloc(sizeof(TEE_Attribute), 0); + if (key_obj1->Attribute == NULL || key_obj2->Attribute == NULL) { + tloge("cipher alloc key attr failed\n"); + return TEE_ERROR_OUT_OF_MEMORY; + } + key_obj1->Attribute->content.ref.length = sizeof(sfd->meta_data->xts_key1); + key_obj1->Attribute->content.ref.buffer = sfd->meta_data->xts_key1; + key_obj2->Attribute->content.ref.length = sizeof(sfd->meta_data->xts_key2); + key_obj2->Attribute->content.ref.buffer = sfd->meta_data->xts_key2; + + return TEE_SUCCESS; +} + +static void aes_xts_crypto_clean(TEE_OperationHandle handle, + TEE_ObjectHandleVar *key_obj1, TEE_ObjectHandleVar *key_obj2) +{ + if (handle != NULL) { + TEE_FreeOperation(handle); + handle = NULL; + } + + if (key_obj1->Attribute != NULL) { + TEE_Free(key_obj1->Attribute); + key_obj1->Attribute = NULL; + } + if (key_obj2->Attribute != NULL) { + TEE_Free(key_obj2->Attribute); + key_obj2->Attribute = NULL; + } +} + +TEE_Result aes_xts_crypto(uint32_t mode, const struct sfd_t *sfd, const struct memref_t *tweak, + const struct memref_t *data_in, struct memref_t *data_out) +{ + TEE_Result ret; + TEE_OperationHandle handle = NULL; + TEE_ObjectHandleVar key_obj1, key_obj2; + uint32_t i; + uint32_t data_offset; + + ret = aes_xts_crypto_check(sfd, tweak, data_in, data_out); + if (ret != TEE_SUCCESS) { + tloge("aes xts crypto check failed, ret 0x%x\n", ret); + return ret; + } + + ret = aes_xts_crypto_init(&key_obj1, &key_obj2, sfd); + if (ret != TEE_SUCCESS) { + tloge("aes xts crypto init failed, ret 0x%x\n", ret); + goto clean; + } + + uint32_t cipher_times = data_in->size / AES_XTS_SINGLE_UNIT; + for (i = 0; i < cipher_times; i++) { + ret = TEE_AllocateOperation(&handle, TEE_ALG_AES_XTS, mode, TEE_MAX_KEY_SIZE_IN_BITS); + if (ret != TEE_SUCCESS) { + tloge("alloc crypto operation failed, ret=0x%x\n", ret); + goto clean; + } + + ret = TEE_SetCryptoFlag(handle, SOFT_CRYPTO); + if (ret != TEE_SUCCESS) + goto clean; + + ret = TEE_SetOperationKey2(handle, &key_obj1, &key_obj2); + if (ret != TEE_SUCCESS) { + tloge("cipher setkey2 failed, ret=0x%x\n", ret); + goto clean; + } + + /* cipher init */ + TEE_CipherInit(handle, (void *)(uintptr_t)tweak->buffer, tweak->size); + + data_out->size = AES_XTS_SINGLE_UNIT; + data_offset = i * AES_XTS_SINGLE_UNIT; + ret = TEE_CipherDoFinal(handle, (void *)(uintptr_t)(data_in->buffer + data_offset), AES_XTS_SINGLE_UNIT, + (void *)(uintptr_t)(data_out->buffer + data_offset), (size_t *)&data_out->size); + if (ret != TEE_SUCCESS) { + tloge("cipher dofinal failed, ret=0x%x\n", ret); + goto clean; + } + + TEE_FreeOperation(handle); + handle = NULL; + } + +clean: + aes_xts_crypto_clean(handle, &key_obj1, &key_obj2); + return ret; +} + +TEE_Result calc_hmac256(struct key_info_t *key_info, const uint8_t *src, int32_t length, + uint8_t *dest, uint32_t *dest_len) +{ + TEE_OperationHandle mac_ops = NULL; + TEE_Result ret; + size_t out_len; + + if (key_info == NULL || src == NULL || dest == NULL || dest_len == NULL || length < 0) + return TEE_ERROR_BAD_PARAMETERS; + + ret = TEE_AllocateOperation(&mac_ops, TEE_ALG_HMAC_SHA256, TEE_MODE_MAC, key_info->key_len); + if (ret != TEE_SUCCESS) + return ret; + + ret = TEE_SetCryptoFlag(mac_ops, SOFT_CRYPTO); + if (ret != TEE_SUCCESS) + goto clean; + + TEE_ObjectHandleVar key_obj; + (void)memset_s((void *)&key_obj, sizeof(key_obj), 0, sizeof(key_obj)); + key_obj.Attribute = TEE_Malloc(sizeof(TEE_Attribute), 0); + if (key_obj.Attribute == NULL) { + tloge("alloc key attr failed\n"); + ret = TEE_ERROR_OUT_OF_MEMORY; + goto clean; + } + + key_obj.Attribute->content.ref.length = key_info->key_len; + key_obj.Attribute->content.ref.buffer = key_info->key; + ret = TEE_SetOperationKey(mac_ops, &key_obj); + if (ret != TEE_SUCCESS) { + tloge("set operation key fail, ret:0x%x", ret); + goto clean; + } + + TEE_MACInit(mac_ops, NULL, 0); + out_len = *dest_len; + ret = TEE_MACComputeFinal(mac_ops, src, (size_t)length, dest, &out_len); + if (ret != 0) { + tloge("TEE MAC error! %x\n", ret); + goto clean; + } + *dest_len = out_len; + ret = TEE_SUCCESS; + +clean: + TEE_FreeOperation(mac_ops); + TEE_Free(key_obj.Attribute); + return ret; +} + +#define BLOCK_SIZE_MAX 0x7D000 /* 500K */ + +TEE_Result cmd_hash(const uint8_t *src_data, uint32_t src_len, uint8_t *dest_data, size_t dest_len) +{ + TEE_OperationHandle crypto_ops = NULL; + uint32_t i, block_count; + TEE_Result ret; + + if ((src_data == NULL) || (dest_data == NULL)) { + tloge("src data or dest data is null"); + return TEE_ERROR_BAD_PARAMETERS; + } + + ret = TEE_AllocateOperation(&crypto_ops, TEE_ALG_SHA256, TEE_MODE_DIGEST, 0); + if (ret != TEE_SUCCESS) { + tloge("TEE_AllocateOperation, fail %x\n", ret); + return ret; + } + + block_count = src_len / BLOCK_SIZE_MAX; + for (i = 0; i < block_count; i++) { + ret = TEE_DigestUpdate(crypto_ops, (void *)(src_data + (uint32_t)(i * BLOCK_SIZE_MAX)), BLOCK_SIZE_MAX); + if (ret != TEE_SUCCESS) { + tloge("TEE_DigestUpdate, fail ret=%x\n", ret); + TEE_FreeOperation(crypto_ops); + return ret; + } + } + + ret = TEE_DigestDoFinal(crypto_ops, (void *)(src_data + (uint32_t)(block_count * BLOCK_SIZE_MAX)), + (src_len % BLOCK_SIZE_MAX), dest_data, &dest_len); + if (ret != TEE_SUCCESS) { + tloge("TEE_DigestDoFinal, fail ret=%x, srclen=%x, dst_len=%x\n", ret, (src_len % BLOCK_SIZE_MAX), dest_len); + TEE_FreeOperation(crypto_ops); + return ret; + } + + TEE_FreeOperation(crypto_ops); + + return TEE_SUCCESS; +} + +#define AES_IV_LEN 16 +TEE_Result aes_cbc_crypto(uint32_t mode, uint8_t *key_value, uint32_t key_size, const uint8_t *iv, + uint32_t iv_size, const uint8_t *data_in, uint32_t data_in_size, uint8_t *data_out) +{ + (void)iv_size; + if (key_value == NULL || iv == NULL || data_in == NULL || data_out == NULL) + return -1; + + TEE_ObjectHandleVar object = { 0 }; + TEE_OperationHandle operation = NULL; + + object.Attribute = TEE_Malloc(sizeof(TEE_Attribute), 0); + if (object.Attribute == NULL) { + tloge("allocate key failed!"); + return TEE_ERROR_OUT_OF_MEMORY; + } + + object.Attribute->content.ref.length = key_size; + object.Attribute->content.ref.buffer = key_value; + + TEE_Result ret = TEE_AllocateOperation(&operation, TEE_ALG_AES_CBC_NOPAD, mode, key_size); + if (ret != TEE_SUCCESS) { + tloge("allocate operation failed, ret = 0x%x", ret); + TEE_Free(object.Attribute); + return ret; + } + + ret = TEE_SetOperationKey(operation, &object); + if (ret != TEE_SUCCESS) { + tloge("set operation key failed, ret = 0x%x", ret); + TEE_Free(object.Attribute); + TEE_FreeOperation(operation); + return ret; + } + + TEE_CipherInit(operation, iv, AES_IV_LEN); + + size_t data_out_size = data_in_size; + ret = TEE_CipherDoFinal(operation, data_in, data_in_size, data_out, &data_out_size); + TEE_Free(object.Attribute); + object.Attribute = NULL; + TEE_FreeOperation(operation); + if (ret != TEE_SUCCESS) + tloge("aes do final failed, ret = 0x%x", ret); + return ret; +} diff --git a/services/ssa/src/secure_storage_agent/ssa_enumerator.c b/services/ssa/src/secure_storage_agent/ssa_enumerator.c index d142a62d..45c04334 100644 --- a/services/ssa/src/secure_storage_agent/ssa_enumerator.c +++ b/services/ssa/src/secure_storage_agent/ssa_enumerator.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2019. All rights reserved. - * Description: enumerator implication - * Author: yanruiqing@huawei.com - * Create: 2019-08-30 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ssa_enumerator.h" #include "string.h" diff --git a/services/ssa/src/secure_storage_agent/ssa_enumerator.h b/services/ssa/src/secure_storage_agent/ssa_enumerator.h index 7544c281..401438ce 100644 --- a/services/ssa/src/secure_storage_agent/ssa_enumerator.h +++ b/services/ssa/src/secure_storage_agent/ssa_enumerator.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: secure storage agent implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __SSA_ENUMERATOR #define __SSA_ENUMERATOR diff --git a/services/ssa/src/secure_storage_agent/ssa_fs.c b/services/ssa/src/secure_storage_agent/ssa_fs.c index 3fac6617..79704296 100644 --- a/services/ssa/src/secure_storage_agent/ssa_fs.c +++ b/services/ssa/src/secure_storage_agent/ssa_fs.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: ssa fs implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "ssa_fs.h" #include diff --git a/services/ssa/src/secure_storage_agent/ssa_fs.h b/services/ssa/src/secure_storage_agent/ssa_fs.h index 42cc0ce4..c8a6ff8b 100644 --- a/services/ssa/src/secure_storage_agent/ssa_fs.h +++ b/services/ssa/src/secure_storage_agent/ssa_fs.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: tee fs implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __SSA_FS_H #define __SSA_FS_H diff --git a/services/ssa/src/secure_storage_agent/ssa_fs_error.h b/services/ssa/src/secure_storage_agent/ssa_fs_error.h index 2b1a2d00..978d3fb0 100644 --- a/services/ssa/src/secure_storage_agent/ssa_fs_error.h +++ b/services/ssa/src/secure_storage_agent/ssa_fs_error.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: secure storage agent implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __SSA_FS_ERRDEF_H #define __SSA_FS_ERRDEF_H diff --git a/services/ssa/src/secure_storage_agent/ssa_helper.c b/services/ssa/src/secure_storage_agent/ssa_helper.c index 930bd5b1..4a59b84e 100644 --- a/services/ssa/src/secure_storage_agent/ssa_helper.c +++ b/services/ssa/src/secure_storage_agent/ssa_helper.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:lBRwzWIfWflpkuvEPG9oHU2mxP0IzvCfvv+i+/xvfe6PT8VRR+8jz7b5YQbqzI49/C6xSBgi -2fFxGZUs+G3nkUIkBkfRerjPcgJTCLqrXspNkFCGTLklL/GZHRhiXBwGnNKhh0MAXEOVfrQU -iukZUWJ4vidruSf/U7e9gpUyQAooCWCSaeb3aIYEst5WD1qne8GcO+5QGB0g7/S8T09ixUGT -nR+osDAHaIEfyoPHfIFAJAQLD0ohh2OwUozrcXB/#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: ssa helper implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "string.h" #include "tee_log.h" diff --git a/services/ssa/src/secure_storage_agent/ssa_helper.h b/services/ssa/src/secure_storage_agent/ssa_helper.h index af3a917a..34cbe58a 100644 --- a/services/ssa/src/secure_storage_agent/ssa_helper.h +++ b/services/ssa/src/secure_storage_agent/ssa_helper.h @@ -1,8 +1,13 @@ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: secure storage agent implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #ifndef __SSA_HELPER_H_ #define __SSA_HELPER_H_ diff --git a/services/ssa/src/secure_storage_agent/tee_ssa_sfs.c b/services/ssa/src/secure_storage_agent/tee_ssa_sfs.c index 8182bdc5..50cf1483 100644 --- a/services/ssa/src/secure_storage_agent/tee_ssa_sfs.c +++ b/services/ssa/src/secure_storage_agent/tee_ssa_sfs.c @@ -1,14 +1,13 @@ -/*$$$!!Warning: Huawei key information asset. No spread without permission.$$$*/ -/*CODEMARK:mJSkoqPZ5FEeD8fzH9bAQfhyPrkcI5cbzjotjI99J9PTkCMNHMtR+8Ejd3mKEkWbMFYmuIhV -lw/je6uplRzXM4SMvhun8vRGD9mNqO2kY4/aQFDUiG2CG+z+BR1XavYOLbgQ6mxl4mdMDMUc -pTTvsgNnGY+uGDhrcSrYT/yiWUcPU+7hHj/1z+1w4sei8NKrE5YtD4ycmPizGfaNhWQY5YvG -yUQ4I+iaikKhay3gs3gbvr2F/fo9kmuK6WNlljMWqZQckvm//k0TiyJFZq4NZA==#*/ -/*$$$!!Warning: Deleting or modifying the preceding information is prohibited.$$$*/ /* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. - * Description: secure storage agent implementation - * Author: Dizhe Mao maodizhe1@huawei.com - * Create: 2018-05-18 + * Copyright (C) 2022 Huawei Technologies Co., Ltd. + * 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. */ #include "tee_defines.h" #include "sfs.h"