Class KeyExchange
- Namespace
- Renci.SshNet.Security
- Assembly
- Renci.SshNet.dll
Represents base class for different key exchange algorithm implementations.
public abstract class KeyExchange : Algorithm, IKeyExchange, IDisposable
Inheritance
Implements
Inherited Members
Properties
ExchangeHash
Gets the exchange hash.
public byte[] ExchangeHash { get; }
Property Value
- byte[]
Session
Gets the session.
protected Session Session { get; }
Property Value
SharedKey
Gets or sets key exchange shared key.
public byte[] SharedKey { get; protected set; }
Property Value
- byte[]
Methods
CalculateHash()
Calculates key exchange hash value.
protected abstract byte[] CalculateHash()
Returns
- byte[]
-
Key exchange hash.
CanTrustHostKey(KeyHostAlgorithm)
Determines whether the specified host key can be trusted.
protected bool CanTrustHostKey(KeyHostAlgorithm host)
Parameters
host
KeyHostAlgorithm-
The host algorithm.
Returns
CreateClientCipher(out bool)
Creates the client side cipher to use.
public Cipher CreateClientCipher(out bool isAead)
Parameters
Returns
- Cipher
-
Client cipher.
CreateClientHash(out bool)
Creates the client side hash algorithm to use.
public HashAlgorithm CreateClientHash(out bool isEncryptThenMAC)
Parameters
Returns
- HashAlgorithm
-
The client-side hash algorithm.
CreateCompressor()
Creates the compression algorithm to use to deflate data.
public Compressor CreateCompressor()
Returns
- Compressor
-
The compression method.
CreateDecompressor()
Creates the compression algorithm to use to inflate data.
public Compressor CreateDecompressor()
Returns
- Compressor
-
The decompression method.
CreateServerCipher(out bool)
Creates the server side cipher to use.
public Cipher CreateServerCipher(out bool isAead)
Parameters
Returns
- Cipher
-
Server cipher.
CreateServerHash(out bool)
Creates the server side hash algorithm to use.
public HashAlgorithm CreateServerHash(out bool isEncryptThenMAC)
Parameters
Returns
- HashAlgorithm
-
The server-side hash algorithm.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool-
true to release both managed and unmanaged resources; false to release only unmanaged resources.
Finish()
Finishes key exchange algorithm.
public virtual void Finish()
Hash(byte[])
Hashes the specified data bytes.
protected abstract byte[] Hash(byte[] hashData)
Parameters
hashData
byte[]-
The hash data.
Returns
- byte[]
-
The hash of the data.
SendMessage(Message)
Sends SSH message to the server.
protected void SendMessage(Message message)
Parameters
message
Message-
The message.
Start(Session, KeyExchangeInitMessage, bool)
Starts the key exchange algorithm.
public virtual void Start(Session session, KeyExchangeInitMessage message, bool sendClientInitMessage)
Parameters
session
Session-
The session.
message
KeyExchangeInitMessage-
The key exchange init message received from the server.
sendClientInitMessage
bool-
Whether to send a key exchange init message in response.
ValidateExchangeHash()
Validates the exchange hash.
protected abstract bool ValidateExchangeHash()
Returns
- bool
-
true if exchange hash is valid; otherwise false.
HostKeyReceived
Occurs when host key received.
public event EventHandler<HostKeyEventArgs> HostKeyReceived