feat: upgrade stream cipher from XOR to AES-128-CTR

Replace the XOR obfuscation cipher with AES-128-CTR using the Windows
BCrypt API. Key material grows from 16 to 32 bytes (16 AES key + 16 IV).
All callers auto-adjust via StreamCipher::KEY_SIZE. No handshake or
protocol changes needed beyond the larger MC|CKey payload.
This commit is contained in:
itsRevela
2026-03-28 20:10:35 -05:00
parent 1036c360dc
commit 245da783b3
6 changed files with 211 additions and 59 deletions

View File

@@ -310,7 +310,7 @@ bool WinsockNetLayer::SendAckAndActivateClientSendCipher()
{
// Activate send cipher immediately after the ack is on the wire
EnterCriticalSection(&s_clientCipherLock);
s_clientSendCipher.Initialize(s_clientPendingKey);
s_clientSendCipher.Initialize(s_clientPendingKey, ServerRuntime::Security::StreamCipher::Client);
LeaveCriticalSection(&s_clientCipherLock);
app.DebugPrintf("Client: Send cipher activated (MC|CAck sent)\n");
}
@@ -329,7 +329,7 @@ bool WinsockNetLayer::SendAckAndActivateClientSendCipher()
void WinsockNetLayer::ActivateClientRecvCipher()
{
EnterCriticalSection(&s_clientCipherLock);
s_clientRecvCipher.Initialize(s_clientPendingKey);
s_clientRecvCipher.Initialize(s_clientPendingKey, ServerRuntime::Security::StreamCipher::Client);
SecureZeroMemory(s_clientPendingKey, sizeof(s_clientPendingKey));
s_clientKeyStored = false;
LeaveCriticalSection(&s_clientCipherLock);