Package com.trilead.ssh2.transport
Class KexManager
- java.lang.Object
-
- com.trilead.ssh2.transport.KexManager
-
- All Implemented Interfaces:
MessageHandler
public class KexManager extends java.lang.Object implements MessageHandler
KexManager.- Version:
- $Id: KexManager.java,v 1.1 2007/10/15 12:49:56 cplattne Exp $
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.Object
accessLock
(package private) boolean
connectionClosed
(package private) ClientServerHello
csh
private static java.util.List<java.lang.String>
DEFAULT_KEY_ALGORITHMS
(package private) java.lang.String
hostname
(package private) boolean
ignore_next_kex_packet
(package private) int
kexCount
(package private) KeyMaterial
km
(package private) KexState
kxs
(package private) ConnectionInfo
lastConnInfo
private static Logger
log
(package private) CryptoWishList
nextKEXcryptoWishList
(package private) DHGexParameters
nextKEXdhgexParameters
(package private) int
port
(package private) java.security.SecureRandom
rnd
(package private) byte[]
sessionId
(package private) TransportManager
tm
(package private) ServerHostKeyVerifier
verifier
-
Constructor Summary
Constructors Constructor Description KexManager(TransportManager tm, ClientServerHello csh, CryptoWishList initialCwl, java.lang.String hostname, int port, ServerHostKeyVerifier keyVerifier, java.security.SecureRandom rnd)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.List<java.lang.String>
buildDefaultKeyAlgorithms()
static void
checkKexAlgorithmList(java.lang.String[] algos)
static void
checkServerHostkeyAlgorithmsList(java.lang.String[] algos)
private boolean
compareFirstOfNameList(java.lang.String[] a, java.lang.String[] b)
private boolean
establishKeyMaterial()
private void
finishKex()
static java.lang.String[]
getDefaultKexAlgorithmList()
static java.lang.String[]
getDefaultServerHostkeyAlgorithmList()
private java.lang.String
getFirstMatch(java.lang.String[] client, java.lang.String[] server)
ConnectionInfo
getOrWaitForConnectionInfo(int minKexCount)
void
handleEndMessage(java.lang.Throwable cause)
Called to inform that no more messages will be delivered.void
handleMessage(byte[] msg, int msglen)
Handle message.void
initiateKEX(CryptoWishList cwl, DHGexParameters dhgex)
private boolean
isGuessOK(KexParameters cpar, KexParameters spar)
private NegotiatedParameters
mergeKexParameters(KexParameters client, KexParameters server)
private boolean
verifySignature(byte[] sig, byte[] hostkey)
-
-
-
Field Detail
-
log
private static final Logger log
-
DEFAULT_KEY_ALGORITHMS
private static final java.util.List<java.lang.String> DEFAULT_KEY_ALGORITHMS
-
kxs
KexState kxs
-
kexCount
int kexCount
-
km
KeyMaterial km
-
sessionId
byte[] sessionId
-
csh
ClientServerHello csh
-
accessLock
final java.lang.Object accessLock
-
lastConnInfo
ConnectionInfo lastConnInfo
-
connectionClosed
boolean connectionClosed
-
ignore_next_kex_packet
boolean ignore_next_kex_packet
-
tm
final TransportManager tm
-
nextKEXcryptoWishList
CryptoWishList nextKEXcryptoWishList
-
nextKEXdhgexParameters
DHGexParameters nextKEXdhgexParameters
-
verifier
ServerHostKeyVerifier verifier
-
hostname
final java.lang.String hostname
-
port
final int port
-
rnd
final java.security.SecureRandom rnd
-
-
Constructor Detail
-
KexManager
public KexManager(TransportManager tm, ClientServerHello csh, CryptoWishList initialCwl, java.lang.String hostname, int port, ServerHostKeyVerifier keyVerifier, java.security.SecureRandom rnd)
-
-
Method Detail
-
getOrWaitForConnectionInfo
public ConnectionInfo getOrWaitForConnectionInfo(int minKexCount) throws java.io.IOException
- Throws:
java.io.IOException
-
getFirstMatch
private java.lang.String getFirstMatch(java.lang.String[] client, java.lang.String[] server) throws NegotiateException
- Throws:
NegotiateException
-
compareFirstOfNameList
private boolean compareFirstOfNameList(java.lang.String[] a, java.lang.String[] b)
-
isGuessOK
private boolean isGuessOK(KexParameters cpar, KexParameters spar)
-
mergeKexParameters
private NegotiatedParameters mergeKexParameters(KexParameters client, KexParameters server)
-
initiateKEX
public void initiateKEX(CryptoWishList cwl, DHGexParameters dhgex) throws java.io.IOException
- Throws:
java.io.IOException
-
establishKeyMaterial
private boolean establishKeyMaterial()
-
finishKex
private void finishKex() throws java.io.IOException
- Throws:
java.io.IOException
-
getDefaultServerHostkeyAlgorithmList
public static java.lang.String[] getDefaultServerHostkeyAlgorithmList()
-
buildDefaultKeyAlgorithms
private static java.util.List<java.lang.String> buildDefaultKeyAlgorithms()
-
checkServerHostkeyAlgorithmsList
public static void checkServerHostkeyAlgorithmsList(java.lang.String[] algos)
-
getDefaultKexAlgorithmList
public static java.lang.String[] getDefaultKexAlgorithmList()
-
checkKexAlgorithmList
public static void checkKexAlgorithmList(java.lang.String[] algos)
-
verifySignature
private boolean verifySignature(byte[] sig, byte[] hostkey) throws java.io.IOException
- Throws:
java.io.IOException
-
handleMessage
public void handleMessage(byte[] msg, int msglen) throws java.io.IOException
Description copied from interface:MessageHandler
Handle message.- Specified by:
handleMessage
in interfaceMessageHandler
- Parameters:
msg
- the msgmsglen
- the msglen- Throws:
java.io.IOException
- the io exception
-
handleEndMessage
public void handleEndMessage(java.lang.Throwable cause) throws java.io.IOException
Description copied from interface:MessageHandler
Called to inform that no more messages will be delivered.- Specified by:
handleEndMessage
in interfaceMessageHandler
- Parameters:
cause
- For diagnosis, the reason that caused the transport to close down.- Throws:
java.io.IOException
- the io exception
-
-