# File lib/net/ssh/userauth/agent.rb, line 88
        def identities
          case @version
            when 1
              code1 = SSH_AGENT_REQUEST_RSA_IDENTITIES
              code2 = SSH_AGENT_RSA_IDENTITIES_ANSWER
            when 2
              code1 = SSH2_AGENT_REQUEST_IDENTITIES
              code2 = SSH2_AGENT_IDENTITIES_ANSWER
            else
              raise NotImplementedError, "SSH version #{@version}"
          end

          type, body = send_with_reply code1
          raise AgentError,
            "could not get identity count" if agent_failed( type )
          raise AgentError, "bad authentication reply: #{type}" if type != code2

          identities = []
          body.read_long.times do
            case @version
              when 1
                key = @keys.get( "rsa" )
                bits = body.read_long
                key.e = body.read_bignum
                key.n = body.read_bignum
              when 2
                blob = @buffers.reader( body.read_string )
                key = blob.read_key
            end

            unless key.respond_to?( :comment= )
              key.instance_eval "def comment=(cmt)\n@comment = cmt\nend\n"
            end

            unless key.respond_to?( :comment )
              key.instance_eval "def comment\n@comment\nend\n"
            end

            key.comment = body.read_string
            identities.push key
          end

          return identities
        end