From e0635ab4cfca38fc1b4aff5f651ff540a382ae4d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 3 Jun 2026 10:56:05 +0200 Subject: [PATCH] libssh2_sign_sk: add `LIBSSH2_API` attribute, document availability Based on it having a public man page, it was likely meant to be a public function. Mark it `LIBSSH2_API` to export it from the DLL on Windows. Also move its public prototype next to userauth functions, since its implemented in userauth.c (though not using the namespace). Follow-up to ed439a29bb0b4d1c3f681f87ccfcd3e5a66c3ba0 #698 Closes #1965 --- docs/libssh2_sign_sk.md | 4 ++++ include/libssh2.h | 34 ++++++++++++++++------------------ src/userauth.c | 1 + 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/docs/libssh2_sign_sk.md b/docs/libssh2_sign_sk.md index 9e6824e3..80e1d0cf 100644 --- a/docs/libssh2_sign_sk.md +++ b/docs/libssh2_sign_sk.md @@ -95,3 +95,7 @@ pass in the PIN, or a function pointer to retrieve the PIN. # RETURN VALUE Return 0 on success or negative on failure. + +# AVAILABILITY + +Added in libssh2 1.11.0 diff --git a/include/libssh2.h b/include/libssh2.h index 0f0f7313..3df4ca14 100644 --- a/include/libssh2.h +++ b/include/libssh2.h @@ -370,24 +370,6 @@ typedef struct _LIBSSH2_LISTENER LIBSSH2_LISTENER; typedef struct _LIBSSH2_KNOWNHOSTS LIBSSH2_KNOWNHOSTS; typedef struct _LIBSSH2_AGENT LIBSSH2_AGENT; -/* SK signature callback */ -typedef struct _LIBSSH2_PRIVKEY_SK { - int algorithm; - uint8_t flags; - const char *application; - const unsigned char *key_handle; - size_t handle_len; - LIBSSH2_USERAUTH_SK_SIGN_FUNC(*sign_callback); - void **orig_abstract; -} LIBSSH2_PRIVKEY_SK; - -int libssh2_sign_sk(LIBSSH2_SESSION *session, - unsigned char **sig, - size_t *sig_len, - const unsigned char *data, - size_t data_len, - void **abstract); - #ifndef LIBSSH2_NO_DEPRECATED typedef struct _LIBSSH2_POLLFD { unsigned char type; /* LIBSSH2_POLLFD_* below */ @@ -758,6 +740,22 @@ LIBSSH2_API int libssh2_userauth_publickey_sk( LIBSSH2_USERAUTH_SK_SIGN_FUNC(*sign_callback), void **abstract); +/* SK signature callback */ +typedef struct _LIBSSH2_PRIVKEY_SK { + int algorithm; + uint8_t flags; + const char *application; + const unsigned char *key_handle; + size_t handle_len; + LIBSSH2_USERAUTH_SK_SIGN_FUNC(*sign_callback); + void **orig_abstract; +} LIBSSH2_PRIVKEY_SK; + +LIBSSH2_API int libssh2_sign_sk(LIBSSH2_SESSION *session, + unsigned char **sig, size_t *sig_len, + const unsigned char *data, size_t data_len, + void **abstract); + #ifndef LIBSSH2_NO_DEPRECATED LIBSSH2_DEPRECATED(1.2.0, "Use system poll() or select()") LIBSSH2_API int libssh2_poll(LIBSSH2_POLLFD *fds, unsigned int nfds, diff --git a/src/userauth.c b/src/userauth.c index 3b1a58ea..039a40f8 100644 --- a/src/userauth.c +++ b/src/userauth.c @@ -931,6 +931,7 @@ static int sign_fromfile(LIBSSH2_SESSION *session, return 0; } +LIBSSH2_API int libssh2_sign_sk(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len, const unsigned char *data, size_t data_len,