Class KeyExchanger

    • Method Detail

      • getSessionID

        byte[] getSessionID()
        Returns the session identifier computed during key exchange.
        Returns:
        session identifier as a byte array
      • isKexDone

        boolean isKexDone()
        Returns:
        whether key exchange has been completed
      • isKexOngoing

        boolean isKexOngoing()
        Returns:
        whether key exchange is currently ongoing
      • isStrictKex

        boolean isStrictKex()
      • isInitialKex

        boolean isInitialKex()
      • startKex

        void startKex​(boolean waitForDone)
               throws TransportException
        Starts key exchange by sending a SSH_MSG_KEXINIT packet. Key exchange needs to be done once mandatorily after initializing the Transport for it to be usable and may be initiated at any later point e.g. if algorithms have changed and should be renegotiated.
        Parameters:
        waitForDone - whether should block till key exchange completed
        Throws:
        TransportException - if there is an error during key exchange
      • isKeyExchangeAllowed

        private boolean isKeyExchangeAllowed()
        Key exchange can be initiated exactly once while connecting or later after authentication when re-keying.
      • findKnownHostAlgs

        private java.util.List<java.lang.String> findKnownHostAlgs​(java.lang.String hostname,
                                                                   int port)
      • verifyHost

        private void verifyHost​(java.security.PublicKey key)
                         throws TransportException
        Tries to validate host key with all the host key verifiers known to this instance ( hostVerifiers)
        Parameters:
        key - the host key to verify
        Throws:
        TransportException
      • setKexDone

        private void setKexDone()
      • resizedKey

        private static byte[] resizedKey​(byte[] E,
                                         int blockSize,
                                         Digest hash,
                                         java.math.BigInteger K,
                                         byte[] H)
        Private method used while putting new keys into use that will resize the key used to initialize the cipher to the needed length.
        Parameters:
        E - the key to resize
        blockSize - the cipher block size
        hash - the hash algorithm
        K - the key exchange K parameter
        H - the key exchange H parameter
        Returns:
        the resized key
      • gotNewKeys

        private void gotNewKeys()