From 7908a166d19f6715fe601eae4e07de98373d8729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B7=8D?= Date: Wed, 6 Aug 2025 14:37:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李巍 --- .../implementation/src/attest/dm_auth_attest_common.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/implementation/src/attest/dm_auth_attest_common.cpp b/services/implementation/src/attest/dm_auth_attest_common.cpp index 16d2f7617..9819b7439 100644 --- a/services/implementation/src/attest/dm_auth_attest_common.cpp +++ b/services/implementation/src/attest/dm_auth_attest_common.cpp @@ -21,7 +21,7 @@ namespace OHOS { namespace DistributedHardware { -const int32_t MAX_CERT_COUNT = 100; +const int32_t DM_CERT_COUNT = 4; constexpr int32_t HEX_TO_UINT8 = 2; const int32_t MAX_LEN_PER_CERT = 8192; @@ -37,7 +37,7 @@ AuthAttestCommon::~AuthAttestCommon() std::string AuthAttestCommon::SerializeDmCertChain(const DmCertChain *chain) { - if (chain == nullptr || chain->cert == nullptr || chain->certCount == 0 || chain->certCount > MAX_CERT_COUNT) { + if (chain == nullptr || chain->cert == nullptr || chain->certCount != DM_CERT_COUNT) { LOGE("input param is invalid."); return "{}"; } @@ -78,7 +78,7 @@ bool ValidateInputJson(const std::string &data) return false; } const uint32_t certCount = jsonObject[TAG_CERT_COUNT].Get(); - if (certCount == 0 || certCount > MAX_CERT_COUNT) { + if (certCount != DM_CERT_COUNT) { LOGE("Invalid certCount value %{public}u", certCount); return false; } -- Gitee From d0a6a5be7fc17aa9ee08d040d89c43380d4c10f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=B7=8D?= Date: Wed, 6 Aug 2025 16:11:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 李巍 --- .../src/attest/dm_auth_attest_common.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/services/implementation/src/attest/dm_auth_attest_common.cpp b/services/implementation/src/attest/dm_auth_attest_common.cpp index 9819b7439..2ac048f9d 100644 --- a/services/implementation/src/attest/dm_auth_attest_common.cpp +++ b/services/implementation/src/attest/dm_auth_attest_common.cpp @@ -21,9 +21,7 @@ namespace OHOS { namespace DistributedHardware { -const int32_t DM_CERT_COUNT = 4; constexpr int32_t HEX_TO_UINT8 = 2; -const int32_t MAX_LEN_PER_CERT = 8192; AuthAttestCommon::AuthAttestCommon() { @@ -37,7 +35,7 @@ AuthAttestCommon::~AuthAttestCommon() std::string AuthAttestCommon::SerializeDmCertChain(const DmCertChain *chain) { - if (chain == nullptr || chain->cert == nullptr || chain->certCount != DM_CERT_COUNT) { + if (chain == nullptr || chain->cert == nullptr || chain->certCount != DM_CERTS_COUNT) { LOGE("input param is invalid."); return "{}"; } @@ -46,7 +44,7 @@ std::string AuthAttestCommon::SerializeDmCertChain(const DmCertChain *chain) JsonObject jsonArrayObj(JsonCreateType::JSON_CREATE_TYPE_ARRAY); for (uint32_t i = 0; i < chain->certCount; ++i) { const DmBlob &blob = chain->cert[i]; - if (blob.data == nullptr || blob.size == 0 || blob.size > MAX_LEN_PER_CERT) { + if (blob.data == nullptr || blob.size == 0 || blob.size > DM_CERTIFICATE_SIZE) { LOGE("Invalid blob: null data or invalid size."); return "{}"; } @@ -78,7 +76,7 @@ bool ValidateInputJson(const std::string &data) return false; } const uint32_t certCount = jsonObject[TAG_CERT_COUNT].Get(); - if (certCount != DM_CERT_COUNT) { + if (certCount != DM_CERTS_COUNT) { LOGE("Invalid certCount value %{public}u", certCount); return false; } @@ -101,7 +99,7 @@ bool ValidateInputJson(const std::string &data) return false; } const uint32_t binSize = hexLen / HEX_TO_UINT8; - if (binSize > MAX_LEN_PER_CERT) { + if (binSize > DM_CERTIFICATE_SIZE) { LOGE("binSize = %{public}u is invalid.", binSize); return false; } -- Gitee