src/Robin/Ntlm/Message/NtlmV2AuthenticateMessageEncoder.php
public function encode(
        $username,
        $nt_domain,
        $client_hostname,
        CredentialInterface $credential,
        ServerChallenge $server_challenge
    ) {
        $negotiate_flags = $server_challenge->getNegotiateFlags();
        $server_challenge_nonce = $server_challenge->getNonce();
        $target_info = $server_challenge->getTargetInfo();
        $target_name = $this->identifyTargetName($username, $nt_domain, $server_challenge);

        // Generate a client challenge
        $client_challenge = $this->random_byte_generator->generate(static::CLIENT_CHALLENGE_LENGTH);

        // Encode the "blob"
        $binary_blob = $this->encodeBlob(new DateTime(), $client_challenge, $target_info);

        if ($credential->isPlaintext()) {
            $nt_hash = $this->nt_hasher->hash($credential, $username, $target_name);
        } elseif ($credential instanceof HashCredentialInterface && HashType::NT_V2 === $credential->getType()) {
            $nt_hash = $credential;
        } else {
            throw new InvalidArgumentException('Unsupported hash credential type');
        }

        $lm_challenge_response = $this->calculateLmResponse(
            $nt_hash,
            $client_challenge,
            $server_challenge_nonce
        );

        $nt_proof_string = $this->calculateNtProofString($nt_hash, $server_challenge_nonce, $binary_blob);

        $nt_challenge_response = ($nt_proof_string . $binary_blob);

        // TODO: Generate an encrypted random session key
        $session_key = '';

        return $this->encodeBinaryMessageString(
            $negotiate_flags,
            $lm_challenge_response,
            $nt_challenge_response,
            $target_name,
            $username,
            $client_hostname,
            $session_key
        );
    }
public function encode(
        $username,
        $nt_domain,
        $client_hostname,
        CredentialInterface $credential,
        ServerChallenge $server_challenge
    ) {
        $negotiate_flags = $server_challenge->getNegotiateFlags();
        $server_challenge_nonce = $server_challenge->getNonce();
        $target_info = $server_challenge->getTargetInfo();
        $target_name = $this->identifyTargetName($username, $nt_domain, $server_challenge);

        // Generate a client challenge
        $client_challenge = $this->random_byte_generator->generate(static::CLIENT_CHALLENGE_LENGTH);

        // Encode the "blob"
        $binary_blob = $this->encodeBlob(new DateTime(), $client_challenge, $target_info);

        if ($credential->isPlaintext()) {
            $nt_hash = $this->nt_hasher->hash($credential, $username, $target_name);
        } elseif ($credential instanceof HashCredentialInterface && HashType::NT_V2 === $credential->getType()) {
            $nt_hash = $credential;
        } else {
            throw new InvalidArgumentException('Unsupported hash credential type');
        }

        $lm_challenge_response = $this->calculateLmResponse(
            $nt_hash,
            $client_challenge,
            $server_challenge_nonce
        );

        $nt_proof_string = $this->calculateNtProofString($nt_hash, $server_challenge_nonce, $binary_blob);

        $nt_challenge_response = ($nt_proof_string . $binary_blob);

        // TODO: Generate an encrypted random session key
        $session_key = '';

        return $this->encodeBinaryMessageString(
            $negotiate_flags,
            $lm_challenge_response,
            $nt_challenge_response,
            $target_name,
            $username,
            $client_hostname,
            $session_key
        );
    }
public function encode ( $ username , $ nt_domain , $ client_hostname , CredentialInterface $ credential , ServerChallenge $ server_challenge ) { $ negotiate_flags = $ server_challenge -> getNegotiateFlags ( ) ; $ server_challenge_nonce = $ server_challenge -> getNonce ( ) ; $ target_info = $ server_challenge -> getTargetInfo ( ) ; $ target_name = $ this -> identifyTargetName ( $ username , $ nt_domain , $ server_challenge ) ; // Generate a client challenge $ client_challenge = $ this -> random_byte_generator -> generate ( static :: CLIENT_CHALLENGE_LENGTH ) ; // Encode the "blob" $ binary_blob = $ this -> encodeBlob ( new DateTime ( ) , $ client_challenge , $ target_info ) ; if ( $ credential -> isPlaintext ( ) ) { $ nt_hash = $ this -> nt_hasher -> hash ( $ credential , $ username , $ target_name ) ; } elseif ( $ credential instanceof HashCredentialInterface && HashType :: NT_V2 === $ credential -> getType ( ) ) { $ nt_hash = $ credential ; } else { throw new InvalidArgumentException ( 'Unsupported hash credential type' ) ; } $ lm_challenge_response = $ this -> calculateLmResponse ( $ nt_hash , $ client_challenge , $ server_challenge_nonce ) ; $ nt_proof_string = $ this -> calculateNtProofString ( $ nt_hash , $ server_challenge_nonce , $ binary_blob ) ; $ nt_challenge_response = ( $ nt_proof_string . $ binary_blob ) ; // TODO: Generate an encrypted random session key $ session_key = '' ; return $ this -> encodeBinaryMessageString ( $ negotiate_flags , $ lm_challenge_response , $ nt_challenge_response , $ target_name , $ username , $ client_hostname , $ session_key ) ; }
{@inheritDoc}
{