fix:clear devicekey

Signed-off-by: fangdong7 <fangdong7@huawei.com>
This commit is contained in:
fangdong7 2024-05-22 11:42:28 +00:00
parent 92df267f3e
commit 10757752b3
3 changed files with 10 additions and 9 deletions

View File

@ -416,8 +416,9 @@ static void SaveDeviceKey(AuthFsm *authFsm, int32_t keyType, AuthLinkType type)
deviceKey.isServerSide = authFsm->info.isServer;
if (AuthInsertDeviceKey(&authFsm->info.nodeInfo, &deviceKey, type) != SOFTBUS_OK) {
AUTH_LOGE(AUTH_FSM, "insert deviceKey fail");
return;
}
(void)memset_s(&deviceKey, sizeof(AuthDeviceKeyInfo), 0, sizeof(AuthDeviceKeyInfo));
(void)memset_s(&sessionKey, sizeof(SessionKey), 0, sizeof(SessionKey));
}
static void CompleteAuthSession(AuthFsm *authFsm, int32_t result)
@ -565,8 +566,10 @@ static int32_t RecoveryFastAuthKey(AuthFsm *authFsm)
ret = AuthSessionSaveSessionKey(authFsm->authSeq, key.deviceKey, key.keyLen);
if (ret != SOFTBUS_OK) {
AUTH_LOGE(AUTH_FSM, "post save sessionKey event");
(void)memset_s(&key, sizeof(AuthDeviceKeyInfo), 0, sizeof(AuthDeviceKeyInfo));
return ret;
}
(void)memset_s(&key, sizeof(AuthDeviceKeyInfo), 0, sizeof(AuthDeviceKeyInfo));
return AuthSessionHandleAuthFinish(authFsm->authSeq);
}

View File

@ -312,8 +312,8 @@ int32_t GetLatestSessionKey(const SessionKeyList *list, AuthLinkType type, int32
latestKey->lastUseTime = GetCurrentTimeMs();
latestKey->useTime[type] = latestKey->lastUseTime;
*index = latestKey->index;
AUTH_LOGI(AUTH_FSM, "get session key succ, index=%{public}d, type=%{public}u, time=%{public}" PRIu64,
latestKey->index, latestKey->type, latestKey->lastUseTime);
AUTH_LOGI(AUTH_FSM, "get session key succ, index=%{public}d, authtype=%{public}d, keytype=%{public}u, "
"time=%{public}" PRIu64, latestKey->index, type, latestKey->type, latestKey->lastUseTime);
return SOFTBUS_OK;
}

View File

@ -372,15 +372,13 @@ static bool IsNeedConnectOnLine(DeviceInfo *device, HbRespData *hbResp)
}
if (LnnRetrieveDeviceInfo(device->devId, &deviceInfo) != SOFTBUS_OK ||
strlen(deviceInfo.connectInfo.macAddr) == 0) {
LNN_LOGI(LNN_HEART_BEAT,
"don't support ble direct online because peer state version change, ver:%{public}d->%{public}d",
deviceInfo.stateVersion, (int32_t)hbResp->stateVersion);
LNN_LOGI(LNN_HEART_BEAT, "don't support ble direct online because retrieve fail, "
"stateVersion=%{public}d->%{public}d", deviceInfo.stateVersion, (int32_t)hbResp->stateVersion);
return true;
}
if (LnnGetLocalNumInfo(NUM_KEY_STATE_VERSION, &stateVersion) == SOFTBUS_OK &&
stateVersion != deviceInfo.localStateVersion) {
LNN_LOGI(LNN_HEART_BEAT,
"don't support ble direct online because local state version change, ver:%{public}d->%{public}d",
LNN_LOGI(LNN_HEART_BEAT, "don't support ble direct online because local stateVersion=%{public}d->%{public}d",
deviceInfo.localStateVersion, stateVersion);
return true;
}
@ -395,7 +393,7 @@ static bool IsNeedConnectOnLine(DeviceInfo *device, HbRespData *hbResp)
LNN_LOGI(LNN_HEART_BEAT, "don't support ble direct online because key not exist");
return true;
}
// update capability
(void)memset_s(&keyInfo, sizeof(AuthDeviceKeyInfo), 0, sizeof(AuthDeviceKeyInfo));
SetDeviceNetCapability(&deviceInfo.netCapacity, hbResp);
if ((ret = LnnUpdateRemoteDeviceInfo(&deviceInfo)) != SOFTBUS_OK) {
LNN_LOGE(LNN_HEART_BEAT, "don't support ble direct online because update device info fail ret=%{public}d", ret);