using System;
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;
#if TUNING
private byte[] _safePrime;
private byte[] _subGroup;
#endif
///
/// Gets or sets the safe prime.
///
///
/// The safe prime.
///
#if TUNING
public BigInteger SafePrime
{
get { return _safePrime.ToBigInteger(); }
}
#else
public BigInteger SafePrime { get; private set; }
#endif
///
/// Gets or sets the generator for subgroup in GF(p).
///
///
/// The sub group.
///
#if TUNING
public BigInteger SubGroup
{
get { return _subGroup.ToBigInteger(); }
}
#else
public BigInteger SubGroup { get; private set; }
#endif
#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; // SafePrime length
capacity += _safePrime.Length; // SafePrime
capacity += 4; // SubGroup length
capacity += _subGroup.Length; // SubGroup
return capacity;
}
}
#endif
///
/// Called when type specific data need to be loaded.
///
protected override void LoadData()
{
#if TUNING
_safePrime = ReadBinary();
_subGroup = ReadBinary();
#else
SafePrime = ReadBigInt();
SubGroup = ReadBigInt();
#endif
}
///
/// Called when type specific data need to be saved.
///
protected override void SaveData()
{
#if TUNING
WriteBinaryString(_safePrime);
WriteBinaryString(_subGroup);
#else
Write(SafePrime);
Write(SubGroup);
#endif
}
}
}