# File lib/net/ssh/authentication/agent.rb, line 121
121:     def sign(key, data)
122:       type, reply = send_and_wait(SSH2_AGENT_SIGN_REQUEST, :string, Buffer.from(:key, key), :string, data, :long, 0)
123: 
124:       if agent_failed(type)
125:         raise AgentError, "agent could not sign data with requested identity"
126:       elsif type != SSH2_AGENT_SIGN_RESPONSE
127:         raise AgentError, "bad authentication response #{type}"
128:       end
129: 
130:       return reply.read_string
131:     end