]> git.ipfire.org Git - thirdparty/openssl.git/log
thirdparty/openssl.git
5 months agoRemove SSL_TOKEN_STORE_HANDLE type
Neil Horman [Fri, 31 Jan 2025 13:02:34 +0000 (08:02 -0500)] 
Remove SSL_TOKEN_STORE_HANDLE type

Replace it with SSL_TOKEN_STORE and make the structure opaque in the
public api

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoModify ossl_quic_get_peer_token to return QUIC_TOKEN
Neil Horman [Thu, 30 Jan 2025 19:38:18 +0000 (14:38 -0500)] 
Modify ossl_quic_get_peer_token to return QUIC_TOKEN

we use this struct internally to track computed tokens, we may as well
use it when fetching those tokens, as it allows the removeal of the QTOK
type

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoRename token_store functions to make them consistent
Neil Horman [Thu, 30 Jan 2025 17:14:26 +0000 (12:14 -0500)] 
Rename token_store functions to make them consistent

we use get0 to get a token store, but set to set it.  Since the latter
takes a refcount, change that to set1.  Also rename the interal quic
functions to match.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoReview fixups
Neil Horman [Tue, 28 Jan 2025 14:41:52 +0000 (09:41 -0500)] 
Review fixups

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoFix a memory leak on free
Neil Horman [Tue, 28 Jan 2025 14:16:09 +0000 (09:16 -0500)] 
Fix a memory leak on free

Forgot to free the CRYPTO_REF when freeing a token

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoReduce our NEW_TOKEN send rate.
Neil Horman [Tue, 28 Jan 2025 13:58:19 +0000 (08:58 -0500)] 
Reduce our NEW_TOKEN send rate.

Currently, we send a NEW_TOKEN frame on every new validated connection,
but thats not necessecary.  Since NEW_TOKEN tokens have a lifetime of 1
hour currently, we really only need to send a NEW_TOKEN if:
1) We validated a RETRY token
or
2) We validated a NEW_TOKEN for which the lifetime is nearing its limit

So lets do that.  When we validate a token, only generate a NEW_TOKEN if
the current token is a RETRY token, or if its a NEW_TOKEN, and there is
less than 10% of the tokens lifetime remaining.

This lets clients use NEW_TOKENS repeatedly (as per the RFC), and saves
us some network bandwith.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoDon't reserve an unused cid for NEW_TOKENS
Neil Horman [Mon, 27 Jan 2025 21:32:32 +0000 (16:32 -0500)] 
Don't reserve an unused cid for NEW_TOKENS

Just realized that NEW_TOKEN tokens don't need a reserved rscid.

Because a client might use a received NEW_TOKEN for multiple subsequent
connections, we allocate a cid when we validate the token on new
connection establishment (in fact we just use the one that the client
sends).  As such the allocated rscid never gets used, and just sits
there until it ages out.

Instead, fill the rscid with random data to mutate subsequently
generated NEW_TOKENS's, since it won't ever be part of the validation
process anyway.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoReference count QUIC_TOKENS
Neil Horman [Mon, 27 Jan 2025 18:56:40 +0000 (13:56 -0500)] 
Reference count QUIC_TOKENS

closer reading of RFC 9000 indicates that a NEW_TOKEN token can be
(re)used repeatedly.

so instead of creating a use once and discard pattern in the token api.
Let the tokens stick around until they are replaced with a new token
from the server.  To do this, we need to ref count the tokens so that we
don't accidentally free them while a given client is waiting to send an
initial frame making use of them.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoCentralize freeing of tokens
Neil Horman [Mon, 27 Jan 2025 18:04:08 +0000 (13:04 -0500)] 
Centralize freeing of tokens

This will make it easier to refcount them in a moment

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoSchedule new token frame after handshake complete
Neil Horman [Sat, 25 Jan 2025 00:51:01 +0000 (19:51 -0500)] 
Schedule new token frame after handshake complete

We don't want to schedule the NEW_TOKEN frame until such time as the
handshake is complete, otherwise we risk giving a token to validate a
future connection to a peer we haven't decided to trust yet

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoAdd test to confirm new token functionality
Neil Horman [Tue, 21 Jan 2025 16:48:51 +0000 (11:48 -0500)] 
Add test to confirm new token functionality

Basically just create two clients and two servers, ensuring that both
clients use the same ctx (to share the token cache).

Connect the first client and server so that the cache gets populated
with a new token, tracing the ssl connection

Connect the second client and server, again tracing the connection with
the same bio

Then sift through the trace, looking for the new token frame in the
first connection, matching it with the token used in the second
connection.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoAdd lookup for initial token assignment on channel start
Neil Horman [Thu, 16 Jan 2025 20:34:33 +0000 (15:34 -0500)] 
Add lookup for initial token assignment on channel start

Start assiging initial tokens, and validating them on receipt

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoEnhance get_peer_token to not require memcpy
Neil Horman [Thu, 16 Jan 2025 18:12:15 +0000 (13:12 -0500)] 
Enhance get_peer_token to not require memcpy

Instead of copying the token thats store, return a pointer to it
along with a pointer to the token struct to free should we need to

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoAdd allocation of token cache on server contexts when needed
Neil Horman [Thu, 16 Jan 2025 13:27:48 +0000 (08:27 -0500)] 
Add allocation of token cache on server contexts when needed

the SSL_new_from_listener api creates a client SSL from a server
SSL_CTX context.  Normally server contexts need no token cache, but once
we start using it as a client, that changes.  Allocate one here when
needed

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoAugment client side recieve code to store NEW_TOKENS
Neil Horman [Wed, 15 Jan 2025 21:21:09 +0000 (16:21 -0500)] 
Augment client side recieve code to store NEW_TOKENS

Start storing new tokens in our new cache

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoextend internal api to allow for add/lookup token ops
Neil Horman [Wed, 15 Jan 2025 20:16:24 +0000 (15:16 -0500)] 
extend internal api to allow for add/lookup token ops

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoAdd docs for token store manipulation
Neil Horman [Wed, 15 Jan 2025 17:01:31 +0000 (12:01 -0500)] 
Add docs for token store manipulation

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoAdd public api to create token cache for QUIC NEW_TOKENS
Neil Horman [Wed, 15 Jan 2025 16:40:49 +0000 (11:40 -0500)] 
Add public api to create token cache for QUIC NEW_TOKENS

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoAdd new token generation transmission
Neil Horman [Sun, 12 Jan 2025 03:16:16 +0000 (22:16 -0500)] 
Add new token generation transmission

When we bind a channel, create a NEW_TOKEN token to be sent on the next
available datagram, once the channel is validated

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26517)

5 months agoClean up a few further TODO(QUIC SERVER)
Tomas Mraz [Thu, 23 Jan 2025 16:42:56 +0000 (17:42 +0100)] 
Clean up a few further TODO(QUIC SERVER)

These are either already implemented or not relevant for
the QUIC server MVP.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26544)

5 months agoAdd build.info for QUIC server demo
Tomas Mraz [Thu, 23 Jan 2025 16:28:43 +0000 (17:28 +0100)] 
Add build.info for QUIC server demo

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26544)

5 months agoWe are not handling AEAD at port level for now
Tomas Mraz [Thu, 23 Jan 2025 16:21:21 +0000 (17:21 +0100)] 
We are not handling AEAD at port level for now

-> TODO(QUIC FUTURE)

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26544)

5 months agoossl_quic_tserver_shutdown(): Remove TODO(QUIC SERVER)
Tomas Mraz [Thu, 23 Jan 2025 16:14:46 +0000 (17:14 +0100)] 
ossl_quic_tserver_shutdown(): Remove TODO(QUIC SERVER)

tserver code is not related to QUIC SERVER

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26544)

5 months agoupdate Dockerfile to pull hq-interop code from new location
Neil Horman [Thu, 23 Jan 2025 19:14:33 +0000 (14:14 -0500)] 
update Dockerfile to pull hq-interop code from new location

Change the dockerfile to use enable-hqinterop and copy binaries from
their new location

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26546)

5 months agoAdd hq-interop configure option
Neil Horman [Thu, 23 Jan 2025 19:10:15 +0000 (14:10 -0500)] 
Add hq-interop configure option

Allow the building of the hq-interop client and server when we are
building our interop container

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26546)

5 months agoMove hq-interop code to test/quic-openssl-docker
Neil Horman [Thu, 23 Jan 2025 19:02:55 +0000 (14:02 -0500)] 
Move hq-interop code to test/quic-openssl-docker

Its the only place we use this code, so put the code in that directory

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26546)

5 months agoDisable server address validation for resumption test
Neil Horman [Thu, 23 Jan 2025 18:55:13 +0000 (13:55 -0500)] 
Disable server address validation for resumption test

The quic-interop runner expects a handshake message and certificate
exchange in the first 3 frames in this test.  The addition of server
address validation retry frames causes the test to fail.  Strictly
speaking this is a shortcoming of the test, but disabling address
validation allows the test to pass, and we have the mechanism, so
disable the feature.

Fixes openssl/project#1061

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26545)

5 months agoUpdate doc/man3/SSL_new_stream.pod
Neil Horman [Thu, 23 Jan 2025 15:26:44 +0000 (10:26 -0500)] 
Update doc/man3/SSL_new_stream.pod

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26527)

5 months agoquic-hq-interop: Allow for retries if we've reached our max stream limit
Neil Horman [Wed, 22 Jan 2025 18:19:52 +0000 (13:19 -0500)] 
quic-hq-interop: Allow for retries if we've reached our max stream limit

Several servers defer the sending of max stream frames.  For instance
quic-go uses a go-routine to do the sending after sufficient existing
streams have finished, while mvfst seems to wait for all outstanding
streams to be closed before issuing a new batch.  This result in the
client, if all streams are in use, getting a transient NULL return from
SSL_new_stream().  Check for the stream limit being reached and allow a
number of retries before giving up to give the server a chance to issue
us more streams.  Also dead-reckon the batch count of streams we use in
parallel to be 1/4 of our total number of available streams (generally
hard coded to 100 for most servers) to avoid using all our streams at
once.  It would be really nice to have an api to expose our negotiated
transport parameters so that the application can know what this limit
is, but until then we have to just guess.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26527)

5 months agoFix up some nits
Neil Horman [Wed, 22 Jan 2025 19:29:19 +0000 (14:29 -0500)] 
Fix up some nits

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoremove check of pending in ossl_quic_free
Neil Horman [Wed, 22 Jan 2025 15:25:47 +0000 (10:25 -0500)] 
remove check of pending in ossl_quic_free

Not strictly needed

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoRemove vestigual accepted flag
Neil Horman [Wed, 22 Jan 2025 15:10:30 +0000 (10:10 -0500)] 
Remove vestigual accepted flag

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoFix more typos
Neil Horman [Wed, 22 Jan 2025 13:37:15 +0000 (08:37 -0500)] 
Fix more typos

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoFix some typos
Neil Horman [Wed, 22 Jan 2025 12:38:51 +0000 (07:38 -0500)] 
Fix some typos

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoupdate docs with reference to SSL_set_ex_data
Neil Horman [Mon, 20 Jan 2025 22:03:42 +0000 (17:03 -0500)] 
update docs with reference to SSL_set_ex_data

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoAttempt to use NULL listeners to avoid use after free
Neil Horman [Tue, 21 Jan 2025 21:55:15 +0000 (16:55 -0500)] 
Attempt to use NULL listeners to avoid use after free

As per @sashan suggestion, try pre-creating user ssls with a NULL
listener

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoUpdate man page to note limitations of callbacks for QUIC
Neil Horman [Fri, 17 Jan 2025 18:36:26 +0000 (13:36 -0500)] 
Update man page to note limitations of callbacks for QUIC

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoFix memory leak in pre-allocated listeners
Neil Horman [Tue, 14 Jan 2025 22:52:20 +0000 (17:52 -0500)] 
Fix memory leak in pre-allocated listeners

We have a chicken and egg problem.

Normally when we create a connection object in quic, we associate it
with a listener, and up the ref on the parent listener, which is fine.

However, now that we are pre-allocating user_ssl objects for incomming
connections we have a situation in which:
1) The pre-alocated connection object holds a ref on the listener
2) The application has no awareness of the quic connection object (and
   so can't free it)
3) The freeing of the listener object never calls into the quic stack,
   because its reference count may hold references from connections that
   haven't been accepted yet

We could require that applications register a function for the
new_pending_conn callback, and track/free these pending connections, but
that seems like alot of extra unneeded work to place on the application

Instead:
a) add a quic_conn_st flag named accepted
b) When pre-allocating connections, clear the flag in (a) and _dont_
   hold a reference to the parent listener
c) in SSL_accept_connection, set the accepted flag and reference the
listener
d) in ossl_quic_free drop the listener reference only if the accepted
flag is set
c) expressly free all user_ssl objects in ossl_quic_port_drop_incoming

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoAdd changes.md entry noting the limitations of recursive SSL calls
Neil Horman [Mon, 13 Jan 2025 17:06:49 +0000 (12:06 -0500)] 
Add changes.md entry noting the limitations of recursive SSL calls

QUIC can't currently make recursive SSL calls, as it potentially results
in deadlock

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agorename new_pending_ssl to new_pending_conn
Neil Horman [Fri, 10 Jan 2025 17:20:40 +0000 (12:20 -0500)] 
rename new_pending_ssl to new_pending_conn

Make it clear its only announcing connections, not streams

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoRun Make update
Neil Horman [Thu, 9 Jan 2025 14:25:22 +0000 (09:25 -0500)] 
Run Make update

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoAdd docs for new callback registration
Neil Horman [Thu, 9 Jan 2025 13:27:58 +0000 (08:27 -0500)] 
Add docs for new callback registration

Add docs for SSL_CTX_set_new_pending_ssl_cb

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoAdd a test to validate our new SSL_accept connection objects
Neil Horman [Wed, 8 Jan 2025 23:31:55 +0000 (18:31 -0500)] 
Add a test to validate our new SSL_accept connection objects

Quick test to validate that:

a) our new pending SSL accept callback works
and
b) That our callback passed SSL objects match those that are returned
by SSL_accept_connection

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoAdd a callback to announce newly created ssl waiting acceptance
Neil Horman [Wed, 8 Jan 2025 19:59:58 +0000 (14:59 -0500)] 
Add a callback to announce newly created ssl waiting acceptance

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoReturn channel tls from ossl_quic_accept_connection
Neil Horman [Wed, 8 Jan 2025 19:12:28 +0000 (14:12 -0500)] 
Return channel tls from ossl_quic_accept_connection

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agouse internal callback to generate user ssl
Neil Horman [Wed, 8 Jan 2025 19:08:36 +0000 (14:08 -0500)] 
use internal callback to generate user ssl

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoAdd callback to get user ssl on channel creation
Neil Horman [Wed, 8 Jan 2025 18:23:55 +0000 (13:23 -0500)] 
Add callback to get user ssl on channel creation

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26361)

5 months agoIf server receives NEW_TOKEN frame, respond with PROTOCOL_VIOLATION
Andrew Dinh [Wed, 15 Jan 2025 15:12:31 +0000 (23:12 +0800)] 
If server receives NEW_TOKEN frame, respond with PROTOCOL_VIOLATION

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26426)

5 months agoFix MARSHALLED_TOKEN_MAX_LEN
Andrew Dinh [Thu, 2 Jan 2025 03:46:06 +0000 (19:46 -0800)] 
Fix MARSHALLED_TOKEN_MAX_LEN

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26333)

5 months agoQUIC FUTURE: Add concurrency architecture design document
Hugo Landau [Wed, 24 Apr 2024 12:38:27 +0000 (13:38 +0100)] 
QUIC FUTURE: Add concurrency architecture design document

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26025)

5 months agoFix sizing on variable in ossl-nghttp3-demo-server
Neil Horman [Thu, 9 Jan 2025 17:12:09 +0000 (12:12 -0500)] 
Fix sizing on variable in ossl-nghttp3-demo-server

On working on a rebase for the quic-server branch, I noted that the
rebase was failing on the http3 server.  It occurs because the new CI
ubuntu container appears to have FORTIFY_SOURCE enabled and trips over
the call to read here.  Specifically the compiler notes that in passing
an int into the read syscall (which accepts a size_t as the 3rd
argument), may interpret a negative value as a very large unsigned value
that exeeds the size allowed by a read call.

Fix it by converting the size variable to a size_t to ensure that the
signing is correct

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26368)

5 months agoImplement SSL_new_from_listener()
Alexandr Nedvedicky [Mon, 9 Dec 2024 09:49:05 +0000 (10:49 +0100)] 
Implement SSL_new_from_listener()

SSL_new_from_listner() creates QUIC connection object (QCSO)
from listener. Caller can use the object retuned from
SSL_new_from_listener() to connect to remote QUIC server.
The QCSO created here shares engine/port with listener.

the change is covered by `test_ssl_new_from_listener()` in
test/quicapitest.c

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26138)

5 months agoMake quic interop tests pass with the demo server
Jean-Frederic Clere [Mon, 16 Dec 2024 09:28:55 +0000 (10:28 +0100)] 
Make quic interop tests pass with the demo server

Included are also multiple style fixes.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26193)

5 months agoIPv6 support for quic interop
Andrew Dinh [Mon, 16 Dec 2024 17:23:59 +0000 (12:23 -0500)] 
IPv6 support for quic interop

Modify the QUIC HQ interop server/client to support both IPv4 and IPv6.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26194)

5 months agoDisable address validation for throughput test
Neil Horman [Tue, 17 Dec 2024 15:54:47 +0000 (10:54 -0500)] 
Disable address validation for throughput test

The multiplexing test using quiche as a client seems to get confused
when server address validation is enabled.  specifically it writes the
wrong keys into its keylog file, causing the test to fail when tshark
can't decode the tls connection that is established.  Fix it by
disabling address validation for the multiplexing/transfer test

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26198)

5 months agoDo read retries in quic hq-interop server
Neil Horman [Sun, 15 Dec 2024 20:26:41 +0000 (15:26 -0500)] 
Do read retries in quic hq-interop server

Normally the throughput test in the interop harness requests several
hundred very small files, resulting in lots of small stream packets from
the client, which are nominally read in a single read operation (as they
typically fit into a single stream frame), and the server was written to
expect that.  However, its still possible, if a stream frame is packed
to the end of a datagram, that only part of its content is carried,
finished in a subsequent stream packet, which leads to a short read.

Augment the server to properly handle SSL_read transient failures so
that such an occurance is handled properly.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26198)

5 months agoFix SSL_read error handling in http3 demo server
Neil Horman [Sat, 14 Dec 2024 14:06:11 +0000 (09:06 -0500)] 
Fix SSL_read error handling in http3 demo server

The SSL_read error handling misses the ZERO_RETURN clause which is
non-fatal, correct that.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26180)

5 months agoCorrect copying of the url value
Neil Horman [Fri, 13 Dec 2024 13:54:49 +0000 (08:54 -0500)] 
Correct copying of the url value

When setting up the url value we copy data from memory regions that
overlap, it leads to bogus output, correct that.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26180)

5 months agoPreserve fileprefix accross reuse in http3 demo server
Neil Horman [Fri, 13 Dec 2024 00:02:54 +0000 (19:02 -0500)] 
Preserve fileprefix accross reuse in http3 demo server

The fileprefix that we serve content from needs to be preserved accross
h3ssl reuse.  Make sure we restore it after zeroing the struct.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26180)

5 months agoAdd http3 test to the interop container
Neil Horman [Wed, 4 Dec 2024 20:27:00 +0000 (15:27 -0500)] 
Add http3 test to the interop container

Set fileprefix for interop container on http3 server test

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26180)

5 months agoEncrypt the address validation token
Andrew Dinh [Thu, 12 Dec 2024 15:28:52 +0000 (09:28 -0600)] 
Encrypt the address validation token

Store an EVP_CIPHER_CTX context with an ephemeral key set in port
and use it to encrypt/decrypt the validation token.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26165)

5 months agoremoving debug code from quic_impl
Neil Horman [Mon, 16 Dec 2024 17:08:08 +0000 (12:08 -0500)] 
removing debug code from quic_impl

I had experimented with starting the ssl handshake during accept, and
forgot to remove it

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26178)

5 months agoFix typo
Neil Horman [Mon, 16 Dec 2024 14:11:05 +0000 (09:11 -0500)] 
Fix typo

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26178)

5 months agoaugment CI to run ampilficationlimit tests
Neil Horman [Thu, 12 Dec 2024 14:43:27 +0000 (09:43 -0500)] 
augment CI to run ampilficationlimit tests

NOTE: Do this for the server test as well after rebase when http3
commits get merged

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26178)

5 months agomodify docker endpoint to not do address validation on transfer test
Neil Horman [Thu, 12 Dec 2024 14:40:29 +0000 (09:40 -0500)] 
modify docker endpoint to not do address validation on transfer test

quic interop uses the transfer test as part of the amplificationlimit
test, and as such we can't do address validation with retry frames
there, as the test requires it

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26178)

5 months agoAdd tracking of receive credit for unvalidated connections
Neil Horman [Mon, 9 Dec 2024 15:21:54 +0000 (10:21 -0500)] 
Add tracking of receive credit for unvalidated connections

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26178)

5 months agoAdd unvalidated credit tracking to packetizer
Neil Horman [Mon, 9 Dec 2024 13:58:28 +0000 (08:58 -0500)] 
Add unvalidated credit tracking to packetizer

Add data to track how much unvalidated credit we are sending and
receiving until such time as we are validated.  Validated conditions
are:

1) A retry token is sent, received, and validated
2) a handshake is completed on the connection

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26178)

5 months agoAdd a warning that disabling server validation is not recommended
Neil Horman [Fri, 6 Dec 2024 16:28:02 +0000 (11:28 -0500)] 
Add a warning that disabling server validation is not recommended

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26114)

5 months agoClarify that this validation only relates to retry packets
Neil Horman [Wed, 4 Dec 2024 21:12:02 +0000 (16:12 -0500)] 
Clarify that this validation only relates to retry packets

Disabling server address validation here only relates to new connections
that arrive without a token.  Future connections using tokens provided
by the server via NEW_TOKEN frames will still be validated

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26114)

5 months agoDisable server address validation on interop handshake test
Neil Horman [Wed, 4 Dec 2024 14:33:30 +0000 (09:33 -0500)] 
Disable server address validation on interop handshake test

The handshake test in the interop suite requires that no server address
validation be preformed, so disable it for this test

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26114)

5 months agoAdd a public flag to disable address validation on listeners
Neil Horman [Wed, 4 Dec 2024 14:25:12 +0000 (09:25 -0500)] 
Add a public flag to disable address validation on listeners

Now that we have the infrastructure to skip address validation, add a
public flag to SSL_new_listener and SSL_new_listener_from to allow the
skipping of address validation on selected quic listener SSL objects

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26114)

5 months agoAdd quic port flag to turn off address validation
Neil Horman [Tue, 3 Dec 2024 21:52:55 +0000 (16:52 -0500)] 
Add quic port flag to turn off address validation

Give us the infrastrucute to skip addr validation on the server

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26114)

5 months agoEnhance port binding to allow connections without odcid
Neil Horman [Tue, 3 Dec 2024 21:44:28 +0000 (16:44 -0500)] 
Enhance port binding to allow connections without odcid

If we opt not to do server address validation, we have no odcid
and therefore never reserved a local cid

We need to follow the initial code path to generate one

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26114)

5 months agoSSL_free() does check for != NULL (thanks Sashan)
Jean-Frederic Clere [Tue, 10 Dec 2024 09:08:11 +0000 (10:08 +0100)] 
SSL_free() does check for != NULL (thanks Sashan)

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoFixes according Sashan review.
Jean-Frederic Clere [Mon, 9 Dec 2024 14:50:02 +0000 (15:50 +0100)] 
Fixes according Sashan review.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoport the 2 improvement suggested by @nhorman to help to run the
Jean-Frederic Clere [Mon, 9 Dec 2024 13:32:28 +0000 (14:32 +0100)] 
port the 2 improvement suggested by @nhorman to help to run the
quic-interop-runner.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoArrange the code following the reviews.
Jean-Frederic Clere [Thu, 5 Dec 2024 14:48:25 +0000 (15:48 +0100)] 
Arrange the code following the reviews.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoFix small things from the review.
Jean-Frederic Clere [Wed, 4 Dec 2024 09:12:15 +0000 (10:12 +0100)] 
Fix small things from the review.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoAdd <sys/socket.h> for OpenBSD.
Jean-Frederic Clere [Tue, 3 Dec 2024 15:43:59 +0000 (16:43 +0100)] 
Add <sys/socket.h> for OpenBSD.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agotypo in comment.
Jean-Frederic Clere [Tue, 3 Dec 2024 15:35:50 +0000 (16:35 +0100)] 
typo in comment.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoArrange the remove_id() logic to be able to remove multiple stream.
Jean-Frederic Clere [Tue, 3 Dec 2024 15:18:03 +0000 (16:18 +0100)] 
Arrange the  remove_id() logic to be able to remove multiple stream.
create a new h3conn in read_from_ssl_ids() when we have a new
connection.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoArrange macox errors.
Jean-Frederic Clere [Wed, 6 Nov 2024 09:59:57 +0000 (10:59 +0100)] 
Arrange macox errors.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agomake check style happy.
Jean-Frederic Clere [Mon, 4 Nov 2024 14:34:37 +0000 (15:34 +0100)] 
make check style happy.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoArrange the logic:
Jean-Frederic Clere [Mon, 4 Nov 2024 10:17:35 +0000 (11:17 +0100)] 
Arrange the logic:
SSL_poll() without SSL_POLL_FLAG_NO_HANDLE_EVENT ticks for each stream
we have in SSL_poll() that prevents the server logic to get all events
Use SSL_poll() with SSL_POLL_FLAG_NO_HANDLE_EVENT and
SSL_handle_events() prevents the problem.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoread_from_ssl_ids() before wait_for_activity if something was received
Jean-Frederic Clere [Wed, 30 Oct 2024 17:06:07 +0000 (18:06 +0100)] 
read_from_ssl_ids() before wait_for_activity if something was received
before and the first time we are in the loop.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoArrange poll logic and get it working with chrome.
Jean-Frederic Clere [Mon, 28 Oct 2024 17:29:36 +0000 (18:29 +0100)] 
Arrange poll logic and get it working with chrome.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoAllow to send some files to test with browsers.
Jean-Frederic Clere [Mon, 28 Oct 2024 09:37:31 +0000 (10:37 +0100)] 
Allow to send some files to test with browsers.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoUse something like wait_for_activity() from demos/quic-server-non-block.c
Jean-Frederic Clere [Fri, 25 Oct 2024 14:23:35 +0000 (16:23 +0200)] 
Use something like wait_for_activity() from demos/quic-server-non-block.c

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25859)

5 months agoAugment RETRY validation token
Andrew Dinh [Wed, 27 Nov 2024 20:35:16 +0000 (12:35 -0800)] 
Augment RETRY validation token

Adds fields to the QUIC RETRY packet validation token:
timestamp, remote_addr, odcid, & rscid.

Also adds functionality to validate the token once returned by the client.

Note that this does not encrypt the token yet.

Also check that the RSCID stored in the RETRY validation
token matches the DCID in the header.

Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26048)

5 months agoDetermine which packet to drop for retry
Neil Horman [Thu, 28 Nov 2024 12:50:22 +0000 (07:50 -0500)] 
Determine which packet to drop for retry

When doing a retry after a version negotiation, we actually need to drop
packet 1 rather than 0 to get a retransmit of the initial packet

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26000)

5 months agoFix length check for datagram size in quic
Neil Horman [Thu, 28 Nov 2024 12:42:56 +0000 (07:42 -0500)] 
Fix length check for datagram size in quic

RFC says we should only accept datagrams of at least 1200 bytes, so the
check should discard anything under that, not over that

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26000)

5 months agoAugment quic interop harness to support server side interop tests
Neil Horman [Mon, 11 Nov 2024 22:12:19 +0000 (17:12 -0500)] 
Augment quic interop harness to support server side interop tests

the quic-interop-runner that we use for interop testing currently only
supports openssl client testing, as we had previously not had a server
to test with.

This PR rectifies that by doing the following:
1) Adding a quic-hq-interop-server.c file in demos/guide
2) Augmenting our interop Dockerfile and entrypoint to support our
   interop containter running in a server role

With these changes we are able to do server side interop testing

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26000)

5 months agoAdd documentation for BIO_dgram_set0_local_addr()
Matt Caswell [Tue, 26 Nov 2024 12:46:00 +0000 (12:46 +0000)] 
Add documentation for BIO_dgram_set0_local_addr()

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26066)

5 months agoAdd the ablity to set a local address for BIO_dgram_pair
Matt Caswell [Tue, 26 Nov 2024 12:36:52 +0000 (12:36 +0000)] 
Add the ablity to set a local address for BIO_dgram_pair

BIOs created from a BIO_dgram_pair don't normally have a local BIO_ADDR
associated with them. This allows us to set one.

Fixes openssl/project#933

Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26066)

5 months agoMake version negotiation packets use network byte order
Neil Horman [Thu, 21 Nov 2024 14:18:53 +0000 (09:18 -0500)] 
Make version negotiation packets use network byte order

@t8m pointed out that versino negotiation packets weren't guaranteeing
network byte ordering in the array of supported versions.

Convert the client to use network byte order on send and receipt.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25968)

5 months agoFixup tests to properly check version negotiation
Neil Horman [Fri, 15 Nov 2024 19:32:56 +0000 (14:32 -0500)] 
Fixup tests to properly check version negotiation

Currently the quic_multistream_test tests version negotiation..sort of.

It uses a packet injector to force the tserver to send a version
negotiation packet back to the client.  Thats no longer needed as the
server will respond to an invalid version properly.

So alter script_74 to, instead of using the injector, use a quic channel
mutator to invalidate the version provided in the initial packet.  Then
we attempt to connect.  If the server responds with a version
negotiation packet and the client restarts with the proper version, then
the test passes, as the connection is extablished.

Also, while we're in here, update the gen_version_neg function to
properly insert a 0 version into the packet header for script_75, as
version negotiation packets require that to be set, otherwise script_75
will fail now when the server notices this discrepancy.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25968)

5 months agoHandle the receipt of version negotiation packets
Neil Horman [Fri, 15 Nov 2024 19:31:36 +0000 (14:31 -0500)] 
Handle the receipt of version negotiation packets

On the client side, when we get a version negotiation packet, we need to
interrogate the supported version list from the server, and either:
1) drop the connection if we don't see a version we can work with

2) select a supported version and try the negotiation again

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25968)

5 months agoAdd port version negotiation response from server
Neil Horman [Fri, 15 Nov 2024 19:09:16 +0000 (14:09 -0500)] 
Add port version negotiation response from server

If the server receives an Initial packet with a version number we don't
support (currently a fixed check for QUIC_VERSION_1), instead of
dropping it, respond with a version negotiation packet to the peer

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25968)

5 months agoAllow packetizer to accept an arg to set protocol version
Neil Horman [Fri, 15 Nov 2024 18:55:05 +0000 (13:55 -0500)] 
Allow packetizer to accept an arg to set protocol version

In preparation for doing version negotiation, expose the ability to have
the packetiser for QUIC set a configured protocol version.  We only set
it to QUIC_VERSION_1 for now, but it allows for us to set different
protocols in the future.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25968)

5 months agoAugment ossl_quic_wire_decode_pkt_hdr
Neil Horman [Fri, 15 Nov 2024 18:34:37 +0000 (13:34 -0500)] 
Augment ossl_quic_wire_decode_pkt_hdr

In preparation for supporting the handling of version negotiation, we
need to be able to detect why the decoding of quic header failed.
Specifically, ossl_quic_wire_decode_pkt_hdr fails if the version
provided in the header isn't QUIC_VERSION_1.  We want to keep that, as
we don't support anything else, but the server code needs to
differentiate when we fail decode because of a version problem, vs some
other more fatal malforming issue.

So add a uint64_t *fail_cause pointer that gets filled out with a
failure cause.  We only use VERSION failures right now, but we can
expand this later if needed

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25968)