From 484ccbc3fe0331912e9c513ab3d243d3eb1128aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 14:51:30 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/include/dm_anonymous.h | 1 + common/src/dm_anonymous.cpp | 15 +++++++++++++++ .../auth_stages/auth_credential.cpp | 6 +++--- .../dm_auth_message_processor.cpp | 7 ++++--- .../hichain/hichain_auth_connector.cpp | 16 +++++++--------- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/common/include/dm_anonymous.h b/common/include/dm_anonymous.h index 2e3647104..46a5734f6 100644 --- a/common/include/dm_anonymous.h +++ b/common/include/dm_anonymous.h @@ -106,6 +106,7 @@ bool IsDmCommonNotifyEventValid(DmCommonNotifyEvent dmCommonNotifyEvent); DM_EXPORT std::string SafetyDump(const JsonItemObject &jsonObj); std::string GetSubStr(const std::string &rawStr, const std::string &separator, int32_t index); bool IsJsonValIntegerString(const JsonItemObject &jsonObj, const std::string &key); +std::string GetAnonyJsonString(const std::string &value); } // namespace DistributedHardware } // namespace OHOS #endif // OHOS_DM_ANONYMOUS_H diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 6a4c57063..2ffd8820c 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -437,5 +437,20 @@ bool IsJsonValIntegerString(const JsonItemObject &jsonObj, const std::string &ke } return true; } + +std::string GetAnonyJsonString(const std::string &value) +{ + std::string retVal; + JsonObject paramJson(value); + if (paramJson.IsDiscarded()) { + return ""; + } + for (auto &element : paramJson.Items()) { + if (element.IsString()) { + paramJson[element.Key()] = GetAnonyString(element.Get()); + } + } + return paramJson.Dump(); +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_credential.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_credential.cpp index 63cb2286a..a483b4ad8 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_credential.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_credential.cpp @@ -315,8 +315,8 @@ int32_t AuthCredentialAgreeState::GenerateCredIdAndPublicKey(DmAuthScope authori (void)authContext->SetCredentialId(DM_AUTH_LOCAL_SIDE, authorizedScope, credId); (void)authContext->SetPublicKey(DM_AUTH_LOCAL_SIDE, authorizedScope, publicKey); LOGI("AuthCredentialAgreeState::GenerateCredIdAndPublicKey credId=%{public}s, publicKey=%{public}s.\n", - authContext->GetCredentialId(DM_AUTH_LOCAL_SIDE, authorizedScope).c_str(), - authContext->GetPublicKey(DM_AUTH_LOCAL_SIDE, authorizedScope).c_str()); + GetAnonyString(authContext->GetCredentialId(DM_AUTH_LOCAL_SIDE, authorizedScope)).c_str(), + GetAnonyString(authContext->GetPublicKey(DM_AUTH_LOCAL_SIDE, authorizedScope)).c_str()); LOGI("AuthCredentialAgreeState::GenerateCredIdAndPublicKey leave."); return DM_OK; } @@ -343,7 +343,7 @@ int32_t AuthCredentialAgreeState::AgreeCredential(DmAuthScope authorizedScope, std::string selfCredId = authContext->GetCredentialId(DM_AUTH_LOCAL_SIDE, authorizedScope); std::string credId; LOGI("AuthCredentialAgreeState::AgreeCredential agree with accountId %{public}d and param %{public}s.", - osAccountId, authParamsString.c_str()); + osAccountId, GetAnonyJsonString(authParamsString).c_str()); int32_t ret = authContext->hiChainAuthConnector->AgreeCredential(osAccountId, selfCredId, authParamsString, credId); if (ret != DM_OK) { diff --git a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp index 38427822c..00e81e4d3 100644 --- a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp @@ -545,8 +545,8 @@ int32_t DmAuthMessageProcessor::ParseMessageRspCredExchange(const JsonObject &js LOGE("DmAuthMessageProcessor::ParseMessageRspCredExchange error, decrypt data failed."); return ERR_DM_FAILED; } - - LOGI("DmAuthMessageProcessor::ParseMessageRspCredExchange plainText=%{public}s", plainText.c_str()); + LOGI("DmAuthMessageProcessor::ParseMessageRspCredExchange plainText=%{public}s", + GetAnonyJsonString(plainText).c_str()); JsonObject jsonData(plainText); @@ -590,7 +590,8 @@ std::string DmAuthMessageProcessor::CreateMessage(DmMessageType msgType, std::sh return ""; } int32_t ret = (this->*(itr->second))(context, jsonObj); - LOGI("DmAuthMessageProcessor::CreateMessage start. message is %{public}s", jsonObj.Dump().c_str()); + LOGI("DmAuthMessageProcessor::CreateMessage start. message is %{public}s", + GetAnonyJsonString(jsonObj.Dump()).c_str()); return (ret == DM_OK) ? jsonObj.Dump() : ""; } diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index f3147e155..58c4bd21b 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -154,7 +154,7 @@ int32_t HiChainAuthConnector::AddCredential(int32_t osAccountId, const std::stri { LOGI("HiChainAuthConnector::AddCredential start."); LOGI("HiChainAuthConnector::AddCredential osAccount=%{public}d, authParams=%{public}s\n", - osAccountId, authParams.c_str()); + osAccountId, GetAnonyJsonString(authParams).c_str()); char *returnData = NULL; const CredManager *credManager = GetCredMgrInstance(); int32_t ret = credManager->addCredential(osAccountId, authParams.c_str(), &returnData); @@ -163,9 +163,7 @@ int32_t HiChainAuthConnector::AddCredential(int32_t osAccountId, const std::stri return ERR_DM_FAILED; } LOGI("HiChainAuthConnector::AddCredential addCredential success ret=%{public}d, returnData=%{public}s.", - ret, returnData); - credId = std::string(returnData); - LOGI("HiChainAuthConnector::AddCredential addCredId=%{public}s.", credId.c_str()); + ret, GetAnonyString(returnData).c_str()); credManager->destroyInfo(&returnData); LOGI("HiChainAuthConnector::AddCredential leave."); return DM_OK; @@ -174,7 +172,7 @@ int32_t HiChainAuthConnector::AddCredential(int32_t osAccountId, const std::stri int32_t HiChainAuthConnector::ExportCredential(int32_t osAccountId, const std::string &credId, std::string &publicKey) { LOGI("HiChainAuthConnector::ExportCredential start. osAccountId=%{public}d, credId=%{public}s", - osAccountId, credId.c_str()); + osAccountId, GetAnonyString(credId).c_str()); char *returnData = NULL; const CredManager *credManager = GetCredMgrInstance(); int32_t ret = credManager->exportCredential(osAccountId, credId.c_str(), &returnData); @@ -191,7 +189,7 @@ int32_t HiChainAuthConnector::ExportCredential(int32_t osAccountId, const std::s } publicKey = jsonAuthParam["keyValue"].Get(); - LOGI("HiChainAuthConnector::ExportCredential leave. publicKey=%{public}s", publicKey.c_str()); + LOGI("HiChainAuthConnector::ExportCredential leave. publicKey=%{public}s", GetAnonyString(publicKey).c_str()); return DM_OK; } @@ -208,14 +206,14 @@ int32_t HiChainAuthConnector::AgreeCredential(int32_t osAccountId, const std::st } credId = returnData; credManager->destroyInfo(&returnData); - LOGI("HiChainAuthConnector::AgreeCredential leave agreeCredId=%{public}s.", credId.c_str()); + LOGI("HiChainAuthConnector::AgreeCredential leave agreeCredId=%{public}s.", GetAnonyString(credId).c_str()); return DM_OK; } int32_t HiChainAuthConnector::DeleteCredential(int32_t osAccountId, const std::string &credId) { LOGI("HiChainAuthConnector::DeleteCredential start. osAccountId=%{public}d, credId=%{public}s", osAccountId, - credId.c_str()); + GetAnonyString(credId).c_str()); const CredManager *credManager = GetCredMgrInstance(); int32_t ret = credManager->deleteCredential(osAccountId, credId.c_str()); if (ret != HC_SUCCESS) { @@ -230,7 +228,7 @@ int32_t HiChainAuthConnector::AuthCredential(int32_t osAccountId, int64_t authRe const std::string &pinCode) { LOGI("HiChainAuthConnector::AuthCredential start. osAccountId=%{public}d, credId=%{public}s", osAccountId, - credId.c_str()); + GetAnonyString(credId).c_str()); if (credId.empty() && pinCode.empty()) { LOGE("HiChainAuthConnector::AuthCredential failed, credId and pinCode is empty."); return ERR_DM_FAILED; -- Gitee From d0ebbe775c38b38a863b29fff6605211c4cc1eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 16:20:00 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/src/dm_anonymous.cpp | 27 +++++++++++++++++-- .../hichain/hichain_auth_connector.cpp | 2 ++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 2ffd8820c..5fa7cb055 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -440,14 +440,37 @@ bool IsJsonValIntegerString(const JsonItemObject &jsonObj, const std::string &ke std::string GetAnonyJsonString(const std::string &value) { - std::string retVal; + const char* TAG_LOCAL_DEVICE_ID = "LOCALDEVICEID"; + const char* TAG_LOCAL_ACCOUNTID = "localAccountId"; + const char* TAG_DATA = "data"; + const char* TAG_NETWORKID_ID = "networkId"; + const char* TAG_LNN_PUBLIC_KEY = "lnnPublicKey"; + const char* TAG_TRANSMIT_PUBLIC_KEY = "transmitPublicKey"; + const char* TAG_DEVICE_ID = "DEVICEID"; + const char* TAG_LOWER_DEVICE_ID = "deviceId"; + const char* TAG_KEY_VALUE = "keyValue"; + JsonObject paramJson(value); if (paramJson.IsDiscarded()) { return ""; } for (auto &element : paramJson.Items()) { if (element.IsString()) { - paramJson[element.Key()] = GetAnonyString(element.Get()); + switch (element.Key()) { + case TAG_LOCAL_DEVICE_ID: + case TAG_LOCAL_ACCOUNTID: + case TAG_DATA: + case TAG_NETWORKID_ID: + case TAG_LNN_PUBLIC_KEY: + case TAG_TRANSMIT_PUBLIC_KEY: + case TAG_DEVICE_ID: + case TAG_LOWER_DEVICE_ID: + case TAG_KEY_VALUE: + paramJson[element.Key()] = GetAnonyString(element.Get()); + break; + default: + break; + } } } return paramJson.Dump(); diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index 58c4bd21b..6c4a0545e 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -164,6 +164,8 @@ int32_t HiChainAuthConnector::AddCredential(int32_t osAccountId, const std::stri } LOGI("HiChainAuthConnector::AddCredential addCredential success ret=%{public}d, returnData=%{public}s.", ret, GetAnonyString(returnData).c_str()); + credId = std::string(returnData); + LOGI("HiChainAuthConnector::AddCredential addCredId=%{public}s.", GetAnonyString(credId).c_str()); credManager->destroyInfo(&returnData); LOGI("HiChainAuthConnector::AddCredential leave."); return DM_OK; -- Gitee From a4c3e12c7cea01fab6ba42505d04b9aa2895ed59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 16:29:29 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../src/dependency/hichain/hichain_auth_connector.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index 71d197b48..cf46c4ad2 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -220,7 +220,6 @@ int32_t HiChainAuthConnector::DeleteCredential(int32_t osAccountId, const std::s int32_t HiChainAuthConnector::AuthCredential(int32_t osAccountId, int64_t authReqId, const std::string &credId, const std::string &pinCode) { - LOGI("HiChainAuthConnector::AuthCredential start. osAccountId=%{public}d, credId=%{public}s", osAccountId, LOGI("start. osAccountId=%{public}s, credId=%{public}s", GetAnonyInt32(osAccountId).c_str(), GetAnonyString(credId).c_str()); if (credId.empty() && pinCode.empty()) { -- Gitee From 34f1c5ad25e53f594f2a040d16e31abb4461a959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 17:29:22 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/src/dm_anonymous.cpp | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 5fa7cb055..b428ba557 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -440,37 +440,18 @@ bool IsJsonValIntegerString(const JsonItemObject &jsonObj, const std::string &ke std::string GetAnonyJsonString(const std::string &value) { - const char* TAG_LOCAL_DEVICE_ID = "LOCALDEVICEID"; - const char* TAG_LOCAL_ACCOUNTID = "localAccountId"; - const char* TAG_DATA = "data"; - const char* TAG_NETWORKID_ID = "networkId"; - const char* TAG_LNN_PUBLIC_KEY = "lnnPublicKey"; - const char* TAG_TRANSMIT_PUBLIC_KEY = "transmitPublicKey"; - const char* TAG_DEVICE_ID = "DEVICEID"; - const char* TAG_LOWER_DEVICE_ID = "deviceId"; - const char* TAG_KEY_VALUE = "keyValue"; - JsonObject paramJson(value); if (paramJson.IsDiscarded()) { return ""; } for (auto &element : paramJson.Items()) { - if (element.IsString()) { - switch (element.Key()) { - case TAG_LOCAL_DEVICE_ID: - case TAG_LOCAL_ACCOUNTID: - case TAG_DATA: - case TAG_NETWORKID_ID: - case TAG_LNN_PUBLIC_KEY: - case TAG_TRANSMIT_PUBLIC_KEY: - case TAG_DEVICE_ID: - case TAG_LOWER_DEVICE_ID: - case TAG_KEY_VALUE: - paramJson[element.Key()] = GetAnonyString(element.Get()); - break; - default: - break; - } + std::string keyStr(element.Key()) + if (element.IsString() && (keyStr == "LOCALDEVICEID" || keyStr == "localAccountId" || + keyStr == "data" || keyStr == "networkId" || keyStr == "lnnPublicKey" || + keyStr == "transmitPublicKey" || keyStr == "DEVICEID" || keyStr == "deviceId" || + keyStr == "keyValue")) { + paramJson[keyStr] = GetAnonyString(element.Get()); + } } return paramJson.Dump(); -- Gitee From 1fd7d3001e1a6ef0857ef884443ea599ddaad857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 17:31:34 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/src/dm_anonymous.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index b428ba557..c29f146ac 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -440,6 +440,9 @@ bool IsJsonValIntegerString(const JsonItemObject &jsonObj, const std::string &ke std::string GetAnonyJsonString(const std::string &value) { + if (value.empty()) { + return ""; + } JsonObject paramJson(value); if (paramJson.IsDiscarded()) { return ""; -- Gitee From 105e149db4cb7f08a3210c2abf9c5f0abbd52ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 17:38:42 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/src/dm_anonymous.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index c29f146ac..053e2c2ad 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -454,7 +454,6 @@ std::string GetAnonyJsonString(const std::string &value) keyStr == "transmitPublicKey" || keyStr == "DEVICEID" || keyStr == "deviceId" || keyStr == "keyValue")) { paramJson[keyStr] = GetAnonyString(element.Get()); - } } return paramJson.Dump(); -- Gitee From 6765403c3f8d45396099b3f455b1b42697b444b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 17:40:35 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/src/dm_anonymous.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 053e2c2ad..cc99954fb 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -448,7 +448,7 @@ std::string GetAnonyJsonString(const std::string &value) return ""; } for (auto &element : paramJson.Items()) { - std::string keyStr(element.Key()) + std::string keyStr(element.Key()); if (element.IsString() && (keyStr == "LOCALDEVICEID" || keyStr == "localAccountId" || keyStr == "data" || keyStr == "networkId" || keyStr == "lnnPublicKey" || keyStr == "transmitPublicKey" || keyStr == "DEVICEID" || keyStr == "deviceId" || -- Gitee From bfc09882d731dbe924e0848b36451b60e2791d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 18:18:55 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/src/dm_anonymous.cpp | 6 +++--- .../src/authentication_v2/dm_auth_message_processor.cpp | 2 +- .../src/dependency/hichain/hichain_auth_connector.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index cc99954fb..81d9facfc 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -450,9 +450,9 @@ std::string GetAnonyJsonString(const std::string &value) for (auto &element : paramJson.Items()) { std::string keyStr(element.Key()); if (element.IsString() && (keyStr == "LOCALDEVICEID" || keyStr == "localAccountId" || - keyStr == "data" || keyStr == "networkId" || keyStr == "lnnPublicKey" || - keyStr == "transmitPublicKey" || keyStr == "DEVICEID" || keyStr == "deviceId" || - keyStr == "keyValue")) { + keyStr == "networkId" || keyStr == "lnnPublicKey" || keyStr == "transmitPublicKey" || + keyStr == "DEVICEID" || keyStr == "deviceId" || keyStr == "keyValue" || + keyStr == "deviceName")) { paramJson[keyStr] = GetAnonyString(element.Get()); } } diff --git a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp index 00e81e4d3..2b1bc4875 100644 --- a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp @@ -719,7 +719,7 @@ int32_t DmAuthMessageProcessor::CreateMessageRspCredExchange(std::shared_ptrEncryptMessage(plainText, cipherText); if (ret != DM_OK) { LOGI("DmAuthMessageProcessor::CreateMessageRspCredExchange encryptMessage failed."); diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index cf46c4ad2..1aa95927e 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -158,7 +158,7 @@ int32_t HiChainAuthConnector::AddCredential(int32_t osAccountId, const std::stri LOGE("Hichain addCredential failed ret %{public}d.", ret); return ERR_DM_FAILED; } - LOGI("success ret=%{public}d, returnData=%{public}s.", ret, returnData); + LOGI("success ret=%{public}d, returnData=%{public}s.", ret, GetAnonyString(returnData).c_str()); credId = std::string(returnData); credManager->destroyInfo(&returnData); return DM_OK; @@ -166,7 +166,7 @@ int32_t HiChainAuthConnector::AddCredential(int32_t osAccountId, const std::stri int32_t HiChainAuthConnector::ExportCredential(int32_t osAccountId, const std::string &credId, std::string &publicKey) { - LOGI("start. osAccountId=%{public}d, credId=%{public}s", osAccountId, credId.c_str()); + LOGI("start. osAccountId=%{public}d, credId=%{public}s", osAccountId, GetAnonyString(credId).c_str()); char *returnData = NULL; const CredManager *credManager = GetCredMgrInstance(); int32_t ret = credManager->exportCredential(osAccountId, credId.c_str(), &returnData); -- Gitee From 38c036850db2d949a2311eabacaad121ecbc136b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 18:23:52 +0800 Subject: [PATCH 09/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- .../src/authentication_v2/dm_auth_message_processor.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp index 2b1bc4875..495371b11 100644 --- a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp @@ -545,8 +545,7 @@ int32_t DmAuthMessageProcessor::ParseMessageRspCredExchange(const JsonObject &js LOGE("DmAuthMessageProcessor::ParseMessageRspCredExchange error, decrypt data failed."); return ERR_DM_FAILED; } - LOGI("DmAuthMessageProcessor::ParseMessageRspCredExchange plainText=%{public}s", - GetAnonyJsonString(plainText).c_str()); + LOGI("plainText=%{public}s", GetAnonyJsonString(plainText).c_str()); JsonObject jsonData(plainText); @@ -590,8 +589,7 @@ std::string DmAuthMessageProcessor::CreateMessage(DmMessageType msgType, std::sh return ""; } int32_t ret = (this->*(itr->second))(context, jsonObj); - LOGI("DmAuthMessageProcessor::CreateMessage start. message is %{public}s", - GetAnonyJsonString(jsonObj.Dump()).c_str()); + LOGI("start. message is %{public}s", GetAnonyJsonString(jsonObj.Dump()).c_str()); return (ret == DM_OK) ? jsonObj.Dump() : ""; } -- Gitee From 571e640077abfa88fa4b9b8c6c469d16d750af00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 18:56:55 +0800 Subject: [PATCH 10/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/src/dm_anonymous.cpp | 3 ++- .../src/dependency/hichain/hichain_auth_connector.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 81d9facfc..5b972054d 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -449,10 +449,11 @@ std::string GetAnonyJsonString(const std::string &value) } for (auto &element : paramJson.Items()) { std::string keyStr(element.Key()); + keyStr. if (element.IsString() && (keyStr == "LOCALDEVICEID" || keyStr == "localAccountId" || keyStr == "networkId" || keyStr == "lnnPublicKey" || keyStr == "transmitPublicKey" || keyStr == "DEVICEID" || keyStr == "deviceId" || keyStr == "keyValue" || - keyStr == "deviceName")) { + keyStr == "deviceName" || keyStr == "REMOTE_DEVICE_NAME" || keyStr == "data")) { paramJson[keyStr] = GetAnonyString(element.Get()); } } diff --git a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp index 1aa95927e..28759e22c 100644 --- a/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp +++ b/services/implementation/src/dependency/hichain/hichain_auth_connector.cpp @@ -200,7 +200,7 @@ int32_t HiChainAuthConnector::AgreeCredential(int32_t osAccountId, const std::st } credId = returnData; credManager->destroyInfo(&returnData); - LOGI("leave agreeCredId=%{public}s.", credId.c_str()); + LOGI("leave agreeCredId=%{public}s.", GetAnonyString(credId).c_str()); return DM_OK; } -- Gitee From b5daa5763c17e64fc077f38bd273641b1f4e9e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 19:02:34 +0800 Subject: [PATCH 11/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/src/dm_anonymous.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 5b972054d..87975f87f 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -449,7 +449,6 @@ std::string GetAnonyJsonString(const std::string &value) } for (auto &element : paramJson.Items()) { std::string keyStr(element.Key()); - keyStr. if (element.IsString() && (keyStr == "LOCALDEVICEID" || keyStr == "localAccountId" || keyStr == "networkId" || keyStr == "lnnPublicKey" || keyStr == "transmitPublicKey" || keyStr == "DEVICEID" || keyStr == "deviceId" || keyStr == "keyValue" || -- Gitee From 8e25396d37a7d9693ce6cfb6b88ff517d73169e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 19:19:47 +0800 Subject: [PATCH 12/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/src/dm_anonymous.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 87975f87f..a910ad2c7 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -447,13 +447,13 @@ std::string GetAnonyJsonString(const std::string &value) if (paramJson.IsDiscarded()) { return ""; } + const std::set Sensitive_Key = { "LOCALDEVICEID", "localAccountId", "networkId", + "lnnPublicKey", "transmitPublicKey", "DEVICEID", "deviceId", "keyValue", "deviceName", "REMOTE_DEVICE_NAME", + "data" }; for (auto &element : paramJson.Items()) { std::string keyStr(element.Key()); - if (element.IsString() && (keyStr == "LOCALDEVICEID" || keyStr == "localAccountId" || - keyStr == "networkId" || keyStr == "lnnPublicKey" || keyStr == "transmitPublicKey" || - keyStr == "DEVICEID" || keyStr == "deviceId" || keyStr == "keyValue" || - keyStr == "deviceName" || keyStr == "REMOTE_DEVICE_NAME" || keyStr == "data")) { - paramJson[keyStr] = GetAnonyString(element.Get()); + if (element.IsString() && Sensitive_Key.find(keyStr) != Sensitive_Key.end())) { + paramJson[keyStr] = GetAnonyString(element.Get()); } } return paramJson.Dump(); -- Gitee From 70d5099fb9cbde54d8978154532c6f6cac77c764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 19:24:01 +0800 Subject: [PATCH 13/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/src/dm_anonymous.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index a910ad2c7..4f38d76ef 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -447,9 +447,9 @@ std::string GetAnonyJsonString(const std::string &value) if (paramJson.IsDiscarded()) { return ""; } - const std::set Sensitive_Key = { "LOCALDEVICEID", "localAccountId", "networkId", - "lnnPublicKey", "transmitPublicKey", "DEVICEID", "deviceId", "keyValue", "deviceName", "REMOTE_DEVICE_NAME", - "data" }; + const std::set Sensitive_Key = { "LOCALDEVICEID", "localAccountId", "networkId", "lnnPublicKey", + "transmitPublicKey", "DEVICEID", "deviceId", "keyValue", "deviceName", "REMOTE_DEVICE_NAME", "data" }; + for (auto &element : paramJson.Items()) { std::string keyStr(element.Key()); if (element.IsString() && Sensitive_Key.find(keyStr) != Sensitive_Key.end())) { -- Gitee From f154d9cf1350c0347817d64ac3c339335ef06020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Sat, 17 May 2025 19:25:48 +0800 Subject: [PATCH 14/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/src/dm_anonymous.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index 4f38d76ef..ea51b2b76 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -451,9 +451,8 @@ std::string GetAnonyJsonString(const std::string &value) "transmitPublicKey", "DEVICEID", "deviceId", "keyValue", "deviceName", "REMOTE_DEVICE_NAME", "data" }; for (auto &element : paramJson.Items()) { - std::string keyStr(element.Key()); - if (element.IsString() && Sensitive_Key.find(keyStr) != Sensitive_Key.end())) { - paramJson[keyStr] = GetAnonyString(element.Get()); + if (element.IsString() && Sensitive_Key.find(element.Key()) != Sensitive_Key.end())) { + paramJson[element.Key()] = GetAnonyString(element.Get()); } } return paramJson.Dump(); -- Gitee From ceda9f5f5bee4803714b73d8f5ac27cdb2d0dd2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E6=99=93=E6=99=93?= Date: Mon, 19 May 2025 09:15:59 +0800 Subject: [PATCH 15/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史晓晓 --- common/src/dm_anonymous.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/src/dm_anonymous.cpp b/common/src/dm_anonymous.cpp index ea51b2b76..77f9f64d6 100644 --- a/common/src/dm_anonymous.cpp +++ b/common/src/dm_anonymous.cpp @@ -16,6 +16,8 @@ #include "dm_anonymous.h" #include "dm_log.h" #include +#include + namespace OHOS { namespace DistributedHardware { namespace { @@ -451,7 +453,7 @@ std::string GetAnonyJsonString(const std::string &value) "transmitPublicKey", "DEVICEID", "deviceId", "keyValue", "deviceName", "REMOTE_DEVICE_NAME", "data" }; for (auto &element : paramJson.Items()) { - if (element.IsString() && Sensitive_Key.find(element.Key()) != Sensitive_Key.end())) { + if (element.IsString() && Sensitive_Key.find(element.Key()) != Sensitive_Key.end()) { paramJson[element.Key()] = GetAnonyString(element.Get()); } } -- Gitee