Temporarily introduce extra verbose tracing.

This commit is contained in:
drieseng
2016-08-23 18:25:52 +02:00
parent 5260f1b73d
commit 31b2019fe4
2 changed files with 18 additions and 3 deletions
+7 -1
View File
@@ -186,7 +186,13 @@ namespace Renci.SshNet.Security
var serverKey = Hash(GenerateSessionKey(SharedKey, ExchangeHash, 'D', sessionId));
serverKey = GenerateSessionKey(SharedKey, ExchangeHash, serverKey, _serverCipherInfo.KeySize / 8);
DiagnosticAbstraction.Log(string.Format("[{0}] Creating server cipher (Name:{1},Key:{2},IV:{3})",
Session.ToHex(Session.SessionId),
Session.ConnectionInfo.CurrentServerEncryption,
Session.ToHex(serverKey),
Session.ToHex(serverVector)));
// Create server cipher
return _serverCipherInfo.Cipher(serverKey, serverVector);
}
+11 -2
View File
@@ -892,9 +892,12 @@ namespace Renci.SshNet
// Read first block - which starts with the packet length
var firstBlock = Read(blockSize);
DiagnosticAbstraction.Log(string.Format("[{0}] FirstBlock [{1}]: {2}", ToHex(SessionId), blockSize, ToHex(firstBlock)));
if (_serverCipher != null)
{
firstBlock = _serverCipher.Decrypt(firstBlock);
DiagnosticAbstraction.Log(string.Format("[{0}] FirstBlock decrypted [{1}]: {2}", ToHex(SessionId), firstBlock.Length, ToHex(firstBlock)));
}
var packetLength = (uint)(firstBlock[0] << 24 | firstBlock[1] << 16 | firstBlock[2] << 8 | firstBlock[3]);
@@ -924,10 +927,14 @@ namespace Renci.SshNet
{
var nextBlocks = Read(bytesToRead);
DiagnosticAbstraction.Log(string.Format("[{0}] NextBlocks [{1}]: {2}", ToHex(SessionId), bytesToRead, ToHex(nextBlocks)));
if (serverHash != null)
{
Buffer.BlockCopy(nextBlocks, nextBlocks.Length - serverHash.Length, serverHash, 0, serverHash.Length);
nextBlocks = nextBlocks.Take(nextBlocks.Length - serverHash.Length);
DiagnosticAbstraction.Log(string.Format("[{0}] ServerHash [{1}]: {2}", ToHex(SessionId), serverHash.Length, ToHex(serverHash)));
}
if (nextBlocks.Length > 0)
@@ -935,6 +942,7 @@ namespace Renci.SshNet
if (_serverCipher != null)
{
nextBlocks = _serverCipher.Decrypt(nextBlocks);
DiagnosticAbstraction.Log(string.Format("[{0}] NextBlocks decrypted [{1}]: {2}", ToHex(SessionId), nextBlocks.Length, ToHex(nextBlocks)));
}
nextBlocks.CopyTo(data, blockSize + inboundPacketSequenceLength);
@@ -942,7 +950,6 @@ namespace Renci.SshNet
}
var paddingLength = data[inboundPacketSequenceLength + packetLengthFieldLength];
var messagePayloadLength = (int) (packetLength - paddingLength - paddingLengthFieldLength);
var messagePayloadOffset = inboundPacketSequenceLength + packetLengthFieldLength + paddingLengthFieldLength;
@@ -965,6 +972,8 @@ namespace Renci.SshNet
messagePayloadOffset = 0;
}
DiagnosticAbstraction.Log(string.Format("[{0}] Message info (Sequence:{1},MessagePayloadLength:{2})", ToHex(SessionId), _inboundPacketSequence, messagePayloadLength));
_inboundPacketSequence++;
return LoadMessage(data, messagePayloadOffset);
@@ -1681,7 +1690,7 @@ namespace Renci.SshNet
return builder.ToString();
}
private static string ToHex(byte[] bytes)
internal static string ToHex(byte[] bytes)
{
if (bytes == null)
return null;