增加控制开关;解决部分轻量设备编译失败;

Signed-off-by: 罗键铭 <541416002@qq.com>
This commit is contained in:
keminLuo
2023-11-14 17:00:28 +08:00
parent b8b3a31160
commit df6dcfaf45
15 changed files with 54 additions and 35 deletions
+4
View File
@@ -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
}
-1
View File
@@ -21,7 +21,6 @@ if (os_level != "mini") {
"-Wextra",
"-Wshadow",
"-fstack-protector-all",
"-D_FORTIFY_SOURCE=2",
"-Wformat=2",
"-Wfloat-equal",
"-Wdate-time",
-1
View File
@@ -22,7 +22,6 @@ shared_library("kit_device_attest") {
"-Wextra",
"-Wshadow",
"-fstack-protector-all",
"-D_FORTIFY_SOURCE=2",
"-Wformat=2",
"-Wfloat-equal",
"-Wdate-time",
-13
View File
@@ -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",
+1 -1
View File
@@ -31,7 +31,7 @@ char* OsGetBuildRootHash(void)
char* OsGetDisplayVersion(void)
{
return AttestStrdup(GetOSFullName());
return AttestStrdup(GetDisplayVersion());
}
char* OsGetManufacture(void)
+1 -1
View File
@@ -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.");
@@ -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;
+1 -1
View File
@@ -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;
@@ -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 <hi_mdm.h>
#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__
@@ -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
@@ -17,11 +17,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include "utils_file.h"
#include <hi_tsensor.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -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 <hi_tsensor.h>
#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__
+2 -2
View File
@@ -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);
}
@@ -25,7 +25,7 @@
bool IsOverTemperatureLimit(void)
{
return true;
return false;
}
int32_t GetFileSize(const char* path, const char* fileName, uint32_t* result)
-1
View File
@@ -24,7 +24,6 @@ executable("devattest_client") {
"-Wextra",
"-Wshadow",
"-fstack-protector-all",
"-D_FORTIFY_SOURCE=2",
"-Wformat=2",
"-Wfloat-equal",
"-Wdate-time",
-1
View File
@@ -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",