1180750SdesThis describes the protocol used by OpenSSH's ssh-agent.
2180750Sdes
3180750SdesOpenSSH's agent supports managing keys for the standard SSH protocol
4180750Sdes2 as well as the legacy SSH protocol 1. Support for these key types
5180750Sdesis almost completely disjoint - in all but a few cases, operations on
6180750Sdesprotocol 2 keys cannot see or affect protocol 1 keys and vice-versa.
7180750Sdes
8180750SdesProtocol 1 and protocol 2 keys are separated because of the differing
9180750Sdescryptographic usage: protocol 1 private RSA keys are used to decrypt
10180750Sdeschallenges that were encrypted with the corresponding public key,
11180750Sdeswhereas protocol 2 RSA private keys are used to sign challenges with
12180750Sdesa private key for verification with the corresponding public key. It
13180750Sdesis considered unsound practice to use the same key for signing and
14180750Sdesencryption.
15180750Sdes
16180750SdesWith a couple of exceptions, the protocol message names used in this
17180750Sdesdocument indicate which type of key the message relates to. SSH_*
18180750Sdesmessages refer to protocol 1 keys only. SSH2_* messages refer to
19180750Sdesprotocol 2 keys. Furthermore, the names also indicate whether the
20180750Sdesmessage is a request to the agent (*_AGENTC_*) or a reply from the
21180750Sdesagent (*_AGENT_*). Section 3 below contains the mapping of the
22180750Sdesprotocol message names to their integer values.
23180750Sdes
24180750Sdes1. Data types
25180750Sdes
26180750SdesBecause of support for legacy SSH protocol 1 keys, OpenSSH's agent
27180750Sdesprotocol makes use of some data types not defined in RFC 4251.
28180750Sdes
29180750Sdes1.1 uint16
30180750Sdes
31180750SdesThe "uint16" data type is a simple MSB-first 16 bit unsigned integer
32180750Sdesencoded in two bytes.
33180750Sdes
34180750Sdes1.2 mpint1
35180750Sdes
36180750SdesThe "mpint1" type represents an arbitrary precision integer (bignum).
37180750SdesIts format is as follows:
38180750Sdes
39180750Sdes	uint16			bits
40180750Sdes	byte[(bits + 7) / 8]	bignum
41180750Sdes
42180750Sdes"bignum" contains an unsigned arbitrary precision integer encoded as
43180750Sdeseight bits per byte in big-endian (MSB first) format.
44180750Sdes
45180750SdesNote the difference between the "mpint1" encoding and the "mpint"
46180750Sdesencoding defined in RFC 4251. Also note that the length of the encoded
47180750Sdesinteger is specified in bits, not bytes and that the byte length of
48180750Sdesthe integer must be calculated by rounding up the number of bits to the
49180750Sdesnearest eight.
50180750Sdes
51180750Sdes2. Protocol Messages
52180750Sdes
53180750SdesAll protocol messages are prefixed with their length in bytes, encoded
54180750Sdesas a 32 bit unsigned integer. Specifically:
55180750Sdes
56180750Sdes	uint32			message_length
57180750Sdes	byte[message_length]	message
58180750Sdes
59180750SdesThe following message descriptions refer only to the content the
60180750Sdes"message" field.
61180750Sdes
62180750Sdes2.1 Generic server responses
63180750Sdes
64180750SdesThe following generic messages may be sent by the server in response to
65180750Sdesrequests from the client. On success the agent may reply either with:
66180750Sdes
67180750Sdes	byte			SSH_AGENT_SUCCESS
68180750Sdes
69180750Sdesor a request-specific success message.
70180750Sdes
71180750SdesOn failure, the agent may reply with:
72180750Sdes
73180750Sdes	byte			SSH_AGENT_FAILURE
74180750Sdes
75180750SdesSSH_AGENT_FAILURE messages are also sent in reply to unknown request
76180750Sdestypes.
77180750Sdes
78180750Sdes2.2 Adding keys to the agent
79180750Sdes
80180750SdesKeys are added to the agent using the SSH_AGENTC_ADD_RSA_IDENTITY and
81180750SdesSSH2_AGENTC_ADD_IDENTITY requests for protocol 1 and protocol 2 keys
82180750Sdesrespectively.
83180750Sdes
84180750SdesTwo variants of these requests are SSH_AGENTC_ADD_RSA_ID_CONSTRAINED
85180750Sdesand SSH2_AGENTC_ADD_ID_CONSTRAINED - these add keys with optional
86180750Sdes"constraints" on their usage.
87180750Sdes
88180750SdesOpenSSH may be built with support for keys hosted on a smartcard
89180750Sdesor other hardware security module. These keys may be added
90180750Sdesto the agent using the SSH_AGENTC_ADD_SMARTCARD_KEY and
91180750SdesSSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED requests.
92180750Sdes
93180750Sdes2.2.1 Key constraints
94180750Sdes
95180750SdesThe OpenSSH agent supports some basic optional constraints on key usage.
96180750SdesAt present there are two constraints defined.
97180750Sdes
98180750SdesThe first constraint limits the validity duration of a key. It is
99180750Sdesencoded as:
100180750Sdes
101180750Sdes	byte			SSH_AGENT_CONSTRAIN_LIFETIME
102180750Sdes	uint32			seconds
103180750Sdes
104180750SdesWhere "seconds" contains the number of seconds that the key shall remain
105180750Sdesvalid measured from the moment that the agent receives it. After the
106180750Sdesvalidity period has expired, OpenSSH's agent will erase these keys from
107180750Sdesmemory.
108180750Sdes
109180750SdesThe second constraint requires the agent to seek explicit user
110180750Sdesconfirmation before performing private key operations with the loaded
111180750Sdeskey. This constraint is encoded as:
112180750Sdes
113180750Sdes	byte			SSH_AGENT_CONSTRAIN_CONFIRM
114180750Sdes
115180750SdesZero or more constraints may be specified when adding a key with one
116180750Sdesof the *_CONSTRAINED requests. Multiple constraints are appended
117180750Sdesconsecutively to the end of the request:
118180750Sdes
119180750Sdes	byte			constraint1_type
120180750Sdes	....			constraint1_data
121180750Sdes	byte			constraint2_type
122180750Sdes	....			constraint2_data
123180750Sdes	....
124180750Sdes	byte			constraintN_type
125180750Sdes	....			constraintN_data
126180750Sdes
127180750SdesSuch a sequence of zero or more constraints will be referred to below
128180750Sdesas "constraint[]". Agents may determine whether there are constraints
129180750Sdesby checking whether additional data exists in the "add key" request
130180750Sdesafter the key data itself. OpenSSH will refuse to add a key if it
131180750Sdescontains unknown constraints.
132180750Sdes
133180750Sdes2.2.2 Add protocol 1 key
134180750Sdes
135180750SdesA client may add a protocol 1 key to an agent with the following
136180750Sdesrequest:
137180750Sdes
138180750Sdes	byte			SSH_AGENTC_ADD_RSA_IDENTITY or
139180750Sdes				SSH_AGENTC_ADD_RSA_ID_CONSTRAINED
140180750Sdes	uint32			ignored
141180750Sdes	mpint1			rsa_n
142180750Sdes	mpint1			rsa_e
143180750Sdes	mpint1			rsa_d
144180750Sdes	mpint1			rsa_iqmp
145180750Sdes	mpint1			rsa_q
146180750Sdes	mpint1			rsa_p
147180750Sdes	string			key_comment
148180750Sdes	constraint[]		key_constraints
149180750Sdes
150180750SdesNote that there is some redundancy in the key parameters; a key could be
151180750Sdesfully specified using just rsa_q, rsa_p and rsa_e at the cost of extra
152180750Sdescomputation.
153180750Sdes
154180750Sdes"key_constraints" may only be present if the request type is
155248619SdesSSH_AGENTC_ADD_RSA_ID_CONSTRAINED.
156180750Sdes
157180750SdesThe agent will reply with a SSH_AGENT_SUCCESS if the key has been
158180750Sdessuccessfully added or a SSH_AGENT_FAILURE if an error occurred.
159180750Sdes
160180750Sdes2.2.3 Add protocol 2 key
161180750Sdes
162221420SdesThe OpenSSH agent supports DSA, ECDSA and RSA keys for protocol 2. DSA
163221420Sdeskeys may be added using the following request
164180750Sdes
165180750Sdes	byte			SSH2_AGENTC_ADD_IDENTITY or
166180750Sdes				SSH2_AGENTC_ADD_ID_CONSTRAINED
167180750Sdes	string			"ssh-dss"
168180750Sdes	mpint			dsa_p
169180750Sdes	mpint			dsa_q
170180750Sdes	mpint			dsa_g
171180750Sdes	mpint			dsa_public_key
172180750Sdes	mpint			dsa_private_key
173180750Sdes	string			key_comment
174180750Sdes	constraint[]		key_constraints
175180750Sdes
176204917SdesDSA certificates may be added with:
177204917Sdes	byte			SSH2_AGENTC_ADD_IDENTITY or
178204917Sdes				SSH2_AGENTC_ADD_ID_CONSTRAINED
179204917Sdes	string			"ssh-dss-cert-v00@openssh.com"
180204917Sdes	string			certificate
181204917Sdes	mpint			dsa_private_key
182204917Sdes	string			key_comment
183204917Sdes	constraint[]		key_constraints
184204917Sdes
185221420SdesECDSA keys may be added using the following request
186221420Sdes
187221420Sdes	byte			SSH2_AGENTC_ADD_IDENTITY or
188221420Sdes				SSH2_AGENTC_ADD_ID_CONSTRAINED
189221420Sdes	string			"ecdsa-sha2-nistp256" |
190221420Sdes				"ecdsa-sha2-nistp384" |
191221420Sdes				"ecdsa-sha2-nistp521"
192221420Sdes	string			ecdsa_curve_name
193221420Sdes	string			ecdsa_public_key
194221420Sdes	mpint			ecdsa_private
195221420Sdes	string			key_comment
196221420Sdes	constraint[]		key_constraints
197221420Sdes
198221420SdesECDSA certificates may be added with:
199221420Sdes	byte			SSH2_AGENTC_ADD_IDENTITY or
200221420Sdes				SSH2_AGENTC_ADD_ID_CONSTRAINED
201221420Sdes	string			"ecdsa-sha2-nistp256-cert-v01@openssh.com" |
202221420Sdes				"ecdsa-sha2-nistp384-cert-v01@openssh.com" |
203221420Sdes				"ecdsa-sha2-nistp521-cert-v01@openssh.com"
204221420Sdes	string			certificate
205221420Sdes	mpint			ecdsa_private_key
206221420Sdes	string			key_comment
207221420Sdes	constraint[]		key_constraints
208221420Sdes
209323124SdesED25519 keys may be added using the following request
210323124Sdes	byte			SSH2_AGENTC_ADD_IDENTITY or
211323124Sdes				SSH2_AGENTC_ADD_ID_CONSTRAINED
212323124Sdes	string			"ssh-ed25519"
213323124Sdes	string			ed25519_public_key
214323124Sdes	string			ed25519_private_key || ed25519_public_key
215323124Sdes	string			key_comment
216323124Sdes	constraint[]		key_constraints
217323124Sdes
218323124SdesED25519 certificates may be added with:
219323124Sdes	byte			SSH2_AGENTC_ADD_IDENTITY or
220323124Sdes				SSH2_AGENTC_ADD_ID_CONSTRAINED
221323124Sdes	string			"ssh-ed25519-cert-v01@openssh.com"
222323124Sdes	string			certificate
223323124Sdes	string			ed25519_public_key
224323124Sdes	string			ed25519_private_key || ed25519_public_key
225323124Sdes	string			key_comment
226323124Sdes	constraint[]		key_constraints
227323124Sdes
228323124SdesFor both ssh-ed25519 and ssh-ed25519-cert-v01@openssh.com keys, the private
229323124Sdeskey has the public key appended (for historical reasons).
230323124Sdes
231180750SdesRSA keys may be added with this request:
232180750Sdes
233180750Sdes	byte			SSH2_AGENTC_ADD_IDENTITY or
234180750Sdes				SSH2_AGENTC_ADD_ID_CONSTRAINED
235180750Sdes	string			"ssh-rsa"
236180750Sdes	mpint			rsa_n
237180750Sdes	mpint			rsa_e
238180750Sdes	mpint			rsa_d
239180750Sdes	mpint			rsa_iqmp
240180750Sdes	mpint			rsa_p
241180750Sdes	mpint			rsa_q
242180750Sdes	string			key_comment
243180750Sdes	constraint[]		key_constraints
244180750Sdes
245204917SdesRSA certificates may be added with this request:
246204917Sdes
247204917Sdes	byte			SSH2_AGENTC_ADD_IDENTITY or
248204917Sdes				SSH2_AGENTC_ADD_ID_CONSTRAINED
249204917Sdes	string			"ssh-rsa-cert-v00@openssh.com"
250204917Sdes	string			certificate
251204917Sdes	mpint			rsa_d
252204917Sdes	mpint			rsa_iqmp
253204917Sdes	mpint			rsa_p
254204917Sdes	mpint			rsa_q
255204917Sdes	string			key_comment
256204917Sdes	constraint[]		key_constraints
257204917Sdes
258180750SdesNote that the 'rsa_p' and 'rsa_q' parameters are sent in the reverse
259180750Sdesorder to the protocol 1 add keys message. As with the corresponding
260180750Sdesprotocol 1 "add key" request, the private key is overspecified to avoid
261180750Sdesredundant processing.
262180750Sdes
263221420SdesFor DSA, ECDSA and RSA key add requests, "key_constraints" may only be
264180750Sdespresent if the request type is SSH2_AGENTC_ADD_ID_CONSTRAINED.
265180750Sdes
266180750SdesThe agent will reply with a SSH_AGENT_SUCCESS if the key has been
267180750Sdessuccessfully added or a SSH_AGENT_FAILURE if an error occurred.
268180750Sdes
269180750Sdes2.2.4 Loading keys from a smartcard
270180750Sdes
271180750SdesThe OpenSSH agent may have optional smartcard support built in to it. If
272180750Sdesso, it supports an operation to load keys from a smartcard. Technically,
273180750Sdesonly the public components of the keys are loaded into the agent so
274180750Sdesthis operation really arranges for future private key operations to be
275180750Sdesdelegated to the smartcard.
276180750Sdes
277180750Sdes	byte			SSH_AGENTC_ADD_SMARTCARD_KEY or
278180750Sdes				SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED
279180750Sdes	string			reader_id
280180750Sdes	string			pin
281180750Sdes	constraint[]		key_constraints
282180750Sdes
283180750Sdes"reader_id" is an identifier to a smartcard reader and "pin"
284180750Sdesis a PIN or passphrase used to unlock the private key(s) on the
285180750Sdesdevice. "key_constraints" may only be present if the request type is
286180750SdesSSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED.
287180750Sdes
288180750SdesThis operation may load all SSH keys that are unlocked using the
289180750Sdes"pin" on the specified reader. The type of key loaded (protocol 1
290180750Sdesor protocol 2) will be specified by the smartcard itself, it is not
291180750Sdesclient-specified.
292180750Sdes
293180750SdesThe agent will reply with a SSH_AGENT_SUCCESS if one or more keys have
294180750Sdesbeen successfully loaded or a SSH_AGENT_FAILURE if an error occurred.
295180750SdesThe agent will also return SSH_AGENT_FAILURE if it does not support
296180750Sdessmartcards.
297180750Sdes
298180750Sdes2.3 Removing multiple keys
299180750Sdes
300180750SdesA client may request that an agent delete all protocol 1 keys using the
301180750Sdesfollowing request:
302180750Sdes
303180750Sdes	byte			SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES
304180750Sdes
305180750SdesThis message requests the deletion of all protocol 2 keys:
306180750Sdes
307180750Sdes	byte			SSH2_AGENTC_REMOVE_ALL_IDENTITIES
308180750Sdes
309180750SdesOn success, the agent will delete all keys of the requested type and
310180750Sdesreply with a SSH_AGENT_SUCCESS message. If an error occurred, the agent
311180750Sdeswill reply with SSH_AGENT_FAILURE.
312180750Sdes
313180750SdesNote that, to delete all keys (both protocol 1 and 2), a client
314180750Sdesmust send both a SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES and a
315180750SdesSSH2_AGENTC_REMOVE_ALL_IDENTITIES request.
316180750Sdes
317180750Sdes2.4 Removing specific keys
318180750Sdes
319180750Sdes2.4.1 Removing a protocol 1 key
320180750Sdes
321180750SdesRemoval of a protocol 1 key may be requested with the following message:
322180750Sdes
323180750Sdes	byte 			SSH_AGENTC_REMOVE_RSA_IDENTITY
324180750Sdes	uint32			key_bits
325180750Sdes	mpint1			rsa_e
326180750Sdes	mpint1			rsa_n
327180750Sdes
328180750SdesNote that key_bits is strictly redundant, as it may be inferred by the
329180750Sdeslength of rsa_n.
330180750Sdes
331180750SdesThe agent will delete any private key matching the specified public key
332180750Sdesand return SSH_AGENT_SUCCESS. If no such key was found, the agent will
333180750Sdesreturn SSH_AGENT_FAILURE.
334180750Sdes
335180750Sdes2.4.2 Removing a protocol 2 key
336180750Sdes
337180750SdesProtocol 2 keys may be removed with the following request:
338180750Sdes
339180750Sdes	byte			SSH2_AGENTC_REMOVE_IDENTITY
340180750Sdes	string			key_blob
341180750Sdes
342180750SdesWhere "key_blob" is encoded as per RFC 4253 section 6.6 "Public Key
343221420SdesAlgorithms" for any of the supported protocol 2 key types.
344180750Sdes
345180750SdesThe agent will delete any private key matching the specified public key
346180750Sdesand return SSH_AGENT_SUCCESS. If no such key was found, the agent will
347180750Sdesreturn SSH_AGENT_FAILURE.
348180750Sdes
349180750Sdes2.4.3 Removing keys loaded from a smartcard
350180750Sdes
351180750SdesA client may request that a server remove one or more smartcard-hosted
352180750Sdeskeys using this message:
353180750Sdes
354180750Sdes	byte			SSH_AGENTC_REMOVE_SMARTCARD_KEY
355180750Sdes	string			reader_id
356180750Sdes	string			pin
357180750Sdes
358180750Sdes"reader_id" the an identifier to a smartcard reader and "pin" is a PIN
359180750Sdesor passphrase used to unlock the private key(s) on the device.
360180750Sdes
361180750SdesWhen this message is received, and if the agent supports
362180750Sdessmartcard-hosted keys, it will delete all keys that are hosted on the
363180750Sdesspecified smartcard that may be accessed with the given "pin".
364180750Sdes
365180750SdesThe agent will reply with a SSH_AGENT_SUCCESS if one or more keys have
366180750Sdesbeen successfully removed or a SSH_AGENT_FAILURE if an error occurred.
367180750SdesThe agent will also return SSH_AGENT_FAILURE if it does not support
368180750Sdessmartcards.
369180750Sdes
370180750Sdes2.5 Requesting a list of known keys
371180750Sdes
372180750SdesAn agent may be requested to list which keys it holds. Different
373180750Sdesrequests exist for protocol 1 and protocol 2 keys.
374180750Sdes
375180750Sdes2.5.1 Requesting a list of protocol 1 keys
376180750Sdes
377180750SdesTo request a list of protocol 1 keys that are held in the agent, a
378180750Sdesclient may send the following message:
379180750Sdes
380180750Sdes	byte			SSH_AGENTC_REQUEST_RSA_IDENTITIES
381180750Sdes
382180750SdesThe agent will reply with the following message:
383180750Sdes
384180750Sdes	byte			SSH_AGENT_RSA_IDENTITIES_ANSWER
385180750Sdes	uint32			num_keys
386180750Sdes
387180750SdesFollowed by zero or more consecutive keys, encoded as:
388180750Sdes
389180750Sdes	uint32			bits
390180750Sdes	mpint1			rsa_e
391180750Sdes	mpint1			rsa_n
392180750Sdes	string			key_comment
393180750Sdes
394180750Sdes2.5.2 Requesting a list of protocol 2 keys
395180750Sdes
396180750SdesA client may send the following message to request a list of
397180750Sdesprotocol 2 keys that are stored in the agent:
398180750Sdes
399180750Sdes	byte			SSH2_AGENTC_REQUEST_IDENTITIES
400180750Sdes
401180750SdesThe agent will reply with the following message header:
402180750Sdes
403180750Sdes	byte			SSH2_AGENT_IDENTITIES_ANSWER
404180750Sdes	uint32			num_keys
405180750Sdes
406180750SdesFollowed by zero or more consecutive keys, encoded as:
407180750Sdes
408180750Sdes	string			key_blob
409180750Sdes	string			key_comment
410180750Sdes
411180750SdesWhere "key_blob" is encoded as per RFC 4253 section 6.6 "Public Key
412221420SdesAlgorithms" for any of the supported protocol 2 key types.
413180750Sdes
414180750Sdes2.6 Private key operations
415180750Sdes
416180750SdesThe purpose of the agent is to perform private key operations, such as
417180750Sdessigning and encryption without requiring a passphrase to unlock the
418180750Sdeskey and without allowing the private key itself to be exposed. There
419180750Sdesare separate requests for the protocol 1 and protocol 2 private key
420180750Sdesoperations.
421180750Sdes
422180750Sdes2.6.1 Protocol 1 private key challenge
423180750Sdes
424180750SdesThe private key operation used in version 1 of the SSH protocol is
425180750Sdesdecrypting a challenge that has been encrypted with a public key.
426180750SdesIt may be requested using this message:
427180750Sdes
428180750Sdes	byte			SSH_AGENTC_RSA_CHALLENGE
429180750Sdes	uint32			ignored
430180750Sdes	mpint1			rsa_e
431180750Sdes	mpint1			rsa_n
432180750Sdes	mpint1			encrypted_challenge
433180750Sdes	byte[16]		session_id
434180750Sdes	uint32			response_type /* must be 1 */
435180750Sdes
436180750Sdes"rsa_e" and "rsa_n" are used to identify which private key to use.
437180750Sdes"encrypted_challenge" is a challenge blob that has (presumably)
438295367Sdesbeen encrypted with the public key and must be in the range
439180750Sdes1 <= encrypted_challenge < 2^256. "session_id" is the SSH protocol 1
440180750Sdessession ID (computed from the server host key, the server semi-ephemeral
441180750Sdeskey and the session cookie).
442180750Sdes
443180750Sdes"ignored" and "response_type" exist for compatibility with legacy
444180750Sdesimplementations. "response_type" must be equal to 1; other response
445180750Sdestypes are not supported.
446180750Sdes
447180750SdesOn receiving this request, the server decrypts the "encrypted_challenge"
448180750Sdesusing the private key matching the supplied (rsa_e, rsa_n) values. For
449180750Sdesthe response derivation, the decrypted challenge is represented as an
450180750Sdesunsigned, big-endian integer encoded in a 32 byte buffer (i.e. values
451180750Sdessmaller than 2^248 will have leading 0 bytes).
452180750Sdes
453180750SdesThe response value is then calculated as:
454180750Sdes
455180750Sdes	response = MD5(decrypted_challenge || session_id)
456180750Sdes
457180750Sdesand returned in the following message
458180750Sdes
459180750Sdes	byte			SSH_AGENT_RSA_RESPONSE
460180750Sdes	byte[16]		response
461180750Sdes
462180750SdesIf the agent cannot find the key specified by the supplied (rsa_e,
463180750Sdesrsa_n) then it will return SSH_AGENT_FAILURE.
464180750Sdes
465180750Sdes2.6.2 Protocol 2 private key signature request
466180750Sdes
467180750SdesA client may use the following message to request signing of data using
468180750Sdesa protocol 2 key:
469180750Sdes
470180750Sdes	byte			SSH2_AGENTC_SIGN_REQUEST
471180750Sdes	string			key_blob
472180750Sdes	string			data
473180750Sdes	uint32			flags
474180750Sdes
475180750SdesWhere "key_blob" is encoded as per RFC 4253 section 6.6 "Public Key
476221420SdesAlgorithms" for any of the supported protocol 2 key types. "flags" is
477221420Sdesa bit-mask, but at present only one possible value is defined (see below
478221420Sdesfor its meaning):
479180750Sdes
480180750Sdes	SSH_AGENT_OLD_SIGNATURE		1
481180750Sdes
482180750SdesUpon receiving this request, the agent will look up the private key that
483180750Sdescorresponds to the public key contained in key_blob. It will use this
484180750Sdesprivate key to sign the "data" and produce a signature blob using the
485180750Sdeskey type-specific method described in RFC 4253 section 6.6 "Public Key
486180750SdesAlgorithms".
487180750Sdes
488180750SdesAn exception to this is for "ssh-dss" keys where the "flags" word
489180750Sdescontains the value SSH_AGENT_OLD_SIGNATURE. In this case, a legacy
490180750Sdessignature encoding is used in lieu of the standard one. In this case,
491180750Sdesthe DSA signature blob is encoded as:
492180750Sdes
493180750Sdes	byte[40]		signature
494180750Sdes
495180750SdesThe signature will be returned in the response message:
496180750Sdes
497180750Sdes	byte			SSH2_AGENT_SIGN_RESPONSE
498180750Sdes	string			signature_blob
499180750Sdes
500180750SdesIf the agent cannot find the key specified by the supplied key_blob then
501180750Sdesit will return SSH_AGENT_FAILURE.
502180750Sdes
503180750Sdes2.7 Locking or unlocking an agent
504180750Sdes
505180750SdesThe agent supports temporary locking with a passphrase to suspend
506180750Sdesprocessing of sensitive operations until it has been unlocked with the
507180750Sdessame passphrase. To lock an agent, a client send the following request:
508180750Sdes
509180750Sdes	byte			SSH_AGENTC_LOCK
510180750Sdes	string			passphrase
511180750Sdes
512180750SdesUpon receipt of this message and if the agent is not already locked,
513180750Sdesit will suspend processing requests and return a SSH_AGENT_SUCCESS
514180750Sdesreply. If the agent is already locked, it will return SSH_AGENT_FAILURE.
515180750Sdes
516180750SdesWhile locked, the agent will refuse all requests except
517180750SdesSSH_AGENTC_UNLOCK, SSH_AGENTC_REQUEST_RSA_IDENTITIES and
518180750SdesSSH2_AGENTC_REQUEST_IDENTITIES. The "request identities" requests are
519180750Sdestreated specially by a locked agent: it will always return an empty list
520180750Sdesof keys.
521180750Sdes
522180750SdesTo unlock an agent, a client may request:
523180750Sdes
524180750Sdes	byte			SSH_AGENTC_UNLOCK
525180750Sdes	string			passphrase
526180750Sdes
527180750SdesIf the passphrase matches and the agent is locked, then it will resume
528180750Sdesprocessing all requests and return SSH_AGENT_SUCCESS. If the agent
529180750Sdesis not locked or the passphrase does not match then it will return
530180750SdesSSH_AGENT_FAILURE.
531180750Sdes
532180750SdesLocking and unlocking affects both protocol 1 and protocol 2 keys.
533180750Sdes
534180750Sdes3. Protocol message numbers
535180750Sdes
536180750Sdes3.1 Requests from client to agent for protocol 1 key operations
537180750Sdes
538180750Sdes	SSH_AGENTC_REQUEST_RSA_IDENTITIES		1
539180750Sdes	SSH_AGENTC_RSA_CHALLENGE			3
540180750Sdes	SSH_AGENTC_ADD_RSA_IDENTITY			7
541180750Sdes	SSH_AGENTC_REMOVE_RSA_IDENTITY			8
542180750Sdes	SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES		9
543180750Sdes	SSH_AGENTC_ADD_RSA_ID_CONSTRAINED		24
544180750Sdes
545180750Sdes3.2 Requests from client to agent for protocol 2 key operations
546180750Sdes
547180750Sdes	SSH2_AGENTC_REQUEST_IDENTITIES			11
548180750Sdes	SSH2_AGENTC_SIGN_REQUEST			13
549180750Sdes	SSH2_AGENTC_ADD_IDENTITY			17
550180750Sdes	SSH2_AGENTC_REMOVE_IDENTITY			18
551180750Sdes	SSH2_AGENTC_REMOVE_ALL_IDENTITIES		19
552180750Sdes	SSH2_AGENTC_ADD_ID_CONSTRAINED			25
553180750Sdes
554180750Sdes3.3 Key-type independent requests from client to agent
555180750Sdes
556180750Sdes	SSH_AGENTC_ADD_SMARTCARD_KEY			20
557180750Sdes	SSH_AGENTC_REMOVE_SMARTCARD_KEY			21
558180750Sdes	SSH_AGENTC_LOCK					22
559180750Sdes	SSH_AGENTC_UNLOCK				23
560180750Sdes	SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED	26
561180750Sdes
562180750Sdes3.4 Generic replies from agent to client
563180750Sdes
564180750Sdes	SSH_AGENT_FAILURE				5
565180750Sdes	SSH_AGENT_SUCCESS				6
566180750Sdes
567180750Sdes3.5 Replies from agent to client for protocol 1 key operations
568180750Sdes
569180750Sdes	SSH_AGENT_RSA_IDENTITIES_ANSWER			2
570180750Sdes	SSH_AGENT_RSA_RESPONSE				4
571180750Sdes
572180750Sdes3.6 Replies from agent to client for protocol 2 key operations
573180750Sdes
574180750Sdes	SSH2_AGENT_IDENTITIES_ANSWER			12
575180750Sdes	SSH2_AGENT_SIGN_RESPONSE			14
576180750Sdes
577180750Sdes3.7 Key constraint identifiers
578180750Sdes
579180750Sdes	SSH_AGENT_CONSTRAIN_LIFETIME			1
580180750Sdes	SSH_AGENT_CONSTRAIN_CONFIRM			2
581180750Sdes
582323124Sdes$OpenBSD: PROTOCOL.agent,v 1.11 2016/05/19 07:45:32 djm Exp $
583