();
35 | }
36 |
37 | ///
38 | /// Called when type specific data need to be loaded.
39 | ///
40 | protected override void LoadData()
41 | {
42 | throw new NotImplementedException();
43 | }
44 |
45 | ///
46 | /// Called when type specific data need to be saved.
47 | ///
48 | protected override void SaveData()
49 | {
50 | Write((uint) Responses.Count);
51 | foreach (var response in Responses)
52 | {
53 | Write(response);
54 | }
55 | }
56 |
57 | internal override void Process(Session session)
58 | {
59 | throw new NotImplementedException();
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Authentication/RequestMessageNone.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Authentication
2 | {
3 | ///
4 | /// Represents "none" SSH_MSG_USERAUTH_REQUEST message.
5 | ///
6 | internal class RequestMessageNone : RequestMessage
7 | {
8 | ///
9 | /// Initializes a new instance of the class.
10 | ///
11 | /// Name of the service.
12 | /// Authentication username.
13 | public RequestMessageNone(ServiceName serviceName, string username)
14 | : base(serviceName, username, "none")
15 | {
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Authentication/SuccessMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Authentication
2 | {
3 | ///
4 | /// Represents SSH_MSG_USERAUTH_SUCCESS message.
5 | ///
6 | [Message("SSH_MSG_USERAUTH_SUCCESS", 52)]
7 | public class SuccessMessage : Message
8 | {
9 | ///
10 | /// Called when type specific data need to be loaded.
11 | ///
12 | protected override void LoadData()
13 | {
14 | }
15 |
16 | ///
17 | /// Called when type specific data need to be saved.
18 | ///
19 | protected override void SaveData()
20 | {
21 | }
22 |
23 | internal override void Process(Session session)
24 | {
25 | session.OnUserAuthenticationSuccessReceived(this);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/ChannelCloseMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Connection
2 | {
3 | ///
4 | /// Represents SSH_MSG_CHANNEL_CLOSE message.
5 | ///
6 | [Message("SSH_MSG_CHANNEL_CLOSE", 97)]
7 | public class ChannelCloseMessage : ChannelMessage
8 | {
9 | ///
10 | /// Initializes a new instance of the class.
11 | ///
12 | public ChannelCloseMessage()
13 | {
14 |
15 | }
16 |
17 | ///
18 | /// Initializes a new instance of the class.
19 | ///
20 | /// The local channel number.
21 | public ChannelCloseMessage(uint localChannelNumber)
22 | : base(localChannelNumber)
23 | {
24 | }
25 |
26 | internal override void Process(Session session)
27 | {
28 | session.OnChannelCloseReceived(this);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/ChannelEofMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Connection
2 | {
3 | ///
4 | /// Represents SSH_MSG_CHANNEL_EOF message.
5 | ///
6 | [Message("SSH_MSG_CHANNEL_EOF", 96)]
7 | public class ChannelEofMessage : ChannelMessage
8 | {
9 | ///
10 | /// Initializes a new instance of the class.
11 | ///
12 | public ChannelEofMessage()
13 | {
14 |
15 | }
16 |
17 | ///
18 | /// Initializes a new instance of the class.
19 | ///
20 | /// The local channel number.
21 | public ChannelEofMessage(uint localChannelNumber)
22 | : base(localChannelNumber)
23 | {
24 | }
25 |
26 | internal override void Process(Session session)
27 | {
28 | session.OnChannelEofReceived(this);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/ChannelFailureMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Connection
2 | {
3 | ///
4 | /// Represents SSH_MSG_CHANNEL_FAILURE message.
5 | ///
6 | [Message("SSH_MSG_CHANNEL_FAILURE", 100)]
7 | public class ChannelFailureMessage : ChannelMessage
8 | {
9 | ///
10 | /// Initializes a new instance of the class.
11 | ///
12 | public ChannelFailureMessage()
13 | {
14 |
15 | }
16 |
17 | ///
18 | /// Initializes a new instance of the class.
19 | ///
20 | /// The local channel number.
21 | public ChannelFailureMessage(uint localChannelNumber)
22 | : base(localChannelNumber)
23 | {
24 | }
25 |
26 | internal override void Process(Session session)
27 | {
28 | session.OnChannelFailureReceived(this);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/ChannelOpen/ChannelOpenInfo.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Common;
2 |
3 | namespace Renci.SshNet.Messages.Connection
4 | {
5 | ///
6 | /// Base class for open channel messages
7 | ///
8 | public abstract class ChannelOpenInfo : SshData
9 | {
10 | ///
11 | /// Gets the type of the channel to open.
12 | ///
13 | ///
14 | /// The type of the channel to open.
15 | ///
16 | public abstract string ChannelType { get; }
17 |
18 | ///
19 | /// Called when type specific data need to be loaded.
20 | ///
21 | protected override void LoadData()
22 | {
23 | }
24 |
25 | ///
26 | /// Called when type specific data need to be saved.
27 | ///
28 | protected override void SaveData()
29 | {
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/ChannelOpen/SessionChannelOpenInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Messages.Connection
4 | {
5 | ///
6 | /// Used to open "session" channel type
7 | ///
8 | internal class SessionChannelOpenInfo : ChannelOpenInfo
9 | {
10 | ///
11 | /// Specifies channel open type
12 | ///
13 | public const string Name = "session";
14 |
15 | ///
16 | /// Gets the type of the channel to open.
17 | ///
18 | ///
19 | /// The type of the channel to open.
20 | ///
21 | public override string ChannelType
22 | {
23 | get { return Name; }
24 | }
25 |
26 | ///
27 | /// Initializes a new instance of the class.
28 | ///
29 | public SessionChannelOpenInfo()
30 | {
31 | }
32 |
33 | ///
34 | /// Initializes a new instance of the class from the
35 | /// specified data.
36 | ///
37 | /// is null.
38 | public SessionChannelOpenInfo(byte[] data)
39 | {
40 | Load(data);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/ChannelOpenFailureReasons.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Connection
2 | {
3 | ///
4 | /// List channel open failure reasons defined by the protocol.
5 | ///
6 | internal enum ChannelOpenFailureReasons : uint
7 | {
8 | ///
9 | /// SSH_OPEN_ADMINISTRATIVELY_PROHIBITED
10 | ///
11 | AdministativelyProhibited = 1,
12 | ///
13 | /// SSH_OPEN_CONNECT_FAILED
14 | ///
15 | ConnectFailed = 2,
16 | ///
17 | /// SSH_OPEN_UNKNOWN_CHANNEL_TYPE
18 | ///
19 | UnknownChannelType = 3,
20 | ///
21 | /// SSH_OPEN_RESOURCE_SHORTAGE
22 | ///
23 | ResourceShortage = 4
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/ChannelRequest/EndOfWriteRequestInfo.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Connection
2 | {
3 | ///
4 | /// Represents "eow@openssh.com" type channel request information
5 | ///
6 | public class EndOfWriteRequestInfo : RequestInfo
7 | {
8 | ///
9 | /// Channel request name
10 | ///
11 | public const string Name = "eow@openssh.com";
12 |
13 | ///
14 | /// Gets the name of the request.
15 | ///
16 | ///
17 | /// The name of the request.
18 | ///
19 | public override string RequestName
20 | {
21 | get { return Name; }
22 | }
23 |
24 | ///
25 | /// Initializes a new instance of the class.
26 | ///
27 | public EndOfWriteRequestInfo()
28 | {
29 | WantReply = false;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/ChannelRequest/KeepAliveRequestInfo.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Connection
2 | {
3 | ///
4 | /// Represents "keepalive@openssh.com" type channel request information
5 | ///
6 | public class KeepAliveRequestInfo : RequestInfo
7 | {
8 | ///
9 | /// Channel request name
10 | ///
11 | public const string Name = "keepalive@openssh.com";
12 |
13 | ///
14 | /// Gets the name of the request.
15 | ///
16 | ///
17 | /// The name of the request.
18 | ///
19 | public override string RequestName
20 | {
21 | get { return Name; }
22 | }
23 |
24 | ///
25 | /// Initializes a new instance of the class.
26 | ///
27 | public KeepAliveRequestInfo()
28 | {
29 | WantReply = false;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/ChannelRequest/RequestInfo.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Common;
2 |
3 | namespace Renci.SshNet.Messages.Connection
4 | {
5 | ///
6 | /// Represents type specific information for channel request.
7 | ///
8 | public abstract class RequestInfo : SshData
9 | {
10 | ///
11 | /// Gets the name of the request.
12 | ///
13 | ///
14 | /// The name of the request.
15 | ///
16 | public abstract string RequestName { get; }
17 |
18 | ///
19 | /// Gets or sets a value indicating whether reply message is needed.
20 | ///
21 | ///
22 | /// true if reply message is needed; otherwise, false.
23 | ///
24 | public bool WantReply { get; protected set; }
25 |
26 | ///
27 | /// Gets the size of the message in bytes.
28 | ///
29 | ///
30 | /// The size of the messages in bytes.
31 | ///
32 | protected override int BufferCapacity
33 | {
34 | get
35 | {
36 | var capacity = base.BufferCapacity;
37 | capacity += 1; // WantReply
38 | return capacity;
39 | }
40 | }
41 |
42 | ///
43 | /// Called when type specific data need to be loaded.
44 | ///
45 | protected override void LoadData()
46 | {
47 | WantReply = ReadBoolean();
48 | }
49 |
50 | ///
51 | /// Called when type specific data need to be saved.
52 | ///
53 | protected override void SaveData()
54 | {
55 | Write(WantReply);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/ChannelRequest/ShellRequestInfo.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Connection
2 | {
3 | ///
4 | /// Represents "shell" type channel request information
5 | ///
6 | internal class ShellRequestInfo : RequestInfo
7 | {
8 | ///
9 | /// Channel request name
10 | ///
11 | public const string Name = "shell";
12 |
13 | ///
14 | /// Gets the name of the request.
15 | ///
16 | ///
17 | /// The name of the request.
18 | ///
19 | public override string RequestName
20 | {
21 | get { return Name; }
22 | }
23 |
24 | ///
25 | /// Initializes a new instance of the class.
26 | ///
27 | public ShellRequestInfo()
28 | {
29 | WantReply = true;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/ChannelSuccessMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Connection
2 | {
3 | ///
4 | /// Represents SSH_MSG_CHANNEL_SUCCESS message.
5 | ///
6 | [Message("SSH_MSG_CHANNEL_SUCCESS", 99)]
7 | public class ChannelSuccessMessage : ChannelMessage
8 | {
9 | ///
10 | /// Initializes a new instance of the class.
11 | ///
12 | public ChannelSuccessMessage()
13 | {
14 |
15 | }
16 |
17 | ///
18 | /// Initializes a new instance of the class.
19 | ///
20 | /// The local channel number.
21 | public ChannelSuccessMessage(uint localChannelNumber)
22 | : base(localChannelNumber)
23 | {
24 | }
25 |
26 | internal override void Process(Session session)
27 | {
28 | session.OnChannelSuccessReceived(this);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/GlobalRequestName.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Connection
2 | {
3 | ///
4 | /// Specifies supported request names.
5 | ///
6 | public enum GlobalRequestName
7 | {
8 | ///
9 | /// tcpip-forward
10 | ///
11 | TcpIpForward,
12 | ///
13 | /// cancel-tcpip-forward
14 | ///
15 | CancelTcpIpForward,
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Connection/RequestFailureMessage.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace Renci.SshNet.Messages.Connection
3 | {
4 | ///
5 | /// Represents SSH_MSG_REQUEST_FAILURE message.
6 | ///
7 | [Message("SSH_MSG_REQUEST_FAILURE", 82)]
8 | public class RequestFailureMessage : Message
9 | {
10 | ///
11 | /// Called when type specific data need to be loaded.
12 | ///
13 | protected override void LoadData()
14 | {
15 | }
16 |
17 | ///
18 | /// Called when type specific data need to be saved.
19 | ///
20 | protected override void SaveData()
21 | {
22 | }
23 |
24 | internal override void Process(Session session)
25 | {
26 | session.OnRequestFailureReceived(this);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/MessageAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Messages
4 | {
5 |
6 | ///
7 | /// Indicates that a class represents SSH message. This class cannot be inherited.
8 | ///
9 | [AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)]
10 | public sealed class MessageAttribute : Attribute
11 | {
12 | ///
13 | /// Gets or sets message name as defined in RFC 4250.
14 | ///
15 | ///
16 | /// The name.
17 | ///
18 | public string Name { get; set; }
19 |
20 | ///
21 | /// Gets or sets message number as defined in RFC 4250.
22 | ///
23 | ///
24 | /// The number.
25 | ///
26 | public byte Number { get; set; }
27 |
28 | ///
29 | /// Initializes a new instance of the class.
30 | ///
31 | /// The name.
32 | /// The number.
33 | public MessageAttribute(string name, byte number)
34 | {
35 | Name = name;
36 | Number = number;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/ServiceName.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages
2 | {
3 | ///
4 | /// Specifies list of supported services
5 | ///
6 | public enum ServiceName
7 | {
8 | ///
9 | /// ssh-userauth
10 | ///
11 | UserAuthentication,
12 |
13 | ///
14 | /// ssh-connection
15 | ///
16 | Connection
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Transport/IKeyExchangedAllowed.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Transport
2 | {
3 | ///
4 | /// Indicates that message that implement this interface is allowed during key exchange phase
5 | ///
6 | public interface IKeyExchangedAllowed
7 | {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Transport/KeyExchangeDhGroupExchangeInit.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Transport
2 | {
3 | ///
4 | /// Represents SSH_MSG_KEX_DH_GEX_INIT message.
5 | ///
6 | [Message("SSH_MSG_KEX_DH_GEX_INIT", 32)]
7 | internal class KeyExchangeDhGroupExchangeInit : Message, IKeyExchangedAllowed
8 | {
9 | ///
10 | /// Gets the E value.
11 | ///
12 | public byte[] E { get; private set; }
13 |
14 | ///
15 | /// Gets the size of the message in bytes.
16 | ///
17 | ///
18 | /// The size of the messages in bytes.
19 | ///
20 | protected override int BufferCapacity
21 | {
22 | get
23 | {
24 | var capacity = base.BufferCapacity;
25 | capacity += 4; // E length
26 | capacity += E.Length; // E
27 | return capacity;
28 | }
29 | }
30 |
31 | ///
32 | /// Initializes a new instance of the class.
33 | ///
34 | /// The client exchange value.
35 | public KeyExchangeDhGroupExchangeInit(byte[] clientExchangeValue)
36 | {
37 | E = clientExchangeValue;
38 | }
39 |
40 | ///
41 | /// Called when type specific data need to be loaded.
42 | ///
43 | protected override void LoadData()
44 | {
45 | E = ReadBinary();
46 | }
47 |
48 | ///
49 | /// Called when type specific data need to be saved.
50 | ///
51 | protected override void SaveData()
52 | {
53 | WriteBinaryString(E);
54 | }
55 |
56 | internal override void Process(Session session)
57 | {
58 | throw new System.NotImplementedException();
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Transport/KeyExchangeDhInitMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Transport
2 | {
3 | ///
4 | /// Represents SSH_MSG_KEXDH_INIT message.
5 | ///
6 | [Message("SSH_MSG_KEXDH_INIT", 30)]
7 | internal class KeyExchangeDhInitMessage : Message, IKeyExchangedAllowed
8 | {
9 | ///
10 | /// Gets the E value.
11 | ///
12 | public byte[] E { get; private set; }
13 |
14 | ///
15 | /// Gets the size of the message in bytes.
16 | ///
17 | ///
18 | /// The size of the messages in bytes.
19 | ///
20 | protected override int BufferCapacity
21 | {
22 | get
23 | {
24 | var capacity = base.BufferCapacity;
25 | capacity += 4; // E length
26 | capacity += E.Length; // E
27 | return capacity;
28 | }
29 | }
30 |
31 | ///
32 | /// Initializes a new instance of the class.
33 | ///
34 | /// The client exchange value.
35 | public KeyExchangeDhInitMessage(byte[] clientExchangeValue)
36 | {
37 | E = clientExchangeValue;
38 | }
39 |
40 | ///
41 | /// Called when type specific data need to be loaded.
42 | ///
43 | protected override void LoadData()
44 | {
45 | E = ReadBinary();
46 | }
47 |
48 | ///
49 | /// Called when type specific data need to be saved.
50 | ///
51 | protected override void SaveData()
52 | {
53 | WriteBinaryString(E);
54 | }
55 |
56 | internal override void Process(Session session)
57 | {
58 | throw new System.NotImplementedException();
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Transport/NewKeysMessage.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Messages.Transport
2 | {
3 | ///
4 | /// Represents SSH_MSG_NEWKEYS message.
5 | ///
6 | [Message("SSH_MSG_NEWKEYS", 21)]
7 | public class NewKeysMessage : Message, IKeyExchangedAllowed
8 | {
9 | ///
10 | /// Called when type specific data need to be loaded.
11 | ///
12 | protected override void LoadData()
13 | {
14 | }
15 |
16 | ///
17 | /// Called when type specific data need to be saved.
18 | ///
19 | protected override void SaveData()
20 | {
21 | }
22 |
23 | internal override void Process(Session session)
24 | {
25 | session.OnNewKeysReceived(this);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Transport/ServiceAcceptMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Renci.SshNet.Common;
3 |
4 | namespace Renci.SshNet.Messages.Transport
5 | {
6 | ///
7 | /// Represents SSH_MSG_SERVICE_ACCEPT message.
8 | ///
9 | [Message("SSH_MSG_SERVICE_ACCEPT", MessageNumber)]
10 | public class ServiceAcceptMessage : Message
11 | {
12 | internal const byte MessageNumber = 6;
13 |
14 | ///
15 | /// Gets the name of the service.
16 | ///
17 | ///
18 | /// The name of the service.
19 | ///
20 | public ServiceName ServiceName { get; private set; }
21 |
22 | ///
23 | /// Called when type specific data need to be loaded.
24 | ///
25 | protected override void LoadData()
26 | {
27 | ServiceName = ReadBinary().ToServiceName();
28 | }
29 |
30 | ///
31 | /// Called when type specific data need to be saved.
32 | ///
33 | protected override void SaveData()
34 | {
35 | throw new NotImplementedException();
36 | }
37 |
38 | internal override void Process(Session session)
39 | {
40 | session.OnServiceAcceptReceived(this);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Messages/Transport/UnimplementedMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Messages.Transport
4 | {
5 | ///
6 | /// Represents SSH_MSG_UNIMPLEMENTED message.
7 | ///
8 | [Message("SSH_MSG_UNIMPLEMENTED", 3)]
9 | public class UnimplementedMessage : Message
10 | {
11 | ///
12 | /// Called when type specific data need to be loaded.
13 | ///
14 | protected override void LoadData()
15 | {
16 | }
17 |
18 | ///
19 | /// Called when type specific data need to be saved.
20 | ///
21 | protected override void SaveData()
22 | {
23 | throw new NotImplementedException();
24 | }
25 |
26 | internal override void Process(Session session)
27 | {
28 | session.OnUnimplementedReceived(this);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Netconf/INetConfSession.cs:
--------------------------------------------------------------------------------
1 | using System.Xml;
2 |
3 | namespace Renci.SshNet.NetConf
4 | {
5 | internal interface INetConfSession : ISubsystemSession
6 | {
7 | ///
8 | /// Gets the NetConf server capabilities.
9 | ///
10 | ///
11 | /// The NetConf server capabilities.
12 | ///
13 | XmlDocument ServerCapabilities { get; }
14 |
15 | ///
16 | /// Gets the NetConf client capabilities.
17 | ///
18 | ///
19 | /// The NetConf client capabilities.
20 | ///
21 | XmlDocument ClientCapabilities { get; }
22 |
23 | XmlDocument SendReceiveRpc(XmlDocument rpc, bool automaticMessageIdHandling);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 | using System.Runtime.CompilerServices;
4 |
5 | [assembly: AssemblyTitle("SSH.NET")]
6 | [assembly: Guid("ad816c5e-6f13-4589-9f3e-59523f8b77a4")]
7 | [assembly: InternalsVisibleTo("Renci.SshNet.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f9194e1eb66b7e2575aaee115ee1d27bc100920e7150e43992d6f668f9737de8b9c7ae892b62b8a36dd1d57929ff1541665d101dc476d6e02390846efae7e5186eec409710fdb596e3f83740afef0d4443055937649bc5a773175b61c57615dac0f0fd10f52b52fedf76c17474cc567b3f7a79de95dde842509fb39aaf69c6c2")]
8 | [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")]
9 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Properties/CommonAssemblyInfo.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/checkymander/sshiva/4bdd8bf4e46f1d6eae2b3696269c87f64df04b0b/sshiva/Renci.SshNet/Properties/CommonAssemblyInfo.cs
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/ProxyTypes.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet
2 | {
3 | ///
4 | /// Specifies the type of proxy client will use to connect to server.
5 | ///
6 | public enum ProxyTypes
7 | {
8 | /// No proxy server.
9 | None,
10 | /// A SOCKS4 proxy server.
11 | Socks4,
12 | /// A SOCKS5 proxy server.
13 | Socks5,
14 | /// A HTTP proxy server.
15 | Http,
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/RemotePathNoneTransformation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet
4 | {
5 | ///
6 | /// Performs no transformation.
7 | ///
8 | internal class RemotePathNoneTransformation : IRemotePathTransformation
9 | {
10 | ///
11 | /// Returns the specified path without applying a transformation.
12 | ///
13 | /// The path to transform.
14 | ///
15 | /// The specified path as is.
16 | ///
17 | /// is null.
18 | ///
19 | /// This transformation is recommended for servers that do not require any quoting to preserve the
20 | /// literal value of metacharacters, or when paths are guaranteed to never contain any such characters.
21 | ///
22 | public string Transform(string path)
23 | {
24 | if (path == null)
25 | {
26 | throw new ArgumentNullException("path");
27 | }
28 |
29 | return path;
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Algorithm.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security
2 | {
3 | ///
4 | /// Represents the abstract base class from which all implementations of algorithms must inherit.
5 | ///
6 | public abstract class Algorithm
7 | {
8 | ///
9 | /// Gets algorithm name.
10 | ///
11 | public abstract string Name { get; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/asn1/x9/X9Curve.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Renci.SshNet.Security.Org.BouncyCastle.Math.EC;
4 | using Renci.SshNet.Security.Org.BouncyCastle.Utilities;
5 |
6 | namespace Renci.SshNet.Security.Org.BouncyCastle.Asn1.X9
7 | {
8 | internal class X9Curve
9 | {
10 | private readonly ECCurve curve;
11 | private readonly byte[] seed;
12 |
13 | public X9Curve(
14 | ECCurve curve)
15 | : this(curve, null)
16 | {
17 | }
18 |
19 | public X9Curve(
20 | ECCurve curve,
21 | byte[] seed)
22 | {
23 | if (curve == null)
24 | throw new ArgumentNullException("curve");
25 |
26 | this.curve = curve;
27 | this.seed = Arrays.Clone(seed);
28 | }
29 |
30 | public ECCurve Curve
31 | {
32 | get { return curve; }
33 | }
34 |
35 | public byte[] GetSeed()
36 | {
37 | return Arrays.Clone(seed);
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/asn1/x9/X9ECParametersHolder.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Org.BouncyCastle.Asn1.X9
2 | {
3 | internal abstract class X9ECParametersHolder
4 | {
5 | private X9ECParameters parameters;
6 |
7 | public X9ECParameters Parameters
8 | {
9 | get
10 | {
11 | lock (this)
12 | {
13 | if (parameters == null)
14 | {
15 | parameters = CreateParameters();
16 | }
17 |
18 | return parameters;
19 | }
20 | }
21 | }
22 |
23 | protected abstract X9ECParameters CreateParameters();
24 | }
25 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/asn1/x9/X9ECPoint.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Security.Org.BouncyCastle.Math.EC;
2 | using Renci.SshNet.Security.Org.BouncyCastle.Utilities;
3 |
4 | namespace Renci.SshNet.Security.Org.BouncyCastle.Asn1.X9
5 | {
6 | internal class X9ECPoint
7 | {
8 | private readonly byte[] encoding;
9 |
10 | private ECCurve c;
11 | private ECPoint p;
12 |
13 | public X9ECPoint(ECPoint p)
14 | : this(p, false)
15 | {
16 | }
17 |
18 | public X9ECPoint(ECPoint p, bool compressed)
19 | {
20 | this.p = p.Normalize();
21 | this.encoding = p.GetEncoded(compressed);
22 | }
23 |
24 | public X9ECPoint(ECCurve c, byte[] encoding)
25 | {
26 | this.c = c;
27 | this.encoding = Arrays.Clone(encoding);
28 | }
29 |
30 | public byte[] GetPointEncoding()
31 | {
32 | return Arrays.Clone(encoding);
33 | }
34 |
35 | public ECPoint Point
36 | {
37 | get
38 | {
39 | if (p == null)
40 | {
41 | p = c.DecodePoint(encoding).Normalize();
42 | }
43 |
44 | return p;
45 | }
46 | }
47 |
48 | public bool IsPointCompressed
49 | {
50 | get
51 | {
52 | byte[] octets = encoding;
53 | return octets != null && octets.Length > 0 && (octets[0] == 2 || octets[0] == 3);
54 | }
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/crypto/AsymmetricCipherKeyPair.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto
4 | {
5 | internal class AsymmetricCipherKeyPair
6 | {
7 | private readonly AsymmetricKeyParameter publicParameter;
8 | private readonly AsymmetricKeyParameter privateParameter;
9 |
10 | public AsymmetricCipherKeyPair(
11 | AsymmetricKeyParameter publicParameter,
12 | AsymmetricKeyParameter privateParameter)
13 | {
14 | if (publicParameter.IsPrivate)
15 | throw new ArgumentException("Expected a public key", "publicParameter");
16 | if (!privateParameter.IsPrivate)
17 | throw new ArgumentException("Expected a private key", "privateParameter");
18 |
19 | this.publicParameter = publicParameter;
20 | this.privateParameter = privateParameter;
21 | }
22 |
23 | public AsymmetricKeyParameter Public
24 | {
25 | get { return publicParameter; }
26 | }
27 |
28 | public AsymmetricKeyParameter Private
29 | {
30 | get { return privateParameter; }
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/crypto/AsymmetricKeyParameter.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto
2 | {
3 | internal abstract class AsymmetricKeyParameter
4 | {
5 | private readonly bool privateKey;
6 |
7 | protected AsymmetricKeyParameter(
8 | bool privateKey)
9 | {
10 | this.privateKey = privateKey;
11 | }
12 |
13 | public bool IsPrivate
14 | {
15 | get { return privateKey; }
16 | }
17 |
18 | public override bool Equals(
19 | object obj)
20 | {
21 | AsymmetricKeyParameter other = obj as AsymmetricKeyParameter;
22 |
23 | if (other == null)
24 | {
25 | return false;
26 | }
27 |
28 | return Equals(other);
29 | }
30 |
31 | protected bool Equals(
32 | AsymmetricKeyParameter other)
33 | {
34 | return privateKey == other.privateKey;
35 | }
36 |
37 | public override int GetHashCode()
38 | {
39 | return privateKey.GetHashCode();
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/crypto/IAsymmetricCipherKeyPairGenerator.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto
2 | {
3 | internal interface IAsymmetricCipherKeyPairGenerator
4 | {
5 | void Init(KeyGenerationParameters parameters);
6 |
7 | AsymmetricCipherKeyPair GenerateKeyPair();
8 | }
9 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/crypto/IDigest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto
4 | {
5 | /**
6 | * interface that a message digest conforms to.
7 | */
8 | internal interface IDigest
9 | {
10 | /**
11 | * return the algorithm name
12 | *
13 | * @return the algorithm name
14 | */
15 | string AlgorithmName { get; }
16 |
17 | /**
18 | * return the size, in bytes, of the digest produced by this message digest.
19 | *
20 | * @return the size, in bytes, of the digest produced by this message digest.
21 | */
22 | int GetDigestSize();
23 |
24 | /**
25 | * return the size, in bytes, of the internal buffer used by this digest.
26 | *
27 | * @return the size, in bytes, of the internal buffer used by this digest.
28 | */
29 | int GetByteLength();
30 |
31 | /**
32 | * update the message digest with a single byte.
33 | *
34 | * @param inByte the input byte to be entered.
35 | */
36 | void Update(byte input);
37 |
38 | /**
39 | * update the message digest with a block of bytes.
40 | *
41 | * @param input the byte array containing the data.
42 | * @param inOff the offset into the byte array where the data starts.
43 | * @param len the length of the data.
44 | */
45 | void BlockUpdate(byte[] input, int inOff, int length);
46 |
47 | /**
48 | * Close the digest, producing the final digest value. The doFinal
49 | * call leaves the digest reset.
50 | *
51 | * @param output the array the digest is to be copied into.
52 | * @param outOff the offset into the out array the digest is to start at.
53 | */
54 | int DoFinal(byte[] output, int outOff);
55 |
56 | /**
57 | * reset the digest back to it's initial state.
58 | */
59 | void Reset();
60 | }
61 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/crypto/KeyGenerationParameters.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Renci.SshNet.Security.Org.BouncyCastle.Security;
4 |
5 | namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto
6 | {
7 | /**
8 | * The base class for parameters to key generators.
9 | */
10 | internal class KeyGenerationParameters
11 | {
12 | private SecureRandom random;
13 | private int strength;
14 |
15 | /**
16 | * initialise the generator with a source of randomness
17 | * and a strength (in bits).
18 | *
19 | * @param random the random byte source.
20 | * @param strength the size, in bits, of the keys we want to produce.
21 | */
22 | public KeyGenerationParameters(
23 | SecureRandom random,
24 | int strength)
25 | {
26 | if (random == null)
27 | throw new ArgumentNullException("random");
28 | if (strength < 1)
29 | throw new ArgumentException("strength must be a positive value", "strength");
30 |
31 | this.random = random;
32 | this.strength = strength;
33 | }
34 |
35 | /**
36 | * return the random source associated with this
37 | * generator.
38 | *
39 | * @return the generators random source.
40 | */
41 | public SecureRandom Random
42 | {
43 | get { return random; }
44 | }
45 |
46 | /**
47 | * return the bit strength for keys produced by this generator,
48 | *
49 | * @return the strength of the keys this generator produces (in bits).
50 | */
51 | public int Strength
52 | {
53 | get { return strength; }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/crypto/License.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 | License
7 |
8 |
9 | The Bouncy Castle Cryptographic C#® API
10 | License:
11 | The Bouncy Castle License
12 | Copyright (c) 2000-2018 The Legion of the Bouncy Castle Inc.
13 | (https://www.bouncycastle.org)
14 | Permission is hereby granted, free of charge, to any person obtaining a
15 | copy of this software and associated documentation files (the "Software"), to deal in the
16 | Software without restriction, including without limitation the rights to use, copy, modify, merge,
17 | publish, distribute, sub license, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
18 | The above copyright notice and this permission notice shall be included
19 | in all copies or substantial portions of the Software.
20 | THE SOFTWARE IS PROVIDED "AS IS",
21 | WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23 | INCLUDING BUT NOT LIMITED TO THE
24 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
26 | PURPOSE AND NONINFRINGEMENT. IN NO
27 | EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
32 | OTHERWISE, ARISING FROM, OUT OF OR IN
33 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35 | DEALINGS IN THE SOFTWARE.
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/crypto/agreement/ECDHCBasicAgreement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Renci.SshNet.Security.Org.BouncyCastle.Math;
4 | using Renci.SshNet.Security.Org.BouncyCastle.Math.EC;
5 | using Renci.SshNet.Security.Org.BouncyCastle.Crypto.Parameters;
6 |
7 | namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto.Agreement
8 | {
9 | internal class ECDHCBasicAgreement
10 | {
11 | private ECPrivateKeyParameters privKey;
12 |
13 | public virtual void Init(
14 | AsymmetricKeyParameter parameters)
15 | {
16 | this.privKey = (ECPrivateKeyParameters)parameters;
17 | }
18 |
19 | public virtual int GetFieldSize()
20 | {
21 | return (privKey.Parameters.Curve.FieldSize + 7) / 8;
22 | }
23 |
24 | public virtual BigInteger CalculateAgreement(
25 | ECPublicKeyParameters pubKey)
26 | {
27 | ECPublicKeyParameters pub = pubKey;
28 | ECDomainParameters dp = privKey.Parameters;
29 | if (!dp.Equals(pub.Parameters))
30 | throw new InvalidOperationException("ECDHC public key has wrong domain parameters");
31 |
32 | BigInteger hd = dp.H.Multiply(privKey.D).Mod(dp.N);
33 |
34 | // Always perform calculations on the exact curve specified by our private key's parameters
35 | ECPoint pubPoint = ECAlgorithms.CleanPoint(dp.Curve, pub.Q);
36 | if (pubPoint.IsInfinity)
37 | throw new InvalidOperationException("Infinity is not a valid public key for ECDHC");
38 |
39 | ECPoint P = pubPoint.Multiply(hd).Normalize();
40 | if (P.IsInfinity)
41 | throw new InvalidOperationException("Infinity is not a valid agreement value for ECDHC");
42 |
43 | return P.AffineXCoord.ToBigInteger();
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/crypto/parameters/ECKeyGenerationParameters.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Security.Org.BouncyCastle.Security;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto.Parameters
4 | {
5 | internal class ECKeyGenerationParameters
6 | : KeyGenerationParameters
7 | {
8 | private readonly ECDomainParameters domainParams;
9 |
10 | public ECKeyGenerationParameters(
11 | ECDomainParameters domainParameters,
12 | SecureRandom random)
13 | : base(random, domainParameters.N.BitLength)
14 | {
15 | this.domainParams = domainParameters;
16 | }
17 |
18 | public ECDomainParameters DomainParameters
19 | {
20 | get { return domainParams; }
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/crypto/parameters/ECPrivateKeyParameters.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Renci.SshNet.Security.Org.BouncyCastle.Math;
4 |
5 | namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto.Parameters
6 | {
7 | internal class ECPrivateKeyParameters
8 | : ECKeyParameters
9 | {
10 | private readonly BigInteger d;
11 |
12 | public ECPrivateKeyParameters(
13 | BigInteger d,
14 | ECDomainParameters parameters)
15 | : this("EC", d, parameters)
16 | {
17 | }
18 |
19 | public ECPrivateKeyParameters(
20 | string algorithm,
21 | BigInteger d,
22 | ECDomainParameters parameters)
23 | : base(algorithm, true, parameters)
24 | {
25 | if (d == null)
26 | throw new ArgumentNullException("d");
27 |
28 | this.d = d;
29 | }
30 |
31 | public BigInteger D
32 | {
33 | get { return d; }
34 | }
35 |
36 | public override bool Equals(
37 | object obj)
38 | {
39 | if (obj == this)
40 | return true;
41 |
42 | ECPrivateKeyParameters other = obj as ECPrivateKeyParameters;
43 |
44 | if (other == null)
45 | return false;
46 |
47 | return Equals(other);
48 | }
49 |
50 | protected bool Equals(
51 | ECPrivateKeyParameters other)
52 | {
53 | return d.Equals(other.d) && base.Equals(other);
54 | }
55 |
56 | public override int GetHashCode()
57 | {
58 | return d.GetHashCode() ^ base.GetHashCode();
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/crypto/parameters/ECPublicKeyParameters.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Renci.SshNet.Security.Org.BouncyCastle.Math.EC;
4 |
5 | namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto.Parameters
6 | {
7 | internal class ECPublicKeyParameters
8 | : ECKeyParameters
9 | {
10 | private readonly ECPoint q;
11 |
12 | public ECPublicKeyParameters(
13 | ECPoint q,
14 | ECDomainParameters parameters)
15 | : this("EC", q, parameters)
16 | {
17 | }
18 |
19 | public ECPublicKeyParameters(
20 | string algorithm,
21 | ECPoint q,
22 | ECDomainParameters parameters)
23 | : base(algorithm, false, parameters)
24 | {
25 | if (q == null)
26 | throw new ArgumentNullException("q");
27 |
28 | this.q = ECDomainParameters.Validate(Parameters.Curve, q);
29 | }
30 |
31 | public ECPoint Q
32 | {
33 | get { return q; }
34 | }
35 |
36 | public override bool Equals(object obj)
37 | {
38 | if (obj == this)
39 | return true;
40 |
41 | ECPublicKeyParameters other = obj as ECPublicKeyParameters;
42 |
43 | if (other == null)
44 | return false;
45 |
46 | return Equals(other);
47 | }
48 |
49 | protected bool Equals(
50 | ECPublicKeyParameters other)
51 | {
52 | return q.Equals(other.q) && base.Equals(other);
53 | }
54 |
55 | public override int GetHashCode()
56 | {
57 | return q.GetHashCode() ^ base.GetHashCode();
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/crypto/prng/IRandomGenerator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Crypto.Prng
4 | {
5 | /// Generic interface for objects generating random bytes.
6 | internal interface IRandomGenerator
7 | {
8 | /// Add more seed material to the generator.
9 | /// A byte array to be mixed into the generator's state.
10 | void AddSeedMaterial(byte[] seed);
11 |
12 | /// Add more seed material to the generator.
13 | /// A long value to be mixed into the generator's state.
14 | void AddSeedMaterial(long seed);
15 |
16 | /// Fill byte array with random values.
17 | /// Array to be filled.
18 | void NextBytes(byte[] bytes);
19 |
20 | /// Fill byte array with random values.
21 | /// Array to receive bytes.
22 | /// Index to start filling at.
23 | /// Length of segment to fill.
24 | void NextBytes(byte[] bytes, int start, int len);
25 | }
26 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/ECLookupTable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC
4 | {
5 | internal interface ECLookupTable
6 | {
7 | int Size { get; }
8 | ECPoint Lookup(int index);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/ECPointMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC
4 | {
5 | internal interface ECPointMap
6 | {
7 | ECPoint Map(ECPoint p);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/abc/ZTauElement.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Abc
2 | {
3 | /**
4 | * Class representing an element of Z[τ]
. Let
5 | * λ
be an element of Z[τ]
. Then
6 | * λ
is given as λ = u + vτ
. The
7 | * components u
and v
may be used directly, there
8 | * are no accessor methods.
9 | * Immutable class.
10 | */
11 | internal class ZTauElement
12 | {
13 | /**
14 | * The "real" part of λ
.
15 | */
16 | public readonly BigInteger u;
17 |
18 | /**
19 | * The "τ
-adic" part of λ
.
20 | */
21 | public readonly BigInteger v;
22 |
23 | /**
24 | * Constructor for an element λ
of
25 | * Z[τ]
.
26 | * @param u The "real" part of λ
.
27 | * @param v The "τ
-adic" part of
28 | * λ
.
29 | */
30 | public ZTauElement(BigInteger u, BigInteger v)
31 | {
32 | this.u = u;
33 | this.v = v;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/endo/ECEndomorphism.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Endo
4 | {
5 | internal interface ECEndomorphism
6 | {
7 | ECPointMap PointMap { get; }
8 |
9 | bool HasEfficientPointMap { get; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/endo/GlvEndomorphism.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Endo
4 | {
5 | internal interface GlvEndomorphism
6 | : ECEndomorphism
7 | {
8 | BigInteger[] DecomposeScalar(BigInteger k);
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/multiplier/AbstractECMultiplier.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Multiplier
2 | {
3 | internal abstract class AbstractECMultiplier
4 | : ECMultiplier
5 | {
6 | public virtual ECPoint Multiply(ECPoint p, BigInteger k)
7 | {
8 | int sign = k.SignValue;
9 | if (sign == 0 || p.IsInfinity)
10 | return p.Curve.Infinity;
11 |
12 | ECPoint positive = MultiplyPositive(p, k.Abs());
13 | ECPoint result = sign > 0 ? positive : positive.Negate();
14 |
15 | /*
16 | * Although the various multipliers ought not to produce invalid output under normal
17 | * circumstances, a final check here is advised to guard against fault attacks.
18 | */
19 | return CheckResult(result);
20 | }
21 |
22 | protected abstract ECPoint MultiplyPositive(ECPoint p, BigInteger k);
23 |
24 | protected virtual ECPoint CheckResult(ECPoint p)
25 | {
26 | return ECAlgorithms.ImplCheckResult(p);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/multiplier/ECMultiplier.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Multiplier
2 | {
3 | /**
4 | * Interface for classes encapsulating a point multiplication algorithm
5 | * for ECPoint
s.
6 | */
7 | internal interface ECMultiplier
8 | {
9 | /**
10 | * Multiplies the ECPoint p
by k
, i.e.
11 | * p
is added k
times to itself.
12 | * @param p The ECPoint
to be multiplied.
13 | * @param k The factor by which p
is multiplied.
14 | * @return p
multiplied by k
.
15 | */
16 | ECPoint Multiply(ECPoint p, BigInteger k);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/multiplier/FixedPointPreCompInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Multiplier
4 | {
5 | /**
6 | * Class holding precomputation data for fixed-point multiplications.
7 | */
8 | internal class FixedPointPreCompInfo
9 | : PreCompInfo
10 | {
11 | protected ECPoint m_offset = null;
12 |
13 | /**
14 | * Lookup table for the precomputed ECPoint
s used for a fixed point multiplication.
15 | */
16 | protected ECLookupTable m_lookupTable = null;
17 |
18 | /**
19 | * The width used for the precomputation. If a larger width precomputation
20 | * is already available this may be larger than was requested, so calling
21 | * code should refer to the actual width.
22 | */
23 | protected int m_width = -1;
24 |
25 | public virtual ECLookupTable LookupTable
26 | {
27 | get { return m_lookupTable; }
28 | set { this.m_lookupTable = value; }
29 | }
30 |
31 | public virtual ECPoint Offset
32 | {
33 | get { return m_offset; }
34 | set { this.m_offset = value; }
35 | }
36 |
37 | public virtual int Width
38 | {
39 | get { return m_width; }
40 | set { this.m_width = value; }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/multiplier/GlvMultiplier.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Endo;
4 |
5 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Multiplier
6 | {
7 | internal class GlvMultiplier
8 | : AbstractECMultiplier
9 | {
10 | protected readonly ECCurve curve;
11 | protected readonly GlvEndomorphism glvEndomorphism;
12 |
13 | public GlvMultiplier(ECCurve curve, GlvEndomorphism glvEndomorphism)
14 | {
15 | if (curve == null || curve.Order == null)
16 | throw new ArgumentException("Need curve with known group order", "curve");
17 |
18 | this.curve = curve;
19 | this.glvEndomorphism = glvEndomorphism;
20 | }
21 |
22 | protected override ECPoint MultiplyPositive(ECPoint p, BigInteger k)
23 | {
24 | if (!curve.Equals(p.Curve))
25 | throw new InvalidOperationException();
26 |
27 | BigInteger n = p.Curve.Order;
28 | BigInteger[] ab = glvEndomorphism.DecomposeScalar(k.Mod(n));
29 | BigInteger a = ab[0], b = ab[1];
30 |
31 | ECPointMap pointMap = glvEndomorphism.PointMap;
32 | if (glvEndomorphism.HasEfficientPointMap)
33 | {
34 | return ECAlgorithms.ImplShamirsTrickWNaf(p, a, pointMap, b);
35 | }
36 |
37 | return ECAlgorithms.ImplShamirsTrickWNaf(p, a, pointMap.Map(p), b);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/multiplier/IPreCompCallback.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Multiplier
4 | {
5 | internal interface IPreCompCallback
6 | {
7 | PreCompInfo Precompute(PreCompInfo existing);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/multiplier/PreCompInfo.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Multiplier
2 | {
3 | /**
4 | * Interface for classes storing precomputation data for multiplication
5 | * algorithms. Used as a Memento (see GOF patterns) for
6 | * WNafMultiplier
.
7 | */
8 | internal interface PreCompInfo
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/multiplier/ValidityPreCompInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Multiplier
4 | {
5 | internal class ValidityPreCompInfo
6 | : PreCompInfo
7 | {
8 | internal static readonly string PRECOMP_NAME = "bc_validity";
9 |
10 | private bool failed = false;
11 | private bool curveEquationPassed = false;
12 | private bool orderPassed = false;
13 |
14 | internal bool HasFailed()
15 | {
16 | return failed;
17 | }
18 |
19 | internal void ReportFailed()
20 | {
21 | failed = true;
22 | }
23 |
24 | internal bool HasCurveEquationPassed()
25 | {
26 | return curveEquationPassed;
27 | }
28 |
29 | internal void ReportCurveEquationPassed()
30 | {
31 | curveEquationPassed = true;
32 | }
33 |
34 | internal bool HasOrderPassed()
35 | {
36 | return orderPassed;
37 | }
38 |
39 | internal void ReportOrderPassed()
40 | {
41 | orderPassed = true;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/multiplier/WNafPreCompInfo.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Multiplier
2 | {
3 | /**
4 | * Class holding precomputation data for the WNAF (Window Non-Adjacent Form)
5 | * algorithm.
6 | */
7 | internal class WNafPreCompInfo
8 | : PreCompInfo
9 | {
10 | /**
11 | * Array holding the precomputed ECPoint
s used for a Window
12 | * NAF multiplication.
13 | */
14 | protected ECPoint[] m_preComp = null;
15 |
16 | /**
17 | * Array holding the negations of the precomputed ECPoint
s used
18 | * for a Window NAF multiplication.
19 | */
20 | protected ECPoint[] m_preCompNeg = null;
21 |
22 | /**
23 | * Holds an ECPoint
representing Twice(this). Used for the
24 | * Window NAF multiplication to create or extend the precomputed values.
25 | */
26 | protected ECPoint m_twice = null;
27 |
28 | public virtual ECPoint[] PreComp
29 | {
30 | get { return m_preComp; }
31 | set { this.m_preComp = value; }
32 | }
33 |
34 | public virtual ECPoint[] PreCompNeg
35 | {
36 | get { return m_preCompNeg; }
37 | set { this.m_preCompNeg = value; }
38 | }
39 |
40 | public virtual ECPoint Twice
41 | {
42 | get { return m_twice; }
43 | set { this.m_twice = value; }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/ec/multiplier/WTauNafPreCompInfo.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.EC.Multiplier
2 | {
3 | /**
4 | * Class holding precomputation data for the WTNAF (Window
5 | * τ
-adic Non-Adjacent Form) algorithm.
6 | */
7 | internal class WTauNafPreCompInfo
8 | : PreCompInfo
9 | {
10 | /**
11 | * Array holding the precomputed AbstractF2mPoint
s used for the
12 | * WTNAF multiplication in
13 | * {@link org.bouncycastle.math.ec.multiplier.WTauNafMultiplier.multiply()
14 | * WTauNafMultiplier.multiply()}
.
15 | */
16 | protected AbstractF2mPoint[] m_preComp;
17 |
18 | public virtual AbstractF2mPoint[] PreComp
19 | {
20 | get { return m_preComp; }
21 | set { this.m_preComp = value; }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/field/FiniteFields.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.Field
4 | {
5 | internal abstract class FiniteFields
6 | {
7 | internal static readonly IFiniteField GF_2 = new PrimeField(BigInteger.ValueOf(2));
8 | internal static readonly IFiniteField GF_3 = new PrimeField(BigInteger.ValueOf(3));
9 |
10 | public static IPolynomialExtensionField GetBinaryExtensionField(int[] exponents)
11 | {
12 | if (exponents[0] != 0)
13 | {
14 | throw new ArgumentException("Irreducible polynomials in GF(2) must have constant term", "exponents");
15 | }
16 | for (int i = 1; i < exponents.Length; ++i)
17 | {
18 | if (exponents[i] <= exponents[i - 1])
19 | {
20 | throw new ArgumentException("Polynomial exponents must be montonically increasing", "exponents");
21 | }
22 | }
23 |
24 | return new GenericPolynomialExtensionField(GF_2, new GF2Polynomial(exponents));
25 | }
26 |
27 | // public static IPolynomialExtensionField GetTernaryExtensionField(Term[] terms)
28 | // {
29 | // return new GenericPolynomialExtensionField(GF_3, new GF3Polynomial(terms));
30 | // }
31 |
32 | public static IFiniteField GetPrimeField(BigInteger characteristic)
33 | {
34 | int bitLength = characteristic.BitLength;
35 | if (characteristic.SignValue <= 0 || bitLength < 2)
36 | {
37 | throw new ArgumentException("Must be >= 2", "characteristic");
38 | }
39 |
40 | if (bitLength < 3)
41 | {
42 | switch (characteristic.IntValue)
43 | {
44 | case 2:
45 | return GF_2;
46 | case 3:
47 | return GF_3;
48 | }
49 | }
50 |
51 | return new PrimeField(characteristic);
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/field/GF2Polynomial.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Renci.SshNet.Security.Org.BouncyCastle.Utilities;
4 |
5 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.Field
6 | {
7 | internal class GF2Polynomial
8 | : IPolynomial
9 | {
10 | protected readonly int[] exponents;
11 |
12 | internal GF2Polynomial(int[] exponents)
13 | {
14 | this.exponents = Arrays.Clone(exponents);
15 | }
16 |
17 | public virtual int Degree
18 | {
19 | get { return exponents[exponents.Length - 1]; }
20 | }
21 |
22 | public virtual int[] GetExponentsPresent()
23 | {
24 | return Arrays.Clone(exponents);
25 | }
26 |
27 | public override bool Equals(object obj)
28 | {
29 | if (this == obj)
30 | {
31 | return true;
32 | }
33 | GF2Polynomial other = obj as GF2Polynomial;
34 | if (null == other)
35 | {
36 | return false;
37 | }
38 | return Arrays.AreEqual(exponents, other.exponents);
39 | }
40 |
41 | public override int GetHashCode()
42 | {
43 | return Arrays.GetHashCode(exponents);
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/field/GenericPolynomialExtensionField.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Renci.SshNet.Security.Org.BouncyCastle.Utilities;
4 |
5 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.Field
6 | {
7 | internal class GenericPolynomialExtensionField
8 | : IPolynomialExtensionField
9 | {
10 | protected readonly IFiniteField subfield;
11 | protected readonly IPolynomial minimalPolynomial;
12 |
13 | internal GenericPolynomialExtensionField(IFiniteField subfield, IPolynomial polynomial)
14 | {
15 | this.subfield = subfield;
16 | this.minimalPolynomial = polynomial;
17 | }
18 |
19 | public virtual BigInteger Characteristic
20 | {
21 | get { return subfield.Characteristic; }
22 | }
23 |
24 | public virtual int Dimension
25 | {
26 | get { return subfield.Dimension * minimalPolynomial.Degree; }
27 | }
28 |
29 | public virtual IFiniteField Subfield
30 | {
31 | get { return subfield; }
32 | }
33 |
34 | public virtual int Degree
35 | {
36 | get { return minimalPolynomial.Degree; }
37 | }
38 |
39 | public virtual IPolynomial MinimalPolynomial
40 | {
41 | get { return minimalPolynomial; }
42 | }
43 |
44 | public override bool Equals(object obj)
45 | {
46 | if (this == obj)
47 | {
48 | return true;
49 | }
50 | GenericPolynomialExtensionField other = obj as GenericPolynomialExtensionField;
51 | if (null == other)
52 | {
53 | return false;
54 | }
55 | return subfield.Equals(other.subfield) && minimalPolynomial.Equals(other.minimalPolynomial);
56 | }
57 |
58 | public override int GetHashCode()
59 | {
60 | return subfield.GetHashCode() ^ Integers.RotateLeft(minimalPolynomial.GetHashCode(), 16);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/field/IExtensionField.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.Field
4 | {
5 | internal interface IExtensionField
6 | : IFiniteField
7 | {
8 | IFiniteField Subfield { get; }
9 |
10 | int Degree { get; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/field/IFiniteField.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.Field
4 | {
5 | internal interface IFiniteField
6 | {
7 | BigInteger Characteristic { get; }
8 |
9 | int Dimension { get; }
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/field/IPolynomial.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.Field
2 | {
3 | internal interface IPolynomial
4 | {
5 | int Degree { get; }
6 |
7 | //BigInteger[] GetCoefficients();
8 |
9 | int[] GetExponentsPresent();
10 |
11 | //Term[] GetNonZeroTerms();
12 | }
13 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/field/IPolynomialExtensionField.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.Field
2 | {
3 | internal interface IPolynomialExtensionField
4 | : IExtensionField
5 | {
6 | IPolynomial MinimalPolynomial { get; }
7 | }
8 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/math/field/PrimeField.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Org.BouncyCastle.Math.Field
2 | {
3 | internal class PrimeField
4 | : IFiniteField
5 | {
6 | protected readonly BigInteger characteristic;
7 |
8 | internal PrimeField(BigInteger characteristic)
9 | {
10 | this.characteristic = characteristic;
11 | }
12 |
13 | public virtual BigInteger Characteristic
14 | {
15 | get { return characteristic; }
16 | }
17 |
18 | public virtual int Dimension
19 | {
20 | get { return 1; }
21 | }
22 |
23 | public override bool Equals(object obj)
24 | {
25 | if (this == obj)
26 | {
27 | return true;
28 | }
29 | PrimeField other = obj as PrimeField;
30 | if (null == other)
31 | {
32 | return false;
33 | }
34 | return characteristic.Equals(other.characteristic);
35 | }
36 |
37 | public override int GetHashCode()
38 | {
39 | return characteristic.GetHashCode();
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/security/DigestUtilities.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Security.Org.BouncyCastle.Crypto;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Security
4 | {
5 | ///
6 | /// Utility class for creating IDigest objects from their names/Oids
7 | ///
8 | internal sealed class DigestUtilities
9 | {
10 | private enum DigestAlgorithm {
11 | SHA_256
12 | };
13 |
14 | private DigestUtilities()
15 | {
16 | }
17 |
18 | public static byte[] DoFinal(
19 | IDigest digest)
20 | {
21 | byte[] b = new byte[digest.GetDigestSize()];
22 | digest.DoFinal(b, 0);
23 | return b;
24 | }
25 |
26 | public static byte[] DoFinal(
27 | IDigest digest,
28 | byte[] input)
29 | {
30 | digest.BlockUpdate(input, 0, input.Length);
31 | return DoFinal(digest);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/security/SecurityUtilityException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Security
4 | {
5 | #if FEATURE_BINARY_SERIALIZATION
6 | [Serializable]
7 | #endif
8 | internal class SecurityUtilityException
9 | : Exception
10 | {
11 | /**
12 | * base constructor.
13 | */
14 | public SecurityUtilityException()
15 | {
16 | }
17 |
18 | /**
19 | * create a SecurityUtilityException with the given message.
20 | *
21 | * @param message the message to be carried with the exception.
22 | */
23 | public SecurityUtilityException(
24 | string message)
25 | : base(message)
26 | {
27 | }
28 |
29 | public SecurityUtilityException(
30 | string message,
31 | Exception exception)
32 | : base(message, exception)
33 | {
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/util/IMemoable.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Utilities
4 | {
5 | internal interface IMemoable
6 | {
7 | ///
8 | /// Produce a copy of this object with its configuration and in its current state.
9 | ///
10 | ///
11 | /// The returned object may be used simply to store the state, or may be used as a similar object
12 | /// starting from the copied state.
13 | ///
14 | IMemoable Copy();
15 |
16 | ///
17 | /// Restore a copied object state into this object.
18 | ///
19 | ///
20 | /// Implementations of this method should try to avoid or minimise memory allocation to perform the reset.
21 | ///
22 | /// an object originally {@link #copy() copied} from an object of the same type as this instance.
23 | /// if the provided object is not of the correct type.
24 | /// if the other parameter is in some other way invalid.
25 | void Reset(IMemoable other);
26 | }
27 |
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/util/Integers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Utilities
4 | {
5 | internal abstract class Integers
6 | {
7 | public static int RotateLeft(int i, int distance)
8 | {
9 | return (i << distance) ^ (int)((uint)i >> -distance);
10 | }
11 |
12 | public static uint RotateLeft(uint i, int distance)
13 | {
14 | return (i << distance) ^ (i >> -distance);
15 | }
16 |
17 | public static int RotateRight(int i, int distance)
18 | {
19 | return (int)((uint)i >> distance) ^ (i << -distance);
20 | }
21 |
22 | public static uint RotateRight(uint i, int distance)
23 | {
24 | return (i >> distance) ^ (i << -distance);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/util/MemoableResetException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Utilities
4 | {
5 | /**
6 | * Exception to be thrown on a failure to reset an object implementing Memoable.
7 | *
8 | * The exception extends InvalidCastException to enable users to have a single handling case,
9 | * only introducing specific handling of this one if required.
10 | *
11 | */
12 | internal class MemoableResetException
13 | : InvalidCastException
14 | {
15 | /**
16 | * Basic Constructor.
17 | *
18 | * @param msg message to be associated with this exception.
19 | */
20 | public MemoableResetException(string msg)
21 | : base(msg)
22 | {
23 | }
24 | }
25 |
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/BouncyCastle/util/Times.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Org.BouncyCastle.Utilities
4 | {
5 | internal sealed class Times
6 | {
7 | private static long NanosecondsPerTick = 100L;
8 |
9 | public static long NanoTime()
10 | {
11 | return DateTime.UtcNow.Ticks * NanosecondsPerTick;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/CertificateHostAlgorithm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security
4 | {
5 | ///
6 | /// Implements certificate support for host algorithm.
7 | ///
8 | public class CertificateHostAlgorithm : HostAlgorithm
9 | {
10 | ///
11 | /// Gets the host key data.
12 | ///
13 | public override byte[] Data
14 | {
15 | get { throw new NotImplementedException(); }
16 | }
17 |
18 | ///
19 | /// Initializes a new instance of the class.
20 | ///
21 | /// The host key name.
22 | public CertificateHostAlgorithm(string name)
23 | : base(name)
24 | {
25 | }
26 |
27 | ///
28 | /// Signs the specified data.
29 | ///
30 | /// The data.
31 | /// Signed data.
32 | ///
33 | public override byte[] Sign(byte[] data)
34 | {
35 | throw new NotImplementedException();
36 | }
37 |
38 | ///
39 | /// Verifies the signature.
40 | ///
41 | /// The data.
42 | /// The signature.
43 | /// true if signature was successfully verified; otherwise false.
44 | ///
45 | public override bool VerifySignature(byte[] data, byte[] signature)
46 | {
47 | throw new NotImplementedException();
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Array16.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal
5 | {
6 | // Array16 Salsa20 state
7 | // Array16 SHA-512 block
8 | internal struct Array16
9 | {
10 | public T x0;
11 | public T x1;
12 | public T x2;
13 | public T x3;
14 | public T x4;
15 | public T x5;
16 | public T x6;
17 | public T x7;
18 | public T x8;
19 | public T x9;
20 | public T x10;
21 | public T x11;
22 | public T x12;
23 | public T x13;
24 | public T x14;
25 | public T x15;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Array8.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal
4 | {
5 | // Array8 Poly1305 key
6 | // Array8 SHA-512 state/output
7 | internal struct Array8
8 | {
9 | public T x0;
10 | public T x1;
11 | public T x2;
12 | public T x3;
13 | public T x4;
14 | public T x5;
15 | public T x6;
16 | public T x7;
17 | }
18 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/FieldElement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal struct FieldElement
6 | {
7 | internal int x0;
8 | internal int x1;
9 | internal int x2;
10 | internal int x3;
11 | internal int x4;
12 | internal int x5;
13 | internal int x6;
14 | internal int x7;
15 | internal int x8;
16 | internal int x9;
17 |
18 | //internal static readonly FieldElement Zero = new FieldElement();
19 | //internal static readonly FieldElement One = new FieldElement() { x0 = 1 };
20 |
21 | internal FieldElement(params int[] elements)
22 | {
23 | InternalAssert.Assert(elements.Length == 10, "elements.Length != 10");
24 | x0 = elements[0];
25 | x1 = elements[1];
26 | x2 = elements[2];
27 | x3 = elements[3];
28 | x4 = elements[4];
29 | x5 = elements[5];
30 | x6 = elements[6];
31 | x7 = elements[7];
32 | x8 = elements[8];
33 | x9 = elements[9];
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/GroupElement.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | /*
6 | ge means group element.
7 |
8 | Here the group is the set of pairs (x,y) of field elements (see fe.h)
9 | satisfying -x^2 + y^2 = 1 + d x^2y^2
10 | where d = -121665/121666.
11 |
12 | Representations:
13 | ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z
14 | ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT
15 | ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T
16 | ge_precomp (Duif): (y+x,y-x,2dxy)
17 | */
18 |
19 | internal struct GroupElementP2
20 | {
21 | public FieldElement X;
22 | public FieldElement Y;
23 | public FieldElement Z;
24 | } ;
25 |
26 | internal struct GroupElementP3
27 | {
28 | public FieldElement X;
29 | public FieldElement Y;
30 | public FieldElement Z;
31 | public FieldElement T;
32 | } ;
33 |
34 | internal struct GroupElementP1P1
35 | {
36 | public FieldElement X;
37 | public FieldElement Y;
38 | public FieldElement Z;
39 | public FieldElement T;
40 | } ;
41 |
42 | internal struct GroupElementPreComp
43 | {
44 | public FieldElement yplusx;
45 | public FieldElement yminusx;
46 | public FieldElement xy2d;
47 |
48 | public GroupElementPreComp(FieldElement yplusx, FieldElement yminusx, FieldElement xy2d)
49 | {
50 | this.yplusx = yplusx;
51 | this.yminusx = yminusx;
52 | this.xy2d = xy2d;
53 | }
54 | } ;
55 |
56 | internal struct GroupElementCached
57 | {
58 | public FieldElement YplusX;
59 | public FieldElement YminusX;
60 | public FieldElement Z;
61 | public FieldElement T2d;
62 | } ;
63 | }
64 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/d.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class LookupTables
6 | {
7 | internal static FieldElement d = new FieldElement(-10913610, 13857413, -15372611, 6949391, 114729, -8787816, -6275908, -3247719, -18696448, -12055116);
8 | }
9 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/d2.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class LookupTables
6 | {
7 | internal static FieldElement d2 = new FieldElement(-21827239, -5839606, -30745221, 13898782, 229458, 15978800, -12551817, -6495438, 29715968, 9444199);
8 | }
9 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/fe_0.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class FieldOperations
6 | {
7 | internal static void fe_0(out FieldElement h)
8 | {
9 | h = default(FieldElement);
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/fe_1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class FieldOperations
6 | {
7 | internal static void fe_1(out FieldElement h)
8 | {
9 | h = default(FieldElement);
10 | h.x0 = 1;
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/fe_add.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class FieldOperations
6 | {
7 | /*
8 | h = f + g
9 | Can overlap h with f or g.
10 |
11 | Preconditions:
12 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
13 | |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
14 |
15 | Postconditions:
16 | |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
17 | */
18 | //void fe_add(fe h,const fe f,const fe g)
19 | internal static void fe_add(out FieldElement h, ref FieldElement f, ref FieldElement g)
20 | {
21 | Int32 f0 = f.x0;
22 | Int32 f1 = f.x1;
23 | Int32 f2 = f.x2;
24 | Int32 f3 = f.x3;
25 | Int32 f4 = f.x4;
26 | Int32 f5 = f.x5;
27 | Int32 f6 = f.x6;
28 | Int32 f7 = f.x7;
29 | Int32 f8 = f.x8;
30 | Int32 f9 = f.x9;
31 | Int32 g0 = g.x0;
32 | Int32 g1 = g.x1;
33 | Int32 g2 = g.x2;
34 | Int32 g3 = g.x3;
35 | Int32 g4 = g.x4;
36 | Int32 g5 = g.x5;
37 | Int32 g6 = g.x6;
38 | Int32 g7 = g.x7;
39 | Int32 g8 = g.x8;
40 | Int32 g9 = g.x9;
41 | Int32 h0 = f0 + g0;
42 | Int32 h1 = f1 + g1;
43 | Int32 h2 = f2 + g2;
44 | Int32 h3 = f3 + g3;
45 | Int32 h4 = f4 + g4;
46 | Int32 h5 = f5 + g5;
47 | Int32 h6 = f6 + g6;
48 | Int32 h7 = f7 + g7;
49 | Int32 h8 = f8 + g8;
50 | Int32 h9 = f9 + g9;
51 | h.x0 = h0;
52 | h.x1 = h1;
53 | h.x2 = h2;
54 | h.x3 = h3;
55 | h.x4 = h4;
56 | h.x5 = h5;
57 | h.x6 = h6;
58 | h.x7 = h7;
59 | h.x8 = h8;
60 | h.x9 = h9;
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/fe_cmov.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class FieldOperations
6 | {
7 | /*
8 | Replace (f,g) with (g,g) if b == 1;
9 | replace (f,g) with (f,g) if b == 0.
10 |
11 | Preconditions: b in {0,1}.
12 | */
13 |
14 | //void fe_cmov(fe f,const fe g,unsigned int b)
15 | internal static void fe_cmov(ref FieldElement f, ref FieldElement g, int b)
16 | {
17 | Int32 f0 = f.x0;
18 | Int32 f1 = f.x1;
19 | Int32 f2 = f.x2;
20 | Int32 f3 = f.x3;
21 | Int32 f4 = f.x4;
22 | Int32 f5 = f.x5;
23 | Int32 f6 = f.x6;
24 | Int32 f7 = f.x7;
25 | Int32 f8 = f.x8;
26 | Int32 f9 = f.x9;
27 | Int32 g0 = g.x0;
28 | Int32 g1 = g.x1;
29 | Int32 g2 = g.x2;
30 | Int32 g3 = g.x3;
31 | Int32 g4 = g.x4;
32 | Int32 g5 = g.x5;
33 | Int32 g6 = g.x6;
34 | Int32 g7 = g.x7;
35 | Int32 g8 = g.x8;
36 | Int32 g9 = g.x9;
37 | Int32 x0 = f0 ^ g0;
38 | Int32 x1 = f1 ^ g1;
39 | Int32 x2 = f2 ^ g2;
40 | Int32 x3 = f3 ^ g3;
41 | Int32 x4 = f4 ^ g4;
42 | Int32 x5 = f5 ^ g5;
43 | Int32 x6 = f6 ^ g6;
44 | Int32 x7 = f7 ^ g7;
45 | Int32 x8 = f8 ^ g8;
46 | Int32 x9 = f9 ^ g9;
47 | b = -b;
48 | x0 &= b;
49 | x1 &= b;
50 | x2 &= b;
51 | x3 &= b;
52 | x4 &= b;
53 | x5 &= b;
54 | x6 &= b;
55 | x7 &= b;
56 | x8 &= b;
57 | x9 &= b;
58 | f.x0 = f0 ^ x0;
59 | f.x1 = f1 ^ x1;
60 | f.x2 = f2 ^ x2;
61 | f.x3 = f3 ^ x3;
62 | f.x4 = f4 ^ x4;
63 | f.x5 = f5 ^ x5;
64 | f.x6 = f6 ^ x6;
65 | f.x7 = f7 ^ x7;
66 | f.x8 = f8 ^ x8;
67 | f.x9 = f9 ^ x9;
68 | }
69 | }
70 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/fe_isnegative.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class FieldOperations
6 | {
7 | /*
8 | return 1 if f is in {1,3,5,...,q-2}
9 | return 0 if f is in {0,2,4,...,q-1}
10 |
11 | Preconditions:
12 | |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
13 | */
14 | //int fe_isnegative(const fe f)
15 | internal static int fe_isnegative(ref FieldElement f)
16 | {
17 | FieldElement fr;
18 | fe_reduce(out fr, ref f);
19 | return fr.x0 & 1;
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/fe_isnonzero.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class FieldOperations
6 | {
7 | /*
8 | return 1 if f == 0
9 | return 0 if f != 0
10 |
11 | Preconditions:
12 | |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
13 | */
14 | // Todo: Discuss this with upstream
15 | // Above comment is from the original code. But I believe the original code returned
16 | // 0 if f == 0
17 | // -1 if f != 0
18 | // This code actually returns 0 if f==0 and 1 if f != 0
19 | internal static int fe_isnonzero(ref FieldElement f)
20 | {
21 | FieldElement fr;
22 | fe_reduce(out fr, ref f);
23 | int differentBits = 0;
24 | differentBits |= fr.x0;
25 | differentBits |= fr.x1;
26 | differentBits |= fr.x2;
27 | differentBits |= fr.x3;
28 | differentBits |= fr.x4;
29 | differentBits |= fr.x5;
30 | differentBits |= fr.x6;
31 | differentBits |= fr.x7;
32 | differentBits |= fr.x8;
33 | differentBits |= fr.x9;
34 | return (int)((unchecked((uint)differentBits - 1) >> 31) ^ 1);
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/fe_neg.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class FieldOperations
6 | {
7 | /*
8 | h = -f
9 |
10 | Preconditions:
11 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
12 |
13 | Postconditions:
14 | |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
15 | */
16 | internal static void fe_neg(out FieldElement h, ref FieldElement f)
17 | {
18 | Int32 f0 = f.x0;
19 | Int32 f1 = f.x1;
20 | Int32 f2 = f.x2;
21 | Int32 f3 = f.x3;
22 | Int32 f4 = f.x4;
23 | Int32 f5 = f.x5;
24 | Int32 f6 = f.x6;
25 | Int32 f7 = f.x7;
26 | Int32 f8 = f.x8;
27 | Int32 f9 = f.x9;
28 | Int32 h0 = -f0;
29 | Int32 h1 = -f1;
30 | Int32 h2 = -f2;
31 | Int32 h3 = -f3;
32 | Int32 h4 = -f4;
33 | Int32 h5 = -f5;
34 | Int32 h6 = -f6;
35 | Int32 h7 = -f7;
36 | Int32 h8 = -f8;
37 | Int32 h9 = -f9;
38 | h.x0 = h0;
39 | h.x1 = h1;
40 | h.x2 = h2;
41 | h.x3 = h3;
42 | h.x4 = h4;
43 | h.x5 = h5;
44 | h.x6 = h6;
45 | h.x7 = h7;
46 | h.x8 = h8;
47 | h.x9 = h9;
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/fe_sub.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class FieldOperations
6 | {
7 | /*
8 | h = f - g
9 | Can overlap h with f or g.
10 |
11 | Preconditions:
12 | |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
13 | |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
14 |
15 | Postconditions:
16 | |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
17 | */
18 |
19 | internal static void fe_sub(out FieldElement h, ref FieldElement f, ref FieldElement g)
20 | {
21 | Int32 f0 = f.x0;
22 | Int32 f1 = f.x1;
23 | Int32 f2 = f.x2;
24 | Int32 f3 = f.x3;
25 | Int32 f4 = f.x4;
26 | Int32 f5 = f.x5;
27 | Int32 f6 = f.x6;
28 | Int32 f7 = f.x7;
29 | Int32 f8 = f.x8;
30 | Int32 f9 = f.x9;
31 | Int32 g0 = g.x0;
32 | Int32 g1 = g.x1;
33 | Int32 g2 = g.x2;
34 | Int32 g3 = g.x3;
35 | Int32 g4 = g.x4;
36 | Int32 g5 = g.x5;
37 | Int32 g6 = g.x6;
38 | Int32 g7 = g.x7;
39 | Int32 g8 = g.x8;
40 | Int32 g9 = g.x9;
41 | Int32 h0 = f0 - g0;
42 | Int32 h1 = f1 - g1;
43 | Int32 h2 = f2 - g2;
44 | Int32 h3 = f3 - g3;
45 | Int32 h4 = f4 - g4;
46 | Int32 h5 = f5 - g5;
47 | Int32 h6 = f6 - g6;
48 | Int32 h7 = f7 - g7;
49 | Int32 h8 = f8 - g8;
50 | Int32 h9 = f9 - g9;
51 | h.x0 = h0;
52 | h.x1 = h1;
53 | h.x2 = h2;
54 | h.x3 = h3;
55 | h.x4 = h4;
56 | h.x5 = h5;
57 | h.x6 = h6;
58 | h.x7 = h7;
59 | h.x8 = h8;
60 | h.x9 = h9;
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/ge_p1p1_to_p2.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class GroupOperations
6 | {
7 | /*
8 | r = p
9 | */
10 | internal static void ge_p1p1_to_p2(out GroupElementP2 r, ref GroupElementP1P1 p)
11 | {
12 | FieldOperations.fe_mul(out r.X, ref p.X, ref p.T);
13 | FieldOperations.fe_mul(out r.Y, ref p.Y, ref p.Z);
14 | FieldOperations.fe_mul(out r.Z, ref p.Z, ref p.T);
15 | }
16 |
17 | }
18 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/ge_p1p1_to_p3.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class GroupOperations
6 | {
7 | /*
8 | r = p
9 | */
10 | internal static void ge_p1p1_to_p3(out GroupElementP3 r, ref GroupElementP1P1 p)
11 | {
12 | FieldOperations.fe_mul(out r.X, ref p.X, ref p.T);
13 | FieldOperations.fe_mul(out r.Y, ref p.Y, ref p.Z);
14 | FieldOperations.fe_mul(out r.Z, ref p.Z, ref p.T);
15 | FieldOperations.fe_mul(out r.T, ref p.X, ref p.Y);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/ge_p2_0.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class GroupOperations
6 | {
7 | internal static void ge_p2_0(out GroupElementP2 h)
8 | {
9 | FieldOperations.fe_0(out h.X);
10 | FieldOperations.fe_1(out h.Y);
11 | FieldOperations.fe_1(out h.Z);
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/ge_p3_0.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class GroupOperations
6 | {
7 | internal static void ge_p3_0(out GroupElementP3 h)
8 | {
9 | FieldOperations.fe_0(out h.X);
10 | FieldOperations.fe_1(out h.Y);
11 | FieldOperations.fe_1(out h.Z);
12 | FieldOperations.fe_0(out h.T);
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/ge_p3_dbl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class GroupOperations
6 | {
7 | /*
8 | r = 2 * p
9 | */
10 | internal static void ge_p3_dbl(out GroupElementP1P1 r, ref GroupElementP3 p)
11 | {
12 | GroupElementP2 q;
13 | ge_p3_to_p2(out q, ref p);
14 | ge_p2_dbl(out r, ref q);
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/ge_p3_to_cached.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class GroupOperations
6 | {
7 | /*
8 | r = p
9 | */
10 | internal static void ge_p3_to_cached(out GroupElementCached r, ref GroupElementP3 p)
11 | {
12 | FieldOperations.fe_add(out r.YplusX, ref p.Y, ref p.X);
13 | FieldOperations.fe_sub(out r.YminusX, ref p.Y, ref p.X);
14 | r.Z = p.Z;
15 | FieldOperations.fe_mul(out r.T2d, ref p.T, ref LookupTables.d2);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/ge_p3_to_p2.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class GroupOperations
6 | {
7 | /*
8 | r = p
9 | */
10 | internal static void ge_p3_to_p2(out GroupElementP2 r, ref GroupElementP3 p)
11 | {
12 | r.X = p.X;
13 | r.Y = p.Y;
14 | r.Z = p.Z;
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/ge_p3_tobytes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class GroupOperations
6 | {
7 | internal static void ge_p3_tobytes(byte[] s, int offset, ref GroupElementP3 h)
8 | {
9 | FieldElement recip;
10 | FieldElement x;
11 | FieldElement y;
12 |
13 | FieldOperations.fe_invert(out recip, ref h.Z);
14 | FieldOperations.fe_mul(out x, ref h.X, ref recip);
15 | FieldOperations.fe_mul(out y, ref h.Y, ref recip);
16 | FieldOperations.fe_tobytes(s, offset, ref y);
17 | s[offset + 31] ^= (byte)(FieldOperations.fe_isnegative(ref x) << 7);
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/ge_precomp_0.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class GroupOperations
6 | {
7 | internal static void ge_precomp_0(out GroupElementPreComp h)
8 | {
9 | FieldOperations.fe_1(out h.yplusx);
10 | FieldOperations.fe_1(out h.yminusx);
11 | FieldOperations.fe_0(out h.xy2d);
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/ge_tobytes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class GroupOperations
6 | {
7 | internal static void ge_tobytes(byte[] s, int offset, ref GroupElementP2 h)
8 | {
9 | FieldElement recip;
10 | FieldElement x;
11 | FieldElement y;
12 |
13 | FieldOperations.fe_invert(out recip, ref h.Z);
14 | FieldOperations.fe_mul(out x, ref h.X, ref recip);
15 | FieldOperations.fe_mul(out y, ref h.Y, ref recip);
16 | FieldOperations.fe_tobytes(s, offset, ref y);
17 | s[offset + 31] ^= (byte)(FieldOperations.fe_isnegative(ref x) << 7);
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/keypair.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class Ed25519Operations
6 | {
7 | internal static void crypto_sign_keypair(byte[] pk, int pkoffset, byte[] sk, int skoffset, byte[] seed, int seedoffset)
8 | {
9 | GroupElementP3 A;
10 | int i;
11 |
12 | Array.Copy(seed, seedoffset, sk, skoffset, 32);
13 | byte[] h = Sha512.Hash(sk, skoffset, 32);//ToDo: Remove alloc
14 | ScalarOperations.sc_clamp(h, 0);
15 |
16 | GroupOperations.ge_scalarmult_base(out A, h, 0);
17 | GroupOperations.ge_p3_tobytes(pk, pkoffset, ref A);
18 |
19 | for (i = 0; i < 32; ++i) sk[skoffset + 32 + i] = pk[pkoffset + i];
20 | CryptoBytes.Wipe(h);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/sc_clamp.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class ScalarOperations
6 | {
7 | internal static void sc_clamp(byte[] s, int offset)
8 | {
9 | s[offset + 0] &= 248;
10 | s[offset + 31] &= 127;
11 | s[offset + 31] |= 64;
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Ed25519Ref10/sqrtm1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal.Ed25519Ref10
4 | {
5 | internal static partial class LookupTables
6 | {
7 | internal static FieldElement sqrtm1 = new FieldElement(-32595792, -7943725, 9377950, 3500415, 12389472, -272473, -25146209, -2005654, 326686, 11406482);
8 | }
9 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/InternalAssert.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Chaos.NaCl.Internal
4 | {
5 | internal static class InternalAssert
6 | {
7 | internal static void Assert(bool condition, string message)
8 | {
9 | if (!condition)
10 | throw new InvalidOperationException("An assertion in Chaos.Crypto failed " + message);
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/Internal/Salsa/replace regex.txt:
--------------------------------------------------------------------------------
1 | x(\d+) ^= rotate\((.+), (\d+)\);
2 | y = \2;\r\nx\1 ^= (y << \3) | (y >> (32 - \3));
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Chaos.NaCl/License.txt:
--------------------------------------------------------------------------------
1 | Public domain
2 |
3 | C# port + code by Christian Winnerlein (CodesInChaos)
4 |
5 | Poly1305 in c
6 | written by Andrew M. (floodyberry)
7 | original license: MIT or PUBLIC DOMAIN
8 | https://github.com/floodyberry/poly1305-donna/blob/master/poly1305-donna-unrolled.c
9 |
10 | Curve25519 and Ed25519 in c
11 | written by Dan Bernstein (djb)
12 | public domain
13 | from Ref10 in SUPERCOP http://bench.cr.yp.to/supercop.html
14 |
15 | (H)Salsa20 in c
16 | written by Dan Bernstein (djb)
17 | public domain
18 | from SUPERCOP http://bench.cr.yp.to/supercop.html
19 |
20 | SHA512
21 | written by Christian Winnerlein (CodesInChaos)
22 | public domain
23 | directly from the specification
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Cryptography/AsymmetricCipher.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Cryptography
2 | {
3 | ///
4 | /// Base class for asymmetric cipher implementations.
5 | ///
6 | public abstract class AsymmetricCipher : Cipher
7 | {
8 | ///
9 | /// Gets the minimum data size.
10 | ///
11 | ///
12 | /// The minimum data size.
13 | ///
14 | public override byte MinimumSize
15 | {
16 | get { return 0; }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Cryptography/DigitalSignature.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security.Cryptography
2 | {
3 | ///
4 | /// Base class for signature implementations
5 | ///
6 | public abstract class DigitalSignature
7 | {
8 | ///
9 | /// Verifies the signature.
10 | ///
11 | /// The input.
12 | /// The signature.
13 | /// True if signature was successfully verified; otherwise false.
14 | public abstract bool Verify(byte[] input, byte[] signature);
15 |
16 | ///
17 | /// Creates the signature.
18 | ///
19 | /// The input.
20 | /// Signed input data.
21 | public abstract byte[] Sign(byte[] input);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Cryptography/HMACMD5.cs:
--------------------------------------------------------------------------------
1 | #if FEATURE_HMAC_MD5
2 |
3 | using System.Security.Cryptography;
4 | using Renci.SshNet.Common;
5 |
6 | namespace Renci.SshNet.Security.Cryptography
7 | {
8 | ///
9 | /// Computes a Hash-based Message Authentication Code (HMAC) by using the hash function.
10 | ///
11 | public class HMACMD5 : System.Security.Cryptography.HMACMD5
12 | {
13 | private readonly int _hashSize;
14 |
15 | ///
16 | /// Initializes a with the specified key.
17 | ///
18 | /// The key.
19 | public HMACMD5(byte[] key)
20 | : base(key)
21 | {
22 | _hashSize = base.HashSize;
23 | }
24 |
25 | ///
26 | /// Initializes a with the specified key and size of the computed hash code.
27 | ///
28 | /// The key.
29 | /// The size, in bits, of the computed hash code.
30 | public HMACMD5(byte[] key, int hashSize)
31 | : base(key)
32 | {
33 | _hashSize = hashSize;
34 | }
35 |
36 | ///
37 | /// Gets the size, in bits, of the computed hash code.
38 | ///
39 | ///
40 | /// The size, in bits, of the computed hash code.
41 | ///
42 | public override int HashSize
43 | {
44 | get { return _hashSize; }
45 | }
46 |
47 | ///
48 | /// Finalizes the hash computation after the last data is processed by the cryptographic stream object.
49 | ///
50 | ///
51 | /// The computed hash code.
52 | ///
53 | protected override byte[] HashFinal()
54 | {
55 | var hash = base.HashFinal();
56 | return hash.Take(HashSize / 8);
57 | }
58 | }
59 | }
60 |
61 | #endif // FEATURE_HMAC_MD5
62 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/Cryptography/StreamCipher.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Security.Cryptography
4 | {
5 | ///
6 | /// Base class of stream cipher algorithms.
7 | ///
8 | public abstract class StreamCipher : SymmetricCipher
9 | {
10 | ///
11 | /// Initializes a new instance of the class.
12 | ///
13 | /// The key.
14 | /// is null.
15 | protected StreamCipher(byte[] key)
16 | : base(key)
17 | {
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/HostAlgorithm.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Security
2 | {
3 | ///
4 | /// Base class for SSH host algorithms.
5 | ///
6 | public abstract class HostAlgorithm
7 | {
8 | ///
9 | /// Gets the host key name.
10 | ///
11 | public string Name { get; private set; }
12 |
13 | ///
14 | /// Gets the host key data.
15 | ///
16 | public abstract byte[] Data { get; }
17 |
18 | ///
19 | /// Initializes a new instance of the class.
20 | ///
21 | /// The host key name.
22 | protected HostAlgorithm(string name)
23 | {
24 | Name = name;
25 | }
26 |
27 | ///
28 | /// Signs the specified data.
29 | ///
30 | /// The data.
31 | /// Signed data.
32 | public abstract byte[] Sign(byte[] data);
33 |
34 | ///
35 | /// Verifies the signature.
36 | ///
37 | /// The data.
38 | /// The signature.
39 | /// True is signature was successfully verifies; otherwise false.
40 | public abstract bool VerifySignature(byte[] data, byte[] signature);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroup1Sha1.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Common;
2 |
3 | namespace Renci.SshNet.Security
4 | {
5 | ///
6 | /// Represents "diffie-hellman-group1-sha1" algorithm implementation.
7 | ///
8 | internal class KeyExchangeDiffieHellmanGroup1Sha1 : KeyExchangeDiffieHellmanGroupSha1
9 | {
10 | private static readonly byte[] SecondOkleyGroupReversed =
11 | {
12 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x81, 0x53, 0xe6, 0xec,
13 | 0x51, 0x66, 0x28, 0x49, 0xe6, 0x1f, 0x4b, 0x7c, 0x11, 0x24, 0x9f, 0xae,
14 | 0xa5, 0x9f, 0x89, 0x5a, 0xfb, 0x6b, 0x38, 0xee, 0xed, 0xb7, 0x06, 0xf4,
15 | 0xb6, 0x5c, 0xff, 0x0b, 0x6b, 0xed, 0x37, 0xa6, 0xe9, 0x42, 0x4c, 0xf4,
16 | 0xc6, 0x7e, 0x5e, 0x62, 0x76, 0xb5, 0x85, 0xe4, 0x45, 0xc2, 0x51, 0x6d,
17 | 0x6d, 0x35, 0xe1, 0x4f, 0x37, 0x14, 0x5f, 0xf2, 0x6d, 0x0a, 0x2b, 0x30,
18 | 0x1b, 0x43, 0x3a, 0xcd, 0xb3, 0x19, 0x95, 0xef, 0xdd, 0x04, 0x34, 0x8e,
19 | 0x79, 0x08, 0x4a, 0x51, 0x22, 0x9b, 0x13, 0x3b, 0xa6, 0xbe, 0x0b, 0x02,
20 | 0x74, 0xcc, 0x67, 0x8a, 0x08, 0x4e, 0x02, 0x29, 0xd1, 0x1c, 0xdc, 0x80,
21 | 0x8b, 0x62, 0xc6, 0xc4, 0x34, 0xc2, 0x68, 0x21, 0xa2, 0xda, 0x0f, 0xc9,
22 | 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
23 | 0x00
24 | };
25 |
26 | ///
27 | /// Gets algorithm name.
28 | ///
29 | public override string Name
30 | {
31 | get { return "diffie-hellman-group1-sha1"; }
32 | }
33 |
34 | ///
35 | /// Gets the group prime.
36 | ///
37 | ///
38 | /// The group prime.
39 | ///
40 | public override BigInteger GroupPrime
41 | {
42 | get
43 | {
44 | return new BigInteger(SecondOkleyGroupReversed);
45 | }
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupExchangeSha1.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Abstractions;
2 |
3 | namespace Renci.SshNet.Security
4 | {
5 | ///
6 | /// Represents "diffie-hellman-group-exchange-sha1" algorithm implementation.
7 | ///
8 | internal class KeyExchangeDiffieHellmanGroupExchangeSha1 : KeyExchangeDiffieHellmanGroupExchangeShaBase
9 | {
10 | ///
11 | /// Gets algorithm name.
12 | ///
13 | public override string Name
14 | {
15 | get { return "diffie-hellman-group-exchange-sha1"; }
16 | }
17 |
18 | ///
19 | /// Gets the size, in bits, of the computed hash code.
20 | ///
21 | ///
22 | /// The size, in bits, of the computed hash code.
23 | ///
24 | protected override int HashSize
25 | {
26 | get { return 160; }
27 | }
28 |
29 | ///
30 | /// Hashes the specified data bytes.
31 | ///
32 | /// The hash data.
33 | ///
34 | /// Hashed bytes
35 | ///
36 | protected override byte[] Hash(byte[] hashData)
37 | {
38 | using (var sha1 = CryptoAbstraction.CreateSHA1())
39 | {
40 | return sha1.ComputeHash(hashData, 0, hashData.Length);
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupExchangeSha256.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Abstractions;
2 |
3 | namespace Renci.SshNet.Security
4 | {
5 | ///
6 | /// Represents "diffie-hellman-group-exchange-sha256" algorithm implementation.
7 | ///
8 | internal class KeyExchangeDiffieHellmanGroupExchangeSha256 : KeyExchangeDiffieHellmanGroupExchangeShaBase
9 | {
10 | ///
11 | /// Gets algorithm name.
12 | ///
13 | public override string Name
14 | {
15 | get { return "diffie-hellman-group-exchange-sha256"; }
16 | }
17 |
18 | ///
19 | /// Gets the size, in bits, of the computed hash code.
20 | ///
21 | ///
22 | /// The size, in bits, of the computed hash code.
23 | ///
24 | protected override int HashSize
25 | {
26 | get { return 256; }
27 | }
28 |
29 | ///
30 | /// Hashes the specified data bytes.
31 | ///
32 | /// Data to hash.
33 | ///
34 | /// Hashed bytes
35 | ///
36 | protected override byte[] Hash(byte[] hashBytes)
37 | {
38 | using (var sha256 = CryptoAbstraction.CreateSHA256())
39 | {
40 | return sha256.ComputeHash(hashBytes);
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupSha1.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Abstractions;
2 |
3 | namespace Renci.SshNet.Security
4 | {
5 | ///
6 | /// Represents "diffie-hellman-group1-sha1" algorithm implementation.
7 | ///
8 | internal abstract class KeyExchangeDiffieHellmanGroupSha1 : KeyExchangeDiffieHellmanGroupShaBase
9 | {
10 | ///
11 | /// Gets the size, in bits, of the computed hash code.
12 | ///
13 | ///
14 | /// The size, in bits, of the computed hash code.
15 | ///
16 | protected override int HashSize
17 | {
18 | get { return 160; }
19 | }
20 |
21 | ///
22 | /// Hashes the specified data bytes.
23 | ///
24 | /// The hash data.
25 | ///
26 | /// Hashed bytes
27 | ///
28 | protected override byte[] Hash(byte[] hashData)
29 | {
30 | using (var sha1 = CryptoAbstraction.CreateSHA1())
31 | {
32 | return sha1.ComputeHash(hashData, 0, hashData.Length);
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupSha256.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Abstractions;
2 |
3 | namespace Renci.SshNet.Security
4 | {
5 | ///
6 | /// Base class for "diffie-hellman" SHA-256 group algorithm implementations.
7 | ///
8 | internal abstract class KeyExchangeDiffieHellmanGroupSha256 : KeyExchangeDiffieHellmanGroupShaBase
9 | {
10 | ///
11 | /// Gets the size, in bits, of the computed hash code.
12 | ///
13 | ///
14 | /// The size, in bits, of the computed hash code.
15 | ///
16 | protected override int HashSize
17 | {
18 | get { return 256; }
19 | }
20 |
21 | ///
22 | /// Hashes the specified data bytes.
23 | ///
24 | /// The hash data.
25 | ///
26 | /// Hashed bytes
27 | ///
28 | protected override byte[] Hash(byte[] hashData)
29 | {
30 | using (var sha256 = CryptoAbstraction.CreateSHA256())
31 | {
32 | return sha256.ComputeHash(hashData);
33 | }
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/KeyExchangeDiffieHellmanGroupSha512.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Abstractions;
2 |
3 | namespace Renci.SshNet.Security
4 | {
5 | ///
6 | /// Base class for "diffie-hellman" SHA-512 group algorithm implementations.
7 | ///
8 | internal abstract class KeyExchangeDiffieHellmanGroupSha512 : KeyExchangeDiffieHellmanGroupShaBase
9 | {
10 | ///
11 | /// Gets the size, in bits, of the computed hash code.
12 | ///
13 | ///
14 | /// The size, in bits, of the computed hash code.
15 | ///
16 | protected override int HashSize
17 | {
18 | get { return 512; }
19 | }
20 |
21 | ///
22 | /// Hashes the specified data bytes.
23 | ///
24 | /// The hash data.
25 | ///
26 | /// Hashed bytes
27 | ///
28 | protected override byte[] Hash(byte[] hashData)
29 | {
30 | using (var sha512 = CryptoAbstraction.CreateSHA512())
31 | {
32 | return sha512.ComputeHash(hashData);
33 | }
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/KeyExchangeECDH256.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Abstractions;
2 | using Renci.SshNet.Security.Org.BouncyCastle.Asn1.Sec;
3 | using Renci.SshNet.Security.Org.BouncyCastle.Asn1.X9;
4 |
5 | namespace Renci.SshNet.Security
6 | {
7 | internal class KeyExchangeECDH256 : KeyExchangeECDH
8 | {
9 | ///
10 | /// Gets algorithm name.
11 | ///
12 | public override string Name
13 | {
14 | get { return "ecdh-sha2-nistp256"; }
15 | }
16 |
17 | ///
18 | /// Gets Curve Parameter.
19 | ///
20 | protected override X9ECParameters CurveParameter
21 | {
22 | get
23 | {
24 | return SecNamedCurves.GetByName("P-256");
25 | }
26 | }
27 |
28 | ///
29 | /// Gets the size, in bits, of the computed hash code.
30 | ///
31 | ///
32 | /// The size, in bits, of the computed hash code.
33 | ///
34 | protected override int HashSize
35 | {
36 | get { return 256; }
37 | }
38 |
39 | ///
40 | /// Hashes the specified data bytes.
41 | ///
42 | /// The hash data.
43 | ///
44 | /// Hashed bytes
45 | ///
46 | protected override byte[] Hash(byte[] hashData)
47 | {
48 | using (var sha256 = CryptoAbstraction.CreateSHA256())
49 | {
50 | return sha256.ComputeHash(hashData, 0, hashData.Length);
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/KeyExchangeECDH384.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Abstractions;
2 | using Renci.SshNet.Security.Org.BouncyCastle.Asn1.Sec;
3 | using Renci.SshNet.Security.Org.BouncyCastle.Asn1.X9;
4 |
5 | namespace Renci.SshNet.Security
6 | {
7 | internal class KeyExchangeECDH384 : KeyExchangeECDH
8 | {
9 | ///
10 | /// Gets algorithm name.
11 | ///
12 | public override string Name
13 | {
14 | get { return "ecdh-sha2-nistp384"; }
15 | }
16 |
17 | ///
18 | /// Gets Curve Parameter.
19 | ///
20 | protected override X9ECParameters CurveParameter
21 | {
22 | get
23 | {
24 | return SecNamedCurves.GetByName("P-384");
25 | }
26 | }
27 |
28 | ///
29 | /// Gets the size, in bits, of the computed hash code.
30 | ///
31 | ///
32 | /// The size, in bits, of the computed hash code.
33 | ///
34 | protected override int HashSize
35 | {
36 | get { return 384; }
37 | }
38 |
39 | ///
40 | /// Hashes the specified data bytes.
41 | ///
42 | /// The hash data.
43 | ///
44 | /// Hashed bytes
45 | ///
46 | protected override byte[] Hash(byte[] hashData)
47 | {
48 | using (var sha384 = CryptoAbstraction.CreateSHA384())
49 | {
50 | return sha384.ComputeHash(hashData, 0, hashData.Length);
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Security/KeyExchangeECDH521.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Abstractions;
2 | using Renci.SshNet.Security.Org.BouncyCastle.Asn1.Sec;
3 | using Renci.SshNet.Security.Org.BouncyCastle.Asn1.X9;
4 |
5 | namespace Renci.SshNet.Security
6 | {
7 | internal class KeyExchangeECDH521 : KeyExchangeECDH
8 | {
9 | ///
10 | /// Gets algorithm name.
11 | ///
12 | public override string Name
13 | {
14 | get { return "ecdh-sha2-nistp521"; }
15 | }
16 |
17 | ///
18 | /// Gets Curve Parameter.
19 | ///
20 | protected override X9ECParameters CurveParameter
21 | {
22 | get
23 | {
24 | return SecNamedCurves.GetByName("P-521");
25 | }
26 | }
27 |
28 | ///
29 | /// Gets the size, in bits, of the computed hash code.
30 | ///
31 | ///
32 | /// The size, in bits, of the computed hash code.
33 | ///
34 | protected override int HashSize
35 | {
36 | get { return 512; }
37 | }
38 |
39 | ///
40 | /// Hashes the specified data bytes.
41 | ///
42 | /// The hash data.
43 | ///
44 | /// Hashed bytes
45 | ///
46 | protected override byte[] Hash(byte[] hashData)
47 | {
48 | using (var sha512 = CryptoAbstraction.CreateSHA512())
49 | {
50 | return sha512.ComputeHash(hashData, 0, hashData.Length);
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/ServiceFactory.NET.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.NetConf;
2 |
3 | namespace Renci.SshNet
4 | {
5 | internal partial class ServiceFactory
6 | {
7 | ///
8 | /// Creates a new in a given
9 | /// and with the specified operation timeout.
10 | ///
11 | /// The to create the in.
12 | /// The number of milliseconds to wait for an operation to complete, or -1 to wait indefinitely.
13 | ///
14 | /// An .
15 | ///
16 | public INetConfSession CreateNetConfSession(ISession session, int operationTimeout)
17 | {
18 | return new NetConfSession(session, operationTimeout);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Flags.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Sftp
4 | {
5 | [Flags]
6 | internal enum Flags
7 | {
8 | None = 0x00000000,
9 | ///
10 | /// SSH_FXF_READ
11 | ///
12 | Read = 0x00000001,
13 | ///
14 | /// SSH_FXF_WRITE
15 | ///
16 | Write = 0x00000002,
17 | ///
18 | /// SSH_FXF_APPEND
19 | ///
20 | Append = 0x00000004,
21 | ///
22 | /// SSH_FXF_CREAT
23 | ///
24 | CreateNewOrOpen = 0x00000008,
25 | ///
26 | /// SSH_FXF_TRUNC
27 | ///
28 | Truncate = 0x00000010,
29 | ///
30 | /// SSH_FXF_EXCL
31 | ///
32 | CreateNew = 0x00000028
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/ISftpFileReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Renci.SshNet.Sftp
4 | {
5 | internal interface ISftpFileReader : IDisposable
6 | {
7 | byte[] Read();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/ISftpResponseFactory.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace Renci.SshNet.Sftp
4 | {
5 | internal interface ISftpResponseFactory
6 | {
7 | SftpMessage Create(uint protocolVersion, byte messageType, Encoding encoding);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Requests/ExtendedRequests/FStatVfsRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Renci.SshNet.Sftp.Responses;
3 |
4 | namespace Renci.SshNet.Sftp.Requests
5 | {
6 | internal class FStatVfsRequest : SftpExtendedRequest
7 | {
8 | private readonly Action _extendedReplyAction;
9 |
10 | public byte[] Handle { get; private set; }
11 |
12 | ///
13 | /// Gets the size of the message in bytes.
14 | ///
15 | ///
16 | /// The size of the messages in bytes.
17 | ///
18 | protected override int BufferCapacity
19 | {
20 | get
21 | {
22 | var capacity = base.BufferCapacity;
23 | capacity += 4; // Handle length
24 | capacity += Handle.Length; // Handle
25 | return capacity;
26 | }
27 | }
28 |
29 | public FStatVfsRequest(uint protocolVersion, uint requestId, byte[] handle, Action extendedAction, Action statusAction)
30 | : base(protocolVersion, requestId, statusAction, "fstatvfs@openssh.com")
31 | {
32 | Handle = handle;
33 |
34 | _extendedReplyAction = extendedAction;
35 | }
36 |
37 | protected override void SaveData()
38 | {
39 | base.SaveData();
40 | WriteBinaryString(Handle);
41 | }
42 |
43 | public override void Complete(SftpResponse response)
44 | {
45 | var extendedReplyResponse = response as SftpExtendedReplyResponse;
46 | if (extendedReplyResponse != null)
47 | {
48 | _extendedReplyAction(extendedReplyResponse);
49 | }
50 | else
51 | {
52 | base.Complete(response);
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Requests/ExtendedRequests/HardLinkRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Renci.SshNet.Sftp.Responses;
3 |
4 | namespace Renci.SshNet.Sftp.Requests
5 | {
6 | internal class HardLinkRequest : SftpExtendedRequest
7 | {
8 | private byte[] _oldPath;
9 | private byte[] _newPath;
10 |
11 | public string OldPath
12 | {
13 | get { return Utf8.GetString(_oldPath, 0, _oldPath.Length); }
14 | private set { _oldPath = Utf8.GetBytes(value); }
15 | }
16 |
17 | public string NewPath
18 | {
19 | get { return Utf8.GetString(_newPath, 0, _newPath.Length); }
20 | private set { _newPath = Utf8.GetBytes(value); }
21 | }
22 |
23 | ///
24 | /// Gets the size of the message in bytes.
25 | ///
26 | ///
27 | /// The size of the messages in bytes.
28 | ///
29 | protected override int BufferCapacity
30 | {
31 | get
32 | {
33 | var capacity = base.BufferCapacity;
34 | capacity += 4; // OldPath length
35 | capacity += _oldPath.Length; // OldPath
36 | capacity += 4; // NewPath length
37 | capacity += _newPath.Length; // NewPath
38 | return capacity;
39 | }
40 | }
41 |
42 | public HardLinkRequest(uint protocolVersion, uint requestId, string oldPath, string newPath, Action statusAction)
43 | : base(protocolVersion, requestId, statusAction, "hardlink@openssh.com")
44 | {
45 | OldPath = oldPath;
46 | NewPath = newPath;
47 | }
48 |
49 | protected override void SaveData()
50 | {
51 | base.SaveData();
52 | WriteBinaryString(_oldPath);
53 | WriteBinaryString(_newPath);
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Requests/SftpCloseRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Renci.SshNet.Sftp.Responses;
3 |
4 | namespace Renci.SshNet.Sftp.Requests
5 | {
6 | internal class SftpCloseRequest : SftpRequest
7 | {
8 | public override SftpMessageTypes SftpMessageType
9 | {
10 | get { return SftpMessageTypes.Close; }
11 | }
12 |
13 | public byte[] Handle { get; private set; }
14 |
15 | ///
16 | /// Gets the size of the message in bytes.
17 | ///
18 | ///
19 | /// The size of the messages in bytes.
20 | ///
21 | protected override int BufferCapacity
22 | {
23 | get
24 | {
25 | var capacity = base.BufferCapacity;
26 | capacity += 4; // Handle length
27 | capacity += Handle.Length; // Handle
28 | return capacity;
29 | }
30 | }
31 |
32 | public SftpCloseRequest(uint protocolVersion, uint requestId, byte[] handle, Action statusAction)
33 | : base(protocolVersion, requestId, statusAction)
34 | {
35 | Handle = handle;
36 | }
37 |
38 | protected override void LoadData()
39 | {
40 | base.LoadData();
41 | Handle = ReadBinary();
42 | }
43 |
44 | protected override void SaveData()
45 | {
46 | base.SaveData();
47 | WriteBinaryString(Handle);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Requests/SftpExtendedRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Renci.SshNet.Sftp.Responses;
3 |
4 | namespace Renci.SshNet.Sftp.Requests
5 | {
6 | internal abstract class SftpExtendedRequest : SftpRequest
7 | {
8 | private byte[] _nameBytes;
9 | private string _name;
10 |
11 | public override SftpMessageTypes SftpMessageType
12 | {
13 | get { return SftpMessageTypes.Extended; }
14 | }
15 |
16 | public string Name
17 | {
18 | get { return _name; }
19 | private set
20 | {
21 | _name = value;
22 | _nameBytes = Utf8.GetBytes(value);
23 | }
24 | }
25 |
26 | ///
27 | /// Gets the size of the message in bytes.
28 | ///
29 | ///
30 | /// The size of the messages in bytes.
31 | ///
32 | protected override int BufferCapacity
33 | {
34 | get
35 | {
36 | var capacity = base.BufferCapacity;
37 | capacity += 4; // Name length
38 | capacity += _nameBytes.Length; // Name
39 | return capacity;
40 | }
41 | }
42 |
43 | protected SftpExtendedRequest(uint protocolVersion, uint requestId, Action statusAction, string name)
44 | : base(protocolVersion, requestId, statusAction)
45 | {
46 | Name = name;
47 | }
48 |
49 | protected override void SaveData()
50 | {
51 | base.SaveData();
52 | WriteBinaryString(_nameBytes);
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Requests/SftpInitRequest.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Sftp.Requests
2 | {
3 | internal class SftpInitRequest : SftpMessage
4 | {
5 | public override SftpMessageTypes SftpMessageType
6 | {
7 | get { return SftpMessageTypes.Init; }
8 | }
9 |
10 | public uint Version { get; private set; }
11 |
12 | ///
13 | /// Gets the size of the message in bytes.
14 | ///
15 | ///
16 | /// The size of the messages in bytes.
17 | ///
18 | protected override int BufferCapacity
19 | {
20 | get
21 | {
22 | var capacity = base.BufferCapacity;
23 | capacity += 4; // Version
24 | return capacity;
25 | }
26 | }
27 |
28 | public SftpInitRequest(uint version)
29 | {
30 | Version = version;
31 | }
32 |
33 | protected override void LoadData()
34 | {
35 | base.LoadData();
36 | Version = ReadUInt32();
37 | }
38 |
39 | protected override void SaveData()
40 | {
41 | base.SaveData();
42 | Write(Version);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Requests/SftpRemoveRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using Renci.SshNet.Sftp.Responses;
4 |
5 | namespace Renci.SshNet.Sftp.Requests
6 | {
7 | internal class SftpRemoveRequest : SftpRequest
8 | {
9 | private byte[] _fileName;
10 |
11 | public override SftpMessageTypes SftpMessageType
12 | {
13 | get { return SftpMessageTypes.Remove; }
14 | }
15 |
16 | public string Filename
17 | {
18 | get { return Encoding.GetString(_fileName, 0, _fileName.Length); }
19 | private set { _fileName = Encoding.GetBytes(value); }
20 | }
21 |
22 | public Encoding Encoding { get; private set; }
23 |
24 | ///
25 | /// Gets the size of the message in bytes.
26 | ///
27 | ///
28 | /// The size of the messages in bytes.
29 | ///
30 | protected override int BufferCapacity
31 | {
32 | get
33 | {
34 | var capacity = base.BufferCapacity;
35 | capacity += 4; // FileName length
36 | capacity += _fileName.Length; // FileName
37 | return capacity;
38 | }
39 | }
40 |
41 | public SftpRemoveRequest(uint protocolVersion, uint requestId, string filename, Encoding encoding, Action statusAction)
42 | : base(protocolVersion, requestId, statusAction)
43 | {
44 | Encoding = encoding;
45 | Filename = filename;
46 | }
47 |
48 | protected override void LoadData()
49 | {
50 | base.LoadData();
51 | _fileName = ReadBinary();
52 | }
53 |
54 | protected override void SaveData()
55 | {
56 | base.SaveData();
57 | WriteBinaryString(_fileName);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Requests/SftpRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Renci.SshNet.Sftp.Responses;
3 |
4 | namespace Renci.SshNet.Sftp.Requests
5 | {
6 | internal abstract class SftpRequest : SftpMessage
7 | {
8 | private readonly Action _statusAction;
9 |
10 | public uint RequestId { get; private set; }
11 |
12 | public uint ProtocolVersion { get; private set; }
13 |
14 | ///
15 | /// Gets the size of the message in bytes.
16 | ///
17 | ///
18 | /// The size of the messages in bytes.
19 | ///
20 | protected override int BufferCapacity
21 | {
22 | get
23 | {
24 | var capacity = base.BufferCapacity;
25 | capacity += 4; // RequestId
26 | return capacity;
27 | }
28 | }
29 |
30 | protected SftpRequest(uint protocolVersion, uint requestId, Action statusAction)
31 | {
32 | RequestId = requestId;
33 | ProtocolVersion = protocolVersion;
34 | _statusAction = statusAction;
35 | }
36 |
37 | public virtual void Complete(SftpResponse response)
38 | {
39 | var statusResponse = response as SftpStatusResponse;
40 | if (statusResponse != null)
41 | {
42 | _statusAction(statusResponse);
43 | }
44 | else
45 | {
46 | throw new InvalidOperationException(string.Format("Response of type '{0}' is not expected.", response.GetType().Name));
47 | }
48 | }
49 |
50 | protected override void LoadData()
51 | {
52 | throw new InvalidOperationException("Request cannot be saved.");
53 | }
54 |
55 | protected override void SaveData()
56 | {
57 | base.SaveData();
58 | Write(RequestId);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Requests/SftpRmDirRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using Renci.SshNet.Sftp.Responses;
4 |
5 | namespace Renci.SshNet.Sftp.Requests
6 | {
7 | internal class SftpRmDirRequest : SftpRequest
8 | {
9 | private byte[] _path;
10 |
11 | public override SftpMessageTypes SftpMessageType
12 | {
13 | get { return SftpMessageTypes.RmDir; }
14 | }
15 |
16 | public string Path
17 | {
18 | get { return Encoding.GetString(_path, 0, _path.Length); }
19 | private set { _path = Encoding.GetBytes(value); }
20 | }
21 |
22 | public Encoding Encoding { get; private set; }
23 |
24 | ///
25 | /// Gets the size of the message in bytes.
26 | ///
27 | ///
28 | /// The size of the messages in bytes.
29 | ///
30 | protected override int BufferCapacity
31 | {
32 | get
33 | {
34 | var capacity = base.BufferCapacity;
35 | capacity += 4; // Path length
36 | capacity += _path.Length; // Path
37 | return capacity;
38 | }
39 | }
40 |
41 | public SftpRmDirRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action statusAction)
42 | : base(protocolVersion, requestId, statusAction)
43 | {
44 | Encoding = encoding;
45 | Path = path;
46 | }
47 |
48 | protected override void LoadData()
49 | {
50 | base.LoadData();
51 | _path = ReadBinary();
52 | }
53 |
54 | protected override void SaveData()
55 | {
56 | base.SaveData();
57 | WriteBinaryString(_path);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Requests/SftpUnblockRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Renci.SshNet.Sftp.Responses;
3 |
4 | namespace Renci.SshNet.Sftp.Requests
5 | {
6 | internal class SftpUnblockRequest : SftpRequest
7 | {
8 | public override SftpMessageTypes SftpMessageType
9 | {
10 | get { return SftpMessageTypes.Unblock; }
11 | }
12 |
13 | public byte[] Handle { get; private set; }
14 |
15 | public ulong Offset { get; private set; }
16 |
17 | public ulong Length { get; private set; }
18 |
19 | ///
20 | /// Gets the size of the message in bytes.
21 | ///
22 | ///
23 | /// The size of the messages in bytes.
24 | ///
25 | protected override int BufferCapacity
26 | {
27 | get
28 | {
29 | var capacity = base.BufferCapacity;
30 | capacity += 4; // Handle length
31 | capacity += Handle.Length; // Handle
32 | capacity += 8; // Offset
33 | capacity += 8; // Length
34 | return capacity;
35 | }
36 | }
37 |
38 | public SftpUnblockRequest(uint protocolVersion, uint requestId, byte[] handle, UInt64 offset, UInt64 length, Action statusAction)
39 | : base(protocolVersion, requestId, statusAction)
40 | {
41 | Handle = handle;
42 | Offset = offset;
43 | Length = length;
44 | }
45 |
46 | protected override void LoadData()
47 | {
48 | base.LoadData();
49 | Handle = ReadBinary();
50 | Offset = ReadUInt64();
51 | Length = ReadUInt64();
52 | }
53 |
54 | protected override void SaveData()
55 | {
56 | base.SaveData();
57 | WriteBinaryString(Handle);
58 | Write(Offset);
59 | Write(Length);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Responses/ExtendedReplies/ExtendedReplyInfo.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Common;
2 |
3 | namespace Renci.SshNet.Sftp.Responses
4 | {
5 | internal abstract class ExtendedReplyInfo
6 | {
7 | public abstract void LoadData(SshDataStream stream);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Responses/ExtendedReplies/StatVfsReplyInfo.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Common;
2 |
3 | namespace Renci.SshNet.Sftp.Responses
4 | {
5 | internal class StatVfsReplyInfo : ExtendedReplyInfo
6 | {
7 | public SftpFileSytemInformation Information { get; private set; }
8 |
9 | public override void LoadData(SshDataStream stream)
10 | {
11 | Information = new SftpFileSytemInformation(stream.ReadUInt64(), // FileSystemBlockSize
12 | stream.ReadUInt64(), // BlockSize
13 | stream.ReadUInt64(), // TotalBlocks
14 | stream.ReadUInt64(), // FreeBlocks
15 | stream.ReadUInt64(), // AvailableBlocks
16 | stream.ReadUInt64(), // TotalNodes
17 | stream.ReadUInt64(), // FreeNodes
18 | stream.ReadUInt64(), // AvailableNodes
19 | stream.ReadUInt64(), // Sid
20 | stream.ReadUInt64(), // Flags
21 | stream.ReadUInt64() // MaxNameLenght
22 | );
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Responses/SftpAttrsResponse.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Sftp.Responses
2 | {
3 | internal class SftpAttrsResponse : SftpResponse
4 | {
5 | public override SftpMessageTypes SftpMessageType
6 | {
7 | get { return SftpMessageTypes.Attrs; }
8 | }
9 |
10 | public SftpFileAttributes Attributes { get; private set; }
11 |
12 | public SftpAttrsResponse(uint protocolVersion)
13 | : base(protocolVersion)
14 | {
15 | }
16 |
17 | protected override void LoadData()
18 | {
19 | base.LoadData();
20 | Attributes = ReadAttributes();
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Responses/SftpDataResponse.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Sftp.Responses
2 | {
3 | internal class SftpDataResponse : SftpResponse
4 | {
5 | public override SftpMessageTypes SftpMessageType
6 | {
7 | get { return SftpMessageTypes.Data; }
8 | }
9 |
10 | public byte[] Data { get; set; }
11 |
12 | public SftpDataResponse(uint protocolVersion)
13 | : base(protocolVersion)
14 | {
15 | }
16 |
17 | protected override void LoadData()
18 | {
19 | base.LoadData();
20 |
21 | Data = ReadBinary();
22 | }
23 |
24 | protected override void SaveData()
25 | {
26 | base.SaveData();
27 |
28 | WriteBinary(Data, 0, Data.Length);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Responses/SftpExtendedReplyResponse.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Sftp.Responses
2 | {
3 | internal class SftpExtendedReplyResponse : SftpResponse
4 | {
5 | public override SftpMessageTypes SftpMessageType
6 | {
7 | get { return SftpMessageTypes.ExtendedReply; }
8 | }
9 |
10 | public SftpExtendedReplyResponse(uint protocolVersion)
11 | : base(protocolVersion)
12 | {
13 | }
14 |
15 | public T GetReply() where T : ExtendedReplyInfo, new()
16 | {
17 | var result = new T();
18 | result.LoadData(DataStream);
19 | return result;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Responses/SftpHandleResponse.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Sftp.Responses
2 | {
3 | internal class SftpHandleResponse : SftpResponse
4 | {
5 | public override SftpMessageTypes SftpMessageType
6 | {
7 | get { return SftpMessageTypes.Handle; }
8 | }
9 |
10 | public byte[] Handle { get; set; }
11 |
12 | public SftpHandleResponse(uint protocolVersion)
13 | : base(protocolVersion)
14 | {
15 | }
16 |
17 | protected override void LoadData()
18 | {
19 | base.LoadData();
20 |
21 | Handle = ReadBinary();
22 | }
23 |
24 | protected override void SaveData()
25 | {
26 | base.SaveData();
27 |
28 | WriteBinary(Handle, 0, Handle.Length);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Responses/SftpResponse.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Sftp.Responses
2 | {
3 | internal abstract class SftpResponse : SftpMessage
4 | {
5 | public uint ResponseId { get; set; }
6 |
7 | public uint ProtocolVersion { get; private set; }
8 |
9 | protected SftpResponse(uint protocolVersion)
10 | {
11 | ProtocolVersion = protocolVersion;
12 | }
13 |
14 | protected override void LoadData()
15 | {
16 | base.LoadData();
17 |
18 | ResponseId = ReadUInt32();
19 | }
20 |
21 | protected override void SaveData()
22 | {
23 | base.SaveData();
24 |
25 | Write(ResponseId);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Responses/SftpStatusResponse.cs:
--------------------------------------------------------------------------------
1 | namespace Renci.SshNet.Sftp.Responses
2 | {
3 | internal class SftpStatusResponse : SftpResponse
4 | {
5 | public override SftpMessageTypes SftpMessageType
6 | {
7 | get { return SftpMessageTypes.Status; }
8 | }
9 |
10 | public SftpStatusResponse(uint protocolVersion)
11 | : base(protocolVersion)
12 | {
13 | }
14 |
15 | public StatusCodes StatusCode { get; private set; }
16 |
17 | public string ErrorMessage { get; private set; }
18 |
19 | public string Language { get; private set; }
20 |
21 | protected override void LoadData()
22 | {
23 | base.LoadData();
24 |
25 | StatusCode = (StatusCodes) ReadUInt32();
26 |
27 | if (ProtocolVersion < 3)
28 | {
29 | return;
30 | }
31 |
32 | if (!IsEndOfData)
33 | {
34 | // the SSH File Transfer Protocol specification states that the error message is UTF-8
35 | ErrorMessage = ReadString(Utf8);
36 |
37 | // the language of the error message; RFC 1766 states that the language code may be
38 | // expressed as US-ASCII
39 | Language = ReadString(Ascii);
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/Responses/SftpVersionResponse.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Renci.SshNet.Sftp.Responses
4 | {
5 | internal class SftpVersionResponse : SftpMessage
6 | {
7 | public override SftpMessageTypes SftpMessageType
8 | {
9 | get { return SftpMessageTypes.Version; }
10 | }
11 |
12 | public uint Version { get; set; }
13 |
14 | public IDictionary Extentions { get; set; }
15 |
16 | protected override void LoadData()
17 | {
18 | base.LoadData();
19 | Version = ReadUInt32();
20 | Extentions = ReadExtensionPair();
21 | }
22 |
23 | protected override void SaveData()
24 | {
25 | base.SaveData();
26 |
27 | Write(Version);
28 | if (Extentions != null)
29 | Write(Extentions);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/SFtpStatAsyncResult.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Common;
2 | using System;
3 |
4 | namespace Renci.SshNet.Sftp
5 | {
6 | internal class SFtpStatAsyncResult : AsyncResult
7 | {
8 | public SFtpStatAsyncResult(AsyncCallback asyncCallback, object state) : base(asyncCallback, state)
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/SftpCloseAsyncResult.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Common;
2 | using System;
3 |
4 | namespace Renci.SshNet.Sftp
5 | {
6 | internal class SftpCloseAsyncResult : AsyncResult
7 | {
8 | public SftpCloseAsyncResult(AsyncCallback asyncCallback, object state) : base(asyncCallback, state)
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/SftpDownloadAsyncResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Renci.SshNet.Common;
3 |
4 | namespace Renci.SshNet.Sftp
5 | {
6 | ///
7 | /// Encapsulates the results of an asynchronous download operation.
8 | ///
9 | public class SftpDownloadAsyncResult : AsyncResult
10 | {
11 | ///
12 | /// Gets or sets a value indicating whether to cancel asynchronous download operation.
13 | ///
14 | ///
15 | /// true if download operation to be canceled; otherwise, false.
16 | ///
17 | ///
18 | /// Download operation will be canceled after finishing uploading current buffer.
19 | ///
20 | public bool IsDownloadCanceled { get; set; }
21 |
22 | ///
23 | /// Gets the number of downloaded bytes.
24 | ///
25 | public ulong DownloadedBytes { get; private set; }
26 |
27 | ///
28 | /// Initializes a new instance of the class.
29 | ///
30 | /// The async callback.
31 | /// The state.
32 | public SftpDownloadAsyncResult(AsyncCallback asyncCallback, object state)
33 | : base(asyncCallback, state)
34 | {
35 | }
36 |
37 | ///
38 | /// Updates asynchronous operation status information.
39 | ///
40 | /// Number of downloaded bytes.
41 | internal void Update(ulong downloadedBytes)
42 | {
43 | DownloadedBytes = downloadedBytes;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/SftpListDirectoryAsyncResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Renci.SshNet.Common;
4 |
5 | namespace Renci.SshNet.Sftp
6 | {
7 | ///
8 | /// Encapsulates the results of an asynchronous directory list operation.
9 | ///
10 | public class SftpListDirectoryAsyncResult : AsyncResult>
11 | {
12 | ///
13 | /// Gets the number of files read so far.
14 | ///
15 | public int FilesRead { get; private set; }
16 |
17 | ///
18 | /// Initializes a new instance of the class.
19 | ///
20 | /// The async callback.
21 | /// The state.
22 | public SftpListDirectoryAsyncResult(AsyncCallback asyncCallback, Object state)
23 | : base(asyncCallback, state)
24 | {
25 |
26 | }
27 |
28 | ///
29 | /// Updates asynchronous operation status information.
30 | ///
31 | /// The files read.
32 | internal void Update(int filesRead)
33 | {
34 | FilesRead = filesRead;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/SftpOpenAsyncResult.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Common;
2 | using System;
3 |
4 | namespace Renci.SshNet.Sftp
5 | {
6 | internal class SftpOpenAsyncResult : AsyncResult
7 | {
8 | public SftpOpenAsyncResult(AsyncCallback asyncCallback, object state) : base(asyncCallback, state)
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/SftpReadAsyncResult.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Common;
2 | using System;
3 |
4 | namespace Renci.SshNet.Sftp
5 | {
6 | internal class SftpReadAsyncResult : AsyncResult
7 | {
8 | public SftpReadAsyncResult(AsyncCallback asyncCallback, object state) : base(asyncCallback, state)
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/SftpRealPathAsyncResult.cs:
--------------------------------------------------------------------------------
1 | using Renci.SshNet.Common;
2 | using System;
3 |
4 | namespace Renci.SshNet.Sftp
5 | {
6 | internal class SftpRealPathAsyncResult : AsyncResult
7 | {
8 | public SftpRealPathAsyncResult(AsyncCallback asyncCallback, object state) : base(asyncCallback, state)
9 | {
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/SftpResponseFactory.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Text;
3 | using Renci.SshNet.Sftp.Responses;
4 | using System.Globalization;
5 |
6 | namespace Renci.SshNet.Sftp
7 | {
8 | internal sealed class SftpResponseFactory : ISftpResponseFactory
9 | {
10 | public SftpMessage Create(uint protocolVersion, byte messageType, Encoding encoding)
11 | {
12 | var sftpMessageType = (SftpMessageTypes) messageType;
13 |
14 | SftpMessage message;
15 |
16 | switch (sftpMessageType)
17 | {
18 | case SftpMessageTypes.Version:
19 | message = new SftpVersionResponse();
20 | break;
21 | case SftpMessageTypes.Status:
22 | message = new SftpStatusResponse(protocolVersion);
23 | break;
24 | case SftpMessageTypes.Data:
25 | message = new SftpDataResponse(protocolVersion);
26 | break;
27 | case SftpMessageTypes.Handle:
28 | message = new SftpHandleResponse(protocolVersion);
29 | break;
30 | case SftpMessageTypes.Name:
31 | message = new SftpNameResponse(protocolVersion, encoding);
32 | break;
33 | case SftpMessageTypes.Attrs:
34 | message = new SftpAttrsResponse(protocolVersion);
35 | break;
36 | case SftpMessageTypes.ExtendedReply:
37 | message = new SftpExtendedReplyResponse(protocolVersion);
38 | break;
39 | default:
40 | throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Message type '{0}' is not supported.", sftpMessageType));
41 | }
42 |
43 | return message;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/SftpSynchronizeDirectoriesAsyncResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Renci.SshNet.Common;
4 | using System.IO;
5 |
6 | namespace Renci.SshNet.Sftp
7 | {
8 | ///
9 | /// Encapsulates the results of an asynchronous directory synchronization operation.
10 | ///
11 | public class SftpSynchronizeDirectoriesAsyncResult : AsyncResult>
12 | {
13 | ///
14 | /// Gets the number of files read so far.
15 | ///
16 | public int FilesRead { get; private set; }
17 |
18 | ///
19 | /// Initializes a new instance of the class.
20 | ///
21 | /// The async callback.
22 | /// The state.
23 | public SftpSynchronizeDirectoriesAsyncResult(AsyncCallback asyncCallback, Object state)
24 | : base(asyncCallback, state)
25 | {
26 | }
27 |
28 | ///
29 | /// Updates asynchronous operation status information.
30 | ///
31 | /// The files read.
32 | internal void Update(int filesRead)
33 | {
34 | FilesRead = filesRead;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sshiva/Renci.SshNet/Sftp/SftpUploadAsyncResult.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Renci.SshNet.Common;
3 |
4 | namespace Renci.SshNet.Sftp
5 | {
6 | ///
7 | /// Encapsulates the results of an asynchronous upload operation.
8 | ///
9 | public class SftpUploadAsyncResult : AsyncResult
10 | {
11 | ///
12 | /// Gets or sets a value indicating whether to cancel asynchronous upload operation
13 | ///
14 | ///
15 | /// true if upload operation to be canceled; otherwise, false.
16 | ///
17 | ///
18 | /// Upload operation will be canceled after finishing uploading current buffer.
19 | ///
20 | public bool IsUploadCanceled { get; set; }
21 |
22 | ///
23 | /// Gets the number of uploaded bytes.
24 | ///
25 | public ulong UploadedBytes { get; private set; }
26 |
27 | ///
28 | /// Initializes a new instance of the class.
29 | ///
30 | /// The async callback.
31 | /// The state.
32 | public SftpUploadAsyncResult(AsyncCallback asyncCallback, Object state)
33 | : base(asyncCallback, state)
34 | {
35 | }
36 |
37 | ///
38 | /// Updates asynchronous operation status information.
39 | ///
40 | /// Number of uploaded bytes.
41 | internal void Update(ulong uploadedBytes)
42 | {
43 | UploadedBytes = uploadedBytes;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/sshiva/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/sshiva/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------