protected function authNtlmResponse( $challenge, $password )
    {
        $password = chunk_split( $password, 1, "\x00" );
        $password = hash( 'md4', $password, true );
        $password .= str_repeat( "\x00", 21 - strlen( $password ) );

        $td = mcrypt_module_open( 'des', '', 'ecb', '' );
        $iv = mcrypt_create_iv( mcrypt_enc_get_iv_size( $td ), MCRYPT_RAND );

        $response = '';        
        for ( $i = 0; $i < 21; $i += 7 )
        {
            $packed = '';
            for ( $p = $i; $p < $i + 7; $p++ )
            {
                $packed .= str_pad( decbin( ord( substr( $password, $p, 1 ) ) ), 8, '0', STR_PAD_LEFT );
            }

            $key = '';
            for ( $p = 0; $p < strlen( $packed ); $p += 7 )
            {
                $s = substr( $packed, $p, 7 );
                $b = $s . ( ( substr_count( $s, '1' ) % 2 ) ? '0' : '1' );
                $key .= chr( bindec( $b ) );
            }

            mcrypt_generic_init( $td, $key, $iv );
            $response .= mcrypt_generic( $td, $challenge );
            mcrypt_generic_deinit( $td );
        }
        mcrypt_module_close( $td );

        return $response;
    }