Reset MAC after TransformFinalBlock on .NET Framework in Session.cs (#1830)

Add `#if NETFRAMEWORK` block to call `_serverMac.Initialize()` after `TransformFinalBlock` in `ReceiveMessage`. Ensures MAC is reset for reuse, addressing issues on older .NET Framework builds (e.g., mscorlib.dll 4.8.4110.0).

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
This commit is contained in:
Scott Xu
2026-09-01 20:38:30 +08:00
committed by GitHub
parent ace38009ee
commit f099365c9d
+10
View File
@@ -1327,6 +1327,11 @@ namespace Renci.SshNet
{
throw new SshConnectionException("MAC error", DisconnectReason.MacError);
}
#if NETFRAMEWORK
// Ensure MAC is reset so that it can be reused for the next packet
// It is only required for certain older .NET Framework builds, e.g., mscorlib.dll version 4.8.4110.0
_serverMac.Initialize();
#endif
}
var numberOfBytesToDecrypt = 4 + packetLength - blockSize;
@@ -1374,6 +1379,11 @@ namespace Renci.SshNet
{
throw new SshConnectionException("MAC error", DisconnectReason.MacError);
}
#if NETFRAMEWORK
// Ensure MAC is reset so that it can be reused for the next packet
// It is only required for certain older .NET Framework builds, e.g., mscorlib.dll version 4.8.4110.0
_serverMac.Initialize();
#endif
}
var paddingLength = _receiveBuffer.ActiveReadOnlySpan[packetLengthFieldLength];