| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace Renci.SshNet.Messages.Authentication |
| | | 4 | | { |
| | | 5 | | /// <summary> |
| | | 6 | | /// Represents "keyboard-interactive" SSH_MSG_USERAUTH_REQUEST message. |
| | | 7 | | /// </summary> |
| | | 8 | | internal sealed class RequestMessageKeyboardInteractive : RequestMessage |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Gets message language. |
| | | 12 | | /// </summary> |
| | 535 | 13 | | public byte[] Language { get; private set; } |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Gets authentication sub methods. |
| | | 17 | | /// </summary> |
| | 535 | 18 | | public byte[] SubMethods { get; private set; } |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Gets the size of the message in bytes. |
| | | 22 | | /// </summary> |
| | | 23 | | /// <value> |
| | | 24 | | /// The size of the messages in bytes. |
| | | 25 | | /// </value> |
| | | 26 | | protected override int BufferCapacity |
| | | 27 | | { |
| | | 28 | | get |
| | 3 | 29 | | { |
| | 3 | 30 | | var capacity = base.BufferCapacity; |
| | 3 | 31 | | capacity += 4; // Language length |
| | 3 | 32 | | capacity += Language.Length; // Language |
| | 3 | 33 | | capacity += 4; // SubMethods length |
| | 3 | 34 | | capacity += SubMethods.Length; // SubMethods |
| | 3 | 35 | | return capacity; |
| | 3 | 36 | | } |
| | | 37 | | } |
| | | 38 | | |
| | | 39 | | /// <summary> |
| | | 40 | | /// Initializes a new instance of the <see cref="RequestMessageKeyboardInteractive"/> class. |
| | | 41 | | /// </summary> |
| | | 42 | | /// <param name="serviceName">Name of the service.</param> |
| | | 43 | | /// <param name="username">Authentication username.</param> |
| | | 44 | | public RequestMessageKeyboardInteractive(ServiceName serviceName, string username) |
| | 529 | 45 | | : base(serviceName, username, "keyboard-interactive") |
| | 529 | 46 | | { |
| | 529 | 47 | | Language = Array.Empty<byte>(); |
| | 529 | 48 | | SubMethods = Array.Empty<byte>(); |
| | 529 | 49 | | } |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Called when type specific data need to be saved. |
| | | 53 | | /// </summary> |
| | | 54 | | protected override void SaveData() |
| | 3 | 55 | | { |
| | 3 | 56 | | base.SaveData(); |
| | | 57 | | |
| | 3 | 58 | | WriteBinaryString(Language); |
| | 3 | 59 | | WriteBinaryString(SubMethods); |
| | 3 | 60 | | } |
| | | 61 | | } |
| | | 62 | | } |