Commit Graph

603 Commits

Author SHA1 Message Date
Dmitry Podgorny
3063d886bd sasl: remove unused argument
_add_key() is a static function which is used only for DIGEST_MD5. Its
argument 'len' is not used and remains 0. Remove it.
2020-03-31 18:58:36 +03:00
Oleg Synelnykov
198bdd77d0 Remove -Wno-unused-parameter
Introduced UNUSED macro with cast to void in commoh.h for internal
use. Used cast to void directly in those files which do not
include common.h. Although this change doesn't fix semantic issues
with unused function parameters, it does explicitly mark all those
places, which might require attention in future.
2020-03-31 17:37:12 +03:00
Dmitry Podgorny
20c039fdb8 sock: replace sockaddr with sockaddr_storage
sockaddr structure may be insufficient to hold IPv6 address. Replace it
with sockaddr_storage structure.

Fixes #153.
2020-03-31 16:29:09 +03:00
Dmitry Podgorny
c92fc849e7 Remove C++ files
Libstrophe used to provide incomplete C++ API which missed connection
class and wasn't supported for a long time. Remove this API.
2020-02-22 23:19:40 +02:00
Dmitry Podgorny
6fdac3ae72 tests/sha512: add test case for a million of a 2020-01-31 01:59:42 +02:00
Dmitry Podgorny
623ff164de tests/scram: add HMAC test vector
Add test for HMAC and make other tests independent from SHA1.
2020-01-31 01:59:42 +02:00
Dmitry Podgorny
faa46d28a5 scram: fix HMAC-SHA-512
HMAC was originally implemented for SHA1 digest according to RFC2104.
The RFC defined blocksize for all digests as 64 bytes. But RFC4868
requires blocksize for SHA384/SHA512 to be 128 bytes.

Extend HMAC implementation to support variable blocksize and fix it for
SHA384/SHA512.
2020-01-31 01:59:42 +02:00
Dmitry Podgorny
1ca10fd167 Fix SASL SCRAM implementation
* Add SCRAM_DIGEST_SIZE macro for maximum possible digest size. It will
  avoid new buffer overflow errors when new digests are added.
* Fix buffer overflow in sasl_scram(). Buffers were allocated for SHA1
  digest size.
* Fix bug with handler re-registration when a SASL SCRAM mechanism
  fails.
2020-01-31 01:59:42 +02:00
Steffen Jaeckel
709e41fd10 add SHA256&SHA512 tests 2020-01-31 01:59:42 +02:00
Steffen Jaeckel
771d5865ae add SCRAM-SHA-256 and SCRAM-SHA-512 support 2020-01-31 01:59:42 +02:00
Steffen Jaeckel
fc064bc883 re-factor SCRAM to be independent of the hash 2020-01-31 01:34:23 +02:00
Steffen Jaeckel
2ca2fcfedd add stripped-down & slightly-modified version of LibTomCrypt SHA512 2020-01-31 01:34:09 +02:00
Steffen Jaeckel
d78b02ee24 add stripped-down & slightly-modified version of LibTomCrypt SHA256 2020-01-31 01:33:51 +02:00
Steffen Jaeckel
2a94a49cef add required LibTomCrypt load/store functions 2020-01-31 01:32:45 +02:00
Dmitry Podgorny
562a06425b Unify coding style
@sjaeckel integrated clang-format with formal coding style. Run his
script and commit changes.

There are pros and cons of this commit.

Mixed coding style is a "broken window". A good single style simplifies
reading and writing code.

On the other hand, this is a big change which will lead to conflicts.
2020-01-31 01:16:50 +02:00
Steffen Jaeckel
eef07cef36 add code style check to travis 2020-01-31 01:14:32 +02:00
Steffen Jaeckel
2e21d5a021 add new format make target 2020-01-31 01:14:32 +02:00
Steffen Jaeckel
abd1b08a97 trim trailing spaces 2020-01-31 01:14:32 +02:00
Steffen Jaeckel
3feed16e2e ignore eclipse related stuff 2020-01-31 01:14:32 +02:00
Dmitry Podgorny
6b38216124 util: replace time_stamp() implementation
Replace Windows/Xbox implementation with solution from NetXMS project.
2020-01-26 00:52:54 +02:00
Dmitry Podgorny
8cfb2d2a03 XEP-0077: add examples/register
XEP-0077 will not be implemented as part of libstrophe's API, but an
example is provided. The example shows how to use the "raw" connection
to register a user.

Closes #54.
2020-01-25 22:59:19 +02:00
Michael Vetter
1b10e8f987 resolver: include headers for select(2)
C-ares implementation uses select(2) but doesn't include required
headers.

Fixes #149.
2020-01-25 22:06:07 +02:00
Dmitry Podgorny
178f566ae2 Unify include of strophe.h 2020-01-10 01:28:47 +02:00
Dmitry Podgorny
0326e5c5e2 handler: avoid unnamed union
Unnamed unions appeared only in C11 standard. Don't use them to
increase portability.
2020-01-10 01:22:53 +02:00
Dmitry Podgorny
212df6d036 tests: add test for stanza functions
Check reference counting in xmpp_stanza_add_child() amd
xmpp_stanza_add_child_ex().
2020-01-10 00:50:22 +02:00
Dmitry Podgorny
4b04db6b2d stanza: add xmpp_stanza_add_child_ex()
This function is introduced by NetXMS project.
2020-01-10 00:49:45 +02:00
Dmitry Podgorny
fb327d4bd1 parser/expat: provide memory handling suite for 1 ctx
Libstrophe doesn't override memory allocation functions in XML libraries
and default allocators are used as result.

Current patch solves this issue partially for expat module. The module
caches 1st strophe context and overrides expat's allocator for parsers
within this context. For all other contexts, fallback to default
allocator.

This is modified version of solution from UnrealEngine project.
2020-01-07 22:45:15 +02:00
Dmitry Podgorny
a811c868ff util: add time_stamp() implementation for XBOX
Backported from UnrealEngine project.
2020-01-07 22:24:10 +02:00
Dmitry Podgorny
3f05bafffb event: move buffer size to a macro
Move buffer size for incoming messages to a macro. So it can be changed
in one place.
2020-01-07 22:20:12 +02:00
Dmitry Podgorny
133abd096d conn: disconnect if user destroys an active connection object
Backported from UnrealEngine project.
2020-01-07 22:16:11 +02:00
Dmitry Podgorny
cecd6b20e8 stanza: add xmpp_stanza_get_context()
This function is backported from UnrealEngine project.
2020-01-07 22:13:39 +02:00
Dmitry Podgorny
2272681ea2 conn: add state checking API
New boolean functions:
  xmpp_conn_is_connecting()
  xmpp_conn_is_connected()
  xmpp_conn_is_disconnected()

These functions are backported from UnrealEngine project.
2020-01-07 22:12:11 +02:00
Dmitry Podgorny
17f79cbbb8 auth: replace stricmp() with _stricmp()
Newer visual studios deprecate stricmp(). Replace it to fix compilation.
2020-01-07 00:24:57 +02:00
Dmitry Podgorny
2570084cae event: don't redefine error codes
Error codes can be defined in visual studio. Unconditional redefine
causes warnings.
2020-01-07 00:14:59 +02:00
Dmitry Podgorny
b2e6458736 autotools: check for snprintf and vsnprintf
src/snprinf.[ch] rely on HAVE_SNPRINTF macro. The check is missed in
configure script and libstrophe always use internal implementation
of snprinf() which may be inefficient. Add check to configure.ac.
2020-01-05 01:14:22 +02:00
Dmitry Podgorny
c192a2b181 md5: remove unused parameter 2020-01-05 00:30:11 +02:00
Dmitry Podgorny
2e325e5e68 tests/sha1: fix type mismatch warning 2020-01-05 00:28:01 +02:00
Manuel Kasper
f0436490b0 Enable SNI with OpenSSL 0.9.8f as well 2019-12-24 09:07:51 +01:00
Manuel Kasper
243664926f Enable TLS SNI 2019-12-23 14:34:19 +01:00
Dmitry Podgorny
466fa2adbf sha1: don't clean local variable i on exit
In this place value of variable i is constant and predictable. No point
to clean it. Furthermore, since the value is not used after assignment,
compiler will optimize and remove the assignment.

This patch fixes a warning from the clang static analyzer.
2019-11-10 16:04:17 +02:00
Dmitry Podgorny
284e8f4421 tls/openssl: check return code
Check return code of SSL_CTX_set_default_verify_paths() and fail TLS on
an error. However, ignore the error when XMPP_CONN_FLAG_TRUST_TLS is
set.
2019-11-10 15:57:23 +02:00
Dmitry Podgorny
6852da97ae ChangeLog: xmpp_stanza_get_child_by_name_and_ns() 2019-11-30 20:39:17 +02:00
Dmitry Podgorny
35f37e8c23 autotools: link against libm with manually detected libxml2
Fixes build on QNX.
2019-11-30 20:36:34 +02:00
Michael Vetter
cbe6701c14 Add xmpp_stanza_get_child_by_name_and_ns()
I think it's fairly common in the XMPP world to actually want a stanza
by it's NS but also want a certain name.

For example this was needed in Profanity:
68af0aad65
2019-11-25 13:58:05 +00:00
Dmitry Podgorny
296df2fca9 tls/openssl: don't use deprecated function in 1.1.0+
SSLv23_client_method() was deprecated in OpenSSL 1.1.0. It is left as
macro to TLS_client_method.
2019-11-25 13:45:51 +00:00
Dmitry Podgorny
7caf88a6a8 rand: avoid VLA in xmpp_rand_nonce()
Don't use additional buffer. Instead, use half of the output buffer.
2019-11-19 01:46:35 +02:00
Dmitry Podgorny
ebaad72a35 ChangeLog: mention recent changes 2019-11-19 01:11:56 +02:00
François Revol
962bf4de5e Haiku: skip -Wextra -Wno-unused-parameter for GCC 2.95
This is needed to compile for the primary arch.
2019-11-17 15:34:27 +01:00
François Revol
884dace400 Haiku: link with libnetwork 2019-11-17 14:29:24 +01:00
François Revol
234bef4025 Haiku: C89 2019-11-17 14:28:26 +01:00