Package com.sshtools.client.components
Class DiffieHellmanGroupExchange
java.lang.Object
com.sshtools.client.SshKeyExchangeClient
com.sshtools.client.components.DiffieHellmanGroupExchange
- All Implemented Interfaces:
com.sshtools.common.ssh.components.Component
,com.sshtools.common.ssh.components.SshComponent
,com.sshtools.common.ssh.SecureComponent
,com.sshtools.synergy.ssh.components.jce.AbstractKeyExchange
,com.sshtools.synergy.ssh.components.SshKeyExchange<SshClientContext>
- Direct Known Subclasses:
DiffieHellmanGroupExchangeSha1JCE
,DiffieHellmanGroupExchangeSha256JCE
public abstract class DiffieHellmanGroupExchange
extends SshKeyExchangeClient
implements com.sshtools.synergy.ssh.components.jce.AbstractKeyExchange
Implementation of the required SSH Transport Protocol key exchange method
"diffie-hellman-group-exchange-sha1".
-
Field Summary
Fields inherited from class com.sshtools.client.SshKeyExchangeClient
clientId, clientKexInit, exchangeHash, firstPacketFollows, hostKey, key, secret, serverId, serverKexInit, signature, transport, useFirstPacket
-
Constructor Summary
ConstructorsConstructorDescriptionDiffieHellmanGroupExchange
(String kexAlgorithm, String hashAlgorithm, com.sshtools.common.ssh.SecurityLevel securityLevel, int priority) Construct an uninitialized instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Calculates the exchange hash as an SHA1 hash of the following data.boolean
exchangeGroup
(com.sshtools.common.util.ByteArrayReader msg) Get the algorithm name for this key exchangevoid
init
(com.sshtools.synergy.ssh.SshTransport<SshClientContext> transport, String clientIdentification, String serverIdentification, byte[] clientKexInit, byte[] serverKexInit, boolean firstPacketFollows, boolean useFirstPacket) void
init
(com.sshtools.synergy.ssh.SshTransport<SshClientContext> transport, String clientId, String serverId, byte[] clientKexInit, byte[] serverKexInit, com.sshtools.common.ssh.components.SshPrivateKey prvkey, com.sshtools.common.ssh.components.SshPublicKey pubkey, boolean firstPacketFollows, boolean useFirstPacket) boolean
isKeyExchangeMessage
(int messageid) boolean
processMessage
(byte[] m) Process a key exchange messagevoid
test()
Methods inherited from class com.sshtools.client.SshKeyExchangeClient
getExchangeHash, getHashAlgorithm, getHostKey, getPriority, getSecret, getSecurityLevel, getSignature, hasReceivedNewKeys, hasSentNewKeys, isComplete, reset, setReceivedNewKeys, setSentNewKeys
-
Constructor Details
-
Method Details
-
getAlgorithm
Get the algorithm name for this key exchange- Specified by:
getAlgorithm
in interfacecom.sshtools.common.ssh.SecureComponent
- Specified by:
getAlgorithm
in interfacecom.sshtools.common.ssh.components.SshComponent
- Specified by:
getAlgorithm
in interfacecom.sshtools.synergy.ssh.components.SshKeyExchange<SshClientContext>
- Returns:
- "diffie-hellman-group1-sha1"
-
init
public void init(com.sshtools.synergy.ssh.SshTransport<SshClientContext> transport, String clientIdentification, String serverIdentification, byte[] clientKexInit, byte[] serverKexInit, boolean firstPacketFollows, boolean useFirstPacket) throws IOException - Throws:
IOException
-
getProvider
- Specified by:
getProvider
in interfacecom.sshtools.synergy.ssh.components.jce.AbstractKeyExchange
- Specified by:
getProvider
in interfacecom.sshtools.synergy.ssh.components.SshKeyExchange<SshClientContext>
-
exchangeGroup
public boolean exchangeGroup(com.sshtools.common.util.ByteArrayReader msg) throws com.sshtools.common.ssh.SshException, IOException - Throws:
com.sshtools.common.ssh.SshException
IOException
-
processMessage
Description copied from class:SshKeyExchangeClient
Process a key exchange message- Specified by:
processMessage
in interfacecom.sshtools.synergy.ssh.components.SshKeyExchange<SshClientContext>
- Specified by:
processMessage
in classSshKeyExchangeClient
- Returns:
- boolean, indicating whether it has processed the message or not
- Throws:
com.sshtools.common.ssh.SshException
IOException
-
calculateExchangeHash
protected void calculateExchangeHash() throws com.sshtools.common.ssh.SshExceptionCalculates 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 UnsignedInteger32 min UnsignedInteger32 n UnsignedInteger32 max BigInteger p BigInteger g BigInteger e, exchange value sent by the client BigInteger f, exchange value sent by the server BigInteger K, the shared secret
- Overrides:
calculateExchangeHash
in classSshKeyExchangeClient
- Throws:
IOException
com.sshtools.common.ssh.SshException
-
isKeyExchangeMessage
public boolean isKeyExchangeMessage(int messageid) -
init
public void init(com.sshtools.synergy.ssh.SshTransport<SshClientContext> transport, String clientId, String serverId, byte[] clientKexInit, byte[] serverKexInit, com.sshtools.common.ssh.components.SshPrivateKey prvkey, com.sshtools.common.ssh.components.SshPublicKey pubkey, boolean firstPacketFollows, boolean useFirstPacket) throws IOException, com.sshtools.common.ssh.SshException - Specified by:
init
in interfacecom.sshtools.synergy.ssh.components.SshKeyExchange<SshClientContext>
- Throws:
IOException
com.sshtools.common.ssh.SshException
-
test
- Specified by:
test
in interfacecom.sshtools.synergy.ssh.components.SshKeyExchange<SshClientContext>
- Throws:
IOException
com.sshtools.common.ssh.SshException
-