# File lib/net/ssh/userauth/agent.rb, line 151
        def sign( key, data )
          blob = @buffers.writer
          blob.write_key key

          packet_data = @buffers.writer
          packet_data.write_string blob.to_s
          packet_data.write_string data.to_s
          packet_data.write_long 0

          type, reply = send_with_reply SSH2_AGENT_SIGN_REQUEST, packet_data
          if agent_failed( type )
            raise AgentError,
              "agent could not sign data with requested identity"
          elsif type != SSH2_AGENT_SIGN_RESPONSE
            raise AgentError, "bad authentication response #{type}"
          end

          return reply.read_string
        end