diff --git a/common/include/dm_constants.h b/common/include/dm_constants.h index 0a2645f57234a62fd297432c44b7c54f216c1083..98484ad0627c505c543db6de4afe33da0adc2a36 100755 --- a/common/include/dm_constants.h +++ b/common/include/dm_constants.h @@ -182,7 +182,7 @@ extern const char* DM_VERSION_5_0_3; extern const char* DM_VERSION_5_0_4; extern const char* DM_VERSION_5_0_5; extern const char* DM_VERSION_5_1_0; -extern const char* DM_VERSION_5_1_1; +extern const char* DM_CURRENT_VERSION; extern const char* DM_ACL_AGING_VERSION; extern const char* DM_VERSION_5_0_OLD_MAX; // Estimated highest version number of the old version } // namespace DistributedHardware diff --git a/common/src/dm_constants.cpp b/common/src/dm_constants.cpp index 9be2b9fb7155033e0478433413a1cc37f8615d6c..f70b2272f119edc1426aba9e585d6932cbf06284 100644 --- a/common/src/dm_constants.cpp +++ b/common/src/dm_constants.cpp @@ -170,7 +170,7 @@ const char* DM_VERSION_5_0_3 = "5.0.3"; const char* DM_VERSION_5_0_4 = "5.0.4"; const char* DM_VERSION_5_0_5 = "5.0.5"; const char* DM_VERSION_5_1_0 = "5.1.0"; -const char* DM_VERSION_5_1_1 = "5.1.1"; +const char* DM_CURRENT_VERSION = DM_VERSION_5_1_0; const char* DM_ACL_AGING_VERSION = DM_VERSION_5_1_0; const char* DM_VERSION_5_0_OLD_MAX = "5.0.99"; // Estimated highest version number of the old version } // namespace DistributedHardware diff --git a/commondependency/src/deviceprofile_connector.cpp b/commondependency/src/deviceprofile_connector.cpp index aebb454592cb4e7a111c4f40760fd0e374aa785a..4b3a3b1dda40d5aa3b6c5316d630de34f47f3499 100644 --- a/commondependency/src/deviceprofile_connector.cpp +++ b/commondependency/src/deviceprofile_connector.cpp @@ -37,8 +37,6 @@ const uint32_t IDENTICAL_ACCOUNT_TYPE = 6; const uint32_t SERVICE_PEER_TO_PEER_TYPE = 7; const uint32_t SERVICE_ACROSS_ACCOUNT_TYPE = 8; -const int32_t USLEEP_TIME_US_120000 = 120000; // 120ms -constexpr uint32_t RETRY_TIMES = 3; const uint32_t DM_INVALIED_TYPE = 2048; const uint32_t SERVICE = 2; @@ -2198,34 +2196,18 @@ DmOfflineParam DeviceProfileConnector::HandleServiceUnBindEvent(int32_t remoteUs DM_EXPORT std::vector DeviceProfileConnector::GetAllAccessControlProfile() { std::vector profiles; - int32_t ret; - uint32_t retryTimes = 0; - do { - ret = DistributedDeviceProfileClient::GetInstance().GetAllAccessControlProfile(profiles); - if (ret != DM_OK) { - ++retryTimes; - LOGE("DP failed."); - usleep(USLEEP_TIME_US_120000); - } - } while (ret != DM_OK && retryTimes < RETRY_TIMES); - + if (DistributedDeviceProfileClient::GetInstance().GetAllAccessControlProfile(profiles) != DM_OK) { + LOGE("DP failed."); + } return profiles; } DM_EXPORT std::vector DeviceProfileConnector::GetAllAclIncludeLnnAcl() { std::vector profiles; - int32_t ret; - uint32_t retryTimes = 0; - do { - ret = DistributedDeviceProfileClient::GetInstance().GetAllAclIncludeLnnAcl(profiles); - if (ret != DM_OK) { - ++retryTimes; - LOGE("DP failed."); - usleep(USLEEP_TIME_US_120000); - } - } while (ret != DM_OK && retryTimes < RETRY_TIMES); - + if (DistributedDeviceProfileClient::GetInstance().GetAllAclIncludeLnnAcl(profiles) != DM_OK) { + LOGE("DP failed."); + } return profiles; } diff --git a/services/implementation/src/authentication_v2/auth_manager.cpp b/services/implementation/src/authentication_v2/auth_manager.cpp index 61c40a1b6e727b0bb36057c1f2b9d7411f7f2557..88668d9ddc83baf4679266941b6b6b548d27a214 100644 --- a/services/implementation/src/authentication_v2/auth_manager.cpp +++ b/services/implementation/src/authentication_v2/auth_manager.cpp @@ -24,8 +24,6 @@ #include "multiple_user_connector.h" #include "auth_manager.h" -#include "dm_auth_cert.h" -#include "dm_auth_attest_common.h" #include "dm_constants.h" #include "dm_crypto.h" #include "dm_random.h" @@ -133,8 +131,8 @@ AuthManager::AuthManager(std::shared_ptr softbusConnector, context_->authenticationMap[AUTH_TYPE_PIN_ULTRASONIC] = nullptr; context_->authenticationMap[AUTH_TYPE_NFC] = nullptr; context_->authenticationMap[AUTH_TYPE_CRE] = nullptr; - context_->accesser.dmVersion = DM_VERSION_5_1_1; - context_->accessee.dmVersion = DM_VERSION_5_1_1; + context_->accesser.dmVersion = DM_CURRENT_VERSION; + context_->accessee.dmVersion = DM_CURRENT_VERSION; context_->timer = std::make_shared(); context_->authMessageProcessor = std::make_shared(); } @@ -622,29 +620,6 @@ int32_t AuthManager::AuthenticateDevice(const std::string &pkgName, int32_t auth return DM_OK; } -std::string GenerateCertificate(std::shared_ptr context_) -{ -#ifdef DEVICE_MANAGER_COMMON_FLAG - if (context_ == nullptr) { - LOGE("context_ is nullptr!"); - return ""; - } - context_->accesser.isCommonFlag = true; - LOGI("Blue device do not generate cert!"); - return ""; -#else - DmCertChain dmCertChain; - int32_t certRet = AuthCert::GetInstance().GenerateCertificate(dmCertChain); - if (certRet != DM_OK) { - LOGE("generate cert fail, certRet = %{public}d", certRet); - return ""; - } - std::string cert = AuthAttestCommon::GetInstance().SerializeDmCertChain(&dmCertChain); - AuthAttestCommon::GetInstance().FreeDmCertChain(dmCertChain); - return cert; -#endif -} - int32_t AuthManager::BindTarget(const std::string &pkgName, const PeerTargetId &targetId, const std::map &bindParam, int sessionId, uint64_t logicalSessionId) { @@ -688,7 +663,6 @@ int32_t AuthManager::BindTarget(const std::string &pkgName, const PeerTargetId & return ERR_DM_INPUT_PARA_INVALID; } - context_->accesser.cert = GenerateCertificate(context_); context_->sessionId = sessionId; context_->logicalSessionId = logicalSessionId; context_->requestId = static_cast(logicalSessionId); diff --git a/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp b/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp index 0639821f5398a6ec18b3b22d16f9ff68a618b012..34f9d2967ada06eccf2a92b22dbe67285fea8772 100644 --- a/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp +++ b/services/implementation/src/authentication_v2/auth_stages/auth_negotiate.cpp @@ -182,47 +182,6 @@ int32_t AuthSinkNegotiateStateMachine::ProcRespNegotiate5_1_0(std::shared_ptr context) -{ -#ifdef DEVICE_MANAGER_COMMON_FLAG - (void)context; - LOGI("Blue device do not verify cert!"); - return DM_OK; -#else - // Compatible with 5.1.0 and earlier - if (!CompareVersion(context->accesser.dmVersion, DM_VERSION_5_1_0)) { - LOGI("cert verify is not supported"); - return DM_OK; - } - // Compatible common device - if (CompareVersion(context->accesser.dmVersion, DM_VERSION_5_1_0) - && context->accesser.isCommonFlag == true) { - LOGI("src is common device."); - if (DeviceProfileConnector::GetInstance() - .CheckIsSameAccountByUdidHash(context->accesser.deviceIdHash) == DM_OK) { - LOGE("src is common device, but the udidHash is identical in acl!"); - return ERR_DM_VERIFY_CERT_FAILED; - } - return DM_OK; - } - DmCertChain dmCertChain{nullptr, 0}; - if (!AuthAttestCommon::GetInstance() - .DeserializeDmCertChain(context->accesser.cert, &dmCertChain)) { - LOGE("cert deserialize fail!"); - return ERR_DM_DESERIAL_CERT_FAILED; - } - int32_t certRet = AuthCert::GetInstance() - .VerifyCertificate(dmCertChain, context->accesser.deviceIdHash.c_str()); - // free dmCertChain memory - AuthAttestCommon::GetInstance().FreeDmCertChain(dmCertChain); - if (certRet != DM_OK) { - LOGE("validate cert fail, certRet = %{public}d", certRet); - return ERR_DM_VERIFY_CERT_FAILED; - } - return DM_OK; -#endif -} - int32_t AuthSinkNegotiateStateMachine::Action(std::shared_ptr context) { LOGI("AuthSinkNegotiateStateMachine::Action sessionid %{public}d", context->sessionId); @@ -247,14 +206,7 @@ int32_t AuthSinkNegotiateStateMachine::Action(std::shared_ptr con context->reason = ERR_DM_VERSION_INCOMPATIBLE; return ERR_DM_VERSION_INCOMPATIBLE; } - // verify cert - int32_t ret = VerifyCertificate(context); - if (ret != DM_OK) { - LOGE("AuthSinkNegotiateStateMachine::Action cert verify fail!"); - context->reason = ret; - return ret; - } - ret = ProcRespNegotiate5_1_0(context); + int32_t ret = ProcRespNegotiate5_1_0(context); if (ret != DM_OK) { LOGE("AuthSinkNegotiateStateMachine::Action proc response negotiate failed"); context->reason = ret; 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 043302bf8374c79955eafed7cfcc7b5bd48afc6d..2dbaeb495b4b81d5fa625a148452703e5f8fd79d 100644 --- a/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_message_processor.cpp @@ -646,8 +646,6 @@ int32_t DmAuthMessageProcessor::CreateNegotiateMessage(std::shared_ptraccesser.tokenIdHash; jsonObject[TAG_BUNDLE_NAME_V2] = context->accesser.bundleName; jsonObject[TAG_EXTRA_INFO] = context->accesser.extraInfo; - jsonObject[TAG_IS_COMMON_FLAG] = context->accesser.isCommonFlag; - jsonObject[TAG_DM_CERT_CHAIN] = context->accesser.cert; jsonObject[TAG_PEER_BUNDLE_NAME_V2] = context->accessee.bundleName; jsonObject[TAG_ULTRASONIC_SIDE] = static_cast(context->ultrasonicInfo); @@ -1016,7 +1014,6 @@ int32_t DmAuthMessageProcessor::ParseNegotiateMessage( context->pkgLabel = jsonObject[TAG_HOST_PKGLABEL].Get(); } ParseUltrasonicSide(jsonObject, context); - ParseCert(jsonObject, context); context->authStateMachine->TransitionTo(std::make_shared()); return DM_OK; } diff --git a/services/implementation/src/device_manager_service_impl.cpp b/services/implementation/src/device_manager_service_impl.cpp index 3ffe3af1e93358c2dad87fea31653b9d923c452e..0d38868934dd057183e676d037900ceca26f7396 100644 --- a/services/implementation/src/device_manager_service_impl.cpp +++ b/services/implementation/src/device_manager_service_impl.cpp @@ -1147,7 +1147,7 @@ void DeviceManagerServiceImpl::OnBytesReceived(int sessionId, const void *data, return; } if (msgType == MSG_TYPE_REQ_ACL_NEGOTIATE || msgType == MSG_TYPE_RESP_ACL_NEGOTIATE) { - curSession->version_ = DM_VERSION_5_1_1; + curSession->version_ = DM_CURRENT_VERSION; } } else { /**