KeyExchangeDhGroupExchangeRequest.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System;
  2. namespace Renci.SshNet.Messages.Transport
  3. {
  4. /// <summary>
  5. /// Represents SSH_MSG_KEX_DH_GEX_REQUEST message.
  6. /// </summary>
  7. [Message("SSH_MSG_KEX_DH_GEX_REQUEST", MessageNumber)]
  8. internal class KeyExchangeDhGroupExchangeRequest : Message, IKeyExchangedAllowed
  9. {
  10. internal const byte MessageNumber = 34;
  11. /// <summary>
  12. /// Gets or sets the minimal size in bits of an acceptable group.
  13. /// </summary>
  14. /// <value>
  15. /// The minimum.
  16. /// </value>
  17. public UInt32 Minimum { get; private set; }
  18. /// <summary>
  19. /// Gets or sets the preferred size in bits of the group the server will send.
  20. /// </summary>
  21. /// <value>
  22. /// The preferred.
  23. /// </value>
  24. public UInt32 Preferred { get; private set; }
  25. /// <summary>
  26. /// Gets or sets the maximal size in bits of an acceptable group.
  27. /// </summary>
  28. /// <value>
  29. /// The maximum.
  30. /// </value>
  31. public UInt32 Maximum { get; private set; }
  32. #if TUNING
  33. /// <summary>
  34. /// Gets the size of the message in bytes.
  35. /// </summary>
  36. /// <value>
  37. /// The size of the messages in bytes.
  38. /// </value>
  39. protected override int BufferCapacity
  40. {
  41. get
  42. {
  43. var capacity = base.BufferCapacity;
  44. capacity += 4; // Minimum
  45. capacity += 4; // Preferred
  46. capacity += 4; // Maximum
  47. return capacity;
  48. }
  49. }
  50. #endif
  51. /// <summary>
  52. /// Initializes a new instance of the <see cref="KeyExchangeDhGroupExchangeRequest"/> class.
  53. /// </summary>
  54. /// <param name="minimum">The minimum.</param>
  55. /// <param name="preferred">The preferred.</param>
  56. /// <param name="maximum">The maximum.</param>
  57. public KeyExchangeDhGroupExchangeRequest(uint minimum, uint preferred, uint maximum)
  58. {
  59. Minimum = minimum;
  60. Preferred = preferred;
  61. Maximum = maximum;
  62. }
  63. /// <summary>
  64. /// Called when type specific data need to be loaded.
  65. /// </summary>
  66. protected override void LoadData()
  67. {
  68. Minimum = ReadUInt32();
  69. Preferred = ReadUInt32();
  70. Maximum = ReadUInt32();
  71. }
  72. /// <summary>
  73. /// Called when type specific data need to be saved.
  74. /// </summary>
  75. protected override void SaveData()
  76. {
  77. Write(Minimum);
  78. Write(Preferred);
  79. Write(Maximum);
  80. }
  81. }
  82. }