libssh  0.7.3
agent.h
1 /*
2  * This file is part of the SSH Library
3  *
4  * Copyright (c) 2008-2009 Andreas Schneider <asn@cryptomilk.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef __AGENT_H
22 #define __AGENT_H
23 
24 #include "libssh/libssh.h"
25 
26 /* Messages for the authentication agent connection. */
27 #define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1
28 #define SSH_AGENT_RSA_IDENTITIES_ANSWER 2
29 #define SSH_AGENTC_RSA_CHALLENGE 3
30 #define SSH_AGENT_RSA_RESPONSE 4
31 #define SSH_AGENT_FAILURE 5
32 #define SSH_AGENT_SUCCESS 6
33 #define SSH_AGENTC_ADD_RSA_IDENTITY 7
34 #define SSH_AGENTC_REMOVE_RSA_IDENTITY 8
35 #define SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES 9
36 
37 /* private OpenSSH extensions for SSH2 */
38 #define SSH2_AGENTC_REQUEST_IDENTITIES 11
39 #define SSH2_AGENT_IDENTITIES_ANSWER 12
40 #define SSH2_AGENTC_SIGN_REQUEST 13
41 #define SSH2_AGENT_SIGN_RESPONSE 14
42 #define SSH2_AGENTC_ADD_IDENTITY 17
43 #define SSH2_AGENTC_REMOVE_IDENTITY 18
44 #define SSH2_AGENTC_REMOVE_ALL_IDENTITIES 19
45 
46 /* smartcard */
47 #define SSH_AGENTC_ADD_SMARTCARD_KEY 20
48 #define SSH_AGENTC_REMOVE_SMARTCARD_KEY 21
49 
50 /* lock/unlock the agent */
51 #define SSH_AGENTC_LOCK 22
52 #define SSH_AGENTC_UNLOCK 23
53 
54 /* add key with constraints */
55 #define SSH_AGENTC_ADD_RSA_ID_CONSTRAINED 24
56 #define SSH2_AGENTC_ADD_ID_CONSTRAINED 25
57 #define SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED 26
58 
59 #define SSH_AGENT_CONSTRAIN_LIFETIME 1
60 #define SSH_AGENT_CONSTRAIN_CONFIRM 2
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 struct ssh_agent_struct {
71  struct ssh_socket_struct *sock;
72  ssh_buffer ident;
73  unsigned int count;
74  ssh_channel channel;
75 };
76 
77 #ifndef _WIN32
78 /* agent.c */
84 struct ssh_agent_struct *agent_new(struct ssh_session_struct *session);
85 
86 void agent_close(struct ssh_agent_struct *agent);
87 
93 void agent_free(struct ssh_agent_struct *agent);
94 
102 int agent_is_running(struct ssh_session_struct *session);
103 
104 int ssh_agent_get_ident_count(struct ssh_session_struct *session);
105 
106 ssh_key ssh_agent_get_next_ident(struct ssh_session_struct *session,
107  char **comment);
108 
109 ssh_key ssh_agent_get_first_ident(struct ssh_session_struct *session,
110  char **comment);
111 
112 ssh_string ssh_agent_sign_data(ssh_session session,
113  const ssh_key pubkey,
114  struct ssh_buffer_struct *data);
115 #endif
116 
117 #endif /* __AGENT_H */
118 /* vim: set ts=2 sw=2 et cindent: */