1
0
mirror of https://github.com/wolfSSL/wolfssl.git synced 2026-10-24 04:09:07 +03:00

33 Commits

Author SHA1 Message Date
Tobias Frauenschläger
42636db290 Refuse application writes only after a fatal alert or close_notify
SendData() refused to write whenever options.isClosed was set, to stop
application data after a fatal alert (RFC 8446 Section 6.2). isClosed is
also set when the transport reports a plain EOF, so a server could no
longer answer a request whose client had already closed its socket.
The write failed without reaching the socket, which reports
SSL_ERROR_SYSCALL with a stale errno instead of EPIPE or ECONNRESET.
nginx logs that at crit level, which made the ssl_stapling.t "no crit"
check in the nginx CI fail intermittently.

Track a fatal alert, sent or received, in a new options.fatalAlert bit
and check that in SendData() instead. A transport EOF goes back to
letting the write reach the socket, as it did before.

Also refuse writes once our own close_notify has been sent, as OpenSSL
does. The isClosed check only caught that when an EOF happened to
arrive after the close_notify. The refused write sets
SSL_SHUTDOWN_ALREADY_DONE_E, which ReceiveData() clears, so the
application can still read the peer's remaining data and its
close_notify.

Session export writes fatalAlert as its own options byte. Export version
7 has not been in a release yet, so it takes the byte without a new
version number; version 7 blobs written by master before this change no
longer import. A version 6 blob only has isClosed, so the importer takes
it as the fatal alert state too, as SendData() did before.
2026-10-21 12:14:01 -07:00
philljj
3a45cc02e6 Merge pull request #11682 from padelsbach/byteray-med-x509
Compat layer: escape control characters in X509 print output
2026-10-15 09:42:49 -05:00
Juliusz Sosinowicz
797e34a271 Add WOLFSSL_CHAIN_VERIFY_CB to replace peer chain verification
Adds an opt-in callback that takes over the peer certificate trust
decision. wolfSSL builds no chain, verifies no signature and checks no
date, revocation status, key usage or host name; the verify callback is
not called either. The callback gets only the DER certificates from the
Certificate message as WOLFSSL_BUFFER_INFO entries, certs[0] first. It
is consulted even under WOLFSSL_VERIFY_NONE, and its rejection fails the
handshake either way.

wolfSSL still decodes every certificate with ParseCert(NO_VERIFY) before
the callback runs, so malformed DER fails the handshake and the callback
is never handed it. Content wolfSSL does not understand - an unknown
critical extension, an unsupported key or signature algorithm, a
signature algorithm mismatch - is not a decoding failure and is left for
the callback to judge. The check runs once, not again on re-entry after
a deferred verdict.

The callback may return CHAIN_VERIFY_WANT_E to suspend the handshake and
be asked again with the same certificates when the application re-enters
wolfSSL_connect(), wolfSSL_accept(), wolfSSL_read() or wolfSSL_write().
A certificate received after the handshake (TLS 1.3 post-handshake
authentication) arrives inside wolfSSL_read() and is resumed by reading
again: ReceiveData() re-enters on any handshake-suspend error, and the
ticket-sent accept state leaves a suspended message alone. Rejection
fails with CHAIN_VERIFY_CB_E and one bad_certificate alert, and sets
peerVerifyRet so wolfSSL_get_verify_result() does not report X509_V_OK.

Still applied: an empty Certificate message keeps the existing
mutual-auth policy (the callback is not called for it), and the minimum
peer key sizes still gate the peer's own key, which the handshake uses
directly.

DTLS, raw public keys and OCSP stapling are not supported with the
callback. wolfSSL_CTX_SetChainVerifyCb() and wolfSSL_SetChainVerifyCb()
refuse with CHAIN_VERIFY_UNSUPPORTED_E when the context or object is
already configured for one of them, and a connection that uses one of
them anyway fails with the same error and an internal_error alert before
the callback is called. The DTLS paths are otherwise untouched.

The callback and its user context can be set on the context or on the
SSL object, the object's taking precedence. The feature is part of
--enable-all, has a CMake option and Doxygen entries.

The suspend machinery is shared with WOLFSSL_NONBLOCK_OCSP and
WOLFSSL_ASYNC_CRYPT. The open-coded pairs of comparisons against
WC_PENDING_E and OCSP_WANT_READ are replaced by IsHsSuspendErr(), and the
matching build guards by WOLFSSL_HAVE_HS_SUSPEND. That also closes three
holes which affected WOLFSSL_NONBLOCK_OCSP builds:

 - DoHandShakeMsg() freed ssl->pendingMsg on a non-WC_PENDING_E suspend
   while ProcPeerCertArgs still pointed into it.
 - wolfSSL_connect()/wolfSSL_accept() and their TLS 1.3 counterparts
   called FreeAsyncCtx() when buffered output flushed, discarding the
   saved certificate state.
 - ProcessPeerCerts() XFREE'd args in WOLFSSL_SMALL_STACK builds without
   WOLFSSL_ASYNC_CRYPT, where args points inside ssl->async.
2026-10-13 05:24:59 +00:00
Paul Adelsbach
9600d4d895 Escape control characters in X509_print alt names 2026-10-12 16:26:56 -07:00
Kareem
cbe035a85b Ensure MTU is set properly when using SCTP with DTLS. Add return code checks and fix wolfSSL_shutdown handling in SCTP examples. 2026-09-15 11:26:06 -07:00
David Garske
517c45f2ed Add TLS 1.3 crypto callback pend tests and byte-stream test memio 2026-09-09 16:03:38 -07:00
David Garske
e1ff608876 Intel QAT: add async hybrid PQC server key share regression test 2026-07-07 09:54:04 -07:00
Daniel Pouzzner
c99567c96d Merge pull request #10596 from SparkiDev/regression_fixes_24
Regression testing fixes
2026-06-05 13:37:56 -05:00
Sean Parkinson
089f1f7c91 TLSv1.3 PSK binders: always use id protection
Removed WOLFSSL_PSK_ID_PROTECTION from use as it is now on by default.
Always check whether the server has a certificate (not a CA chain).
If there is a certificate then continue, otherwise, report a binder
error.

Added test to ensure binder error returned and alert sent when no
NO_CERT. test_tls13_bad_psk_binder already tested no certificate.

Allowed memio test harness to be built when NO_CERT is defined.
2026-06-05 11:16:48 +10:00
Sean Parkinson
26a2b793dc Regression testing fixes
1. Side-aware ML-KEM in TLS (tls.c, tls13.c, ssl.c, internal.h):
TLSX_IsGroupSupported/TLSX_UseSupportedCurve take a `side` arg; new
TLSX_IsMlKemGroupSupported + client/server support macros. A build only
capable of one ML-KEM op no longer advertises groups it can't use for
its role.

2. NO_ASN_TIME support (ssl_asn1.c, ssl.h, settings.h): data-only
ASN1_TIME APIs now compile without system time; OCSP responder
auto-disabled under NO_ASN_TIME.

3. SP ECC (sp_*.c, sp_x86_64_asm.asm): curve `b` constants and
sp_ecc_is_point_* always compiled (point-check available in more
configs); asm movsxd -> movsx.

4. configure.ac: BUILD_MEMUSE fixed to trigger on != "xno".

5. Test fixes: HRR-aware TLS 1.3 memio tests (new
test_memio_msg_is_hello_retry_request); tightened build guards
(Ed25519/Ed448 key-import, AES decrypt, XMSS heights, SP sizes,
static-PSK).
2026-06-04 18:29:24 +10:00
Juliusz Sosinowicz
003c0147d0 Refactor: Use XFILE for test memory I/O dumps 2026-03-31 12:42:15 +02:00
JacobBarthelmeh
a156ed7bc7 update Copyright year 2026-02-18 09:52:21 -07:00
David Garske
4d3925d526 Add X25519 non-blocking support for key gen and shared secret
## Summary
- Add non-blocking (incremental) Curve25519 key generation and shared secret via `WC_X25519_NONBLOCK`, modeled after the existing ECC non-blocking pattern (`WC_ECC_NONBLOCK`)
- Implement `curve25519_nb()` and `fe_inv__distinct_nb()` in `fe_low_mem.c` as state-machine variants that return `FP_WOULDBLOCK` to yield after each field multiply
- Add `wc_curve25519_set_nonblock()` API to attach/detach non-blocking context to a key
- Integrate X25519 non-blocking with TLS 1.2/1.3 key share generation and shared secret in `tls.c` and `internal.c` (behind `WC_X25519_NONBLOCK && WOLFSSL_ASYNC_CRYPT_SW`)
- Add `--enable-curve25519=nonblock` configure option (auto-enables `--enable-asynccrypt` and `--enable-asynccrypt-sw`)
- Add X25519 async software dispatch cases in `async.c` and types in `async.h`
- Fix async guard in `curve25519.c` to require `WOLFSSL_ASYNC_CRYPT_SW` (matching other algorithms)
- Overhaul `examples/async/` client/server: non-blocking I/O via `WOLFSSL_USER_IO`, standalone `Makefile`, X25519/ECC mode selection, CI-friendly ready-file sync
- Add `examples/configs/user_settings_curve25519nonblock.h` and CI coverage in `os-check.yml` and new `async-examples.yml` workflow
- Add wolfcrypt test and API test coverage for X25519 non-blocking
2026-02-04 21:28:52 -08:00
Sean Parkinson
0b2fb66af6 api.c: Split out more functions
wolfSSL_PEM, wolfSSL_X509, wolfSSL_X509_NAME, wolfSSL_X509_PUBKEY API
testing moved out to separate files.
2025-12-11 15:32:09 +10:00
Marco Oliverio
6855325bf8 test: memio: simulate_want_write: block client on is_client == true 2025-11-03 13:43:33 +01:00
Marco Oliverio
6b0e24eed2 test_memio: support WANT_WRITE simulation 2025-10-13 16:27:55 +02:00
Juliusz Sosinowicz
42238c57b7 Improve documentation and add comments to test_memio buffer utilities 2025-10-10 11:52:47 +02:00
Juliusz Sosinowicz
8233d0d8a2 test_memio_move_message: add docs 2025-10-08 16:20:39 +02:00
Juliusz Sosinowicz
6fbbdf9324 Add message order sanity checks
Reorganize test_dtls tests to use TEST_DECL_GROUP
Reorganize test_tls tests to use TEST_DECL_GROUP
2025-10-08 11:11:03 +02:00
Kareem
ec92f76dec Fix tests when building with PEM support disabled by using DER certs/keys. 2025-09-12 16:11:07 -07:00
Juliusz Sosinowicz
0d532cc3f2 Test DTLS replay protection 2025-08-07 19:52:05 +02:00
JacobBarthelmeh
629c5b4cf6 updating license from GPLv2 to GPLv3 2025-07-10 16:11:36 -06:00
Sean Parkinson
574de4b234 Memory allocation failure testing fixes
Fixes for test code to cleanup on failure properly.
pkcs7.c: when streaming, free the decrypting content when adding data to
the stream fails.
2025-07-01 11:50:42 +10:00
Marco Oliverio
23b73bb298 test_memio: preserve write boundaries in reads 2025-05-19 10:25:24 +02:00
Daniel Pouzzner
690bb14203 tests/utils.c and tests/api/test_dtls.c: fixes for include order, re tests/unit.h. 2025-02-14 10:57:29 -06:00
Juliusz Sosinowicz
e02da08192 Reorganize utility functions into tests/utils.c and testsuite/utils.c 2025-02-14 09:51:29 -06:00
Juliusz Sosinowicz
b32ff0b0b8 Rename utils.c to utils.h
This better signals that this file is meant to be included directly in testing programs and also plays better with my IDE.
2023-08-18 15:05:23 +02:00
Juliusz Sosinowicz
e96837aa34 cond: Add start and end API for mutex handling 2023-08-10 18:07:51 +02:00
David Garske
5b16586483 Fixes for wolfSSL conditional porting. Can cause deadlock in high usage situations. Added better signal support on MacOS. Issue created in PR #6437. 2023-08-08 12:46:42 -07:00
Juliusz Sosinowicz
67d6d438c5 Port testing to wolfSSL threading interface 2023-08-04 10:49:39 +02:00
Juliusz Sosinowicz
d3aa11bf87 Place manual memio helpers in utils.c and add macro for them 2023-07-24 09:14:21 +02:00
Daniel Pouzzner
648f474d83 configure.ac:
if ENABLED_LINUXKM_PIE, add -DWOLFSSL_NO_OCSP_ISSUER_CHECK to gate out backward dependency in asn.c;

  if ENABLE_LINUXKM, don't error on FIPS without thread_ls_on;

  for --enable-curl, set ENABLED_MD4="yes", and move --enable-md4 AC_ARG_ENABLE() clause up to a position adjacent to des3 handling;

scripts/sniffer-gen.sh: fix illegal exit code (SC2242);

src/internal.c: fix clang-analyzer-core.NonNullParamChecker in CreateTicket();

src/ocsp.c: fix readability-redundant-preprocessor;

src/tls.c: fix empty-body in TLSX_PskKeModes_Parse() and clang-diagnostic-unreachable-code-break in ALPN_Select();

tests/api.c: fix several clang-analyzer-core.NullDereference related to Expect*() refactor;

wolfcrypt/src/asn.c:

  fix -Wconversions in DecodeAuthKeyId() and ParseCertRelative();

  fix readability-redundant-declaration re GetCA() and GetCAByName();

  gate inclusion of wolfssl/internal.h on !defined(WOLFCRYPT_ONLY);

wolfssl/internal.h: add macro-detection gating around GetCA() and GetCAByName() prototypes matching gates in wolfcrypt/src/asn.c;

tests/utils.c: in create_tmp_dir(), use one-arg variant of mkdir() if defined(__CYGWIN__) || defined(__MINGW32__).
2023-07-12 13:47:40 -05:00
Juliusz Sosinowicz
d2642e329d Properly enforce the pathLenConstraint of the BasicConstraints extension
- move the testsuite file helps into a new tests/utils.c file so that they can be used across all tests
- dump the raw TLS stream when WOLFSSL_DUMP_MEMIO_STREAM is defined so that it can be examined in Wireshark
2023-07-06 19:00:11 +02:00