using System;
using Renci.SshNet.Common;
namespace Renci.SshNet.Messages.Transport
{
///
/// Represents SSH_MSG_KEX_DH_GEX_REPLY message.
///
[Message("SSH_MSG_KEX_DH_GEX_REPLY", MessageNumber)]
internal class KeyExchangeDhGroupExchangeReply : Message
{
internal const byte MessageNumber = 33;
#if TUNING
private byte[] _fBytes;
#endif
///
/// Gets server public host key and certificates
///
/// The host key.
public byte[] HostKey { get; private set; }
///
/// Gets the F value.
///
#if TUNING
public BigInteger F
{
get { return _fBytes.ToBigInteger(); }
}
#else
public BigInteger F { get; private set; }
#endif
///
/// Gets the signature of H.
///
/// The signature.
public byte[] Signature { get; private set; }
#if TUNING
///
/// Gets the size of the message in bytes.
///
///
/// The size of the messages in bytes.
///
protected override int BufferCapacity
{
get
{
var capacity = base.BufferCapacity;
capacity += 4; // HostKey length
capacity += HostKey.Length; // HostKey
capacity += 4; // F length
capacity += _fBytes.Length; // F
capacity += 4; // Signature length
capacity += Signature.Length; // Signature
return capacity;
}
}
#endif
///
/// Called when type specific data need to be loaded.
///
protected override void LoadData()
{
#if TUNING
HostKey = ReadBinary();
_fBytes = ReadBinary();
Signature = ReadBinary();
#else
HostKey = ReadBinaryString();
F = ReadBigInt();
Signature = ReadBinaryString();
#endif
}
///
/// Called when type specific data need to be saved.
///
protected override void SaveData()
{
WriteBinaryString(HostKey);
#if TUNING
WriteBinaryString(_fBytes);
#else
Write(F);
#endif
WriteBinaryString(Signature);
}
}
}