Package com.sshtools.client
Class SshKeyExchangeClient
java.lang.Object
com.sshtools.client.SshKeyExchangeClient
- All Implemented Interfaces:
Component,SshComponent,SecureComponent,SshKeyExchange<SshClientContext>
- Direct Known Subclasses:
Curve25519SHA256Client,DiffieHellmanEcdh,DiffieHellmanGroup,DiffieHellmanGroupExchange,Rsa1024Sha1,Rsa2048Sha256
public abstract class SshKeyExchangeClient
extends Object
implements SshKeyExchange<SshClientContext>
An abstract base class for all key exchange implementations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected byte[]protected BigIntegerprotected byte[]The exchange hash produced during key exchange.protected BigIntegerprotected booleanprotected byte[]The server's host key.protected SshPublicKeyprotected BigIntegerThe secret value produced during key exchange.protected Stringprotected byte[]protected byte[]The signature generated over the exchange hashprotected SshTransport<SshClientContext>The transport protocol for sending/receiving messagesprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionSshKeyExchangeClient(String hashAlgorithm, SecurityLevel securityLevel, int priority) Contruct an uninitialized key exchange -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCalculates the exchange hash as an SHA1 hash of the following data.byte[]Get the output of the key exchangebyte[]Get the host key supplied during key exchange.intGet the secret value produced during key exchange.byte[]Get the signature produced during key exchange.booleanbooleanbooleanabstract booleanprocessMessage(byte[] msg) Process a key exchange messagevoidreset()Reset the key exchange.voidsetReceivedNewKeys(boolean receivedNewKeys) voidsetSentNewKeys(boolean sentNewKeys) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.sshtools.synergy.ssh.components.SshKeyExchange
getAlgorithm, getProvider, init, test
-
Field Details
-
secret
The secret value produced during key exchange. -
exchangeHash
protected byte[] exchangeHashThe exchange hash produced during key exchange. -
hostKey
protected byte[] hostKeyThe server's host key. -
signature
protected byte[] signatureThe signature generated over the exchange hash -
clientId
-
serverId
-
clientKexInit
protected byte[] clientKexInit -
serverKexInit
protected byte[] serverKexInit -
key
-
firstPacketFollows
protected boolean firstPacketFollows -
useFirstPacket
protected boolean useFirstPacket -
e
-
f
-
transport
The transport protocol for sending/receiving messages
-
-
Constructor Details
-
SshKeyExchangeClient
Contruct an uninitialized key exchange
-
-
Method Details
-
getSecurityLevel
- Specified by:
getSecurityLevelin interfaceSecureComponent
-
getPriority
public int getPriority()- Specified by:
getPriorityin interfaceSecureComponent
-
setReceivedNewKeys
public void setReceivedNewKeys(boolean receivedNewKeys) - Specified by:
setReceivedNewKeysin interfaceSshKeyExchange<SshClientContext>
-
setSentNewKeys
public void setSentNewKeys(boolean sentNewKeys) - Specified by:
setSentNewKeysin interfaceSshKeyExchange<SshClientContext>
-
hasSentNewKeys
public boolean hasSentNewKeys()- Specified by:
hasSentNewKeysin interfaceSshKeyExchange<SshClientContext>
-
hasReceivedNewKeys
public boolean hasReceivedNewKeys()- Specified by:
hasReceivedNewKeysin interfaceSshKeyExchange<SshClientContext>
-
getExchangeHash
public byte[] getExchangeHash()Get the output of the key exchange- Specified by:
getExchangeHashin interfaceSshKeyExchange<SshClientContext>- Returns:
- the exchange hash output.
-
getHostKey
public byte[] getHostKey()Get the host key supplied during key exchange.- Specified by:
getHostKeyin interfaceSshKeyExchange<SshClientContext>- Returns:
- the server's host key
-
getSecret
Get the secret value produced during key exchange.- Specified by:
getSecretin interfaceSshKeyExchange<SshClientContext>- Returns:
- The secret value produced during key exchange
-
getSignature
public byte[] getSignature()Get the signature produced during key exchange.- Specified by:
getSignaturein interfaceSshKeyExchange<SshClientContext>- Returns:
- the signature produced from the exchange hash.
-
processMessage
Process a key exchange message- Specified by:
processMessagein interfaceSshKeyExchange<SshClientContext>- Parameters:
msg-- Returns:
- boolean, indicating whether it has processed the message or not
- Throws:
IOExceptionSshException
-
reset
public void reset()Reset the key exchange. -
isComplete
public boolean isComplete() -
getHashAlgorithm
- Specified by:
getHashAlgorithmin interfaceSshKeyExchange<SshClientContext>
-
calculateExchangeHash
Calculates the exchange hash as an SHA1 hash of the following data.
String the client's version string (CR and NL excluded) String the server's version string (CR and NL excluded) String the payload of the client's SSH_MSG_KEXINIT String the payload of the server's SSH_MSG_KEXINIT String the host key BigInteger e, exchange value sent by the client BigInteger f, exchange value sent by the server BigInteger K, the shared secret
- Throws:
IOExceptionSshException
-