Fix incorrect IV for encrypted control stream packets on big-endian machines
This commit is contained in:
parent
d14f62c26a
commit
b2c39883bf
1 changed files with 4 additions and 3 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue