Files
Sun1602/Tools/WiseClient/Sessions/ServerSession.PacketCrypt.cpp
T
2022-10-26 12:25:11 +08:00

64 lines
1.7 KiB
C++

#include "stdafx.h"
#include <PacketStruct_CG.h>
#include "ServerSession.h"
// (SUN_SECURE)
void ClientCryptPack4Packet::InitCryptInfo(
DWORD dwUserKey,
BYTE byProtoMajorVer,
BYTE byProtoMinorVer)
{
NODE.m_SNKey.Initialize(dwUserKey, byProtoMajorVer, byProtoMinorVer);
}
//////////////////////////////////////////////////////////////////////////
// (ABOUNT_CRYPT)
// MSG_CG_CRYPTOGRAPHY_KEY 수신시 CryptManager Instance 만들기
BOOL ClientCryptPack4Packet::SetCryptographyInfo(MSG_BASE* pMsg)
{
MSG_CG_CRYPTOGRAPHY_KEY* pRecvMsg = (MSG_CG_CRYPTOGRAPHY_KEY *)pMsg;
DWORD dwUserKey = CryptManager::GetUserKeyInCryptInfo(pRecvMsg->GetCryptStream());
InitCryptInfo(dwUserKey, C2S_HIGH_VERSION_NO, C2S_MIDDLE_VERSION_NO);
#ifdef __NA000630_070817_MOLA_5th_UPDATE
printf("RandomKEY %08X\n", dwUserKey);
#endif //
CryptManagerDeletator& rMANAGER = NODE.m_pCryptManager;
if(GetRecvSNKey() == pRecvMsg->GetSNKey())
{
rMANAGER = CryptManager::SetCryptAlgorithmInfo(
GetRecvPairSNKey(),
pRecvMsg->GetCryptStream(),
pRecvMsg->GetCryptInfo());
SetUsePacketCrypt(TRUE);
NextRoundSNKey4Recv();
return TRUE;
}
else
{
return FALSE;
}
}
// MSG_CG_CRYPTOGRAPHY_SNK_KEY 수신시 SNK 변환
BOOL ClientCryptPack4Packet::SetCryptographyInfo_SNK(MSG_BASE* pMsg)
{
MSG_CG_CRYPTOGRAPHY_SNK_KEY* pRecvMsg = (MSG_CG_CRYPTOGRAPHY_SNK_KEY*)pMsg;
KEY4SNKey() = pRecvMsg->m_dwSNKey;
GetClientSNKey().Initialize(pRecvMsg->m_dwSNKey, C2S_HIGH_VERSION_NO, C2S_MIDDLE_VERSION_NO);
return TRUE;
}
// Get Instance for CLIENT
//inline CryptManager* ClientCryptPack4Packet::SetCryptAlgorithmInfo(BYTE byPairSNKey, BYTE* IN cryptInfo, BYTE cryptIdx);