From 7b113c9b7514b36595c6f61457f3d061d11340ce Mon Sep 17 00:00:00 2001 From: lihuhua Date: Wed, 6 Jul 2022 14:52:37 +0800 Subject: [PATCH] add itrustee sdk 6.1.1 open source --- CHANGELOG | 12 +- CMakeLists.txt | 36 - Makefile | 17 - README.en.md => README | 6 +- README.md | 20 - build/cmake/aarch64_toolchain.cmake | 14 + build/cmake/common.cmake | 54 + build/mk/{cloud => }/common.mk | 35 +- build/pack-TA/Readme.txt | 12 + build/pack-TA/build_ta.sh | 22 + build/pack-TA/input/Readme.txt | 4 + build/pack-TA/output/Readme.txt | 1 + build/signtools/{cloud => }/config_cloud.ini | 69 +- build/signtools/generate_hash.py | 51 + build/signtools/generate_signature.py | 48 +- build/signtools/get_ta_elf_hash.py | 241 +++ build/signtools/manifest.py | 133 +- .../{cloud => }/rsa_public_key_cloud.pem | 0 build/signtools/signtool_v3.py | 605 +++++-- build/tools/srv_entry_check.sh | 13 + build/tools/ta_entry_check.sh | 52 + build/tools/ta_link_64.ld | 20 +- build/tools/ta_link_64.smee.ld | 262 +++ include/CA/tee_client_api.h | 17 +- include/CA/tee_client_constants.h | 61 +- include/CA/tee_client_list.h | 37 +- include/CA/tee_client_log.h | 7 +- include/CA/tee_client_type.h | 54 +- include/TA/huawei_ext/crypto_wrapper.h | 582 +------ include/TA/huawei_ext/permsrv_api_cert.h | 22 + include/TA/huawei_ext/qsi_data_structure.h | 60 + include/TA/huawei_ext/tee_crypto_err.h | 42 + include/TA/huawei_ext/tee_crypto_hal.h | 11 +- include/TA/huawei_ext/tee_err.h | 31 + include/TA/huawei_ext/tee_ext_api.h | 39 +- include/TA/huawei_ext/tee_hw_ext_api_legacy.h | 293 ++++ include/TA/huawei_ext/tee_log.h | 216 ++- include/TA/huawei_ext/tee_log_legacy.h | 20 + include/TA/huawei_ext/tee_openssl_err.h | 500 ++++++ include/TA/huawei_ext/tee_ra_api.h | 27 + include/TA/pthread_attr.h | 22 + include/TA/tee_arith_api.h | 19 +- include/TA/tee_core_api.h | 2 + include/TA/tee_crypto_api.h | 154 +- include/TA/tee_defines.h | 278 +-- include/TA/tee_mem_mgmt_api.h | 3 +- include/TA/tee_object_api.h | 3 +- include/TA/tee_property_api.h | 3 +- include/TA/tee_time_api.h | 79 +- include/TA/tee_trusted_storage_api.h | 309 ++++ include/TA/tee_uuid.h | 27 + src/CA/{cloud => }/libteec_adaptor.c | 82 +- test/CA/helloworld/{cloud => }/Makefile | 13 +- test/CA/helloworld/ReadMe.txt | 2 - test/CA/helloworld/ca_demo.c | 15 +- test/CA/helloworld/cloud/CMakeLists.txt | 32 - test/TA/helloworld/CMakeLists.txt | 30 + test/TA/helloworld/{cloud => }/Makefile | 13 +- test/TA/helloworld/ReadMe.txt | 7 +- test/TA/helloworld/cloud/CMakeLists.txt | 53 - test/TA/helloworld/config.cmake | 23 + test/TA/helloworld/config.mk | 19 +- test/TA/helloworld/config.sh | 34 + test/TA/helloworld/ta_demo.c | 9 +- .../musl/libc/arch/aarch64/bits/alltypes.h | 245 ++- .../musl/libc/arch/aarch64/bits/syscall.h | 1124 ++++++------ .../musl/libc/arch/arm/bits/alltypes.h | 246 ++- .../musl/libc/arch/arm/bits/syscall.h | 1501 +++++++++-------- .../open_source/musl/libc/arch/arm/crt_arch.h | 27 + .../musl/libc/arch/generic/bits/shm.h | 2 +- thirdparty/open_source/musl/libc/ctype.h | 5 + thirdparty/open_source/musl/libc/float.h | 52 + thirdparty/open_source/musl/libc/limits.h | 2 + thirdparty/open_source/musl/libc/pthread.h | 18 + thirdparty/open_source/musl/libc/stddef.h | 2 - thirdparty/open_source/musl/libc/stdlib.h | 1 + thirdparty/open_source/musl/libc/sys/mman.h | 3 +- thirdparty/open_source/musl/libc/time.h | 2 - 78 files changed, 5074 insertions(+), 3133 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 Makefile rename README.en.md => README (89%) delete mode 100644 README.md create mode 100644 build/cmake/aarch64_toolchain.cmake create mode 100644 build/cmake/common.cmake rename build/mk/{cloud => }/common.mk (30%) mode change 100755 => 100644 create mode 100644 build/pack-TA/Readme.txt create mode 100644 build/pack-TA/build_ta.sh create mode 100644 build/pack-TA/input/Readme.txt create mode 100644 build/pack-TA/output/Readme.txt rename build/signtools/{cloud => }/config_cloud.ini (55%) create mode 100644 build/signtools/generate_hash.py create mode 100644 build/signtools/get_ta_elf_hash.py rename build/signtools/{cloud => }/rsa_public_key_cloud.pem (100%) create mode 100644 build/tools/srv_entry_check.sh create mode 100644 build/tools/ta_entry_check.sh create mode 100644 build/tools/ta_link_64.smee.ld create mode 100644 include/TA/huawei_ext/permsrv_api_cert.h create mode 100644 include/TA/huawei_ext/qsi_data_structure.h create mode 100644 include/TA/huawei_ext/tee_crypto_err.h create mode 100644 include/TA/huawei_ext/tee_err.h create mode 100644 include/TA/huawei_ext/tee_hw_ext_api_legacy.h create mode 100644 include/TA/huawei_ext/tee_log_legacy.h create mode 100644 include/TA/huawei_ext/tee_openssl_err.h create mode 100644 include/TA/huawei_ext/tee_ra_api.h create mode 100644 include/TA/pthread_attr.h create mode 100644 include/TA/tee_trusted_storage_api.h create mode 100644 include/TA/tee_uuid.h rename src/CA/{cloud => }/libteec_adaptor.c (74%) rename test/CA/helloworld/{cloud => }/Makefile (42%) mode change 100755 => 100644 delete mode 100755 test/CA/helloworld/ReadMe.txt delete mode 100644 test/CA/helloworld/cloud/CMakeLists.txt create mode 100644 test/TA/helloworld/CMakeLists.txt rename test/TA/helloworld/{cloud => }/Makefile (64%) mode change 100755 => 100644 delete mode 100644 test/TA/helloworld/cloud/CMakeLists.txt create mode 100644 test/TA/helloworld/config.cmake create mode 100644 test/TA/helloworld/config.sh create mode 100644 thirdparty/open_source/musl/libc/arch/arm/crt_arch.h create mode 100644 thirdparty/open_source/musl/libc/float.h diff --git a/CHANGELOG b/CHANGELOG index 7e22858..e90d34c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,14 @@ -v0.1.0 (Apr 2, 2020) +v5.1.2 (Jun 21, 2021) +====== +Features: +--------- +* add support for cmake +v5.1.1 (May 21, 2021) +====== +Fixes: +------ +* The problem of storing the aeskey file is rectified, and the dependency on the pycryptodomex-3.10.1 plug-in package is introduced. +v5.1.0 (Apr 2, 2020) ====== Features: --------- diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index a7906a9..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required (VERSION 2.8) -project (teec_adaptor) -cmake_policy (SET CMP0037 OLD) - -# Add source files -set(SRCS ./src/CA/cloud/libteec_adaptor.c) - -# Add header file include directories -include_directories( - ./include/CA - ./thirdparty/open_source/liboundscheck/include -) - -# Set options -set(CMAKE_TEEC_ADAPTOR_FLAGS "-fstack-protector-strong -fPIC -ftrapv -s -D_FORTIFY_SOURCE=2 -O2") -set(CMAKE_TEEC_ADAPTOR_FLAGS "${CMAKE_TEEC_ADAPTOR_FLAGS} -z text -z now -z relro -z noexecstack -pie -shared") - -# Set output dir -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}) - -# Generate .so file -add_library(teec_adaptor SHARED ${SRCS}) -set_target_properties(teec_adaptor PROPERTIES COMPILE_FLAGS ${CMAKE_TEEC_ADAPTOR_FLAGS}) - -# Clean output -add_custom_target(clean - COMMAND rm -rf ${PROJECT_SOURCE_DIR}/libteec_adaptor.so - COMMAND @echo "clean up" -) - -# Install -add_custom_target(install - COMMAND install -d /opt/itrustee_sdk - COMMAND cp -rf ${PROJECT_SOURCE_DIR}/build ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/License ${PROJECT_SOURCE_DIR}/thirdparty /opt/itrustee_sdk - COMMAND install -pm 644 ${PROJECT_SOURCE_DIR}/libteec_adaptor.so /lib64 -) diff --git a/Makefile b/Makefile deleted file mode 100644 index 0f5cdff..0000000 --- a/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -CUR_DIR=$(shell pwd) -iTrustee_SDK_PATH=${CUR_DIR} -TARGET_APP := libteec_adaptor.so -APP_SOURCES += $(iTrustee_SDK_PATH)/src/CA/cloud/libteec_adaptor.c -APP_CFLAGS += -fstack-protector-strong -fPIC -ftrapv -s -D_FORTIFY_SOURCE=2 -O2 -APP_CFLAGS += -I$(iTrustee_SDK_PATH)/include/CA -I$(iTrustee_SDK_PATH)/thirdparty/open_source/libboundscheck/include - -APP_LDFLAGS += -z text -z now -z relro -z noexecstack -pie -shared -$(TARGET_APP): $(APP_SOURCE) - @$(CC) $(APP_CFLAGS) $(APP_LDFLAGS) $(APP_SOURCES) -o $@ - -install: $(TARGET_APP) - install -d /opt/itrustee_sdk - cp -r build include License thirdparty /opt/itrustee_sdk - install -pm 644 libteec_adaptor.so /lib64/ -clean: - rm -rf *.o $(TARGET_APP) diff --git a/README.en.md b/README similarity index 89% rename from README.en.md rename to README index 0f159e9..6811e56 100644 --- a/README.en.md +++ b/README @@ -9,12 +9,12 @@ Ensure that the header file path is thirdparty/open_source/libboundscheck/includ This software download address is https://gitee.com/openeuler/libboundscheck. build demo project: -$ cd test/CA/helloworld/cloud +$ cd test/CA/helloworld $ make -$ cd test/TA/helloworld/cloud +$ cd test/TA/helloworld $ make copy build result CA executable file and TA binary(xxx.sec) to /vendor/bin/ #the path "/vendor/bin/" may be changed as your opinion, make sure it consistent with the path defined in your TA's source code -$ /vendor/bin/teec_hello +$ /vendor/bin/demo_hello for more details please refor "iTrustee SDK¿ª·¢ÕßÊÖ²á.chm" diff --git a/README.md b/README.md deleted file mode 100644 index 0f159e9..0000000 --- a/README.md +++ /dev/null @@ -1,20 +0,0 @@ -iTrustee SDK -============ - -Getting Started ---------------- -Before setup your own project, please download libboundscheck software for secure function library. -Decompress the openeuler-libboundscheck-master.zip package, then put this software to thirdparty/open_source path. -Ensure that the header file path is thirdparty/open_source/libboundscheck/include. -This software download address is https://gitee.com/openeuler/libboundscheck. - -build demo project: -$ cd test/CA/helloworld/cloud -$ make -$ cd test/TA/helloworld/cloud -$ make -copy build result CA executable file and TA binary(xxx.sec) to /vendor/bin/ -#the path "/vendor/bin/" may be changed as your opinion, make sure it consistent with the path defined in your TA's source code -$ /vendor/bin/teec_hello - -for more details please refor "iTrustee SDK¿ª·¢ÕßÊÖ²á.chm" diff --git a/build/cmake/aarch64_toolchain.cmake b/build/cmake/aarch64_toolchain.cmake new file mode 100644 index 0000000..97dc45d --- /dev/null +++ b/build/cmake/aarch64_toolchain.cmake @@ -0,0 +1,14 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. +# toolchain.cmake +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR aarch64) + +#set(CMAKE_FIND_ROOT_PATH $ENV{TOOLCHAINS_ROOT}) + +set(CMAKE_C_COMPILER cc CACHE PATH "GCC 64 compiler") +set(CMAKE_LINKER ld CACHE PATH "GCC C64 LD") +set(CMAKE_OBJCOPY objcopy CACHE PATH "GCC 64 objcopy") + +set(CMAKE_SKIP_BUILD_RPATH TRUE CACHE BOOL "" FORCE) +set(CMAKE_C_CREATE_SHARED_LIBRARY " -o ") + diff --git a/build/cmake/common.cmake b/build/cmake/common.cmake new file mode 100644 index 0000000..f18d3f4 --- /dev/null +++ b/build/cmake/common.cmake @@ -0,0 +1,54 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. +# compile flags +set(ITRUSTEE_BUILD_PATH $ENV{ITRUSTEE_BUILD_PATH}) +set(LIBC ${ITRUSTEE_BUILD_PATH}/thirdparty/open_source/musl) +set(LIBSECURE ${ITRUSTEE_BUILD_PATH}/thirdparty/open_source/libboundscheck) + +set(COMMON_INCLUDES + ${COMMON_INCLUDES} + ${LIBC}/libc + ${LIBC}/libc/arch/aarch64 + ${LIBC}/libc/arch/aarch64/bits + ${LIBC}/libc/arch/generic + ${LIBSECURE}/include + ${ITRUSTEE_BUILD_PATH}/include/TA + ${ITRUSTEE_BUILD_PATH}/include/TA/huawei_ext +) + +set(COMMON_CFLAGS + ${COMMON_CFLAGS} + -W + -Wall + -Werror + -fno-short-enums + -fno-omit-frame-pointer + -fstack-protector-strong + -Wextra + -nostdinc + -march=armv8-a -Os + -fPIC + -fno-common + -fsigned-char +) + +set(COMMON_LDFLAGS + ${COMMON_LDFLAGS} + "-s" + "SHELL:-z text" + "SHELL:-z now" + "SHELL:-z relro" + "SHELL:-z noexecstack" + "SHELL:-z max-page-size=0x1000" + "SHELL:-z common-page-size=0x1000" + "-shared" +) + +if ("${USE_SMEE}" STREQUAL "y") + list(APPEND COMMON_LDFLAGS + "-T${ITRUSTEE_BUILD_PATH}/build/tools/ta_link_64.smee.ld" + ) +else() + List(APPEND COMMON_LDFLAGS + "-T${ITRUSTEE_BUILD_PATH}/build/tools/ta_link_64.ld" + ) +endif() diff --git a/build/mk/cloud/common.mk b/build/mk/common.mk old mode 100755 new mode 100644 similarity index 30% rename from build/mk/cloud/common.mk rename to build/mk/common.mk index 73fdd5b..758e92d --- a/build/mk/cloud/common.mk +++ b/build/mk/common.mk @@ -1,21 +1,22 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2018-2021. All rights reserved. CUR_DIR=$(shell pwd) -iTrustee_SDK_PATH=${CUR_DIR}/../../../../ -SIGNTOOL_DIR=${iTrustee_SDK_PATH}/build/signtools/ +ifeq ($(ITRUSTEE_BUILD_PATH), ) + ITRUSTEE_BUILD_PATH=${CUR_DIR}/../../.. +endif +SIGNTOOL_DIR=${ITRUSTEE_BUILD_PATH}/build/signtools -LIBC=$(iTrustee_SDK_PATH)/thirdparty/open_source/musl -LIBSECURE=$(iTrustee_SDK_PATH)/thirdparty/open_source/libboundscheck/ +LIBC=$(ITRUSTEE_BUILD_PATH)/thirdparty/open_source/musl +LIBSECURE=$(ITRUSTEE_BUILD_PATH)/thirdparty/open_source/libboundscheck # set compile parameters -CFLAGS += -O -W -Wall +CFLAGS += -W -Wall CFLAGS += -Werror CFLAGS += -fno-short-enums CFLAGS += -fno-omit-frame-pointer CFLAGS += -fstack-protector-strong -CFLAGS += -Wextra -nostdinc -nodefaultlibs -CFLAGS += -march=armv8-a -Os -Wno-main -fPIC -CFLAGS += -Wno-error=unused-parameter -Wno-error=unused-but-set-variable - -CFLAGS += -DCONFIG_AUTH_CLOUD +CFLAGS += -Wextra -nostdinc +CFLAGS += -march=armv8-a -Os -fPIC +CFLAGS += -fno-common -fsigned-char # set header directory INCLUDEDIR += -I$(LIBC)/libc \ @@ -25,12 +26,14 @@ INCLUDEDIR += -I$(LIBC)/libc \ INCLUDEDIR += -I$(LIBSECURE)/include -INCLUDEDIR += -I$(iTrustee_SDK_PATH)/include/TA/ \ - -I$(iTrustee_SDK_PATH)/include/TA/huawei_ext/ \ - -$(info "include is: "$(INCLUDEDIR)) +INCLUDEDIR += -I$(ITRUSTEE_BUILD_PATH)/include/TA/ \ + -I$(ITRUSTEE_BUILD_PATH)/include/TA/huawei_ext/ \ # set LD flags -LDFLAGS += -s -z text -z now -z relro -z noexecstack -shared +LDFLAGS += -s -z text -z now -z relro -z noexecstack -z max-page-size=0x1000 -z common-page-size=0x1000 -shared -LDFLAGS += -T$(iTrustee_SDK_PATH)/build/tools/ta_link_64.ld +ifeq ($(USE_SMEE),y) + LDFLAGS += -T$(ITRUSTEE_BUILD_PATH)/build/tools/ta_link_64.smee.ld +else + LDFLAGS += -T$(ITRUSTEE_BUILD_PATH)/build/tools/ta_link_64.ld +endif diff --git a/build/pack-TA/Readme.txt b/build/pack-TA/Readme.txt new file mode 100644 index 0000000..05a2a56 --- /dev/null +++ b/build/pack-TA/Readme.txt @@ -0,0 +1,12 @@ +1.TA Signature Packing Preparation Materials, and put these files to build/pack-TA/input folder: +1).libcombine.so TA compilation product +2).manifest.txt Basic TA configuration information +3).config.mk file + +2.Generate rsa key pair by cmd:openssl genrsa -out private_key.pem 4096, +then put this file to build/signtools/TA_cert/, file name must be private_key.pem. + +3.Apply for the TA config certificate from the Huawei contact person, then put this file to +build/signtools/signed_config/, file name must be config. + +4.Run build_TA_Linux_release.sh script. Obtain the signed TA product sec file from build/pack-TA/output folder. \ No newline at end of file diff --git a/build/pack-TA/build_ta.sh b/build/pack-TA/build_ta.sh new file mode 100644 index 0000000..c5cff34 --- /dev/null +++ b/build/pack-TA/build_ta.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Description: preare toolchains and env for build ta. +# Copyright @ Huawei Technologies Co., Ltd. 2021-2022. All rights reserved. +# iTrustee licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS 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 + +LOCAL_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +ITRUSTEE_SDK_PATH=$LOCAL_PATH/../signtools/ + +INPUT_PATH=$LOCAL_PATH/input +OUTPUT_PATH=$LOCAL_PATH/output + +python3 -B ${ITRUSTEE_SDK_PATH}/signtool_v3.py ${INPUT_PATH} ${OUTPUT_PATH} --privateCfg ${ITRUSTEE_SDK_PATH}/config_cloud.ini diff --git a/build/pack-TA/input/Readme.txt b/build/pack-TA/input/Readme.txt new file mode 100644 index 0000000..28ae7f5 --- /dev/null +++ b/build/pack-TA/input/Readme.txt @@ -0,0 +1,4 @@ +TA Signature Packing Preparation Materials, and put these files in this folder: +1).libcombine.so TA compilation product +2).manifest.txt Basic TA configuration information +3).config.mk file \ No newline at end of file diff --git a/build/pack-TA/output/Readme.txt b/build/pack-TA/output/Readme.txt new file mode 100644 index 0000000..da8f565 --- /dev/null +++ b/build/pack-TA/output/Readme.txt @@ -0,0 +1 @@ +The final TA sec file is generated in this path. \ No newline at end of file diff --git a/build/signtools/cloud/config_cloud.ini b/build/signtools/config_cloud.ini similarity index 55% rename from build/signtools/cloud/config_cloud.ini rename to build/signtools/config_cloud.ini index 4d70fcd..14f60ff 100644 --- a/build/signtools/cloud/config_cloud.ini +++ b/build/signtools/config_cloud.ini @@ -1,49 +1,60 @@ -[config] -;0 means debug -;1 means release +[signSecPrivateCfg] +;;; +;private key length for signing TA: ;[fixed value] -releaseType = 1 +;256 ECDSA Alg +;2048/4096 RSA Alg +secSignKeyLen = 4096 ;;; -;0 means TA not installed by OTRP -;1 means TA installed by OTRP -otrpFlag = 0 +;[fixed value] +;0 means SHA256 hash type +;1 means SHA512 hash type +secHashType = 0 ;;; -;server address for signing TA -serverIp= +; [fixed value] +;0 means padding type is pkcs1v15 +;1 means padding type is PSS +;[fixed value] +secPaddingType = 0 ;;; -;public key for encrypt TA ;[fixed value] -encryptKey = cloud/rsa_public_key_cloud.pem +;RSA alg +;ECDSA alg +;SM2 alg +secSignAlg = RSA +;;; +;public key for encrypt TA +secEncryptKey = rsa_public_key_cloud.pem ;;; ;public key length +secEncryptKeyLen = 3072 + +[signSecPublicCfg] +;;; ;[fixed value] -encryptKeyLen = 3072 +; sec sign key type +;0 means debug +;1 means release +secReleaseType = 1 +;;; +;0 means TA not installed by OTRP +;1 means TA installed by OTRP +secOtrpFlag = 0 ;;; ;0 means not sign ;1 means signed by local private ;2 means signed using native sign tool; ;3 means signed by CI ;[fixed value] -signType = 1 +secSignType = 1 +;;; +;server address for signing TA +secSignServerIp = ;;; ;private key for signing TA ;[private key owned by yourself] -signKey = TA_cert/private_key.pem -;;; -;private key length for signing TA -;[key length should be 4096 for security enhance] -signKeyLen = 4096 -;;; -;0 means SHA256 hash type -;1 means SHA512 hash type -;[set value to 0 by default] -hashType = 0 -;;; -;0 means padding type is pkcs1v15 -;1 means padding type is PSS -;[set value to 0 by default] -paddingType = 0 +secSignKey = TA_cert/private_key.pem ;;; ;config file ;[signed config file by Huawei] -configPath= signed_config/config +configPath = signed_config/config diff --git a/build/signtools/generate_hash.py b/build/signtools/generate_hash.py new file mode 100644 index 0000000..58252c8 --- /dev/null +++ b/build/signtools/generate_hash.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# coding:utf-8 +#---------------------------------------------------------------------------- +# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved. +# iTrustee licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS 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: cal hash for generating a trusted application load image +#---------------------------------------------------------------------------- + +import struct +import os +import hashlib +import stat + +HASH256 = 0 +HASH512 = 1 + + +def gen_hash(hash_type, in_data, out_file_path): + # Initialize a SHA256 object from the Python hash library + if int(hash_type) == HASH256: + hash_op = hashlib.sha256() + elif int(hash_type) == HASH512: + hash_op = hashlib.sha512() + hash_op.update(in_data) + + #-----hash file used for ras sign--- + fd_hash = os.open(out_file_path, os.O_WRONLY | os.O_CREAT, \ + stat.S_IWUSR | stat.S_IRUSR) + hash_fp = os.fdopen(fd_hash, "wb") + # fixed hash prefix value + if int(hash_type) == HASH256: + hash_fp.write(struct.pack('B'*19, 0x30, 0x31, 0x30, 0x0d, 0x06, \ + 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, \ + 0x05, 0x00, 0x04, 0x20)) + elif int(hash_type) == HASH512: + hash_fp.write(struct.pack('B'*19, 0x30, 0x51, 0x30, 0x0d, 0x06, \ + 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, \ + 0x05, 0x00, 0x04, 0x40)) + hash_fp.write(hash_op.digest()) + hash_fp.close() + return + + diff --git a/build/signtools/generate_signature.py b/build/signtools/generate_signature.py index 382aa91..b309505 100644 --- a/build/signtools/generate_signature.py +++ b/build/signtools/generate_signature.py @@ -11,44 +11,28 @@ # KIND, EITHER EXPRESS 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: tools for generating a trusted application load image #---------------------------------------------------------------------------- -import struct -import os -import hashlib import subprocess -HASH256 = 0 -HASH512 = 1 +from generate_hash import gen_hash -def gen_hash(hash_type, in_file_path, out_file_path): - in_file_size = os.path.getsize(in_file_path) - # Initialize a SHA256 object from the Python hash library - if int(hash_type) == HASH256: - hash_op = hashlib.sha256() - elif int(hash_type) == HASH512: - hash_op = hashlib.sha512() - # Set the input buffer and return the output digest - with open(in_file_path, 'rb') as in_file: - hash_op.update(in_file.read(in_file_size)) - #-----hash file used for ras sign--- - with open(out_file_path, 'wb') as hash_fp: - # fixed hash prefix value - hash_fp.write(struct.pack('B'*19, 0x30, 0x31, 0x30, 0x0d, 0x06, \ - 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, \ - 0x05, 0x00, 0x04, 0x20)) - hash_fp.write(hash_op.digest()) - return - -def gen_ta_signature(cfg, uuid_str, raw_data_path, hash_file_path, out_file_path): - gen_hash(cfg.hash_type, raw_data_path, hash_file_path) - cmd = "openssl rsautl -sign -inkey {} -in {} -out {}".\ +def gen_ta_signature(cfg, uuid_str, raw_data, raw_data_path, hash_file_path, \ + out_file_path, out_path, key_info_data): + if cfg.sign_type == '1': # signed with local key + gen_hash(cfg.hash_type, raw_data, hash_file_path) + cmd = "openssl rsautl -sign -inkey {} -in {} -out {}".\ format(cfg.sign_key, hash_file_path, out_file_path) - try: - subprocess.check_output(cmd.split(), shell=False) - except Exception: - print("sign operation failed") - raise RuntimeError + try: + subprocess.check_output(cmd.split(), shell=False) + except Exception: + print("sign operation failed") + raise RuntimeError + else: + print("unhandled signtype %s" % cfg.sign_type) + return + diff --git a/build/signtools/get_ta_elf_hash.py b/build/signtools/get_ta_elf_hash.py new file mode 100644 index 0000000..25d4fc3 --- /dev/null +++ b/build/signtools/get_ta_elf_hash.py @@ -0,0 +1,241 @@ +#!/usr/bin/env python3 +# coding:utf-8 +""" +Calculate the elfhash values of TAs by segment and combine the values. +Copyright @ Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. +# iTrustee licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +""" + +from __future__ import print_function +import os +import sys +import hashlib +import struct + + +def elf_header_verify_check(elf_header): + """ check is elf file """ + elfinfo_mag0_index = 0 + elfinfo_mag1_index = 1 + elfinfo_mag2_index = 2 + elfinfo_mag3_index = 3 + elfinfo_mag0 = '\x7f' + elfinfo_mag1 = 'E' + elfinfo_mag2 = 'L' + elfinfo_mag3 = 'F' + + if (elf_header.e_ident[elfinfo_mag0_index] != ord(elfinfo_mag0)) or \ + (elf_header.e_ident[elfinfo_mag1_index] != ord(elfinfo_mag1)) or \ + (elf_header.e_ident[elfinfo_mag2_index] != ord(elfinfo_mag2)) or \ + (elf_header.e_ident[elfinfo_mag3_index] != ord(elfinfo_mag3)): + return False + return True + + +class ElfIdent: + """ define elf ident """ + s = struct.Struct('4sBBB9s') + + def __init__(self, data): + unpacked_data = (ElfIdent.s).unpack(data) + self.unpacked_data = unpacked_data + self.ei_magic = unpacked_data[0] + self.ei_class = unpacked_data[1] + self.ei_data = unpacked_data[2] + self.ei_ver = unpacked_data[3] + self.ei_pad = unpacked_data[4] + + +#---------------------------------------------------------------------------- +# ELF Header Class +#---------------------------------------------------------------------------- +class Elf32Ehdr: + """ 32bit elf file header """ + s = struct.Struct('16sHHIIIIIHHHHHH') + + def __init__(self, data): + unpacked_data = (Elf32Ehdr.s).unpack(data) + self.unpacked_data = unpacked_data + self.e_ident = unpacked_data[0] + self.e_type = unpacked_data[1] + self.e_machine = unpacked_data[2] + self.e_version = unpacked_data[3] + self.e_entry = unpacked_data[4] + self.e_phoff = unpacked_data[5] + self.e_shoff = unpacked_data[6] + self.e_flags = unpacked_data[7] + self.e_ehsize = unpacked_data[8] + self.e_phentsize = unpacked_data[9] + self.e_phnum = unpacked_data[10] + self.e_shentsize = unpacked_data[11] + self.e_shnum = unpacked_data[12] + self.e_shstrndx = unpacked_data[13] + + +class Elf64Ehdr: + """ 64bit elf file header """ + s = struct.Struct('16sHHIQQQIHHHHHH') + + def __init__(self, data): + unpacked_data = (Elf64Ehdr.s).unpack(data) + self.unpacked_data = unpacked_data + self.e_ident = unpacked_data[0] + self.e_type = unpacked_data[1] + self.e_machine = unpacked_data[2] + self.e_version = unpacked_data[3] + self.e_entry = unpacked_data[4] + self.e_phoff = unpacked_data[5] + self.e_shoff = unpacked_data[6] + self.e_flags = unpacked_data[7] + self.e_ehsize = unpacked_data[8] + self.e_phentsize = unpacked_data[9] + self.e_phnum = unpacked_data[10] + self.e_shentsize = unpacked_data[11] + self.e_shnum = unpacked_data[12] + self.e_shstrndx = unpacked_data[13] + + +#---------------------------------------------------------------------------- +# ELF Header Class +#---------------------------------------------------------------------------- +class Elf32Phdr: + """ 32bit elf file Phdr """ + s = struct.Struct('IIIIIIII') + + def __init__(self, data): + unpacked_data = (Elf32Phdr.s).unpack(data) + self.unpacked_data = unpacked_data + self.p_type = unpacked_data[0] + self.p_offset = unpacked_data[1] + self.p_vaddr = unpacked_data[2] + self.p_paddr = unpacked_data[3] + self.p_filesz = unpacked_data[4] + self.p_memsz = unpacked_data[5] + self.p_flags = unpacked_data[6] + self.p_align = unpacked_data[7] + + +class Elf64Phdr: + """ 64bit elf file Phdr """ + s = struct.Struct('IIQQQQQQ') + + def __init__(self, data): + unpacked_data = (Elf64Phdr.s).unpack(data) + self.unpacked_data = unpacked_data + self.p_type = unpacked_data[0] + self.p_flags = unpacked_data[1] + self.p_offset = unpacked_data[2] + self.p_vaddr = unpacked_data[3] + self.p_paddr = unpacked_data[4] + self.p_filesz = unpacked_data[5] + self.p_memsz = unpacked_data[6] + self.p_align = unpacked_data[7] + + +#---------------------------------------------------------------------------- +# generate hash use SHA256 +#---------------------------------------------------------------------------- +def generate_sha256_hash_hex(in_buf): + """ initialize a SHA256 object from the Python hash library """ + m = hashlib.sha256() + # Set the input buffer and return the output digest + m.update(in_buf) + return m.hexdigest() + + +def get_elf_file_hash(file_name): + """ get elf file hash """ + with open(file_name, 'rb') as elf_file_fp: + elf_buf = elf_file_fp.read() + return generate_sha256_hash_hex(elf_buf) + + +class ElfInfo: + """ elf info message """ + + def __init__(self): + self.elf32_phdr_size = 32 + self.elf64_phdr_size = 56 + self.elf_ident_size = 16 + self.elf64_hdr_size = 64 + self.elf32_hdr_size = 52 + self.elfinfo_class_32 = 1 + self.elfinfo_class_64 = 2 + self.load_type = 0x1 + self.write_flag = 0x2 + self.exec_flag = 0x1 + + +def get_code_segment_from_elf(elf_file_name, out_hash_file_name, sign_data): + """ verify ELF header information """ + hash_value_summary = "" + elf_info = ElfInfo() + + with open(elf_file_name, 'rb') as elf_fp: + elf_ident_buf = elf_fp.read(elf_info.elf_ident_size) + elf_ident = ElfIdent(elf_ident_buf) + elf_fp.seek(0) + if elf_ident.ei_class == elf_info.elfinfo_class_64: + elf_hd_buf = elf_fp.read(elf_info.elf64_hdr_size) + elf_header = Elf64Ehdr(elf_hd_buf) + elif elf_ident.ei_class == elf_info.elfinfo_class_32: + elf_hd_buf = elf_fp.read(elf_info.elf32_hdr_size) + elf_header = Elf32Ehdr(elf_hd_buf) + else: + print("No Support ELFINFO_CLASS") + + if elf_header_verify_check(elf_header) is False: + print("ELF file failed verification: %s" % elf_file_name) + + for i_phd in range(0, elf_header.e_phnum): + if elf_ident.ei_class == elf_info.elfinfo_class_64: + elf_phd_header = Elf64Phdr(elf_fp.read(elf_info.elf64_phdr_size)) + elif elf_ident.ei_class == elf_info.elfinfo_class_32: + elf_phd_header = Elf32Phdr(elf_fp.read(elf_info.elf32_phdr_size)) + else: + print("No Support ELFINFO_CLASS") + + if (elf_phd_header.p_type != elf_info.load_type) or \ + (elf_phd_header.p_flags & elf_info.exec_flag != elf_info.exec_flag) or \ + (elf_phd_header.p_flags & elf_info.write_flag == elf_info.write_flag): + continue + + # get segment buf form elf file + elf_fp.seek(elf_phd_header.p_offset) + elf_segment_buf = elf_fp.read(elf_phd_header.p_memsz) + + # buf 4k alignment + if len(elf_segment_buf) % 4096 != 0: + alignment_len = (len(elf_segment_buf) // 4096 + 1) * 4096 + elf_segment_buf = elf_segment_buf.ljust(alignment_len, b'\0') + # get hash from segment buf + hash_value_summary = hash_value_summary + generate_sha256_hash_hex(elf_segment_buf) + + # move the read pointer of the file to the original position. + if elf_ident.ei_class == elf_info.elfinfo_class_64: + elf_fp.seek((i_phd + 1) * elf_info.elf64_phdr_size + elf_info.elf64_hdr_size) + elif elf_ident.ei_class == elf_info.elfinfo_class_32: + elf_fp.seek((i_phd + 1) * elf_info.elf32_phdr_size + elf_info.elf32_hdr_size) + + elf_fp.seek(0) + with os.fdopen(os.open('hash_{}.txt'.format(out_hash_file_name), os.O_RDWR | os.O_CREAT, 0o755), \ + "w+", 0o755) as file_ob: + file_ob.write("mem_hash : {}\n".format(generate_sha256_hash_hex(bytes.fromhex(hash_value_summary)))) + file_ob.write("img_hash : {}".format(generate_sha256_hash_hex(sign_data))) + + +def main(): + """ main function """ + get_code_segment_from_elf(sys.argv[1], "test", sys.argv[3]) + + +if __name__ == '__main__': + main() diff --git a/build/signtools/manifest.py b/build/signtools/manifest.py index 6468190..66aa301 100755 --- a/build/signtools/manifest.py +++ b/build/signtools/manifest.py @@ -11,15 +11,20 @@ # KIND, EITHER EXPRESS 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: tools for generating a trusted application load image #---------------------------------------------------------------------------- import string import struct import uuid import os +import re +import stat -PRODUCT_TA_IMAGE = 1 -PRODUCT_DYN_LIB = 2 -PRODUCT_SERVICE_IMAGE = 3 +PRODUCT_TA_IMAGE = 1 +PRODUCT_DYN_LIB = 2 +PRODUCT_SERVICE_IMAGE = 3 +PRODUCT_CLIENT_IMAGE = 4 +PRODUCT_DRIVER_IMAGE = 5 class PackUuid: @@ -27,12 +32,12 @@ class PackUuid: data = struct.Struct('IHH8b') def __init__(self, data): - unpacked_data = (PackUuid.data).unpack(str.encode(data)) - self.unpacked_data = unpacked_data - self.time_low = unpacked_data[0] - self.time_mid = unpacked_data[1] + unpacked_data = (PackUuid.data).unpack(str.encode(data)) + self.unpacked_data = unpacked_data + self.time_low = unpacked_data[0] + self.time_mid = unpacked_data[1] self.time_hi_version = unpacked_data[2] - self.clock_seq_node = unpacked_data[3] + self.clock_seq_node = unpacked_data[3] def print_values(self): print("ATTRIBUTE / VALUE") @@ -58,13 +63,13 @@ class Manifest: data = struct.Struct('I' * 6) def __init__(self, data): - unpacked_data = (Manifest.data).unpack(str.encode(data)) - self.unpacked_data = unpacked_data + unpacked_data = (Manifest.data).unpack(str.encode(data)) + self.unpacked_data = unpacked_data self.single_instance = unpacked_data[0] - self.multi_session = unpacked_data[1] - self.multi_command = unpacked_data[2] - self.heap_size = unpacked_data[3] - self.stack_size = unpacked_data[4] + self.multi_session = unpacked_data[1] + self.multi_command = unpacked_data[2] + self.heap_size = unpacked_data[3] + self.stack_size = unpacked_data[4] self.instancekeepalive = unpacked_data[5] def print_values(self): @@ -127,7 +132,6 @@ def trailing_space_tabs(str_line): print('trailing space tabs in value head and trail') space_tabs = chr(9) + chr(32) + chr(160) space_tabs_newlines = space_tabs + chr(10) + chr(13) - print('tab: {}'.format(space_tabs)) print('str in: {}'.format(str_line)) index = 0 @@ -174,8 +178,12 @@ def parser_manifest(manifest, manifest_data_path, mani_ext): manifest_val.stack_size = 2048 service_name = 'external_service' + dyn_conf_target_type = 0 - with open(manifest, 'r') as mani_fp, open(mani_ext, 'wb') as mani_ext_fp: + with open(manifest, 'r') as mani_fp: + fd_ext = os.open(mani_ext, os.O_WRONLY | os.O_CREAT, \ + stat.S_IWUSR | stat.S_IRUSR) + mani_ext_fp = os.fdopen(fd_ext, "wb") for each_line in mani_fp: print(each_line) if each_line.startswith("#") or not len(each_line.strip()): @@ -194,10 +202,12 @@ def parser_manifest(manifest, manifest_data_path, mani_ext): if verify_property_name(prop_name) is False: print('manifest format invalid, please check it') + mani_ext_fp.close() return (False, 0) if verify_property_value(prop_value_v) is False: print('manifest format invalid, please check it') + mani_ext_fp.close() return (False, 0) # name:value to lowcase, and parse manifest @@ -257,27 +267,60 @@ def parser_manifest(manifest, manifest_data_path, mani_ext): service_name = prop_value_v print('b') + elif 'gpd.ta.dynconf' == prop_name_low: + mani_ext_fp.close() + raise Exception("gpd.ta.dynConf is reserved, cannot set") + else: print('b') #write have not paresed manifest into sample.manifest file mani_ext_fp.write(str.encode(prop_name_t)) mani_ext_fp.write(str.encode(prop_value)) - if 'gpd.ta.is_tee_service' == prop_name_low: - prop_value_low = prop_value_v.lower() - if 'true' == prop_value_low: - target_type = PRODUCT_SERVICE_IMAGE - elif 'gpd.ta.is_lib' == prop_name_low: + if 'gpd.ta.is_lib' == prop_name_low: prop_value_low = prop_value_v.lower() if 'true' == prop_value_low: target_type = PRODUCT_DYN_LIB - + elif 'gpd.ta.target_type' == prop_name_low: + dyn_conf_target_type = int(prop_value_v) + if dyn_conf_target_type > 0xFFFF or \ + dyn_conf_target_type < 0: + mani_ext_fp.close() + raise RuntimeError("target_type " + \ + str(dyn_conf_target_type) + \ + " must in range [0, 0xFFFF]") + + mani_ext_fp.close() #write the whole parsed manifest into sample.manifest file service_name_len = len(service_name) print('service name: {}'.format(service_name)) print('service name len: {}'.format(service_name_len)) - if service_name_len > 64: - print("service name len exceed MAX value 27") + + max_service_len = 64 + + # dyn_conf_target_type is 1 means that is drv + if dyn_conf_target_type == 1: + max_service_len = 32 + target_type = PRODUCT_DRIVER_IMAGE + if not re.match(r"^[A-Za-z0-9_]*$", service_name): + raise RuntimeError("drv's name only can use \ + [A-Z] [a-z] [0-9] and '_'") + + if dyn_conf_target_type == 3: + max_service_len = 32 + target_type = PRODUCT_SERVICE_IMAGE + if not re.match(r"^[A-Za-z0-9_]*$", service_name): + raise RuntimeError("drv's name only can use \ + [A-Z] [a-z] [0-9] and '_'") + if dyn_conf_target_type == 4: + max_service_len = 32 + target_type = PRODUCT_CLIENT_IMAGE + if not re.match(r"^[A-Za-z0-9_]*$", service_name): + raise RuntimeError("drv's name only can use \ + [A-Z] [a-z] [0-9] and '_'") + + if service_name_len > max_service_len: + print("service name len cannot larger than " + str(max_service_len)) raise RuntimeError # get manifest string file len @@ -296,24 +339,48 @@ def parser_manifest(manifest, manifest_data_path, mani_ext): print("manifest strint: {}".format(manifest_string_buf)) #---- write manifest parse context to manifest file - with open(manifest_data_path, 'wb') as out_manifest_fp: - out_manifest_fp.write(uuid_val.bytes_le) - out_manifest_fp.write(str.encode(service_name)) - out_manifest_fp.write(manifest_val.get_pack_data()) - + fd_out = os.open(manifest_data_path, os.O_WRONLY | os.O_CREAT, \ + stat.S_IWUSR | stat.S_IRUSR) + out_manifest_fp = os.fdopen(fd_out, "wb") + out_manifest_fp.write(uuid_val.bytes_le) + out_manifest_fp.write(str.encode(service_name)) + out_manifest_fp.write(manifest_val.get_pack_data()) + out_manifest_fp.close() + + uuid_str = str(uuid_val) product_name = str(uuid_val) if target_type == PRODUCT_TA_IMAGE: print("product type is ta image") - product_name = "".join([product_name, ".sec"]) + product_name = "".join([uuid_str, ".sec"]) + elif target_type == PRODUCT_DRIVER_IMAGE: + print("product type is driver") + product_name = "".join([service_name, ".sec"]) elif target_type == PRODUCT_SERVICE_IMAGE: print("product type is service") - product_name = "".join([product_name, service_name, "_svr.sec"]) + product_name = "".join([service_name, ".sec"]) + elif target_type == PRODUCT_CLIENT_IMAGE: + print("product type is client") + product_name = "".join([service_name, ".so.sec"]) elif target_type == PRODUCT_DYN_LIB: print("product type is dyn lib") - product_name = "".join([product_name, service_name, ".so.sec"]) + product_name = "".join([uuid_str, service_name, ".so.sec"]) else: print("invalid product type!") raise RuntimeError - return (True, product_name) + return (True, product_name, uuid_str) + + +def process_manifest_file(xml_config_path, manifest_path, \ + manifest_data_path, mani_ext): + + manifest_txt_exist = True + if not os.path.exists(manifest_path): + print("xml trans manifest cfg") + manifest_txt_exist = False + from xml_trans_manifest import trans_xml_to_manifest + trans_xml_to_manifest(xml_config_path, manifest_path) + ret, product_name, uuid_str = parser_manifest(manifest_path, \ + manifest_data_path, mani_ext) + return (ret, product_name, uuid_str, manifest_txt_exist) diff --git a/build/signtools/cloud/rsa_public_key_cloud.pem b/build/signtools/rsa_public_key_cloud.pem similarity index 100% rename from build/signtools/cloud/rsa_public_key_cloud.pem rename to build/signtools/rsa_public_key_cloud.pem diff --git a/build/signtools/signtool_v3.py b/build/signtools/signtool_v3.py index 39a719d..357dce0 100755 --- a/build/signtools/signtool_v3.py +++ b/build/signtools/signtool_v3.py @@ -11,31 +11,32 @@ # KIND, EITHER EXPRESS 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: tools for generating a trusted application load image #---------------------------------------------------------------------------- import struct import os import stat -import hashlib import binascii -import subprocess import shutil -import getpass import argparse +import configparser +import re -try: - from configparser import SafeConfigParser -except ImportError: - from ConfigParser import SafeConfigParser -from manifest import parser_manifest +from manifest import process_manifest_file from generate_signature import gen_ta_signature +from Cryptodome.Hash import SHA256 +from Cryptodome.Cipher import PKCS1_OAEP +from Cryptodome.PublicKey import RSA +from Cryptodome.Cipher import AES +from Cryptodome.Random import get_random_bytes + # fixed value, {1, 2} version are abandoned. VERSION = 3 TA_VERSION = 3 -MAX_EXT_PROP_LEN = 152 MAGIC1 = 0xA5A55A5A MAGIC2 = 0x55AA @@ -63,6 +64,20 @@ ELF_INFO_VERSION_INDEX = 6 ELF_INFO_VERSION_CURRENT = 1 ELF_BLOCK_ALIGN = 0x1000 +SEC_HEADER_BYTES = 16 + + +def whitelist_check(intput_str): + if not re.match(r"^[A-Za-z0-9\/\-_.]+$", intput_str): + return 1 + return 0 + + +def integer_check(intput_str): + if not str(intput_str).isdigit(): + return 1 + return 0 + #---------------------------------------------------------------------------- # Verify ELF header contents from an input ELF file @@ -91,33 +106,115 @@ def verify_elf_header(elf_path): return -class Configuration: - release_type = 0 - otrp_flag = 0 - sign_type = 0 +class AllCfg: + release_type = "1" + otrp_flag = "0" + sign_type = "0" public_key = "" - pub_key_len = 0 + pub_key_len = "" + re_sign_flag = "0" server_ip = "" config_path = "" sign_key = "" - sign_key_len = 2048 - hash_type = 0 - padding_type = 0 + sign_alg = "RSA" - def __init__(self, file_name): - parser = SafeConfigParser() + +class PublicCfg: + def __init__(self, file_name, all_cfg): + cfg_section = "signSecPublicCfg" + parser = configparser.ConfigParser() parser.read(file_name) - self.release_type = parser.get("config", "releaseType") - self.otrp_flag = parser.get("config", "otrpFlag") - self.sign_type = parser.get("config", "signType") - self.public_key = parser.get("config", "encryptKey") - self.pub_key_len = parser.get("config", "encryptKeyLen") - self.server_ip = parser.get("config", "serverIp") - self.config_path = parser.get("config", "configPath") - self.sign_key = parser.get("config", "signKey") - self.sign_key_len = parser.get("config", "signKeyLen") - self.hash_type = parser.get("config", "hashType") - self.padding_type = parser.get("config", "paddingType") + + if parser.has_option(cfg_section, "secReleaseType"): + all_cfg.release_type = parser.get(cfg_section, "secReleaseType") + if parser.has_option(cfg_section, "secOtrpFlag"): + all_cfg.otrp_flag = parser.get(cfg_section, "secOtrpFlag") + + all_cfg.sign_type = parser.get(cfg_section, "secSignType") + if parser.has_option(cfg_section, "secSignServerIp"): + all_cfg.server_ip = parser.get(cfg_section, "secSignServerIp") + + all_cfg.config_path = parser.get(cfg_section, "configPath") + all_cfg.sign_key = parser.get(cfg_section, "secSignKey") + + +class PrivateCfg: + def __init__(self, file_name, all_cfg): + cfg_section = 'signSecPrivateCfg' + parser = configparser.ConfigParser() + parser.read(file_name) + + if parser.has_option(cfg_section, "secEncryptKey"): + all_cfg.public_key = parser.get(cfg_section, "secEncryptKey") + + if parser.has_option(cfg_section, "secEncryptKeyLen"): + all_cfg.pub_key_len = parser.get(cfg_section, "secEncryptKeyLen") + + if parser.has_option(cfg_section, "secReSignFlag"): + all_cfg.re_sign_flag = parser.get(cfg_section, "secReSignFlag") + + all_cfg.hash_type = parser.get(cfg_section, "secHashType") + all_cfg.sign_key_len = parser.get(cfg_section, "secSignKeyLen") + all_cfg.padding_type = parser.get(cfg_section, "secPaddingType") + + if parser.has_option(cfg_section, "secSignAlg"): + all_cfg.sign_alg = parser.get(cfg_section, "secSignAlg") + + +def check_cfg(cfg): + if cfg.release_type != "": + if integer_check(cfg.release_type): + print("secReleaseType is invalid.") + return 1 + if cfg.otrp_flag != "": + if integer_check(cfg.otrp_flag): + print("secOtrpFlag is invalid.") + return 1 + if cfg.sign_type != "": + if integer_check(cfg.sign_type): + print("secSignType is invalid.") + return 1 + if cfg.server_ip != "": + if whitelist_check(cfg.server_ip): + print("secSignServerIp is invalid.") + return 1 + if cfg.config_path != "": + if whitelist_check(cfg.config_path): + print("configPath is invalid.") + return 1 + if cfg.sign_key != "": + if whitelist_check(cfg.sign_key): + print("secSignKey is invalid.") + return 1 + if cfg.public_key != "": + if whitelist_check(cfg.public_key): + print("secEncryptKey is invalid.") + return 1 + if cfg.pub_key_len != "": + if integer_check(cfg.pub_key_len): + print("secEncryptKeyLen is invalid.") + return 1 + if cfg.re_sign_flag != "": + if integer_check(cfg.re_sign_flag): + print("secReSignFlag is invalid.") + return 1 + if cfg.hash_type != "": + if integer_check(cfg.hash_type): + print("secHashType is invalid.") + return 1 + if cfg.sign_key_len != "": + if integer_check(cfg.sign_key_len): + print("secSignKeyLen is invalid.") + return 1 + if cfg.padding_type != "": + if integer_check(cfg.padding_type): + print("secPaddingType is invalid.") + return 1 + if cfg.sign_alg != "": + if whitelist_check(cfg.sign_alg): + print("secSignAlg is invalid.") + return 1 + return 0 def gen_header(content_len, key_version): @@ -125,60 +222,76 @@ def gen_header(content_len, key_version): key_version) -def gen_aes_key_info(cfg, iv_file_path, key_file_path, out_file_path): - rand_iv_cmd = "openssl rand -out {} 16".format(iv_file_path) - rand_key_cmd = "openssl rand -out {} 32".format(key_file_path) - try: - subprocess.check_output(rand_iv_cmd.split(), shell=False) - subprocess.check_output(rand_key_cmd.split(), shell=False) - except Exception: - print("rand operation failed") - raise RuntimeError - - os.chmod(iv_file_path, stat.S_IWUSR | stat.S_IRUSR) - os.chmod(key_file_path, stat.S_IWUSR | stat.S_IRUSR) - +def get_sign_alg(cfg): sign_alg = 0 sign_alg = sign_alg | (int(cfg.release_type) << 28) sign_alg = sign_alg | (int(cfg.padding_type) << 27) sign_alg = sign_alg | (int(cfg.hash_type) << 26) - if cfg.sign_key_len == "2048": - sign_alg = sign_alg | 0x00002048 - elif cfg.sign_key_len == "4096": - sign_alg = sign_alg | 0x00004096 + if cfg.sign_alg == "RSA": + sign_alg = sign_alg | (2 << 20) + elif cfg.sign_alg == "ECDSA": + sign_alg = sign_alg | (1 << 20) + if cfg.sign_type == '4': + sign_alg = sign_alg | 0x0000C000 + else: + if cfg.sign_key_len == "2048": + sign_alg = sign_alg | 0x00002048 + elif cfg.sign_key_len == "4096": + sign_alg = sign_alg | 0x00004096 + elif cfg.sign_key_len == "256": + sign_alg = sign_alg | 0x00000256 + return sign_alg - print("sign_alg value is 0x%x" % sign_alg) - with open(out_file_path, 'wb') as out_file: - out_file.write(struct.pack('I', 32)) - out_file.write(struct.pack('I', 16)) - out_file.write(struct.pack('I', sign_alg)) - with open(key_file_path, 'rb') as key_file: - out_file.write(key_file.read(32)) +def gen_aes_key_info(cfg): + iv_data = get_random_bytes(16) + key_data = get_random_bytes(32) - with open(iv_file_path, 'rb') as iv_file: - out_file.write(iv_file.read(16)) + sign_alg = get_sign_alg(cfg) + key_info = struct.pack('<3I', 32, 16, sign_alg) + key_info += key_data + key_info += iv_data + return key_data, iv_data, key_info + + +def gen_sign_alg_info(cfg, out_file_path): + sign_alg = get_sign_alg(cfg) + print("sign_alg value is 0x%x" % sign_alg) + + fd_out = os.open(out_file_path, os.O_WRONLY | os.O_CREAT, \ + stat.S_IWUSR | stat.S_IRUSR) + out_file = os.fdopen(fd_out, "wb") + out_file.write(struct.pack('I', 0)) + out_file.write(struct.pack('I', 0)) + out_file.write(struct.pack('I', sign_alg)) + out_file.close() - os.chmod(out_file_path, stat.S_IWUSR | stat.S_IRUSR) return -def encrypt_aes_key(pubkey_path, in_path, out_path): - cmd = "openssl rsautl -encrypt -pubin -oaep -inkey {} -in {} -out {}". \ - format(pubkey_path, in_path, out_path) - try: - subprocess.check_output(cmd.split(), shell=False) - except Exception: - print("RSA encrypt operation failed") - raise RuntimeError - os.chmod(out_path, stat.S_IWUSR | stat.S_IRUSR) +def encrypt_aes_key(pubkey_path, in_data, out_path): + with open(pubkey_path, 'rb') as pubkey_file_fd: + pubkey_file = pubkey_file_fd.read(os.path.getsize(pubkey_path)) + pubkey = RSA.importKey(pubkey_file) + cipher = PKCS1_OAEP.new(pubkey) + ciphertext = cipher.encrypt(in_data) + + fd_out = os.open(out_path, os.O_WRONLY | os.O_CREAT, \ + stat.S_IWUSR | stat.S_IRUSR) + out_file = os.fdopen(fd_out, "wb") + out_file.write(ciphertext) + out_file.close() return -def gen_signature(cfg, uuid_str, raw_data_path, hash_file_path, out_file_path): - gen_ta_signature(cfg, uuid_str, raw_data_path, hash_file_path, out_file_path) + +def gen_signature(cfg, uuid_str, raw_data, raw_data_path, hash_file_path, \ + out_file_path, out_path, key_info_data): + gen_ta_signature(cfg, uuid_str, raw_data, raw_data_path, \ + hash_file_path, out_file_path, out_path, key_info_data) os.chmod(out_file_path, stat.S_IWUSR | stat.S_IRUSR) return + def gen_raw_data(manifest_data_path, manifest_ext_path, elf_file_path, \ config_path, raw_file_path): manifest_size = os.path.getsize(manifest_data_path) @@ -186,87 +299,97 @@ def gen_raw_data(manifest_data_path, manifest_ext_path, elf_file_path, \ elf_size = os.path.getsize(elf_file_path) config_size = 0 - if manifest_ext_size > MAX_EXT_PROP_LEN: - print("too much data in \"manifest.txt\" to be handled. \ - extra string len %d" \ - % manifest_ext_size) - raise RuntimeError - verify_elf_header(elf_file_path) - with open(raw_file_path, 'wb') as file_op: - header = "" - if os.path.isfile(config_path): - config_size = os.path.getsize(config_path) - header = struct.pack('IIIII', TA_VERSION, manifest_size, \ - manifest_ext_size, \ - elf_size, config_size) - file_op.write(header) - - with open(manifest_data_path, 'rb') as manifest_data: - file_op.write(manifest_data.read(manifest_size)) - - with open(manifest_ext_path, 'rb') as manifest_ext: - file_op.write(manifest_ext.read(manifest_ext_size)) - - with open(elf_file_path, 'rb') as elf: - file_op.write(elf.read(elf_size)) - if config_size != 0: - with open(config_path, 'rb') as config: - file_op.write(config.read(config_size)) + fd_op = os.open(raw_file_path, os.O_WRONLY | os.O_CREAT, \ + stat.S_IWUSR | stat.S_IRUSR) + file_op = os.fdopen(fd_op, "wb") + header = "" + if os.path.isfile(config_path): + config_size = os.path.getsize(config_path) + header = struct.pack('IIIII', TA_VERSION, manifest_size, \ + manifest_ext_size, \ + elf_size, config_size) + file_op.write(header) + + with open(manifest_data_path, 'rb') as manifest_data: + file_op.write(manifest_data.read(manifest_size)) + + with open(manifest_ext_path, 'rb') as manifest_ext: + file_op.write(manifest_ext.read(manifest_ext_size)) + + with open(elf_file_path, 'rb') as elf: + file_op.write(elf.read(elf_size)) + if config_size != 0: + with open(config_path, 'rb') as config: + file_op.write(config.read(config_size)) + file_op.close() return -def aes_encrypt(key_path, iv_path, in_file_path, out_file_path): - key_size = os.path.getsize(key_path) - with open(key_path, 'rb') as key_file: - key_data = key_file.read(key_size) - hex_key_str = binascii.b2a_hex(key_data) - - iv_size = os.path.getsize(iv_path) - with open(iv_path, 'rb') as iv_file: - iv_data = iv_file.read(iv_size) - hex_iv_str = binascii.b2a_hex(iv_data) - - cmd = "openssl enc -aes-256-cbc -in {} -out {} -K {} -iv {}".\ - format(in_file_path, out_file_path, \ - bytes.decode(hex_key_str), bytes.decode(hex_iv_str)) - try: - subprocess.check_output(cmd.split(), shell=False) - except Exception: - print("AES encrypt operation failed") - raise RuntimeError +def aes_encrypt(key_data, iv_data, in_file_path, out_file_path): + in_size = os.path.getsize(in_file_path) + with open(in_file_path, 'rb') as in_file: + in_data = in_file.read(in_size) + padding = 16 - in_size % 16 + in_data += bytes([padding]) * padding + + cipher = AES.new(key_data, AES.MODE_CBC, iv_data) + ciphertext = cipher.encrypt(in_data) + + fd_out = os.open(out_file_path, os.O_WRONLY | os.O_CREAT, \ + stat.S_IWUSR | stat.S_IRUSR) + out_file = os.fdopen(fd_out, "wb") + out_file.write(ciphertext) + out_file.close() - os.chmod(out_file_path, stat.S_IWUSR | stat.S_IRUSR) return -def parser_api_level(compile_config): +def parser_api_level(mk_compile_cfg, cmake_compile_cfg): default_api_level = 1 - if not os.path.exists(compile_config): - print("TA Make Config doesn't exist, ignore it") + compile_cfg_file = '' + + # The config.mk file is first searched. + # The config.cmake file is searched only when the config.mk file does + # not exist. If the API_LEVEL macro is not defined in either of the + # two files, the default value LEVEL 1 is used. + if os.path.exists(mk_compile_cfg): + compile_cfg_file = mk_compile_cfg + elif os.path.exists(cmake_compile_cfg): + compile_cfg_file = cmake_compile_cfg + else: + print("Build config file doesn't exist, ignore it") return default_api_level - with open(compile_config) as file_op: + + with open(compile_cfg_file) as file_op: for line in file_op: if line.startswith("#") or not "-DAPI_LEVEL" in line: continue key, value = line.strip().split("-DAPI_LEVEL=") print("key info {}".format(key)) - print(("ta_api_level = {}".format(value))) - return value + print(("ta_api_level = {}".format(value[0]))) + return value[0] + + print("Build Config file doesn't define API_LEVEL") return default_api_level -def update_api_level(compile_config, manifest): +def update_api_level(mk_compile_cfg, cmake_compile_cfg, manifest): data = '' with open(manifest, 'r') as file_op: for line in file_op: if line.startswith("#") or not "gpd.ta.api_level" in line: data += line - line = "\ngpd.ta.api_level:{}\n".format(parser_api_level(compile_config)) + + api_level = parser_api_level(mk_compile_cfg, cmake_compile_cfg) + line = "\ngpd.ta.api_level:{}\n".format(api_level) data += line - with open(manifest, "w") as file_op: - file_op.writelines(data) + fd_op = os.open(manifest, os.O_WRONLY | os.O_CREAT, \ + stat.S_IWUSR | stat.S_IRUSR) + file_op = os.fdopen(fd_op, "w") + file_op.writelines(data) + file_op.close() def update_otrp_flag(manifest): @@ -277,38 +400,64 @@ def update_otrp_flag(manifest): data += line line = "\ngpd.ta.otrp_flag:{}\n".format('true') data += line - with open(manifest, "w") as file_op: - file_op.writelines(data) + fd_op = os.open(manifest, os.O_WRONLY | os.O_CREAT, \ + stat.S_IWUSR | stat.S_IRUSR) + file_op = os.fdopen(fd_op, "w") + file_op.writelines(data) + file_op.close() -def gen_data_for_sign(header, key_info, raw_file, data_sign): - key_info_len = os.path.getsize(key_info) +def gen_data_for_sign(header, key_data, raw_file): raw_file_len = os.path.getsize(raw_file) + with open(raw_file, 'rb') as raw_fp: + raw_data = raw_fp.read(raw_file_len) - with open(data_sign, 'wb') as data_fp, \ - open(key_info, 'rb') as key_fp, open(raw_file, 'rb') as raw_fp: - data_fp.write(header) - data_fp.write(key_fp.read(key_info_len)) - data_fp.write(raw_fp.read(raw_file_len)) + data_sign = header + data_sign += key_data + data_sign += raw_data + return data_sign def gen_key_version(cfg): if cfg.pub_key_len == '3072': return int(0x0202) - if cfg.pub_key_len == '2048': + elif cfg.pub_key_len == '2048': return int(0x0002) + elif cfg.pub_key_len == '': + return int(0x0000) + print("unhandled pulic key len %s" % cfg.pub_key_len) raise RuntimeError +def pack_signature(signature_path, signature_size): + add_size = 72 - signature_size + with open(signature_path, 'rb+') as signature_file: + signature_buf = signature_file.read(signature_size) + signature_file.seek(0) + for index in range(0, add_size): + signature_file.write(b'\x00') + signature_file.write(signature_buf) + + +def check_if_is_drv(manifest_path): + with open(manifest_path, 'r') as mani_fp: + for each_line in mani_fp: + if each_line.startswith("#") or not len(each_line.strip()): + continue + name = each_line.split(":")[0].strip() + if name == "gpd.ta.target_type" and \ + str(each_line.split(":")[1].strip()) == "1": + return 1 + return 0 + + def gen_sec_image(in_path, out_path, cfg): # temporary files - temp_path = os.path.join(in_path, "temp") + temp_path = os.path.join(out_path, "temp") shutil.rmtree(temp_path, ignore_errors=True) os.mkdir(temp_path) os.chmod(temp_path, stat.S_IRWXU) - iv_file_path = os.path.join(temp_path, "iv.bin") - key_file_path = os.path.join(temp_path, "aeskey.bin") key_info_path = os.path.join(temp_path, "KeyInfo") enc_key_path = os.path.join(temp_path, "KeyInfo.enc") raw_file_path = os.path.join(temp_path, "rawData") @@ -322,64 +471,152 @@ def gen_sec_image(in_path, out_path, cfg): # mandentory input files manifest_path = os.path.join(in_path, "manifest.txt") elf_file_path = os.path.join(in_path, "libcombine.so") - compile_config_path = os.path.join(in_path, "config.mk") - - ret, product_name = parser_manifest(manifest_path, \ - manifest_data_path, manifest_ext_path) + mk_cfg_path = os.path.join(in_path, "config.mk") + cmake_cfg_path = os.path.join(in_path, "config.cmake") + dyn_conf_xml_file_path = os.path.join(in_path, "dyn_perm.xml") + tag_parse_dict_file_path = os.path.join(os.getcwd(), "tag_parse_dict.csv") + xml_config_path = os.path.join(in_path, "configs.xml") + + is_encrypt_sec = True + if cfg.public_key == "" or cfg.pub_key_len == "": + is_encrypt_sec = False + + # 1. parser_manifest + ret, product_name, uuid_str, manifest_txt_exist = \ + process_manifest_file(xml_config_path, \ + manifest_path, manifest_data_path, manifest_ext_path) if ret is False: raise RuntimeError - update_api_level(compile_config_path, manifest_ext_path) + # 2. update_api_level + update_api_level(mk_cfg_path, cmake_cfg_path, manifest_ext_path) - if cfg.otrp_flag == 1: + # 3. update_otrp_flag + if cfg.otrp_flag == "1": print("package otrp sec file\n") update_otrp_flag(manifest_ext_path) + # 4. parser_dyn_conf + if os.path.exists(dyn_conf_xml_file_path): + from dyn_conf_parser import parser_dyn_conf + parser_dyn_conf(dyn_conf_xml_file_path, manifest_ext_path, \ + tag_parse_dict_file_path, in_path) + else: + if check_if_is_drv(manifest_path) == 1: + if not os.path.exists(cfg.config_path): + ans = "gpd.ta.dynConf:00000\n" + manifest_ext_path_fd = os.open(manifest_ext_path, \ + os.O_RDWR, 0o600) + with os.fdopen(manifest_ext_path_fd, 'a+') as mani_ext_fp: + mani_ext_fp.write(ans) + + # 5. gen_raw_data gen_raw_data(manifest_data_path, manifest_ext_path, elf_file_path, \ cfg.config_path, raw_file_path) - # generate AES key info to encrypt raw data - gen_aes_key_info(cfg, iv_file_path, key_file_path, key_info_path) - encrypt_aes_key(cfg.public_key, key_info_path, enc_key_path) - - aes_encrypt(key_file_path, iv_file_path, raw_file_path, enc_raw_path) + if cfg.sign_type == '4': + sign_len = 0 + else: + if int(cfg.sign_key_len) == 256: + sign_len = 72 + else: + sign_len = int(cfg.sign_key_len) / 8 + + # 6. gen aes key, and encrypt aes key with RSA key, + # and encrypt raw data with aes key + if is_encrypt_sec is True: + # generate AES key info to encrypt raw data + key_data, iv_data, key_info_data = gen_aes_key_info(cfg) + encrypt_aes_key(cfg.public_key, key_info_data, enc_key_path) + aes_encrypt(key_data, iv_data, raw_file_path, enc_raw_path) + + # generate Main Header + content_len = os.path.getsize(enc_key_path) \ + + sign_len \ + + os.path.getsize(enc_raw_path) + else: + gen_sign_alg_info(cfg, key_info_path) + # generate Main Header + content_len = os.path.getsize(key_info_path) \ + + sign_len \ + + os.path.getsize(raw_file_path) + with open(key_info_path, 'rb') as key_info_fp: + key_info_data = key_info_fp.read(os.path.getsize(key_info_path)) - # generate Main Header - content_len = os.path.getsize(enc_key_path) + \ - (int(cfg.sign_key_len) / 8) + \ - os.path.getsize(enc_raw_path) key_version = gen_key_version(cfg) header = gen_header(int(content_len), key_version) + data_for_sign = gen_data_for_sign(header, key_info_data, raw_file_path) - gen_data_for_sign(header, key_info_path, raw_file_path, data_for_sign_path) - - uuid_str = product_name[0:36] + uuid_str = uuid_str[0:36] print('uuid str {}'.format(uuid_str)) - gen_signature(cfg, uuid_str, data_for_sign_path, hash_path, signature_path) + # 7. gen signature + gen_signature(cfg, uuid_str, data_for_sign, data_for_sign_path, \ + hash_path, signature_path, out_path, key_info_data) + + if os.path.exists("get_ta_elf_hash.py"): + if os.path.exists(elf_file_path): + from get_ta_elf_hash import get_code_segment_from_elf + get_code_segment_from_elf(elf_file_path, uuid_str, data_for_sign) + + # 8. pack sec img: header || key || signature || raw_data + signature_size = os.path.getsize(signature_path) + if sign_len == 72: + if signature_size != 72: + pack_signature(signature_path, signature_size) + elif sign_len == 0: + sign_len = signature_size + # generate Main Header + if is_encrypt_sec is True: + key_data_path = enc_key_path + raw_data_path = enc_raw_path + else: + key_data_path = key_info_path + raw_data_path = raw_file_path + content_len = os.path.getsize(key_data_path) \ + + sign_len \ + + os.path.getsize(raw_data_path) + header = gen_header(int(content_len), key_version) sec_img_path = os.path.join(out_path, product_name) - with open(sec_img_path, 'wb') as sec_image: - # write to sec file [1.header info] - sec_image.write(header) + fd_image = os.open(sec_img_path, os.O_WRONLY | os.O_CREAT, \ + stat.S_IWUSR | stat.S_IRUSR) + sec_image = os.fdopen(fd_image, "wb") + # write to sec file [1.header info] + sec_image.write(header) + if is_encrypt_sec is True: # write to sec file [2.AES key info] enc_key_size = os.path.getsize(enc_key_path) with open(enc_key_path, 'rb') as enc_key_info: sec_image.write(enc_key_info.read(enc_key_size)) - # write to sec file [3.signature] - signature_size = os.path.getsize(signature_path) - with open(signature_path, 'rb') as signature_file: - sec_image.write(signature_file.read(signature_size)) + else: + key_info_size = os.path.getsize(key_info_path) + with open(key_info_path, 'rb') as key_info_fp: + sec_image.write(key_info_fp.read(key_info_size)) + # write to sec file [3.signature] + signature_size = os.path.getsize(signature_path) + with open(signature_path, 'rb') as signature_file: + sec_image.write(signature_file.read(signature_size)) + if is_encrypt_sec is True: # write to sec file [4.encrypted raw data] enc_raw_size = os.path.getsize(enc_raw_path) with open(enc_raw_path, 'rb') as enc_raw_data: sec_image.write(enc_raw_data.read(enc_raw_size)) + else: + raw_file_size = os.path.getsize(raw_file_path) + with open(raw_file_path, 'rb') as raw_file_data: + sec_image.write(raw_file_data.read(raw_file_size)) + sec_image.truncate(int(SEC_HEADER_BYTES) + int(content_len)) + sec_image.close() print("=========================SUCCESS============================") - print("generate TA(V3 format) load image success: ") + print("generate sec(common format) load image success: ") print(sec_img_path) print("============================================================") + if manifest_txt_exist is False and os.path.exists(manifest_path): + os.remove(manifest_path) + #remove temp files shutil.rmtree(temp_path) return @@ -392,17 +629,47 @@ def main(): (libcombine.so; manifest.txt; ...", type=str) parser.add_argument("out_path", help="input path of signed file. \ (xxx.sec)", type=str) - parser.add_argument("--config", help="sign configuation file", type=str) + parser.add_argument("--publicCfg", \ + help="sign cfg for ta developer", type=str) + parser.add_argument("--privateCfg", \ + help="sign cfg for product developer", type=str) args = parser.parse_args() - if args.config: - cfg = Configuration(args.config) + cfg = AllCfg() + if args.privateCfg: + PrivateCfg(args.privateCfg, cfg) else: - cfg = Configuration(os.path.join(sign_tool_dir, "config.ini")) + print("please config private cfg file") + raise RuntimeError + if args.publicCfg: + PublicCfg(args.publicCfg, cfg) + else: + PublicCfg(args.privateCfg, cfg) + + if check_cfg(cfg): + print("the configuration file field is incorrect.") + exit() in_path = os.path.abspath(args.in_path) out_path = os.path.abspath(args.out_path) + if not os.path.exists(in_path): + print("input_path does not exist.") + exit() + if not os.path.exists(out_path): + print("out_path does not exist.") + exit() + if whitelist_check(in_path): + print("input_path is incorrect.") + exit() + if whitelist_check(out_path): + print("out_path is incorrect.") + exit() os.chdir(sign_tool_dir) - gen_sec_image(in_path, out_path, cfg) + + if cfg.re_sign_flag == "1": + from re_generate_signature import re_sign_sec_img + re_sign_sec_img(in_path, out_path, cfg) + else: + gen_sec_image(in_path, out_path, cfg) if __name__ == '__main__': diff --git a/build/tools/srv_entry_check.sh b/build/tools/srv_entry_check.sh new file mode 100644 index 0000000..870076c --- /dev/null +++ b/build/tools/srv_entry_check.sh @@ -0,0 +1,13 @@ +#!/bin/bash +# Copyright Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. +set -e + +echo "------------- check SRV tee_task_entry begin --------------" +task_entry=$($1 -s $2 | grep -w tee_task_entry) || true +if [[ "$task_entry" != "" ]]; then + exit 0 +else + echo "----- SRV should define tee_task_entry symbol ---" + exit 1 +fi +echo "------------- check SRV tee_task_entry succ --------------" diff --git a/build/tools/ta_entry_check.sh b/build/tools/ta_entry_check.sh new file mode 100644 index 0000000..eab72a3 --- /dev/null +++ b/build/tools/ta_entry_check.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# Copyright Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. +# iTrustee licensed under the Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan +# PSL v2. +# You may obtain a copy of Mulan PSL v2 at: +# http://license.coscl.org.cn/MulanPSL2 +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY +# KIND, EITHER EXPRESS 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 + +#params: $1-readelf cmd; $2-libcombine.so; $3-USE_ENTRY_BINARY; $4-DYN_LINK; $5-TARGET_IS_ARM64 + +# if USE_ENTRY_BINARY is y, means link elf_main_entry.o +# no need to check +if [ "$3" == "y" ]; then + echo "------ no need to check task_entry ----" + exit 0 +fi + +# for ta not link elf_main_entry.o +# should not define tee_task_entry symbol +echo "------------- check TA tee_task_entry begin --------------" +task_entry=$($1 -s $2 | grep -w tee_task_entry) || true +if [[ "$task_entry" != "" ]]; then + echo "----- ERROR TA should not define tee_task_entry symbol ---" + echo " $task_entry" + exit 1 +fi +echo "------------- check TA tee_task_entry succ --------------" + +# if TARGET_IS_ARM64 is y, means is aarch64 TA +# for aarch64 ta no need to compile ta_magic.c +if [ "$5" == "y" ]; then + echo "------- aarch64 TA no need check magic ----" + exit 0 +fi + +# if DYN_LINK is y, means is DYN TA +# for 32bit dyn ta should compile ta_magic.c +# since it not link elf_main_entry.o +task_magic=$($1 -S $2 | grep -w ".magic") || true +if [ "$4" == "y" ]; then + echo "------- check TA magic begin ------" + if [[ "$task_magic" == "" ]]; then + echo "------ ERROR DYN TA should compile ta_magic.c -----" + exit 1 + fi; + echo "------- check TA magic succ ------" +fi diff --git a/build/tools/ta_link_64.ld b/build/tools/ta_link_64.ld index 61388e0..a3eb30a 100644 --- a/build/tools/ta_link_64.ld +++ b/build/tools/ta_link_64.ld @@ -8,6 +8,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: Describe the link file for 64bits TA */ OUTPUT_FORMAT("elf64-littleaarch64", "elf64-bigaarch64", @@ -19,6 +20,7 @@ SECTIONS { /* Read-only sections, merged into text segment: */ . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; + _start = .; /* This should be the first section after program headers */ .magic : { *(.magic) } .note.gnu.build-id : { *(.note.gnu.build-id) } @@ -49,7 +51,14 @@ SECTIONS *(.rela.plt) *(.rela.iplt) } - .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata : + { + *(.rodata .rodata.* .gnu.linkonce.r.*) + . = ALIGN(16); + PROVIDE (__start___llvm_prf_names = .); + *(__llvm_prf_names) + PROVIDE (__stop___llvm_prf_names = .); + } .rodata1 : { *(.rodata1) } .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) } .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } @@ -150,6 +159,15 @@ SECTIONS { PROVIDE (__data_start = .); *(.data .data.* .gnu.linkonce.d.*) + PROVIDE (__start___llvm_prf_cnts = .); + *(__llvm_prf_cnts) + PROVIDE (__stop___llvm_prf_cnts = .); + PROVIDE (__start___llvm_prf_data = .); + *(__llvm_prf_data) + PROVIDE (__stop___llvm_prf_data = .); + PROVIDE (__start___llvm_prf_vnds = .); + *(__llvm_prf_vnds); + PROVIDE (__stop___llvm_prf_vnds = .); SORT(CONSTRUCTORS) } .data1 : { *(.data1) } diff --git a/build/tools/ta_link_64.smee.ld b/build/tools/ta_link_64.smee.ld new file mode 100644 index 0000000..db72a53 --- /dev/null +++ b/build/tools/ta_link_64.smee.ld @@ -0,0 +1,262 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2019-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS 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: Describe the link file for 64bits TA + */ + +OUTPUT_FORMAT("elf64-littleaarch64", "elf64-bigaarch64", + "elf64-littleaarch64") +OUTPUT_ARCH(aarch64) +ENTRY(_start) +SEARCH_DIR("=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/lib64"); SEARCH_DIR("=/usr/local/lib64"); SEARCH_DIR("=/lib64"); SEARCH_DIR("=/usr/lib64"); SEARCH_DIR("=/home/tcwg-buildslave/workspace/tcwg-make-release/builder_arch/amd64/label/tcwg-x86_64-build/target/aarch64-linux-gnu/_build/builds/destdir/x86_64-unknown-linux-gnu/aarch64-linux-gnu/lib"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); + +PHDRS +{ + phdr PT_PHDR PHDRS FLAGS (4); + text PT_LOAD FILEHDR PHDRS FLAGS (5); + xtext PT_LOAD FLAGS (1); + smee 0x65656d73 AT(smee_start) FLAGS (6); + data PT_LOAD FLAGS (6); + dynamic PT_DYNAMIC FLAGS (6); + relro 0x6474e552 FLAGS (4); + stack PT_GNU_STACK FLAGS (6); +} + +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; + _start = .; + /* This should be the first section after program headers */ + .magic : { *(.magic) } : text + .note.gnu.build-id : { *(.note.gnu.build-id) } + .hash : { *(.hash) } + .gnu.hash : { *(.gnu.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + *(.rela.ifunc) + } + .rela.plt : + { + *(.rela.plt) + *(.rela.iplt) + } + .rodata : + { + *(.rodata .rodata.* .gnu.linkonce.r.*) + . = ALIGN(16); + PROVIDE (__start___llvm_prf_names = .); + *(__llvm_prf_names) + PROVIDE (__stop___llvm_prf_names = .); + } + .rodata1 : { *(.rodata1) } + .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) } + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } + .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table + .gcc_except_table.*) } + .gnu_extab : ONLY_IF_RO { *(.gnu_extab*) } + /* These sections are generated by the Sun/Oracle C++ compiler. */ + .exception_ranges : ONLY_IF_RO { *(.exception_ranges + .exception_ranges*) } + /* Make sure the address of text segment is aligned in 4k for xom */ + . = ALIGN(0x1000); + .init : + { + KEEP (*(SORT_NONE(.init))) + } : xtext =0 + .plt : ALIGN(16) { *(.plt) *(.iplt) } + .text : + { + *(.text.unlikely .text.*_unlikely .text.unlikely.*) + *(.text.exit .text.exit.*) + *(.text.startup .text.startup.*) + *(.text.hot .text.hot.*) + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + } =0 + .fini : + { + KEEP (*(SORT_NONE(.fini))) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + + . = ALIGN(0x1000); + PROVIDE_HIDDEN (smee_start = .); + .smee : ALIGN(0x1000) + { + *(sram_protection_section) + *(smee* .smee* .*smee) + } : smee + + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); + /* Exception handling */ + .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } + .gnu_extab : ONLY_IF_RW { *(.gnu_extab) } + .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } + .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } + /* Thread Local Storage sections */ + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + .preinit_array : + { + KEEP (*(.preinit_array)) + } + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*))) + KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors)) + PROVIDE_HIDDEN (__init_array_end = .); + } + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*))) + KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors)) + PROVIDE_HIDDEN (__fini_array_end = .); + } + .ctors : + { + /* gcc uses crtbegin.o to find the start of + the constructors, so we make sure it is + first. Because this is a wildcard, it + doesn't matter if the user does not + actually link against crtbegin.o; the + linker won't look for a file to match a + wildcard. The wildcard also means that it + doesn't matter which directory crtbegin.o + is in. */ + KEEP (*crtbegin.o(.ctors)) + KEEP (*crtbegin?.o(.ctors)) + /* We don't want to include the .ctor section from + the crtend.o file until after the sorted ctors. + The .ctor section from the crtend file contains the + end of ctors marker and it must be last */ + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors)) + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + } + .dtors : + { + KEEP (*crtbegin.o(.dtors)) + KEEP (*crtbegin?.o(.dtors)) + KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors)) + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + } + .jcr : { KEEP (*(.jcr)) } + .data.rel.ro : + { + *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) + *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) + } : data : relro + .dynamic : { *(.dynamic) } : data : dynamic : relro + .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } : data : relro + . = DATA_SEGMENT_RELRO_END (0, .); + .data : + { + PROVIDE (__data_start = .); + *(.data .data.* .gnu.linkonce.d.*) + PROVIDE (__start___llvm_prf_cnts = .); + *(__llvm_prf_cnts) + PROVIDE (__stop___llvm_prf_cnts = .); + PROVIDE (__start___llvm_prf_data = .); + *(__llvm_prf_data) + PROVIDE (__stop___llvm_prf_data = .); + PROVIDE (__start___llvm_prf_vnds = .); + *(__llvm_prf_vnds); + PROVIDE (__stop___llvm_prf_vnds = .); + SORT(CONSTRUCTORS) + } : data + .data1 : { *(.data1) } + _edata = .; PROVIDE (edata = .); + . = .; + __bss_start = .; + __bss_start__ = .; + TA_BSS_START = .; + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + . = ALIGN(. != 0 ? 64 / 8 : 1); + } : data + TA_BSS_END = .; + _bss_end__ = . ; __bss_end__ = . ; + . = ALIGN(64 / 8); + . = SEGMENT_START("ldata-segment", .); + . = ALIGN(64 / 8); + __end__ = . ; + _end = .; PROVIDE (end = .); + . = DATA_SEGMENT_END (.); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + /* DWARF 3 */ + .debug_pubtypes 0 : { *(.debug_pubtypes) } + .debug_ranges 0 : { *(.debug_ranges) } + /* DWARF Extension. */ + .debug_macro 0 : { *(.debug_macro) } + .debug_addr 0 : { *(.debug_addr) } + .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) } + .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) } + /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) } +} diff --git a/include/CA/tee_client_api.h b/include/CA/tee_client_api.h index c139d4d..637c110 100644 --- a/include/CA/tee_client_api.h +++ b/include/CA/tee_client_api.h @@ -8,6 +8,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: TEE client API definitions */ #ifndef _TEE_CLIENT_API_H_ @@ -24,7 +25,7 @@ #include #include "tee_client_type.h" -#include +#include "tee_client_log.h" #ifdef __cplusplus extern "C" { @@ -44,7 +45,7 @@ extern "C" { * initializes a new TEE Context, forming a connection between this Client Application and the TEE * * @param name [IN] TEE name (unused) - * @param context [IN/OUT] pointer to TEEC_Context to be initialized + * @param context [OUT] pointer to TEEC_Context to be initialized * * @return TEEC_SUCCESS operation success * @return TEEC_ERROR_BAD_PARAMETERS invalid parameter @@ -74,11 +75,11 @@ void TEEC_FinalizeContext( * @param connectionData [IN] any necessary data required to support the connection method * @param operation [IN/OUT] a pointer to an Operation containing a set of Parameters to exchange with the * Trusted Application - * @param returnOrigin [IN/OUT] a pointer to a variable which will contain the return origin, This field may be NULL + * @param returnOrigin [OUT] a pointer to a variable which will contain the return origin, This field may be NULL * if the return origin is not needed * * @return TEEC_SUCCESS operation success - * @return TEEC_ERROR_BAD_PARAMETERS invalid parameter£¬context or session or destination is NULL + * @return TEEC_ERROR_BAD_PARAMETERS invalid parameter, context or session or destination is NULL * @return TEEC_ERROR_ACCESS_DENIED client Application's connection request is denied * @return TEEC_ERROR_OUT_OF_MEMORY system resource is out of use * @return TEEC_ERROR_TRUSTED_APP_LOAD_ERROR load Trusted Application failed @@ -109,10 +110,10 @@ void TEEC_CloseSession( * @param session [IN/OUT] the open Session in which the command will be invoked * @param commandID [IN] the identifier of the Command within the Trusted Application to invoke * @param operation [IN/OUT] a pointer to a Client Application initialized TEEC_Operation structure - * @param returnOrigin [IN/OUT] a pointer to a variable which will contain the return origin + * @param returnOrigin [OUT] a pointer to a variable which will contain the return origin * * @return TEEC_SUCCESS operation success - * @return TEEC_ERROR_BAD_PARAMETERS invalid parameter£¬session is NULL or operation data invalid + * @return TEEC_ERROR_BAD_PARAMETERS invalid parameter, session is NULL or operation data invalid * @return TEEC_ERROR_ACCESS_DENIED invoke command operation is denied * @return TEEC_ERROR_OUT_OF_MEMORY system resource is out of use * @return others refer TEEC_ReturnCode @@ -155,8 +156,8 @@ TEEC_Result TEEC_AllocateSharedMemory( /* * deregisters or deallocates a previously initialized block of Shared Memory - * if memory is allocated by ¹ýTEEC_AllocateSharedMemory, system will free this memory - * if memory is registered by ¹ýTEEC_RegisterSharedMemory, system will not free this memory + * if memory is allocated by TEEC_AllocateSharedMemory, system will free this memory + * if memory is registered by TEEC_RegisterSharedMemory, system will not free this memory * * @param sharedMem [IN/OUT] a pointer to a valid Shared Memory structure * diff --git a/include/CA/tee_client_constants.h b/include/CA/tee_client_constants.h index 9ddff9b..ba5b9d2 100644 --- a/include/CA/tee_client_constants.h +++ b/include/CA/tee_client_constants.h @@ -8,38 +8,39 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: static definitions of client API */ #ifndef _TEE_CLIENT_CONSTANTS_H_ #define _TEE_CLIENT_CONSTANTS_H_ enum TEEC_ReturnCode { - TEEC_SUCCESS = 0x0, /* success */ - TEEC_ERROR_INVALID_CMD, /* invalid command */ - TEEC_ERROR_SERVICE_NOT_EXIST, /* target service is not exist */ - TEEC_ERROR_SESSION_NOT_EXIST, /* session between client and service is not exist */ - TEEC_ERROR_SESSION_MAXIMUM, /* exceed max num of sessions */ - TEEC_ERROR_REGISTER_EXIST_SERVICE, /* cannot register the service which already exist */ - TEEC_ERROR_TAGET_DEAD_FATAL, /* system error occurs in TEE */ - TEEC_ERROR_READ_DATA, /* failed to read data in file */ - TEEC_ERROR_WRITE_DATA, /* failed to write data to file */ - TEEC_ERROR_TRUNCATE_OBJECT, /* data is truncated */ - TEEC_ERROR_SEEK_DATA, /* failed to seek data in file */ - TEEC_ERROR_FSYNC_DATA, /* failed to sync data in file */ - TEEC_ERROR_RENAME_OBJECT, /* failed to rename file */ - TEEC_ERROR_TRUSTED_APP_LOAD_ERROR, /* failed to load Trusted Application */ - TEEC_ERROR_GENERIC = 0xFFFF0000, /* generic error occurs */ - TEEC_ERROR_ACCESS_DENIED = 0xFFFF0001, /* permission check failed, in initilize context or - open session or invoke commnad */ - TEEC_ERROR_CANCEL = 0xFFFF0002, /* operation is already canceled */ + TEEC_SUCCESS = 0x0, /* success */ + TEEC_ERROR_INVALID_CMD, /* invalid command */ + TEEC_ERROR_SERVICE_NOT_EXIST, /* target service is not exist */ + TEEC_ERROR_SESSION_NOT_EXIST, /* session between client and service is not exist */ + TEEC_ERROR_SESSION_MAXIMUM, /* exceed max num of sessions */ + TEEC_ERROR_REGISTER_EXIST_SERVICE, /* cannot register the service which already exist */ + TEEC_ERROR_TAGET_DEAD_FATAL, /* system error occurs in TEE */ + TEEC_ERROR_READ_DATA, /* failed to read data in file */ + TEEC_ERROR_WRITE_DATA, /* failed to write data to file */ + TEEC_ERROR_TRUNCATE_OBJECT, /* data is truncated */ + TEEC_ERROR_SEEK_DATA, /* failed to seek data in file */ + TEEC_ERROR_FSYNC_DATA, /* failed to sync data in file */ + TEEC_ERROR_RENAME_OBJECT, /* failed to rename file */ + TEEC_ERROR_TRUSTED_APP_LOAD_ERROR, /* failed to load Trusted Application */ + TEEC_ERROR_GENERIC = 0xFFFF0000, /* generic error occurs */ + TEEC_ERROR_ACCESS_DENIED = 0xFFFF0001, /* permission check failed, in initilize context or + open session or invoke commnad */ + TEEC_ERROR_CANCEL = 0xFFFF0002, /* operation is already canceled */ TEEC_ERROR_ACCESS_CONFLICT = 0xFFFF0003, /* confilct occurs in concurrent access to data, error occurs in file operaions generally */ - TEEC_ERROR_EXCESS_DATA = 0xFFFF0004, /* exceed max data to be handled by system */ - TEEC_ERROR_BAD_FORMAT = 0xFFFF0005, /* data format is invalid, Trusted Application cannot - handle it */ - TEEC_ERROR_BAD_PARAMETERS = 0xFFFF0006, /* invalid parameters */ - TEEC_ERROR_BAD_STATE = 0xFFFF0007, /* operation failed in current state, when try to access - storage without initilize storage service */ + TEEC_ERROR_EXCESS_DATA = 0xFFFF0004, /* exceed max data to be handled by system */ + TEEC_ERROR_BAD_FORMAT = 0xFFFF0005, /* data format is invalid, Trusted Application cannot + handle it */ + TEEC_ERROR_BAD_PARAMETERS = 0xFFFF0006, /* invalid parameters */ + TEEC_ERROR_BAD_STATE = 0xFFFF0007, /* operation failed in current state, when try to access + storage without initilize storage service */ TEEC_ERROR_ITEM_NOT_FOUND = 0xFFFF0008, /* cannot find target item */ TEEC_ERROR_NOT_IMPLEMENTED = 0xFFFF0009, /* request operation is not implemented */ TEEC_ERROR_NOT_SUPPORTED = 0xFFFF000A, /* request operation is not supported */ @@ -52,7 +53,13 @@ enum TEEC_ReturnCode { TEEC_ERROR_SHORT_BUFFER = 0xFFFF0010, /* out buffer is not enough for current request */ TEEC_ERROR_MAC_INVALID = 0xFFFF3071, /* MAC value check failed */ TEEC_ERROR_TARGET_DEAD = 0xFFFF3024, /* Trusted Application is crashed */ - TEEC_FAIL = 0xFFFF5002 /* reserved error code */ + TEEC_FAIL = 0xFFFF5002, /* common error */ + TEEC_ERROR_EXTERNAL_CANCEL = 0xFFFF0011, /* used by adapt only, event caused User Interface operation aborted */ + TEEC_ERROR_OVERFLOW = 0xFFFF300F, /* used by adapt only */ + TEEC_ERROR_STORAGE_NO_SPACE = 0xFFFF3041, /* used by adapt only */ + TEEC_ERROR_SIGNATURE_INVALID = 0xFFFF3072, /* used by adapt only */ + TEEC_ERROR_TIME_NOT_SET = 0xFFFF5000, /* used by adapt only */ + TEEC_ERROR_TIME_NEEDS_RESET = 0xFFFF5001 /* used by adapt only */ }; enum TEEC_ReturnCodeOrigin { @@ -66,6 +73,7 @@ enum TEEC_SharedMemCtl { TEEC_MEM_INPUT = 0x1, /* input type of memroy */ TEEC_MEM_OUTPUT = 0x2, /* output type of memory */ TEEC_MEM_INOUT = 0x3, /* memory is used as both input and output */ + TEEC_MEM_SHARED_INOUT = 0x4, /* no copy shared memory */ }; enum TEEC_ParamType { @@ -79,6 +87,7 @@ enum TEEC_ParamType { refer TEEC_TempMemoryReference */ TEEC_ION_INPUT = 0x08, /* input type of icon memory reference, refer TEEC_IonReference */ TEEC_ION_SGLIST_INPUT = 0x09, /* input type of ion memory block reference, refer TEEC_IonSglistReference */ + TEEC_MEMREF_SHARED_INOUT = 0x0a, /* no copy mem */ TEEC_MEMREF_WHOLE = 0xc, /* use whole memory block, refer TEEC_RegisteredMemoryReference */ TEEC_MEMREF_PARTIAL_INPUT = 0xd, /* input type of memory reference, refer TEEC_RegisteredMemoryReference */ TEEC_MEMREF_PARTIAL_OUTPUT = 0xe, /* output type of memory reference, refer TEEC_RegisteredMemoryReference */ @@ -103,7 +112,7 @@ enum TEEC_LoginMethod { TEEC_LOGIN_GROUP_APPLICATION = 0x6, /* Login data about the group running the Client Application and about the Client Application itself is provided */ - TEEC_LOGIN_IDENTIFY = 0x7, /* iTrustee defined login type, Login data is provided by REE system */ + TEEC_LOGIN_IDENTIFY = 0x7, /* Login data is provided by REE system */ }; enum TST_CMD_ID { TST_CMD_ID_01 = 1, diff --git a/include/CA/tee_client_list.h b/include/CA/tee_client_list.h index 4aa6a53..b606984 100644 --- a/include/CA/tee_client_list.h +++ b/include/CA/tee_client_list.h @@ -8,6 +8,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: linked list data types and basic operations */ #ifndef TEE_CLIENT_LIST_H @@ -23,8 +24,8 @@ struct ListNode { #define LIST_DECLARE(name) \ struct ListNode name = { \ - .next = &name, \ - .prev = &name, \ + .next = &(name), \ + .prev = &(name), \ } static inline void ListInit(struct ListNode *list) @@ -80,25 +81,25 @@ static inline struct ListNode *ListRemoveTail(struct ListNode *list) } #define LIST_ENTRY(ptr, type, member) \ - ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) + ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->(member)))) #define LIST_FOR_EACH(pos, list) \ - for (pos = (list)->next; pos != (list); pos = pos->next) + for ((pos) = (list)->next; (pos) != (list); (pos) = (pos)->next) #define LIST_FOR_EACH_SAFE(pos, n, list) \ - for ((pos) = (list)->next, (n) = (pos)->next; \ - (pos) != (list); \ - (pos) = (n), (n) = (pos)->next) - -#define LIST_FOR_EACH_ENTRY(pos, list, member) \ - for (pos = LIST_ENTRY((list)->next, typeof(*pos), member); \ - &pos->member != (list); \ - pos = LIST_ENTRY(pos->member.next, typeof(*pos), member)) - -#define LIST_FOR_EACH_ENTRY_SAFE(pos, n, list, member) \ - for (pos = LIST_ENTRY((list)->next, typeof(*pos), member), \ - n = LIST_ENTRY(pos->member.next, typeof(*pos), member); \ - &pos->member != (list); \ - pos = n, n = LIST_ENTRY(n->member.next, typeof(*n), member)) + for ((pos) = (list)->next, (n) = (pos)->next; (pos) != (list); (pos) = (n), (n) = (pos)->next) + +#define LIST_FOR_EACH_ENTRY(pos, list, member) \ + do { \ + for ((pos) = LIST_ENTRY((list)->next, typeof(*(pos)), (member)); &(pos)->(member) != (list); \ + (pos) = LIST_ENTRY((pos)->(member).next, typeof(*(pos)), (member))) \ + } while (0) + +#define LIST_FOR_EACH_ENTRY_SAFE(pos, n, list, member) \ + do { \ + for ((pos) = LIST_ENTRY((list)->next, typeof(*(pos)), (member)), \ + (n) = LIST_ENTRY((pos)->(member).next, typeof(*(pos)), (member)); \ + &(pos)->(member) != (list); (pos) = (n), (n) = LIST_ENTRY((n)->(member).next, typeof(*(n)), (member))) \ + } while (0) #endif diff --git a/include/CA/tee_client_log.h b/include/CA/tee_client_log.h index e3b7fae..69abcb6 100644 --- a/include/CA/tee_client_log.h +++ b/include/CA/tee_client_log.h @@ -8,19 +8,20 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: TEE client log api */ #ifndef TEE_CLIENT_LOG_H #define TEE_CLIENT_LOG_H -#include +#include #ifdef TEEC_DEBUG -#define TEEC_Debug(...) syslog(LOG_USER | LOG_INFO, __VA_ARGS__); +#define TEEC_Debug(fmt, args...) printf("%s: " fmt, __func__, ## args) #else #define TEEC_Debug(...) #endif -#define TEEC_Error(...) syslog(LOG_USER | LOG_INFO, __VA_ARGS__); +#define TEEC_Error(fmt, args...) printf("%s: " fmt, __func__, ## args) #endif diff --git a/include/CA/tee_client_type.h b/include/CA/tee_client_type.h index c5b97e3..3566633 100644 --- a/include/CA/tee_client_type.h +++ b/include/CA/tee_client_type.h @@ -8,47 +8,20 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: data type and structure definition according to GP */ #ifndef _TEE_CLIENT_TYPE_H_ #define _TEE_CLIENT_TYPE_H_ +#include +#include #include #include #include #include "tee_client_list.h" #include "tee_client_constants.h" -typedef unsigned int uint32_t; - -typedef signed int int32_t; - -typedef unsigned short uint16_t; - -typedef signed short int16_t; - -typedef unsigned char uint8_t; - -typedef signed char int8_t; - -#ifndef __cplusplus -#ifndef bool -#define bool uint8_t -#endif -#endif - -#ifndef true -#define true 1 -#endif - -#ifndef false -#define false 0 -#endif - -#ifndef NULL -#define NULL 0 -#endif - typedef enum TEEC_ReturnCode TEEC_Result; typedef struct { @@ -63,17 +36,23 @@ typedef struct { uint8_t *ta_path; struct ListNode session_list; struct ListNode shrd_mem_list; - struct { - void *buffer; - sem_t buffer_barrier; - } share_buffer; + union { + struct { + void *buffer; + sem_t buffer_barrier; + } share_buffer; + uint64_t imp; /* for adapt */ + }; } TEEC_Context; typedef struct { uint32_t session_id; TEEC_UUID service_id; uint32_t ops_cnt; - struct ListNode head; + union { + struct ListNode head; + uint64_t imp; /* for adapt */ + }; TEEC_Context *context; } TEEC_Session; @@ -83,7 +62,10 @@ typedef struct { uint32_t flags; /* reference to TEEC_SharedMemCtl */ uint32_t ops_cnt; bool is_allocated; /* identify whether the memory is registered or allocated */ - struct ListNode head; + union { + struct ListNode head; + void* imp; /* for adapt, imp is not used by system CA, only for vendor CA */ + }; TEEC_Context *context; } TEEC_SharedMemory; diff --git a/include/TA/huawei_ext/crypto_wrapper.h b/include/TA/huawei_ext/crypto_wrapper.h index e05e90b..48ae46a 100755 --- a/include/TA/huawei_ext/crypto_wrapper.h +++ b/include/TA/huawei_ext/crypto_wrapper.h @@ -8,63 +8,66 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: soft engine in boringssl */ #ifndef __CRYPTO_WRAPPER_H__ #define __CRYPTO_WRAPPER_H__ -#include +#include #include -#include - -#define SHA256_LEN 32 -#define OEM_KEY_LEN 16 - +#include "crypto_aes_wrapper.h" +#include "crypto_cert_wrapper.h" +#include "crypto_device_key_wrapper.h" +#include "crypto_ec_wrapper.h" +#include "crypto_ec_x509_wrapper.h" +#include "crypto_rsa_wrapper.h" +#include "crypto_x509_wrapper.h" +#include "crypto_inner_wrapper.h" + +#define SHA256_LEN 32 +#define OEM_KEY_LEN 16 #define ECC_P256_PRIV_LEN 64 #define ECC_P256_PUB_LEN 32 -#define RSA_PUB_LEN 1024 -#define RSA_PRIV_LEN 512 #define ATTEST_TBS_MAXSIZE 512 #define ATTESTATION_KEY_USAGE_OFFSET 16 #define EC_FIX_BUFFER_LEN 66 #define SHA256_HASH_LEN 32 -#define ECC_PRIV_LEN 66 -#define ECC_PUB_LEN 66 /* macro in tomcrypto start */ /* ECC domain id */ -#define NIST_P192 0 -#define NIST_P224 1 -#define NIST_P256 2 -#define NIST_P384 3 -#define NIST_P521 4 - -#define SHA1_HASH 1 -#define SHA224_HASH 2 -#define SHA256_HASH 3 -#define SHA384_HASH 4 -#define SHA512_HASH 5 +#define NIST_P192 0 +#define NIST_P224 1 +#define NIST_P256 2 +#define NIST_P384 3 +#define NIST_P521 4 + +#define SHA1_HASH 1 +#define SHA224_HASH 2 +#define SHA256_HASH 3 +#define SHA384_HASH 4 +#define SHA512_HASH 5 /* Algorithm id */ -#define RSA_ALG 0 -#define ECC_ALG 1 +#define RSA_ALG 0 +#define ECC_ALG 1 /* macro in tomcrypto end */ -#define DIR_ENC 0 -#define DIR_DEC 1 - -#define CRYPTO_NUMBER_TWO 2 -#define CRYPTO_NUMBER_THREE 3 -#define CRYPTO_NUMBER_FOUR 4 -#define CRYPTO_NUMBER_FIVE 5 -#define CRYPTO_NUMBER_SIX 6 -#define CRYPTO_NUMBER_SEVEN 7 -#define CRYPTO_NUMBER_EIGHT 8 -#define VALIDITY_TIME_SIZE 13 -#define SECRET_KEY_MAX_LEN 64 -#define CER_PUBLIC_KEY_MAX_LEN 300 -#define VALIDITY_FIX_LEN 32 -#define KEY_USAGE_FIX_LEN 41 -#define ITEM_THREE_ADD_LEN 12 -#define ITEM_THREE_MOVE_LEN 27 -#define ITEM_TWO_ADD_LEN 23 +#define DIR_ENC 0 +#define DIR_DEC 1 + +#define CRYPTO_NUMBER_TWO 2 +#define CRYPTO_NUMBER_THREE 3 +#define CRYPTO_NUMBER_FOUR 4 +#define CRYPTO_NUMBER_FIVE 5 +#define CRYPTO_NUMBER_SIX 6 +#define CRYPTO_NUMBER_SEVEN 7 +#define CRYPTO_NUMBER_EIGHT 8 +#define VALIDITY_TIME_SIZE 13 +#define SECRET_KEY_MAX_LEN 64 +#define CER_PUBLIC_KEY_MAX_LEN 300 +#define VALIDITY_FIX_LEN 32 +#define KEY_USAGE_FIX_LEN 41 +#define ITEM_THREE_ADD_LEN 12 +#define ITEM_THREE_MOVE_LEN 27 +#define ITEM_TWO_ADD_LEN 23 /* table struct for match convert */ typedef struct { @@ -72,52 +75,6 @@ typedef struct { uint32_t dest; } crypto_u2u; -#define VALIDITY_TIME_SIZE 13 -typedef struct { - uint8_t start[VALIDITY_TIME_SIZE]; - uint8_t end[VALIDITY_TIME_SIZE]; -} validity_period_t; - -typedef struct { - uint32_t domain; - uint8_t x[ECC_PUB_LEN]; - uint32_t x_len; - uint8_t y[ECC_PUB_LEN]; - uint32_t y_len; -} ecc_pub_key_t; - -typedef struct { - uint32_t domain; - uint8_t r[ECC_PRIV_LEN]; - uint32_t r_len; -} ecc_priv_key_t; - -typedef struct { - uint8_t e[RSA_PUB_LEN]; - uint32_t e_len; - uint8_t n[RSA_PUB_LEN]; - uint32_t n_len; -} rsa_pub_key_t; - -typedef struct { - uint8_t e[RSA_PUB_LEN]; - uint32_t e_len; - uint8_t n[RSA_PUB_LEN]; - uint32_t n_len; - uint8_t d[RSA_PUB_LEN]; - uint32_t d_len; - uint8_t p[RSA_PRIV_LEN]; - uint32_t p_len; - uint8_t q[RSA_PRIV_LEN]; - uint32_t q_len; - uint8_t dp[RSA_PRIV_LEN]; - uint32_t dp_len; - uint8_t dq[RSA_PRIV_LEN]; - uint32_t dq_len; - uint8_t qinv[RSA_PRIV_LEN]; - uint32_t qinv_len; -} rsa_priv_key_t; - typedef struct { unsigned char *ou; unsigned char *o; @@ -125,455 +82,4 @@ typedef struct { unsigned char *cn; } dn_name_t; -struct ec_pub_info { - uint8_t *x; - uint32_t x_len; - uint8_t *y; - uint32_t y_len; -}; - -struct ec_priv_info { - uint32_t nid; - uint8_t *r; - uint32_t r_len; -}; - -/* - * Convert the ecc public key passed in by the user into the ecc_pub_key_t structure. - * - * @param pub [OUT] The ecc public key structure - * @param in [IN] The ecc public key buffer - * @param inlen [IN] The length of ecc public key buffer - * - * @return 1: Import ecc public key success - * @return -1: Import ecc public key failed - */ -int32_t ecc_import_pub(ecc_pub_key_t *pub, const uint8_t *in, uint32_t inlen); - -/* - * Convert the ecc_pub_key_t structure passed in by the user into ecc public key buffer. - * - * @param out [OUT] The ecc public key buffer - * @param outlen [IN/OUT] The length of ecc public key buffer - * @param pub [IN] The ecc public key structure - * - * @return -1: Export ecc public key failed - * @return others: The real size of out buffer - */ -int32_t ecc_export_pub(uint8_t *out, uint32_t out_size, ecc_pub_key_t *pub); - -/* - * Read next TLV (Type-Length-Value) from ASN1 buffer. - * - * @param type [OUT] Type of TLV - * @param header_len [OUT] Length of TLV - * @param buf [IN] Input TLV - * @param buf_len [IN] Length of buf in bytes - * - * @return -1: Get next TLV failed - * @return others: Length of next TLV - */ -int32_t get_next_tlv(uint32_t *type, uint32_t *header_len, const uint8_t *buf, uint32_t buf_len); - -/* - * Convert the ecc private key passed in by the user into the ecc_priv_key_t structure. - * - * @param priv [OUT] The ecc private key structure - * @param in [IN] The ecc private key buffer - * @param inlen [IN] The length of ecc private key buffer - * - * @return -1: Import ecc private key failed - * @return others: The width of ecc private key - */ -int32_t ecc_import_priv(ecc_priv_key_t *priv, const uint8_t *in, uint32_t inlen); - -/* - * Use ECC algorithm to sign user data. - * - * @param signature [OUT] The signature of input data - * @param sig_siz [IN/OUT] The length of signature - * @param in [IN] The data to be sign - * @param in_len [IN] The length of input data - * @param priv [IN] The ecc private key structure - * - * @return -1: Sign input buffer use ecc failed - * @return others: The length of signature - */ -int32_t ecc_sign_digest(uint8_t *signature, uint32_t sig_size, uint8_t *in, uint32_t in_len, ecc_priv_key_t *priv); - -/* - * Verify the data with ECC algorithm. - * - * @param signature [IN] The signature of input data - * @param sig_len [IN] The length of signature - * @param in [IN] The input data - * @param in_len [IN] The length of input data - * @param pub [IN] The ecc public key structure - * - * @return 1: Verify digest success - * @return -1: Verify digest failed - */ -int32_t ecc_verify_digest(const uint8_t *signature, uint32_t sig_len, uint8_t *in, uint32_t in_len, ecc_pub_key_t *pub); - -/* - * Generate rsa key pair. - * @param priv [OUT] The rsa private key structure - * @param pub [OUT] The rsa public key structure - * @param e [IN] The exponent of rsa key - * @param key_size [IN] The size of rsa key - * - * @return 0: Generate rsa keypair success - * @return -1: Generate rsa keypair failed - */ -int32_t rsa_generate_keypair(rsa_priv_key_t *priv, rsa_pub_key_t *pub, uint32_t e, uint32_t key_size); - -/* - * Do rsa encryption. - * - * @param dest_data [OUT] The dest data buffer - * @param dest_len [IN/OUT] The length of dest data - * @param src_data [IN] The src data buffer - * @param src_len [IN] The length of src data - * @param pub [IN] The rsa public key structure - * @param padding [IN] The padding type of encryption - * @param hash_nid [IN] The hash_nid of encryption - * - * @return 0: Do rsa encryption success - * @return -1: Do rsa encryption failed - */ -int32_t rsa_encrypt(uint8_t *dest_data, uint32_t *dest_len, uint8_t *src_data, uint32_t src_len, rsa_pub_key_t *pub, - int32_t padding, int32_t hash_nid); - -/* - * Do rsa decryption. - * - * @param dest_data [OUT] The dest data buffer - * @param dest_len [IN/OUT] The length of dest data - * @param src_data [IN] The src data buffer - * @param src_len [IN] The length of src data - * @param priv [IN] THE rsa private key structure - * @param padding [IN] The padding type of encryption - * @param hash_nid [IN] The hash_nid of encryption - * - * @return 0: Do rsa decryption success - * @return -1: Do rsa decryption failed - */ -int32_t rsa_decrypt(uint8_t *dest_data, uint32_t *dest_len, uint8_t *src_data, uint32_t src_len, rsa_priv_key_t *priv, - uint32_t padding, int32_t hash_nid); - -/* - * Do rsa Sign digest. - * - * @param signature [OUT] The signature of input data - * @param sig_size [IN/OUT] The length of signature - * @param in [IN] The input data - * @param in_len [IN] The length of input data - * @param priv [IN] The rsa private key structure - * @param salt_len [IN] The length of salt - * @param hash_nid [IN] The hash_nid of encryption - * @param padding [IN] The padding type of encryption - * - * @return 0: Do rsa sign digest success - * @return -1: Do rsa Sign digest failed - */ -int32_t rsa_sign_digest(uint8_t *signature, uint32_t *sig_size, uint8_t *in, uint32_t in_len, rsa_priv_key_t *priv, - uint32_t salt_len, int32_t hash_nid, int32_t padding); - -/* - * Do rsa Verify digest. - * - * @param signature [IN] The signature of input data - * @param sig_size [IN] The length of signature - * @param in [IN] The input data - * @param in_len [IN] The length of input data - * @param pub [IN] The rsa public key structure - * @param salt_len [IN] The length of salt - * @param hash_nid [IN] The hash_nid of encryption - * @param padding [IN] The padding type of encryption - * - * @return 0: Do rsa verify success - * @return -1: Do rsa verify failed - */ -int32_t rsa_verify_digest(uint8_t *signature, uint32_t sig_size, uint8_t *in, uint32_t in_len, const rsa_pub_key_t *pub, - uint32_t salt_len, int32_t hash_nid, int32_t padding); - -/* - * Convert the rsa private key passed in by the user into the rsa_priv_key_t structure. - * - * @param priv [OUT] The rsa private key structure - * @param in [IN] The rsa private key buffer - * @param inlen [IN] The length of rsa private key buffer - * - * @return -1: Import rsa private key failed - * @return 0: Import rsa private key success - */ -int rsa_import_priv(rsa_priv_key_t *priv, const uint8_t *in, uint32_t in_len); - -/* - * Check the certificate revocation list. - * - * @param cert [IN] The crl buffer - * @param cert_len [IN] The length of crl buffer - * @param parent_key [IN] The public key to verify the crl - * @param parent_key_len [IN] The length of public key - * - * @return 1: Check the crl success - * @return others: Check the crl failed - */ -int x509_crl_validate(uint8_t *cert, uint32_t cert_len, uint8_t *parent_key, uint32_t parent_key_len); - -/* - * Check the x509 certificate. - * - * @param cert [IN] The certificate buffer - * @param cert_len [IN] The length of certificate buffer - * @param parent_key [IN] The public key to verify the crl - * @param parent_key_len [IN] The length of public key - * - * @return 1: Check the cert success - * @return others: Check the cert failed - */ -int x509_cert_validate(uint8_t *cert, uint32_t cert_len, uint8_t *parent_key, uint32_t parent_key_len); - -/* - * Get public key from certificate. - * - * @param pub [OUT] The public key struct - * @param in [IN] The certificate buffer - * @param inlen [IN] The length of certificate buffer - * - * @return 0: Get public key success - * @return -1: Get public key failed - */ -int import_pub_from_sp(void *pub, const uint8_t *in, uint32_t inlen); - -/* - * Get public key from certificate. - * - * @param pub [OUT] The public key buffer - * @param cert [IN] The certificate buffer - * @param cert_len [IN] The length of certificate buffer - * - * @return -1: Get public key failed - * @return others: The length of public key buffer - */ -int get_subject_public_key(uint8_t *pub, const uint8_t *cert, uint32_t cert_len); - -/* - * Get public key from certificate. - * - * @param pub [OUT] The public key buffer - * @param pub_size [IN/OUT] The length of public key buffer - * @param cert [IN] The certificate buffer - * @param cert_len [IN] The length of certificate buffer - * - * @return -1: Get public key failed - * @return others: The length of public key buffer - */ -int get_subject_public_key_new(uint8_t *pub, uint32_t pub_size, const uint8_t *cert, uint32_t cert_len); - -/* - * Get valid date from certificate. - * - * @param vd [OUT] The valid data structure - * @param cert [IN] The certificate buffer - * @param cert_len [IN] The length of certificate buffer - * - * @return 0: Get valid date success - * @return -1: Get valid data failed - */ -int get_validity_from_cert(validity_period_t *vd, uint8_t *cert, uint32_t cert_len); - -/* - * Get common name from certificate. - * - * @param name [OUT] The common name buffer - * @param name_size [IN/OUT] The length of common name buffer - * @param cert [IN] The certificate buffer - * @param cert_len [IN] The length of certificate buffer - * - * @return -1: Get common name failed - * @return others: Get common name success - */ -int get_subject_CN(uint8_t *name, uint32_t name_size, const uint8_t *cert, uint32_t cert_len); - -/* - * Get organization name from certificate. - * - * @param name [OUT] The organization name buffer - * @param name_size [IN/OUT] The length of organization name buffer - * @param cert [IN] The certificate buffer - * @param cert_len [IN] The length of certificate buffer - * - * @return -1: Get organization name failed - * @return others: Get organization name success - */ -int get_subject_OU(uint8_t *name, uint32_t name_size, const uint8_t *cert, uint32_t cert_len); - -/* - * Get serial number from certificate. - * - * @param serial_number [OUT] The serial number buffer - * @param serial_number_size [IN/OUT] The length of serial number buffer - * @param cert [IN] The certificate buffer - * @param cert_len [IN] The length of certificate buffer - * - * @return -1: Get serial number failed - * @return others: Get serial number success - */ -int get_serial_number_from_cert(uint8_t *serial_number, uint32_t serial_number_size, uint8_t *cert, uint32_t cert_len); - -/* - * Get issuer from certificate. - * - * @param issuer [OUT] The issuer buffer - * @param issuer_size [IN/OUT] The length of issuer buffer - * @param cert [IN] The certificate buffer - * @param cert_len [IN] The length of certificate buffer - * - * @return -1: Get serial number failed - * @return others: Get serial number success - */ -int get_issuer_from_cert(uint8_t *issuer, uint32_t issuer_size, uint8_t *crl, uint32_t crl_len); - -/* - * Get element number from certificate. - * - * @param elem [OUT] The element with elem_id - * @param elem_id [IN] The index of element - * @param cert [IN] The certificate buffer - * @param cert_len [IN] The length of certificate buffer - * - * @return -1: Get element failed - * @return others: The length of element - */ -int32_t get_tbs_element(uint8_t **elem, uint32_t elem_id, const uint8_t *cert, uint32_t cert_len); - -/* - * Recover the root certificate. - * - * @param cert [OUT] The certificate buffer - * @param cert_len [IN/OUT] The length of certificate buffer - * @param priv [IN] The private key structure - * @param keytype [IN] The keytype of private key - * - * @return -1: Recover root certificate failed - * @return others: Recover root certificate success - */ -int32_t recover_root_cert(uint8_t *cert, uint32_t cert_len, const void *priv, uint32_t keytype); - -/* - * Convert the rsa_pub_key_t structure passed in by the user into rsa public key buffer. - * - * @param out [OUT] The rsa public key buffer - * @param outlen [IN] The length of rsa public key buffer - * @param pub [IN] The rsa public key structure - * - * @return -1: Export rsa public key failed - * @return others: The real size of out buffer - */ -int32_t rsa_export_pub_sp(uint8_t *out, uint32_t out_size, rsa_pub_key_t *pub); - -/* - * Sign the pkcs10 certificate. - * - * @param cert [OUT] The certificate buffer - * @param cert_len [IN] The length of certificate buffer - * @param csr [IN] The certificate signing request buffer - * @param csr_len [IN] The length of certificate signing request buffer - * @param valid [IN] The valid date buffer - * @param serial_number [IN] The serial number buffer - * @param serial_length [IN] The length of serial number buffer - * @param priv [IN] The private key structure - * @param keytype [IN] The keytype of private key - * - * @return -1: Sign the pkcs10 certificate failed - * @return others: The real size of certificate - */ -int32_t sign_pkcs10(uint8_t *cert, uint32_t cert_len, - const uint8_t *csr, uint32_t csr_len, const validity_period_t *valid, - const uint8_t *serial_number, uint32_t serial_length, const void *priv, uint32_t keytype); - -/* - * Create attestation certificate with input params. - * - * @param cert [OUT] The certificate buffer - * @param cert_len [IN] The length of certificate buffer - * @param valid [IN] The valid date buffer - * @param issuer_tlv [IN] The issuer buffer - * @param issuer_tlv_len [IN] The length of issuer buffer - * @param subject_public_key [IN] The subject public key buffer - * @param subject_public_key_len [IN] The length of subject public key buffer - * @param attestation_ext [IN] The attestation extrol infor buffer - * @param attestation_ext_len [IN] The length of attestation extrol infor buffer - * @param priv_sign [IN] The private key buffer - * @param key_usage_sign_bit [IN] The usage sign falg - * @param key_usage_encrypt_bit [IN] The usage encrypt flag - * @param keytype [IN] The keytype of private key - * @param hash [IN] The hash func of digest - * - * @return -1: Create attestation certificate failed - * @return others: The real size of certificate - */ -int32_t create_attestation_cert(uint8_t *cert, uint32_t cert_len, const validity_period_t *valid, - const uint8_t *issuer_tlv, uint32_t issuer_tlv_len, - const uint8_t *subject_public_key, uint32_t subject_public_key_len, - const uint8_t *attestation_ext, uint32_t attestation_ext_len, void *priv_sign, - uint32_t key_usage_sign_bit, uint32_t key_usage_encrypt_bit, uint32_t key_type, - uint32_t hash); - -/* - * Get oem huk. - * - * @param huk [OUT] The oem huk buffer - * @param key [IN] The hmac key buffer - * @param key_size [IN] The length of hmac key buffer - * - * @return 0: Get oem huk success - * @return -1: Get oem huk failed - */ -int get_class_oem_huk(uint8_t *huk, const uint8_t *key, uint32_t key_size); - -/* - * Derive ecc public key from private key. - * - * @param priv_info [IN] The ecc_priv_key_t structure - * @param pub_info [OUT] The ecc_pub_key_t structure - * - * @return 0: Derive ecc public key success - * @return -1: Derive ecc public key failed - */ -int ecc_derive_public_key(ecc_priv_key_t *priv_info, ecc_pub_key_t *pub_info); - -/* - * Derive ecc private key from huk. - * - * @param priv [OUT] The ecc_priv_key_t structure - * @param secret [IN] The huk buffer - * @param sec_len [IN] The length of huk buffer - * - * @return 0: Derive ecc private key success - * @return -1: Derive ecc private key failed - */ -int derive_ecc_private_key_from_huk(ecc_priv_key_t *priv, const uint8_t *secret, uint32_t sec_len); - -/* - * Do aes key wrap operation. - * @param params [IN/OUT] The cdrm_params structure contains key/iv/input/output info - * - * @return TEE_SUCCESS: Do aes key wrap operation success - * @return others: Do aes key wrap operation failed - */ -TEE_Result aes_key_wrap(struct cdrm_params *params); - -/* - * Do aes key unwrap operation. - * - * @param params [IN/OUT] The cdrm_params structure contains key/iv/input/output info - * - * @return TEE_SUCCESS: Do aes key unwrap operation success - * @return others: Do aes key unwrap operation failed - */ -TEE_Result aes_key_unwrap(struct cdrm_params *params); - #endif diff --git a/include/TA/huawei_ext/permsrv_api_cert.h b/include/TA/huawei_ext/permsrv_api_cert.h new file mode 100644 index 0000000..bfc0a88 --- /dev/null +++ b/include/TA/huawei_ext/permsrv_api_cert.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS 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: permsrv cert api interface head file + */ + +#ifndef __PERSRV_API_CERT_H__ +#define __PERSRV_API_CERT_H__ + +#include "tee_defines.h" + +TEE_Result ta_signing_cert_import(const char *cert_buf, uint32_t cert_size, const char *pub_key_buf, uint32_t pub_size); +TEE_Result ta_signing_cert_export(uint8_t *dst, uint32_t *len, uint32_t limit); +TEE_Result ta_signing_cert_destroy(void); +#endif diff --git a/include/TA/huawei_ext/qsi_data_structure.h b/include/TA/huawei_ext/qsi_data_structure.h new file mode 100644 index 0000000..38e6673 --- /dev/null +++ b/include/TA/huawei_ext/qsi_data_structure.h @@ -0,0 +1,60 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS 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: Data Structure Definations of QSI. + */ +#ifndef QSI_DATA_STRUCTURE_H +#define QSI_DATA_STRUCTURE_H +#include + +enum seal_operation { + SEAL, + UNSEAL +}; + +struct seal_param { + uint8_t *data; + size_t size; + uint8_t *cipher_data; + size_t *cipher_size; + uint32_t algorithm; + enum seal_operation operation; +}; + +struct qsi_provision_params { + uint32_t scenario; + uint32_t param_set_size; + uint8_t *param_set; + uint32_t out_size; + uint8_t *out_data; +}; + +struct qsi_report_params { + TEE_UUID uuid; + void *user_data; + uint32_t user_size; + uint32_t param_set_size; + uint8_t *param_set; + void *report; + uint32_t report_size; + bool with_tcb; +}; + +struct qsi_save_akcert_params { + uint32_t length; + uint8_t *buffer; +}; + +struct ra_buffer_data { + uint32_t length; + uint8_t *buffer; +}; + +#endif diff --git a/include/TA/huawei_ext/tee_crypto_err.h b/include/TA/huawei_ext/tee_crypto_err.h new file mode 100644 index 0000000..fe9091e --- /dev/null +++ b/include/TA/huawei_ext/tee_crypto_err.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS 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: tee crypto err definitions + */ + +#ifndef TEE_CRYPTO_ERR_H +#define TEE_CRYPTO_ERR_H + +#include + +#define MAX_COMMON_CRYPTO_ENGINE_ERR 99 +/* + * notes: all extension tee error rule is TEE_EXT_ERROR_BASE | CRYPTO_MODULE_ERR_ID | ALG_ERR_ID | base_error_value, + * For example, the crypto module extension error codes are prefixed with 0x8002, + * and base_error_value is opensoure lib err. + */ +enum soft_algthorm_err_id { + SM2_LIB_ERR_ID = 0x0000, /* GMSSL common err and ec err */ + SM4_LIB_ERR_ID = 0x1000, /* GMSSL evp err */ + /* as below: for openssl opensource lib */ + COMM_LIB_ERR_ID = 0x2000, + BN_LIB_ERR_ID = 0x3000, + RSA_LIB_ERR_ID = 0x4000, + EVP_LIB_ERR_ID = 0x5000, + PEM_LIB_ERR_ID = 0x6000, + X509_LIB_ERR_ID = 0x7000, + ASN1_LIB_ERR_ID = 0x8000, + CRYPTO_LIB_ERR_ID = 0x9000, + EC_LIB_ERR_ID = 0xa000, + PKCS7_LIB_ERR_ID = 0xb000, + OTHER_LIB_ERR_ID = 0xc000, +}; + +#endif diff --git a/include/TA/huawei_ext/tee_crypto_hal.h b/include/TA/huawei_ext/tee_crypto_hal.h index 7444618..f8b3b50 100755 --- a/include/TA/huawei_ext/tee_crypto_hal.h +++ b/include/TA/huawei_ext/tee_crypto_hal.h @@ -8,17 +8,18 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: crypto hal info function */ #ifndef TEE_CRYPTO_HAL_H #define TEE_CRYPTO_HAL_H #include "tee_crypto_api.h" enum CRYPTO_ENGINE { - DX_CRYPTO, - EPS_CRYPTO, - SOFT_CRYPTO, - SEC_CRYPTO, - CRYPTO_ENGINE_MAX, + DX_CRYPTO = 0, + EPS_CRYPTO = 1, + SOFT_CRYPTO = 2, + SEC_CRYPTO = 3, + CRYPTO_ENGINE_MAX = 1024, }; /* diff --git a/include/TA/huawei_ext/tee_err.h b/include/TA/huawei_ext/tee_err.h new file mode 100644 index 0000000..3dc4ed3 --- /dev/null +++ b/include/TA/huawei_ext/tee_err.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS 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: Reference of TEE error definitions + */ + +#ifndef TEE_ERROR_H +#define TEE_ERROR_H + +#include + +/* + * notes: all extension tee error rule is TEE_EXT_ERROR_BASE | xx_MODULE_ERR_ID | base_error_value, + * For example, the crypto module extension error codes are prefixed with 0x8002. + */ +#define TEE_EXT_ERROR_BASE 0x80000000 + +enum ext_error_module { + OTRP_MODULE_ERR_ID = 0x000000, + SSA_MODULE_ERR_ID = 0x010000, + CRYPTO_MODULE_ERR_ID = 0x020000, +}; + +#endif \ No newline at end of file diff --git a/include/TA/huawei_ext/tee_ext_api.h b/include/TA/huawei_ext/tee_ext_api.h index d74c749..2e593cd 100644 --- a/include/TA/huawei_ext/tee_ext_api.h +++ b/include/TA/huawei_ext/tee_ext_api.h @@ -8,13 +8,14 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: Tee ext api header file */ #ifndef TEE_EXT_API_H #define TEE_EXT_API_H #include "tee_defines.h" -#include "tee_core_api.h" +#include "tee_hw_ext_api_legacy.h" #ifdef __cplusplus #if __cplusplus @@ -35,14 +36,18 @@ extern "C" { #define TEE_GET_REEINFO_SUCCESS 0 #define TEE_GET_REEINFO_FAILED 1 +#define TEE_SMC_FROM_USR 0 +#define TEE_SMC_FROM_KERNEL 1 + #define RESERVED_BUF_SIZE 32 -typedef struct __caller_info { +typedef struct ta_caller_info { uint32_t session_type; union { TEE_UUID caller_uuid; uint8_t ca_info[RESERVED_BUF_SIZE]; } caller_identity; - uint8_t reserved[RESERVED_BUF_SIZE]; + uint8_t smc_from_kernel_mode; + uint8_t reserved[RESERVED_BUF_SIZE - 1]; } caller_info; /* @@ -54,7 +59,7 @@ typedef struct __caller_info { * return TEE_SUCCESS operation success * return others failed to get caller info */ -TEE_Result TEE_EXT_GetCallerInfo(caller_info *caller_info_data, uint32_t length); +TEE_Result tee_ext_get_caller_info(caller_info *caller_info_data, uint32_t length); /* * verify TA's caller's identify @@ -86,8 +91,32 @@ TEE_Result AddCaller_TA_all(void); * * @return session type of current session */ -uint32_t TEE_GetSessionType(void); +uint32_t tee_get_session_type(void); + +/* + * Check CA params during CA Authentication + * + * @param param_types [IN] CA caller's param types + * @param params[TEE_PARAMS_NUM] [IN] CA caller's params + * + * return TEE_SUCCESS + */ +TEE_Result TEE_EXT_CheckClientPerm(uint32_t param_types, const TEE_Param params[TEE_PARAMS_NUM]); +/* + * derive key from platform key + * + * @param object [IN/OUT] input data in ObjectInfo->keytype, output keys in Attributes. + * @param keySize [IN] key size in bits, it desides the ecc curve type too. + * @param params [IN] unused + * @param paramCount [IN] unused + * @param exinfo [IN] user info as derive slat. + * @param exinfo_size [IN] size of user info, Max is 64bytes, must bigger than 0. + * + * @return TEE_SUCCESS means success, others means failed. + */ +TEE_Result tee_ext_derive_ta_platfrom_keys(TEE_ObjectHandle object, uint32_t key_size, const TEE_Attribute *params, + uint32_t param_count, const uint8_t *exinfo, uint32_t exinfo_size); #ifdef __cplusplus #if __cplusplus } diff --git a/include/TA/huawei_ext/tee_hw_ext_api_legacy.h b/include/TA/huawei_ext/tee_hw_ext_api_legacy.h new file mode 100644 index 0000000..bf5a770 --- /dev/null +++ b/include/TA/huawei_ext/tee_hw_ext_api_legacy.h @@ -0,0 +1,293 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS 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: Functions in this header file are deprecated. Do not use + */ + +#ifndef __TEE_HW_EXT_API_LEGACY_H__ +#define __TEE_HW_EXT_API_LEGACY_H__ + +#include "tee_defines.h" +#include "tee_crypto_api.h" + +/* + * ta version anti rollback api + * + * @param ta_version [IN] version to be checked + * + * @return TEE_SUCCESS check result is OK + * @return others check ta version failed + */ +TEE_Result TEE_EXT_TA_version_check(uint32_t ta_version); + +/* + * check wheather target TA(uuid) has permission to invoke target command + * this feature is only supported by TA with certificate + * + * @param [IN] uuid of caller TA + * @param [IN] cmd id of request + * + * @return TEE_SUCCESS target TA has the permission to invoke target command + * @return TEE_ERROR_ACCESS_DENIED target TA don't has permission to invoke target command + */ +TEE_Result TEE_EXT_CheckInvokePermission(const TEE_UUID *uuid, uint32_t cmd); + +/* + * get sharemem of verify boot information + * + * @param buffer [OUT] the address to save verify boot info + * @param size [IN] length of buffer + * + * @return 0 means success, others means failed + */ +TEE_Result TEE_EXT_GetVerifyBootInfo(char *buffer, uint32_t size); + +/* + * derive key from device rootkey and UUID of the current task + * + * @param salt [IN] data for salt + * @param size [IN] salt length + * @param key [OUT] pointer where key is saved + * @param key_size [IN] key_size must be integer times of 16 + * + * @return TEE_SUCCESS OK + * @return TEE_ERROR_BAD_PARAMETERS illegal parameters + * @return TEE_ERROR_GENERIC internal error + */ +TEE_Result TEE_EXT_DeriveTARootKey(const uint8_t *salt, uint32_t size, uint8_t *key, uint32_t key_size); + +/* + * get rot key for multiple platforms + * + * @param enc_key [IN] encrypted rot key or NULL + * @param en_key_size [IN] encrypted rot key buff len or zero + * @param key [OUT]rot key buff pointer + * @param key_size [IN/OUT] rot key buffer length + * + * @return 0 get rot key success + * @return -1 get rot key failed + */ +int32_t TEE_EXT_GetRoT(const uint8_t *enc_key, uint32_t en_key_size, uint8_t *key, uint32_t *key_size); + +/* + * get device unique id in TEE + * + * @param device_unique_id [OUT] buffer to store the result + * @param length [IN/OUT] buffer length of device ID + * + * return TEE_SUCCESS operation success + * return others operation failed + */ +TEE_Result TEE_EXT_GetDeviceUniqueId(uint8_t *device_unique_id, uint32_t *length); + +TEE_Result TEE_EXT_GetSeCapability(const TEE_UUID *uuid, uint64_t *result); + +/* + * @ingroup TEE_EXT_API + * @brief get shared memory infomation of SecFlash + * + * @param buffer [OUT] the address to save SecFlash shared memory info + * @param length [IN] length of buffer + * + * @retval NA + */ +TEE_Result TEE_EXT_GetSecFlashShareMem(char *buffer, uint32_t size); + +/* + * @ingroup share memory + * @brief get sharemem of verify boot information + * + * @par + * @param buffer [OUT] the address to save verify boot info + * @param size [IN] length of buffer + * + * @retval NA + * + * @par dependence: + * @li tee_ext_api.h + * @see + * @since V100R008C00 + */ +TEE_Result TEE_EXT_GetTrustBootImgInfo(char *buffer, uint32_t size); + +/* + * @ingroup derive key for keymaster + * @brief using root key to derive key for keymaster + * + * @par + * @param buffer [IN] input secret + * @param size [IN] input secret size + * @param buffer [OUT] derived key + * @param size [OUT] derived key size + * + * @retval NA + * + * @par dependence: + * @li tee_ext_api.h + * @see + * @since V100R007C00 + */ +TEE_Result TEE_EXT_ROOT_DeriveKey2(const uint8_t *secret, uint32_t secret_len, uint8_t *key, uint32_t key_len); + +/* + * @ingroup ROOT_UuidDeriveKey + * @brief derive key from device rootkey and UUID of the current task + * + * @attention + * @param salt [IN] data for salt + * @param size [IN] salt length + * @param key_size [OUT] size of generated key, fix-size 32 bytes + * @param key [OUT] pointer where key is saved + * + * @retval #TEE_SUCCESS OK + * @retval #TEE_ERROR_BAD_PARAMETERS illegal parameters + * @retval #TEE_ERROR_GENERIC internal error + * + * @par dependence: + * @li tee_ext_api.h + * @see + * @since V100R007C00 + */ +TEE_Result TEE_EXT_ROOT_UuidDeriveKey(const uint8_t *salt, uint32_t size, uint8_t *key, uint32_t *key_size); + +/* + * @ingroup crypto + * @brief AES encryption and decryption integration mode. + * + * @attention: Now this api only support algorithm: AES_CBC_NOPAD/ AES_ECB_PKCS5, + * and input key can derive by root key. + * @param db [IN] Whether to derive the key with the input key and root key. + * @param iv [IN] input iv + * @param mode [IN] 0:encrypt; 1:decrypt + * @param alg [IN] AES algorithm: TEE_CRYPTO_ALGORITHM_ID + * @param key [IN] input key + * @param key_len [IN] input key len + * @param cyp_src [IN] input data + * @param dst [OUT] ouput data + * @param src_len [IN] input data len + * @param dst_len [OUT] ouput data len + * + * @retval #TEE_SUCCESS success + * @retval #TEE_ERROR_BAD_PARAMETERS illegal parameters + * @retval #TEE_ERROR_OUT_OF_MEMORY alloc memory fail + * + * @par dependence: + * @li crypto + * @li tee_ext_api.h + * @see TEE_CipherInit | TEE_CipherUpdate | TEE_CipherDoFinal + * @since V100R005C00 + */ +TEE_Result TEE_EXT_AES_CRYPTO(bool db, const uint8_t *iv, bool mode, uint32_t alg, const uint8_t *key, uint32_t key_len, + const uint8_t *cyp_src, uint8_t *dst, uint32_t src_len, uint32_t *dst_len); + +/* + * @ingroup crypto + * @brief calculate hash. + * + * @attention + * @param algorithm [IN] hash algorithm: like SHA1, SHA256 + * @param ptr [IN] input data + * @param size [IN] input data length + * @param hash_result [OUT] hash result: SHA1 20bytes; SHA256 32bytes + * + * @retval #TEE_SUCCESS success + * @retval #TEE_ERROR_BAD_PARAMETERS illegal parameters + * @retval #TEE_ERROR_GENERIC error + * + * @par dependence: + * @li crypto + * @li tee_ext_api.h + * @since V100R005C00 + */ +TEE_Result TEE_EXT_HASH(tee_crypto_algorithm_id algorithm, const uint8_t *ptr, uint32_t size, uint8_t *hash_result); + +/* + * @ingroup TEE_HWI_IPC_MESSAGE + * @brief Wait for registered messages from IRQs + * + * @param hwi [IN] IRQ number to register + */ +TEE_Result TEE_EXT_HwiMsgRegister(uint32_t hwi); + +/* + * @ingroup TEE_HWI_IPC_MESSAGE + * @brief Unregister to receive message for HWI number + * + * @param hwi [IN] IRQ number to unregister for + */ +TEE_Result TEE_EXT_HwiMsgDeregister(uint32_t hwi); + +/* + * @ingroup TEE_HWI_IPC_MESSAGE + * @brief Wait for registered messages from IRQs + * + * @param NULL + * + * @retval received message id + */ +uint32_t TEE_EXT_HwiMsgWait(void); + +/* + * @ingroup TEE_HW_EXT_API + * @brief check wheather device rooted 1:rooted, 0:unrooted + * + * @param NULL + * + * @retval true means device is rooted + */ +bool TEE_EXT_IsDeviceRooted(void); + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +struct ta_caller_info; + +/* + * Get caller info of current session, refer caller_info struct for more details + * + * @param caller_info_data [OUT] caller info to be returned + * @param length [IN] sizeof struct caller_info + * + * return TEE_SUCCESS operation success + * return others failed to get caller info + */ +TEE_Result TEE_EXT_GetCallerInfo(struct ta_caller_info *caller_info_data, uint32_t length); + +/* + * get cruurent session type + * + * @return session type of current session + */ +uint32_t TEE_GetSessionType(void); + +/* + * derive key from platform key + * + * @param object [IN/OUT] input data in ObjectInfo->keytype, output keys in Attributes. + * @param keySize [IN] key size in bits, it desides the ecc curve type too. + * @param params [IN] unused + * @param paramCount [IN] unused + * @param exinfo [IN] user info as derive slat. + * @param exinfo_size [IN] size of user info, Max is 64bytes, must bigger than 0. + * + * @return TEE_SUCCESS means success, others means failed. + */ +TEE_Result TEE_EXT_DeriveTAPlatfromKeys(TEE_ObjectHandle object, uint32_t key_size, const TEE_Attribute *params, + uint32_t param_count, const uint8_t *exinfo, uint32_t exinfo_size); +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cpluscplus */ +#endif /* __cpluscplus */ + +#endif diff --git a/include/TA/huawei_ext/tee_log.h b/include/TA/huawei_ext/tee_log.h index dc213da..bd83686 100644 --- a/include/TA/huawei_ext/tee_log.h +++ b/include/TA/huawei_ext/tee_log.h @@ -8,21 +8,26 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: Reference of TEE log api and internal definitions */ #ifndef __TEE_LOG_H #define __TEE_LOG_H #include "tee_defines.h" +#include "tee_log_legacy.h" -#define DEBUG_TAG "[debug]" -#define INFO_TAG "[info]" -#define WARNING_TAG "[warning]" -#define ERROR_TAG "[error]" +#define TA_LOG_LEVEL_ERROR 0 +#define TA_LOG_LEVEL_WARNING 1 +#define TA_LOG_LEVEL_INFO 2 +#define TA_LOG_LEVEL_DEBUG 3 +#define TA_LOG_LEVEL_VERBO 4 -#define LEVEL_DEBUG 2 -#define LEVEL_WARNING 1 -#define LEVEL_ERROR 0 +#define TA_LOG_LEVEL_DEFAULT TA_LOG_LEVEL_INFO +// TA_LOG_LEVEL can be redefined by TA developers +#ifndef TA_LOG_LEVEL +#define TA_LOG_LEVEL TA_LOG_LEVEL_DEFAULT +#endif #define TAG_VERB "[verb]" #define TAG_DEBUG "[debug]" @@ -30,6 +35,10 @@ #define TAG_WARN "[warn]" #define TAG_ERROR "[error]" +#define DEBUG_TAG "[debug]" +#define INFO_TAG "[info]" +#define WARNING_TAG "[warning]" +#define ERROR_TAG "[error]" typedef enum { LOG_LEVEL_ERROR = 0, LOG_LEVEL_WARN = 1, @@ -46,84 +55,138 @@ void tee_print(LOG_LEVEL log_level, const char *fmt, ...); void tee_print_driver(LOG_LEVEL log_level, const char *log_tag, const char *fmt, ...); extern const char *g_debug_prefix; -#define TEE_LogPrintf(fmt, args...) SLog(fmt, ##args) -#ifdef LOG_ON +/* tlogv */ +#if (TA_LOG_LEVEL >= TA_LOG_LEVEL_VERBO) #ifdef DRIVER_LOG_TAG #define tlogv(fmt, args...) \ tee_print_driver(LOG_LEVEL_VERBO, DRIVER_LOG_TAG, "%s %d:" fmt "", TAG_VERB, __LINE__, ##args) -#define tlogd(fmt, args...) \ - tee_print_driver(LOG_LEVEL_DEBUG, DRIVER_LOG_TAG, "%s %d:" fmt "", TAG_DEBUG, __LINE__, ##args) -#define tlogi(fmt, args...) \ - tee_print_driver(LOG_LEVEL_INFO, DRIVER_LOG_TAG, "%s %d:" fmt "", TAG_INFO, __LINE__, ##args) -#define tlogw(fmt, args...) \ - tee_print_driver(LOG_LEVEL_WARN, DRIVER_LOG_TAG, "%s %d:" fmt "", TAG_WARN, __LINE__, ##args) #else #define tlogv(fmt, args...) tee_print(LOG_LEVEL_VERBO, "%s %d:" fmt "", TAG_VERB, __LINE__, ##args) -#define tlogd(fmt, args...) tee_print(LOG_LEVEL_DEBUG, "%s %d:" fmt "", TAG_DEBUG, __LINE__, ##args) -#define tlogi(fmt, args...) tee_print(LOG_LEVEL_INFO, "%s %d:" fmt "", TAG_INFO, __LINE__, ##args) -#define tlogw(fmt, args...) tee_print(LOG_LEVEL_WARN, "%s %d:" fmt "", TAG_WARN, __LINE__, ##args) -#endif +#endif /* DRIVER_LOG_TAG */ #else #define tlogv(fmt, args...) \ do { \ } while (0) +#endif /* TA_LOG_LEVEL >= TA_LOG_LEVEL_VERBO */ + +/* tlogd */ +#if (TA_LOG_LEVEL >= TA_LOG_LEVEL_DEBUG) +#ifdef DRIVER_LOG_TAG +#define tlogd(fmt, args...) \ + tee_print_driver(LOG_LEVEL_DEBUG, DRIVER_LOG_TAG, "%s %d:" fmt "", TAG_DEBUG, __LINE__, ##args) +#else +#define tlogd(fmt, args...) tee_print(LOG_LEVEL_DEBUG, "%s %d:" fmt "", TAG_DEBUG, __LINE__, ##args) +#endif /* DRIVER_LOG_TAG */ +#else #define tlogd(fmt, args...) \ do { \ } while (0) +#endif /* TA_LOG_LEVEL >= TA_LOG_LEVEL_DEBUG */ + +/* tlogi */ +#if (TA_LOG_LEVEL >= TA_LOG_LEVEL_INFO) +#ifdef DRIVER_LOG_TAG +#define tlogi(fmt, args...) \ + tee_print_driver(LOG_LEVEL_INFO, DRIVER_LOG_TAG, "%s %d:" fmt "", TAG_INFO, __LINE__, ##args) +#else +#define tlogi(fmt, args...) tee_print(LOG_LEVEL_INFO, "%s %d:" fmt "", TAG_INFO, __LINE__, ##args) +#endif /* DRIVER_LOG_TAG */ +#else #define tlogi(fmt, args...) \ do { \ } while (0) +#endif /* TA_LOG_LEVEL >= TA_LOG_LEVEL_INFO */ + +/* tlogw */ +#if (TA_LOG_LEVEL >= TA_LOG_LEVEL_WARNING) +#ifdef DRIVER_LOG_TAG +#define tlogw(fmt, args...) \ + tee_print_driver(LOG_LEVEL_WARN, DRIVER_LOG_TAG, "%s %d:" fmt "", TAG_WARN, __LINE__, ##args) +#else +#define tlogw(fmt, args...) tee_print(LOG_LEVEL_WARN, "%s %d:" fmt "", TAG_WARN, __LINE__, ##args) +#endif /* DRIVER_LOG_TAG */ +#else #define tlogw(fmt, args...) \ do { \ } while (0) -#endif /* ENG_VERSION */ +#endif /* TA_LOG_LEVEL >= TA_LOG_LEVEL_WARNING */ +/* tloge */ +#if (TA_LOG_LEVEL >= TA_LOG_LEVEL_ERROR) // Always meet this condition #ifndef TLOGE_NO_TIMESTAMP #ifdef DRIVER_LOG_TAG #define tloge(fmt, args...) \ tee_print_driver(LOG_LEVEL_ERROR, DRIVER_LOG_TAG, "%s %d:" fmt " ", TAG_ERROR, __LINE__, ##args) #else #define tloge(fmt, args...) tee_print(LOG_LEVEL_ERROR, "%s %d:" fmt " ", TAG_ERROR, __LINE__, ##args) -#endif +#endif /* DRIVER_LOG_TAG */ #else #define tloge(fmt, args...) printf("[%s] %s %d:" fmt " ", g_debug_prefix, TAG_ERROR, __LINE__, ##args) -#endif +#endif /* TLOGE_NO_TIMESTAMP */ +#else +#define tloge(fmt, args...) \ + do { \ + } while (0) +#endif /* TA_LOG_LEVEL >= TA_LOG_LEVEL_ERROR */ void ta_print(LOG_LEVEL log_level, const char *fmt, ...); -#ifdef LOG_ON +/* ta_logv */ +#if (TA_LOG_LEVEL >= TA_LOG_LEVEL_VERBO) #define ta_logv(fmt, args...) ta_print(LOG_LEVEL_VERBO, "%s %d: " fmt "\n", TAG_VERB, __LINE__, ##args) -#define ta_logd(fmt, args...) ta_print(LOG_LEVEL_DEBUG, "%s %d: " fmt "\n", TAG_DEBUG, __LINE__, ##args) -#define ta_logi(fmt, args...) ta_print(LOG_LEVEL_INFO, "%s %d: " fmt "\n", TAG_INFO, __LINE__, ##args) -#define ta_logw(fmt, args...) ta_print(LOG_LEVEL_WARN, "%s %d: " fmt "\n", TAG_WARN, __LINE__, ##args) #else #define ta_logv(fmt, args...) \ do { \ } while (0) +#endif /* TA_LOG_LEVEL >= TA_LOG_LEVEL_VERBO */ + +/* ta_logd */ +#if (TA_LOG_LEVEL >= TA_LOG_LEVEL_DEBUG) +#define ta_logd(fmt, args...) ta_print(LOG_LEVEL_DEBUG, "%s %d: " fmt "\n", TAG_DEBUG, __LINE__, ##args) +#else #define ta_logd(fmt, args...) \ do { \ } while (0) +#endif /* TA_LOG_LEVEL >= TA_LOG_LEVEL_DEBUG */ + +/* ta_logi */ +#if (TA_LOG_LEVEL >= TA_LOG_LEVEL_INFO) +#define ta_logi(fmt, args...) ta_print(LOG_LEVEL_INFO, "%s %d: " fmt "\n", TAG_INFO, __LINE__, ##args) +#else #define ta_logi(fmt, args...) \ do { \ } while (0) +#endif /* TA_LOG_LEVEL >= TA_LOG_LEVEL_INFO */ + +/* ta_logw */ +#if (TA_LOG_LEVEL >= TA_LOG_LEVEL_WARNING) +#define ta_logw(fmt, args...) ta_print(LOG_LEVEL_WARN, "%s %d: " fmt "\n", TAG_WARN, __LINE__, ##args) +#else #define ta_logw(fmt, args...) \ do { \ } while (0) -#endif +#endif /* TA_LOG_LEVEL >= TA_LOG_LEVEL_WARNING */ + +/* ta_loge */ +#if (TA_LOG_LEVEL >= TA_LOG_LEVEL_ERROR) // Always meet this condition #define ta_loge(fmt, args...) ta_print(LOG_LEVEL_ERROR, "%s %d: " fmt "\n", TAG_ERROR, __LINE__, ##args) +#else +#define ta_loge(fmt, args...) \ + do { \ + } while (0) +#endif /* TA_LOG_LEVEL >= TA_LOG_LEVEL_ERROR */ -/* in debug version users can dynamically modify the loglevel ,in release version, users have to modify the level by - * compile */ +/* +in debug version, users can dynamically modify the loglevel, +in release version, users have to modify the level by compile +*/ #ifndef DEBUG_VERSION - #ifdef TA_DEBUG #define ta_debug(fmt, args...) uart_printf_func("%s %s: " fmt "", DEBUG_TAG, __FUNCTION__, ##args) #else #define ta_debug(fmt, args...) -#endif - +#endif /* TA_DEBUG */ #else - #define ta_debug(fmt, args...) \ do { \ uint32_t level; \ @@ -142,67 +205,61 @@ void ta_print(LOG_LEVEL log_level, const char *fmt, ...); } \ } while (0) -#endif +#endif /* DEBUG_VERSION */ #define ta_info(fmt, args...) uart_printf_func("%s: " fmt "", INFO_TAG, ##args) #define ta_error(fmt, args...) uart_printf_func("%s: " fmt " ", ERROR_TAG, ##args) -#define TA_LOG -#ifdef TA_LOG +/* Log level for SLogx */ #define TRACE_S "[Trace]" #define WARNING_S "[Warning]" #define ERROR_S "[Error]" -/* - * Print trace level's log. - * - * @param fmt [IN] assert condition. - * @param args [IN] params for format config. - * - * @return void - */ -#define SLogTrace(fmt, args...) SLog("%s: " fmt "\n", TRACE_S, ##args) +#define TA_SLOG_LEVEL_ERROR 0 +#define TA_SLOG_LEVEL_WARNING 1 +#define TA_SLOG_LEVEL_TRACE 2 -/* - * Print warning level's log. - * - * @param fmt [IN] assert condition. - * @param args [IN] params for format config. - * - * @return void - */ -#define SLogWarning(fmt, args...) SLog("%s: " fmt "\n", WARNING_S, ##args) +#define TA_SLOG_LEVEL_DEFAULT TA_SLOG_LEVEL_WARNING +// TA_SLOG_LEVEL can be redefined by TA developers +#ifndef TA_SLOG_LEVEL +#define TA_SLOG_LEVEL TA_SLOG_LEVEL_DEFAULT +#endif -/* - * Print error level's log. - * - * @param fmt [IN] assert condition. - * @param args [IN] params for format config. - * - * @return void - */ -#define SLogError(fmt, args...) SLog("%s: " fmt "\n", ERROR_S, ##args) +/* SLogTrace */ +#if (TA_SLOG_LEVEL >= TA_SLOG_LEVEL_TRACE) +#define SLogTrace(fmt, args...) tee_print(LOG_LEVEL_DEBUG, "%s: " fmt "\n", TRACE_S, ##args) +#else +#define SLogTrace(fmt, args...) \ + do { \ + } while (0) +#endif -/* - * Assert api for tee log, note: should call Panic to deal, here just return - * - * @param exp [IN] Printf log's format config style. - * - * @return void - */ +/* SLogWarning */ +#if (TA_SLOG_LEVEL >= TA_SLOG_LEVEL_WARNING) +#define SLogWarning(fmt, args...) tee_print(LOG_LEVEL_WARN, "%s: " fmt "\n", WARNING_S, ##args) +#else +#define SLogWarning(fmt, args...) \ + do { \ + } while (0) +#endif + +/* SLogError */ +#if (TA_SLOG_LEVEL >= TA_SLOG_LEVEL_ERROR) +#define SLogError(fmt, args...) tee_print(LOG_LEVEL_ERROR, "%s: " fmt "\n", ERROR_S, ##args) +#else +#define SLogError(fmt, args...) \ + do { \ + } while (0) +#endif + +/* SAssert, Assert api for tee log, note: should call Panic to deal, here just return */ #define SAssert(exp) \ do { \ if (!(exp)) { \ - SLog("Assertion [ %s ] Failed: File %s, Line %d\n", #exp, "__FILE__", __LINE__); \ + tee_print(LOG_LEVEL_ERROR, "Assertion [%s] Failed: File %s, Line %d\n", #exp, __FILE__, __LINE__); \ return 0xFFFF0001; \ } \ } while (0); -#else -#define SLogTrace(fmt, args...) ((void)0) -#define SLogWarning(fmt, args...) ((void)0) -#define SLogError(fmt, args...) ((void)0) -#define SAssert(exp) ((void)0) -#endif /* * Output log to tee log file. @@ -211,6 +268,7 @@ void ta_print(LOG_LEVEL log_level, const char *fmt, ...); * * @return void */ -void SLog(const char *fmt, ...); +void slog(const char *fmt, ...); uint32_t get_value(void); -#endif +#define TEE_LogPrintf(fmt, args...) slog(fmt, ##args) +#endif /* __TEE_LOG_H */ diff --git a/include/TA/huawei_ext/tee_log_legacy.h b/include/TA/huawei_ext/tee_log_legacy.h new file mode 100644 index 0000000..ab555aa --- /dev/null +++ b/include/TA/huawei_ext/tee_log_legacy.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS 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: Reference of TEE log api and internal definitions + */ + +#ifndef __TEE_LOG_LEGACY_H__ +#define __TEE_LOG_LEGACY_H__ + +#include + +void SLog(const char *fmt, ...); +#endif /* __TEE_LOG_LEGACY_H__ */ diff --git a/include/TA/huawei_ext/tee_openssl_err.h b/include/TA/huawei_ext/tee_openssl_err.h new file mode 100644 index 0000000..c23e635 --- /dev/null +++ b/include/TA/huawei_ext/tee_openssl_err.h @@ -0,0 +1,500 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS 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: tee crypto err definitions + */ + +#ifndef TEE_OPENSSL_ERR_H +#define TEE_OPENSSL_ERR_H + +/* + * define openssl lib reasons err code: + * Delete the prefix TEE_ERR_, which is the error code name in the open-source library. + */ +/* for common lib err */ +#define TEE_ERR_R_MALLOC_FAILURE 0x80022041 +#define TEE_ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED 0x80022042 +#define TEE_ERR_R_PASSED_NULL_PARAMETER 0x80022043 +#define TEE_ERR_R_INTERNAL_ERROR 0x80022044 +#define TEE_ERR_R_DISABLED 0x80022045 +#define TEE_ERR_R_INIT_FAIL 0x80022046 +#define TEE_ERR_R_PASSED_INVALID_ARGUMENT 0x80022007 +#define TEE_ERR_R_OPERATION_FAIL 0x80022048 + +/* for bn lib err */ +#define TEE_ERR_BN_R_ARG2_LT_ARG3 0x80023064 +#define TEE_ERR_BN_R_BAD_RECIPROCAL 0x80023065 +#define TEE_ERR_BN_R_BIGNUM_TOO_LONG 0x80023072 +#define TEE_ERR_BN_R_BITS_TOO_SMALL 0x80023076 +#define TEE_ERR_BN_R_CALLED_WITH_EVEN_MODULUS 0x80023066 +#define TEE_ERR_BN_R_DIV_BY_ZERO 0x80023067 +#define TEE_ERR_BN_R_ENCODING_ERROR 0x80023068 +#define TEE_ERR_BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 0x80023069 +#define TEE_ERR_BN_R_INPUT_NOT_REDUCED 0x8002306e +#define TEE_ERR_BN_R_INVALID_LENGTH 0x8002306a +#define TEE_ERR_BN_R_INVALID_RANGE 0x80023073 +#define TEE_ERR_BN_R_INVALID_SHIFT 0x80023077 +#define TEE_ERR_BN_R_NOT_A_SQUARE 0x8002306f +#define TEE_ERR_BN_R_NOT_INITIALIZED 0x8002306b +#define TEE_ERR_BN_R_NO_INVERSE 0x8002306c +#define TEE_ERR_BN_R_NO_SOLUTION 0x80023074 +#define TEE_ERR_BN_R_PRIVATE_KEY_TOO_LARGE 0x80023075 +#define TEE_ERR_BN_R_P_IS_NOT_PRIME 0x80023070 +#define TEE_ERR_BN_R_TOO_MANY_ITERATIONS 0x80023071 +#define TEE_ERR_BN_R_TOO_MANY_TEMPORARY_VARIABLES 0x8002306d + +/* for rsa lib err */ +#define TEE_ERR_RSA_R_ALGORITHM_MISMATCH 0x80024064 +#define TEE_ERR_RSA_R_BAD_E_VALUE 0x80024065 +#define TEE_ERR_RSA_R_BAD_FIXED_HEADER_DECRYPT 0x80024066 +#define TEE_ERR_RSA_R_BAD_PAD_BYTE_COUNT 0x80024067 +#define TEE_ERR_RSA_R_BAD_SIGNATURE 0x80024068 +#define TEE_ERR_RSA_R_BLOCK_TYPE_IS_NOT_01 0x8002406a +#define TEE_ERR_RSA_R_BLOCK_TYPE_IS_NOT_02 0x8002406b +#define TEE_ERR_RSA_R_DATA_GREATER_THAN_MOD_LEN 0x8002406c +#define TEE_ERR_RSA_R_DATA_TOO_LARGE 0x8002406d +#define TEE_ERR_RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 0x8002406e +#define TEE_ERR_RSA_R_DATA_TOO_LARGE_FOR_MODULUS 0x80024084 +#define TEE_ERR_RSA_R_DATA_TOO_SMALL 0x8002406f +#define TEE_ERR_RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 0x8002407a +#define TEE_ERR_RSA_R_DIGEST_DOES_NOT_MATCH 0x8002409e +#define TEE_ERR_RSA_R_DIGEST_NOT_ALLOWED 0x80024091 +#define TEE_ERR_RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 0x80024070 +#define TEE_ERR_RSA_R_DMP1_NOT_CONGRUENT_TO_D 0x8002407c +#define TEE_ERR_RSA_R_DMQ1_NOT_CONGRUENT_TO_D 0x8002407d +#define TEE_ERR_RSA_R_D_E_NOT_CONGRUENT_TO_1 0x8002407b +#define TEE_ERR_RSA_R_FIRST_OCTET_INVALID 0x80024085 +#define TEE_ERR_RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE 0x80024090 +#define TEE_ERR_RSA_R_INVALID_DIGEST 0x8002409d +#define TEE_ERR_RSA_R_INVALID_DIGEST_LENGTH 0x8002408f +#define TEE_ERR_RSA_R_INVALID_HEADER 0x80024089 +#define TEE_ERR_RSA_R_INVALID_LABEL 0x800240a0 +#define TEE_ERR_RSA_R_INVALID_MESSAGE_LENGTH 0x80024083 +#define TEE_ERR_RSA_R_INVALID_MGF1_MD 0x8002409c +#define TEE_ERR_RSA_R_INVALID_MULTI_PRIME_KEY 0x800240a7 +#define TEE_ERR_RSA_R_INVALID_OAEP_PARAMETERS 0x800240a1 +#define TEE_ERR_RSA_R_INVALID_PADDING 0x8002408a +#define TEE_ERR_RSA_R_INVALID_PADDING_MODE 0x8002408d +#define TEE_ERR_RSA_R_INVALID_PSS_PARAMETERS 0x80024095 +#define TEE_ERR_RSA_R_INVALID_PSS_SALTLEN 0x80024092 +#define TEE_ERR_RSA_R_INVALID_SALT_LENGTH 0x80024096 +#define TEE_ERR_RSA_R_INVALID_TRAILER 0x8002408b +#define TEE_ERR_RSA_R_INVALID_X931_DIGEST 0x8002408e +#define TEE_ERR_RSA_R_IQMP_NOT_INVERSE_OF_Q 0x8002407e +#define TEE_ERR_RSA_R_KEY_PRIME_NUM_INVALID 0x800240a5 +#define TEE_ERR_RSA_R_KEY_SIZE_TOO_SMALL 0x80024078 +#define TEE_ERR_RSA_R_LAST_OCTET_INVALID 0x80024086 +#define TEE_ERR_RSA_R_MISSING_PRIVATE_KEY 0x800240b3 +#define TEE_ERR_RSA_R_MGF1_DIGEST_NOT_ALLOWED 0x80024098 +#define TEE_ERR_RSA_R_MODULUS_TOO_LARGE 0x80024069 +#define TEE_ERR_RSA_R_MP_COEFFICIENT_NOT_INVERSE_OF_R 0x800240a8 +#define TEE_ERR_RSA_R_MP_EXPONENT_NOT_CONGRUENT_TO_D 0x800240a9 +#define TEE_ERR_RSA_R_MP_R_NOT_PRIME 0x800240aa +#define TEE_ERR_RSA_R_NO_PUBLIC_EXPONENT 0x8002408c +#define TEE_ERR_RSA_R_NULL_BEFORE_BLOCK_MISSING 0x80024071 +#define TEE_ERR_RSA_R_N_DOES_NOT_EQUAL_PRODUCT_OF_PRIMES 0x800240ac +#define TEE_ERR_RSA_R_N_DOES_NOT_EQUAL_P_Q 0x8002407f +#define TEE_ERR_RSA_R_OAEP_DECODING_ERROR 0x80024079 +#define TEE_ERR_RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 0x80024094 +#define TEE_ERR_RSA_R_PADDING_CHECK_FAILED 0x80024072 +#define TEE_ERR_RSA_R_PKCS_DECODING_ERROR 0x8002409f +#define TEE_ERR_RSA_R_PSS_SALTLEN_TOO_SMALL 0x800240a4 +#define TEE_ERR_RSA_R_P_NOT_PRIME 0x80024080 +#define TEE_ERR_RSA_R_Q_NOT_PRIME 0x80024081 +#define TEE_ERR_RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 0x80024082 +#define TEE_ERR_RSA_R_SLEN_CHECK_FAILED 0x80024088 +#define TEE_ERR_RSA_R_SLEN_RECOVERY_FAILED 0x80024087 +#define TEE_ERR_RSA_R_SSLV3_ROLLBACK_ATTACK 0x80024073 +#define TEE_ERR_RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 0x80024074 +#define TEE_ERR_RSA_R_UNKNOWN_ALGORITHM_TYPE 0x80024075 +#define TEE_ERR_RSA_R_UNKNOWN_DIGEST 0x800240a6 +#define TEE_ERR_RSA_R_UNKNOWN_MASK_DIGEST 0x80024097 +#define TEE_ERR_RSA_R_UNKNOWN_PADDING_TYPE 0x80024076 +#define TEE_ERR_RSA_R_UNSUPPORTED_ENCRYPTION_TYPE 0x800240a2 +#define TEE_ERR_RSA_R_UNSUPPORTED_LABEL_SOURCE 0x800240a3 +#define TEE_ERR_RSA_R_UNSUPPORTED_MASK_ALGORITHM 0x80024099 +#define TEE_ERR_RSA_R_UNSUPPORTED_MASK_PARAMETER 0x8002409a +#define TEE_ERR_RSA_R_UNSUPPORTED_SIGNATURE_TYPE 0x8002409b +#define TEE_ERR_RSA_R_VALUE_MISSING 0x80024093 +#define TEE_ERR_RSA_R_WRONG_SIGNATURE_LENGTH 0x80024077 + +/* for evp lib err */ +#define TEE_ERR_EVP_R_AES_KEY_SETUP_FAILED 0x8002508f +#define TEE_ERR_EVP_R_ARIA_KEY_SETUP_FAILED 0x800250b0 +#define TEE_ERR_EVP_R_BAD_DECRYPT 0x80025064 +#define TEE_ERR_EVP_R_BAD_KEY_LENGTH 0x800250c3 +#define TEE_ERR_EVP_R_BUFFER_TOO_SMALL 0x8002509b +#define TEE_ERR_EVP_R_CAMELLIA_KEY_SETUP_FAILED 0x8002509d +#define TEE_ERR_EVP_R_CIPHER_PARAMETER_ERROR 0x8002507a +#define TEE_ERR_EVP_R_COMMAND_NOT_SUPPORTED 0x80025093 +#define TEE_ERR_EVP_R_COPY_ERROR 0x800250ad +#define TEE_ERR_EVP_R_CTRL_NOT_IMPLEMENTED 0x80025084 +#define TEE_ERR_EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 0x80025085 +#define TEE_ERR_EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 0x8002508a +#define TEE_ERR_EVP_R_DECODE_ERROR 0x80025072 +#define TEE_ERR_EVP_R_DIFFERENT_KEY_TYPES 0x80025065 +#define TEE_ERR_EVP_R_DIFFERENT_PARAMETERS 0x80025099 +#define TEE_ERR_EVP_R_ERROR_LOADING_SECTION 0x800250a5 +#define TEE_ERR_EVP_R_ERROR_SETTING_FIPS_MODE 0x800250a6 +#define TEE_ERR_EVP_R_EXPECTING_AN_HMAC_KEY 0x800250ae +#define TEE_ERR_EVP_R_EXPECTING_AN_RSA_KEY 0x8002507f +#define TEE_ERR_EVP_R_EXPECTING_A_DH_KEY 0x80025080 +#define TEE_ERR_EVP_R_EXPECTING_A_DSA_KEY 0x80025081 +#define TEE_ERR_EVP_R_EXPECTING_A_EC_KEY 0x8002508e +#define TEE_ERR_EVP_R_EXPECTING_A_POLY1305_KEY 0x800250a4 +#define TEE_ERR_EVP_R_EXPECTING_A_SIPHASH_KEY 0x800250af +#define TEE_ERR_EVP_R_FIPS_MODE_NOT_SUPPORTED 0x800250a7 +#define TEE_ERR_EVP_R_GET_RAW_KEY_FAILED 0x800250b6 +#define TEE_ERR_EVP_R_ILLEGAL_SCRYPT_PARAMETERS 0x800250ab +#define TEE_ERR_EVP_R_INITIALIZATION_ERROR 0x80025086 +#define TEE_ERR_EVP_R_INPUT_NOT_INITIALIZED 0x8002506f +#define TEE_ERR_EVP_R_INVALID_DIGEST 0x80025098 +#define TEE_ERR_EVP_R_INVALID_FIPS_MODE 0x800250a8 +#define TEE_ERR_EVP_R_INVALID_IV_LENGTH 0x800250c2 +#define TEE_ERR_EVP_R_INVALID_KEY 0x800250a3 +#define TEE_ERR_EVP_R_INVALID_KEY_LENGTH 0x80025082 +#define TEE_ERR_EVP_R_INVALID_OPERATION 0x80025094 +#define TEE_ERR_EVP_R_KEYGEN_FAILURE 0x80025078 +#define TEE_ERR_EVP_R_KEY_SETUP_FAILED 0x800250b4 +#define TEE_ERR_EVP_R_MEMORY_LIMIT_EXCEEDED 0x800250ac +#define TEE_ERR_EVP_R_MESSAGE_DIGEST_IS_NULL 0x8002509f +#define TEE_ERR_EVP_R_METHOD_NOT_SUPPORTED 0x80025090 +#define TEE_ERR_EVP_R_MISSING_PARAMETERS 0x80025067 +#define TEE_ERR_EVP_R_NOT_XOF_OR_INVALID_LENGTH 0x800250b2 +#define TEE_ERR_EVP_R_NO_CIPHER_SET 0x80025083 +#define TEE_ERR_EVP_R_NO_DEFAULT_DIGEST 0x8002509e +#define TEE_ERR_EVP_R_NO_DIGEST_SET 0x8002508b +#define TEE_ERR_EVP_R_NO_KEY_SET 0x8002509a +#define TEE_ERR_EVP_R_NO_OPERATION_SET 0x80025095 +#define TEE_ERR_EVP_R_ONLY_ONESHOT_SUPPORTED 0x800250b1 +#define TEE_ERR_EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 0x80025096 +#define TEE_ERR_EVP_R_OPERATON_NOT_INITIALIZED 0x80025097 +#define TEE_ERR_EVP_R_PARTIALLY_OVERLAPPING 0x800250a2 +#define TEE_ERR_EVP_R_PBKDF2_ERROR 0x800250b5 +#define TEE_ERR_EVP_R_PKEY_APPLICATION_ASN1_METHOD_ALREADY_REGISTERED 0x800250b3 +#define TEE_ERR_EVP_R_PRIVATE_KEY_DECODE_ERROR 0x80025091 +#define TEE_ERR_EVP_R_PRIVATE_KEY_ENCODE_ERROR 0x80025092 +#define TEE_ERR_EVP_R_PUBLIC_KEY_NOT_RSA 0x8002506a +#define TEE_ERR_EVP_R_UNKNOWN_CIPHER 0x800250a0 +#define TEE_ERR_EVP_R_UNKNOWN_DIGEST 0x800250a1 +#define TEE_ERR_EVP_R_UNKNOWN_OPTION 0x800250a9 +#define TEE_ERR_EVP_R_UNKNOWN_PBE_ALGORITHM 0x80025079 +#define TEE_ERR_EVP_R_UNSUPPORTED_ALGORITHM 0x8002509c +#define TEE_ERR_EVP_R_UNSUPPORTED_CIPHER 0x8002506b +#define TEE_ERR_EVP_R_UNSUPPORTED_KEYLENGTH 0x8002507b +#define TEE_ERR_EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 0x8002507c +#define TEE_ERR_EVP_R_UNSUPPORTED_KEY_SIZE 0x8002506c +#define TEE_ERR_EVP_R_UNSUPPORTED_NUMBER_OF_ROUNDS 0x80025087 +#define TEE_ERR_EVP_R_UNSUPPORTED_PRF 0x8002507d +#define TEE_ERR_EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 0x80025076 +#define TEE_ERR_EVP_R_UNSUPPORTED_SALT_TYPE 0x8002507e +#define TEE_ERR_EVP_R_WRAP_MODE_NOT_ALLOWED 0x800250aa +#define TEE_ERR_EVP_R_WRONG_FINAL_BLOCK_LENGTH 0x8002506d +#define TEE_ERR_EVP_R_XTS_DUPLICATED_KEYS 0x800250b7 + +/* for pem lib err */ +#define TEE_ERR_PEM_R_BAD_BASE64_DECODE 0x80026064 +#define TEE_ERR_PEM_R_BAD_DECRYPT 0x80026065 +#define TEE_ERR_PEM_R_BAD_END_LINE 0x80026066 +#define TEE_ERR_PEM_R_BAD_IV_CHARS 0x80026067 +#define TEE_ERR_PEM_R_BAD_MAGIC_NUMBER 0x80026074 +#define TEE_ERR_PEM_R_BAD_PASSWORD_READ 0x80026068 +#define TEE_ERR_PEM_R_BAD_VERSION_NUMBER 0x80026075 +#define TEE_ERR_PEM_R_BIO_WRITE_FAILURE 0x80026076 +#define TEE_ERR_PEM_R_CIPHER_IS_NULL 0x8002607f +#define TEE_ERR_PEM_R_ERROR_CONVERTING_PRIVATE_KEY 0x80026073 +#define TEE_ERR_PEM_R_EXPECTING_PRIVATE_KEY_BLOB 0x80026077 +#define TEE_ERR_PEM_R_EXPECTING_PUBLIC_KEY_BLOB 0x80026078 +#define TEE_ERR_PEM_R_HEADER_TOO_LONG 0x80026080 +#define TEE_ERR_PEM_R_INCONSISTENT_HEADER 0x80026079 +#define TEE_ERR_PEM_R_KEYBLOB_HEADER_PARSE_ERROR 0x8002607a +#define TEE_ERR_PEM_R_KEYBLOB_TOO_SHORT 0x8002607b +#define TEE_ERR_PEM_R_MISSING_DEK_IV 0x80026081 +#define TEE_ERR_PEM_R_NOT_DEK_INFO 0x80026069 +#define TEE_ERR_PEM_R_NOT_ENCRYPTED 0x8002606a +#define TEE_ERR_PEM_R_NOT_PROC_TYPE 0x8002606b +#define TEE_ERR_PEM_R_NO_START_LINE 0x8002606c +#define TEE_ERR_PEM_R_PROBLEMS_GETTING_PASSWORD 0x8002606d +#define TEE_ERR_PEM_R_PVK_DATA_TOO_SHORT 0x8002607c +#define TEE_ERR_PEM_R_PVK_TOO_SHORT 0x8002607d +#define TEE_ERR_PEM_R_READ_KEY 0x8002606f +#define TEE_ERR_PEM_R_SHORT_HEADER 0x80026070 +#define TEE_ERR_PEM_R_UNEXPECTED_DEK_IV 0x80026082 +#define TEE_ERR_PEM_R_UNSUPPORTED_CIPHER 0x80026071 +#define TEE_ERR_PEM_R_UNSUPPORTED_ENCRYPTION 0x80026072 +#define TEE_ERR_PEM_R_UNSUPPORTED_KEY_COMPONENTS 0x8002607e + +/* for x509 lib err */ +#define TEE_ERR_X509_R_AKID_MISMATCH 0x8002706e +#define TEE_ERR_X509_R_BAD_SELECTOR 0x80027085 +#define TEE_ERR_X509_R_BAD_X509_FILETYPE 0x80027064 +#define TEE_ERR_X509_R_BASE64_DECODE_ERROR 0x80027076 +#define TEE_ERR_X509_R_CANT_CHECK_DH_KEY 0x80027072 +#define TEE_ERR_X509_R_CERT_ALREADY_IN_HASH_TABLE 0x80027065 +#define TEE_ERR_X509_R_CRL_ALREADY_DELTA 0x8002707f +#define TEE_ERR_X509_R_CRL_VERIFY_FAILURE 0x80027083 +#define TEE_ERR_X509_R_IDP_MISMATCH 0x80027080 +#define TEE_ERR_X509_R_INVALID_ATTRIBUTES 0x8002708a +#define TEE_ERR_X509_R_INVALID_DIRECTORY 0x80027071 +#define TEE_ERR_X509_R_INVALID_FIELD_NAME 0x80027077 +#define TEE_ERR_X509_R_INVALID_TRUST 0x8002707b +#define TEE_ERR_X509_R_ISSUER_MISMATCH 0x80027081 +#define TEE_ERR_X509_R_KEY_TYPE_MISMATCH 0x80027073 +#define TEE_ERR_X509_R_KEY_VALUES_MISMATCH 0x80027074 +#define TEE_ERR_X509_R_LOADING_CERT_DIR 0x80027067 +#define TEE_ERR_X509_R_LOADING_DEFAULTS 0x80027068 +#define TEE_ERR_X509_R_METHOD_NOT_SUPPORTED 0x8002707c +#define TEE_ERR_X509_R_NAME_TOO_LONG 0x80027086 +#define TEE_ERR_X509_R_NEWER_CRL_NOT_NEWER 0x80027084 +#define TEE_ERR_X509_R_NO_CERTIFICATE_FOUND 0x80027087 +#define TEE_ERR_X509_R_NO_CERTIFICATE_OR_CRL_FOUND 0x80027088 +#define TEE_ERR_X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 0x80027069 +#define TEE_ERR_X509_R_NO_CRL_FOUND 0x80027089 +#define TEE_ERR_X509_R_NO_CRL_NUMBER 0x80027082 +#define TEE_ERR_X509_R_PUBLIC_KEY_DECODE_ERROR 0x8002707d +#define TEE_ERR_X509_R_PUBLIC_KEY_ENCODE_ERROR 0x8002707e +#define TEE_ERR_X509_R_SHOULD_RETRY 0x8002706a +#define TEE_ERR_X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 0x8002706b +#define TEE_ERR_X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 0x8002706c +#define TEE_ERR_X509_R_UNKNOWN_KEY_TYPE 0x80027075 +#define TEE_ERR_X509_R_UNKNOWN_NID 0x8002706d +#define TEE_ERR_X509_R_UNKNOWN_PURPOSE_ID 0x80027079 +#define TEE_ERR_X509_R_UNKNOWN_TRUST_ID 0x80027078 +#define TEE_ERR_X509_R_UNSUPPORTED_ALGORITHM 0x8002706f +#define TEE_ERR_X509_R_WRONG_LOOKUP_TYPE 0x80027070 +#define TEE_ERR_X509_R_WRONG_TYPE 0x8002707a + +/* for asn1 lib err */ +#define TEE_ERR_ASN1_R_ADDING_OBJECT 0x800280ab +#define TEE_ERR_ASN1_R_ASN1_PARSE_ERROR 0x800280cb +#define TEE_ERR_ASN1_R_ASN1_SIG_PARSE_ERROR 0x800280cc +#define TEE_ERR_ASN1_R_AUX_ERROR 0x80028064 +#define TEE_ERR_ASN1_R_BAD_OBJECT_HEADER 0x80028066 +#define TEE_ERR_ASN1_R_BMPSTRING_IS_WRONG_LENGTH 0x800280d6 +#define TEE_ERR_ASN1_R_BN_LIB 0x80028069 +#define TEE_ERR_ASN1_R_BOOLEAN_IS_WRONG_LENGTH 0x8002806a +#define TEE_ERR_ASN1_R_BUFFER_TOO_SMALL 0x8002806b +#define TEE_ERR_ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 0x8002806c +#define TEE_ERR_ASN1_R_CONTEXT_NOT_INITIALISED 0x800280d9 +#define TEE_ERR_ASN1_R_DATA_IS_WRONG 0x8002806d +#define TEE_ERR_ASN1_R_DECODE_ERROR 0x8002806e +#define TEE_ERR_ASN1_R_DEPTH_EXCEEDED 0x800280ae +#define TEE_ERR_ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED 0x800280c6 +#define TEE_ERR_ASN1_R_ENCODE_ERROR 0x80028070 +#define TEE_ERR_ASN1_R_ERROR_GETTING_TIME 0x800280ad +#define TEE_ERR_ASN1_R_ERROR_LOADING_SECTION 0x800280ac +#define TEE_ERR_ASN1_R_ERROR_SETTING_CIPHER_PARAMS 0x80028072 +#define TEE_ERR_ASN1_R_EXPECTING_AN_INTEGER 0x80028073 +#define TEE_ERR_ASN1_R_EXPECTING_AN_OBJECT 0x80028074 +#define TEE_ERR_ASN1_R_EXPLICIT_LENGTH_MISMATCH 0x80028077 +#define TEE_ERR_ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 0x80028078 +#define TEE_ERR_ASN1_R_FIELD_MISSING 0x80028079 +#define TEE_ERR_ASN1_R_FIRST_NUM_TOO_LARGE 0x8002807a +#define TEE_ERR_ASN1_R_HEADER_TOO_LONG 0x8002807b +#define TEE_ERR_ASN1_R_ILLEGAL_BITSTRING_FORMAT 0x800280af +#define TEE_ERR_ASN1_R_ILLEGAL_BOOLEAN 0x800280b0 +#define TEE_ERR_ASN1_R_ILLEGAL_CHARACTERS 0x8002807c +#define TEE_ERR_ASN1_R_ILLEGAL_FORMAT 0x800280b1 +#define TEE_ERR_ASN1_R_ILLEGAL_HEX 0x800280b2 +#define TEE_ERR_ASN1_R_ILLEGAL_IMPLICIT_TAG 0x800280b3 +#define TEE_ERR_ASN1_R_ILLEGAL_INTEGER 0x800280b4 +#define TEE_ERR_ASN1_R_ILLEGAL_NEGATIVE_VALUE 0x800280e2 +#define TEE_ERR_ASN1_R_ILLEGAL_NESTED_TAGGING 0x800280b5 +#define TEE_ERR_ASN1_R_ILLEGAL_NULL 0x8002807d +#define TEE_ERR_ASN1_R_ILLEGAL_NULL_VALUE 0x800280b6 +#define TEE_ERR_ASN1_R_ILLEGAL_OBJECT 0x800280b7 +#define TEE_ERR_ASN1_R_ILLEGAL_OPTIONAL_ANY 0x8002807e +#define TEE_ERR_ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 0x800280aa +#define TEE_ERR_ASN1_R_ILLEGAL_PADDING 0x800280dd +#define TEE_ERR_ASN1_R_ILLEGAL_TAGGED_ANY 0x8002807f +#define TEE_ERR_ASN1_R_ILLEGAL_TIME_VALUE 0x800280b8 +#define TEE_ERR_ASN1_R_ILLEGAL_ZERO_CONTENT 0x800280de +#define TEE_ERR_ASN1_R_INTEGER_NOT_ASCII_FORMAT 0x800280b9 +#define TEE_ERR_ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 0x80028080 +#define TEE_ERR_ASN1_R_INVALID_BIT_STRING_BITS_LEFT 0x800280dc +#define TEE_ERR_ASN1_R_INVALID_BMPSTRING_LENGTH 0x80028081 +#define TEE_ERR_ASN1_R_INVALID_DIGIT 0x80028082 +#define TEE_ERR_ASN1_R_INVALID_MIME_TYPE 0x800280cd +#define TEE_ERR_ASN1_R_INVALID_MODIFIER 0x800280ba +#define TEE_ERR_ASN1_R_INVALID_NUMBER 0x800280bb +#define TEE_ERR_ASN1_R_INVALID_OBJECT_ENCODING 0x800280d8 +#define TEE_ERR_ASN1_R_INVALID_SCRYPT_PARAMETERS 0x800280e3 +#define TEE_ERR_ASN1_R_INVALID_SEPARATOR 0x80028083 +#define TEE_ERR_ASN1_R_INVALID_STRING_TABLE_VALUE 0x800280da +#define TEE_ERR_ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 0x80028085 +#define TEE_ERR_ASN1_R_INVALID_UTF8STRING 0x80028086 +#define TEE_ERR_ASN1_R_INVALID_VALUE 0x800280db +#define TEE_ERR_ASN1_R_LIST_ERROR 0x800280bc +#define TEE_ERR_ASN1_R_MIME_NO_CONTENT_TYPE 0x800280ce +#define TEE_ERR_ASN1_R_MIME_PARSE_ERROR 0x800280cf +#define TEE_ERR_ASN1_R_MIME_SIG_PARSE_ERROR 0x800280d0 +#define TEE_ERR_ASN1_R_MISSING_EOC 0x80028089 +#define TEE_ERR_ASN1_R_MISSING_SECOND_NUMBER 0x8002808a +#define TEE_ERR_ASN1_R_MISSING_VALUE 0x800280bd +#define TEE_ERR_ASN1_R_MSTRING_NOT_UNIVERSAL 0x8002808b +#define TEE_ERR_ASN1_R_MSTRING_WRONG_TAG 0x8002808c +#define TEE_ERR_ASN1_R_NESTED_ASN1_STRING 0x800280c5 +#define TEE_ERR_ASN1_R_NESTED_TOO_DEEP 0x800280c9 +#define TEE_ERR_ASN1_R_NON_HEX_CHARACTERS 0x8002808d +#define TEE_ERR_ASN1_R_NOT_ASCII_FORMAT 0x800280be +#define TEE_ERR_ASN1_R_NOT_ENOUGH_DATA 0x8002808e +#define TEE_ERR_ASN1_R_NO_CONTENT_TYPE 0x800280d1 +#define TEE_ERR_ASN1_R_NO_MATCHING_CHOICE_TYPE 0x8002808f +#define TEE_ERR_ASN1_R_NO_MULTIPART_BODY_FAILURE 0x800280d2 +#define TEE_ERR_ASN1_R_NO_MULTIPART_BOUNDARY 0x800280d3 +#define TEE_ERR_ASN1_R_NO_SIG_CONTENT_TYPE 0x800280d4 +#define TEE_ERR_ASN1_R_NULL_IS_WRONG_LENGTH 0x80028090 +#define TEE_ERR_ASN1_R_OBJECT_NOT_ASCII_FORMAT 0x800280bf +#define TEE_ERR_ASN1_R_ODD_NUMBER_OF_CHARS 0x80028091 +#define TEE_ERR_ASN1_R_SECOND_NUMBER_TOO_LARGE 0x80028093 +#define TEE_ERR_ASN1_R_SEQUENCE_LENGTH_MISMATCH 0x80028094 +#define TEE_ERR_ASN1_R_SEQUENCE_NOT_CONSTRUCTED 0x80028095 +#define TEE_ERR_ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 0x800280c0 +#define TEE_ERR_ASN1_R_SHORT_LINE 0x80028096 +#define TEE_ERR_ASN1_R_SIG_INVALID_MIME_TYPE 0x800280d5 +#define TEE_ERR_ASN1_R_STREAMING_NOT_SUPPORTED 0x800280ca +#define TEE_ERR_ASN1_R_STRING_TOO_LONG 0x80028097 +#define TEE_ERR_ASN1_R_STRING_TOO_SHORT 0x80028098 +#define TEE_ERR_ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 0x8002809a +#define TEE_ERR_ASN1_R_TIME_NOT_ASCII_FORMAT 0x800280c1 +#define TEE_ERR_ASN1_R_TOO_LARGE 0x800280df +#define TEE_ERR_ASN1_R_TOO_LONG 0x8002809b +#define TEE_ERR_ASN1_R_TOO_SMALL 0x800280e0 +#define TEE_ERR_ASN1_R_TYPE_NOT_CONSTRUCTED 0x8002809c +#define TEE_ERR_ASN1_R_TYPE_NOT_PRIMITIVE 0x800280c3 +#define TEE_ERR_ASN1_R_UNEXPECTED_EOC 0x8002809f +#define TEE_ERR_ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 0x800280d7 +#define TEE_ERR_ASN1_R_UNKNOWN_FORMAT 0x800280a0 +#define TEE_ERR_ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 0x800280a1 +#define TEE_ERR_ASN1_R_UNKNOWN_OBJECT_TYPE 0x800280a2 +#define TEE_ERR_ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 0x800280a3 +#define TEE_ERR_ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 0x800280c7 +#define TEE_ERR_ASN1_R_UNKNOWN_TAG 0x800280c2 +#define TEE_ERR_ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 0x800280a4 +#define TEE_ERR_ASN1_R_UNSUPPORTED_CIPHER 0x800280e4 +#define TEE_ERR_ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 0x800280a7 +#define TEE_ERR_ASN1_R_UNSUPPORTED_TYPE 0x800280c4 +#define TEE_ERR_ASN1_R_WRONG_INTEGER_TYPE 0x800280e1 +#define TEE_ERR_ASN1_R_WRONG_PUBLIC_KEY_TYPE 0x800280c8 +#define TEE_ERR_ASN1_R_WRONG_TAG 0x800280a8 + +/* for crypto lib err */ +#define TEE_ERR_CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 0x80029065 +#define TEE_ERR_CRYPTO_R_ILLEGAL_HEX_DIGIT 0x80029066 +#define TEE_ERR_CRYPTO_R_ODD_NUMBER_OF_DIGITS 0x80029067 + +/* for ec lib err */ +#define TEE_ERR_EC_R_ASN1_ERROR 0x8002a073 +#define TEE_ERR_EC_R_BAD_SIGNATURE 0x8002a09c +#define TEE_ERR_EC_R_BIGNUM_OUT_OF_RANGE 0x8002a090 +#define TEE_ERR_EC_R_BUFFER_TOO_SMALL 0x8002a064 +#define TEE_ERR_EC_R_CANNOT_INVERT 0x8002a0a5 +#define TEE_ERR_EC_R_COORDINATES_OUT_OF_RANGE 0x8002a092 +#define TEE_ERR_EC_R_CURVE_DOES_NOT_SUPPORT_ECDH 0x8002a0a0 +#define TEE_ERR_EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING 0x8002a09f +#define TEE_ERR_EC_R_D2I_ECPKPARAMETERS_FAILURE 0x8002a075 +#define TEE_ERR_EC_R_DECODE_ERROR 0x8002a08e +#define TEE_ERR_EC_R_DISCRIMINANT_IS_ZERO 0x8002a076 +#define TEE_ERR_EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 0x8002a077 +#define TEE_ERR_EC_R_FIELD_TOO_LARGE 0x8002a08f +#define TEE_ERR_EC_R_GF2M_NOT_SUPPORTED 0x8002a093 +#define TEE_ERR_EC_R_GROUP2PKPARAMETERS_FAILURE 0x8002a078 +#define TEE_ERR_EC_R_I2D_ECPKPARAMETERS_FAILURE 0x8002a079 +#define TEE_ERR_EC_R_INCOMPATIBLE_OBJECTS 0x8002a065 +#define TEE_ERR_EC_R_INVALID_ARGUMENT 0x8002a070 +#define TEE_ERR_EC_R_INVALID_COMPRESSED_POINT 0x8002a06e +#define TEE_ERR_EC_R_INVALID_COMPRESSION_BIT 0x8002a06d +#define TEE_ERR_EC_R_INVALID_CURVE 0x8002a08d +#define TEE_ERR_EC_R_INVALID_DIGEST 0x8002a097 +#define TEE_ERR_EC_R_INVALID_DIGEST_TYPE 0x8002a08a +#define TEE_ERR_EC_R_INVALID_ENCODING 0x8002a066 +#define TEE_ERR_EC_R_INVALID_FIELD 0x8002a067 +#define TEE_ERR_EC_R_INVALID_FORM 0x8002a068 +#define TEE_ERR_EC_R_INVALID_GROUP_ORDER 0x8002a07a +#define TEE_ERR_EC_R_INVALID_KEY 0x8002a074 +#define TEE_ERR_EC_R_INVALID_OUTPUT_LENGTH 0x8002a0a1 +#define TEE_ERR_EC_R_INVALID_PEER_KEY 0x8002a085 +#define TEE_ERR_EC_R_INVALID_PENTANOMIAL_BASIS 0x8002a084 +#define TEE_ERR_EC_R_INVALID_PRIVATE_KEY 0x8002a07b +#define TEE_ERR_EC_R_INVALID_TRINOMIAL_BASIS 0x8002a089 +#define TEE_ERR_EC_R_KDF_PARAMETER_ERROR 0x8002a094 +#define TEE_ERR_EC_R_KEYS_NOT_SET 0x8002a08c +#define TEE_ERR_EC_R_LADDER_POST_FAILURE 0x8002a088 +#define TEE_ERR_EC_R_LADDER_PRE_FAILURE 0x8002a099 +#define TEE_ERR_EC_R_LADDER_STEP_FAILURE 0x8002a0a2 +#define TEE_ERR_EC_R_MISSING_PARAMETERS 0x8002a07c +#define TEE_ERR_EC_R_MISSING_PRIVATE_KEY 0x8002a07d +#define TEE_ERR_EC_R_NEED_NEW_SETUP_VALUES 0x8002a09d +#define TEE_ERR_EC_R_NOT_A_NIST_PRIME 0x8002a087 +#define TEE_ERR_EC_R_NOT_IMPLEMENTED 0x8002a07e +#define TEE_ERR_EC_R_NOT_INITIALIZED 0x8002a06f +#define TEE_ERR_EC_R_NO_PARAMETERS_SET 0x8002a08b +#define TEE_ERR_EC_R_NO_PRIVATE_VALUE 0x8002a09a +#define TEE_ERR_EC_R_OPERATION_NOT_SUPPORTED 0x8002a098 +#define TEE_ERR_EC_R_PASSED_NULL_PARAMETER 0x8002a086 +#define TEE_ERR_EC_R_PEER_KEY_ERROR 0x8002a095 +#define TEE_ERR_EC_R_PKPARAMETERS2GROUP_FAILURE 0x8002a07f +#define TEE_ERR_EC_R_POINT_ARITHMETIC_FAILURE 0x8002a09b +#define TEE_ERR_EC_R_POINT_AT_INFINITY 0x8002a06a +#define TEE_ERR_EC_R_POINT_COORDINATES_BLIND_FAILURE 0x8002a0a3 +#define TEE_ERR_EC_R_POINT_IS_NOT_ON_CURVE 0x8002a06b +#define TEE_ERR_EC_R_RANDOM_NUMBER_GENERATION_FAILED 0x8002a09e +#define TEE_ERR_EC_R_SHARED_INFO_ERROR 0x8002a096 +#define TEE_ERR_EC_R_SLOT_FULL 0x8002a06c +#define TEE_ERR_EC_R_UNDEFINED_GENERATOR 0x8002a071 +#define TEE_ERR_EC_R_UNDEFINED_ORDER 0x8002a080 +#define TEE_ERR_EC_R_UNKNOWN_COFACTOR 0x8002a0a4 +#define TEE_ERR_EC_R_UNKNOWN_GROUP 0x8002a081 +#define TEE_ERR_EC_R_UNKNOWN_ORDER 0x8002a072 +#define TEE_ERR_EC_R_UNSUPPORTED_FIELD 0x8002a083 +#define TEE_ERR_EC_R_WRONG_CURVE_PARAMETERS 0x8002a091 +#define TEE_ERR_EC_R_WRONG_ORDER 0x8002a082 + +/* for pkcs7 lib err */ +#define TEE_ERR_PKCS7_R_CERTIFICATE_VERIFY_ERROR 0x8002b075 +#define TEE_ERR_PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 0x8002b090 +#define TEE_ERR_PKCS7_R_CIPHER_NOT_INITIALIZED 0x8002b074 +#define TEE_ERR_PKCS7_R_CONTENT_AND_DATA_PRESENT 0x8002b076 +#define TEE_ERR_PKCS7_R_CTRL_ERROR 0x8002b098 +#define TEE_ERR_PKCS7_R_DECRYPT_ERROR 0x8002b077 +#define TEE_ERR_PKCS7_R_DIGEST_FAILURE 0x8002b065 +#define TEE_ERR_PKCS7_R_ENCRYPTION_CTRL_FAILURE 0x8002b095 +#define TEE_ERR_PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 0x8002b096 +#define TEE_ERR_PKCS7_R_ERROR_ADDING_RECIPIENT 0x8002b078 +#define TEE_ERR_PKCS7_R_ERROR_SETTING_CIPHER 0x8002b079 +#define TEE_ERR_PKCS7_R_INVALID_NULL_POINTER 0x8002b08f +#define TEE_ERR_PKCS7_R_INVALID_SIGNED_DATA_TYPE 0x8002b09b +#define TEE_ERR_PKCS7_R_NO_CONTENT 0x8002b07a +#define TEE_ERR_PKCS7_R_NO_DEFAULT_DIGEST 0x8002b097 +#define TEE_ERR_PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND 0x8002b09a +#define TEE_ERR_PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 0x8002b073 +#define TEE_ERR_PKCS7_R_NO_SIGNATURES_ON_DATA 0x8002b07b +#define TEE_ERR_PKCS7_R_NO_SIGNERS 0x8002b08e +#define TEE_ERR_PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 0x8002b068 +#define TEE_ERR_PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 0x8002b07c +#define TEE_ERR_PKCS7_R_PKCS7_ADD_SIGNER_ERROR 0x8002b099 +#define TEE_ERR_PKCS7_R_PKCS7_DATASIGN 0x8002b091 +#define TEE_ERR_PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 0x8002b07f +#define TEE_ERR_PKCS7_R_SIGNATURE_FAILURE 0x8002b069 +#define TEE_ERR_PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 0x8002b080 +#define TEE_ERR_PKCS7_R_SIGNING_CTRL_FAILURE 0x8002b093 +#define TEE_ERR_PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 0x8002b094 +#define TEE_ERR_PKCS7_R_SMIME_TEXT_ERROR 0x8002b081 +#define TEE_ERR_PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 0x8002b06a +#define TEE_ERR_PKCS7_R_UNABLE_TO_FIND_MEM_BIO 0x8002b06b +#define TEE_ERR_PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 0x8002b06c +#define TEE_ERR_PKCS7_R_UNKNOWN_DIGEST_TYPE 0x8002b06d +#define TEE_ERR_PKCS7_R_UNKNOWN_OPERATION 0x8002b06e +#define TEE_ERR_PKCS7_R_UNSUPPORTED_CIPHER_TYPE 0x8002b06f +#define TEE_ERR_PKCS7_R_UNSUPPORTED_CONTENT_TYPE 0x8002b070 +#define TEE_ERR_PKCS7_R_WRONG_CONTENT_TYPE 0x8002b071 +#define TEE_ERR_PKCS7_R_WRONG_PKCS7_TYPE 0x8002b072 + +#endif \ No newline at end of file diff --git a/include/TA/huawei_ext/tee_ra_api.h b/include/TA/huawei_ext/tee_ra_api.h new file mode 100644 index 0000000..0eabd16 --- /dev/null +++ b/include/TA/huawei_ext/tee_ra_api.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS 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: API of TCMGR service. + */ +#ifndef TCMGR_SERVICE_TEE_RA_API_H +#define TCMGR_SERVICE_TEE_RA_API_H +#include +#include "qsi_data_structure.h" + +TEE_Result ra_qsi_provision(struct qsi_provision_params *provision_params); +TEE_Result ra_qsi_report(struct qsi_report_params *ra_params); +TEE_Result ra_qsi_save_akcert(struct qsi_save_akcert_params *akcert_params); +TEE_Result ra_local_report(TEE_UUID target_uuid, const struct ra_buffer_data *usr_data, + struct ra_buffer_data *param_set, struct ra_buffer_data *report, bool with_tcb); + +TEE_Result ra_seal(uint8_t *data, size_t in_size, uint8_t *cipher_data, size_t *cipher_size, uint32_t alg); +TEE_Result ra_unseal(uint8_t *cipher_data, size_t cipher_size, uint8_t *data, size_t *out_size, uint32_t alg); + +#endif diff --git a/include/TA/pthread_attr.h b/include/TA/pthread_attr.h new file mode 100644 index 0000000..9583cbd --- /dev/null +++ b/include/TA/pthread_attr.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS 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: phtread attribution declared + */ +#ifndef PTHREAD_ATTR_H +#define PTHREAD_ATTR_H + +#define TEESMP_THREAD_ATTR_CA_WILDCARD 0 +#define TEESMP_THREAD_ATTR_CA_INHERIT (-1U) +#define TEESMP_THREAD_ATTR_TASK_ID_INHERIT (-1U) +#define TEESMP_THREAD_ATTR_HAS_SHADOW 0x1 +#define TEESMP_THREAD_ATTR_NO_SHADOW 0x0 + +#endif diff --git a/include/TA/tee_arith_api.h b/include/TA/tee_arith_api.h index 76ca0b0..e456804 100755 --- a/include/TA/tee_arith_api.h +++ b/include/TA/tee_arith_api.h @@ -8,16 +8,13 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: tee crypto definitions */ #ifndef TEE_ARITH_API_H #define TEE_ARITH_API_H -#include "tee_defines.h" - -#ifndef API_LEVEL -#define API_LEVEL API_LEVEL1_0 -#endif +#include /* * below definitions are defined by Global Platform @@ -69,7 +66,7 @@ void TEE_BigIntInit(TEE_BigInt *bigInt, size_t len); */ void TEE_BigIntInitFMMContext(TEE_BigIntFMMContext *context, size_t len, const TEE_BigInt *modulus); -#if (API_LEVEL >= API_LEVEL1_1_1) +#if defined(API_LEVEL) && (API_LEVEL >= API_LEVEL1_1_1) /* * calculates the necessary prerequisites for the fast modular multiplication and stores them in a context. @@ -82,7 +79,7 @@ void TEE_BigIntInitFMMContext(TEE_BigIntFMMContext *context, size_t len, const T * @return other failed */ TEE_Result TEE_BigIntInitFMMContext1(TEE_BigIntFMMContext *context, size_t len, const TEE_BigInt *modulus); -#endif // API_LEVEL +#endif /* API_LEVEL */ /* * initializes bigIntFMM and sets its represented value to zero. @@ -194,7 +191,7 @@ bool TEE_BigIntGetBit(const TEE_BigInt *src, uint32_t bitIndex); */ uint32_t TEE_BigIntGetBitCount(const TEE_BigInt *src); -#if (API_LEVEL >= API_LEVEL1_2) +#if defined(API_LEVEL) && (API_LEVEL >= API_LEVEL1_2) /* * sets the bitIndexth bit of the natural binary representation of |op| to 1 or 0 * @@ -228,7 +225,7 @@ TEE_Result TEE_BigIntAssign(TEE_BigInt *dest, const TEE_BigInt *src); * @return #TEE_ERROR_OVERFLOW In case the dest operand cannot hold the value of |src| */ TEE_Result TEE_BigIntAbs(TEE_BigInt *dest, const TEE_BigInt *src); -#endif // API_LEVEL +#endif /* API_LEVEL */ /* * computes dest = op1 + op2 @@ -441,7 +438,7 @@ void TEE_BigIntConvertFromFMM(TEE_BigInt *dest, const TEE_BigIntFMM *src, const void TEE_BigIntComputeFMM(TEE_BigIntFMM *dest, const TEE_BigIntFMM *op1, const TEE_BigIntFMM *op2, const TEE_BigInt *n, const TEE_BigIntFMMContext *context); -#if (API_LEVEL >= API_LEVEL1_1_1) +#if defined(API_LEVEL) && (API_LEVEL >= API_LEVEL1_1_1) /* * computes dest = (op1 ^ op2) (mod n). * @@ -456,7 +453,7 @@ void TEE_BigIntComputeFMM(TEE_BigIntFMM *dest, const TEE_BigIntFMM *op1, const T */ TEE_Result TEE_BigIntExpMod(TEE_BigInt *des, TEE_BigInt *op1, const TEE_BigInt *op2, const TEE_BigInt *n, TEE_BigIntFMMContext *context); -#endif // API_LEVEL +#endif /* API_LEVEL */ /* * check whether n exists to make dest = (op1 ^ op2) (mod n). diff --git a/include/TA/tee_core_api.h b/include/TA/tee_core_api.h index c07be0b..9fd9b35 100644 --- a/include/TA/tee_core_api.h +++ b/include/TA/tee_core_api.h @@ -8,6 +8,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: tee core api definitions */ #ifndef __TEE_CORE_API_H #define __TEE_CORE_API_H @@ -79,4 +80,5 @@ bool TEE_UnmaskCancellation(void); /* not supported */ bool TEE_MaskCancellation(void); + #endif diff --git a/include/TA/tee_crypto_api.h b/include/TA/tee_crypto_api.h index c711d30..eca49c1 100644 --- a/include/TA/tee_crypto_api.h +++ b/include/TA/tee_crypto_api.h @@ -8,22 +8,22 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: tee crypto definitions */ #ifndef TEE_CRYPTO_API_H #define TEE_CRYPTO_API_H -#include "pthread.h" // pthread_mutex_t -#include "tee_defines.h" -#include "tee_mem_mgmt_api.h" +#include /* pthread_mutex_t */ +#include +#include #ifndef NULL #define NULL ((void *)0) #endif -#define TEE_MAX_KEY_SIZE_IN_BITS (1024 * 8) - -#define SW_RSA_KEYLEN 1024 +#define TEE_MAX_KEY_SIZE_IN_BITS (1024 * 8) +#define SW_RSA_KEYLEN 1024 #define TEE_DH_MAX_SIZE_OF_OTHER_INFO 64 /* bytes */ enum __TEE_Operation_Constants { @@ -82,54 +82,58 @@ enum __tee_crypto_algorithm_id { TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384 = 0x60213230, TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512 = 0x60214230, #endif - TEE_ALG_RSA_NOPAD = 0x60000030, - TEE_ALG_DSA_SHA1 = 0x70002131, - TEE_ALG_DSA_SHA224 = 0x70003131, - TEE_ALG_DSA_SHA256 = 0x70004131, - TEE_ALG_DH_DERIVE_SHARED_SECRET = 0x80000032, - TEE_ALG_MD5 = 0x50000001, - TEE_ALG_SHA1 = 0x50000002, - TEE_ALG_SHA224 = 0x50000003, - TEE_ALG_SHA256 = 0x50000004, - TEE_ALG_SHA384 = 0x50000005, - TEE_ALG_SHA512 = 0x50000006, - TEE_ALG_HMAC_MD5 = 0x30000001, - TEE_ALG_HMAC_SHA1 = 0x30000002, - TEE_ALG_HMAC_SHA224 = 0x30000003, - TEE_ALG_HMAC_SHA256 = 0x30000004, - TEE_ALG_HMAC_SHA384 = 0x30000005, - TEE_ALG_HMAC_SHA512 = 0x30000006, - TEE_ALG_HMAC_SM3 = 0x30000007, - TEE_ALG_AES_ECB_PKCS5 = 0x10000020, - TEE_ALG_AES_CBC_PKCS5 = 0x10000220, - TEE_ALG_ECDSA_SHA1 = 0x70001042, - TEE_ALG_ECDSA_SHA224 = 0x70002042, - TEE_ALG_ECDSA_SHA256 = 0x70003042, - TEE_ALG_ECDSA_SHA384 = 0x70004042, - TEE_ALG_ECDSA_SHA512 = 0x70005042, - TEE_ALG_ED25519 = 0x70005043, - TEE_ALG_ECDH_DERIVE_SHARED_SECRET = 0x80000042, - TEE_ALG_X25519 = 0x80000044, - TEE_ALG_ECC = 0x80000001, - TEE_ALG_ECDSA_P192 = 0x70001042, - TEE_ALG_ECDSA_P224 = 0x70002042, - TEE_ALG_ECDSA_P256 = 0x70003042, - TEE_ALG_ECDSA_P384 = 0x70004042, - TEE_ALG_ECDSA_P521 = 0x70005042, - TEE_ALG_ECDH_P192 = 0x80001042, - TEE_ALG_ECDH_P224 = 0x80002042, - TEE_ALG_ECDH_P256 = 0x80003042, - TEE_ALG_ECDH_P384 = 0x80004042, - TEE_ALG_ECDH_P521 = 0x80005042, - TEE_ALG_SM2_DSA_SM3 = 0x70006045, - TEE_ALG_SM2_PKE = 0x80000045, - TEE_ALG_SM3 = 0x50000007, - TEE_ALG_SM4_ECB_NOPAD = 0x10000014, - TEE_ALG_SM4_CBC_NOPAD = 0x10000114, - TEE_ALG_SM4_CTR = 0x10000214, - TEE_ALG_SM4_XTS = 0x10000414, - TEE_ALG_SM4_OFB = 0x10000514, - TEE_ALG_AES_OFB = 0x10000510, + TEE_ALG_RSA_NOPAD = 0x60000030, + TEE_ALG_DSA_SHA1 = 0x70002131, + TEE_ALG_DSA_SHA224 = 0x70003131, + TEE_ALG_DSA_SHA256 = 0x70004131, + TEE_ALG_DH_DERIVE_SHARED_SECRET = 0x80000032, + TEE_ALG_MD5 = 0x50000001, + TEE_ALG_SHA1 = 0x50000002, + TEE_ALG_SHA224 = 0x50000003, + TEE_ALG_SHA256 = 0x50000004, + TEE_ALG_SHA384 = 0x50000005, + TEE_ALG_SHA512 = 0x50000006, + TEE_ALG_HMAC_MD5 = 0x30000001, + TEE_ALG_HMAC_SHA1 = 0x30000002, + TEE_ALG_HMAC_SHA224 = 0x30000003, + TEE_ALG_HMAC_SHA256 = 0x30000004, + TEE_ALG_HMAC_SHA384 = 0x30000005, + TEE_ALG_HMAC_SHA512 = 0x30000006, + TEE_ALG_HMAC_SM3 = 0x30000007, + TEE_ALG_AES_ECB_PKCS5 = 0x10000020, + TEE_ALG_AES_CBC_PKCS5 = 0x10000220, + TEE_ALG_ECDSA_SHA1 = 0x70001042, + TEE_ALG_ECDSA_SHA224 = 0x70002042, + TEE_ALG_ECDSA_SHA256 = 0x70003042, + TEE_ALG_ECDSA_SHA384 = 0x70004042, + TEE_ALG_ECDSA_SHA512 = 0x70005042, + TEE_ALG_ED25519 = 0x70005043, + TEE_ALG_ECDH_DERIVE_SHARED_SECRET = 0x80000042, + TEE_ALG_X25519 = 0x80000044, + TEE_ALG_ECC = 0x80000001, + TEE_ALG_ECDSA_P192 = 0x70001042, + TEE_ALG_ECDSA_P224 = 0x70002042, + TEE_ALG_ECDSA_P256 = 0x70003042, + TEE_ALG_ECDSA_P384 = 0x70004042, + TEE_ALG_ECDSA_P521 = 0x70005042, + TEE_ALG_ECDH_P192 = 0x80001042, + TEE_ALG_ECDH_P224 = 0x80002042, + TEE_ALG_ECDH_P256 = 0x80003042, + TEE_ALG_ECDH_P384 = 0x80004042, + TEE_ALG_ECDH_P521 = 0x80005042, + TEE_ALG_SIP_HASH = 0xF0000002, + TEE_ALG_SM2_DSA_SM3 = 0x70006045, + TEE_ALG_SM2_PKE = 0x80000045, + TEE_ALG_SM3 = 0x50000007, + TEE_ALG_SM4_ECB_NOPAD = 0x10000014, + TEE_ALG_SM4_CBC_NOPAD = 0x10000114, + TEE_ALG_SM4_CBC_PKCS7 = 0xF0000003, + TEE_ALG_SM4_CTR = 0x10000214, + TEE_ALG_SM4_CFB128 = 0xF0000000, + TEE_ALG_SM4_XTS = 0x10000414, + TEE_ALG_SM4_OFB = 0x10000514, + TEE_ALG_AES_OFB = 0x10000510, + TEE_ALG_SM4_GCM = 0xF0000005, }; typedef enum __tee_crypto_algorithm_id tee_crypto_algorithm_id; @@ -162,13 +166,13 @@ typedef enum { } TEE_DH_OpMode_t; typedef enum { - TEE_DH_ASN1_DerivMode = 0, /* *< ASN1_DerivMode */ - TEE_DH_ConcatDerivMode = 1, /* *< ConcatDerivMode */ - TEE_DH_X963_DerivMode = TEE_DH_ConcatDerivMode, /* *< X963_DerivMode */ - TEE_DH_OMADRM_DerivMode = 2, /* *< OMADRM_DerivMode */ - TEE_DH_ISO18033_KDF1_DerivMode = 3, /* *< ISO18033_KDF1_DerivMode */ - TEE_DH_ISO18033_KDF2_DerivMode = 4, /* *< ISO18033_KDF2_DerivMode */ - TEE_DH_DerivFunc_NumOfModes, /* *< num of modes */ + TEE_DH_ASN1_DerivMode = 0, /* ASN1_DerivMode */ + TEE_DH_ConcatDerivMode = 1, /* ConcatDerivMode */ + TEE_DH_X963_DerivMode = TEE_DH_ConcatDerivMode, /* X963_DerivMode */ + TEE_DH_OMADRM_DerivMode = 2, /* OMADRM_DerivMode */ + TEE_DH_ISO18033_KDF1_DerivMode = 3, /* ISO18033_KDF1_DerivMode */ + TEE_DH_ISO18033_KDF2_DerivMode = 4, /* ISO18033_KDF2_DerivMode */ + TEE_DH_DerivFunc_NumOfModes, /* num of modes */ } TEE_DH_DerivFuncMode; enum __TEE_DK_ObjectAttribute { @@ -242,9 +246,9 @@ typedef struct { } TEE_OperationInfoMultiple; struct __TEE_OperationHandle { - uint32_t algorithm; /* *< #__TEE_CRYPTO_ALGORITHM_ID */ - uint32_t operationClass; /* *< #__TEE_Operation_Constants */ - uint32_t mode; /* *< #__TEE_OperationMode */ + uint32_t algorithm; /* #__TEE_CRYPTO_ALGORITHM_ID */ + uint32_t operationClass; /* #__TEE_Operation_Constants */ + uint32_t mode; /* #__TEE_OperationMode */ uint32_t digestLength; uint32_t maxKeySize; uint32_t keySize; @@ -261,12 +265,12 @@ struct __TEE_OperationHandle { void *privateKey; uint32_t privateKeyLen; uint32_t IVLen; - // start of DH + /* start of DH */ TEE_DH_OtherInfo *dh_otherinfo; /* #TEE_DH_OtherInfo */ uint32_t dh_hash_mode; /* #TEE_DH_HASH_Mode */ uint32_t dh_derive_func; /* #TEE_DH_DerivFuncMode */ uint32_t dh_op_mode; /* #TEE_DH_OpMode_t */ - // end of DH + /* end of DH */ pthread_mutex_t operation_lock; void *hal_info; }; @@ -430,11 +434,11 @@ TEE_Result TEE_CipherDoFinal(TEE_OperationHandle operation, const void *srcData, */ #ifndef GP_SUPPORT -#if (API_LEVEL >= 2) +#if defined(API_LEVEL) && (API_LEVEL >= 2) void TEE_DigestUpdate(TEE_OperationHandle operation, const void *chunk, size_t chunkSize); #else TEE_Result TEE_DigestUpdate(TEE_OperationHandle operation, const void *chunk, size_t chunkSize); -#endif // API_LEVEL +#endif /* API_LEVEL */ #else void TEE_DigestUpdate(TEE_OperationHandle operation, const void *chunk, size_t chunkSize); @@ -506,13 +510,13 @@ TEE_Result TEE_MACComputeFinal(TEE_OperationHandle operation, const void *messag */ #ifndef GP_SUPPORT -#if (API_LEVEL >= 2) +#if defined(API_LEVEL) && (API_LEVEL >= 2) TEE_Result TEE_MACCompareFinal(TEE_OperationHandle operation, const void *message, size_t messageLen, const void *mac, const size_t macLen); #else TEE_Result TEE_MACCompareFinal(TEE_OperationHandle operation, const void *message, size_t messageLen, const void *mac, const size_t *macLen); -#endif // API_LEVEL +#endif /* API_LEVEL */ #else TEE_Result TEE_MACCompareFinal(TEE_OperationHandle operation, const void *message, size_t messageLen, const void *mac, @@ -687,7 +691,7 @@ TEE_Result TEE_AsymmetricSignDigest(TEE_OperationHandle operation, const TEE_Att TEE_Result TEE_AsymmetricVerifyDigest(TEE_OperationHandle operation, const TEE_Attribute *params, uint32_t paramCount, void *digest, size_t digestLen, void *signature, size_t signatureLen); -#if (API_LEVEL >= 2) +#if defined(API_LEVEL) && (API_LEVEL >= 2) /* * Get Operation Info multiple @@ -702,9 +706,9 @@ TEE_Result TEE_AsymmetricVerifyDigest(TEE_OperationHandle operation, const TEE_A */ TEE_Result TEE_GetOperationInfoMultiple(TEE_OperationHandle operation, TEE_OperationInfoMultiple *operationInfoMultiple, const size_t *operationSize); -#endif // API_LEVEL +#endif /* API_LEVEL */ -#if (API_LEVEL >= 3) +#if defined(API_LEVEL) && (API_LEVEL >= 2) /* * check whether the algorithm is sopported @@ -716,6 +720,8 @@ TEE_Result TEE_GetOperationInfoMultiple(TEE_OperationHandle operation, TEE_Opera * @return TEE_ERROR_NOT_SUPPORTED not support */ TEE_Result TEE_IsAlgorithmSupported(uint32_t algId, uint32_t element); -#endif // API_LEVEL + +TEE_Result TEE_IsHardWareSupportAlgorithm(uint32_t alg_type); +#endif /* API_LEVEL */ #endif diff --git a/include/TA/tee_defines.h b/include/TA/tee_defines.h index 8289c07..7d77c32 100755 --- a/include/TA/tee_defines.h +++ b/include/TA/tee_defines.h @@ -8,6 +8,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: Reference of TEE internal api and internal definitions */ #ifndef __TEE_DEFINES_H @@ -16,6 +17,7 @@ #include #include #include +#include #ifndef TA_EXPORT #define TA_EXPORT @@ -28,17 +30,8 @@ typedef int *tee_mutex_handle; #define API_LEVEL1_2 3 #define TEE_PARAMS_NUM 4 -#undef true -#define true 1 -#undef false -#define false 0 - -#ifndef NULL -#define NULL ((void *)0) -#endif - -#define PARAM_NOT_USED(val) ((void)val) +#define PARAM_NOT_USED(val) ((void)(val)) typedef union { struct { @@ -84,6 +77,10 @@ enum TEE_ParamType { TEE_PARAM_TYPE_MEMREF_INOUT = 0x7, TEE_PARAM_TYPE_ION_INPUT = 0x8, TEE_PARAM_TYPE_ION_SGLIST_INPUT = 0x9, + TEE_PARAM_TYPE_MEMREF_SHARED_INOUT = 0xa, + TEE_PARAM_TYPE_RESMEM_INPUT = 0xc, + TEE_PARAM_TYPE_RESMEM_OUTPUT = 0xd, + TEE_PARAM_TYPE_RESMEM_INOUT = 0xe, }; #define S_VAR_NOT_USED(variable) \ @@ -149,6 +146,9 @@ enum TEE_ObjectAttribute { TEE_ATTR_ED25519_PH = 0xF0000543, TEE_ATTR_X25519_PUBLIC_VALUE = 0xD0000944, TEE_ATTR_X25519_PRIVATE_VALUE = 0xC0000A44, + TEE_ATTR_PBKDF2_HMAC_PASSWORD = 0xD0000133, + TEE_ATTR_PBKDF2_HMAC_SALT = 0xD0000134, + TEE_ATTR_PBKDF2_HMAC_DIGEST = 0xF0000135, }; enum TEE_ObjectType { @@ -185,6 +185,8 @@ enum TEE_ObjectType { TEE_TYPE_SM2_PKE_KEYPAIR = 0xA1000047, TEE_TYPE_HMAC_SM3 = 0xA0000007, TEE_TYPE_SM4 = 0xA0000014, + TEE_TYPE_SIP_HASH = 0xF0000002, + TEE_TYPE_PBKDF2_HMAC = 0xF0000004, TEE_TYPE_CORRUPTED_OBJECT = 0xA00000BE, }; @@ -205,130 +207,115 @@ struct __TEE_ObjectHandle { }; typedef struct __TEE_ObjectHandle *TEE_ObjectHandle; -#define NODE_LEN 8 -typedef struct tee_uuid { - uint32_t timeLow; - uint16_t timeMid; - uint16_t timeHiAndVersion; - uint8_t clockSeqAndNode[NODE_LEN]; -} TEE_UUID; - -typedef struct spawn_uuid { - uint64_t uuid_valid; - TEE_UUID uuid; -} spawn_uuid_t; - enum TEE_Result_Value { - TEE_SUCCESS = 0x0, /* success */ - TEE_ERROR_INVALID_CMD, /* command is invalid */ - TEE_ERROR_SERVICE_NOT_EXIST, /* service is not exist */ - TEE_ERROR_SESSION_NOT_EXIST, /* session is not exist */ - TEE_ERROR_SESSION_MAXIMUM, /* exceeds max session count */ - TEE_ERROR_REGISTER_EXIST_SERVICE, /* service already registered */ - TEE_ERROR_TARGET_DEAD_FATAL, /* internal error occurs */ - TEE_ERROR_READ_DATA, /* read data failed */ - TEE_ERROR_WRITE_DATA, /* write data failed */ - TEE_ERROR_TRUNCATE_OBJECT, /* truncate data failed */ - TEE_ERROR_SEEK_DATA, /* seek data failed */ - TEE_ERROR_SYNC_DATA, /* sync data failed */ - TEE_ERROR_RENAME_OBJECT, /* rename file failed */ - TEE_ERROR_TRUSTED_APP_LOAD_ERROR, /* error occurs when loading TA */ - TEE_ERROR_OTRP_LOAD_NOT_MATCHED = 0x80000100, /* TA type is inconsistent with the loading mode. */ - TEE_ERROR_OTRP_LOAD_EXCEED = 0x80000101, /* the not open session's otrp service num exceeds */ - TEE_ERROR_OTRP_ACCESS_DENIED = 0x80000102, /* uuid of load cmd is not inconsistent with the sec file */ - TEE_ERROR_OTRP_SERVICE_AGED = 0x80000103, /* otrp service is aged */ - TEE_ERROR_STORAGE_EIO = 0x80001001, /* I/O error occurs in storage operation */ - TEE_ERROR_STORAGE_EAGAIN = 0x80001002, /* storage section is unavailable */ - TEE_ERROR_STORAGE_ENOTDIR = 0x80001003, /* operation target is not directory */ - TEE_ERROR_STORAGE_EISDIR = 0x80001004, /* cannot do this operation on directory */ - TEE_ERROR_STORAGE_ENFILE = 0x80001005, /* opened files exceed max count in system */ - TEE_ERROR_STORAGE_EMFILE = 0x80001006, /* opened files exceed max count for this process */ - TEE_ERROR_STORAGE_EROFS = 0x80001007, /* stroage section is read only */ - TEE_ERROR_STORAGE_INSE_NOTSUPPORT = 0x80001008, /* SFS inse mode is not supported */ - TEE_ERROR_STORAGE_INSE_ERROR = 0x80001009, /* SFS inse encrypto/decrypto error occurs */ - TEE_ERROR_STORAGE_PATH_WRONG = 0x8000100A, /* File path error */ - TEE_ERROR_MSG_QUEUE_OVERFLOW = 0x8000100B, /* sevice msg queue overflow */ - TEE_ERROR_CORRUPT_OBJECT = 0xF0100001, /* file object has been damaged */ - TEE_ERROR_STORAGE_NOT_AVAILABLE = 0xF0100003, /* storage section is unavailable */ - TEE_ERROR_CIPHERTEXT_INVALID = 0xF0100006, /* cipher text is incorrect */ - TEE_ISOCKET_ERROR_PROTOCOL = 0xF1007001, /* protocol error in socket connection */ - TEE_ISOCKET_ERROR_REMOTE_CLOSED = 0xF1007002, /* socket is closed by remote */ - TEE_ISOCKET_ERROR_TIMEOUT = 0xF1007003, /* socket connection is timeout */ - TEE_ISOCKET_ERROR_OUT_OF_RESOURCES = 0xF1007004, /* no resource avaliable for socket connection */ - TEE_ISOCKET_ERROR_LARGE_BUFFER = 0xF1007005, /* buffer is too large in socket connection */ - TEE_ISOCKET_WARNING_PROTOCOL = 0xF1007006, /* warnning occurs in socket connection */ - TEE_ERROR_GENERIC = 0xFFFF0000, /* generic error */ - TEE_ERROR_ACCESS_DENIED = 0xFFFF0001, /* access is denied */ - TEE_ERROR_CANCEL = 0xFFFF0002, /* operation has been canceled */ - TEE_ERROR_ACCESS_CONFLICT = 0xFFFF0003, /* conflict access error occurs */ - TEE_ERROR_EXCESS_DATA = 0xFFFF0004, /* exceeds max data size */ - TEE_ERROR_BAD_FORMAT = 0xFFFF0005, /* incorrect data format */ - TEE_ERROR_BAD_PARAMETERS = 0xFFFF0006, /* incorrect parameters */ - TEE_ERROR_BAD_STATE = 0xFFFF0007, /* operation is not allowed in current state */ - TEE_ERROR_ITEM_NOT_FOUND = 0xFFFF0008, /* cannot find target item */ - TEE_ERROR_NOT_IMPLEMENTED = 0xFFFF0009, /* api is not implemented */ - TEE_ERROR_NOT_SUPPORTED = 0xFFFF000A, /* api is not supported */ - TEE_ERROR_NO_DATA = 0xFFFF000B, /* no data avaliable for this operation */ - TEE_ERROR_OUT_OF_MEMORY = 0xFFFF000C, /* not memory avaliable for this operation */ - TEE_ERROR_BUSY = 0xFFFF000D, /* system busy to handle this operation */ - TEE_ERROR_COMMUNICATION = 0xFFFF000E, /* communication error with target */ - TEE_ERROR_SECURITY = 0xFFFF000F, /* security error occurs */ - TEE_ERROR_SHORT_BUFFER = 0xFFFF0010, /* buffer is too short for this operation */ - TEE_ERROR_EXTERNAL_CANCEL = 0xFFFF0011, /* operation is canceled */ - TEE_PENDING = 0xFFFF2000, /* service is in pending state(in asynchronous state) */ - TEE_PENDING2 = 0xFFFF2001, /* service is in pending state() */ - TEE_PENDING3 = 0xFFFF2002, /* reserved error definition */ - TEE_ERROR_TIMEOUT = 0xFFFF3001, /* operation is timeout */ - TEE_ERROR_OVERFLOW = 0xFFFF300f, /* operation overflow */ - TEE_ERROR_TARGET_DEAD = 0xFFFF3024, /* TA is crashed */ - TEE_ERROR_STORAGE_NO_SPACE = 0xFFFF3041, /* no enough space to store data */ - TEE_ERROR_MAC_INVALID = 0xFFFF3071, /* MAC operation failed */ - TEE_ERROR_SIGNATURE_INVALID = 0xFFFF3072, /* signature check failed */ - TEE_CLIENT_INTR = 0xFFFF4000, /* Interrupted by CFC. Broken control flow is detected. */ - TEE_ERROR_TIME_NOT_SET = 0xFFFF5000, /* time is not set */ - TEE_ERROR_TIME_NEEDS_RESET = 0xFFFF5001, /* time need to be reset */ - TEE_FAIL = 0xFFFF5002, /* system error */ - TEE_ERROR_TIMER = 0xFFFF6000, /* base value of timer error codes */ - TEE_ERROR_TIMER_CREATE_FAILED, /* failed to create timer */ - TEE_ERROR_TIMER_DESTORY_FAILED, /* failed to destory timer */ - TEE_ERROR_TIMER_NOT_FOUND, /* timer not found */ - TEE_ERROR_RPMB_BASE = 0xFFFF7000, /* base value of RPMB error codes */ - TEE_ERROR_RPMB_GENERIC = 0xFFFF7001, /* generic error of RPMB operations */ - TEE_ERROR_RPMB_MAC_FAIL, /* verify MAC failed in RPMB operations */ - TEE_ERROR_RPMB_COUNTER_FAIL, /* invalid counter in RPMB operations */ - TEE_ERROR_RPMB_ADDR_FAIL, /* addresss check failed in RPMB operations */ - TEE_ERROR_RPMB_WRITE_FAIL, /* failed to write data to RPMB */ - TEE_ERROR_RPMB_READ_FAIL, /* failed to read data in RPMB */ - TEE_ERROR_RPMB_KEY_NOT_PROGRAM, /* key is not provisioned in RPMB */ - TEE_ERROR_RPMB_RESP_UNEXPECT_MSGTYPE = 0xFFFF7100, /* incorrect message type in RPMB response */ - TEE_ERROR_RPMB_RESP_UNEXPECT_BLKCNT, /* incorrect message data block count in RPMB response */ - TEE_ERROR_RPMB_RESP_UNEXPECT_BLKIDX, /* incorrect message data block index in RPMB response */ - TEE_ERROR_RPMB_RESP_UNEXPECT_WRCNT, /* incorrect message data counter in RPMB response */ - TEE_ERROR_RPMB_RESP_UNEXPECT_NONCE, /* incorrect message data nonce in RPMB response */ - TEE_ERROR_RPMB_RESP_UNEXPECT_MAC, /* incorrect message data MAC in RPMB response */ - TEE_ERROR_RPMB_FILE_NOT_FOUND, /* file not found in RPMB */ - TEE_ERROR_RPMB_NOSPC, /* not space left for RPMB operations */ - TEE_ERROR_RPMB_SPC_CONFLICT, /* exceeds max space of RPMB for this TA */ - TEE_ERROR_RPMB_NOT_AVAILABLE, /* RPMB service not ready */ - TEE_ERROR_RPMB_DAMAGED, /* RPMB partition is damaged */ - TEE_ERROR_TUI_IN_USE = 0xFFFF7110, - TEE_ERROR_TUI_SWITCH_CHANNAL, - TEE_ERROR_TUI_CFG_DRIVER, - TEE_ERROR_TUI_INVALID_EVENT, - TEE_ERROR_TUI_POLL_EVENT, - TEE_ERROR_TUI_CANCELED, - TEE_ERROR_TUI_EXIT, - TEE_ERROR_TUI_NOT_AVAILABLE, - TEE_ERROR_SEC_FLASH_NOT_AVAILABLE, - TEE_ERROR_SESRV_NOT_AVAILABLE, - TEE_ERROR_BIOSRV_NOT_AVAILABLE, - TEE_ERROR_ROTSRV_NOT_AVAILABLE, - TEE_ERROR_ARTSRV_NOT_AVAILABLE, - TEE_ERROR_HSMSRV_NOT_AVAILABLE, - TEE_ERROR_ANTIROOT_RSP_FAIL = 0xFFFF9110, - TEE_ERROR_ANTIROOT_INVOKE_ERROR = 0xFFFF9111, - TEE_ERROR_AUDIT_FAIL = 0xFFFF9112, - TEE_FAIL2 + TEE_SUCCESS = 0x00000000, /* success */ + TEE_ERROR_INVALID_CMD = 0x00000001, /* command is invalid */ + TEE_ERROR_SERVICE_NOT_EXIST = 0x00000002, /* service is not exist */ + TEE_ERROR_SESSION_NOT_EXIST = 0x00000003, /* session is not exist */ + TEE_ERROR_SESSION_MAXIMUM = 0x00000004, /* exceeds max session count */ + TEE_ERROR_REGISTER_EXIST_SERVICE = 0x00000005, /* service already registered */ + TEE_ERROR_TARGET_DEAD_FATAL = 0x00000006, /* internal error occurs */ + TEE_ERROR_READ_DATA = 0x00000007, /* read data failed */ + TEE_ERROR_WRITE_DATA = 0x00000008, /* write data failed */ + TEE_ERROR_TRUNCATE_OBJECT = 0x00000009, /* truncate data failed */ + TEE_ERROR_SEEK_DATA = 0x0000000A, /* seek data failed */ + TEE_ERROR_SYNC_DATA = 0x0000000B, /* sync data failed */ + TEE_ERROR_RENAME_OBJECT = 0x0000000C, /* rename file failed */ + TEE_ERROR_TRUSTED_APP_LOAD_ERROR = 0x0000000D, /* error occurs when loading TA */ + TEE_ERROR_OTRP_LOAD_NOT_MATCHED = 0x80000100, /* TA type is inconsistent with the loading mode. */ + TEE_ERROR_OTRP_LOAD_EXCEED = 0x80000101, /* the not open session's otrp service num exceeds */ + TEE_ERROR_OTRP_ACCESS_DENIED = 0x80000102, /* uuid of load cmd is not inconsistent with the sec file */ + TEE_ERROR_OTRP_SERVICE_AGED = 0x80000103, /* otrp service is aged */ + TEE_ERROR_STORAGE_EIO = 0x80001001, /* I/O error occurs in storage operation */ + TEE_ERROR_STORAGE_EAGAIN = 0x80001002, /* storage section is unavailable */ + TEE_ERROR_STORAGE_ENOTDIR = 0x80001003, /* operation target is not directory */ + TEE_ERROR_STORAGE_EISDIR = 0x80001004, /* cannot do this operation on directory */ + TEE_ERROR_STORAGE_ENFILE = 0x80001005, /* opened files exceed max count in system */ + TEE_ERROR_STORAGE_EMFILE = 0x80001006, /* opened files exceed max count for this process */ + TEE_ERROR_STORAGE_EROFS = 0x80001007, /* stroage section is read only */ + TEE_ERROR_STORAGE_PATH_WRONG = 0x8000100A, /* File path error */ + TEE_ERROR_MSG_QUEUE_OVERFLOW = 0x8000100B, /* sevice msg queue overflow */ + TEE_ERROR_CORRUPT_OBJECT = 0xF0100001, /* file object has been damaged */ + TEE_ERROR_STORAGE_NOT_AVAILABLE = 0xF0100003, /* storage section is unavailable */ + TEE_ERROR_CIPHERTEXT_INVALID = 0xF0100006, /* cipher text is incorrect */ + TEE_ISOCKET_ERROR_PROTOCOL = 0xF1007001, /* protocol error in socket connection */ + TEE_ISOCKET_ERROR_REMOTE_CLOSED = 0xF1007002, /* socket is closed by remote */ + TEE_ISOCKET_ERROR_TIMEOUT = 0xF1007003, /* socket connection is timeout */ + TEE_ISOCKET_ERROR_OUT_OF_RESOURCES = 0xF1007004, /* no resource avaliable for socket connection */ + TEE_ISOCKET_ERROR_LARGE_BUFFER = 0xF1007005, /* buffer is too large in socket connection */ + TEE_ISOCKET_WARNING_PROTOCOL = 0xF1007006, /* warnning occurs in socket connection */ + TEE_ERROR_GENERIC = 0xFFFF0000, /* generic error */ + TEE_ERROR_ACCESS_DENIED = 0xFFFF0001, /* access is denied */ + TEE_ERROR_CANCEL = 0xFFFF0002, /* operation has been canceled */ + TEE_ERROR_ACCESS_CONFLICT = 0xFFFF0003, /* conflict access error occurs */ + TEE_ERROR_EXCESS_DATA = 0xFFFF0004, /* exceeds max data size */ + TEE_ERROR_BAD_FORMAT = 0xFFFF0005, /* incorrect data format */ + TEE_ERROR_BAD_PARAMETERS = 0xFFFF0006, /* incorrect parameters */ + TEE_ERROR_BAD_STATE = 0xFFFF0007, /* operation is not allowed in current state */ + TEE_ERROR_ITEM_NOT_FOUND = 0xFFFF0008, /* cannot find target item */ + TEE_ERROR_NOT_IMPLEMENTED = 0xFFFF0009, /* api is not implemented */ + TEE_ERROR_NOT_SUPPORTED = 0xFFFF000A, /* api is not supported */ + TEE_ERROR_NO_DATA = 0xFFFF000B, /* no data avaliable for this operation */ + TEE_ERROR_OUT_OF_MEMORY = 0xFFFF000C, /* not memory avaliable for this operation */ + TEE_ERROR_BUSY = 0xFFFF000D, /* system busy to handle this operation */ + TEE_ERROR_COMMUNICATION = 0xFFFF000E, /* communication error with target */ + TEE_ERROR_SECURITY = 0xFFFF000F, /* security error occurs */ + TEE_ERROR_SHORT_BUFFER = 0xFFFF0010, /* buffer is too short for this operation */ + TEE_ERROR_EXTERNAL_CANCEL = 0xFFFF0011, /* operation is canceled */ + TEE_PENDING = 0xFFFF2000, /* service is in pending state(in asynchronous state) */ + TEE_PENDING2 = 0xFFFF2001, /* service is in pending state() */ + TEE_PENDING3 = 0xFFFF2002, /* reserved error definition */ + TEE_ERROR_TIMEOUT = 0xFFFF3001, /* operation is timeout */ + TEE_ERROR_OVERFLOW = 0xFFFF300f, /* operation overflow */ + TEE_ERROR_TARGET_DEAD = 0xFFFF3024, /* TA is crashed */ + TEE_ERROR_STORAGE_NO_SPACE = 0xFFFF3041, /* no enough space to store data */ + TEE_ERROR_MAC_INVALID = 0xFFFF3071, /* MAC operation failed */ + TEE_ERROR_SIGNATURE_INVALID = 0xFFFF3072, /* signature check failed */ + TEE_CLIENT_INTR = 0xFFFF4000, /* Interrupted by CFC. Broken control flow is detected. */ + TEE_ERROR_TIME_NOT_SET = 0xFFFF5000, /* time is not set */ + TEE_ERROR_TIME_NEEDS_RESET = 0xFFFF5001, /* time need to be reset */ + TEE_FAIL = 0xFFFF5002, /* system error */ + TEE_ERROR_TIMER = 0xFFFF6000, /* base value of timer error codes */ + TEE_ERROR_TIMER_CREATE_FAILED = 0xFFFF6001, /* failed to create timer */ + TEE_ERROR_TIMER_DESTORY_FAILED = 0xFFFF6002, /* failed to destory timer */ + TEE_ERROR_TIMER_NOT_FOUND = 0xFFFF6003, /* timer not found */ + TEE_ERROR_RPMB_BASE = 0xFFFF7000, /* base value of RPMB error codes */ + TEE_ERROR_RPMB_GENERIC = 0xFFFF7001, /* generic error of RPMB operations */ + TEE_ERROR_RPMB_MAC_FAIL = 0xFFFF7002, /* verify MAC failed in RPMB operations */ + TEE_ERROR_RPMB_COUNTER_FAIL = 0xFFFF7003, /* invalid counter in RPMB operations */ + TEE_ERROR_RPMB_ADDR_FAIL = 0xFFFF7004, /* addresss check failed in RPMB operations */ + TEE_ERROR_RPMB_WRITE_FAIL = 0xFFFF7005, /* failed to write data to RPMB */ + TEE_ERROR_RPMB_READ_FAIL = 0xFFFF7006, /* failed to read data in RPMB */ + TEE_ERROR_RPMB_KEY_NOT_PROGRAM = 0xFFFF7007, /* key is not provisioned in RPMB */ + TEE_ERROR_RPMB_RESP_UNEXPECT_MSGTYPE = 0xFFFF7100, /* incorrect message type in RPMB response */ + TEE_ERROR_RPMB_RESP_UNEXPECT_BLKCNT = 0xFFFF7101, /* incorrect message data block count in RPMB response */ + TEE_ERROR_RPMB_RESP_UNEXPECT_BLKIDX = 0xFFFF7102, /* incorrect message data block index in RPMB response */ + TEE_ERROR_RPMB_RESP_UNEXPECT_WRCNT = 0xFFFF7103, /* incorrect message data counter in RPMB response */ + TEE_ERROR_RPMB_RESP_UNEXPECT_NONCE = 0xFFFF7104, /* incorrect message data nonce in RPMB response */ + TEE_ERROR_RPMB_RESP_UNEXPECT_MAC = 0xFFFF7105, /* incorrect message data MAC in RPMB response */ + TEE_ERROR_RPMB_FILE_NOT_FOUND = 0xFFFF7106, /* file not found in RPMB */ + TEE_ERROR_RPMB_NOSPC = 0xFFFF7107, /* not space left for RPMB operations */ + TEE_ERROR_RPMB_SPC_CONFLICT = 0xFFFF7108, /* exceeds max space of RPMB for this TA */ + TEE_ERROR_RPMB_NOT_AVAILABLE = 0xFFFF7109, /* RPMB service not ready */ + TEE_ERROR_RPMB_DAMAGED = 0xFFFF710A, /* RPMB partition is damaged */ + TEE_ERROR_TUI_IN_USE = 0xFFFF7110, /* TUI is being used */ + TEE_ERROR_TUI_SWITCH_CHANNAL = 0xFFFF7111, /* incorrect message switch channal in TUI response */ + TEE_ERROR_TUI_CFG_DRIVER = 0xFFFF7112, /* incorrect message configurator driver in TUI response */ + TEE_ERROR_TUI_INVALID_EVENT = 0xFFFF7113, /* invalid TUI event */ + TEE_ERROR_TUI_POLL_EVENT = 0xFFFF7114, /* incorrect message polling events in TUI response */ + TEE_ERROR_TUI_CANCELED = 0xFFFF7115, /* TUI is cancelled */ + TEE_ERROR_TUI_EXIT = 0xFFFF7116, /* TUI is exited */ + TEE_ERROR_TUI_NOT_AVAILABLE = 0xFFFF7117, /* TUI unavailable */ + TEE_ERROR_SEC_FLASH_NOT_AVAILABLE = 0xFFFF7118, /* sec flash is not available */ + TEE_ERROR_SESRV_NOT_AVAILABLE = 0xFFFF7119, /* SE service has crashed or not enabled */ + TEE_ERROR_BIOSRV_NOT_AVAILABLE = 0xFFFF711A, /* BIO service is not available */ + TEE_ERROR_ROTSRV_NOT_AVAILABLE = 0xFFFF711B, /* ROT service is not available */ + TEE_ERROR_ARTSRV_NOT_AVAILABLE = 0xFFFF711C, /* ART service is not available */ + TEE_ERROR_HSMSRV_NOT_AVAILABLE = 0xFFFF711D, /* HSM service is not available */ + TEE_ERROR_ANTIROOT_RSP_FAIL = 0xFFFF9110, /* AntiRoot Response verify failed */ + TEE_ERROR_ANTIROOT_INVOKE_ERROR = 0xFFFF9111, /* AntiRoot ERROR during invokecmd */ + TEE_ERROR_AUDIT_FAIL = 0xFFFF9112, /* audit failed */ + TEE_FAIL2 = 0xFFFF9113 /* unused */ }; /* @@ -342,6 +329,7 @@ enum TEE_LoginMethod { TEE_LOGIN_USER_APPLICATION = 0x5, TEE_LOGIN_GROUP_APPLICATION = 0x6, TEE_LOGIN_IDENTIFY = 0x7, /* iTrustee defined Lognin type */ + TEEK_LOGIN_IDENTIFY = 0x80000001, /* iTrustee defined lognin type from linux kernel */ }; typedef struct { @@ -364,4 +352,28 @@ typedef struct __TEE_ObjectHandle *TEE_ObjectHandle; typedef struct __TEE_ObjectEnumHandle *TEE_ObjectEnumHandle; typedef struct __TEE_OperationHandle *TEE_OperationHandle; +#define TEE_TIMEOUT_INFINITE (0xFFFFFFFF) + +typedef struct { + uint32_t seconds; + uint32_t millis; +} TEE_Time; + +typedef struct { + int32_t seconds; + int32_t millis; + int32_t min; + int32_t hour; + int32_t day; + int32_t month; + int32_t year; +} TEE_Date_Time; + +typedef struct { + uint32_t type; + uint32_t timer_id; + uint32_t timer_class; + uint32_t reserved2; +} TEE_timer_property; + #endif diff --git a/include/TA/tee_mem_mgmt_api.h b/include/TA/tee_mem_mgmt_api.h index 5b91566..c890836 100644 --- a/include/TA/tee_mem_mgmt_api.h +++ b/include/TA/tee_mem_mgmt_api.h @@ -8,6 +8,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: Header file of memory management api */ #ifndef TEE_MEM_MGMT_API_H @@ -61,7 +62,7 @@ enum MALLOC_HINT { * * @return void */ -#if (API_LEVEL >= API_LEVEL1_2) +#if defined(API_LEVEL) && (API_LEVEL >= API_LEVEL1_2) void TEE_MemFill(void *buffer, uint8_t x, size_t size); #else void TEE_MemFill(void *buffer, uint32_t x, size_t size); diff --git a/include/TA/tee_object_api.h b/include/TA/tee_object_api.h index c8200e5..e4c10c3 100644 --- a/include/TA/tee_object_api.h +++ b/include/TA/tee_object_api.h @@ -8,6 +8,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: Reference of TEE object api definitions */ #ifndef __TEE_OBJECT_API_H @@ -237,7 +238,7 @@ TEE_Result TEE_GenerateKey(TEE_ObjectHandle object, uint32_t keySize, TEE_Attrib */ TEE_Result TEE_InfoObjectData(TEE_ObjectHandle object, uint32_t *pos, uint32_t *len); -#if (API_LEVEL >= 2) +#if defined(API_LEVEL) && (API_LEVEL >= 2) /* * Obtain the TEE_ObjectInfo of the object and copy it to the space pointed diff --git a/include/TA/tee_property_api.h b/include/TA/tee_property_api.h index fb00a96..a88586a 100644 --- a/include/TA/tee_property_api.h +++ b/include/TA/tee_property_api.h @@ -8,6 +8,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: TEE property implementation header file */ #ifndef TEE_PROPERTY_API_H @@ -69,7 +70,7 @@ TEE_Result TEE_GetPropertyAsBool(TEE_PropSetHandle propsetOrEnumerator, const ch */ TEE_Result TEE_GetPropertyAsU32(TEE_PropSetHandle propsetOrEnumerator, const char *name, uint32_t *value); -#if (API_LEVEL >= API_LEVEL1_2) +#if defined(API_LEVEL) && (API_LEVEL >= API_LEVEL1_2) /* * retrieves a single property in a property set and converts its value to a 64-bit unsigned integer * diff --git a/include/TA/tee_time_api.h b/include/TA/tee_time_api.h index 31cc5f8..fb09958 100644 --- a/include/TA/tee_time_api.h +++ b/include/TA/tee_time_api.h @@ -8,6 +8,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: Reference of TEE time api definitions */ #ifndef __TEE_TIME_API_H @@ -15,34 +16,6 @@ #include "tee_defines.h" -#define TEE_TIMEOUT_INFINITE (0xFFFFFFFF) - -typedef struct { - uint32_t seconds; - uint32_t millis; -} TEE_Time; - -typedef struct { - int32_t seconds; - int32_t millis; - int32_t min; - int32_t hour; - int32_t day; - int32_t month; - int32_t year; -} TEE_Date_Time; - -typedef struct { - uint32_t type; - uint32_t timer_id; - uint32_t timer_class; - uint32_t reserved2; -} TEE_timer_property; - -typedef enum { - ANTI_ROOT_TIMER = 1, -} TEE_Anti_Root_Timer_Type; - /* * Get current TEE system rtc time * @@ -111,54 +84,4 @@ void TEE_GetREETime(TEE_Time *time); * @return void */ void TEE_GetREETimeStr(char *time_str, uint32_t time_str_len); - -/* - * Create rtc timer event - * - * @param time_seconds [IN] specified number of seconds - * @param timer_property [IN] specified property of timer - * - * @return TEE_SUCCESS success - * @return TEE_ERROR_GENERIC create timer fail - */ -TEE_Result TEE_EXT_CreateTimer(uint32_t time_seconds, TEE_timer_property *timer_property); - -/* - * Destory rtc timer event - * - * @param timer_property [IN] specified property of timer - * - * @return TEE_SUCCESS success - * @return TEE_ERROR_GENERIC destroy timer fail - */ -TEE_Result TEE_EXT_DestoryTimer(TEE_timer_property *timer_property); - -/* - * Get expire time of rtc timer event - * - * @param timer_property [IN] specified property of timer - * @param time_seconds [OUT] expire time of rtc timer event - * - * @return TEE_SUCCESS success - * @return TEE_ERROR_GENERIC get expire time fail - */ -TEE_Result TEE_EXT_GetTimerExpire(TEE_timer_property *timer_property, uint32_t *time_seconds); - -/* - * Get remain time of rtc timer event - * - * @param timer_property [IN] specified property of timer - * @param time_seconds [OUT] remain time of rtc timer event - * - * @return TEE_SUCCESS success - * @return TEE_ERROR_GENERIC get remain time fail - */ -TEE_Result TEE_EXT_GetTimerRemain(TEE_timer_property *timer_property, uint32_t *time_seconds); - -/* - * Get secure rtc time - * - * @return current rtc seconds - */ -unsigned int __get_secure_rtc_time(void); #endif diff --git a/include/TA/tee_trusted_storage_api.h b/include/TA/tee_trusted_storage_api.h new file mode 100644 index 0000000..9c3d51b --- /dev/null +++ b/include/TA/tee_trusted_storage_api.h @@ -0,0 +1,309 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS 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: Reference of TEE trusted storage definitions + */ + +#ifndef __TEE_TRUSTED_STORAGE_API_H +#define __TEE_TRUSTED_STORAGE_API_H + +#include "tee_defines.h" +#include "tee_object_api.h" + +/* + * Data stream positioning start position option, used in TEE_SeekObjectData function + */ +enum __TEE_Whence { + TEE_DATA_SEEK_SET = 0, /* Position the starting position as the beginning of the data stream */ + TEE_DATA_SEEK_CUR, /* Position the starting position as the current data stream position */ + TEE_DATA_SEEK_END /* Position the starting position at the end of the data stream */ +}; + +struct __TEE_ObjectEnumHandle; +typedef struct __TEE_ObjectEnumHandle *TEE_ObjectEnumHandle; + +typedef uint32_t TEE_Whence; + +/* + * Storage ID, which defines the storage space of the corresponding application + */ +enum Object_Storage_Constants { + TEE_OBJECT_STORAGE_PRIVATE = 0x00000001, /* Separate private storage space for each application */ +}; + +/* + * System resource constraints, such as the maximum value that the data stream position indicator can take + */ +enum Miscellaneous_Constants { + TEE_DATA_MAX_POSITION = 0xFFFFFFFF, /* The maximum length that the position indicator of the data stream can take */ + TEE_OBJECT_ID_MAX_LEN = 64, /* The maximum length of objectID, which actually extends to 128 bytes */ +}; + +/* + * The maximum number of bytes of data that the data stream can store + */ +enum TEE_DATA_Size { + TEE_DATA_OBJECT_MAX_SIZE = 0xFFFFFFFF /* The maximum bytes of data that the object data stream can store */ +}; + +/* + * The handleFlags of TEE_ObjectHandle determines the access authority of + * the TEE_ObjectHandle to the object data stream + */ +enum Data_Flag_Constants { + /* Have read permission to the data stream, and can read */ + TEE_DATA_FLAG_ACCESS_READ = 0x00000001, + /* Have write permission to the data stream, and can write and truncate */ + TEE_DATA_FLAG_ACCESS_WRITE = 0x00000002, + /* Have WRITE_META permission for data stream, and can delete and rename operation */ + TEE_DATA_FLAG_ACCESS_WRITE_META = 0x00000004, + /* + * Have shared read permissions on the data stream, you can open multiple + * TEE_ObjectHandles for concurrent reading + */ + TEE_DATA_FLAG_SHARE_READ = 0x00000010, + /* + * Have shared write permissions for the data stream, and multiple TEE_ObjectHandles + * can be opened for concurrent writing + */ + TEE_DATA_FLAG_SHARE_WRITE = 0x00000020, + /* Unused */ + TEE_DATA_FLAG_CREATE = 0x00000200, + /* + * Protect an existing file with the same name. If the file with the same name does not exist, + * create a new data file; if the file with the same name exists, an error will be reported + */ + TEE_DATA_FLAG_EXCLUSIVE = 0x00000400, + /* + * Protect an existing file with the same name. If the file with the same name does not exist, + * create a new data file; if the file with the same name exists, an error will be reported + */ + TEE_DATA_FLAG_OVERWRITE = 0x00000400, + /* + * If the bit27 is set to 1, it means deriving the 32-bytes TA root key at one time, + * if it is 0, it means deriving two 16-bytes TA root keys and combined them together + */ + TEE_DATA_FLAG_DERIVE_32BYTES_KEY_ONCE = 0x08000000, + /* If bit28 is set to 1, it means AES256, if it is 0, it means AES128 */ + TEE_DATA_FLAG_AES256 = 0x10000000, + /* If bit29 is set to 1, it means that the lower version will be opened first */ + TEE_DATA_FLAG_OPEN_AESC = 0x20000000, +}; + +/* + * Create a new persistent object, you can directly initialize the data stream and TEE_Attribute, + * the user can use the returned handle to access the object's TEE_Attribute and data stream + * + * @param storageID [IN] Corresponding to a separate storage space for each application, + * the value is Object_Storage_Constants + * @param objectID [IN] Object identifier, the name of the object to be created + * @param objectIDLen [IN] The length of the object identifier by byte, no more than 128 bytes + * @param flags [IN] Flags after object creation, the value can be one or more of Data_Flag_Constants + * or Handle_Flag_Constants + * @param attributes [IN] The TEE_ObjectHandle of the transient object, used to initialize the + * TEE_Attribute of the object, can be TEE_HANDLE_NULL + * @param initialData [IN] Initial data, used to initialize data stream data + * @param initialDataLen [IN] InitialData length in byte + * @param object [OUT] TEE_ObjectHandle returned after the function is successfully executed + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_ITEM_NOT_FOUND: The storageID does not exist + * @return TEE_ERROR_ACCESS_CONFLICT Access conflict + * @return TEE_ERROR_OUT_OF_MEMORY Insufficient memory to complete the operation + * @return TEE_ERROR_STORAGE_NO_SPACE There is not enough space to create the object + */ +TEE_Result TEE_CreatePersistentObject(uint32_t storageID, const void *ojbectID, size_t objectIDLen, uint32_t flags, + TEE_ObjectHandle attributes, const void *initialData, size_t initialDataLen, + TEE_ObjectHandle *object); + +/* + * Open an existing permanent object, the returned handle can be used by the user to access + * the object's TEE_Attribute and data stream + * + * @param storageID [IN] orresponding to a separate storage space for each application, + * the value is Object_Storage_Constants + * @param objectID [IN] object identifier, the name of the object to be opened + * @param objectIDLen [IN] The length of the object identifier by byte, no more than 128 bytes + * @param flags [IN] Flags after object opened, the value can be one or more of + * Data_Flag_Constants or Handle_Flag_Constants + * @param object [OUT] TEE_ObjectHandle returned after the function is successfully executed + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_ITEM_NOT_FOUND: The storageID does not exist or cannot find object identifier + * @return TEE_ERROR_ACCESS_CONFLICT Access conflict + * @return TEE_ERROR_OUT_OF_MEMORY Insufficient memory to complete the operation + */ +TEE_Result TEE_OpenPersistentObject(uint32_t storageID, const void *ojbectID, size_t objectIDLen, uint32_t flags, + TEE_ObjectHandle *object); + +/* + * Read size bytes of data from the object's data stream to the buffer, + * the TEE_ObjectHandle must have been opened with TEE_DATA_FLAG_ACCESS_READ permission + * + * @param objbect [IN] The TEE_ObjectHandle to be read + * @param buffer [OUT] Buffer for storing read data + * @param size [IN] Size of data to be read by byte + * @param count [OUT] Size of data actually read by byte + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_OUT_OF_MEMORY Insufficient memory to complete the operation + */ +TEE_Result TEE_ReadObjectData(TEE_ObjectHandle ojbect, void *buffer, size_t size, uint32_t *count); + +/* + * Write size bytes of data from the buffer to the data stream of the object. + * TEE_ObjectHandle must have been opened with TEE_DATA_FLAG_ACCESS_WRITE permission + * + * @param ojbect [IN] The TEE_ObjectHandle to be write + * @param buffer [IN] Store the data to be written + * @param size [IN] The length of the data to be written, the size does not exceed 4096 bytes + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_OUT_OF_MEMORY Insufficient memory to complete the operation + * @return TEE_ERROR_STORAGE_NO_SPACE There is not enough space to perform the operation + */ +TEE_Result TEE_WriteObjectData(TEE_ObjectHandle ojbect, const void *buffer, size_t size); + +/* + * This function changes the size of the data stream. If the size is smaller than the size of + * the current data stream, delete all excess bytes. If size is greater than the size of the + * current data stream, use '0' to expand + * TEE_ObjectHandle must be opened with TEE_DATA_FLAG_ACCESS_WRITE permission + * + * @param object [IN] TEE_ObjectHandle to be truncated + * @param size [IN] The new length of the data stream, the size does not exceed 4096 bytes + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_STORAGE_NO_SPACE There is not enough space to perform the operation + */ +TEE_Result TEE_TruncateObjectData(TEE_ObjectHandle object, size_t size); + +/* + * Set the data stream position pointed to by TEE_ObjectHandle, and set the data stream position to: + * start position + offset + * The parameter whence controls the starting position of the offset, the value can choose in TEE_Whence, + * and the meaning is as follows: + * TEE_DATA_SEEK_SET, the starting position of the data stream offset is the file header, which is 0 + * TEE_DATA_SEEK_CUR, the starting position of the data stream offset is the current position + * TEE_DATA_SEEK_END, the starting position of the data stream offset is the end of the file + * When the parameter offset is a positive number, it is offset backward, and when it is negative, it is offset forward. + * + * @param object [IN] TEE_ObjectHandle to be set + * @param offset [IN] The size of the data stream position movement, the size does not exceed 4096 bytes + * @param whence [IN] The initial position of the data stream offset + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_OVERFLOW The operation causes the value of the position indicator to exceed its + * system limit TEE_DATA_MAX_POSITION + */ +TEE_Result TEE_SeekObjectData(TEE_ObjectHandle object, int32_t offset, TEE_Whence whence); + +/* + * Close the opened TEE_ObjectHandle and delete the object. The object must be a persistent object + * and must have been opened with TEE_DATA_FLAG_ACCESS_WRITE_META permission + * + * @param object [IN] TEE_ObjectHandle to be closed and deleted + * + * @return void + */ +void TEE_CloseAndDeletePersistentObject(TEE_ObjectHandle object); + +/* + * Synchronize the opened TEE_ObjectHandle, and synchronize the corresponding security attribute files to the disk + * + * @param object [IN] TEE_ObjectHandle to be synchronized + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + */ +TEE_Result TEE_SyncPersistentObject(TEE_ObjectHandle object); + +/* + * Change the object identifier, the TEE_ObjectHandle must be opened with TEE_DATA_FLAG_ACCESS_WRITE_META permission + * + * @param ojbect [IN/OUT] The object handle to be modified + * @param newObjectID [IN] New object identifier + * @param newObjectIDLen [IN] New object identifier length + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + */ +TEE_Result TEE_RenamePersistentObject(TEE_ObjectHandle object, void *newObjectID, size_t newObjectIDLen); + +/* + * Allocate the handle of an uninitialized object enumerator + * + * @param object [OUT] Pointer to the handle of the newly created object enumerator + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_OUT_OF_MEMORY No enough memory to allocate + */ +TEE_Result TEE_AllocatePersistentObjectEnumerator(TEE_ObjectEnumHandle *obj_enumerator); + +/* + * Release a object enumerator handle that has allocated. The handle becomes invalid after the function is called, + * and all allocated are released. Use it in pair with TEE_AllocatePersistentObjectEnumerator + * + * @param object [IN] TEE_ObjectEnumHandle to be released + * + * @return void + */ +void TEE_FreePersistentObjectEnumerator(TEE_ObjectEnumHandle obj_enumerator); + +/* + * Reset the temporary object enumerator to its initial state, that is, the state just after the allocate + * + * @param object [IN] TEE_ObjectEnumHandle of the object enumerator to be reset + * + * @return void + */ +void TEE_ResetPersistentObjectEnumerator(TEE_ObjectEnumHandle obj_enumerator); + +/* + * Start enumerating all objects in a given storage space, the information of the object can be obtained + * through the TEE_GetNextPersistentObject function + * + * @param object [IN] TEE_ObjectEnumHandle of the allocated object enumerator + * @param storageID [IN] Correspond to a separate storage space for each application, the value is + * Object_Storage_Constants, currently only supports TEE_STORAGE_PRIVATE + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ITEM_NOT_FOUND storageID is not TEE_STORAGE_PRIVATE or there is no object in the storage space + */ +TEE_Result TEE_StartPersistentObjectEnumerator(TEE_ObjectEnumHandle obj_enumerator, uint32_t storage_id); + +/* + * Get the next object in the object enumerator, and return the object's TEE_ObjectInfo, objectID, + * objectIDLen information + * + * @param object [IN] TEE_ObjectEnumHandle of the initialized object enumerator + * @param objectInfo [OUT] Pointer to the structure used to store the obtained TEE_ObjectInfo + * @param objectInfo [OUT] Pointer to a buffer, used to store the obtained objectID + * @param objectInfo [OUT] Used to store the obtained objectIDLen + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ITEM_NOT_FOUND The enumerator has no object or the enumerator has not been initialized + */ +TEE_Result TEE_GetNextPersistentObject(TEE_ObjectEnumHandle obj_enumerator, + TEE_ObjectInfo *object_info, void *object_id, size_t *object_id_len); + +#if defined(API_LEVEL) && (API_LEVEL >= 2) + +/* + * Close the opened TEE_ObjectHandle and delete the object. The object must be a persistent object + * and must have been opened with TEE_DATA_FLAG_ACCESS_WRITE_META permission + * + * @param object [IN] TEE_ObjectHandle to be closed and deleted + * + * @return TEE_SUCCESS Indicates that the function was executed successfully + * @return TEE_ERROR_STORAGE_NOT_AVAILABLE Cannot access the storage area where the file is located + */ +TEE_Result TEE_CloseAndDeletePersistentObject1(TEE_ObjectHandle object); + +#endif // API_LEVEL +#endif diff --git a/include/TA/tee_uuid.h b/include/TA/tee_uuid.h new file mode 100644 index 0000000..3bad4e7 --- /dev/null +++ b/include/TA/tee_uuid.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. + * iTrustee licensed under the Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS 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: Defines of GP TEE_UUID + */ + +#ifndef TEE_UUID_H +#define TEE_UUID_H + +#include + +#define NODE_LEN 8 +typedef struct tee_uuid { + uint32_t timeLow; + uint16_t timeMid; + uint16_t timeHiAndVersion; + uint8_t clockSeqAndNode[NODE_LEN]; +} TEE_UUID; + +#endif diff --git a/src/CA/cloud/libteec_adaptor.c b/src/CA/libteec_adaptor.c similarity index 74% rename from src/CA/cloud/libteec_adaptor.c rename to src/CA/libteec_adaptor.c index a37cbac..65ce2fd 100644 --- a/src/CA/cloud/libteec_adaptor.c +++ b/src/CA/libteec_adaptor.c @@ -8,6 +8,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: this file is used for adapting interfaces in libteec.so */ #include @@ -41,10 +42,6 @@ typedef TEEC_Result (*allocateSharedMemory_f)(TEEC_Context *context, TEEC_SharedMemory *sharedMem); typedef void (*releaseSharedMemory_f)(TEEC_SharedMemory *sharedMem); typedef void (*requestCancellation_f)(TEEC_Operation *operation); -typedef TEEC_Result (*EXT_RegisterAgent_f)(uint32_t agentId, int *devFd, void **buffer); -typedef TEEC_Result (*EXT_WaitEvent_f)(uint32_t agentId, int devFd); -typedef TEEC_Result (*EXT_SendEventResponse_f)(uint32_t agentId, int devFd); -typedef TEEC_Result (*EXT_UnregisterAgent_f)(uint32_t agentId, int devFd, void **buffer); typedef struct { initializeContext_f initializeContextFn; @@ -56,10 +53,6 @@ typedef struct { allocateSharedMemory_f allocateSharedMemoryFn; releaseSharedMemory_f releaseSharedMemoryFn; requestCancellation_f requestCancellationFn; - EXT_RegisterAgent_f EXT_RegisterAgentFn; - EXT_WaitEvent_f EXT_WaitEventFn; - EXT_SendEventResponse_f EXT_SendEventResponseFn; - EXT_UnregisterAgent_f EXT_UnregisterAgentFn; } TeecApiTable; static TeecApiTable g_teecApiTable; @@ -102,34 +95,6 @@ static TEEC_Result GetBasicApiSymbol(TeecApiTable *teecApiTable) TEEC_Error("get symbol TEEC_InvokeCommand failed\n"); return TEEC_ERROR_GENERIC; } - - teecApiTable->EXT_RegisterAgentFn = - (EXT_RegisterAgent_f)(dlsym(g_libTeecHandle, "TEEC_EXT_RegisterAgent")); - if (teecApiTable->EXT_RegisterAgentFn == NULL) { - TEEC_Error("get symbol TEEC_EXT_RegisterAgent failed\n"); - return TEEC_ERROR_GENERIC; - } - - teecApiTable->EXT_WaitEventFn = - (EXT_WaitEvent_f)(dlsym(g_libTeecHandle, "TEEC_EXT_WaitEvent")); - if (teecApiTable->EXT_WaitEventFn == NULL) { - TEEC_Error("get symbol TEEC_EXT_WaitEvent failed\n"); - return TEEC_ERROR_GENERIC; - } - - teecApiTable->EXT_SendEventResponseFn = - (EXT_SendEventResponse_f)(dlsym(g_libTeecHandle, "TEEC_EXT_SendEventResponse")); - if (teecApiTable->EXT_SendEventResponseFn == NULL) { - TEEC_Error("get symbol TEEC_EXT_SendEventResponse failed\n"); - return TEEC_ERROR_GENERIC; - } - - teecApiTable->EXT_UnregisterAgentFn = - (EXT_UnregisterAgent_f)(dlsym(g_libTeecHandle, "TEEC_EXT_UnregisterAgent")); - if (teecApiTable->EXT_UnregisterAgentFn == NULL) { - TEEC_Error("get symbol TEEC_EXT_UnregisterAgent failed\n"); - return TEEC_ERROR_GENERIC; - } return TEEC_SUCCESS; } @@ -302,48 +267,3 @@ void TEEC_RequestCancellation(TEEC_Operation *operation) g_teecApiTable.requestCancellationFn(operation); } - -/* This function is not support for usual user currently(just for secGear) */ -TEEC_Result TEEC_EXT_RegisterAgent(uint32_t agentId, int *devFd, void **buffer) -{ - if (g_teecApiTable.EXT_RegisterAgentFn == NULL) { - TEEC_Error("TEEC_EXT_RegisterAgent is null!\n"); - return TEEC_ERROR_GENERIC; - } - - g_teecApiTable.EXT_RegisterAgentFn(agentId, devFd, buffer); -} - -/* This function is not support for usual user currently(just for secGear) */ -TEEC_Result TEEC_EXT_WaitEvent(uint32_t agentId, int devFd) -{ - if (g_teecApiTable.EXT_WaitEventFn == NULL) { - TEEC_Error("TEEC_EXT_WaitEvent is null!\n"); - return TEEC_ERROR_GENERIC; - } - - g_teecApiTable.EXT_WaitEventFn(agentId, devFd); -} - -/* This function is not support for usual user currently(just for secGear) */ -TEEC_Result TEEC_EXT_SendEventResponse(uint32_t agentId, int devFd) -{ - if (g_teecApiTable.EXT_SendEventResponseFn == NULL) { - TEEC_Error("TEEC_EXT_SendEventResponse is null!\n"); - return TEEC_ERROR_GENERIC; - } - - g_teecApiTable.EXT_SendEventResponseFn(agentId, devFd); -} - -/* This function is not support for usual user currently(just for secGear) */ -TEEC_Result TEEC_EXT_UnregisterAgent(uint32_t agentId, int devFd, void **buffer) -{ - if (g_teecApiTable.EXT_UnregisterAgentFn == NULL) { - TEEC_Error("TEEC_EXT_UnregisterAgent is null!\n"); - return TEEC_ERROR_GENERIC; - } - - g_teecApiTable.EXT_UnregisterAgentFn(agentId, devFd, buffer); -} - diff --git a/test/CA/helloworld/cloud/Makefile b/test/CA/helloworld/Makefile old mode 100755 new mode 100644 similarity index 42% rename from test/CA/helloworld/cloud/Makefile rename to test/CA/helloworld/Makefile index 190b131..d4392da --- a/test/CA/helloworld/cloud/Makefile +++ b/test/CA/helloworld/Makefile @@ -1,19 +1,20 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2018-2021. All rights reserved. CUR_DIR=$(shell pwd) -iTrustee_SDK_PATH=${CUR_DIR}/../../../../ +ITRUSTEE_BUILD_PATH=${CUR_DIR}/../../../ -TARGET_APP := teec_hello +TARGET_APP := demo_hello -APP_SOURCES := ../ca_demo.c +APP_SOURCES := ./ca_demo.c -APP_SOURCES += $(iTrustee_SDK_PATH)/src/CA/cloud/libteec_adaptor.c +APP_SOURCES += $(ITRUSTEE_BUILD_PATH)/src/CA/libteec_adaptor.c APP_CFLAGS += -fstack-protector-strong -fPIC -APP_CFLAGS += -I$(iTrustee_SDK_PATH)/include/CA \ +APP_CFLAGS += -I$(ITRUSTEE_BUILD_PATH)/include/CA \ APP_LDFLAGS += -ldl -lpthread -APP_LDFLAGS += -z text -z now -z relro -z noexecstack -pie +APP_LDFLAGS += -z text -z now -z relro -z noexecstack -pie -s APP_OBJECTS := $(APP_SOURCES:.c=.o) $(TARGET_APP): $(APP_SOURCES) diff --git a/test/CA/helloworld/ReadMe.txt b/test/CA/helloworld/ReadMe.txt deleted file mode 100755 index e10f8b8..0000000 --- a/test/CA/helloworld/ReadMe.txt +++ /dev/null @@ -1,2 +0,0 @@ -Makefile is located in different folder for different product -please switch to target folder and execute "make" command to build TA binary for target product diff --git a/test/CA/helloworld/ca_demo.c b/test/CA/helloworld/ca_demo.c index 57c0e35..a5910ea 100755 --- a/test/CA/helloworld/ca_demo.c +++ b/test/CA/helloworld/ca_demo.c @@ -8,6 +8,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: C file template for CA */ #include @@ -25,10 +26,8 @@ #define OPERATION_START_FLAG 1 #define OUT_BUFF_INDEX 3 -static const TEEC_UUID DEMO_TEMPLATE_UUID = -{ - 0xe3d37f4a, 0xf24c, 0x48d0, - { 0x88, 0x84, 0x3b, 0xdd, 0x6c, 0x44, 0xe9, 0x88 } +static const TEEC_UUID g_demoTemplateUuid = { + 0xe3d37f4a, 0xf24c, 0x48d0, { 0x88, 0x84, 0x3b, 0xdd, 0x6c, 0x44, 0xe9, 0x88 } }; enum { @@ -57,16 +56,14 @@ int main(void) operation.paramTypes = TEEC_PARAM_TYPES( TEEC_NONE, TEEC_NONE, - TEEC_MEMREF_TEMP_INPUT, - TEEC_MEMREF_TEMP_INPUT); + TEEC_NONE, + TEEC_NONE); result = TEEC_OpenSession( - &context, &session, &DEMO_TEMPLATE_UUID, TEEC_LOGIN_IDENTIFY, NULL, &operation, &origin); + &context, &session, &g_demoTemplateUuid, TEEC_LOGIN_IDENTIFY, NULL, &operation, &origin); if (result != TEEC_SUCCESS) { printf("teec open session failed"); goto cleanup_2; - } else { - TEEC_Debug("teec open session successed"); } operation.started = OPERATION_START_FLAG; diff --git a/test/CA/helloworld/cloud/CMakeLists.txt b/test/CA/helloworld/cloud/CMakeLists.txt deleted file mode 100644 index 42fe486..0000000 --- a/test/CA/helloworld/cloud/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -cmake_minimum_required (VERSION 2.8) -project (teec_hello) -cmake_policy (SET CMP0037 OLD) - -# Add source files -set(SRCS - ../ca_demo.c - ../../../../src/CA/cloud/libteec_adaptor.c -) - -# Add header file include directories -include_directories( - ../../../../include/CA -) - -# Set options -set(CMAKE_TEEC_HELLO_FLAGS "-fstack-protector-strong -fPIC") -set(CMAKE_TEEC_HELLO_FLAGS "${CMAKE_TEEC_HELLO_FLAGS} -z text -z now -z relro -z noexecstack -pie") - -# Set output dir -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}) - -# Generate execute file -add_executable(rsa_demo ${SRCS}) -target_link_libraries(rsa_demo dl pthread) -set_target_properties(rsa_demo PROPERTIES COMPILE_FLAGS ${CMAKE_TEEC_HELLO_FLAGS}) - -# Clean output -add_custom_target(clean - COMMAND rm -rf ${PROJECT_SOURCE_DIR}/teec_hello - COMMAND @echo "clean up" -) diff --git a/test/TA/helloworld/CMakeLists.txt b/test/TA/helloworld/CMakeLists.txt new file mode 100644 index 0000000..45334da --- /dev/null +++ b/test/TA/helloworld/CMakeLists.txt @@ -0,0 +1,30 @@ +# sdk cmake. +# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved. +cmake_minimum_required(VERSION 3.16 FATAL_ERROR) +project(tee_sdk C) + +if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) + message(FATAL_ERROR "Forbid compiling in the source tree") +endif() + +include(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake) +include($ENV{ITRUSTEE_BUILD_PATH}/build/cmake/common.cmake) + +set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +set(CURRENT_TARGET_SO "combine") + +set(SDK_C_SOURCES + ${SDK_C_SOURCES} + ta_demo.c +) + +add_library(${CURRENT_TARGET_SO} SHARED ${SDK_C_SOURCES}) +target_include_directories(${CURRENT_TARGET_SO} PUBLIC ${COMMON_INCLUDES}) +target_compile_options(${CURRENT_TARGET_SO} PRIVATE ${COMMON_CFLAGS}) +target_link_options(${CURRENT_TARGET_SO} PRIVATE ${COMMON_LDFLAGS}) + +add_custom_command( + TARGET ${CURRENT_TARGET_SO} POST_BUILD + COMMAND ${CMAKE_OBJCOPY} ${CMAKE_CURRENT_SOURCE_DIR}/libcombine.so + COMMAND python3 -B $ENV{ITRUSTEE_BUILD_PATH}/build/signtools/signtool_v3.py ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} --privateCfg $ENV{ITRUSTEE_BUILD_PATH}/build/signtools/config_cloud.ini +) diff --git a/test/TA/helloworld/cloud/Makefile b/test/TA/helloworld/Makefile old mode 100755 new mode 100644 similarity index 64% rename from test/TA/helloworld/cloud/Makefile rename to test/TA/helloworld/Makefile index 63b2fa5..1a659b2 --- a/test/TA/helloworld/cloud/Makefile +++ b/test/TA/helloworld/Makefile @@ -1,8 +1,8 @@ -include ../config.mk -include ../../../../build/mk/cloud/common.mk +# Copyright (c) Huawei Technologies Co., Ltd. 2018-2021. All rights reserved. +include ./config.mk +include ../../../build/mk/common.mk SRC += $(wildcard ./*.c) -SRC += ../ta_demo.c # set header directory INCLUDEDIR += -I./include @@ -12,12 +12,11 @@ COBJS := $(SRC:%.c=%.o) TARGET = $(COBJS) sec_binary:combine - cp ../config.mk ./ - cp ../manifest.txt ./ - python3 -B ${SIGNTOOL_DIR}/signtool_v3.py ${CUR_DIR} ${CUR_DIR} --config ${SIGNTOOL_DIR}/cloud/config_cloud.ini + python3 -B ${SIGNTOOL_DIR}/signtool_v3.py ${CUR_DIR} ${CUR_DIR} --privateCfg ${SIGNTOOL_DIR}/config_cloud.ini combine: $(TARGET) $(LD) $(LDFLAGS) $(TARGET) $(EXTRAO) -o libcombine.so + objcopy libcombine.so src/%.o: ./src/%.c $(CC) $(CFLAGS) $(INCLUDEDIR) -c $< -o $@ @@ -26,4 +25,4 @@ src/%.o: ./src/%.c $(CC) $(CFLAGS) $(INCLUDEDIR) -c $< -o $@ clean: - rm -f $(COBJS) *.so + rm -f $(COBJS) *.so *.sec diff --git a/test/TA/helloworld/ReadMe.txt b/test/TA/helloworld/ReadMe.txt index e10f8b8..0802d8b 100755 --- a/test/TA/helloworld/ReadMe.txt +++ b/test/TA/helloworld/ReadMe.txt @@ -1,2 +1,5 @@ -Makefile is located in different folder for different product -please switch to target folder and execute "make" command to build TA binary for target product +You need to install the pycryptodome library of python and run the make command to compile the binary of ta. + +If TA wants to regist driver's permission, you must have dynamic permission file and driver's excel +The name of the dynamic permission file must be 'dyn_perm.xml', the driver's excel's name can be 'driver name'.xlsx, and you can get it from driver's developer. +You must install the xlrd-1.2.0 and defusedxml-0.7.1 library of python and run the make command to sign the binary of ta. \ No newline at end of file diff --git a/test/TA/helloworld/cloud/CMakeLists.txt b/test/TA/helloworld/cloud/CMakeLists.txt deleted file mode 100644 index d7ed83a..0000000 --- a/test/TA/helloworld/cloud/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -cmake_minimum_required (VERSION 2.8) -project (teec_hello) -cmake_policy (SET CMP0037 OLD) - -# Set variable -set(iTrustee_SDK_PATH ${PROJECT_SOURCE_DIR}/../../../../) -set(SIGNTOOL_DIR ${iTrustee_SDK_PATH}/build/signtools) -set(LIBC ${iTrustee_SDK_PATH}/thirdparty/open_source/musl) -set(LIBSECURE ${iTrustee_SDK_PATH}/thirdparty/open_source/libboundscheck) - -# Add source files -file(GLOB SRCS "./*.c") -set(SRCS ${SRCS} ../ta_demo.c) - -# Add header file include directories -include_directories( - ${LIBC}/libc - ${LIBC}/libc/arch/aarch64 - ${LIBC}/libc/arch/aarch64/bits - ${LIBC}/libc/arch/generic - ${LIBSECURE}/include - ${iTrustee_SDK_PATH}/include/TA - ${iTrustee_SDK_PATH}/include/TA/huawei_ext - ${PROJECT_SOURCE_DIR}/include -) - -# Set options -set(CMAKE_TA_FLAGS "-DAPI_LEVEL=1 -O -W -Wall -Werror -fno-short-enums -fno-omit-frame-pointer -fstack-protector-strong") -set(CMAKE_TA_FLAGS "${CMAKE_TA_FLAGS} -Wextra -nostdinc -nodefaultlibs -march=armv8-a -Os -Wno-main -fPIC") -set(CMAKE_TA_FLAGS "${CMAKE_TA_FLAGS} -Wno-error=unused-parameter -Wno-error=unused-but-set-variable") -set(CMAKE_TA_LD_FLAGS "-s -z text -z now -z relro -z noexecstack -shared") -set(CMAKE_TA_LD_FLAGS "${CMAKE_TA_LD_FLAGS} -T${iTrustee_SDK_PATH}/build/tools/ta_link_64.ld") - -# Set output dir -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}) - -# Generate .so file -add_library(tmp_object OBJECT ${SRCS}) -set_target_properties(tmp_object PROPERTIES COMPILE_FLAGS ${CMAKE_TA_FLAGS}) -add_library(combine SHARED $) -set_target_properties(combine PROPERTIES LINK_FLAGS ${CMAKE_TA_LD_FLAGS}) - -add_custom_command(TARGET combine - POST_BUILD - COMMAND cp -f ${PROJECT_SOURCE_DIR}/../manifest.txt ${PROJECT_SOURCE_DIR} - COMMAND python3 -B ${SIGNTOOL_DIR}/signtool_v3.py ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR} --config ${PROJECT_SOURCE_DIR}/config_cloud.ini -) - -# Clean output -add_custom_target(clean - COMMAND rm -rf ${PROJECT_SOURCE_DIR}/libcombine.so ${PROJECT_SOURCE_DIR}/*.sec - COMMAND @echo "clean up" -) diff --git a/test/TA/helloworld/config.cmake b/test/TA/helloworld/config.cmake new file mode 100644 index 0000000..b7323b6 --- /dev/null +++ b/test/TA/helloworld/config.cmake @@ -0,0 +1,23 @@ +# Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. +# +# API_LEVEL which indicates the GP API version of TA +# API_LEVEL=1 indicates GP 1.0 which is the current version of itrustee +# API_LEVEL=2 indicates GP 1.1.1 which is the current version of the partner +# API_LEVEL=3 indicates GP 1.2 which is the version we both going to support +# If no API_LEVEL is specified, API of GP 1.0 will be taken +# +# USE_SMEE which indicates the feature of sram memory encryption +# set(USE_SMEE y) indicates the feature of sram memory encryption will be enabled +# If no USE_SMEE is specified, smee feature will be disabled +# If USE_SMEE is specified and a section is custimized, +# explicitly specify the segment to which the section belongs in the link script(ta_link_64.smee.ld) + +# TEE flags +set(COMMON_CFLAGS -DAPI_LEVEL=1) +set(USE_SMEE n) +if ("${TARGET_IS_ARM64}" STREQUAL "") + set(TARGET_IS_ARM64 y) +endif() +if ("${USE_SMEE}" STREQUAL "") + set(USE_SMEE n) +endif() diff --git a/test/TA/helloworld/config.mk b/test/TA/helloworld/config.mk index ebdbd8c..7a405a3 100644 --- a/test/TA/helloworld/config.mk +++ b/test/TA/helloworld/config.mk @@ -1,10 +1,23 @@ # -# Copyright (c) Huawei Technologies Co., Ltd. 2018-2020. All rights reserved. +# Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. # # API_LEVEL which indicates the GP API version of TA # API_LEVEL=1 indicates GP 1.0 which is the current version of itrustee # API_LEVEL=2 indicates GP 1.1.1 which is the current version of the partner # API_LEVEL=3 indicates GP 1.2 which is the version we both going to support -# If no API_LEVEL is specified, API of GP 1.0 will be taked +# If no API_LEVEL is specified, API of GP 1.0 will be taken +# +# USE_SMEE which indicates the feature of sram memory encryption +# USE_SMEE=y indicates the feature of sram memory encryption will be enabled +# If no USE_SMEE is specified, smee feature will not be disabled +# If USE_SMEE is specified and a section is custimized, +# explicitly specify the segment to which the section belongs in the link script(ta_link_64.smee.ld) + CFLAGS += -DAPI_LEVEL=1 -TARGET_IS_ARM64 = y +USE_SMEE = n +ifeq ($(TARGET_IS_ARM64),) + TARGET_IS_ARM64 = y +endif +ifeq ($(USE_SMEE),) + USE_SMEE = n +endif diff --git a/test/TA/helloworld/config.sh b/test/TA/helloworld/config.sh new file mode 100644 index 0000000..f1170b9 --- /dev/null +++ b/test/TA/helloworld/config.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Copyright Huawei Technologies Co., Ltd. 2022-2022. All rights reserved. +# This script is used to compile the demo sdk. +set -e + +export SOURCE_PATH=$(dirname $0) +export ABS_SOURCE_PATH=$(cd ${SOURCE_PATH};pwd) +export ITRUSTEE_BUILD_PATH=${ABS_SOURCE_PATH}/../../.. + +#clean +if [ "$#" -eq 1 ] && [ "$1"x = "clean"x ]; then + rm -f *.o *.so *.sec + if [ -d "cmake_build" ]; then + rm -rf cmake_build + echo "rm -rf cmake_build" + fi + exit 0 +fi + +echo "Cmake compile TA begin" +if [ -d "cmake_build" ]; then + rm -rf cmake_build + echo "rm -rf cmake_build" +fi +mkdir -p cmake_build +echo "mkdir cmake_build" +cd cmake_build/ + +cmake -DCMAKE_TOOLCHAIN_FILE=${ITRUSTEE_BUILD_PATH}/build/cmake/aarch64_toolchain.cmake .. + +make VERBOSE=1 + +cd .. +rm -rf cmake_build diff --git a/test/TA/helloworld/ta_demo.c b/test/TA/helloworld/ta_demo.c index ec17d6d..d8fd886 100755 --- a/test/TA/helloworld/ta_demo.c +++ b/test/TA/helloworld/ta_demo.c @@ -8,6 +8,7 @@ * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR * PURPOSE. * See the Mulan PSL v2 for more details. + * Description: TA template code for reference */ #include @@ -24,7 +25,7 @@ enum { static TEE_Result get_ta_version(char* buffer, size_t *buf_len) { - char *version = TA_TEMPLATE_VERSION; + const char *version = TA_TEMPLATE_VERSION; if (*buf_len < strlen(version) + 1) { tloge("buffer is too short for storing result"); @@ -49,14 +50,12 @@ static TEE_Result get_ta_version(char* buffer, size_t *buf_len) */ TEE_Result TA_CreateEntryPoint(void) { - TEE_Result ret = TEE_ERROR_GENERIC; + TEE_Result ret; tlogd("----- TA entry point ----- "); tlogd("TA version: %s", TA_TEMPLATE_VERSION); -#ifdef CONFIG_AUTH_CLOUD - ret = addcaller_ca_exec("/vendor/bin/teec_hello", "root"); -#endif + ret = addcaller_ca_exec("/vendor/bin/demo_hello", "root"); if (ret == TEE_SUCCESS) { tlogd("TA entry point: add ca whitelist success"); } else { diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/alltypes.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/alltypes.h index a0309c0..96e1d1f 100644 --- a/thirdparty/open_source/musl/libc/arch/aarch64/bits/alltypes.h +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/alltypes.h @@ -1,35 +1,15 @@ #define _Addr long -#ifdef __LP64__ #define _Int64 long -#else -#define _Int64 long long -#endif #define _Reg long -#define __LITTLE_ENDIAN 1234 -#define __BIG_ENDIAN 4321 -#define __USE_TIME_BITS64 1 - -#ifndef __BYTE_ORDER #if __AARCH64EB__ #define __BYTE_ORDER 4321 #else #define __BYTE_ORDER 1234 #endif -#endif #define __LONG_MAX 0x7fffffffffffffffL -#if defined(__NEED_va_list) && !defined(__DEFINED_va_list) -typedef __builtin_va_list va_list; -#define __DEFINED_va_list -#endif - -#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list) -typedef __builtin_va_list __isoc_va_list; -#define __DEFINED___isoc_va_list -#endif - #ifndef __cplusplus #if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t) typedef unsigned wchar_t; @@ -42,6 +22,7 @@ typedef unsigned wint_t; #define __DEFINED_wint_t #endif + #if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t) typedef int blksize_t; #define __DEFINED_blksize_t @@ -52,6 +33,7 @@ typedef unsigned int nlink_t; #define __DEFINED_nlink_t #endif + #if defined(__NEED_float_t) && !defined(__DEFINED_float_t) typedef float float_t; #define __DEFINED_float_t @@ -62,100 +44,15 @@ typedef double double_t; #define __DEFINED_double_t #endif + #if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t) -typedef struct { - long long __ll; - long double __ld; -} max_align_t; +typedef struct { long long __ll; long double __ld; } max_align_t; #define __DEFINED_max_align_t #endif -#if defined(__NEED_time_t) && !defined(__DEFINED_time_t) -typedef long time_t; -#define __DEFINED_time_t -#endif - -#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t) -typedef long suseconds_t; -#define __DEFINED_suseconds_t -#endif - -#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t) -typedef struct { - union { - int __i[14]; - volatile int __vi[14]; - unsigned long __s[7]; - } __u; -} pthread_attr_t; -#define __DEFINED_pthread_attr_t -#endif - -#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t) -typedef struct { - union { - int __i[10]; - volatile int __vi[10]; - volatile void *volatile __p[5]; - } __u; -} pthread_mutex_t; -#define __DEFINED_pthread_mutex_t -#endif - -#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t) -typedef struct { - union { - int __i[10]; - volatile int __vi[10]; - volatile void *volatile __p[5]; - } __u; -} mtx_t; -#define __DEFINED_mtx_t -#endif - -#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t) -typedef struct { - union { - int __i[12]; - volatile int __vi[12]; - void *__p[6]; - } __u; -} pthread_cond_t; -#define __DEFINED_pthread_cond_t -#endif - -#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t) -typedef struct { - union { - int __i[12]; - volatile int __vi[12]; - void *__p[6]; - } __u; -} cnd_t; -#define __DEFINED_cnd_t -#endif - -#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t) -typedef struct { - union { - int __i[14]; - volatile int __vi[14]; - void *__p[7]; - } __u; -} pthread_rwlock_t; -#define __DEFINED_pthread_rwlock_t -#endif - -#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t) -typedef struct { - union { - int __i[8]; - volatile int __vi[8]; - void *__p[4]; - } __u; -} pthread_barrier_t; -#define __DEFINED_pthread_barrier_t -#endif +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __USE_TIME_BITS64 1 #if defined(__NEED_size_t) && !defined(__DEFINED_size_t) typedef unsigned _Addr size_t; @@ -192,28 +89,39 @@ typedef _Reg register_t; #define __DEFINED_register_t #endif +#if defined(__NEED_time_t) && !defined(__DEFINED_time_t) +typedef _Int64 time_t; +#define __DEFINED_time_t +#endif + +#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t) +typedef _Int64 suseconds_t; +#define __DEFINED_suseconds_t +#endif + + #if defined(__NEED_int8_t) && !defined(__DEFINED_int8_t) typedef signed char int8_t; #define __DEFINED_int8_t #endif #if defined(__NEED_int16_t) && !defined(__DEFINED_int16_t) -typedef short int16_t; +typedef signed short int16_t; #define __DEFINED_int16_t #endif #if defined(__NEED_int32_t) && !defined(__DEFINED_int32_t) -typedef int int32_t; +typedef signed int int32_t; #define __DEFINED_int32_t #endif #if defined(__NEED_int64_t) && !defined(__DEFINED_int64_t) -typedef _Int64 int64_t; +typedef signed _Int64 int64_t; #define __DEFINED_int64_t #endif #if defined(__NEED_intmax_t) && !defined(__DEFINED_intmax_t) -typedef _Int64 intmax_t; +typedef signed _Int64 intmax_t; #define __DEFINED_intmax_t #endif @@ -247,6 +155,7 @@ typedef unsigned _Int64 uintmax_t; #define __DEFINED_uintmax_t #endif + #if defined(__NEED_mode_t) && !defined(__DEFINED_mode_t) typedef unsigned mode_t; #define __DEFINED_mode_t @@ -292,6 +201,7 @@ typedef unsigned _Int64 fsfilcnt_t; #define __DEFINED_fsfilcnt_t #endif + #if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t) typedef unsigned wint_t; #define __DEFINED_wint_t @@ -302,8 +212,9 @@ typedef unsigned long wctype_t; #define __DEFINED_wctype_t #endif + #if defined(__NEED_timer_t) && !defined(__DEFINED_timer_t) -typedef void *timer_t; +typedef void * timer_t; #define __DEFINED_timer_t #endif @@ -318,21 +229,16 @@ typedef long clock_t; #endif #if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval) -struct timeval { - time_t tv_sec; - suseconds_t tv_usec; -}; +struct timeval { time_t tv_sec; suseconds_t tv_usec; }; #define __DEFINED_struct_timeval #endif #if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec) -struct timespec { - time_t tv_sec; - long tv_nsec; -}; +struct timespec { time_t tv_sec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321); long tv_nsec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321); }; #define __DEFINED_struct_timespec #endif + #if defined(__NEED_pid_t) && !defined(__DEFINED_pid_t) typedef int pid_t; #define __DEFINED_pid_t @@ -363,6 +269,7 @@ typedef unsigned useconds_t; #define __DEFINED_useconds_t #endif + #ifdef __cplusplus #if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t) typedef unsigned long pthread_t; @@ -371,7 +278,7 @@ typedef unsigned long pthread_t; #else #if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t) -typedef struct __pthread *pthread_t; +typedef struct __pthread * pthread_t; #define __DEFINED_pthread_t #endif @@ -392,65 +299,72 @@ typedef int pthread_spinlock_t; #endif #if defined(__NEED_pthread_mutexattr_t) && !defined(__DEFINED_pthread_mutexattr_t) -typedef struct { - unsigned __attr; -} pthread_mutexattr_t; +typedef struct { unsigned __attr; } pthread_mutexattr_t; #define __DEFINED_pthread_mutexattr_t #endif #if defined(__NEED_pthread_condattr_t) && !defined(__DEFINED_pthread_condattr_t) -typedef struct { - unsigned __attr; -} pthread_condattr_t; +typedef struct { unsigned __attr; } pthread_condattr_t; #define __DEFINED_pthread_condattr_t #endif #if defined(__NEED_pthread_barrierattr_t) && !defined(__DEFINED_pthread_barrierattr_t) -typedef struct { - unsigned __attr; -} pthread_barrierattr_t; +typedef struct { unsigned __attr; } pthread_barrierattr_t; #define __DEFINED_pthread_barrierattr_t #endif #if defined(__NEED_pthread_rwlockattr_t) && !defined(__DEFINED_pthread_rwlockattr_t) -typedef struct { - unsigned __attr[2]; -} pthread_rwlockattr_t; +typedef struct { unsigned __attr[2]; } pthread_rwlockattr_t; #define __DEFINED_pthread_rwlockattr_t #endif + +#if defined(__NEED_struct__IO_FILE) && !defined(__DEFINED_struct__IO_FILE) +struct _IO_FILE { char __x; }; +#define __DEFINED_struct__IO_FILE +#endif + #if defined(__NEED_FILE) && !defined(__DEFINED_FILE) typedef struct _IO_FILE FILE; #define __DEFINED_FILE #endif + +#if defined(__NEED_va_list) && !defined(__DEFINED_va_list) +typedef __builtin_va_list va_list; +#define __DEFINED_va_list +#endif + +#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list) +typedef __builtin_va_list __isoc_va_list; +#define __DEFINED___isoc_va_list +#endif + + #if defined(__NEED_mbstate_t) && !defined(__DEFINED_mbstate_t) -typedef struct __mbstate_t { - unsigned __opaque1, __opaque2; -} mbstate_t; +typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t; #define __DEFINED_mbstate_t #endif + #if defined(__NEED_locale_t) && !defined(__DEFINED_locale_t) -typedef struct __locale_struct *locale_t; +typedef struct __locale_struct * locale_t; #define __DEFINED_locale_t #endif + #if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t) -typedef struct __sigset_t { - unsigned long __bits[128 / sizeof(long)]; -} sigset_t; +typedef struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t; #define __DEFINED_sigset_t #endif + #if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec) -struct iovec { - void *iov_base; - size_t iov_len; -}; +struct iovec { void *iov_base; size_t iov_len; }; #define __DEFINED_struct_iovec #endif + #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) typedef unsigned socklen_t; #define __DEFINED_socklen_t @@ -461,6 +375,43 @@ typedef unsigned short sa_family_t; #define __DEFINED_sa_family_t #endif + +#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t) +typedef struct { union { int __i[sizeof(long)==8?14:9]; volatile int __vi[sizeof(long)==8?14:9]; unsigned long __s[sizeof(long)==8?7:9]; } __u; } pthread_attr_t; +#define __DEFINED_pthread_attr_t +#endif + +#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t) +typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } pthread_mutex_t; +#define __DEFINED_pthread_mutex_t +#endif + +#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t) +typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } mtx_t; +#define __DEFINED_mtx_t +#endif + +#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t) +typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } pthread_cond_t; +#define __DEFINED_pthread_cond_t +#endif + +#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t) +typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } cnd_t; +#define __DEFINED_cnd_t +#endif + +#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t) +typedef struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t; +#define __DEFINED_pthread_rwlock_t +#endif + +#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t) +typedef struct { union { int __i[sizeof(long)==8?8:5]; volatile int __vi[sizeof(long)==8?8:5]; void *__p[sizeof(long)==8?4:5]; } __u; } pthread_barrier_t; +#define __DEFINED_pthread_barrier_t +#endif + + #undef _Addr #undef _Int64 #undef _Reg diff --git a/thirdparty/open_source/musl/libc/arch/aarch64/bits/syscall.h b/thirdparty/open_source/musl/libc/arch/aarch64/bits/syscall.h index d57a091..b56bfb8 100644 --- a/thirdparty/open_source/musl/libc/arch/aarch64/bits/syscall.h +++ b/thirdparty/open_source/musl/libc/arch/aarch64/bits/syscall.h @@ -1,551 +1,583 @@ -#define __NR_io_setup 0 -#define __NR_io_destroy 1 -#define __NR_io_submit 2 -#define __NR_io_cancel 3 -#define __NR_io_getevents 4 -#define __NR_setxattr 5 -#define __NR_lsetxattr 6 -#define __NR_fsetxattr 7 -#define __NR_getxattr 8 -#define __NR_lgetxattr 9 -#define __NR_fgetxattr 10 -#define __NR_listxattr 11 -#define __NR_llistxattr 12 -#define __NR_flistxattr 13 -#define __NR_removexattr 14 -#define __NR_lremovexattr 15 -#define __NR_fremovexattr 16 -#define __NR_getcwd 17 -#define __NR_lookup_dcookie 18 -#define __NR_eventfd2 19 -#define __NR_epoll_create1 20 -#define __NR_epoll_ctl 21 -#define __NR_epoll_pwait 22 -#define __NR_dup 23 -#define __NR_dup3 24 -#define __NR_fcntl 25 -#define __NR_inotify_init1 26 -#define __NR_inotify_add_watch 27 -#define __NR_inotify_rm_watch 28 -#define __NR_ioctl 29 -#define __NR_ioprio_set 30 -#define __NR_ioprio_get 31 -#define __NR_flock 32 -#define __NR_mknodat 33 -#define __NR_mkdirat 34 -#define __NR_unlinkat 35 -#define __NR_symlinkat 36 -#define __NR_linkat 37 -#define __NR_renameat 38 -#define __NR_umount2 39 -#define __NR_mount 40 -#define __NR_pivot_root 41 -#define __NR_nfsservctl 42 -#define __NR_statfs 43 -#define __NR_fstatfs 44 -#define __NR_truncate 45 -#define __NR_ftruncate 46 -#define __NR_fallocate 47 -#define __NR_faccessat 48 -#define __NR_chdir 49 -#define __NR_fchdir 50 -#define __NR_chroot 51 -#define __NR_fchmod 52 -#define __NR_fchmodat 53 -#define __NR_fchownat 54 -#define __NR_fchown 55 -#define __NR_openat 56 -#define __NR_close 57 -#define __NR_vhangup 58 -#define __NR_pipe2 59 -#define __NR_quotactl 60 -#define __NR_getdents64 61 -#define __NR_lseek 62 -#define __NR_read 63 -#define __NR_write 64 -#define __NR_readv 65 -#define __NR_writev 66 -#define __NR_pread64 67 -#define __NR_pwrite64 68 -#define __NR_preadv 69 -#define __NR_pwritev 70 -#define __NR_sendfile 71 -#define __NR_pselect6 72 -#define __NR_ppoll 73 -#define __NR_signalfd4 74 -#define __NR_vmsplice 75 -#define __NR_splice 76 -#define __NR_tee 77 -#define __NR_readlinkat 78 -#define __NR_newfstatat 79 -#define __NR_fstat 80 -#define __NR_sync 81 -#define __NR_fsync 82 -#define __NR_fdatasync 83 -#define __NR_sync_file_range 84 -#define __NR_timerfd_create 85 -#define __NR_timerfd_settime 86 -#define __NR_timerfd_gettime 87 -#define __NR_utimensat 88 -#define __NR_acct 89 -#define __NR_capget 90 -#define __NR_capset 91 -#define __NR_personality 92 -#define __NR_exit 93 -#define __NR_exit_group 94 -#define __NR_waitid 95 -#define __NR_set_tid_address 96 -#define __NR_unshare 97 -#define __NR_futex 98 -#define __NR_set_robust_list 99 -#define __NR_get_robust_list 100 -#define __NR_nanosleep 101 -#define __NR_getitimer 102 -#define __NR_setitimer 103 -#define __NR_kexec_load 104 -#define __NR_init_module 105 -#define __NR_delete_module 106 -#define __NR_timer_create 107 -#define __NR_timer_gettime 108 -#define __NR_timer_getoverrun 109 -#define __NR_timer_settime 110 -#define __NR_timer_delete 111 -#define __NR_clock_settime 112 -#define __NR_clock_gettime 113 -#define __NR_clock_getres 114 -#define __NR_clock_nanosleep 115 -#define __NR_syslog 116 -#define __NR_ptrace 117 -#define __NR_sched_setparam 118 -#define __NR_sched_setscheduler 119 -#define __NR_sched_getscheduler 120 -#define __NR_sched_getparam 121 -#define __NR_sched_setaffinity 122 -#define __NR_sched_getaffinity 123 -#define __NR_sched_yield 124 +#define __NR_io_setup 0 +#define __NR_io_destroy 1 +#define __NR_io_submit 2 +#define __NR_io_cancel 3 +#define __NR_io_getevents 4 +#define __NR_setxattr 5 +#define __NR_lsetxattr 6 +#define __NR_fsetxattr 7 +#define __NR_getxattr 8 +#define __NR_lgetxattr 9 +#define __NR_fgetxattr 10 +#define __NR_listxattr 11 +#define __NR_llistxattr 12 +#define __NR_flistxattr 13 +#define __NR_removexattr 14 +#define __NR_lremovexattr 15 +#define __NR_fremovexattr 16 +#define __NR_getcwd 17 +#define __NR_lookup_dcookie 18 +#define __NR_eventfd2 19 +#define __NR_epoll_create1 20 +#define __NR_epoll_ctl 21 +#define __NR_epoll_pwait 22 +#define __NR_dup 23 +#define __NR_dup3 24 +#define __NR_fcntl 25 +#define __NR_inotify_init1 26 +#define __NR_inotify_add_watch 27 +#define __NR_inotify_rm_watch 28 +#define __NR_ioctl 29 +#define __NR_ioprio_set 30 +#define __NR_ioprio_get 31 +#define __NR_flock 32 +#define __NR_mknodat 33 +#define __NR_mkdirat 34 +#define __NR_unlinkat 35 +#define __NR_symlinkat 36 +#define __NR_linkat 37 +#define __NR_renameat 38 +#define __NR_umount2 39 +#define __NR_mount 40 +#define __NR_pivot_root 41 +#define __NR_nfsservctl 42 +#define __NR_statfs 43 +#define __NR_fstatfs 44 +#define __NR_truncate 45 +#define __NR_ftruncate 46 +#define __NR_fallocate 47 +#define __NR_faccessat 48 +#define __NR_chdir 49 +#define __NR_fchdir 50 +#define __NR_chroot 51 +#define __NR_fchmod 52 +#define __NR_fchmodat 53 +#define __NR_fchownat 54 +#define __NR_fchown 55 +#define __NR_openat 56 +#define __NR_close 57 +#define __NR_vhangup 58 +#define __NR_pipe2 59 +#define __NR_quotactl 60 +#define __NR_getdents64 61 +#define __NR_lseek 62 +#define __NR_read 63 +#define __NR_write 64 +#define __NR_readv 65 +#define __NR_writev 66 +#define __NR_pread64 67 +#define __NR_pwrite64 68 +#define __NR_preadv 69 +#define __NR_pwritev 70 +#define __NR_sendfile 71 +#define __NR_pselect6 72 +#define __NR_ppoll 73 +#define __NR_signalfd4 74 +#define __NR_vmsplice 75 +#define __NR_splice 76 +#define __NR_tee 77 +#define __NR_readlinkat 78 +#define __NR_newfstatat 79 +#define __NR_fstat 80 +#define __NR_sync 81 +#define __NR_fsync 82 +#define __NR_fdatasync 83 +#define __NR_sync_file_range 84 +#define __NR_timerfd_create 85 +#define __NR_timerfd_settime 86 +#define __NR_timerfd_gettime 87 +#define __NR_utimensat 88 +#define __NR_acct 89 +#define __NR_capget 90 +#define __NR_capset 91 +#define __NR_personality 92 +#define __NR_exit 93 +#define __NR_exit_group 94 +#define __NR_waitid 95 +#define __NR_set_tid_address 96 +#define __NR_unshare 97 +#define __NR_futex 98 +#define __NR_set_robust_list 99 +#define __NR_get_robust_list 100 +#define __NR_nanosleep 101 +#define __NR_getitimer 102 +#define __NR_setitimer 103 +#define __NR_kexec_load 104 +#define __NR_init_module 105 +#define __NR_delete_module 106 +#define __NR_timer_create 107 +#define __NR_timer_gettime 108 +#define __NR_timer_getoverrun 109 +#define __NR_timer_settime 110 +#define __NR_timer_delete 111 +#define __NR_clock_settime 112 +#define __NR_clock_gettime 113 +#define __NR_clock_getres 114 +#define __NR_clock_nanosleep 115 +#define __NR_syslog 116 +#define __NR_ptrace 117 +#define __NR_sched_setparam 118 +#define __NR_sched_setscheduler 119 +#define __NR_sched_getscheduler 120 +#define __NR_sched_getparam 121 +#define __NR_sched_setaffinity 122 +#define __NR_sched_getaffinity 123 +#define __NR_sched_yield 124 #define __NR_sched_get_priority_max 125 #define __NR_sched_get_priority_min 126 -#define __NR_sched_rr_get_interval 127 -#define __NR_restart_syscall 128 -#define __NR_kill 129 -#define __NR_tkill 130 -#define __NR_tgkill 131 -#define __NR_sigaltstack 132 -#define __NR_rt_sigsuspend 133 -#define __NR_rt_sigaction 134 -#define __NR_rt_sigprocmask 135 -#define __NR_rt_sigpending 136 -#define __NR_rt_sigtimedwait 137 -#define __NR_rt_sigqueueinfo 138 -#define __NR_rt_sigreturn 139 -#define __NR_setpriority 140 -#define __NR_getpriority 141 -#define __NR_reboot 142 -#define __NR_setregid 143 -#define __NR_setgid 144 -#define __NR_setreuid 145 -#define __NR_setuid 146 -#define __NR_setresuid 147 -#define __NR_getresuid 148 -#define __NR_setresgid 149 -#define __NR_getresgid 150 -#define __NR_setfsuid 151 -#define __NR_setfsgid 152 -#define __NR_times 153 -#define __NR_setpgid 154 -#define __NR_getpgid 155 -#define __NR_getsid 156 -#define __NR_setsid 157 -#define __NR_getgroups 158 -#define __NR_setgroups 159 -#define __NR_uname 160 -#define __NR_sethostname 161 -#define __NR_setdomainname 162 -#define __NR_getrlimit 163 -#define __NR_setrlimit 164 -#define __NR_getrusage 165 -#define __NR_umask 166 -#define __NR_prctl 167 -#define __NR_getcpu 168 -#define __NR_gettimeofday 169 -#define __NR_settimeofday 170 -#define __NR_adjtimex 171 -#define __NR_getpid 172 -#define __NR_getppid 173 -#define __NR_getuid 174 -#define __NR_geteuid 175 -#define __NR_getgid 176 -#define __NR_getegid 177 -#define __NR_gettid 178 -#define __NR_sysinfo 179 -#define __NR_mq_open 180 -#define __NR_mq_unlink 181 -#define __NR_mq_timedsend 182 -#define __NR_mq_timedreceive 183 -#define __NR_mq_notify 184 -#define __NR_mq_getsetattr 185 -#define __NR_msgget 186 -#define __NR_msgctl 187 -#define __NR_msgrcv 188 -#define __NR_msgsnd 189 -#define __NR_semget 190 -#define __NR_semctl 191 -#define __NR_semtimedop 192 -#define __NR_semop 193 -#define __NR_shmget 194 -#define __NR_shmctl 195 -#define __NR_shmat 196 -#define __NR_shmdt 197 -#define __NR_socket 198 -#define __NR_socketpair 199 -#define __NR_bind 200 -#define __NR_listen 201 -#define __NR_accept 202 -#define __NR_connect 203 -#define __NR_getsockname 204 -#define __NR_getpeername 205 -#define __NR_sendto 206 -#define __NR_recvfrom 207 -#define __NR_setsockopt 208 -#define __NR_getsockopt 209 -#define __NR_shutdown 210 -#define __NR_sendmsg 211 -#define __NR_recvmsg 212 -#define __NR_readahead 213 -#define __NR_brk 214 -#define __NR_munmap 215 -#define __NR_mremap 216 -#define __NR_add_key 217 -#define __NR_request_key 218 -#define __NR_keyctl 219 -#define __NR_clone 220 -#define __NR_execve 221 -#define __NR_mmap 222 -#define __NR_fadvise64 223 -#define __NR_swapon 224 -#define __NR_swapoff 225 -#define __NR_mprotect 226 -#define __NR_msync 227 -#define __NR_mlock 228 -#define __NR_munlock 229 -#define __NR_mlockall 230 -#define __NR_munlockall 231 -#define __NR_mincore 232 -#define __NR_madvise 233 -#define __NR_remap_file_pages 234 -#define __NR_mbind 235 -#define __NR_get_mempolicy 236 -#define __NR_set_mempolicy 237 -#define __NR_migrate_pages 238 -#define __NR_move_pages 239 -#define __NR_rt_tgsigqueueinfo 240 -#define __NR_perf_event_open 241 -#define __NR_accept4 242 -#define __NR_recvmmsg 243 -#define __NR_wait4 260 -#define __NR_prlimit64 261 -#define __NR_fanotify_init 262 -#define __NR_fanotify_mark 263 -#define __NR_name_to_handle_at 264 -#define __NR_open_by_handle_at 265 -#define __NR_clock_adjtime 266 -#define __NR_syncfs 267 -#define __NR_setns 268 -#define __NR_sendmmsg 269 -#define __NR_process_vm_readv 270 -#define __NR_process_vm_writev 271 -#define __NR_kcmp 272 -#define __NR_finit_module 273 -#define __NR_sched_setattr 274 -#define __NR_sched_getattr 275 -#define __NR_renameat2 276 -#define __NR_seccomp 277 -#define __NR_getrandom 278 -#define __NR_memfd_create 279 -#define __NR_bpf 280 -#define __NR_execveat 281 -#define __NR_userfaultfd 282 -#define __NR_membarrier 283 -#define __NR_mlock2 284 -#define __NR_copy_file_range 285 -#define __NR_preadv2 286 -#define __NR_pwritev2 287 -#define __NR_pkey_mprotect 288 -#define __NR_pkey_alloc 289 -#define __NR_pkey_free 290 +#define __NR_sched_rr_get_interval 127 +#define __NR_restart_syscall 128 +#define __NR_kill 129 +#define __NR_tkill 130 +#define __NR_tgkill 131 +#define __NR_sigaltstack 132 +#define __NR_rt_sigsuspend 133 +#define __NR_rt_sigaction 134 +#define __NR_rt_sigprocmask 135 +#define __NR_rt_sigpending 136 +#define __NR_rt_sigtimedwait 137 +#define __NR_rt_sigqueueinfo 138 +#define __NR_rt_sigreturn 139 +#define __NR_setpriority 140 +#define __NR_getpriority 141 +#define __NR_reboot 142 +#define __NR_setregid 143 +#define __NR_setgid 144 +#define __NR_setreuid 145 +#define __NR_setuid 146 +#define __NR_setresuid 147 +#define __NR_getresuid 148 +#define __NR_setresgid 149 +#define __NR_getresgid 150 +#define __NR_setfsuid 151 +#define __NR_setfsgid 152 +#define __NR_times 153 +#define __NR_setpgid 154 +#define __NR_getpgid 155 +#define __NR_getsid 156 +#define __NR_setsid 157 +#define __NR_getgroups 158 +#define __NR_setgroups 159 +#define __NR_uname 160 +#define __NR_sethostname 161 +#define __NR_setdomainname 162 +#define __NR_getrlimit 163 +#define __NR_setrlimit 164 +#define __NR_getrusage 165 +#define __NR_umask 166 +#define __NR_prctl 167 +#define __NR_getcpu 168 +#define __NR_gettimeofday 169 +#define __NR_settimeofday 170 +#define __NR_adjtimex 171 +#define __NR_getpid 172 +#define __NR_getppid 173 +#define __NR_getuid 174 +#define __NR_geteuid 175 +#define __NR_getgid 176 +#define __NR_getegid 177 +#define __NR_gettid 178 +#define __NR_sysinfo 179 +#define __NR_mq_open 180 +#define __NR_mq_unlink 181 +#define __NR_mq_timedsend 182 +#define __NR_mq_timedreceive 183 +#define __NR_mq_notify 184 +#define __NR_mq_getsetattr 185 +#define __NR_msgget 186 +#define __NR_msgctl 187 +#define __NR_msgrcv 188 +#define __NR_msgsnd 189 +#define __NR_semget 190 +#define __NR_semctl 191 +#define __NR_semtimedop 192 +#define __NR_semop 193 +#define __NR_shmget 194 +#define __NR_shmctl 195 +#define __NR_shmat 196 +#define __NR_shmdt 197 +#define __NR_socket 198 +#define __NR_socketpair 199 +#define __NR_bind 200 +#define __NR_listen 201 +#define __NR_accept 202 +#define __NR_connect 203 +#define __NR_getsockname 204 +#define __NR_getpeername 205 +#define __NR_sendto 206 +#define __NR_recvfrom 207 +#define __NR_setsockopt 208 +#define __NR_getsockopt 209 +#define __NR_shutdown 210 +#define __NR_sendmsg 211 +#define __NR_recvmsg 212 +#define __NR_readahead 213 +#define __NR_brk 214 +#define __NR_munmap 215 +#define __NR_mremap 216 +#define __NR_add_key 217 +#define __NR_request_key 218 +#define __NR_keyctl 219 +#define __NR_clone 220 +#define __NR_execve 221 +#define __NR_mmap 222 +#define __NR_fadvise64 223 +#define __NR_swapon 224 +#define __NR_swapoff 225 +#define __NR_mprotect 226 +#define __NR_msync 227 +#define __NR_mlock 228 +#define __NR_munlock 229 +#define __NR_mlockall 230 +#define __NR_munlockall 231 +#define __NR_mincore 232 +#define __NR_madvise 233 +#define __NR_remap_file_pages 234 +#define __NR_mbind 235 +#define __NR_get_mempolicy 236 +#define __NR_set_mempolicy 237 +#define __NR_migrate_pages 238 +#define __NR_move_pages 239 +#define __NR_rt_tgsigqueueinfo 240 +#define __NR_perf_event_open 241 +#define __NR_accept4 242 +#define __NR_recvmmsg 243 +#define __NR_wait4 260 +#define __NR_prlimit64 261 +#define __NR_fanotify_init 262 +#define __NR_fanotify_mark 263 +#define __NR_name_to_handle_at 264 +#define __NR_open_by_handle_at 265 +#define __NR_clock_adjtime 266 +#define __NR_syncfs 267 +#define __NR_setns 268 +#define __NR_sendmmsg 269 +#define __NR_process_vm_readv 270 +#define __NR_process_vm_writev 271 +#define __NR_kcmp 272 +#define __NR_finit_module 273 +#define __NR_sched_setattr 274 +#define __NR_sched_getattr 275 +#define __NR_renameat2 276 +#define __NR_seccomp 277 +#define __NR_getrandom 278 +#define __NR_memfd_create 279 +#define __NR_bpf 280 +#define __NR_execveat 281 +#define __NR_userfaultfd 282 +#define __NR_membarrier 283 +#define __NR_mlock2 284 +#define __NR_copy_file_range 285 +#define __NR_preadv2 286 +#define __NR_pwritev2 287 +#define __NR_pkey_mprotect 288 +#define __NR_pkey_alloc 289 +#define __NR_pkey_free 290 +#define __NR_statx 291 +#define __NR_io_pgetevents 292 +#define __NR_rseq 293 +#define __NR_kexec_file_load 294 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 -#define SYS_io_setup 0 -#define SYS_io_destroy 1 -#define SYS_io_submit 2 -#define SYS_io_cancel 3 -#define SYS_io_getevents 4 -#define SYS_setxattr 5 -#define SYS_lsetxattr 6 -#define SYS_fsetxattr 7 -#define SYS_getxattr 8 -#define SYS_lgetxattr 9 -#define SYS_fgetxattr 10 -#define SYS_listxattr 11 -#define SYS_llistxattr 12 -#define SYS_flistxattr 13 -#define SYS_removexattr 14 -#define SYS_lremovexattr 15 -#define SYS_fremovexattr 16 -#define SYS_getcwd 17 -#define SYS_lookup_dcookie 18 -#define SYS_eventfd2 19 -#define SYS_epoll_create1 20 -#define SYS_epoll_ctl 21 -#define SYS_epoll_pwait 22 -#define SYS_dup 23 -#define SYS_dup3 24 -#define SYS_fcntl 25 -#define SYS_inotify_init1 26 -#define SYS_inotify_add_watch 27 -#define SYS_inotify_rm_watch 28 -#define SYS_ioctl 29 -#define SYS_ioprio_set 30 -#define SYS_ioprio_get 31 -#define SYS_flock 32 -#define SYS_mknodat 33 -#define SYS_mkdirat 34 -#define SYS_unlinkat 35 -#define SYS_symlinkat 36 -#define SYS_linkat 37 -#define SYS_renameat 38 -#define SYS_umount2 39 -#define SYS_mount 40 -#define SYS_pivot_root 41 -#define SYS_nfsservctl 42 -#define SYS_statfs 43 -#define SYS_fstatfs 44 -#define SYS_truncate 45 -#define SYS_ftruncate 46 -#define SYS_fallocate 47 -#define SYS_faccessat 48 -#define SYS_chdir 49 -#define SYS_fchdir 50 -#define SYS_chroot 51 -#define SYS_fchmod 52 -#define SYS_fchmodat 53 -#define SYS_fchownat 54 -#define SYS_fchown 55 -#define SYS_openat 56 -#define SYS_close 57 -#define SYS_vhangup 58 -#define SYS_pipe2 59 -#define SYS_quotactl 60 -#define SYS_getdents64 61 -#define SYS_lseek 62 -#define SYS_read 63 -#define SYS_write 64 -#define SYS_readv 65 -#define SYS_writev 66 -#define SYS_pread64 67 -#define SYS_pwrite64 68 -#define SYS_preadv 69 -#define SYS_pwritev 70 -#define SYS_sendfile 71 -#define SYS_pselect6 72 -#define SYS_ppoll 73 -#define SYS_signalfd4 74 -#define SYS_vmsplice 75 -#define SYS_splice 76 -#define SYS_tee 77 -#define SYS_readlinkat 78 -#define SYS_newfstatat 79 -#define SYS_fstat 80 -#define SYS_sync 81 -#define SYS_fsync 82 -#define SYS_fdatasync 83 -#define SYS_sync_file_range 84 -#define SYS_timerfd_create 85 -#define SYS_timerfd_settime 86 -#define SYS_timerfd_gettime 87 -#define SYS_utimensat 88 -#define SYS_acct 89 -#define SYS_capget 90 -#define SYS_capset 91 -#define SYS_personality 92 -#define SYS_exit 93 -#define SYS_exit_group 94 -#define SYS_waitid 95 -#define SYS_set_tid_address 96 -#define SYS_unshare 97 -#define SYS_futex 98 -#define SYS_set_robust_list 99 -#define SYS_get_robust_list 100 -#define SYS_nanosleep 101 -#define SYS_getitimer 102 -#define SYS_setitimer 103 -#define SYS_kexec_load 104 -#define SYS_init_module 105 -#define SYS_delete_module 106 -#define SYS_timer_create 107 -#define SYS_timer_gettime 108 -#define SYS_timer_getoverrun 109 -#define SYS_timer_settime 110 -#define SYS_timer_delete 111 -#define SYS_clock_settime 112 -#define SYS_clock_gettime 113 -#define SYS_clock_getres 114 -#define SYS_clock_nanosleep 115 -#define SYS_syslog 116 -#define SYS_ptrace 117 -#define SYS_sched_setparam 118 -#define SYS_sched_setscheduler 119 -#define SYS_sched_getscheduler 120 -#define SYS_sched_getparam 121 -#define SYS_sched_setaffinity 122 -#define SYS_sched_getaffinity 123 -#define SYS_sched_yield 124 +#define SYS_io_setup 0 +#define SYS_io_destroy 1 +#define SYS_io_submit 2 +#define SYS_io_cancel 3 +#define SYS_io_getevents 4 +#define SYS_setxattr 5 +#define SYS_lsetxattr 6 +#define SYS_fsetxattr 7 +#define SYS_getxattr 8 +#define SYS_lgetxattr 9 +#define SYS_fgetxattr 10 +#define SYS_listxattr 11 +#define SYS_llistxattr 12 +#define SYS_flistxattr 13 +#define SYS_removexattr 14 +#define SYS_lremovexattr 15 +#define SYS_fremovexattr 16 +#define SYS_getcwd 17 +#define SYS_lookup_dcookie 18 +#define SYS_eventfd2 19 +#define SYS_epoll_create1 20 +#define SYS_epoll_ctl 21 +#define SYS_epoll_pwait 22 +#define SYS_dup 23 +#define SYS_dup3 24 +#define SYS_fcntl 25 +#define SYS_inotify_init1 26 +#define SYS_inotify_add_watch 27 +#define SYS_inotify_rm_watch 28 +#define SYS_ioctl 29 +#define SYS_ioprio_set 30 +#define SYS_ioprio_get 31 +#define SYS_flock 32 +#define SYS_mknodat 33 +#define SYS_mkdirat 34 +#define SYS_unlinkat 35 +#define SYS_symlinkat 36 +#define SYS_linkat 37 +#define SYS_renameat 38 +#define SYS_umount2 39 +#define SYS_mount 40 +#define SYS_pivot_root 41 +#define SYS_nfsservctl 42 +#define SYS_statfs 43 +#define SYS_fstatfs 44 +#define SYS_truncate 45 +#define SYS_ftruncate 46 +#define SYS_fallocate 47 +#define SYS_faccessat 48 +#define SYS_chdir 49 +#define SYS_fchdir 50 +#define SYS_chroot 51 +#define SYS_fchmod 52 +#define SYS_fchmodat 53 +#define SYS_fchownat 54 +#define SYS_fchown 55 +#define SYS_openat 56 +#define SYS_close 57 +#define SYS_vhangup 58 +#define SYS_pipe2 59 +#define SYS_quotactl 60 +#define SYS_getdents64 61 +#define SYS_lseek 62 +#define SYS_read 63 +#define SYS_write 64 +#define SYS_readv 65 +#define SYS_writev 66 +#define SYS_pread64 67 +#define SYS_pwrite64 68 +#define SYS_preadv 69 +#define SYS_pwritev 70 +#define SYS_sendfile 71 +#define SYS_pselect6 72 +#define SYS_ppoll 73 +#define SYS_signalfd4 74 +#define SYS_vmsplice 75 +#define SYS_splice 76 +#define SYS_tee 77 +#define SYS_readlinkat 78 +#define SYS_newfstatat 79 +#define SYS_fstat 80 +#define SYS_sync 81 +#define SYS_fsync 82 +#define SYS_fdatasync 83 +#define SYS_sync_file_range 84 +#define SYS_timerfd_create 85 +#define SYS_timerfd_settime 86 +#define SYS_timerfd_gettime 87 +#define SYS_utimensat 88 +#define SYS_acct 89 +#define SYS_capget 90 +#define SYS_capset 91 +#define SYS_personality 92 +#define SYS_exit 93 +#define SYS_exit_group 94 +#define SYS_waitid 95 +#define SYS_set_tid_address 96 +#define SYS_unshare 97 +#define SYS_futex 98 +#define SYS_set_robust_list 99 +#define SYS_get_robust_list 100 +#define SYS_nanosleep 101 +#define SYS_getitimer 102 +#define SYS_setitimer 103 +#define SYS_kexec_load 104 +#define SYS_init_module 105 +#define SYS_delete_module 106 +#define SYS_timer_create 107 +#define SYS_timer_gettime 108 +#define SYS_timer_getoverrun 109 +#define SYS_timer_settime 110 +#define SYS_timer_delete 111 +#define SYS_clock_settime 112 +#define SYS_clock_gettime 113 +#define SYS_clock_getres 114 +#define SYS_clock_nanosleep 115 +#define SYS_syslog 116 +#define SYS_ptrace 117 +#define SYS_sched_setparam 118 +#define SYS_sched_setscheduler 119 +#define SYS_sched_getscheduler 120 +#define SYS_sched_getparam 121 +#define SYS_sched_setaffinity 122 +#define SYS_sched_getaffinity 123 +#define SYS_sched_yield 124 #define SYS_sched_get_priority_max 125 #define SYS_sched_get_priority_min 126 -#define SYS_sched_rr_get_interval 127 -#define SYS_restart_syscall 128 -#define SYS_kill 129 -#define SYS_tkill 130 -#define SYS_tgkill 131 -#define SYS_sigaltstack 132 -#define SYS_rt_sigsuspend 133 -#define SYS_rt_sigaction 134 -#define SYS_rt_sigprocmask 135 -#define SYS_rt_sigpending 136 -#define SYS_rt_sigtimedwait 137 -#define SYS_rt_sigqueueinfo 138 -#define SYS_rt_sigreturn 139 -#define SYS_setpriority 140 -#define SYS_getpriority 141 -#define SYS_reboot 142 -#define SYS_setregid 143 -#define SYS_setgid 144 -#define SYS_setreuid 145 -#define SYS_setuid 146 -#define SYS_setresuid 147 -#define SYS_getresuid 148 -#define SYS_setresgid 149 -#define SYS_getresgid 150 -#define SYS_setfsuid 151 -#define SYS_setfsgid 152 -#define SYS_times 153 -#define SYS_setpgid 154 -#define SYS_getpgid 155 -#define SYS_getsid 156 -#define SYS_setsid 157 -#define SYS_getgroups 158 -#define SYS_setgroups 159 -#define SYS_uname 160 -#define SYS_sethostname 161 -#define SYS_setdomainname 162 -#define SYS_getrlimit 163 -#define SYS_setrlimit 164 -#define SYS_getrusage 165 -#define SYS_umask 166 -#define SYS_prctl 167 -#define SYS_getcpu 168 -#define SYS_gettimeofday 169 -#define SYS_settimeofday 170 -#define SYS_adjtimex 171 -#define SYS_getpid 172 -#define SYS_getppid 173 -#define SYS_getuid 174 -#define SYS_geteuid 175 -#define SYS_getgid 176 -#define SYS_getegid 177 -#define SYS_gettid 178 -#define SYS_sysinfo 179 -#define SYS_mq_open 180 -#define SYS_mq_unlink 181 -#define SYS_mq_timedsend 182 -#define SYS_mq_timedreceive 183 -#define SYS_mq_notify 184 -#define SYS_mq_getsetattr 185 -#define SYS_msgget 186 -#define SYS_msgctl 187 -#define SYS_msgrcv 188 -#define SYS_msgsnd 189 -#define SYS_semget 190 -#define SYS_semctl 191 -#define SYS_semtimedop 192 -#define SYS_semop 193 -#define SYS_shmget 194 -#define SYS_shmctl 195 -#define SYS_shmat 196 -#define SYS_shmdt 197 -#define SYS_socket 198 -#define SYS_socketpair 199 -#define SYS_bind 200 -#define SYS_listen 201 -#define SYS_accept 202 -#define SYS_connect 203 -#define SYS_getsockname 204 -#define SYS_getpeername 205 -#define SYS_sendto 206 -#define SYS_recvfrom 207 -#define SYS_setsockopt 208 -#define SYS_getsockopt 209 -#define SYS_shutdown 210 -#define SYS_sendmsg 211 -#define SYS_recvmsg 212 -#define SYS_readahead 213 -#define SYS_brk 214 -#define SYS_munmap 215 -#define SYS_mremap 216 -#define SYS_add_key 217 -#define SYS_request_key 218 -#define SYS_keyctl 219 -#define SYS_clone 220 -#define SYS_execve 221 -#define SYS_mmap 222 -#define SYS_fadvise64 223 -#define SYS_swapon 224 -#define SYS_swapoff 225 -#define SYS_mprotect 226 -#define SYS_msync 227 -#define SYS_mlock 228 -#define SYS_munlock 229 -#define SYS_mlockall 230 -#define SYS_munlockall 231 -#define SYS_mincore 232 -#define SYS_madvise 233 -#define SYS_remap_file_pages 234 -#define SYS_mbind 235 -#define SYS_get_mempolicy 236 -#define SYS_set_mempolicy 237 -#define SYS_migrate_pages 238 -#define SYS_move_pages 239 -#define SYS_rt_tgsigqueueinfo 240 -#define SYS_perf_event_open 241 -#define SYS_accept4 242 -#define SYS_recvmmsg 243 -#define SYS_wait4 260 -#define SYS_prlimit64 261 -#define SYS_fanotify_init 262 -#define SYS_fanotify_mark 263 -#define SYS_name_to_handle_at 264 -#define SYS_open_by_handle_at 265 -#define SYS_clock_adjtime 266 -#define SYS_syncfs 267 -#define SYS_setns 268 -#define SYS_sendmmsg 269 -#define SYS_process_vm_readv 270 -#define SYS_process_vm_writev 271 -#define SYS_kcmp 272 -#define SYS_finit_module 273 -#define SYS_sched_setattr 274 -#define SYS_sched_getattr 275 -#define SYS_renameat2 276 -#define SYS_seccomp 277 -#define SYS_getrandom 278 -#define SYS_memfd_create 279 -#define SYS_bpf 280 -#define SYS_execveat 281 -#define SYS_userfaultfd 282 -#define SYS_membarrier 283 -#define SYS_mlock2 284 -#define SYS_copy_file_range 285 -#define SYS_preadv2 286 -#define SYS_pwritev2 287 -#define SYS_pkey_mprotect 288 -#define SYS_pkey_alloc 289 -#define SYS_pkey_free 290 +#define SYS_sched_rr_get_interval 127 +#define SYS_restart_syscall 128 +#define SYS_kill 129 +#define SYS_tkill 130 +#define SYS_tgkill 131 +#define SYS_sigaltstack 132 +#define SYS_rt_sigsuspend 133 +#define SYS_rt_sigaction 134 +#define SYS_rt_sigprocmask 135 +#define SYS_rt_sigpending 136 +#define SYS_rt_sigtimedwait 137 +#define SYS_rt_sigqueueinfo 138 +#define SYS_rt_sigreturn 139 +#define SYS_setpriority 140 +#define SYS_getpriority 141 +#define SYS_reboot 142 +#define SYS_setregid 143 +#define SYS_setgid 144 +#define SYS_setreuid 145 +#define SYS_setuid 146 +#define SYS_setresuid 147 +#define SYS_getresuid 148 +#define SYS_setresgid 149 +#define SYS_getresgid 150 +#define SYS_setfsuid 151 +#define SYS_setfsgid 152 +#define SYS_times 153 +#define SYS_setpgid 154 +#define SYS_getpgid 155 +#define SYS_getsid 156 +#define SYS_setsid 157 +#define SYS_getgroups 158 +#define SYS_setgroups 159 +#define SYS_uname 160 +#define SYS_sethostname 161 +#define SYS_setdomainname 162 +#define SYS_getrlimit 163 +#define SYS_setrlimit 164 +#define SYS_getrusage 165 +#define SYS_umask 166 +#define SYS_prctl 167 +#define SYS_getcpu 168 +#define SYS_gettimeofday 169 +#define SYS_settimeofday 170 +#define SYS_adjtimex 171 +#define SYS_getpid 172 +#define SYS_getppid 173 +#define SYS_getuid 174 +#define SYS_geteuid 175 +#define SYS_getgid 176 +#define SYS_getegid 177 +#define SYS_gettid 178 +#define SYS_sysinfo 179 +#define SYS_mq_open 180 +#define SYS_mq_unlink 181 +#define SYS_mq_timedsend 182 +#define SYS_mq_timedreceive 183 +#define SYS_mq_notify 184 +#define SYS_mq_getsetattr 185 +#define SYS_msgget 186 +#define SYS_msgctl 187 +#define SYS_msgrcv 188 +#define SYS_msgsnd 189 +#define SYS_semget 190 +#define SYS_semctl 191 +#define SYS_semtimedop 192 +#define SYS_semop 193 +#define SYS_shmget 194 +#define SYS_shmctl 195 +#define SYS_shmat 196 +#define SYS_shmdt 197 +#define SYS_socket 198 +#define SYS_socketpair 199 +#define SYS_bind 200 +#define SYS_listen 201 +#define SYS_accept 202 +#define SYS_connect 203 +#define SYS_getsockname 204 +#define SYS_getpeername 205 +#define SYS_sendto 206 +#define SYS_recvfrom 207 +#define SYS_setsockopt 208 +#define SYS_getsockopt 209 +#define SYS_shutdown 210 +#define SYS_sendmsg 211 +#define SYS_recvmsg 212 +#define SYS_readahead 213 +#define SYS_brk 214 +#define SYS_munmap 215 +#define SYS_mremap 216 +#define SYS_add_key 217 +#define SYS_request_key 218 +#define SYS_keyctl 219 +#define SYS_clone 220 +#define SYS_execve 221 +#define SYS_mmap 222 +#define SYS_fadvise64 223 +#define SYS_swapon 224 +#define SYS_swapoff 225 +#define SYS_mprotect 226 +#define SYS_msync 227 +#define SYS_mlock 228 +#define SYS_munlock 229 +#define SYS_mlockall 230 +#define SYS_munlockall 231 +#define SYS_mincore 232 +#define SYS_madvise 233 +#define SYS_remap_file_pages 234 +#define SYS_mbind 235 +#define SYS_get_mempolicy 236 +#define SYS_set_mempolicy 237 +#define SYS_migrate_pages 238 +#define SYS_move_pages 239 +#define SYS_rt_tgsigqueueinfo 240 +#define SYS_perf_event_open 241 +#define SYS_accept4 242 +#define SYS_recvmmsg 243 +#define SYS_wait4 260 +#define SYS_prlimit64 261 +#define SYS_fanotify_init 262 +#define SYS_fanotify_mark 263 +#define SYS_name_to_handle_at 264 +#define SYS_open_by_handle_at 265 +#define SYS_clock_adjtime 266 +#define SYS_syncfs 267 +#define SYS_setns 268 +#define SYS_sendmmsg 269 +#define SYS_process_vm_readv 270 +#define SYS_process_vm_writev 271 +#define SYS_kcmp 272 +#define SYS_finit_module 273 +#define SYS_sched_setattr 274 +#define SYS_sched_getattr 275 +#define SYS_renameat2 276 +#define SYS_seccomp 277 +#define SYS_getrandom 278 +#define SYS_memfd_create 279 +#define SYS_bpf 280 +#define SYS_execveat 281 +#define SYS_userfaultfd 282 +#define SYS_membarrier 283 +#define SYS_mlock2 284 +#define SYS_copy_file_range 285 +#define SYS_preadv2 286 +#define SYS_pwritev2 287 +#define SYS_pkey_mprotect 288 +#define SYS_pkey_alloc 289 +#define SYS_pkey_free 290 +#define SYS_statx 291 +#define SYS_io_pgetevents 292 +#define SYS_rseq 293 +#define SYS_kexec_file_load 294 +#define SYS_pidfd_send_signal 424 +#define SYS_io_uring_setup 425 +#define SYS_io_uring_enter 426 +#define SYS_io_uring_register 427 +#define SYS_open_tree 428 +#define SYS_move_mount 429 +#define SYS_fsopen 430 +#define SYS_fsconfig 431 +#define SYS_fsmount 432 +#define SYS_fspick 433 +#define SYS_pidfd_open 434 +#define SYS_clone3 435 diff --git a/thirdparty/open_source/musl/libc/arch/arm/bits/alltypes.h b/thirdparty/open_source/musl/libc/arch/arm/bits/alltypes.h index 41b4204..44a823a 100644 --- a/thirdparty/open_source/musl/libc/arch/arm/bits/alltypes.h +++ b/thirdparty/open_source/musl/libc/arch/arm/bits/alltypes.h @@ -1,31 +1,16 @@ -#define _Addr int +#define _REDIR_TIME64 0 +#define _Addr int #define _Int64 long long -#define _Reg int +#define _Reg int -#define __LITTLE_ENDIAN 1234 -#define __BIG_ENDIAN 4321 -#define __USE_TIME_BITS64 1 - -#ifndef __BYTE_ORDER -#if __AARCH64EB__ +#if __ARMEB__ #define __BYTE_ORDER 4321 #else #define __BYTE_ORDER 1234 #endif -#endif #define __LONG_MAX 0x7fffffffL -#if defined(__NEED_va_list) && !defined(__DEFINED_va_list) -typedef __builtin_va_list va_list; -#define __DEFINED_va_list -#endif - -#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list) -typedef __builtin_va_list __isoc_va_list; -#define __DEFINED___isoc_va_list -#endif - #ifndef __cplusplus #if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t) typedef unsigned wchar_t; @@ -44,100 +29,15 @@ typedef double double_t; #define __DEFINED_double_t #endif + #if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t) -typedef struct { - long long __ll; - long double __ld; -} max_align_t; +typedef struct { long long __ll; long double __ld; } max_align_t; #define __DEFINED_max_align_t #endif -#if defined(__NEED_time_t) && !defined(__DEFINED_time_t) -typedef long time_t; -#define __DEFINED_time_t -#endif - -#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t) -typedef long suseconds_t; -#define __DEFINED_suseconds_t -#endif - -#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t) -typedef struct { - union { - int __i[9]; - volatile int __vi[9]; - unsigned __s[9]; - } __u; -} pthread_attr_t; -#define __DEFINED_pthread_attr_t -#endif - -#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t) -typedef struct { - union { - int __i[6]; - volatile int __vi[6]; - volatile void *volatile __p[6]; - } __u; -} pthread_mutex_t; -#define __DEFINED_pthread_mutex_t -#endif - -#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t) -typedef struct { - union { - int __i[6]; - volatile int __vi[6]; - volatile void *volatile __p[6]; - } __u; -} mtx_t; -#define __DEFINED_mtx_t -#endif - -#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t) -typedef struct { - union { - int __i[12]; - volatile int __vi[12]; - void *__p[12]; - } __u; -} pthread_cond_t; -#define __DEFINED_pthread_cond_t -#endif - -#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t) -typedef struct { - union { - int __i[12]; - volatile int __vi[12]; - void *__p[12]; - } __u; -} cnd_t; -#define __DEFINED_cnd_t -#endif - -#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t) -typedef struct { - union { - int __i[8]; - volatile int __vi[8]; - void *__p[8]; - } __u; -} pthread_rwlock_t; -#define __DEFINED_pthread_rwlock_t -#endif - -#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t) -typedef struct { - union { - int __i[5]; - volatile int __vi[5]; - void *__p[5]; - } __u; -} pthread_barrier_t; -#define __DEFINED_pthread_barrier_t -#endif +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __USE_TIME_BITS64 1 #if defined(__NEED_size_t) && !defined(__DEFINED_size_t) typedef unsigned _Addr size_t; @@ -174,28 +74,39 @@ typedef _Reg register_t; #define __DEFINED_register_t #endif +#if defined(__NEED_time_t) && !defined(__DEFINED_time_t) +typedef long time_t; +#define __DEFINED_time_t +#endif + +#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t) +typedef long suseconds_t; +#define __DEFINED_suseconds_t +#endif + + #if defined(__NEED_int8_t) && !defined(__DEFINED_int8_t) typedef signed char int8_t; #define __DEFINED_int8_t #endif #if defined(__NEED_int16_t) && !defined(__DEFINED_int16_t) -typedef short int16_t; +typedef signed short int16_t; #define __DEFINED_int16_t #endif #if defined(__NEED_int32_t) && !defined(__DEFINED_int32_t) -typedef int int32_t; +typedef signed int int32_t; #define __DEFINED_int32_t #endif #if defined(__NEED_int64_t) && !defined(__DEFINED_int64_t) -typedef _Int64 int64_t; +typedef signed _Int64 int64_t; #define __DEFINED_int64_t #endif #if defined(__NEED_intmax_t) && !defined(__DEFINED_intmax_t) -typedef _Int64 intmax_t; +typedef signed _Int64 intmax_t; #define __DEFINED_intmax_t #endif @@ -229,6 +140,7 @@ typedef unsigned _Int64 uintmax_t; #define __DEFINED_uintmax_t #endif + #if defined(__NEED_mode_t) && !defined(__DEFINED_mode_t) typedef unsigned mode_t; #define __DEFINED_mode_t @@ -274,6 +186,7 @@ typedef unsigned _Int64 fsfilcnt_t; #define __DEFINED_fsfilcnt_t #endif + #if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t) typedef unsigned wint_t; #define __DEFINED_wint_t @@ -284,8 +197,9 @@ typedef unsigned long wctype_t; #define __DEFINED_wctype_t #endif + #if defined(__NEED_timer_t) && !defined(__DEFINED_timer_t) -typedef void *timer_t; +typedef void * timer_t; #define __DEFINED_timer_t #endif @@ -300,21 +214,16 @@ typedef long clock_t; #endif #if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval) -struct timeval { - time_t tv_sec; - suseconds_t tv_usec; -}; +struct timeval { time_t tv_sec; suseconds_t tv_usec; }; #define __DEFINED_struct_timeval #endif #if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec) -struct timespec { - time_t tv_sec; - long tv_nsec; -}; +struct timespec { time_t tv_sec; long tv_nsec; }; #define __DEFINED_struct_timespec #endif + #if defined(__NEED_pid_t) && !defined(__DEFINED_pid_t) typedef int pid_t; #define __DEFINED_pid_t @@ -345,6 +254,7 @@ typedef unsigned useconds_t; #define __DEFINED_useconds_t #endif + #ifdef __cplusplus #if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t) typedef unsigned long pthread_t; @@ -353,7 +263,7 @@ typedef unsigned long pthread_t; #else #if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t) -typedef struct __pthread *pthread_t; +typedef struct __pthread * pthread_t; #define __DEFINED_pthread_t #endif @@ -374,65 +284,72 @@ typedef int pthread_spinlock_t; #endif #if defined(__NEED_pthread_mutexattr_t) && !defined(__DEFINED_pthread_mutexattr_t) -typedef struct { - unsigned __attr; -} pthread_mutexattr_t; +typedef struct { unsigned __attr; } pthread_mutexattr_t; #define __DEFINED_pthread_mutexattr_t #endif #if defined(__NEED_pthread_condattr_t) && !defined(__DEFINED_pthread_condattr_t) -typedef struct { - unsigned __attr; -} pthread_condattr_t; +typedef struct { unsigned __attr; } pthread_condattr_t; #define __DEFINED_pthread_condattr_t #endif #if defined(__NEED_pthread_barrierattr_t) && !defined(__DEFINED_pthread_barrierattr_t) -typedef struct { - unsigned __attr; -} pthread_barrierattr_t; +typedef struct { unsigned __attr; } pthread_barrierattr_t; #define __DEFINED_pthread_barrierattr_t #endif #if defined(__NEED_pthread_rwlockattr_t) && !defined(__DEFINED_pthread_rwlockattr_t) -typedef struct { - unsigned __attr[2]; -} pthread_rwlockattr_t; +typedef struct { unsigned __attr[2]; } pthread_rwlockattr_t; #define __DEFINED_pthread_rwlockattr_t #endif + +#if defined(__NEED_struct__IO_FILE) && !defined(__DEFINED_struct__IO_FILE) +struct _IO_FILE { char __x; }; +#define __DEFINED_struct__IO_FILE +#endif + #if defined(__NEED_FILE) && !defined(__DEFINED_FILE) typedef struct _IO_FILE FILE; #define __DEFINED_FILE #endif + +#if defined(__NEED_va_list) && !defined(__DEFINED_va_list) +typedef __builtin_va_list va_list; +#define __DEFINED_va_list +#endif + +#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list) +typedef __builtin_va_list __isoc_va_list; +#define __DEFINED___isoc_va_list +#endif + + #if defined(__NEED_mbstate_t) && !defined(__DEFINED_mbstate_t) -typedef struct __mbstate_t { - unsigned __opaque1, __opaque2; -} mbstate_t; +typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t; #define __DEFINED_mbstate_t #endif + #if defined(__NEED_locale_t) && !defined(__DEFINED_locale_t) -typedef struct __locale_struct *locale_t; +typedef struct __locale_struct * locale_t; #define __DEFINED_locale_t #endif + #if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t) -typedef struct __sigset_t { - unsigned long __bits[128 / sizeof(long)]; -} sigset_t; +typedef struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t; #define __DEFINED_sigset_t #endif + #if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec) -struct iovec { - void *iov_base; - size_t iov_len; -}; +struct iovec { void *iov_base; size_t iov_len; }; #define __DEFINED_struct_iovec #endif + #if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t) typedef unsigned socklen_t; #define __DEFINED_socklen_t @@ -443,6 +360,43 @@ typedef unsigned short sa_family_t; #define __DEFINED_sa_family_t #endif + +#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t) +typedef struct { union { int __i[sizeof(long)==8?14:9]; volatile int __vi[sizeof(long)==8?14:9]; unsigned long __s[sizeof(long)==8?7:9]; } __u; } pthread_attr_t; +#define __DEFINED_pthread_attr_t +#endif + +#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t) +typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } pthread_mutex_t; +#define __DEFINED_pthread_mutex_t +#endif + +#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t) +typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } mtx_t; +#define __DEFINED_mtx_t +#endif + +#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t) +typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } pthread_cond_t; +#define __DEFINED_pthread_cond_t +#endif + +#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t) +typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } cnd_t; +#define __DEFINED_cnd_t +#endif + +#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t) +typedef struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t; +#define __DEFINED_pthread_rwlock_t +#endif + +#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t) +typedef struct { union { int __i[sizeof(long)==8?8:5]; volatile int __vi[sizeof(long)==8?8:5]; void *__p[sizeof(long)==8?4:5]; } __u; } pthread_barrier_t; +#define __DEFINED_pthread_barrier_t +#endif + + #undef _Addr #undef _Int64 #undef _Reg diff --git a/thirdparty/open_source/musl/libc/arch/arm/bits/syscall.h b/thirdparty/open_source/musl/libc/arch/arm/bits/syscall.h index 6b128e5..5afaa3e 100644 --- a/thirdparty/open_source/musl/libc/arch/arm/bits/syscall.h +++ b/thirdparty/open_source/musl/libc/arch/arm/bits/syscall.h @@ -1,715 +1,790 @@ -#define __NR_restart_syscall 0 -#define __NR_exit 1 -#define __NR_fork 2 -#define __NR_read 3 -#define __NR_write 4 -#define __NR_open 5 -#define __NR_close 6 -#define __NR_creat 8 -#define __NR_link 9 -#define __NR_unlink 10 -#define __NR_execve 11 -#define __NR_chdir 12 -#define __NR_mknod 14 -#define __NR_chmod 15 -#define __NR_lchown 16 -#define __NR_lseek 19 -#define __NR_getpid 20 -#define __NR_mount 21 -#define __NR_setuid 23 -#define __NR_getuid 24 -#define __NR_ptrace 26 -#define __NR_pause 29 -#define __NR_access 33 -#define __NR_nice 34 -#define __NR_sync 36 -#define __NR_kill 37 -#define __NR_rename 38 -#define __NR_mkdir 39 -#define __NR_rmdir 40 -#define __NR_dup 41 -#define __NR_pipe 42 -#define __NR_times 43 -#define __NR_brk 45 -#define __NR_setgid 46 -#define __NR_getgid 47 -#define __NR_geteuid 49 -#define __NR_getegid 50 -#define __NR_acct 51 -#define __NR_umount2 52 -#define __NR_ioctl 54 -#define __NR_fcntl 55 -#define __NR_setpgid 57 -#define __NR_umask 60 -#define __NR_chroot 61 -#define __NR_ustat 62 -#define __NR_dup2 63 -#define __NR_getppid 64 -#define __NR_getpgrp 65 -#define __NR_setsid 66 -#define __NR_sigaction 67 -#define __NR_setreuid 70 -#define __NR_setregid 71 -#define __NR_sigsuspend 72 -#define __NR_sigpending 73 -#define __NR_sethostname 74 -#define __NR_setrlimit 75 -#define __NR_getrusage 77 -#define __NR_gettimeofday 78 -#define __NR_settimeofday 79 -#define __NR_getgroups 80 -#define __NR_setgroups 81 -#define __NR_symlink 83 -#define __NR_readlink 85 -#define __NR_uselib 86 -#define __NR_swapon 87 -#define __NR_reboot 88 -#define __NR_munmap 91 -#define __NR_truncate 92 -#define __NR_ftruncate 93 -#define __NR_fchmod 94 -#define __NR_fchown 95 -#define __NR_getpriority 96 -#define __NR_setpriority 97 -#define __NR_statfs 99 -#define __NR_fstatfs 100 -#define __NR_syslog 103 -#define __NR_setitimer 104 -#define __NR_getitimer 105 -#define __NR_stat 106 -#define __NR_lstat 107 -#define __NR_fstat 108 -#define __NR_vhangup 111 -#define __NR_wait4 114 -#define __NR_swapoff 115 -#define __NR_sysinfo 116 -#define __NR_fsync 118 -#define __NR_sigreturn 119 -#define __NR_clone 120 -#define __NR_setdomainname 121 -#define __NR_uname 122 -#define __NR_adjtimex 124 -#define __NR_mprotect 125 -#define __NR_sigprocmask 126 -#define __NR_init_module 128 -#define __NR_delete_module 129 -#define __NR_quotactl 131 -#define __NR_getpgid 132 -#define __NR_fchdir 133 -#define __NR_bdflush 134 -#define __NR_sysfs 135 -#define __NR_personality 136 -#define __NR_setfsuid 138 -#define __NR_setfsgid 139 -#define __NR__llseek 140 -#define __NR_getdents 141 -#define __NR__newselect 142 -#define __NR_flock 143 -#define __NR_msync 144 -#define __NR_readv 145 -#define __NR_writev 146 -#define __NR_getsid 147 -#define __NR_fdatasync 148 -#define __NR__sysctl 149 -#define __NR_mlock 150 -#define __NR_munlock 151 -#define __NR_mlockall 152 -#define __NR_munlockall 153 -#define __NR_sched_setparam 154 -#define __NR_sched_getparam 155 -#define __NR_sched_setscheduler 156 -#define __NR_sched_getscheduler 157 -#define __NR_sched_yield 158 -#define __NR_sched_get_priority_max 159 -#define __NR_sched_get_priority_min 160 -#define __NR_sched_rr_get_interval 161 -#define __NR_nanosleep 162 -#define __NR_mremap 163 -#define __NR_setresuid 164 -#define __NR_getresuid 165 -#define __NR_poll 168 -#define __NR_nfsservctl 169 -#define __NR_setresgid 170 -#define __NR_getresgid 171 -#define __NR_prctl 172 -#define __NR_rt_sigreturn 173 -#define __NR_rt_sigaction 174 -#define __NR_rt_sigprocmask 175 -#define __NR_rt_sigpending 176 -#define __NR_rt_sigtimedwait 177 -#define __NR_rt_sigqueueinfo 178 -#define __NR_rt_sigsuspend 179 -#define __NR_pread64 180 -#define __NR_pwrite64 181 -#define __NR_chown 182 -#define __NR_getcwd 183 -#define __NR_capget 184 -#define __NR_capset 185 -#define __NR_sigaltstack 186 -#define __NR_sendfile 187 -#define __NR_vfork 190 -#define __NR_ugetrlimit 191 -#define __NR_mmap2 192 -#define __NR_truncate64 193 -#define __NR_ftruncate64 194 -#define __NR_stat64 195 -#define __NR_lstat64 196 -#define __NR_fstat64 197 -#define __NR_lchown32 198 -#define __NR_getuid32 199 -#define __NR_getgid32 200 -#define __NR_geteuid32 201 -#define __NR_getegid32 202 -#define __NR_setreuid32 203 -#define __NR_setregid32 204 -#define __NR_getgroups32 205 -#define __NR_setgroups32 206 -#define __NR_fchown32 207 -#define __NR_setresuid32 208 -#define __NR_getresuid32 209 -#define __NR_setresgid32 210 -#define __NR_getresgid32 211 -#define __NR_chown32 212 -#define __NR_setuid32 213 -#define __NR_setgid32 214 -#define __NR_setfsuid32 215 -#define __NR_setfsgid32 216 -#define __NR_getdents64 217 -#define __NR_pivot_root 218 -#define __NR_mincore 219 -#define __NR_madvise 220 -#define __NR_fcntl64 221 -#define __NR_gettid 224 -#define __NR_readahead 225 -#define __NR_setxattr 226 -#define __NR_lsetxattr 227 -#define __NR_fsetxattr 228 -#define __NR_getxattr 229 -#define __NR_lgetxattr 230 -#define __NR_fgetxattr 231 -#define __NR_listxattr 232 -#define __NR_llistxattr 233 -#define __NR_flistxattr 234 -#define __NR_removexattr 235 -#define __NR_lremovexattr 236 -#define __NR_fremovexattr 237 -#define __NR_tkill 238 -#define __NR_sendfile64 239 -#define __NR_futex 240 -#define __NR_sched_setaffinity 241 -#define __NR_sched_getaffinity 242 -#define __NR_io_setup 243 -#define __NR_io_destroy 244 -#define __NR_io_getevents 245 -#define __NR_io_submit 246 -#define __NR_io_cancel 247 -#define __NR_exit_group 248 -#define __NR_lookup_dcookie 249 -#define __NR_epoll_create 250 -#define __NR_epoll_ctl 251 -#define __NR_epoll_wait 252 -#define __NR_remap_file_pages 253 -#define __NR_set_tid_address 256 -#define __NR_timer_create 257 -#define __NR_timer_settime 258 -#define __NR_timer_gettime 259 -#define __NR_timer_getoverrun 260 -#define __NR_timer_delete 261 -#define __NR_clock_settime 262 -#define __NR_clock_gettime 263 -#define __NR_clock_getres 264 -#define __NR_clock_nanosleep 265 -#define __NR_statfs64 266 -#define __NR_fstatfs64 267 -#define __NR_tgkill 268 -#define __NR_utimes 269 -#define __NR_fadvise64_64 270 -#define __NR_arm_fadvise64_64 270 -#define __NR_pciconfig_iobase 271 -#define __NR_pciconfig_read 272 -#define __NR_pciconfig_write 273 -#define __NR_mq_open 274 -#define __NR_mq_unlink 275 -#define __NR_mq_timedsend 276 -#define __NR_mq_timedreceive 277 -#define __NR_mq_notify 278 -#define __NR_mq_getsetattr 279 -#define __NR_waitid 280 -#define __NR_socket 281 -#define __NR_bind 282 -#define __NR_connect 283 -#define __NR_listen 284 -#define __NR_accept 285 -#define __NR_getsockname 286 -#define __NR_getpeername 287 -#define __NR_socketpair 288 -#define __NR_send 289 -#define __NR_sendto 290 -#define __NR_recv 291 -#define __NR_recvfrom 292 -#define __NR_shutdown 293 -#define __NR_setsockopt 294 -#define __NR_getsockopt 295 -#define __NR_sendmsg 296 -#define __NR_recvmsg 297 -#define __NR_semop 298 -#define __NR_semget 299 -#define __NR_semctl 300 -#define __NR_msgsnd 301 -#define __NR_msgrcv 302 -#define __NR_msgget 303 -#define __NR_msgctl 304 -#define __NR_shmat 305 -#define __NR_shmdt 306 -#define __NR_shmget 307 -#define __NR_shmctl 308 -#define __NR_add_key 309 -#define __NR_request_key 310 -#define __NR_keyctl 311 -#define __NR_semtimedop 312 -#define __NR_vserver 313 -#define __NR_ioprio_set 314 -#define __NR_ioprio_get 315 -#define __NR_inotify_init 316 -#define __NR_inotify_add_watch 317 -#define __NR_inotify_rm_watch 318 -#define __NR_mbind 319 -#define __NR_get_mempolicy 320 -#define __NR_set_mempolicy 321 -#define __NR_openat 322 -#define __NR_mkdirat 323 -#define __NR_mknodat 324 -#define __NR_fchownat 325 -#define __NR_futimesat 326 -#define __NR_fstatat64 327 -#define __NR_unlinkat 328 -#define __NR_renameat 329 -#define __NR_linkat 330 -#define __NR_symlinkat 331 -#define __NR_readlinkat 332 -#define __NR_fchmodat 333 -#define __NR_faccessat 334 -#define __NR_pselect6 335 -#define __NR_ppoll 336 -#define __NR_unshare 337 -#define __NR_set_robust_list 338 -#define __NR_get_robust_list 339 -#define __NR_splice 340 -#define __NR_sync_file_range2 341 -#define __NR_arm_sync_file_range 341 -#define __NR_tee 342 -#define __NR_vmsplice 343 -#define __NR_move_pages 344 -#define __NR_getcpu 345 -#define __NR_epoll_pwait 346 -#define __NR_kexec_load 347 -#define __NR_utimensat 348 -#define __NR_signalfd 349 -#define __NR_timerfd_create 350 -#define __NR_eventfd 351 -#define __NR_fallocate 352 -#define __NR_timerfd_settime 353 -#define __NR_timerfd_gettime 354 -#define __NR_signalfd4 355 -#define __NR_eventfd2 356 -#define __NR_epoll_create1 357 -#define __NR_dup3 358 -#define __NR_pipe2 359 -#define __NR_inotify_init1 360 -#define __NR_preadv 361 -#define __NR_pwritev 362 -#define __NR_rt_tgsigqueueinfo 363 -#define __NR_perf_event_open 364 -#define __NR_recvmmsg 365 -#define __NR_accept4 366 -#define __NR_fanotify_init 367 -#define __NR_fanotify_mark 368 -#define __NR_prlimit64 369 -#define __NR_name_to_handle_at 370 -#define __NR_open_by_handle_at 371 -#define __NR_clock_adjtime 372 -#define __NR_syncfs 373 -#define __NR_sendmmsg 374 -#define __NR_setns 375 -#define __NR_process_vm_readv 376 -#define __NR_process_vm_writev 377 -#define __NR_kcmp 378 -#define __NR_finit_module 379 -#define __NR_sched_setattr 380 -#define __NR_sched_getattr 381 -#define __NR_renameat2 382 -#define __NR_seccomp 383 -#define __NR_getrandom 384 -#define __NR_memfd_create 385 -#define __NR_bpf 386 -#define __NR_execveat 387 -#define __NR_userfaultfd 388 -#define __NR_membarrier 389 -#define __NR_mlock2 390 -#define __NR_copy_file_range 391 -#define __NR_preadv2 392 -#define __NR_pwritev2 393 -#define __NR_pkey_mprotect 394 -#define __NR_pkey_alloc 395 -#define __NR_pkey_free 396 +#define __NR_restart_syscall 0 +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3 +#define __NR_write 4 +#define __NR_open 5 +#define __NR_close 6 +#define __NR_creat 8 +#define __NR_link 9 +#define __NR_unlink 10 +#define __NR_execve 11 +#define __NR_chdir 12 +#define __NR_mknod 14 +#define __NR_chmod 15 +#define __NR_lchown 16 +#define __NR_lseek 19 +#define __NR_getpid 20 +#define __NR_mount 21 +#define __NR_setuid 23 +#define __NR_getuid 24 +#define __NR_ptrace 26 +#define __NR_pause 29 +#define __NR_access 33 +#define __NR_nice 34 +#define __NR_sync 36 +#define __NR_kill 37 +#define __NR_rename 38 +#define __NR_mkdir 39 +#define __NR_rmdir 40 +#define __NR_dup 41 +#define __NR_pipe 42 +#define __NR_times 43 +#define __NR_brk 45 +#define __NR_setgid 46 +#define __NR_getgid 47 +#define __NR_geteuid 49 +#define __NR_getegid 50 +#define __NR_acct 51 +#define __NR_umount2 52 +#define __NR_ioctl 54 +#define __NR_fcntl 55 +#define __NR_setpgid 57 +#define __NR_umask 60 +#define __NR_chroot 61 +#define __NR_ustat 62 +#define __NR_dup2 63 +#define __NR_getppid 64 +#define __NR_getpgrp 65 +#define __NR_setsid 66 +#define __NR_sigaction 67 +#define __NR_setreuid 70 +#define __NR_setregid 71 +#define __NR_sigsuspend 72 +#define __NR_sigpending 73 +#define __NR_sethostname 74 +#define __NR_setrlimit 75 +#define __NR_getrusage 77 +#define __NR_gettimeofday_time32 78 +#define __NR_settimeofday_time32 79 +#define __NR_getgroups 80 +#define __NR_setgroups 81 +#define __NR_symlink 83 +#define __NR_readlink 85 +#define __NR_uselib 86 +#define __NR_swapon 87 +#define __NR_reboot 88 +#define __NR_munmap 91 +#define __NR_truncate 92 +#define __NR_ftruncate 93 +#define __NR_fchmod 94 +#define __NR_fchown 95 +#define __NR_getpriority 96 +#define __NR_setpriority 97 +#define __NR_statfs 99 +#define __NR_fstatfs 100 +#define __NR_syslog 103 +#define __NR_setitimer 104 +#define __NR_getitimer 105 +#define __NR_stat 106 +#define __NR_lstat 107 +#define __NR_fstat 108 +#define __NR_vhangup 111 +#define __NR_wait4 114 +#define __NR_swapoff 115 +#define __NR_sysinfo 116 +#define __NR_fsync 118 +#define __NR_sigreturn 119 +#define __NR_clone 120 +#define __NR_setdomainname 121 +#define __NR_uname 122 +#define __NR_adjtimex 124 +#define __NR_mprotect 125 +#define __NR_sigprocmask 126 +#define __NR_init_module 128 +#define __NR_delete_module 129 +#define __NR_quotactl 131 +#define __NR_getpgid 132 +#define __NR_fchdir 133 +#define __NR_bdflush 134 +#define __NR_sysfs 135 +#define __NR_personality 136 +#define __NR_setfsuid 138 +#define __NR_setfsgid 139 +#define __NR__llseek 140 +#define __NR_getdents 141 +#define __NR__newselect 142 +#define __NR_flock 143 +#define __NR_msync 144 +#define __NR_readv 145 +#define __NR_writev 146 +#define __NR_getsid 147 +#define __NR_fdatasync 148 +#define __NR__sysctl 149 +#define __NR_mlock 150 +#define __NR_munlock 151 +#define __NR_mlockall 152 +#define __NR_munlockall 153 +#define __NR_sched_setparam 154 +#define __NR_sched_getparam 155 +#define __NR_sched_setscheduler 156 +#define __NR_sched_getscheduler 157 +#define __NR_sched_yield 158 +#define __NR_sched_get_priority_max 159 +#define __NR_sched_get_priority_min 160 +#define __NR_sched_rr_get_interval 161 +#define __NR_nanosleep 162 +#define __NR_mremap 163 +#define __NR_setresuid 164 +#define __NR_getresuid 165 +#define __NR_poll 168 +#define __NR_nfsservctl 169 +#define __NR_setresgid 170 +#define __NR_getresgid 171 +#define __NR_prctl 172 +#define __NR_rt_sigreturn 173 +#define __NR_rt_sigaction 174 +#define __NR_rt_sigprocmask 175 +#define __NR_rt_sigpending 176 +#define __NR_rt_sigtimedwait 177 +#define __NR_rt_sigqueueinfo 178 +#define __NR_rt_sigsuspend 179 +#define __NR_pread64 180 +#define __NR_pwrite64 181 +#define __NR_chown 182 +#define __NR_getcwd 183 +#define __NR_capget 184 +#define __NR_capset 185 +#define __NR_sigaltstack 186 +#define __NR_sendfile 187 +#define __NR_vfork 190 +#define __NR_ugetrlimit 191 +#define __NR_mmap2 192 +#define __NR_truncate64 193 +#define __NR_ftruncate64 194 +#define __NR_stat64 195 +#define __NR_lstat64 196 +#define __NR_fstat64 197 +#define __NR_lchown32 198 +#define __NR_getuid32 199 +#define __NR_getgid32 200 +#define __NR_geteuid32 201 +#define __NR_getegid32 202 +#define __NR_setreuid32 203 +#define __NR_setregid32 204 +#define __NR_getgroups32 205 +#define __NR_setgroups32 206 +#define __NR_fchown32 207 +#define __NR_setresuid32 208 +#define __NR_getresuid32 209 +#define __NR_setresgid32 210 +#define __NR_getresgid32 211 +#define __NR_chown32 212 +#define __NR_setuid32 213 +#define __NR_setgid32 214 +#define __NR_setfsuid32 215 +#define __NR_setfsgid32 216 +#define __NR_getdents64 217 +#define __NR_pivot_root 218 +#define __NR_mincore 219 +#define __NR_madvise 220 +#define __NR_fcntl64 221 +#define __NR_gettid 224 +#define __NR_readahead 225 +#define __NR_setxattr 226 +#define __NR_lsetxattr 227 +#define __NR_fsetxattr 228 +#define __NR_getxattr 229 +#define __NR_lgetxattr 230 +#define __NR_fgetxattr 231 +#define __NR_listxattr 232 +#define __NR_llistxattr 233 +#define __NR_flistxattr 234 +#define __NR_removexattr 235 +#define __NR_lremovexattr 236 +#define __NR_fremovexattr 237 +#define __NR_tkill 238 +#define __NR_sendfile64 239 +#define __NR_futex 240 +#define __NR_sched_setaffinity 241 +#define __NR_sched_getaffinity 242 +#define __NR_io_setup 243 +#define __NR_io_destroy 244 +#define __NR_io_getevents 245 +#define __NR_io_submit 246 +#define __NR_io_cancel 247 +#define __NR_exit_group 248 +#define __NR_lookup_dcookie 249 +#define __NR_epoll_create 250 +#define __NR_epoll_ctl 251 +#define __NR_epoll_wait 252 +#define __NR_remap_file_pages 253 +#define __NR_set_tid_address 256 +#define __NR_timer_create 257 +#define __NR_timer_settime32 258 +#define __NR_timer_gettime32 259 +#define __NR_timer_getoverrun 260 +#define __NR_timer_delete 261 +#define __NR_clock_settime32 262 +#define __NR_clock_gettime32 263 +#define __NR_clock_getres_time32 264 +#define __NR_clock_nanosleep_time32 265 +#define __NR_statfs64 266 +#define __NR_fstatfs64 267 +#define __NR_tgkill 268 +#define __NR_utimes 269 +#define __NR_fadvise64_64 270 +#define __NR_arm_fadvise64_64 270 +#define __NR_pciconfig_iobase 271 +#define __NR_pciconfig_read 272 +#define __NR_pciconfig_write 273 +#define __NR_mq_open 274 +#define __NR_mq_unlink 275 +#define __NR_mq_timedsend 276 +#define __NR_mq_timedreceive 277 +#define __NR_mq_notify 278 +#define __NR_mq_getsetattr 279 +#define __NR_waitid 280 +#define __NR_socket 281 +#define __NR_bind 282 +#define __NR_connect 283 +#define __NR_listen 284 +#define __NR_accept 285 +#define __NR_getsockname 286 +#define __NR_getpeername 287 +#define __NR_socketpair 288 +#define __NR_send 289 +#define __NR_sendto 290 +#define __NR_recv 291 +#define __NR_recvfrom 292 +#define __NR_shutdown 293 +#define __NR_setsockopt 294 +#define __NR_getsockopt 295 +#define __NR_sendmsg 296 +#define __NR_recvmsg 297 +#define __NR_semop 298 +#define __NR_semget 299 +#define __NR_semctl 300 +#define __NR_msgsnd 301 +#define __NR_msgrcv 302 +#define __NR_msgget 303 +#define __NR_msgctl 304 +#define __NR_shmat 305 +#define __NR_shmdt 306 +#define __NR_shmget 307 +#define __NR_shmctl 308 +#define __NR_add_key 309 +#define __NR_request_key 310 +#define __NR_keyctl 311 +#define __NR_semtimedop 312 +#define __NR_vserver 313 +#define __NR_ioprio_set 314 +#define __NR_ioprio_get 315 +#define __NR_inotify_init 316 +#define __NR_inotify_add_watch 317 +#define __NR_inotify_rm_watch 318 +#define __NR_mbind 319 +#define __NR_get_mempolicy 320 +#define __NR_set_mempolicy 321 +#define __NR_openat 322 +#define __NR_mkdirat 323 +#define __NR_mknodat 324 +#define __NR_fchownat 325 +#define __NR_futimesat 326 +#define __NR_fstatat64 327 +#define __NR_unlinkat 328 +#define __NR_renameat 329 +#define __NR_linkat 330 +#define __NR_symlinkat 331 +#define __NR_readlinkat 332 +#define __NR_fchmodat 333 +#define __NR_faccessat 334 +#define __NR_pselect6 335 +#define __NR_ppoll 336 +#define __NR_unshare 337 +#define __NR_set_robust_list 338 +#define __NR_get_robust_list 339 +#define __NR_splice 340 +#define __NR_sync_file_range2 341 +#define __NR_arm_sync_file_range 341 +#define __NR_tee 342 +#define __NR_vmsplice 343 +#define __NR_move_pages 344 +#define __NR_getcpu 345 +#define __NR_epoll_pwait 346 +#define __NR_kexec_load 347 +#define __NR_utimensat 348 +#define __NR_signalfd 349 +#define __NR_timerfd_create 350 +#define __NR_eventfd 351 +#define __NR_fallocate 352 +#define __NR_timerfd_settime32 353 +#define __NR_timerfd_gettime32 354 +#define __NR_signalfd4 355 +#define __NR_eventfd2 356 +#define __NR_epoll_create1 357 +#define __NR_dup3 358 +#define __NR_pipe2 359 +#define __NR_inotify_init1 360 +#define __NR_preadv 361 +#define __NR_pwritev 362 +#define __NR_rt_tgsigqueueinfo 363 +#define __NR_perf_event_open 364 +#define __NR_recvmmsg 365 +#define __NR_accept4 366 +#define __NR_fanotify_init 367 +#define __NR_fanotify_mark 368 +#define __NR_prlimit64 369 +#define __NR_name_to_handle_at 370 +#define __NR_open_by_handle_at 371 +#define __NR_clock_adjtime 372 +#define __NR_syncfs 373 +#define __NR_sendmmsg 374 +#define __NR_setns 375 +#define __NR_process_vm_readv 376 +#define __NR_process_vm_writev 377 +#define __NR_kcmp 378 +#define __NR_finit_module 379 +#define __NR_sched_setattr 380 +#define __NR_sched_getattr 381 +#define __NR_renameat2 382 +#define __NR_seccomp 383 +#define __NR_getrandom 384 +#define __NR_memfd_create 385 +#define __NR_bpf 386 +#define __NR_execveat 387 +#define __NR_userfaultfd 388 +#define __NR_membarrier 389 +#define __NR_mlock2 390 +#define __NR_copy_file_range 391 +#define __NR_preadv2 392 +#define __NR_pwritev2 393 +#define __NR_pkey_mprotect 394 +#define __NR_pkey_alloc 395 +#define __NR_pkey_free 396 +#define __NR_statx 397 +#define __NR_rseq 398 +#define __NR_io_pgetevents 399 +#define __NR_migrate_pages 400 +#define __NR_kexec_file_load 401 +#define __NR_clock_gettime64 403 +#define __NR_clock_settime64 404 +#define __NR_clock_adjtime64 405 +#define __NR_clock_getres_time64 406 +#define __NR_clock_nanosleep_time64 407 +#define __NR_timer_gettime64 408 +#define __NR_timer_settime64 409 +#define __NR_timerfd_gettime64 410 +#define __NR_timerfd_settime64 411 +#define __NR_utimensat_time64 412 +#define __NR_pselect6_time64 413 +#define __NR_ppoll_time64 414 +#define __NR_io_pgetevents_time64 416 +#define __NR_recvmmsg_time64 417 +#define __NR_mq_timedsend_time64 418 +#define __NR_mq_timedreceive_time64 419 +#define __NR_semtimedop_time64 420 +#define __NR_rt_sigtimedwait_time64 421 +#define __NR_futex_time64 422 +#define __NR_sched_rr_get_interval_time64 423 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 -#define __ARM_NR_breakpoint 0x0f0001 -#define __ARM_NR_cacheflush 0x0f0002 -#define __ARM_NR_usr26 0x0f0003 -#define __ARM_NR_usr32 0x0f0004 -#define __ARM_NR_set_tls 0x0f0005 +#define __ARM_NR_breakpoint 0x0f0001 +#define __ARM_NR_cacheflush 0x0f0002 +#define __ARM_NR_usr26 0x0f0003 +#define __ARM_NR_usr32 0x0f0004 +#define __ARM_NR_set_tls 0x0f0005 +#define __ARM_NR_get_tls 0x0f0006 -#define SYS_restart_syscall 0 -#define SYS_exit 1 -#define SYS_fork 2 -#define SYS_read 3 -#define SYS_write 4 -#define SYS_open 5 -#define SYS_close 6 -#define SYS_creat 8 -#define SYS_link 9 -#define SYS_unlink 10 -#define SYS_execve 11 -#define SYS_chdir 12 -#define SYS_mknod 14 -#define SYS_chmod 15 -#define SYS_lchown 16 -#define SYS_lseek 19 -#define SYS_getpid 20 -#define SYS_mount 21 -#define SYS_setuid 23 -#define SYS_getuid 24 -#define SYS_ptrace 26 -#define SYS_pause 29 -#define SYS_access 33 -#define SYS_nice 34 -#define SYS_sync 36 -#define SYS_kill 37 -#define SYS_rename 38 -#define SYS_mkdir 39 -#define SYS_rmdir 40 -#define SYS_dup 41 -#define SYS_pipe 42 -#define SYS_times 43 -#define SYS_brk 45 -#define SYS_setgid 46 -#define SYS_getgid 47 -#define SYS_geteuid 49 -#define SYS_getegid 50 -#define SYS_acct 51 -#define SYS_umount2 52 -#define SYS_ioctl 54 -#define SYS_fcntl 55 -#define SYS_setpgid 57 -#define SYS_umask 60 -#define SYS_chroot 61 -#define SYS_ustat 62 -#define SYS_dup2 63 -#define SYS_getppid 64 -#define SYS_getpgrp 65 -#define SYS_setsid 66 -#define SYS_sigaction 67 -#define SYS_setreuid 70 -#define SYS_setregid 71 -#define SYS_sigsuspend 72 -#define SYS_sigpending 73 -#define SYS_sethostname 74 -#define SYS_setrlimit 75 -#define SYS_getrusage 77 -#define SYS_gettimeofday 78 -#define SYS_settimeofday 79 -#define SYS_getgroups 80 -#define SYS_setgroups 81 -#define SYS_symlink 83 -#define SYS_readlink 85 -#define SYS_uselib 86 -#define SYS_swapon 87 -#define SYS_reboot 88 -#define SYS_munmap 91 -#define SYS_truncate 92 -#define SYS_ftruncate 93 -#define SYS_fchmod 94 -#define SYS_fchown 95 -#define SYS_getpriority 96 -#define SYS_setpriority 97 -#define SYS_statfs 99 -#define SYS_fstatfs 100 -#define SYS_syslog 103 -#define SYS_setitimer 104 -#define SYS_getitimer 105 -#define SYS_stat 106 -#define SYS_lstat 107 -#define SYS_fstat 108 -#define SYS_vhangup 111 -#define SYS_wait4 114 -#define SYS_swapoff 115 -#define SYS_sysinfo 116 -#define SYS_fsync 118 -#define SYS_sigreturn 119 -#define SYS_clone 120 -#define SYS_setdomainname 121 -#define SYS_uname 122 -#define SYS_adjtimex 124 -#define SYS_mprotect 125 -#define SYS_sigprocmask 126 -#define SYS_init_module 128 -#define SYS_delete_module 129 -#define SYS_quotactl 131 -#define SYS_getpgid 132 -#define SYS_fchdir 133 -#define SYS_bdflush 134 -#define SYS_sysfs 135 -#define SYS_personality 136 -#define SYS_setfsuid 138 -#define SYS_setfsgid 139 -#define SYS__llseek 140 -#define SYS_getdents 141 -#define SYS__newselect 142 -#define SYS_flock 143 -#define SYS_msync 144 -#define SYS_readv 145 -#define SYS_writev 146 -#define SYS_getsid 147 -#define SYS_fdatasync 148 -#define SYS__sysctl 149 -#define SYS_mlock 150 -#define SYS_munlock 151 -#define SYS_mlockall 152 -#define SYS_munlockall 153 -#define SYS_sched_setparam 154 -#define SYS_sched_getparam 155 -#define SYS_sched_setscheduler 156 -#define SYS_sched_getscheduler 157 -#define SYS_sched_yield 158 -#define SYS_sched_get_priority_max 159 -#define SYS_sched_get_priority_min 160 -#define SYS_sched_rr_get_interval 161 -#define SYS_nanosleep 162 -#define SYS_mremap 163 -#define SYS_setresuid 164 -#define SYS_getresuid 165 -#define SYS_poll 168 -#define SYS_nfsservctl 169 -#define SYS_setresgid 170 -#define SYS_getresgid 171 -#define SYS_prctl 172 -#define SYS_rt_sigreturn 173 -#define SYS_rt_sigaction 174 -#define SYS_rt_sigprocmask 175 -#define SYS_rt_sigpending 176 -#define SYS_rt_sigtimedwait 177 -#define SYS_rt_sigqueueinfo 178 -#define SYS_rt_sigsuspend 179 -#define SYS_pread64 180 -#define SYS_pwrite64 181 -#define SYS_chown 182 -#define SYS_getcwd 183 -#define SYS_capget 184 -#define SYS_capset 185 -#define SYS_sigaltstack 186 -#define SYS_sendfile 187 -#define SYS_vfork 190 -#define SYS_ugetrlimit 191 -#define SYS_mmap2 192 -#define SYS_truncate64 193 -#define SYS_ftruncate64 194 -#define SYS_stat64 195 -#define SYS_lstat64 196 -#define SYS_fstat64 197 -#define SYS_lchown32 198 -#define SYS_getuid32 199 -#define SYS_getgid32 200 -#define SYS_geteuid32 201 -#define SYS_getegid32 202 -#define SYS_setreuid32 203 -#define SYS_setregid32 204 -#define SYS_getgroups32 205 -#define SYS_setgroups32 206 -#define SYS_fchown32 207 -#define SYS_setresuid32 208 -#define SYS_getresuid32 209 -#define SYS_setresgid32 210 -#define SYS_getresgid32 211 -#define SYS_chown32 212 -#define SYS_setuid32 213 -#define SYS_setgid32 214 -#define SYS_setfsuid32 215 -#define SYS_setfsgid32 216 -#define SYS_getdents64 217 -#define SYS_pivot_root 218 -#define SYS_mincore 219 -#define SYS_madvise 220 -#define SYS_fcntl64 221 -#define SYS_gettid 224 -#define SYS_readahead 225 -#define SYS_setxattr 226 -#define SYS_lsetxattr 227 -#define SYS_fsetxattr 228 -#define SYS_getxattr 229 -#define SYS_lgetxattr 230 -#define SYS_fgetxattr 231 -#define SYS_listxattr 232 -#define SYS_llistxattr 233 -#define SYS_flistxattr 234 -#define SYS_removexattr 235 -#define SYS_lremovexattr 236 -#define SYS_fremovexattr 237 -#define SYS_tkill 238 -#define SYS_sendfile64 239 -#define SYS_futex 240 -#define SYS_sched_setaffinity 241 -#define SYS_sched_getaffinity 242 -#define SYS_io_setup 243 -#define SYS_io_destroy 244 -#define SYS_io_getevents 245 -#define SYS_io_submit 246 -#define SYS_io_cancel 247 -#define SYS_exit_group 248 -#define SYS_lookup_dcookie 249 -#define SYS_epoll_create 250 -#define SYS_epoll_ctl 251 -#define SYS_epoll_wait 252 -#define SYS_remap_file_pages 253 -#define SYS_set_tid_address 256 -#define SYS_timer_create 257 -#define SYS_timer_settime 258 -#define SYS_timer_gettime 259 -#define SYS_timer_getoverrun 260 -#define SYS_timer_delete 261 -#define SYS_clock_settime 262 -#define SYS_clock_gettime 263 -#define SYS_clock_getres 264 -#define SYS_clock_nanosleep 265 -#define SYS_statfs64 266 -#define SYS_fstatfs64 267 -#define SYS_tgkill 268 -#define SYS_utimes 269 -#define SYS_fadvise64_64 270 -#define SYS_arm_fadvise64_64 270 -#define SYS_pciconfig_iobase 271 -#define SYS_pciconfig_read 272 -#define SYS_pciconfig_write 273 -#define SYS_mq_open 274 -#define SYS_mq_unlink 275 -#define SYS_mq_timedsend 276 -#define SYS_mq_timedreceive 277 -#define SYS_mq_notify 278 -#define SYS_mq_getsetattr 279 -#define SYS_waitid 280 -#define SYS_socket 281 -#define SYS_bind 282 -#define SYS_connect 283 -#define SYS_listen 284 -#define SYS_accept 285 -#define SYS_getsockname 286 -#define SYS_getpeername 287 -#define SYS_socketpair 288 -#define SYS_send 289 -#define SYS_sendto 290 -#define SYS_recv 291 -#define SYS_recvfrom 292 -#define SYS_shutdown 293 -#define SYS_setsockopt 294 -#define SYS_getsockopt 295 -#define SYS_sendmsg 296 -#define SYS_recvmsg 297 -#define SYS_semop 298 -#define SYS_semget 299 -#define SYS_semctl 300 -#define SYS_msgsnd 301 -#define SYS_msgrcv 302 -#define SYS_msgget 303 -#define SYS_msgctl 304 -#define SYS_shmat 305 -#define SYS_shmdt 306 -#define SYS_shmget 307 -#define SYS_shmctl 308 -#define SYS_add_key 309 -#define SYS_request_key 310 -#define SYS_keyctl 311 -#define SYS_semtimedop 312 -#define SYS_vserver 313 -#define SYS_ioprio_set 314 -#define SYS_ioprio_get 315 -#define SYS_inotify_init 316 -#define SYS_inotify_add_watch 317 -#define SYS_inotify_rm_watch 318 -#define SYS_mbind 319 -#define SYS_get_mempolicy 320 -#define SYS_set_mempolicy 321 -#define SYS_openat 322 -#define SYS_mkdirat 323 -#define SYS_mknodat 324 -#define SYS_fchownat 325 -#define SYS_futimesat 326 -#define SYS_fstatat64 327 -#define SYS_unlinkat 328 -#define SYS_renameat 329 -#define SYS_linkat 330 -#define SYS_symlinkat 331 -#define SYS_readlinkat 332 -#define SYS_fchmodat 333 -#define SYS_faccessat 334 -#define SYS_pselect6 335 -#define SYS_ppoll 336 -#define SYS_unshare 337 -#define SYS_set_robust_list 338 -#define SYS_get_robust_list 339 -#define SYS_splice 340 -#define SYS_sync_file_range2 341 -#define SYS_arm_sync_file_range 341 -#define SYS_tee 342 -#define SYS_vmsplice 343 -#define SYS_move_pages 344 -#define SYS_getcpu 345 -#define SYS_epoll_pwait 346 -#define SYS_kexec_load 347 -#define SYS_utimensat 348 -#define SYS_signalfd 349 -#define SYS_timerfd_create 350 -#define SYS_eventfd 351 -#define SYS_fallocate 352 -#define SYS_timerfd_settime 353 -#define SYS_timerfd_gettime 354 -#define SYS_signalfd4 355 -#define SYS_eventfd2 356 -#define SYS_epoll_create1 357 -#define SYS_dup3 358 -#define SYS_pipe2 359 -#define SYS_inotify_init1 360 -#define SYS_preadv 361 -#define SYS_pwritev 362 -#define SYS_rt_tgsigqueueinfo 363 -#define SYS_perf_event_open 364 -#define SYS_recvmmsg 365 -#define SYS_accept4 366 -#define SYS_fanotify_init 367 -#define SYS_fanotify_mark 368 -#define SYS_prlimit64 369 -#define SYS_name_to_handle_at 370 -#define SYS_open_by_handle_at 371 -#define SYS_clock_adjtime 372 -#define SYS_syncfs 373 -#define SYS_sendmmsg 374 -#define SYS_setns 375 -#define SYS_process_vm_readv 376 -#define SYS_process_vm_writev 377 -#define SYS_kcmp 378 -#define SYS_finit_module 379 -#define SYS_sched_setattr 380 -#define SYS_sched_getattr 381 -#define SYS_renameat2 382 -#define SYS_seccomp 383 -#define SYS_getrandom 384 -#define SYS_memfd_create 385 -#define SYS_bpf 386 -#define SYS_execveat 387 -#define SYS_userfaultfd 388 -#define SYS_membarrier 389 -#define SYS_mlock2 390 -#define SYS_copy_file_range 391 -#define SYS_preadv2 392 -#define SYS_pwritev2 393 -#define SYS_pkey_mprotect 394 -#define SYS_pkey_alloc 395 -#define SYS_pkey_free 396 +#define SYS_restart_syscall 0 +#define SYS_exit 1 +#define SYS_fork 2 +#define SYS_read 3 +#define SYS_write 4 +#define SYS_open 5 +#define SYS_close 6 +#define SYS_creat 8 +#define SYS_link 9 +#define SYS_unlink 10 +#define SYS_execve 11 +#define SYS_chdir 12 +#define SYS_mknod 14 +#define SYS_chmod 15 +#define SYS_lchown 16 +#define SYS_lseek 19 +#define SYS_getpid 20 +#define SYS_mount 21 +#define SYS_setuid 23 +#define SYS_getuid 24 +#define SYS_ptrace 26 +#define SYS_pause 29 +#define SYS_access 33 +#define SYS_nice 34 +#define SYS_sync 36 +#define SYS_kill 37 +#define SYS_rename 38 +#define SYS_mkdir 39 +#define SYS_rmdir 40 +#define SYS_dup 41 +#define SYS_pipe 42 +#define SYS_times 43 +#define SYS_brk 45 +#define SYS_setgid 46 +#define SYS_getgid 47 +#define SYS_geteuid 49 +#define SYS_getegid 50 +#define SYS_acct 51 +#define SYS_umount2 52 +#define SYS_ioctl 54 +#define SYS_fcntl 55 +#define SYS_setpgid 57 +#define SYS_umask 60 +#define SYS_chroot 61 +#define SYS_ustat 62 +#define SYS_dup2 63 +#define SYS_getppid 64 +#define SYS_getpgrp 65 +#define SYS_setsid 66 +#define SYS_sigaction 67 +#define SYS_setreuid 70 +#define SYS_setregid 71 +#define SYS_sigsuspend 72 +#define SYS_sigpending 73 +#define SYS_sethostname 74 +#define SYS_setrlimit 75 +#define SYS_getrusage 77 +#define SYS_gettimeofday_time32 78 +#define SYS_settimeofday_time32 79 +#define SYS_getgroups 80 +#define SYS_setgroups 81 +#define SYS_symlink 83 +#define SYS_readlink 85 +#define SYS_uselib 86 +#define SYS_swapon 87 +#define SYS_reboot 88 +#define SYS_munmap 91 +#define SYS_truncate 92 +#define SYS_ftruncate 93 +#define SYS_fchmod 94 +#define SYS_fchown 95 +#define SYS_getpriority 96 +#define SYS_setpriority 97 +#define SYS_statfs 99 +#define SYS_fstatfs 100 +#define SYS_syslog 103 +#define SYS_setitimer 104 +#define SYS_getitimer 105 +#define SYS_stat 106 +#define SYS_lstat 107 +#define SYS_fstat 108 +#define SYS_vhangup 111 +#define SYS_wait4 114 +#define SYS_swapoff 115 +#define SYS_sysinfo 116 +#define SYS_fsync 118 +#define SYS_sigreturn 119 +#define SYS_clone 120 +#define SYS_setdomainname 121 +#define SYS_uname 122 +#define SYS_adjtimex 124 +#define SYS_mprotect 125 +#define SYS_sigprocmask 126 +#define SYS_init_module 128 +#define SYS_delete_module 129 +#define SYS_quotactl 131 +#define SYS_getpgid 132 +#define SYS_fchdir 133 +#define SYS_bdflush 134 +#define SYS_sysfs 135 +#define SYS_personality 136 +#define SYS_setfsuid 138 +#define SYS_setfsgid 139 +#define SYS__llseek 140 +#define SYS_getdents 141 +#define SYS__newselect 142 +#define SYS_flock 143 +#define SYS_msync 144 +#define SYS_readv 145 +#define SYS_writev 146 +#define SYS_getsid 147 +#define SYS_fdatasync 148 +#define SYS__sysctl 149 +#define SYS_mlock 150 +#define SYS_munlock 151 +#define SYS_mlockall 152 +#define SYS_munlockall 153 +#define SYS_sched_setparam 154 +#define SYS_sched_getparam 155 +#define SYS_sched_setscheduler 156 +#define SYS_sched_getscheduler 157 +#define SYS_sched_yield 158 +#define SYS_sched_get_priority_max 159 +#define SYS_sched_get_priority_min 160 +#define SYS_sched_rr_get_interval 161 +#define SYS_nanosleep 162 +#define SYS_mremap 163 +#define SYS_setresuid 164 +#define SYS_getresuid 165 +#define SYS_poll 168 +#define SYS_nfsservctl 169 +#define SYS_setresgid 170 +#define SYS_getresgid 171 +#define SYS_prctl 172 +#define SYS_rt_sigreturn 173 +#define SYS_rt_sigaction 174 +#define SYS_rt_sigprocmask 175 +#define SYS_rt_sigpending 176 +#define SYS_rt_sigtimedwait 177 +#define SYS_rt_sigqueueinfo 178 +#define SYS_rt_sigsuspend 179 +#define SYS_pread64 180 +#define SYS_pwrite64 181 +#define SYS_chown 182 +#define SYS_getcwd 183 +#define SYS_capget 184 +#define SYS_capset 185 +#define SYS_sigaltstack 186 +#define SYS_sendfile 187 +#define SYS_vfork 190 +#define SYS_ugetrlimit 191 +#define SYS_mmap2 192 +#define SYS_truncate64 193 +#define SYS_ftruncate64 194 +#define SYS_stat64 195 +#define SYS_lstat64 196 +#define SYS_fstat64 197 +#define SYS_lchown32 198 +#define SYS_getuid32 199 +#define SYS_getgid32 200 +#define SYS_geteuid32 201 +#define SYS_getegid32 202 +#define SYS_setreuid32 203 +#define SYS_setregid32 204 +#define SYS_getgroups32 205 +#define SYS_setgroups32 206 +#define SYS_fchown32 207 +#define SYS_setresuid32 208 +#define SYS_getresuid32 209 +#define SYS_setresgid32 210 +#define SYS_getresgid32 211 +#define SYS_chown32 212 +#define SYS_setuid32 213 +#define SYS_setgid32 214 +#define SYS_setfsuid32 215 +#define SYS_setfsgid32 216 +#define SYS_getdents64 217 +#define SYS_pivot_root 218 +#define SYS_mincore 219 +#define SYS_madvise 220 +#define SYS_fcntl64 221 +#define SYS_gettid 224 +#define SYS_readahead 225 +#define SYS_setxattr 226 +#define SYS_lsetxattr 227 +#define SYS_fsetxattr 228 +#define SYS_getxattr 229 +#define SYS_lgetxattr 230 +#define SYS_fgetxattr 231 +#define SYS_listxattr 232 +#define SYS_llistxattr 233 +#define SYS_flistxattr 234 +#define SYS_removexattr 235 +#define SYS_lremovexattr 236 +#define SYS_fremovexattr 237 +#define SYS_tkill 238 +#define SYS_sendfile64 239 +#define SYS_futex 240 +#define SYS_sched_setaffinity 241 +#define SYS_sched_getaffinity 242 +#define SYS_io_setup 243 +#define SYS_io_destroy 244 +#define SYS_io_getevents 245 +#define SYS_io_submit 246 +#define SYS_io_cancel 247 +#define SYS_exit_group 248 +#define SYS_lookup_dcookie 249 +#define SYS_epoll_create 250 +#define SYS_epoll_ctl 251 +#define SYS_epoll_wait 252 +#define SYS_remap_file_pages 253 +#define SYS_set_tid_address 256 +#define SYS_timer_create 257 +#define SYS_timer_settime32 258 +#define SYS_timer_gettime32 259 +#define SYS_timer_getoverrun 260 +#define SYS_timer_delete 261 +#define SYS_clock_settime32 262 +#define SYS_clock_gettime32 263 +#define SYS_clock_getres_time32 264 +#define SYS_clock_nanosleep_time32 265 +#define SYS_statfs64 266 +#define SYS_fstatfs64 267 +#define SYS_tgkill 268 +#define SYS_utimes 269 +#define SYS_fadvise64_64 270 +#define SYS_arm_fadvise64_64 270 +#define SYS_pciconfig_iobase 271 +#define SYS_pciconfig_read 272 +#define SYS_pciconfig_write 273 +#define SYS_mq_open 274 +#define SYS_mq_unlink 275 +#define SYS_mq_timedsend 276 +#define SYS_mq_timedreceive 277 +#define SYS_mq_notify 278 +#define SYS_mq_getsetattr 279 +#define SYS_waitid 280 +#define SYS_socket 281 +#define SYS_bind 282 +#define SYS_connect 283 +#define SYS_listen 284 +#define SYS_accept 285 +#define SYS_getsockname 286 +#define SYS_getpeername 287 +#define SYS_socketpair 288 +#define SYS_send 289 +#define SYS_sendto 290 +#define SYS_recv 291 +#define SYS_recvfrom 292 +#define SYS_shutdown 293 +#define SYS_setsockopt 294 +#define SYS_getsockopt 295 +#define SYS_sendmsg 296 +#define SYS_recvmsg 297 +#define SYS_semop 298 +#define SYS_semget 299 +#define SYS_semctl 300 +#define SYS_msgsnd 301 +#define SYS_msgrcv 302 +#define SYS_msgget 303 +#define SYS_msgctl 304 +#define SYS_shmat 305 +#define SYS_shmdt 306 +#define SYS_shmget 307 +#define SYS_shmctl 308 +#define SYS_add_key 309 +#define SYS_request_key 310 +#define SYS_keyctl 311 +#define SYS_semtimedop 312 +#define SYS_vserver 313 +#define SYS_ioprio_set 314 +#define SYS_ioprio_get 315 +#define SYS_inotify_init 316 +#define SYS_inotify_add_watch 317 +#define SYS_inotify_rm_watch 318 +#define SYS_mbind 319 +#define SYS_get_mempolicy 320 +#define SYS_set_mempolicy 321 +#define SYS_openat 322 +#define SYS_mkdirat 323 +#define SYS_mknodat 324 +#define SYS_fchownat 325 +#define SYS_futimesat 326 +#define SYS_fstatat64 327 +#define SYS_unlinkat 328 +#define SYS_renameat 329 +#define SYS_linkat 330 +#define SYS_symlinkat 331 +#define SYS_readlinkat 332 +#define SYS_fchmodat 333 +#define SYS_faccessat 334 +#define SYS_pselect6 335 +#define SYS_ppoll 336 +#define SYS_unshare 337 +#define SYS_set_robust_list 338 +#define SYS_get_robust_list 339 +#define SYS_splice 340 +#define SYS_sync_file_range2 341 +#define SYS_arm_sync_file_range 341 +#define SYS_tee 342 +#define SYS_vmsplice 343 +#define SYS_move_pages 344 +#define SYS_getcpu 345 +#define SYS_epoll_pwait 346 +#define SYS_kexec_load 347 +#define SYS_utimensat 348 +#define SYS_signalfd 349 +#define SYS_timerfd_create 350 +#define SYS_eventfd 351 +#define SYS_fallocate 352 +#define SYS_timerfd_settime32 353 +#define SYS_timerfd_gettime32 354 +#define SYS_signalfd4 355 +#define SYS_eventfd2 356 +#define SYS_epoll_create1 357 +#define SYS_dup3 358 +#define SYS_pipe2 359 +#define SYS_inotify_init1 360 +#define SYS_preadv 361 +#define SYS_pwritev 362 +#define SYS_rt_tgsigqueueinfo 363 +#define SYS_perf_event_open 364 +#define SYS_recvmmsg 365 +#define SYS_accept4 366 +#define SYS_fanotify_init 367 +#define SYS_fanotify_mark 368 +#define SYS_prlimit64 369 +#define SYS_name_to_handle_at 370 +#define SYS_open_by_handle_at 371 +#define SYS_clock_adjtime 372 +#define SYS_syncfs 373 +#define SYS_sendmmsg 374 +#define SYS_setns 375 +#define SYS_process_vm_readv 376 +#define SYS_process_vm_writev 377 +#define SYS_kcmp 378 +#define SYS_finit_module 379 +#define SYS_sched_setattr 380 +#define SYS_sched_getattr 381 +#define SYS_renameat2 382 +#define SYS_seccomp 383 +#define SYS_getrandom 384 +#define SYS_memfd_create 385 +#define SYS_bpf 386 +#define SYS_execveat 387 +#define SYS_userfaultfd 388 +#define SYS_membarrier 389 +#define SYS_mlock2 390 +#define SYS_copy_file_range 391 +#define SYS_preadv2 392 +#define SYS_pwritev2 393 +#define SYS_pkey_mprotect 394 +#define SYS_pkey_alloc 395 +#define SYS_pkey_free 396 +#define SYS_statx 397 +#define SYS_rseq 398 +#define SYS_io_pgetevents 399 +#define SYS_migrate_pages 400 +#define SYS_kexec_file_load 401 +#define SYS_clock_gettime64 403 +#define SYS_clock_settime64 404 +#define SYS_clock_adjtime64 405 +#define SYS_clock_getres_time64 406 +#define SYS_clock_nanosleep_time64 407 +#define SYS_timer_gettime64 408 +#define SYS_timer_settime64 409 +#define SYS_timerfd_gettime64 410 +#define SYS_timerfd_settime64 411 +#define SYS_utimensat_time64 412 +#define SYS_pselect6_time64 413 +#define SYS_ppoll_time64 414 +#define SYS_io_pgetevents_time64 416 +#define SYS_recvmmsg_time64 417 +#define SYS_mq_timedsend_time64 418 +#define SYS_mq_timedreceive_time64 419 +#define SYS_semtimedop_time64 420 +#define SYS_rt_sigtimedwait_time64 421 +#define SYS_futex_time64 422 +#define SYS_sched_rr_get_interval_time64 423 +#define SYS_pidfd_send_signal 424 +#define SYS_io_uring_setup 425 +#define SYS_io_uring_enter 426 +#define SYS_io_uring_register 427 +#define SYS_open_tree 428 +#define SYS_move_mount 429 +#define SYS_fsopen 430 +#define SYS_fsconfig 431 +#define SYS_fsmount 432 +#define SYS_fspick 433 +#define SYS_pidfd_open 434 +#define SYS_clone3 435 diff --git a/thirdparty/open_source/musl/libc/arch/arm/crt_arch.h b/thirdparty/open_source/musl/libc/arch/arm/crt_arch.h new file mode 100644 index 0000000..42e9a26 --- /dev/null +++ b/thirdparty/open_source/musl/libc/arch/arm/crt_arch.h @@ -0,0 +1,27 @@ +#ifndef ARM_CRT_ARCH_H +#define ARM_CRT_ARCH_H + +__asm__( +".text\n" +".global " START "\n" +".type " START ",%function\n" +START ": \n" +" mov fp, #0\n" +" mov lr, #0\n" +" ldr r5, [r0, #8]\n" /* paratbl */ +/* Little-endian */ +" str r1, [r5, #20]\n" /* PT_ZERO1 */ +" str r2, [r5, #24]\n" /* PT_ZERO2 */ +" ldr r1, 1f\n" +" add r1, pc, r1\n" +" mov r5, sp\n" +"2: and r5, r5, #-16\n" +" mov sp, r5\n" +" bl " START "_c\n" +".weak _DYNAMIC\n" +".hidden _DYNAMIC\n" +".align 2\n" +"1: .word _DYNAMIC-2b\n" +); + +#endif \ No newline at end of file diff --git a/thirdparty/open_source/musl/libc/arch/generic/bits/shm.h b/thirdparty/open_source/musl/libc/arch/generic/bits/shm.h index 8d19378..da07a2a 100644 --- a/thirdparty/open_source/musl/libc/arch/generic/bits/shm.h +++ b/thirdparty/open_source/musl/libc/arch/generic/bits/shm.h @@ -1,4 +1,4 @@ -#define SHMLBA 4096 +#define SHMLBA (4*4096) struct shmid_ds { struct ipc_perm shm_perm; diff --git a/thirdparty/open_source/musl/libc/ctype.h b/thirdparty/open_source/musl/libc/ctype.h index 7936536..7b91d3e 100644 --- a/thirdparty/open_source/musl/libc/ctype.h +++ b/thirdparty/open_source/musl/libc/ctype.h @@ -66,6 +66,11 @@ int toascii(int); #define _toupper(a) ((a)&0x5f) #define isascii(a) (0 ? isascii(a) : (unsigned)(a) < 128) +#include + +const int32_t **__ctype_tolower_loc(void); +const int32_t **__ctype_toupper_loc(void); + #endif #ifdef __cplusplus diff --git a/thirdparty/open_source/musl/libc/float.h b/thirdparty/open_source/musl/libc/float.h new file mode 100644 index 0000000..713aadb --- /dev/null +++ b/thirdparty/open_source/musl/libc/float.h @@ -0,0 +1,52 @@ +#ifndef _FLOAT_H +#define _FLOAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +int __flt_rounds(void); +#define FLT_ROUNDS (__flt_rounds()) + +#define FLT_RADIX 2 + +#define FLT_TRUE_MIN 1.40129846432481707092e-45F +#define FLT_MIN 1.17549435082228750797e-38F +#define FLT_MAX 3.40282346638528859812e+38F +#define FLT_EPSILON 1.1920928955078125e-07F + +#define FLT_MANT_DIG 24 +#define FLT_MIN_EXP (-125) +#define FLT_MAX_EXP 128 +#define FLT_HAS_SUBNORM 1 + +#define FLT_DIG 6 +#define FLT_DECIMAL_DIG 9 +#define FLT_MIN_10_EXP (-37) +#define FLT_MAX_10_EXP 38 + +#define DBL_TRUE_MIN 4.94065645841246544177e-324 +#define DBL_MIN 2.22507385850720138309e-308 +#define DBL_MAX 1.79769313486231570815e+308 +#define DBL_EPSILON 2.22044604925031308085e-16 + +#define DBL_MANT_DIG 53 +#define DBL_MIN_EXP (-1021) +#define DBL_MAX_EXP 1024 +#define DBL_HAS_SUBNORM 1 + +#define DBL_DIG 15 +#define DBL_DECIMAL_DIG 17 +#define DBL_MIN_10_EXP (-307) +#define DBL_MAX_10_EXP 308 + +#define LDBL_HAS_SUBNORM 1 +#define LDBL_DECIMAL_DIG DECIMAL_DIG + +#include + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/thirdparty/open_source/musl/libc/limits.h b/thirdparty/open_source/musl/libc/limits.h index c9794bb..53a27b9 100644 --- a/thirdparty/open_source/musl/libc/limits.h +++ b/thirdparty/open_source/musl/libc/limits.h @@ -37,6 +37,8 @@ #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#include + #define PIPE_BUF 4096 #define FILESIZEBITS 64 #ifndef NAME_MAX diff --git a/thirdparty/open_source/musl/libc/pthread.h b/thirdparty/open_source/musl/libc/pthread.h index 22120b0..e386944 100644 --- a/thirdparty/open_source/musl/libc/pthread.h +++ b/thirdparty/open_source/musl/libc/pthread.h @@ -6,6 +6,24 @@ extern "C" { #include +/* Musl did not provide the "owner" marco directly, + * so users can not access the mutex-owner-ID. + * Thus we added this macro for getting the owner-ID + * of the mutex. */ +#define MUTEX_OWNER __u.__vi[1] & 0x7fffffff + +/* These macros provides macros for accessing inner + * attributes of the pthread_mutex_t struct. + * It is intened for solving the compiling failure + * of Dopra codes which claims that .__data.* realm + * can not be found in pthread_mutex_t. */ +#define MUTEX_TYPE __u.__i[0] +#define MUTEX_LOCK __u.__vi[1] +#define MUTEX_WAITERS __u.__vi[2] +#define MUTEX_PREV __u.__p[3] +#define MUTEX_NEXT __u.__p[4] +#define MUTEX_COUNT __u.__i[5] + #define __NEED_time_t #define __NEED_clockid_t #define __NEED_struct_timespec diff --git a/thirdparty/open_source/musl/libc/stddef.h b/thirdparty/open_source/musl/libc/stddef.h index 4a914ee..bd75385 100644 --- a/thirdparty/open_source/musl/libc/stddef.h +++ b/thirdparty/open_source/musl/libc/stddef.h @@ -1,13 +1,11 @@ #ifndef _STDDEF_H #define _STDDEF_H -#ifndef NULL #ifdef __cplusplus #define NULL 0L #else #define NULL ((void*)0) #endif -#endif #define __NEED_ptrdiff_t #define __NEED_size_t diff --git a/thirdparty/open_source/musl/libc/stdlib.h b/thirdparty/open_source/musl/libc/stdlib.h index 194c203..0372af9 100644 --- a/thirdparty/open_source/musl/libc/stdlib.h +++ b/thirdparty/open_source/musl/libc/stdlib.h @@ -36,6 +36,7 @@ int rand (void); void srand (unsigned); void *malloc (size_t); +void *malloc_coherent(size_t n); void *calloc (size_t, size_t); void *realloc (void *, size_t); void free (void *); diff --git a/thirdparty/open_source/musl/libc/sys/mman.h b/thirdparty/open_source/musl/libc/sys/mman.h index 105af9d..3bade72 100644 --- a/thirdparty/open_source/musl/libc/sys/mman.h +++ b/thirdparty/open_source/musl/libc/sys/mman.h @@ -20,7 +20,6 @@ extern "C" { #define MAP_SHARED 0x01 #define MAP_PRIVATE 0x02 -#define MAP_RESERVE 0x04 #define MAP_SHARED_VALIDATE 0x03 #define MAP_TYPE 0x0f #define MAP_FIXED 0x10 @@ -113,7 +112,7 @@ extern "C" { #include void *mmap (void *, size_t, int, int, int, off_t); -int munmap (const void *, size_t); +int munmap (void *, size_t); int mprotect (void *, size_t, int); int msync (void *, size_t, int); diff --git a/thirdparty/open_source/musl/libc/time.h b/thirdparty/open_source/musl/libc/time.h index 1b18024..5494df1 100644 --- a/thirdparty/open_source/musl/libc/time.h +++ b/thirdparty/open_source/musl/libc/time.h @@ -7,13 +7,11 @@ extern "C" { #include -#ifndef NULL #ifdef __cplusplus #define NULL 0L #else #define NULL ((void*)0) #endif -#endif #define __NEED_size_t -- Gitee