mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2025-08-17 08:55:48 +00:00
Fix incorrect IV for encrypted control stream packets on big-endian machines
This commit is contained in:
parent
d14f62c26a
commit
b2c39883bf
@ -410,6 +410,10 @@ static bool encryptControlMessage(PNVCTL_ENCRYPTED_PACKET_HEADER encPacket, PNVC
|
||||
unsigned char iv[16] = { 0 };
|
||||
int encryptedSize = sizeof(*packet) + packet->payloadLength;
|
||||
|
||||
// This is a truncating cast, but it's what Nvidia does, so we have to mimic it.
|
||||
// NB: Setting the IV must happen while encPacket->seq is still in native byte-order!
|
||||
iv[0] = (unsigned char)encPacket->seq;
|
||||
|
||||
encPacket->encryptedHeaderType = LE16(encPacket->encryptedHeaderType);
|
||||
encPacket->length = LE16(encPacket->length);
|
||||
encPacket->seq = LE32(encPacket->seq);
|
||||
@ -417,9 +421,6 @@ static bool encryptControlMessage(PNVCTL_ENCRYPTED_PACKET_HEADER encPacket, PNVC
|
||||
packet->type = LE16(packet->type);
|
||||
packet->payloadLength = LE16(packet->payloadLength);
|
||||
|
||||
// This is a truncating cast, but it's what Nvidia does, so we have to mimic it.
|
||||
iv[0] = (unsigned char)encPacket->seq;
|
||||
|
||||
return PltEncryptMessage(encryptionCtx, ALGORITHM_AES_GCM, 0,
|
||||
(unsigned char*)StreamConfig.remoteInputAesKey, sizeof(StreamConfig.remoteInputAesKey),
|
||||
iv, sizeof(iv),
|
||||
|
Loading…
x
Reference in New Issue
Block a user