1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00
Commit graph

44 commits

Author SHA1 Message Date
Andy Green
946b1fbff1 coverity: 2021-12-1 uplevel fixes 2022-03-15 10:28:09 +00:00
Andy Green
7e841130e0 coverity fixes 2022-01-16 10:48:11 +00:00
Andy Green
270a14813f sshd: fix leak on disconnect
Disconnect wants to keep a copy of the description string, but it is never
freed.  Make it ephemeral just for the ->disconnect_reason() op so it is
cleaned out correctly.
2021-11-07 07:04:09 +00:00
Andy Green
095798d5d9 sshd: plugin: work with _BUILTIN
The sshd example has gotten crufted a few different ways.

Adapt the test-sshd protocol and callbacks to not collide with the plugin
ssh-demo exports, for BUILTIN case.

Do not build a static copy of ssh-base for test-sshd if PLUGINS_BUILTIN is
going to provide it via lws import.

Add pvo for ssh-base to enable it on to the test-sshd vhost.

Banner staging in buf[] shared some of source and dest when it was copied
in, move it up a bit to avoid this.

Add note about rsa key disable workaround on Fedora.

test-sshd uses CGI (and requires it enabled to build) because it predates
lws_spawn... lws cgi was migrated to lws_spawn, really the test=sshd needs
rewriting to use lws_spawn directly instead of cgi.
2021-11-07 07:04:09 +00:00
Jakov Smolić
252890d19c plugins: sshd: eg musl needs sys/types if available
https://github.com/warmcat/libwebsockets/issues/2477
2021-11-04 07:12:37 +00:00
Orefkov Aleksander
d1248188e0 pugins: sshd: handle window-change request
Added processing of window-change request, according to RFC 4254 6.7
https://datatracker.ietf.org/doc/html/rfc4254#section-6.7
For processing called callback pty_req with empty terminal and modes.
2021-10-19 15:39:53 +01:00
Orefkov Aleksander
2504eba456 plugins: sshd: channel fixes
In responses  with channel numbers, the sender's channel number is sent instead of the recipient's channel number.
See for example https://datatracker.ietf.org/doc/html/rfc4254#section-5.1
Putty uses channel 256 for session, and existing code break it with "Received SSH2_MSG_CHANNEL_OPEN_CONFIRMATION for nonexistent channel 0" error.
2021-10-19 10:50:09 +01:00
Orefkov Aleksander
4c5e7a37df plugins: sshd: mbedtls 3 extra adaptation
In fresh mbedtls rsa public decrypt is deprecated and not work on public keys.
Replaced by lws_genrsa_hash_sig_verify.
2021-10-19 10:50:01 +01:00
Orefkov Aleksander
e34e6fe263 plugins: sshd: sc25519 must handle last bit
This was originally commented because Coverity objected to it.
2021-10-19 06:38:45 +01:00
Andy Green
fabe78d222 Wextra
Add -Wextra (with -Wno-unused-parameter) to unix builds in addition to
-Wall -Werror.

This can successfully build everything in Sai without warnings / errors.
2021-07-04 10:29:54 +01:00
Andy Green
671ffe7063 plugins: ssh: xenial warning fixes 2021-02-28 17:07:51 +00:00
Andy Green
0e6df74409 plugins: add option LWS_WITH_PLUGINS_BUILTIN
Add the ability to just build plugins into the main library.
They are already designed to have a pinhole export for when
they are used as dynamic lib plugins so their namespace
does not conflict.
2021-01-31 20:24:29 +00:00
Andy Green
6497220e87 plugins: add LWS_BUILD_HASH to header and require match
Also prioritize LD_LIBRARY_PATH check for plugins first

Iterate through paths in LD_LIBRARY_PATH in order

Warn on failed plugins init but continue protocol init
2021-01-28 05:52:41 +00:00
Andy Green
c9731c5f17 type comparisons: fixes
This is a huge patch that should be a global NOP.

For unix type platforms it enables -Wconversion to issue warnings (-> error)
for all automatic casts that seem less than ideal but are normally concealed
by the toolchain.

This is things like passing an int to a size_t argument.  Once enabled, I
went through all args on my default build (which build most things) and
tried to make the removed default cast explicit.

With that approach it neither change nor bloat the code, since it compiles
to whatever it was doing before, just with the casts made explicit... in a
few cases I changed some length args from int to size_t but largely left
the causes alone.

From now on, new code that is relying on less than ideal casting
will complain and nudge me to improve it by warnings.
2021-01-05 10:56:38 +00:00
Andy Green
8d88d2f4f1 plugins: use new export symbol convention 2020-10-09 21:30:49 +01:00
Andy Green
d98101d1e3 plugins: generalize and provide public api
Move the common plugin scanning dir stuff to be based on lws_dir, which
already builds for windows.  Previously this was done via dirent for unix
and libuv for windows.

Reduce the dl plat stuff to just wrap instantiation and destruction of
dynlibs, establish common code in lib/misc/dir.c for plugin scanning
itself.

Migrate the libuv windows dl stuff to windows-plugins.c, so that he's
available even if later libuv loop support becomes and event lib plugin.

Remove the existing api exports scheme for plugins, just export a const struct
now which has a fixed header type but then whatever you want afterwards depending
on the class / purpose of the plugin.  Place a "class" string in the header so
there can be different kinds of plugins implying different types exported.

Make the plugin apis public and add support for filter by class string, and
per instantation / destruction callbacks so the subclassed header type can
do its thing for the plugin class.  The user provides a linked-list base
for his class of plugins, so he can manage them completely separately and
in user code / user export types.

Rip out some last hangers-on from generic sessions / tables.

This is all aimed at making the plugins support general enough so it can
provide event lib plugins later.
2020-08-31 16:51:37 +01:00
Andy Green
0bfd39135e cleaning 2020-01-05 22:17:58 +00:00
Andy Green
26319663f7 license: switch LGPLv2.1+SLE parts to MIT 2019-08-14 10:44:38 +01:00
Andy Green
d41e0f8f7c sshd: explicitly transfer free responsibility when adopting last_alloc 2019-03-10 08:02:02 +08:00
Andy Green
eda102e397 jwe 2018-12-27 06:45:32 +08:00
Andy Green
a3dcc95471 genec: generic ECDH crypto layer
!!! WIP

This implements the "genec" layer wrapping mbedtls + openssl
ECDH support.

API tests are added for the parts that are implemented so far.

Stuff related to ec at all, like keys, are prefixed lws_genec_.
Stuff specific to ECDH are prefixed lws_genecdh_.
2018-12-27 06:45:31 +08:00
Andy Green
47e14ba34b genrsa: add OAEP and PSS and convert openssl to EVP
Wanting PSS padding on signatures triggers and avalanche of
openssl EVP conversions as the only way to do it with the
openssl public apis.
2018-12-27 06:45:31 +08:00
Andy Green
ddb94d4e27 genaes: generic AES layer independent of tls library
Although RSA can be used directly for signing / JWS
on large chunks of data since it's only operating on
the hash, when JWE support arrives, which allows bulk
encryption, it's going to be mandatory to support
secondary AES ciphers to use on the bulk data.

This adds generic support for all AES modes that OpenSSL
and mbedTLS have in common, works on both mbedTLS and
OpenSSL the same, and adds unit tests for each mode
in api-test-gencrypto, to run in CI.
2018-12-27 06:45:31 +08:00
Andy Green
440dacc992 JOSE: refactor and prepare for JWE
Until now the JOSE pieces only had enough support for ACME.
This patch improves the JWK parsing to prepare for more
complete support and for adding JWE, genaes and genec in
later patches.
2018-12-27 06:45:31 +08:00
Andy Green
33a6034875 codacy: minor fixes 2018-10-13 08:16:27 +08:00
Andy Green
d461f46a97 libwebsockets.h: clean out some boilerplate better put in core/private.h
https://github.com/warmcat/libwebsockets/issues/1370
2018-08-16 19:10:32 +08:00
Andy Green
db6976992d sshd: make sure no aliases on last_alloc 2018-06-07 09:41:36 +08:00
Andy Green
c4f4b5c3c4 sshd: fix timingsafe_bcmp
https://github.com/warmcat/libwebsockets/issues/1288
2018-05-23 17:24:42 +08:00
Andy Green
16e2f09710 refactor mode and states into roles and states 2018-04-06 12:22:19 +08:00
Andy Green
e9931680c8 sshd: fixes 2018-04-06 10:44:02 +08:00
Andy Green
aae2c24678 lws_snprintf 2018-03-12 09:28:42 +08:00
Andy Green
46f10cade7 gcc 8: fixes for warnings on sshd.c 2018-03-08 09:01:10 +08:00
Andy Green
b94091130b sshd: support async exec or shell close 2017-12-27 10:02:34 +08:00
Andy Green
8ff7dce46d sshd: protect against NULL kex 2017-12-08 06:26:54 +08:00
Andy Green
79d2038fdf esp32 fixes
This add support for a platform socketfd offset.
2017-12-01 11:37:35 +08:00
Andy Green
be525cb624 appveyor: Enable 64-bit build with OpenSSL and HTTP2
Fix warnings found from that

Introduce lws_ptr_diff(head, tail) helper to normalize
pointers to char *, do the subtraction and cast the
result to int.
2017-11-26 19:16:17 +08:00
Andy Green
c32a22c20b lws-genrsa: add resuable backend-independent rsa decrypt in tls/ and migrate sshd to it 2017-11-10 16:56:44 +08:00
Andy Green
c7b536764f coverity-fixes 2017-11-10 10:59:58 +08:00
Andy Green
491fd183f8 lws_timingsafe_bcmp 2017-10-28 13:24:41 +08:00
Andy Green
1c70181ca2 build: enable signed vs unsigned warnings on gcc
This enables selected things from -Wextra, can't use -Wextra because it is
fussy enough to complain about unused params on functions... they are
there for a reason.

-Wsign-compare
-Wignored-qualifiers
not -Wimplicit-fallthrough=3 ... only on gcc 7
-Wtype-limits
-Wuninitialized
not -Wclobbered ... only on gcc 7ish

fix the warnings everywhere they were found.
2017-10-25 07:17:29 +08:00
Andy Green
89cb55ea58 tls: split out common, openssl and mbedtls code
- introduce lib/tls/mbedtls lib/tls/openssl
 - move wrapper into lib/tls/mbedtls/wrapper
 - introduce private helpers to hide backend

This patch doesn't replace or remove the wrapper, it moves it
to lib/tls/mbedtls/wrapper.

But it should be now that the ONLY functions directly consuming
wrapper apis are isolated in

  - lib/tls/mbedtls/client.c (180 lines)
  - lib/tls/mbedtls/server.c (317 lines)
  - lib/tls/mbedtls/ssl.c    (325 lines)

In particular there are no uses of openssl or mbedtls-related
constants outside of ./lib/tls any more.
2017-10-25 07:17:29 +08:00
Andy Green
001b3010a6 sshd: fix NULL vhd protection 2017-10-19 11:26:29 +08:00
Andy Green
fc995df480 CMake: convert all LWS_USE_... to LWS_WITH_...
Almost all the CMake options begin with LWS_WITH_..., but many of the
symbols passed to lws are LWS_USE_... , this causes neededless confusion,
compounded by the fact that a few CMake options also begin with
LWS_USE_.

This patch globally converts all LWS_USE_... to LWS_WITH_..., so there
is only one prefix to remember in both CMake and the code.

The affected public CMake options are

LWS_USE_BORINGSSL     ->  LWS_WITH_BORINGSSL
LWS_USE_CYASSL        ->  LWS_WITH_CYASSL
LWS_USE_WOLFSSL       ->  LWS_WITH_WOLFSSL
LWS_USE_MBEDTLS       ->  LWS_WITH_MBEDTLS
LWS_USE_BUNDLED_ZLIB  ->  LWS_WITH_BUNDLED_ZLIB
2017-10-16 17:13:48 +08:00
Andy Green
7597ac3766 Plugins: add ssh-base ssh server plugin 2017-10-16 16:59:57 +08:00