libssh  0.8.4
The SSH library
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 /* Signature flags from draft-miller-ssh-agent-02 */
70 #define SSH_AGENT_RSA_SHA2_256 0x02
71 #define SSH_AGENT_RSA_SHA2_512 0x04
72 
74  struct ssh_socket_struct *sock;
75  ssh_buffer ident;
76  unsigned int count;
77  ssh_channel channel;
78 };
79 
80 #ifndef _WIN32
81 /* agent.c */
87 struct ssh_agent_struct *ssh_agent_new(struct ssh_session_struct *session);
88 
89 void ssh_agent_close(struct ssh_agent_struct *agent);
90 
96 void ssh_agent_free(struct ssh_agent_struct *agent);
97 
105 int ssh_agent_is_running(struct ssh_session_struct *session);
106 
107 int ssh_agent_get_ident_count(struct ssh_session_struct *session);
108 
109 ssh_key ssh_agent_get_next_ident(struct ssh_session_struct *session,
110  char **comment);
111 
112 ssh_key ssh_agent_get_first_ident(struct ssh_session_struct *session,
113  char **comment);
114 
115 ssh_string ssh_agent_sign_data(ssh_session session,
116  const ssh_key pubkey,
117  struct ssh_buffer_struct *data);
118 #endif
119 
120 #endif /* __AGENT_H */
Definition: pki.h:42
Definition: agent.h:73
Definition: channels.h:57
Definition: session.h:102
Definition: string.h:29
Definition: socket.c:76
Definition: buffer.c:47