mirror of
https://github.com/libssh2/libssh2.git
synced 2025-08-05 20:55:47 +03:00
Agent forwarding implementation (#752)
This PR contains a series of patches that date back many years and I believe were discussed on the mailing list, but never merged. We have been using these in our local copy of libssh2 without issue since 2015, if not earlier. I believe this is the full set of changes, as we tried to use comments to mark where our copy of libssh2 differs from the canonical version. This also contains changes I made earlier this year, but which were not discussed on the mailing list, to support certificates and FIDO2 keys with agent forwarding. Note that this is not a complete implementation of agent forwarding, as that is outside the scope of libssh2. Clients still need to provide their own implementation that parses ssh-agent methods after calling libssh2_channel_read() and calls the appropriate callback messages in libssh2. See the man page changes in this PR for more details. Integration-patches-by: Viktor Szakats * prefer size_t * prefer unsigned int over u_int in public function * add const * docs, indent, checksrc, debug call, compiler warning fixes
This commit is contained in:
@@ -333,6 +333,22 @@ typedef struct _LIBSSH2_SK_SIG_INFO {
|
||||
void name(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel, \
|
||||
const char *shost, int sport, void **abstract)
|
||||
|
||||
#define LIBSSH2_AUTHAGENT_FUNC(name) \
|
||||
void name(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel, \
|
||||
void **abstract)
|
||||
|
||||
#define LIBSSH2_ADD_IDENTITIES_FUNC(name) \
|
||||
void name(LIBSSH2_SESSION *session, void *buffer, \
|
||||
const char *agent_path, void **abstract)
|
||||
|
||||
#define LIBSSH2_AUTHAGENT_SIGN_FUNC(name) \
|
||||
int name(LIBSSH2_SESSION* session, \
|
||||
unsigned char *blob, unsigned int blen, \
|
||||
const unsigned char *data, unsigned int dlen, \
|
||||
unsigned char **signature, unsigned int *sigLen, \
|
||||
const char *agentPath, \
|
||||
void **abstract)
|
||||
|
||||
#define LIBSSH2_CHANNEL_CLOSE_FUNC(name) \
|
||||
void name(LIBSSH2_SESSION *session, void **session_abstract, \
|
||||
LIBSSH2_CHANNEL *channel, void **channel_abstract)
|
||||
@@ -348,13 +364,16 @@ typedef struct _LIBSSH2_SK_SIG_INFO {
|
||||
int flags, void **abstract)
|
||||
|
||||
/* libssh2_session_callback_set() constants */
|
||||
#define LIBSSH2_CALLBACK_IGNORE 0
|
||||
#define LIBSSH2_CALLBACK_DEBUG 1
|
||||
#define LIBSSH2_CALLBACK_DISCONNECT 2
|
||||
#define LIBSSH2_CALLBACK_MACERROR 3
|
||||
#define LIBSSH2_CALLBACK_X11 4
|
||||
#define LIBSSH2_CALLBACK_SEND 5
|
||||
#define LIBSSH2_CALLBACK_RECV 6
|
||||
#define LIBSSH2_CALLBACK_IGNORE 0
|
||||
#define LIBSSH2_CALLBACK_DEBUG 1
|
||||
#define LIBSSH2_CALLBACK_DISCONNECT 2
|
||||
#define LIBSSH2_CALLBACK_MACERROR 3
|
||||
#define LIBSSH2_CALLBACK_X11 4
|
||||
#define LIBSSH2_CALLBACK_SEND 5
|
||||
#define LIBSSH2_CALLBACK_RECV 6
|
||||
#define LIBSSH2_CALLBACK_AUTHAGENT 7
|
||||
#define LIBSSH2_CALLBACK_AUTHAGENT_IDENTITIES 8
|
||||
#define LIBSSH2_CALLBACK_AUTHAGENT_SIGN 9
|
||||
|
||||
/* libssh2_session_method_pref() constants */
|
||||
#define LIBSSH2_METHOD_KEX 0
|
||||
@@ -747,6 +766,8 @@ LIBSSH2_API int
|
||||
libssh2_userauth_publickey_sk(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
size_t username_len,
|
||||
const unsigned char *pubkeydata,
|
||||
size_t pubkeydata_len,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase,
|
||||
@@ -1331,6 +1352,23 @@ libssh2_agent_userauth(LIBSSH2_AGENT *agent,
|
||||
const char *username,
|
||||
struct libssh2_agent_publickey *identity);
|
||||
|
||||
/*
|
||||
* libssh2_agent_sign()
|
||||
*
|
||||
* Sign a payload using a system-installed ssh-agent.
|
||||
*
|
||||
* Returns 0 if succeeded, or a negative value for error.
|
||||
*/
|
||||
LIBSSH2_API int
|
||||
libssh2_agent_sign(LIBSSH2_AGENT *agent,
|
||||
struct libssh2_agent_publickey *identity,
|
||||
unsigned char **sig,
|
||||
size_t *s_len,
|
||||
const unsigned char *data,
|
||||
size_t d_len,
|
||||
const char *method,
|
||||
unsigned int method_len);
|
||||
|
||||
/*
|
||||
* libssh2_agent_disconnect()
|
||||
*
|
||||
|
Reference in New Issue
Block a user