Class KeyExchange
Represents base class for different key exchange algorithm implementations.
public abstract class KeyExchange : Algorithm, IKeyExchange, IDisposable
- Inheritance
-
KeyExchange
- Implements
- Inherited Members
Constructors
KeyExchange()
protected KeyExchange()
Properties
ExchangeHash
Gets the exchange hash.
public byte[] ExchangeHash { get; }
Property Value
- byte[]
The exchange hash.
Session
Gets the session.
protected Session Session { get; }
Property Value
- Session
The session.
SharedKey
Gets or sets key exchange shared key.
public byte[] SharedKey { get; protected set; }
Property Value
- byte[]
The shared key.
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
KeyHostAlgorithmThe 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
booltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
~KeyExchange()
Releases unmanaged resources and performs other cleanup operations before the KeyExchange is reclaimed by garbage collection.
protected ~KeyExchange()
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
MessageThe message.
Start(Session, KeyExchangeInitMessage, bool)
public virtual void Start(Session session, KeyExchangeInitMessage message, bool sendClientInitMessage)
Parameters
session
Sessionmessage
KeyExchangeInitMessagesendClientInitMessage
bool
ValidateExchangeHash()
Validates the exchange hash.
protected abstract bool ValidateExchangeHash()
Returns
- bool
true if exchange hash is valid; otherwise false.
Events
HostKeyReceived
Occurs when host key received.
public event EventHandler<HostKeyEventArgs> HostKeyReceived