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".
  • Constructor Details

    • DiffieHellmanGroupExchange

      public DiffieHellmanGroupExchange(String kexAlgorithm, String hashAlgorithm, com.sshtools.common.ssh.SecurityLevel securityLevel, int priority)
      Construct an uninitialized instance.
  • Method Details

    • getAlgorithm

      public String getAlgorithm()
      Get the algorithm name for this key exchange
      Specified by:
      getAlgorithm in interface com.sshtools.common.ssh.SecureComponent
      Specified by:
      getAlgorithm in interface com.sshtools.common.ssh.components.SshComponent
      Specified by:
      getAlgorithm in interface com.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

      public String getProvider()
      Specified by:
      getProvider in interface com.sshtools.synergy.ssh.components.jce.AbstractKeyExchange
      Specified by:
      getProvider in interface com.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

      public boolean processMessage(byte[] m) throws com.sshtools.common.ssh.SshException, IOException
      Description copied from class: SshKeyExchangeClient
      Process a key exchange message
      Specified by:
      processMessage in interface com.sshtools.synergy.ssh.components.SshKeyExchange<SshClientContext>
      Specified by:
      processMessage in class SshKeyExchangeClient
      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.SshException

      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
        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 class SshKeyExchangeClient
      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 interface com.sshtools.synergy.ssh.components.SshKeyExchange<SshClientContext>
      Throws:
      IOException
      com.sshtools.common.ssh.SshException
    • test

      public void test() throws IOException, com.sshtools.common.ssh.SshException
      Specified by:
      test in interface com.sshtools.synergy.ssh.components.SshKeyExchange<SshClientContext>
      Throws:
      IOException
      com.sshtools.common.ssh.SshException