xref: /titanic_41/usr/src/cmd/ssh/include/authfd.h (revision c2580b931007758eab8cb5ae8726ebe1588e259b)
1 /*	$OpenBSD: authfd.h,v 1.31 2002/09/11 18:27:25 stevesk Exp $	*/
2 
3 #ifndef	_AUTHFD_H
4 #define	_AUTHFD_H
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 
13 /*
14  * Author: Tatu Ylonen <ylo@cs.hut.fi>
15  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
16  *                    All rights reserved
17  * Functions to interface with the SSH_AUTHENTICATION_FD socket.
18  *
19  * As far as I am concerned, the code I have written for this software
20  * can be used freely for any purpose.  Any derived versions of this
21  * software must be clearly marked as such, and if the derived work is
22  * incompatible with the protocol description in the RFC file, it must be
23  * called by a name other than "ssh" or "Secure Shell".
24  */
25 
26 #include "buffer.h"
27 
28 /* Messages for the authentication agent connection. */
29 #define SSH_AGENTC_REQUEST_RSA_IDENTITIES	1
30 #define SSH_AGENT_RSA_IDENTITIES_ANSWER		2
31 #define SSH_AGENTC_RSA_CHALLENGE		3
32 #define SSH_AGENT_RSA_RESPONSE			4
33 #define SSH_AGENT_FAILURE			5
34 #define SSH_AGENT_SUCCESS			6
35 #define SSH_AGENTC_ADD_RSA_IDENTITY		7
36 #define SSH_AGENTC_REMOVE_RSA_IDENTITY		8
37 #define SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES	9
38 
39 /* private OpenSSH extensions for SSH2 */
40 #define SSH2_AGENTC_REQUEST_IDENTITIES		11
41 #define SSH2_AGENT_IDENTITIES_ANSWER		12
42 #define SSH2_AGENTC_SIGN_REQUEST		13
43 #define SSH2_AGENT_SIGN_RESPONSE		14
44 #define SSH2_AGENTC_ADD_IDENTITY		17
45 #define SSH2_AGENTC_REMOVE_IDENTITY		18
46 #define SSH2_AGENTC_REMOVE_ALL_IDENTITIES	19
47 
48 /* smartcard */
49 #define SSH_AGENTC_ADD_SMARTCARD_KEY		20
50 #define SSH_AGENTC_REMOVE_SMARTCARD_KEY		21
51 
52 /* lock/unlock the agent */
53 #define SSH_AGENTC_LOCK				22
54 #define SSH_AGENTC_UNLOCK			23
55 
56 /* add key with constraints */
57 #define SSH_AGENTC_ADD_RSA_ID_CONSTRAINED	24
58 #define SSH2_AGENTC_ADD_ID_CONSTRAINED		25
59 
60 #define	SSH_AGENT_CONSTRAIN_LIFETIME		1
61 
62 /* extended failure messages */
63 #define SSH2_AGENT_FAILURE			30
64 
65 /* additional error code for ssh.com's ssh-agent2 */
66 #define SSH_COM_AGENT2_FAILURE			102
67 
68 #define	SSH_AGENT_OLD_SIGNATURE			0x01
69 
70 typedef struct {
71 	int	fd;
72 	Buffer	identities;
73 	int	howmany;
74 }	AuthenticationConnection;
75 
76 int	ssh_agent_present(void);
77 int	ssh_get_authentication_socket(void);
78 void	ssh_close_authentication_socket(int);
79 
80 AuthenticationConnection *ssh_get_authentication_connection(void);
81 void	ssh_close_authentication_connection(AuthenticationConnection *);
82 int	 ssh_get_num_identities(AuthenticationConnection *, int);
83 Key	*ssh_get_first_identity(AuthenticationConnection *, char **, int);
84 Key	*ssh_get_next_identity(AuthenticationConnection *, char **, int);
85 int	 ssh_add_identity(AuthenticationConnection *, Key *, const char *);
86 int	 ssh_add_identity_constrained(AuthenticationConnection *, Key *, const char *, u_int);
87 int	 ssh_remove_identity(AuthenticationConnection *, Key *);
88 int	 ssh_remove_all_identities(AuthenticationConnection *, int);
89 int	 ssh_lock_agent(AuthenticationConnection *, int, const char *);
90 int	 ssh_update_card(AuthenticationConnection *, int, const char *, const char *);
91 
92 int
93 ssh_decrypt_challenge(AuthenticationConnection *, Key *, BIGNUM *, u_char[16],
94     u_int, u_char[16]);
95 
96 int
97 ssh_agent_sign(AuthenticationConnection *, Key *, u_char **, u_int *, u_char *,
98     u_int);
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* _AUTHFD_H */
105