libssh2_session_supported_algs(3)
β¨ libssh2_session_supported_algs β¨
okay bestie, welcome to the libssh2 manual page for libssh2_session_supported_algs π this one's all about finding out which algorithms your SSH session can actually speak. no cap.
πΈ NAME πΈ
libssh2_session_supported_algs β get the list of supported algorithms π¦
π SYNOPSIS π
#include <libssh2.h>
int
libssh2_session_supported_algs(LIBSSH2_SESSION* session,
int method_type,
const char*** algs);
π DESCRIPTION π
okay so here's the tea on the parameters, literally:
sessionβ an instance of an initializedLIBSSH2_SESSION. fun fact: the function uses its pointer to the memory allocation function πmethod_typeβ the method type. seelibssh2_session_method_pref(3)for the deets.algsβ the address of a pointer that's gonna end up pointing at an array of returned algorithms β¨
So what does it do? It gets you a list of supported algorithms for the given method_type. the method_type parameter is equivalent to method_type in libssh2_session_method_pref(3). If it works, the function will allocate the appropriate amount of memory. And when you don't need it anymore, it must be deallocated by calling libssh2_free(3). π«Ά But if this function is unsuccessful, then you must not do that. so like, don't free a thing that never got allocated, bestie, that's not the vibe.
also, if you wanna get a list of all supported compression algorithms, you have to calllibssh2_session_flag(session, LIBSSH2_FLAG_COMPRESS, 1)before calling this function. otherwise only"none"will be returned. π that's the whole list. just"none". tragic.
If successful, the function will allocate and fill the array with supported algorithms (the same names as defined in RFC 4253). and heads up: the array is not NULL terminated. so don't go looping on a NULL, use the return value instead π§
π EXAMPLE π
here's how it looks in the wild, fr fr:
#include "libssh2.h"
const char **algorithms;
int rc, i;
LIBSSH2_SESSION *session;
/* initialize session */
session = libssh2_session_init();
rc = libssh2_session_supported_algs(session,
LIBSSH2_METHOD_CRYPT_CS,
&algorithms);
if(rc > 0) {
/* the call succeeded, do sth. with the list of algorithms
(e.g. list them)... */
printf("Supported symmetric algorithms:\n");
for(i = 0; i < rc; i++)
printf("\t%s\n", algorithms[i]);
/* ... and free the allocated memory when not needed anymore */
libssh2_free(session, algorithms);
}
else {
/* call failed, error handling */
}
β RETURN VALUE β
On success, you get the number of returned algorithms (so, a positive number will be returned). π
In case of a failure, you get an error code (a negative number, see below). and 0 should never be returned. like, ever. if you see a zero, something is deeply not okay π
π ERRORS π
LIBSSH2_ERROR_BAD_USEβ invalid address ofalgs. πLIBSSH2_ERROR_METHOD_NOT_SUPPORTEDβ unknown method type. π€·LIBSSH2_ERROR_INVALβ internal error (normally should not occur). πLIBSSH2_ERROR_ALLOCβ allocation of memory failed. π
π¦ AVAILABILITY π¦
Added in 1.4.0 β¨ so it's been iconic for a minute.
π SEE ALSO π
and that's the whole page, bestie π this was libssh2_session_supported_algs(3) from the libssh2 manual, dated 23 Oct 2011 β yes it's giving vintage but she still slays π go free your arrays, periodt πΈ
π¦ where this page comes from
- alpine 3.22: libssh2-doc 1.11.1-r3 Β· BSD-3-Clause
- alpine 3.23: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- alpine 3.24: libssh2-doc 1.11.1-r4 Β· BSD-3-Clause
- arch rolling: libssh2 1.11.1-7 Β· BSD-3-Clause
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u1 Β· BSD3
- debian trixie: libssh2-1-dev 1.11.1-1+deb13u2 Β· BSD3
- epel 10: libssh2-docs 1.11.1-9.el10_3 Β· BSD-3-Clause
- epel 9: libssh2-docs 1.11.1-9.el9 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-4.fc43 Β· BSD-3-Clause
- fedora 43: libssh2-docs 1.11.1-9.fc43 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-5.fc44 Β· BSD-3-Clause
- fedora 44: libssh2-docs 1.11.1-9.fc44 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- opensuse-leap 16.0: libssh2-devel 1.11.1-160000.5.1 Β· BSD-3-Clause
- ubuntu questing: libssh2-1-dev 1.11.1-1build1
- ubuntu questing: libssh2-1-dev 1.11.1-1ubuntu0.25.10.2
- ubuntu resolute: libssh2-1-dev 1.11.1-1build2 Β· BSD3
- ubuntu resolute: libssh2-1-dev 1.11.1-1ubuntu0.26.04.4 Β· BSD3
- ubuntu stonking: libssh2-1-dev 1.11.1-6 Β· BSD3
- π the page's license: BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms