using Renci.SshNet.Common;
namespace Renci.SshNet.Messages.Transport
{
///
/// Represents SSH_MSG_KEX_DH_GEX_GROUP message.
///
[Message("SSH_MSG_KEX_DH_GEX_GROUP", MessageNumber)]
public class KeyExchangeDhGroupExchangeGroup : Message
{
internal const byte MessageNumber = 31;
private byte[] _safePrime;
private byte[] _subGroup;
///
/// Gets or sets the safe prime.
///
///
/// The safe prime.
///
public BigInteger SafePrime
{
get { return _safePrime.ToBigInteger(); }
}
///
/// Gets or sets the generator for subgroup in GF(p).
///
///
/// The sub group.
///
public BigInteger SubGroup
{
get { return _subGroup.ToBigInteger(); }
}
///
/// 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; // SafePrime length
capacity += _safePrime.Length; // SafePrime
capacity += 4; // SubGroup length
capacity += _subGroup.Length; // SubGroup
return capacity;
}
}
///
/// Called when type specific data need to be loaded.
///
protected override void LoadData()
{
_safePrime = ReadBinary();
_subGroup = ReadBinary();
}
///
/// Called when type specific data need to be saved.
///
protected override void SaveData()
{
WriteBinaryString(_safePrime);
WriteBinaryString(_subGroup);
}
internal override void Process(Session session)
{
session.OnKeyExchangeDhGroupExchangeGroupReceived(this);
}
}
}