Skip to content

version: add libssh2_build_options() - #2178

Closed
vszakats wants to merge 14 commits into
libssh2:masterfrom
vszakats:buildopt
Closed

vszakats wants to merge 14 commits into
libssh2:masterfrom
vszakats:buildopt

Conversation

@vszakats

@vszakats vszakats commented Jul 2, 2026 •

Copy link
Copy Markdown
Member

Returning for example (without newlines):

crypto:LibreSSL MD5:off MD5-PEM:off RIPEMD160:off DSA:off
RSA:on RSA-SHA1:on ECDSA:on ED25519:on ML-KEM:off
AES-CTR:on AES-CBC:on BLOWFISH:off RC4:off CAST:off
3DES:off zlib:on clear-memory:on debug-logging:on

To allow library users to find out these details, and add a searchable
static string to binaries with this information.

Possible values for crypto: AWS-LC, BoringSSL, Libgcrypt,
LibreSSL, mbedTLS, OpenSSL, OpenSSL/1.1.1, OS400QC3, WinCNG,
wolfSSL.

Also:

  • replace manual translation of crypto engine enum to name in CMake
    integration test snippet with the new API.

Fixes #2161


  • perhaps also include the crypto engine, e.g. as crypto:<engine-name>?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new public API, libssh2_build_options(), to expose build-time feature availability (e.g., MD5 enabled/disabled) as a runtime string, addressing the detectability concerns raised in #2161.

Changes:

  • Add libssh2_build_options() to the public header and implement it in src/version.c as a compile-time-constructed feature string.
  • Add SSH2_CRYPTO_ENGINE_NAME per crypto backend to report the selected crypto implementation in the build options string.
  • Update docs and a CMake test program to print the build options output.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/cmake/test.c Switch test output to print libssh2_build_options() instead of manually mapping crypto engine enum to a string.
src/version.c Implement libssh2_build_options() and embed a build-options string built from compile-time feature macros.
src/openssl.h Define SSH2_CRYPTO_ENGINE_NAME for OpenSSL-family backends (OpenSSL, LibreSSL, wolfSSL, AWS-LC, BoringSSL).
src/mbedtls.h Define SSH2_CRYPTO_ENGINE_NAME for mbedTLS backend.
src/wincng.h Define SSH2_CRYPTO_ENGINE_NAME for WinCNG backend.
src/os400qc3.h Define SSH2_CRYPTO_ENGINE_NAME for OS400QC3 backend.
src/libgcrypt.h Define SSH2_CRYPTO_ENGINE_NAME for libgcrypt backend (currently misspelled).
include/libssh2.h Add public API declaration for libssh2_build_options().
docs/Makefile.inc Add generated manpage target for libssh2_build_options(3).
docs/libssh2_version.md Add See-also link to libssh2_build_options(3) (also adds a redundant self-link).
docs/libssh2_crypto_engine.md Add See-also links to libssh2_build_options(3) and libssh2_version(3).
docs/libssh2_build_options.md Add new documentation page for libssh2_build_options(3) (front-matter title and return-value description need corrections).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/libgcrypt.h Resolved
Comment thread include/libssh2.h Resolved
Comment thread docs/libssh2_build_options.md Resolved
Comment thread docs/libssh2_build_options.md Resolved
Comment thread docs/libssh2_version.md Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread docs/libssh2_build_options.md Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread src/version.c Resolved
Comment thread docs/libssh2_build_options.md Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Comment thread include/libssh2.h
Comment on lines 1062 to +1063
LIBSSH2_API libssh2_crypto_engine_t libssh2_crypto_engine(void);
LIBSSH2_API const char *libssh2_build_options(void);

@vszakats vszakats Jul 3, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd only mess it up and no way to verify, won't touch.

edit: on a second look, why is there a libssh2 binding
in the libssh2 repo?

@vszakats vszakats closed this in 2673970 Jul 3, 2026
@vszakats
vszakats deleted the buildopt branch July 3, 2026 14:13
vszakats added a commit to vszakats/libssh2 that referenced this pull request Jul 14, 2026
vszakats added a commit that referenced this pull request Jul 14, 2026
Internally: make the agent backend guards unique for each backend, make
them contain the backend name. Use them in `agent.c`, move them to a
separate header and also reuse them from `version.c`.

Ref: #2285 (comment)
Follow-up to 2673970 #2178

Closes #2312
vszakats added a commit that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make MD5 availability detectable

2 participants