From df6dcfaf455da8eefac066a09f489ddd4360caea Mon Sep 17 00:00:00 2001 From: keminLuo Date: Tue, 14 Nov 2023 17:00:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8E=A7=E5=88=B6=E5=BC=80?= =?UTF-8?q?=E5=85=B3=EF=BC=9B=E8=A7=A3=E5=86=B3=E9=83=A8=E5=88=86=E8=BD=BB?= =?UTF-8?q?=E9=87=8F=E8=AE=BE=E5=A4=87=E7=BC=96=E8=AF=91=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=EF=BC=9B=20Signed-off-by:=20=E7=BD=97=E9=94=AE=E9=93=AD=20<541?= =?UTF-8?q?416002@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/devattestconfig.gni | 4 +++ framework/BUILD.gn | 1 - interfaces/kit/js/BUILD.gn | 1 - services/core/BUILD.gn | 13 --------- services/core/adapter/attest_adapter_os.c | 2 +- services/core/attest/attest_service_auth.c | 2 +- .../core/attest/attest_service_challenge.c | 2 +- services/core/include/network/attest_tls.h | 2 +- .../adapter/attest_adapter_network_config.c | 27 +++++++++++++++++-- .../core/mini/attest/attest_service_pcid.c | 3 ++- .../mini/utils/attest_utils_file_detail.c | 24 +++++++++++------ services/core/network/attest_tls.c | 4 +-- .../small/utils/attest_utils_file_detail.c | 2 +- test/startup/BUILD.gn | 1 - test/tdd/gtest/BUILD.gn | 1 - 15 files changed, 54 insertions(+), 35 deletions(-) diff --git a/build/devattestconfig.gni b/build/devattestconfig.gni index 249ab2c..2872f61 100644 --- a/build/devattestconfig.gni +++ b/build/devattestconfig.gni @@ -53,3 +53,7 @@ declare_args() { if (attest_build_target == attest_debug) { enable_attest_log_debug = true } + +if (defined(abi_type) && abi_type != "") { + integrate_attest_mini_module = false +} diff --git a/framework/BUILD.gn b/framework/BUILD.gn index d8788c2..c24ff04 100644 --- a/framework/BUILD.gn +++ b/framework/BUILD.gn @@ -21,7 +21,6 @@ if (os_level != "mini") { "-Wextra", "-Wshadow", "-fstack-protector-all", - "-D_FORTIFY_SOURCE=2", "-Wformat=2", "-Wfloat-equal", "-Wdate-time", diff --git a/interfaces/kit/js/BUILD.gn b/interfaces/kit/js/BUILD.gn index 92b3b94..c523ad4 100644 --- a/interfaces/kit/js/BUILD.gn +++ b/interfaces/kit/js/BUILD.gn @@ -22,7 +22,6 @@ shared_library("kit_device_attest") { "-Wextra", "-Wshadow", "-fstack-protector-all", - "-D_FORTIFY_SOURCE=2", "-Wformat=2", "-Wfloat-equal", "-Wdate-time", diff --git a/services/core/BUILD.gn b/services/core/BUILD.gn index 173aa96..3760ad6 100644 --- a/services/core/BUILD.gn +++ b/services/core/BUILD.gn @@ -96,17 +96,6 @@ if (ohos_kernel_type == "liteos_m") { ":devattest_core_hi3861_config", ] - cflags = [ - "-Wall", - "-Wextra", - "-Wshadow", - "-fstack-protector-all", - "-D_FORTIFY_SOURCE=2", - "-Wformat=2", - "-Wfloat-equal", - "-Wdate-time", - ] - deps = [ "$ohos_product_adapter_dir/utils/token:hal_token_static", "//base/startup/init/interfaces/innerkits:parameter", @@ -133,10 +122,8 @@ if (ohos_kernel_type == "liteos_m") { ] cflags = [ "-ftrapv", - "-Werror", "-Wextra", "-Wshadow", - "-fstack-protector-all", "-Wformat=2", "-Wfloat-equal", "-Wdate-time", diff --git a/services/core/adapter/attest_adapter_os.c b/services/core/adapter/attest_adapter_os.c index 3640f2b..f7932c7 100644 --- a/services/core/adapter/attest_adapter_os.c +++ b/services/core/adapter/attest_adapter_os.c @@ -31,7 +31,7 @@ char* OsGetBuildRootHash(void) char* OsGetDisplayVersion(void) { - return AttestStrdup(GetOSFullName()); + return AttestStrdup(GetDisplayVersion()); } char* OsGetManufacture(void) diff --git a/services/core/attest/attest_service_auth.c b/services/core/attest/attest_service_auth.c index 8d2ce3b..e5afc9d 100644 --- a/services/core/attest/attest_service_auth.c +++ b/services/core/attest/attest_service_auth.c @@ -122,7 +122,7 @@ int32_t GetAttestStatusPara(void) int ret = AttestGetParameter(STARTSUP_PARA_ATTEST_KEY, STARTSUP_PARA_ATTEST_ERROR, attestResult, sizeof(attestResult)); if ((ret != 0) && (strcmp(STARTSUP_PARA_ATTEST_OK, attestResult) == 0)) { - ATTEST_LOG_INFO("[GetAttestStatusPara] success."); + ATTEST_LOG_INFO("[GetAttestStatusPara] success, persist.xts.devattest.authresult = %s", attestResult); return ATTEST_OK; } ATTEST_LOG_WARN("[GetAttestStatusPara] failed."); diff --git a/services/core/attest/attest_service_challenge.c b/services/core/attest/attest_service_challenge.c index a3a644c..ac7cd76 100644 --- a/services/core/attest/attest_service_challenge.c +++ b/services/core/attest/attest_service_challenge.c @@ -100,7 +100,7 @@ static int32_t ParseChallengeResult(const char* jsonStr, ChallengeResult* challe return -(int32_t)(errorCode); } - challenge->currentTime = GetObjectItemValueNumber(jsonStr, "currentTime"); + challenge->currentTime = (uint64_t)GetObjectItemValueNumber(jsonStr, "currentTime"); if (isnan((double)challenge->currentTime)) { ATTEST_LOG_ERROR("[ParseChallengeResult] GetObjectItem currentTime failed."); return ATTEST_ERR; diff --git a/services/core/include/network/attest_tls.h b/services/core/include/network/attest_tls.h index e72e299..8d26e37 100644 --- a/services/core/include/network/attest_tls.h +++ b/services/core/include/network/attest_tls.h @@ -17,7 +17,7 @@ #include "mbedtls/x509_crt.h" -#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) +#define ATTEST_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) typedef struct { const unsigned char *certDer; diff --git a/services/core/mini/adapter/attest_adapter_network_config.c b/services/core/mini/adapter/attest_adapter_network_config.c index ef73c9f..6e64df6 100644 --- a/services/core/mini/adapter/attest_adapter_network_config.c +++ b/services/core/mini/adapter/attest_adapter_network_config.c @@ -14,11 +14,13 @@ */ #ifdef __LITEOS_M__ -#include "hi_mdm.h" #include "attest_utils_log.h" #include "attest_adapter.h" +#if defined(CHIP_VER_Hi3861) +#include + #define HI_NV_XTS_DEV_ATTEST_NET 0x60 #define HI_NV_NET_SIZE 164 @@ -71,4 +73,25 @@ int32_t AttestWriteNetworkConfig(const char* data, uint32_t len) } return ATTEST_OK; } -#endif + +#else + +int32_t AttestReadNetworkConfig(char* buffer, uint32_t bufferLen) +{ + (void)buffer; + (void)bufferLen; + ATTEST_LOG_ERROR("[AttestReadNetworkConfig] Need to implement interface AttestReadNetworkConfig!"); + return ATTEST_ERR; +} + +int32_t AttestWriteNetworkConfig(const char* data, uint32_t len) +{ + (void)data; + (void)bufferLen; + ATTEST_LOG_ERROR("[AttestWriteNetworkConfig] Need to implement interface AttestWriteNetworkConfig!"); + return ATTEST_ERR; +} + +#endif // defined(CHIP_VER_Hi3861) + +#endif // __LITEOS_M__ diff --git a/services/core/mini/attest/attest_service_pcid.c b/services/core/mini/attest/attest_service_pcid.c index 009bac5..7a9d47f 100644 --- a/services/core/mini/attest/attest_service_pcid.c +++ b/services/core/mini/attest/attest_service_pcid.c @@ -14,12 +14,13 @@ */ #ifdef __LITEOS_M__ +#include "attest_utils.h" #include "attest_service_device.h" #define ATTEST_DEFAULT_PCID "pcid" char* GetPcid(void) { // LITEOS_M not support pcid, this function return default value, but don't use - return ATTEST_DEFAULT_PCID; + return AttestStrdup(ATTEST_DEFAULT_PCID); } #endif diff --git a/services/core/mini/utils/attest_utils_file_detail.c b/services/core/mini/utils/attest_utils_file_detail.c index 9611465..ddeac74 100644 --- a/services/core/mini/utils/attest_utils_file_detail.c +++ b/services/core/mini/utils/attest_utils_file_detail.c @@ -17,11 +17,7 @@ #include #include #include - #include "utils_file.h" -#include - - #include #include #include @@ -29,11 +25,14 @@ #include "attest_utils.h" #include "attest_utils_file.h" - -#define WRITE_FLASH_MAX_TEMPERATURE 80 static const uint32_t MAX_FILE_BYTES_LIMIT = 5120; -// L0 温度监控 +#if defined(CHIP_VER_Hi3861) +#include + +#define WRITE_FLASH_MAX_TEMPERATURE 80 + +// 轻量设备温度监控 bool IsOverTemperatureLimit(void) { hi_s16 temperature = 0; @@ -49,6 +48,15 @@ bool IsOverTemperatureLimit(void) return (temperature >= WRITE_FLASH_MAX_TEMPERATURE); } +#else + +bool IsOverTemperatureLimit(void) +{ + return false; +} + +#endif // defined(CHIP_VER_Hi3861) + int32_t GetFileSize(const char* path, const char* fileName, uint32_t* result) { if (path == NULL || fileName == NULL || result == NULL) { @@ -165,4 +173,4 @@ bool DeleteFile(const char* path, const char* fileName) } return true; } -#endif +#endif // __LITEOS_M__ diff --git a/services/core/network/attest_tls.c b/services/core/network/attest_tls.c index 4760735..de41add 100644 --- a/services/core/network/attest_tls.c +++ b/services/core/network/attest_tls.c @@ -265,7 +265,7 @@ int32_t LoadCommonCert(mbedtls_x509_crt* chain) int32_t LoadCommonOtherCert(mbedtls_x509_crt* chain, uint32_t cursor) { - if (chain == NULL || cursor >= ARRAY_SIZE(g_commonOtherCert)) { + if (chain == NULL || cursor >= ATTEST_ARRAY_SIZE(g_commonOtherCert)) { ATTEST_LOG_ERROR("[LoadCommonOtherCert] Invalid parameter"); return ERR_NET_PARSE_CERT_FAIL; } @@ -280,5 +280,5 @@ int32_t LoadCommonOtherCert(mbedtls_x509_crt* chain, uint32_t cursor) int32_t GetCommonCertSize(void) { - return ARRAY_SIZE(g_commonOtherCert); + return ATTEST_ARRAY_SIZE(g_commonOtherCert); } \ No newline at end of file diff --git a/services/core/small/utils/attest_utils_file_detail.c b/services/core/small/utils/attest_utils_file_detail.c index 759515e..33922ee 100644 --- a/services/core/small/utils/attest_utils_file_detail.c +++ b/services/core/small/utils/attest_utils_file_detail.c @@ -25,7 +25,7 @@ bool IsOverTemperatureLimit(void) { - return true; + return false; } int32_t GetFileSize(const char* path, const char* fileName, uint32_t* result) diff --git a/test/startup/BUILD.gn b/test/startup/BUILD.gn index d4720f8..4bab737 100644 --- a/test/startup/BUILD.gn +++ b/test/startup/BUILD.gn @@ -24,7 +24,6 @@ executable("devattest_client") { "-Wextra", "-Wshadow", "-fstack-protector-all", - "-D_FORTIFY_SOURCE=2", "-Wformat=2", "-Wfloat-equal", "-Wdate-time", diff --git a/test/tdd/gtest/BUILD.gn b/test/tdd/gtest/BUILD.gn index a1b3946..af3ffac 100644 --- a/test/tdd/gtest/BUILD.gn +++ b/test/tdd/gtest/BUILD.gn @@ -25,7 +25,6 @@ if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") { "-Wextra", "-Wshadow", "-fstack-protector-all", - "-D_FORTIFY_SOURCE=2", "-Wformat=2", "-Wfloat-equal", "-Wdate-time",