1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-08-01 11:26:53 +03:00

261 Commits

Author SHA1 Message Date
784446b6c5 build: add support for clang-cl, add CI job
- ci/appveyor: add clang-cl job.
- ci/appvayor: optimize setting an env.
- build: fix clang-cl builds.
- build: fix `-Wcast-function-type` compiler warnings for OpenSSL 3.
- build: use `stdint.h` with MSVC when supported.
- src: use `PRId64` for MSVC where supported.
- src: avoid recursive macro definition for `recv()` and `send()`.
- session: silence `-Wcast-function-type` for `libssh2_session_callback_set2()`.
  Sadly this function is still not fully warning-clean, and it
  seems we'd need separate setter-getters for each callback
  to avoid all warnings.

Closes #1484
2025-01-31 05:13:18 +01:00
cf3aac1aba libssh2_base64_decode: add deprecation warning
Cherry-picked from #1484
2025-01-31 02:04:59 +01:00
7027604505 libssh2_scp_send, libssh2_scp_send_ex: add deprecation warning
Also:
- switch to non-deprecated alternative in examples.
- add pointers and deprecation warning to libssh2_scp_send man page.

Cherry-picked from #1484
2025-01-31 02:04:59 +01:00
780bf13aa2 libssh2.h: typo fixes
Closes #1496
2024-11-21 11:46:26 +01:00
83590ac70d libssh2.h: add note about release versions to LIBSSH2_VERSION
As noted in #771 and #1473, the blessed and signed releases are on
libssh2.org and any other archives, like those generated by GitHub,
are just a collection of files from the tag and are not the official
releases.

This adds a note, which already exists for `LIBSSH2_TIMESTAMP`, to
`LIBSSH2_VERSION`, to clarify this fact.

Closes #1475
2024-10-23 01:15:07 +02:00
c04d57e785 libssh2.h: bump to 1.11.2_DEV 2024-10-21 12:00:17 +02:00
00e5975ad2 libssh2.h: bump to 1.11.1 2024-10-21 11:59:53 +02:00
b7ab0faa70 disable DSA by default
Also:
- add `LIBSSH2_DSA_ENABLE` to enable it explicitly.
- test the above option in CI.
- say 'deprecated' in docs and public header.
- disable DSA in the CI server config.
  (OpenSSH 9.8 no longer builds with it by default)
  https://www.openssh.com/txt/release-9.8
  Patch-by: Jose Quaresma
- disable more DSA code when not enabled.

Fixes #1433
Closes #1435
2024-07-30 22:59:02 +02:00
a6a9093b39 userauth: avoid oob with huge interactive kbd response
- If the length of a response is `UINT_MAX - 3` or larger, an unsigned
  integer overflow occurs on 64-bit systems. Avoid such truncation to
  always allocate enough memory to avoid subsequent out of boundary
  writes.

  Patch-by: Tobias Stoeckmann

- also add FIXME to bump up length field to `size_t` (ABI break)

Closes #1337
2024-03-29 09:11:40 +00:00
4718ede4e0 src: check hash update/final success
Also:
- delete unused internal macro `libssh2_md5()` where defined.
- prefix `libssh2_os400qc3_hash*()` function names with underscore.
  These are public/visible, but internal.
- add FIXMEs to OS/400 code to verify update/final calls; some OS API,
  some internal.

Ref: https://github.com/libssh2/libssh2/pull/1301#discussion_r1446861650
Reviewed-by: Michael Buckley
Reviewed-by: Patrick Monnerat
Closes #1303
2024-01-18 23:54:29 +00:00
2ed9eb92f3 src: check hash init success
Before this patch, SHA2 and SHA1 init function results were cast to
`void`. This patch makes sure to verify these values.

Also:
- exclude an `assert(0)` from release builds in `_libssh2_sha_algo_ctx_init()`.
  (return error instead)
- fix indentation / whitespace

Reviewed-by: Michael Buckley
Closes #1301
2024-01-10 16:32:26 +00:00
f64885b6ab mac: handle low-level errors
- update low-level hmac functions from macros to functions.
- libgcrypt: propagate low-level hmac errors.
- libgcrypt: add error checks for hmac calls.
- os400qc3: add error checks, propagate them.
  Assisted-by: Patrick Monnerat
- mbedtls: fix propagating low-level hmac errors.
- wincng: fix propagating low-level hmac errors.
- mac: verify success of low-level hmac functions.
- knownhost: verify success of low-level hmac functions.
- transport: verify success of MAC hash call.
- minor type cleanup in wincng.
- delete unused ripemd wrapper in wincng.
- delete unused SHA384 wrapper in mbedtls.

Reported-by: Paul Howarth
Reviewed-by: Michael Buckley
Closes #1297
2024-01-10 16:32:22 +00:00
c0f69548be session: add libssh2_session_callback_set2()
Add new `libssh2_session_callback_set2()` API that deprecates
`libssh2_session_callback_set()`.

The new implementation offers the same functionality, but accepts and
returns a generic function pointer (of type `libssh2_cb_generic *`), as
opposed to the old function that used data pointers (`void *`). The new
solution thus avoids data to function (and vice versa) pointer
conversions, which has undefined behaviour in standard C.

About the name: It seems the `*2` suffix was used in the past for
replacement functions for deprecated ones. Let's stick with that.
`*_ex` was preferred for new functions that extend existing ones with
new features.

Closes #1285
2023-12-18 15:02:17 +00:00
9839ebe5e9 libssh2.h: add deprecated function warnings
With deprecated-at versions and suggested replacement function.

It's possible to silence them by defining `LIBSSH2_DISABLE_DEPRECATION`.

Also add depcreated-at versions to documentation, and unify wording.

Ref: https://github.com/libssh2/libssh2/pull/1260#issuecomment-1837017987
Closes #1289
2023-12-16 17:43:02 +00:00
28dbf01667 add portable LIBSSH2_SOCKET_CLOSE() macro
Add `LIBSSH2_SOCKET_CLOSE()` to the public `libssh2.h` header, for user
code. It translates to `closesocket()` on Windows and `close()` on other
platforms.

Use it in example code.

It makes them more readable by reducing the number of `_WIN32` guards.

Closes #1278
2023-12-08 11:19:04 +00:00
b1414503f5 build: add LIBSSH2_NO_DEPRECATED option (#1266)
The following APIs have been deprecated for over 10 years and
use `LIBSSH2_NO_DEPRECATED` to mark them as deprecated:

libssh2_session_startup()
libssh2_banner_set()
libssh2_channel_receive_window_adjust()
libssh2_channel_handle_extended_data()
libssh2_scp_recv()

Add these options to disable them:
- autotools: `--disable-deprecated`
- cmake: `-DLIBSSH2_NO_DEPRECATED=ON`
- `CPPFLAGS`: `-DLIBSSH2_NO_DEPRECATED`

Fixes #1259
Replaces #1260
Co-authored-by: Viktor Szakats
Closes #1267
2023-12-06 00:14:53 +01:00
afa6b86560 build: enable missing OpenSSF-recommended warnings, with fixes
Ref:
https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html
(2023-11-29)

Enable new warnings:

- replace `-Wno-sign-conversion` with `-Wsign-conversion`.

  Fix them in example, tests and wincng. There remain about 360 of these
  warnings in `src`. Add a TODO item for those and disable `-Werror` for
  this particular warning.

- enable `-Wformat=2` for clang (in both cmake and autotools).

- enable `__attribute__((format))` for `_libssh2_debug()`,
  `_libssh2_snprintf()` and in tests for `run_command()`.

  `LIBSSH2_PRINTF()` copied from `CURL_TEMP_PRINTF()` in curl.

- enable `-Wimplicit-fallthrough`.

- enable `-Wtrampolines`.

Fix them:

- src: replace obsolete fall-through-comments with
  `__attribute__((fallthrough))`.

- wincng: fix `-Wsign-conversion` warnings.

- tests: fix `-Wsign-conversion` warnings.

- example: fix `-Wsign-conversion` warnings.

- src: fix `-Wformat` issues in trace calls.

  Also, where necessary fix `int` and `unsigned char` casts to
  `unsigned int` and adjust printf format strings. These were not
  causing compiler warnings.

  Cast large types to `long` to avoid dealing with printf masks for
  `size_t` and other C99 types. Existing code often used `int` for this.
  I'll update them to `long` in an upcoming commit.

- tests: fix `-Wformat` warning.

- silence `-Wformat-nonliteral` warnings.

- mbedtls: silence `-Wsign-conversion`/`-Warith-conversion`
  in external header.

Closes #1257
2023-12-03 01:32:20 +00:00
b136c37998 tidy-up: unsigned -> unsigned int
In the `interval` argument of public `libssh2_keepalive_config()`.

Tested via #1257
2023-12-02 09:53:56 +00:00
631e7734c8 libssh2.h: use _WIN32 for Windows detection instead of rolling our own
Sync up `libssh2.h` Windows detection with the libssh2 source code.

`libssh2.h` was using `WIN32` and `LIBSSH2_WIN32` for Windows detection,
next to the official `_WIN32`. After this patch it only uses `_WIN32`
for this. Also, make it stop defining `LIBSSH2_WIN32`.

There is a slight chance these break compatibility with Windows
compilers that fail to define `_WIN32`. I'm not aware of any obsolete
or modern compiler affected, but in case there is one, one possible
solution is to define this macro manually.

Closes #1238
2023-11-22 13:10:54 +00:00
481be044e0 revert: build: respect autotools DLL_EXPORT in libssh2.h
Revert fb1195cf88 #917

On a second look this change did not improve anything with autotools
builds. autotools seems to handle the dll export matter without it.

This patch also broke (e.g.) curl-for-win autotools builds, where the
curl build defines `DLL_EXPORT` while building libcurl DLL. `libssh2.h`
picks it up, resulting in unresolved symbols while trying to link a
static libssh2 on Windows. The best fix seems to be to revert this,
instead of adding extra tweaks to dependents.

Fixes:
https://ci.appveyor.com/project/curlorg/curl-for-win/builds/47667412#L11035
```
ld.lld-15: error: undefined symbol: __declspec(dllimport) libssh2_session_block_directions
>>> referenced by vssh/.libs/libcurl_la-libssh2.o:(ssh_do)
>>> referenced by vssh/.libs/libcurl_la-libssh2.o:(ssh_connect)
>>> referenced by vssh/.libs/libcurl_la-libssh2.o:(ssh_multi_statemach)
>>> referenced 8 more times

ld.lld-15: error: undefined symbol: __declspec(dllimport) libssh2_session_init_ex
>>> referenced by vssh/.libs/libcurl_la-libssh2.o:(ssh_connect)

ld.lld-15: error: undefined symbol: __declspec(dllimport) libssh2_session_set_read_timeout
[...]
```

Closes #1141
2023-07-29 23:52:33 +00:00
f6aa31f48f provide SPDX identifiers
- All files have prominent copyright and SPDX identifier
- If not embedded in the file, in the .reuse/dep5 file
- All used licenses are in LICENSES/ (not shipped in tarballs)
- A new REUSE CI job verify that all files are OK

Assisted-by: Viktor Szakats

Closes #1084
2023-06-07 08:18:55 +02:00
187d89bb07 copyright: remove years from copyright headers
Also:
- uppercase `(C)`.
- add missing 'All rights reserved.' lines.
- drop duplicate 'Author' lines.
- add copyright headers where missing.
- enable copyright header check in checksrc.

Reasons for deleting years (copied as-is from curl):
- they are mostly pointless in all major jurisdictions
- many big corporations and projects already don't use them
- saves us from pointless churn
- git keeps history for us
- the year range is kept in COPYING

Closes #1082
2023-06-04 19:19:16 +00:00
e800038cb9 libssh2.h: bump to 1.11.1_DEV [ci skip] 2023-05-30 23:12:40 +00:00
1c3f1b7da5 libssh2.h: bump to 1.11.0 for release 2023-05-30 17:58:13 +02:00
a683133dfe tidy-up: C header use
- drop unused or duplicate C headers.
- add missing ones (that worked by chance).
  (`string.h`, `stdlib.h`)
- mention the functions that need certain headers.
- move some headers from crypto header to crypto C source.
- reorder headers in some places.
- simplify the #if tree for `sys/select.h` in `libssh2_priv.h`.
- move scp-specific macros next to their header to `scp.c`
  Follow-up to 5db836b2a8

Closes #999
2023-04-27 14:27:17 +00:00
bc4e619e76 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
2023-04-22 10:54:20 +02:00
a4544c0117 channel: add support for "signal" message
Can send specific signals to remote process. Allows for slightly
improved remote process management, if the server supports it.

Integration-patches-by: Viktor Szakats

* doc updates
* change `signame_len` to `size_t`
* variable scopes
* fix checksrc warnings

Closes #672
Closes #991
2023-04-20 21:51:29 +00:00
739e41bf40 switch to internal base64 decode that uses size_t
Make the public `libssh2_base64_decode()` a wrapper for that.
Bump up length sizes in callers.

Also fix output size calculation to first divide then multiply.

Closes #978
2023-04-17 14:30:51 +00:00
0a500b3554 scp: option to not quote paths (#803)
A new flag named `LIBSSH2_FLAG_QUOTE_PATHS` has been added, to make
libssh2 not quote file paths sent to the remote's scp subsystem. Some
custom ssh daemons cannot handle quoted paths, and this makes this flag
useful.

Authored-by: Jörgen Sigvardsson <jorgen.sigvardsson@westermo.com>
2023-04-15 18:11:19 +02:00
6dc42e9d62 Make OS/400 implementation work again (#953)
* os400: support QADRT development files in a non-standard directory

This enables the possibility to compile libssh2 even if the ascii
runtime development files are not installed system-wide.

* userauth_kbd_packet: fix a pointer target type mismatch.

A temporary variable matching the parameter type is used before copying
to the real target and checking for overflow (that should not occur!).

* os400qc3: move and fix big number procedures

A bug added by a previous code style cleaning is fixed.
_libssh2_random() now checks and return the success status.

* os400qc3: fix cipher definition block lengths

They were wrongly set to the key size.

* Diffie-Hellman min/max modulus sizes are dependent of crypto-backend

In particular, os400qc3 limits the maximum group size to 2048-bits.
Move definitions of these parameters to crypto backend header files.

* kex: return an error if Diffie-Hellman key pair generation fails

* os400: add an ascii assert.h header file

* os400qc3: implement RSA SHA2 256/512
2023-04-13 14:08:12 +02:00
224fffb178 include: delete leading underscore from macro name
It can cause compiler warnings in 3rd-party code.

Follow-up to 59666e03f0

Closes #957
2023-04-13 11:09:35 +00:00
73d95a055c build: be friendly with 3rd-party build tools
After recent build changes, 3rd party build that took the list of
C source to compile them as-is, stopped working as expected, due to
`blowfish.c` and crypto-backend C sources no longer expected to compile
separately but via `bcrypt_pbkdf.c` and `crypto.c`, respectively.

This patch ensures that compiling these files directly result in an
empty object instead of redundant code and duplicated symbols.

Also:
- add a compile-time error if none of the supported crypto backends
  are enabled.
- fix `libssh2_crypto_engine()` for wolfSSL and os400qc3.
  Rearrange code to avoid a hard-to-find copy of crypto-backend
  selection guards.

Follow-up to 4f0f4bff5a
Follow-up to ff3c774e03

Closes #951
2023-04-12 09:17:10 +00:00
504026262d include: indentation fixes 2023-04-11 02:33:45 +02:00
fe706697ed Support for direct-streamlocal@openssh.com UNIX socket connection (#945)
This patch allow to use direct-streamlocal service from OpenSSH 6.7,
that allows UNIX socket connections.

Mods:
- delete unrelated condition:
  Ref: https://github.com/libssh2/libssh2/pull/216#discussion_r374748111
- rebase on master, whitespace updates.

Patch-by: @gjalves Gustavo Junior Alves

Closes #216
Closes #632
Closes #945
2023-04-10 14:23:17 +02:00
8017592163 cmake: add HIDE_SYMBOLS option & do symbol hiding on *nix
- implement symbol hiding on non-Windows platforms.

  The essence of the detection logic was copied from:
  dfabe8bca2/CMake/CurlSymbolHiding.cmake

  Then simplified and shortened. This method doesn't require a recent
  CMake version, nor an external, auto-generated C header.

  Move `configure_file()` after `set(LIBSSH2_API ...)`, for the config
  file to pick up `LIBSSH2_API`s value.

  Closes #602

- add CMake option `HIDE_SYMBOLS`.

  This setting means to hide non-public functions from the libssh2
  dynamic library when set to `ON`. The default.

  When set to `OFF`, make all non-static/internal functions visible
  in the dynamic library.

  This setting requires `BUILD_SHARED_LIBS=ON`.

- honor this setting on Windows.

  By setting the `LIBSSH2_EXPORTS` manual macro again, and stop
  recognizing the automatic CMake macro for this purpose:
  `libssh2_shared_EXPORT`.

Closes #939
2023-04-09 10:13:43 +00:00
59666e03f0 build: hand-crafted config rework & header tidy-up
- introduce the concept of a project level setup header
  `src/libssh2_setup.h`, that is used by `src`, `example` and `tests`
  alike. Move there all common platform/compiler configuration from
  `src/libssh2_priv.h`, individual sources and `CMakeFiles.txt` files.
  Also move there our hand-crafted (= not auto-generated by CMake or
  autotools) configuration `win32/libssh2-config.h`.

- `win32` directory is empty now, delete it.

- `Makefile.mk`: adapt to the above. Build-directory is the target
  triplet, or any custom name set via `BLD_DIR`.

- sync header path order between build systems:
  build/src -> source/src -> source/include

- delete redundant references to `windows.h`, `winsock2.h`,
  `ws2tcpip.h`.

- delete unnecessary #includes, update order (`libssh2_setup.h` first,
  `winsock2.h` first), simplify where possible.

  This makes the code warning-free without `WIN32_LEAN_AND_MEAN`.
  At the same time this patch applies this macro globally, to avoid
  header bloat.

- example: add missing *nix header guards.

- example: fix misindented `HAVE_UNISTD_H` `#ifdef`s.

- set `WIN32` with all build-tools.

- set `HAVE_SYS_PARAM_H` in the hand-crafted config for MinGW.
  To match auto-detection.

- move a source-specific macro to `misc.c` from `libssh2_priv.h`.

See the PR's individual commits for step-by-step updates.

Closes #932
2023-04-07 23:44:43 +00:00
c20c81ab10 Configurable session read timeout (#892)
This set of changes provides a mechanism to runtime-configure the
previously #define'd timeout for reading packets from a session. The
intention here is to also extend libcurl to be able to use this
interface so that when fetching from sftp servers which are very slow
to return directory listings, connections do not time-out so much.

* Add new field to session to hold configurable read timeout

* Updated `_libssh2_packet_require()`, `_libssh2_packet_requirev()`,
  and `sftp_packet_requirev()` to use new field in session structure

* Updated docs for API functions to set/get read timeout field in
  session structure

* Updated `libssh2.h` to declare the get/set read timeout functions

Co-authored-by: Jon Axtell <jon.axtell@codethink.co.uk>
Credit: Daniel Silverstone
2023-04-05 15:53:53 +02:00
d709e3f9d0 libssh2.h: bump LIBSSH2_COPYRIGHT year [ci skip] 2023-04-04 17:52:10 +00:00
fb1195cf88 build: respect autotools DLL_EXPORT in libssh2.h
The `DLL_EXPORT` macro is automatically set by autotools when building
the libssh2 DLL. Certain toolchains might require this to correctly
export symbols, so make sure to respect it in `libssh2.h` to enable
`declspec(dllexport)`.

With this patch we have a manual macro for that (`LIBSSH2_EXPORT`),
this autotools one, the CMake one, and `_WINDLL` (added in
c355d31ff9), possibly defined by Visual
Studio.

Closes #917
2023-04-02 03:24:39 +00:00
84f5cb9f23 netware: delete support (#888)
Last related commit happened 15 years ago.
NetWare had it last release in 2009.

All links referenced from the make file are inaccessible.
2023-03-29 02:09:30 +02:00
1d9af00609 tidy-up: fix typos (#886)
detected by codespell 2.2.4.
2023-03-27 19:26:58 +02:00
bd078e12bd cmake: automatic exports macro tidy-up (#875)
In a recent CMake update I left the original CMake EXPORTS macro
unchanged (`libssh2_EXPORTS`) for compatibility.

However, that macro was also recently added [1] and not present in an
official release yet, so we might as well just use the new native one
instead (`libssh2_shared_EXPORTS`), defined by CMake automatically.
This way we don't need to define the old macro manually.

CMake forms this macro from the lib's internal name as defined in
`add_library()` by appending `_EXPORTS`. That target name changed from
`libssh2` to `libssh2_shared` after introducing dual shared + static
builds in the recent update.

If we're here, add a new, stable, build-tool agnostic macro with the
same effect, for non-CMake use: `LIBSSH2_EXPORTS`

[1] 1f0fe7443a (2021-10-26)

Follow-up to 4e2580628d
2023-03-24 03:29:46 +01:00
2addafb77b build fixes and improvements (mostly for Windows)
- in `hostkey.c` check the result of `libssh2_sha256_init()` and
  `libssh2_sha512_init()` calls. This avoid the warning that we're
  ignoring the return values.

- fix code using `int` (or `SOCKET`) for sockets. Use libssh2's
  dedicated `libssh2_socket_t` and `LIBSSH2_INVALID_SOCKET` instead.

- fix compiler warnings due to `STATUS_*` macro redefinitions between
  `ntstatus.h` / `winnt.h`. Solve it by manually defining the single
  `STATUS` value we need from `ntstatus.h` and stop including the whole
  header.
  Fixes #733

- improve Windows UWP/WinRT builds by detecting it with code copied
  from the curl project. Then excluding problematic libssh2 parts
  according to PR by Dmitry Kostjučenko.
  Fixes #734

- always use `SecureZeroMemory()` on Windows.

  We can tweak this if not found or not inlined by a C compiler which
  we otherwise support. Same if it causes issues with UWP apps.

  Ref: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa366877(v=vs.85)
  Ref: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlsecurezeromemory

- always enable `LIBSSH2_CLEAR_MEMORY` on Windows. CMake and
  curl-for-win builds already did that. Delete `SecureZeroMemory()`
  detection from autotools' WinCNG backend logic, that this
  setting used to depend on.

  TODO: Enable it for all platforms in a separate PR.
  TODO: For clearing buffers in WinCNG, call `_libssh2_explicit_zero()`,
        insead of a local function or explicit `SecureZeroMemory()`.

- Makefile.inc: move `os400qc3.h` to `HEADERS`. This fixes
  compilation on non-unixy platforms. Recent regression.

- `libssh2.rc`: replace copyright with plain ASCII, as in curl.

  Ref: curl/curl@1ca62bb
  Ref: curl/curl#7765
  Ref: curl/curl#7776

- CMake fixes and improvements:

  - enable warnings with llvm/clang.
  - enable more comprehensive warnings with gcc and llvm/clang.
    Logic copied from curl:
    233810bb5f/CMakeLists.txt (L131-L148)
  - fix `Policy CMP0080` CMake warning by deleting that reference.
  - add `ENABLE_WERROR` (default: `OFF`) option. Ported from curl.
  - add `PICKY_COMPILER` (default: `ON`) option, as known from curl.

    It controls both the newly added picky warnings for llvm/clang and
    gcc, and also the pre-existing ones for MSVC.

- `win32/GNUmakefile` fixes and improvements:

  - delete `_AMD64_` and add missing `-m64` for x64 builds under test.
  - add support for `ARCH=custom`.
    It disables hardcoded Intel 64-bit and Intel 32-bit options,
    allowing ARM64 builds.
  - add support for `LIBSSH2_RCFLAG_EXTRAS`.
    To pass custom options to windres, e.g. in ARM64 builds.
  - add support for `LIBSSH2_RC`. To override `windres`.
  - delete support for Metrowerks C. Last released in 2004.

- `win32/libssh2_config.h`: delete unnecessary socket #includes

  `src/libssh2_priv.h` includes `winsock2.h` and `ws2tcpip.h` further
   down the line, triggered by `HAVE_WINSOCK2_H`.

  `mswsock.h` does not seem to be necessary anymore.

  Double-including these (before `windows.h`) caused compiler failures
  when building against BoringSSL and warnings with LibreSSL. We could
  work this around by passing `-DNOCRYPT`. Deleting the duplicates
  fixes these issues.

  Timeline:
  2013: c910cd382d deleted `mswsock.h` from `src/libssh2_priv.h`
  2008: 8c43bc52b1 added `winsock2.h` and `ws2tcpip.h` to `src/libssh2_priv.h`
  2005: dc4bb1af96 added the now deleted #includes

- delete or replace `LIBSSH2_WIN32` with `WIN32`.

- replace hand-rolled `HAVE_WINDOWS_H` macro with `WIN32`. Also delete
  its detections/definitions.

- delete unused `LIBSSH2_DARWIN` macro.

- delete unused `writev()` Windows implementation

  There is no reference to `writev()` since 2007-02-02, commit
  9d55db6501.

- fix a bunch of MSVC / llvm/clang / gcc compiler warnings:

  - `warning C4100: '...': unreferenced formal parameter`
  - using value of undefined PP macro `LIBSSH2DEBUG`
  - missing void from function definition
  - `if()` block missing in non-debug builds
  - unreferenced variable in non-debug builds
  - `warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]`
    in `_libssh2_debug()`
  - `warning C4295: 'ciphertext' : array is too small to include a terminating null character`
  - `warning C4706: assignment within conditional expression`
  - `warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or
      define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings`
    By suppressning it. Would be best to use inet_pton() as suggested.
    On Windows this needs Vista though.
  - `warning C4152: nonstandard extension, function/data pointer conversion in expression`
    (silenced locally)
  - `warning C4068: unknown pragma`

  Ref: https://ci.appveyor.com/project/libssh2org/libssh2/builds/46354480/job/j7d0m34qgq8rag5w

Closes #808
2023-03-03 13:30:03 +00:00
ed439a29bb Support for sk-ecdsa-sha2-nistp256 and sk-ssh-ed25519 keys, FIDO (#698)
Notes:
Add support for sk-ecdsa-sha2-nistp256@openssh.com and sk-ssh-ed25519@openssh.com key exchange for FIDO auth using the OpenSSL backend. Stub API for other backends.

Credit:
Michael Buckley
2022-09-29 09:05:34 -07:00
83853f8aea Use modern API in userauth_keyboard_interactive() (#663)
Files: userauth_kbd_packet.c, userauth_kbd_packet.h, test_keyboard_interactive_auth_info_request.c, userauth.c

Notes:
This refactors `SSH_MSG_USERAUTH_INFO_REQUEST` processing in `userauth_keyboard_interactive()` in order to improve robustness, correctness and readability or the code.

* Refactor userauth_keyboard_interactive to use new api for packet parsing
* add unit test for userauth_keyboard_interactive_parse_response()
* add _libssh2_get_boolean() and _libssh2_get_byte() utility functions

Credit:
xalopp
2022-02-19 15:46:40 -08:00
de7a74aff2 Legacy Agent support for rsa2 key upgrading/downgrading #659 (#662)
Files: libssh2.h, agent.c, userauth.c

Notes:
Part 2 of the fix for #659. This adds rsa key downgrading for agents that don't support sha2 upgrading. It also adds better trace output for debugging/logging around key upgrading.

Credit:
Will Cosgrove (signed off by Michael Buckley)
2022-01-14 11:55:18 -08:00
d5ed0e6536 ssh: Add support for userauth banner.
The new libssh2_userauth_banner API allows to get an optional
userauth banner sent with SSH_MSG_USERAUTH_BANNER packet by the
server.

Closes #610
2022-01-13 15:35:29 +01:00
e24a4a9d48 Runtime engine detection with libssh2_crypto_engine() (#643)
File:
version.c, HACKING-CRYPTO, libssh2.h, libssh2_crypto_engine.3, makefile.

Notes:
libssh2_crypto_engine() API to get crypto engine at runtime.

Credit: Bastien Durel
2022-01-06 10:06:02 -08:00
64a555d6f5 RSA SHA2 256/512 key upgrade support RFC 8332 #536 (#626)
Notes:
* Host Key RSA 256/512 support #536
* Client side key hash upgrading for RFC 8332
* Support for server-sig-algs, ext-info-c server messages
* Customizing preferred server-sig-algs via the preference LIBSSH2_METHOD_SIGN_ALGO

Credit: Anders Borum, Will Cosgrove
2022-01-06 09:50:58 -08:00
1f0fe7443a Use libssh2_EXPORTS as an alternative to _WINDLL (#470)
Files: libssh2.h

Notes:
`_WINDLL` is only defined when a Visual Studio CMake generator is used, `libssh2_EXPORTS` is used though for all CMake generator if a shared libssh2 library is being built.

Credit:
Uwe L. Korn
2021-10-26 09:21:56 -07:00