#NEWLINE# def ssh_KEXINIT( self , packet ) : #NEWLINE# #INDENT# '\n        Called when we receive a MSG_KEXINIT message.  Payload::\n            bytes[16] cookie\n            string keyExchangeAlgorithms\n            string keyAlgorithms\n            string incomingEncryptions\n            string outgoingEncryptions\n            string incomingAuthentications\n            string outgoingAuthentications\n            string incomingCompressions\n            string outgoingCompressions\n            string incomingLanguages\n            string outgoingLanguages\n            bool firstPacketFollows\n            unit32 0 (reserved)\n\n        Starts setting up the key exchange, keys, encryptions, and\n        authentications.  Extended by ssh_KEXINIT in SSHServerTransport and\n        SSHClientTransport.\n\n        @type packet: L{bytes}\n        @param packet: The message data.\n\n        @return: A L{tuple} of negotiated key exchange algorithms, key\n        algorithms, and unhandled data, or C{None} if something went wrong.\n        ' #NEWLINE# self . otherKexInitPayload = ( chr ( MSG_KEXINIT ) + packet ) #NEWLINE# k = getNS ( packet [ 16 : ] , 10 ) #NEWLINE# ( strings , rest ) = ( k [ : ( - 1 ) ] , k [ ( - 1 ) ] ) #NEWLINE# ( kexAlgs , keyAlgs , encCS , encSC , macCS , macSC , compCS , compSC , langCS , langSC ) = [ s . split ( b',' ) for s in strings ] #NEWLINE# outs = [ encSC , macSC , compSC ] #NEWLINE# ins = [ encCS , macSC , compCS ] #NEWLINE# if self . isClient : #NEWLINE# #INDENT# ( outs , ins ) = ( ins , outs ) #NEWLINE# #UNINDENT# server = ( self . supportedKeyExchanges , self . supportedPublicKeys , self . supportedCiphers , self . supportedCiphers , self . supportedMACs , self . supportedMACs , self . supportedCompressions , self . supportedCompressions ) #NEWLINE# client = ( kexAlgs , keyAlgs , outs [ 0 ] , ins [ 0 ] , outs [ 1 ] , ins [ 1 ] , outs [ 2 ] , ins [ 2 ] ) #NEWLINE# if self . isClient : #NEWLINE# #INDENT# ( server , client ) = ( client , server ) #NEWLINE# #UNINDENT# self . kexAlg = ffs ( client [ 0 ] , server [ 0 ] ) #NEWLINE# self . keyAlg = ffs ( client [ 1 ] , server [ 1 ] ) #NEWLINE# self . nextEncryptions = SSHCiphers ( ffs ( client [ 2 ] , server [ 2 ] ) , ffs ( client [ 3 ] , server [ 3 ] ) , ffs ( client [ 4 ] , server [ 4 ] ) , ffs ( client [ 5 ] , server [ 5 ] ) ) #NEWLINE# self . outgoingCompressionType = ffs ( client [ 6 ] , server [ 6 ] ) #NEWLINE# self . incomingCompressionType = ffs ( client [ 7 ] , server [ 7 ] ) #NEWLINE# if ( None in ( self . kexAlg , self . keyAlg , self . outgoingCompressionType , self . incomingCompressionType ) ) : #NEWLINE# #INDENT# self . sendDisconnect ( DISCONNECT_KEY_EXCHANGE_FAILED , b"couldn't match all kex parts" ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( None in self . nextEncryptions . __dict__ . values ( ) ) : #NEWLINE# #INDENT# self . sendDisconnect ( DISCONNECT_KEY_EXCHANGE_FAILED , b"couldn't match all kex parts" ) #NEWLINE# return #NEWLINE# #UNINDENT# log . msg ( ( 'kex alg, key alg: %s %s' % ( self . kexAlg , self . keyAlg ) ) ) #NEWLINE# log . msg ( ( 'outgoing: %s %s %s' % ( self . nextEncryptions . outCipType , compSC . nextEncryptions . outMACType , self . outgoingCompressionType ) ) ) #NEWLINE# log . msg ( ( 'incoming: %s %s %s' % ( self . nextEncryptions . inCipType , self . nextEncryptions . inMACType , self . incomingCompressionType ) ) ) #NEWLINE# if ( self . _keyExchangeState == self . _KEY_EXCHANGE_REQUESTED ) : #NEWLINE# #INDENT# self . _keyExchangeState = self . _KEY_EXCHANGE_PROGRESSING #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . sendKexInit ( ) #NEWLINE# #UNINDENT# return ( kexAlgs , keyAlgs , rest )