libssh  0.7.2
include/libssh/agent.h
00001 /*
00002  * This file is part of the SSH Library
00003  *
00004  * Copyright (c) 2008-2009 Andreas Schneider <asn@cryptomilk.org>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 
00021 #ifndef __AGENT_H
00022 #define __AGENT_H
00023 
00024 #include "libssh/libssh.h"
00025 
00026 /* Messages for the authentication agent connection. */
00027 #define SSH_AGENTC_REQUEST_RSA_IDENTITIES        1
00028 #define SSH_AGENT_RSA_IDENTITIES_ANSWER          2
00029 #define SSH_AGENTC_RSA_CHALLENGE                 3
00030 #define SSH_AGENT_RSA_RESPONSE                   4
00031 #define SSH_AGENT_FAILURE                        5
00032 #define SSH_AGENT_SUCCESS                        6
00033 #define SSH_AGENTC_ADD_RSA_IDENTITY              7
00034 #define SSH_AGENTC_REMOVE_RSA_IDENTITY           8
00035 #define SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES     9
00036 
00037 /* private OpenSSH extensions for SSH2 */
00038 #define SSH2_AGENTC_REQUEST_IDENTITIES           11
00039 #define SSH2_AGENT_IDENTITIES_ANSWER             12
00040 #define SSH2_AGENTC_SIGN_REQUEST                 13
00041 #define SSH2_AGENT_SIGN_RESPONSE                 14
00042 #define SSH2_AGENTC_ADD_IDENTITY                 17
00043 #define SSH2_AGENTC_REMOVE_IDENTITY              18
00044 #define SSH2_AGENTC_REMOVE_ALL_IDENTITIES        19
00045 
00046 /* smartcard */
00047 #define SSH_AGENTC_ADD_SMARTCARD_KEY             20
00048 #define SSH_AGENTC_REMOVE_SMARTCARD_KEY          21
00049 
00050 /* lock/unlock the agent */
00051 #define SSH_AGENTC_LOCK                          22
00052 #define SSH_AGENTC_UNLOCK                        23
00053 
00054 /* add key with constraints */
00055 #define SSH_AGENTC_ADD_RSA_ID_CONSTRAINED        24
00056 #define SSH2_AGENTC_ADD_ID_CONSTRAINED           25
00057 #define SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED 26
00058 
00059 #define SSH_AGENT_CONSTRAIN_LIFETIME             1
00060 #define SSH_AGENT_CONSTRAIN_CONFIRM              2
00061 
00062 /* extended failure messages */
00063 #define SSH2_AGENT_FAILURE                       30
00064 
00065 /* additional error code for ssh.com's ssh-agent2 */
00066 #define SSH_COM_AGENT2_FAILURE                   102
00067 
00068 #define SSH_AGENT_OLD_SIGNATURE                  0x01
00069 
00070 struct ssh_agent_struct {
00071   struct ssh_socket_struct *sock;
00072   ssh_buffer ident;
00073   unsigned int count;
00074   ssh_channel channel;
00075 };
00076 
00077 #ifndef _WIN32
00078 /* agent.c */
00084 struct ssh_agent_struct *agent_new(struct ssh_session_struct *session);
00085 
00086 void agent_close(struct ssh_agent_struct *agent);
00087 
00093 void agent_free(struct ssh_agent_struct *agent);
00094 
00102 int agent_is_running(struct ssh_session_struct *session);
00103 
00104 int ssh_agent_get_ident_count(struct ssh_session_struct *session);
00105 
00106 ssh_key ssh_agent_get_next_ident(struct ssh_session_struct *session,
00107                                  char **comment);
00108 
00109 ssh_key ssh_agent_get_first_ident(struct ssh_session_struct *session,
00110                                   char **comment);
00111 
00112 ssh_string ssh_agent_sign_data(ssh_session session,
00113                                const ssh_key pubkey,
00114                                struct ssh_buffer_struct *data);
00115 #endif
00116 
00117 #endif /* __AGENT_H */
00118 /* vim: set ts=2 sw=2 et cindent: */