Skip to content

Commit f8d1e3b

Browse files
committed
Reset MAC after TransformFinalBlock on .NET Framework in Session.cs
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).
1 parent f7d2ac1 commit f8d1e3b

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎src/Renci.SshNet/Session.cs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,11 @@ private Message ReceiveMessage(Socket socket)
13271327
{
13281328
throw new SshConnectionException("MAC error", DisconnectReason.MacError);
13291329
}
1330+
#if NETFRAMEWORK
1331+
// Ensure MAC is reset so that it can be reused for the next packet
1332+
// It is only required for certain older .NET Framework builds, e.g., mscorlib.dll version  4.8.4110.0
1333+
_serverMac.Initialize();
1334+
#endif
13301335
}
13311336

13321337
var numberOfBytesToDecrypt = 4 + packetLength - blockSize;
@@ -1374,6 +1379,11 @@ private Message ReceiveMessage(Socket socket)
13741379
{
13751380
throw new SshConnectionException("MAC error", DisconnectReason.MacError);
13761381
}
1382+
#if NETFRAMEWORK
1383+
// Ensure MAC is reset so that it can be reused for the next packet
1384+
// It is only required for certain older .NET Framework builds, e.g., mscorlib.dll version  4.8.4110.0
1385+
_serverMac.Initialize();
1386+
#endif
13771387
}
13781388

13791389
var paddingLength = _receiveBuffer.ActiveReadOnlySpan[packetLengthFieldLength];

0 commit comments

Comments
 (0)