src/Handlers/KEXDH/INIT.php
public function handle(
        $msgType,
        \fpoirotte\Pssht\Wire\Decoder $decoder,
        \fpoirotte\Pssht\Transport $transport,
        array &$context
    ) {
        $hostAlgo   = null;
        foreach ($context['kex']['client']->getServerHostKeyAlgos() as $algo) {
            if (isset($context['serverKeys'][$algo])) {
                $hostAlgo = $algo;
                break;
            }
        }
        if ($hostAlgo === null) {
            throw new \RuntimeException();
        }
        $response   = $this->createResponse($decoder, $transport, $context, $hostAlgo);

        $logging    = \Plop\Plop::getInstance();
        $secret = gmp_strval($response->getSharedSecret(), 16);
        $logging->debug(
            "Shared secret:\r\n%s",
            array(
                wordwrap($secret, 16, ' ', true)
            )
        );

        $logging->debug(
            'Hash: %s',
            array(
                wordwrap(bin2hex($response->getExchangeHash()), 16, ' ', true)
            )
        );

        if (!isset($context['sessionIdentifier'])) {
            $context['sessionIdentifier'] = $response->getExchangeHash();
        }
        $context['DH'] = $response;
        $transport->writeMessage($response);
        return true;
    }
public function handle(
        $msgType,
        \fpoirotte\Pssht\Wire\Decoder $decoder,
        \fpoirotte\Pssht\Transport $transport,
        array &$context
    ) {
        $hostAlgo   = null;
        foreach ($context['kex']['client']->getServerHostKeyAlgos() as $algo) {
            if (isset($context['serverKeys'][$algo])) {
                $hostAlgo = $algo;
                break;
            }
        }
        if ($hostAlgo === null) {
            throw new \RuntimeException();
        }
        $response   = $this->createResponse($decoder, $transport, $context, $hostAlgo);

        $logging    = \Plop\Plop::getInstance();
        $secret = gmp_strval($response->getSharedSecret(), 16);
        $logging->debug(
            "Shared secret:\r\n%s",
            array(
                wordwrap($secret, 16, ' ', true)
            )
        );

        $logging->debug(
            'Hash: %s',
            array(
                wordwrap(bin2hex($response->getExchangeHash()), 16, ' ', true)
            )
        );

        if (!isset($context['sessionIdentifier'])) {
            $context['sessionIdentifier'] = $response->getExchangeHash();
        }
        $context['DH'] = $response;
        $transport->writeMessage($response);
        return true;
    }
public function handle ( $ msgType , \ fpoirotte \ Pssht \ Wire \ Decoder $ decoder , \ fpoirotte \ Pssht \ Transport $ transport , array & $ context ) { $ hostAlgo = null ; foreach ( $ context [ 'kex' ] [ 'client' ] -> getServerHostKeyAlgos ( ) as $ algo ) { if ( isset ( $ context [ 'serverKeys' ] [ $ algo ] ) ) { $ hostAlgo = $ algo ; break ; } } if ( $ hostAlgo === null ) { throw new \ RuntimeException ( ) ; } $ response = $ this -> createResponse ( $ decoder , $ transport , $ context , $ hostAlgo ) ; $ logging = \ Plop \ Plop :: getInstance ( ) ; $ secret = gmp_strval ( $ response -> getSharedSecret ( ) , 16 ) ; $ logging -> debug ( "Shared secret:\r\n%s" , array ( wordwrap ( $ secret , 16 , ' ' , true ) ) ) ; $ logging -> debug ( 'Hash: %s' , array ( wordwrap ( bin2hex ( $ response -> getExchangeHash ( ) ) , 16 , ' ' , true ) ) ) ; if ( ! isset ( $ context [ 'sessionIdentifier' ] ) ) { $ context [ 'sessionIdentifier' ] = $ response -> getExchangeHash ( ) ; } $ context [ 'DH' ] = $ response ; $ transport -> writeMessage ( $ response ) ; return true ; }
SSH_MSG_KEXDH_INIT = 30
SSH_MSG_KEXDH_INIT = 30