History log of /openbsd-current/lib/libssl/ssl_versions.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.27 02-Jul-2023 beck

Disable TLS 1.0 and TLS 1.1 in libssl

Their time has long since past, and they should not be used.
This change restricts ssl to versions 1.2 and 1.3, and changes
the regression tests to understand we no longer speak the legacy
protocols.

For the moment the magical "golden" byte for byte comparison
tests of raw handshake values are disabled util jsing fixes them.

ok jsing@ tb@


Revision tags: OPENBSD_7_3_BASE
# 1.26 26-Nov-2022 tb

Make internal header file names consistent

Libcrypto currently has a mess of *_lcl.h, *_locl.h, and *_local.h names
used for internal headers. Move all these headers we inherited from
OpenSSL to *_local.h, reserving the name *_internal.h for our own code.
Similarly, move dtls_locl.h and ssl_locl.h to dtls_local and ssl_local.h.
constant_time_locl.h is moved to constant_time.h since it's special.

Adjust all .c files in libcrypto, libssl and regress.

The diff is mechanical with the exception of tls13_quic.c, where
#include <ssl_locl.h> was fixed manually.

discussed with jsing,
no objection bcook


# 1.25 02-Oct-2022 jsing

Get rid of SSL_CTX_INTERNAL and SSL_INTERNAL.

These are no longer necessary due to SSL_CTX and SSL now being fully
opaque. Merge SSL_CTX_INTERNAL back into SSL_CTX and SSL_INTERNAL back
into SSL.

Prompted by tb@


Revision tags: OPENBSD_7_2_BASE
# 1.24 11-Sep-2022 jsing

Enforce the minimum TLS version requirement for QUIC.

ok tb@


# 1.23 30-Jun-2022 tb

Add checks to ensure we do not initiate or negotiate handshakes with
versions below the minimum required by the security level.

input & ok jsing


Revision tags: OPENBSD_7_1_BASE
# 1.22 05-Feb-2022 jsing

Bye bye S3I.

S3I has served us well, however now that libssl is fully opaque it is time
to say goodbye. Aside from removing the calloc/free/memset, the rest is
mechanical sed.

ok inoguchi@ tb@


# 1.21 23-Oct-2021 jsing

Provide a way to determine our maximum legacy version.

With the introduction of TLSv1.3, we need the ability to determine our
maximum legacy version and to track our peer's maximum legacy version.
This is needed for both the TLS record layer when using TLSv1.3, plus
it is needed for RSA key exhange in TLS prior to TLSv1.3, where the
maximum legacy version is incorporated in the pre-master secret to
avoid downgrade attacks.

This unbreaks RSA KEX for the TLS client when the non-version specific
method is used with TLSv1.0 or TLSv1.1 (clearly no one does this).

ok tb@


Revision tags: OPENBSD_7_0_BASE
# 1.20 01-Jul-2021 jsing

Merge SSL_METHOD_INTERNAL into SSL_METHOD.

Now that SSL_METHOD is opaque and in internal headers, we can remove
SSL_METHOD_INTERNAL by merging it back into SSL_METHOD.

ok tb@


# 1.19 27-Jun-2021 jsing

Correct handling of SSL_OP_NO_DTLSv1.

When converting to TLS flags, we need to also include SSL_OP_NO_TLSv1,
otherwise the TLS equivalent of SSL_OP_NO_DTLSv1 is TLSv1.0 only, which
does not work so well when we try to switch back to DTLS versions.


Revision tags: OPENBSD_6_9_BASE
# 1.18 19-Mar-2021 tb

Undo previous. As pointed out by jsing I clearly wasn't fully awake...


# 1.17 17-Mar-2021 tb

fix whitespace nit in previous


# 1.16 17-Mar-2021 jsing

Add support for DTLSv1.2 version handling.

This teaches the version functions that handle protocol versions about
DTLSv1.2 and the SSL_OP_NO_DTLS* options. We effectively convert between
TLS and TLS protocol versions where necessary.

ok inoguchi@ tb@


# 1.15 11-Mar-2021 jsing

Remove ssl_downgrade_max_version().

Now that we store our maximum TLS version at the start of the handshake,
we can check against that directly.

ok inoguchi@ tb@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.26 26-Nov-2022 tb

Make internal header file names consistent

Libcrypto currently has a mess of *_lcl.h, *_locl.h, and *_local.h names
used for internal headers. Move all these headers we inherited from
OpenSSL to *_local.h, reserving the name *_internal.h for our own code.
Similarly, move dtls_locl.h and ssl_locl.h to dtls_local and ssl_local.h.
constant_time_locl.h is moved to constant_time.h since it's special.

Adjust all .c files in libcrypto, libssl and regress.

The diff is mechanical with the exception of tls13_quic.c, where
#include <ssl_locl.h> was fixed manually.

discussed with jsing,
no objection bcook


# 1.25 02-Oct-2022 jsing

Get rid of SSL_CTX_INTERNAL and SSL_INTERNAL.

These are no longer necessary due to SSL_CTX and SSL now being fully
opaque. Merge SSL_CTX_INTERNAL back into SSL_CTX and SSL_INTERNAL back
into SSL.

Prompted by tb@


Revision tags: OPENBSD_7_2_BASE
# 1.24 11-Sep-2022 jsing

Enforce the minimum TLS version requirement for QUIC.

ok tb@


# 1.23 30-Jun-2022 tb

Add checks to ensure we do not initiate or negotiate handshakes with
versions below the minimum required by the security level.

input & ok jsing


Revision tags: OPENBSD_7_1_BASE
# 1.22 05-Feb-2022 jsing

Bye bye S3I.

S3I has served us well, however now that libssl is fully opaque it is time
to say goodbye. Aside from removing the calloc/free/memset, the rest is
mechanical sed.

ok inoguchi@ tb@


# 1.21 23-Oct-2021 jsing

Provide a way to determine our maximum legacy version.

With the introduction of TLSv1.3, we need the ability to determine our
maximum legacy version and to track our peer's maximum legacy version.
This is needed for both the TLS record layer when using TLSv1.3, plus
it is needed for RSA key exhange in TLS prior to TLSv1.3, where the
maximum legacy version is incorporated in the pre-master secret to
avoid downgrade attacks.

This unbreaks RSA KEX for the TLS client when the non-version specific
method is used with TLSv1.0 or TLSv1.1 (clearly no one does this).

ok tb@


Revision tags: OPENBSD_7_0_BASE
# 1.20 01-Jul-2021 jsing

Merge SSL_METHOD_INTERNAL into SSL_METHOD.

Now that SSL_METHOD is opaque and in internal headers, we can remove
SSL_METHOD_INTERNAL by merging it back into SSL_METHOD.

ok tb@


# 1.19 27-Jun-2021 jsing

Correct handling of SSL_OP_NO_DTLSv1.

When converting to TLS flags, we need to also include SSL_OP_NO_TLSv1,
otherwise the TLS equivalent of SSL_OP_NO_DTLSv1 is TLSv1.0 only, which
does not work so well when we try to switch back to DTLS versions.


Revision tags: OPENBSD_6_9_BASE
# 1.18 19-Mar-2021 tb

Undo previous. As pointed out by jsing I clearly wasn't fully awake...


# 1.17 17-Mar-2021 tb

fix whitespace nit in previous


# 1.16 17-Mar-2021 jsing

Add support for DTLSv1.2 version handling.

This teaches the version functions that handle protocol versions about
DTLSv1.2 and the SSL_OP_NO_DTLS* options. We effectively convert between
TLS and TLS protocol versions where necessary.

ok inoguchi@ tb@


# 1.15 11-Mar-2021 jsing

Remove ssl_downgrade_max_version().

Now that we store our maximum TLS version at the start of the handshake,
we can check against that directly.

ok inoguchi@ tb@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.25 02-Oct-2022 jsing

Get rid of SSL_CTX_INTERNAL and SSL_INTERNAL.

These are no longer necessary due to SSL_CTX and SSL now being fully
opaque. Merge SSL_CTX_INTERNAL back into SSL_CTX and SSL_INTERNAL back
into SSL.

Prompted by tb@


Revision tags: OPENBSD_7_2_BASE
# 1.24 11-Sep-2022 jsing

Enforce the minimum TLS version requirement for QUIC.

ok tb@


# 1.23 30-Jun-2022 tb

Add checks to ensure we do not initiate or negotiate handshakes with
versions below the minimum required by the security level.

input & ok jsing


Revision tags: OPENBSD_7_1_BASE
# 1.22 05-Feb-2022 jsing

Bye bye S3I.

S3I has served us well, however now that libssl is fully opaque it is time
to say goodbye. Aside from removing the calloc/free/memset, the rest is
mechanical sed.

ok inoguchi@ tb@


# 1.21 23-Oct-2021 jsing

Provide a way to determine our maximum legacy version.

With the introduction of TLSv1.3, we need the ability to determine our
maximum legacy version and to track our peer's maximum legacy version.
This is needed for both the TLS record layer when using TLSv1.3, plus
it is needed for RSA key exhange in TLS prior to TLSv1.3, where the
maximum legacy version is incorporated in the pre-master secret to
avoid downgrade attacks.

This unbreaks RSA KEX for the TLS client when the non-version specific
method is used with TLSv1.0 or TLSv1.1 (clearly no one does this).

ok tb@


Revision tags: OPENBSD_7_0_BASE
# 1.20 01-Jul-2021 jsing

Merge SSL_METHOD_INTERNAL into SSL_METHOD.

Now that SSL_METHOD is opaque and in internal headers, we can remove
SSL_METHOD_INTERNAL by merging it back into SSL_METHOD.

ok tb@


# 1.19 27-Jun-2021 jsing

Correct handling of SSL_OP_NO_DTLSv1.

When converting to TLS flags, we need to also include SSL_OP_NO_TLSv1,
otherwise the TLS equivalent of SSL_OP_NO_DTLSv1 is TLSv1.0 only, which
does not work so well when we try to switch back to DTLS versions.


Revision tags: OPENBSD_6_9_BASE
# 1.18 19-Mar-2021 tb

Undo previous. As pointed out by jsing I clearly wasn't fully awake...


# 1.17 17-Mar-2021 tb

fix whitespace nit in previous


# 1.16 17-Mar-2021 jsing

Add support for DTLSv1.2 version handling.

This teaches the version functions that handle protocol versions about
DTLSv1.2 and the SSL_OP_NO_DTLS* options. We effectively convert between
TLS and TLS protocol versions where necessary.

ok inoguchi@ tb@


# 1.15 11-Mar-2021 jsing

Remove ssl_downgrade_max_version().

Now that we store our maximum TLS version at the start of the handshake,
we can check against that directly.

ok inoguchi@ tb@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.24 11-Sep-2022 jsing

Enforce the minimum TLS version requirement for QUIC.

ok tb@


# 1.23 30-Jun-2022 tb

Add checks to ensure we do not initiate or negotiate handshakes with
versions below the minimum required by the security level.

input & ok jsing


Revision tags: OPENBSD_7_1_BASE
# 1.22 05-Feb-2022 jsing

Bye bye S3I.

S3I has served us well, however now that libssl is fully opaque it is time
to say goodbye. Aside from removing the calloc/free/memset, the rest is
mechanical sed.

ok inoguchi@ tb@


# 1.21 23-Oct-2021 jsing

Provide a way to determine our maximum legacy version.

With the introduction of TLSv1.3, we need the ability to determine our
maximum legacy version and to track our peer's maximum legacy version.
This is needed for both the TLS record layer when using TLSv1.3, plus
it is needed for RSA key exhange in TLS prior to TLSv1.3, where the
maximum legacy version is incorporated in the pre-master secret to
avoid downgrade attacks.

This unbreaks RSA KEX for the TLS client when the non-version specific
method is used with TLSv1.0 or TLSv1.1 (clearly no one does this).

ok tb@


Revision tags: OPENBSD_7_0_BASE
# 1.20 01-Jul-2021 jsing

Merge SSL_METHOD_INTERNAL into SSL_METHOD.

Now that SSL_METHOD is opaque and in internal headers, we can remove
SSL_METHOD_INTERNAL by merging it back into SSL_METHOD.

ok tb@


# 1.19 27-Jun-2021 jsing

Correct handling of SSL_OP_NO_DTLSv1.

When converting to TLS flags, we need to also include SSL_OP_NO_TLSv1,
otherwise the TLS equivalent of SSL_OP_NO_DTLSv1 is TLSv1.0 only, which
does not work so well when we try to switch back to DTLS versions.


Revision tags: OPENBSD_6_9_BASE
# 1.18 19-Mar-2021 tb

Undo previous. As pointed out by jsing I clearly wasn't fully awake...


# 1.17 17-Mar-2021 tb

fix whitespace nit in previous


# 1.16 17-Mar-2021 jsing

Add support for DTLSv1.2 version handling.

This teaches the version functions that handle protocol versions about
DTLSv1.2 and the SSL_OP_NO_DTLS* options. We effectively convert between
TLS and TLS protocol versions where necessary.

ok inoguchi@ tb@


# 1.15 11-Mar-2021 jsing

Remove ssl_downgrade_max_version().

Now that we store our maximum TLS version at the start of the handshake,
we can check against that directly.

ok inoguchi@ tb@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.23 30-Jun-2022 tb

Add checks to ensure we do not initiate or negotiate handshakes with
versions below the minimum required by the security level.

input & ok jsing


Revision tags: OPENBSD_7_1_BASE
# 1.22 05-Feb-2022 jsing

Bye bye S3I.

S3I has served us well, however now that libssl is fully opaque it is time
to say goodbye. Aside from removing the calloc/free/memset, the rest is
mechanical sed.

ok inoguchi@ tb@


# 1.21 23-Oct-2021 jsing

Provide a way to determine our maximum legacy version.

With the introduction of TLSv1.3, we need the ability to determine our
maximum legacy version and to track our peer's maximum legacy version.
This is needed for both the TLS record layer when using TLSv1.3, plus
it is needed for RSA key exhange in TLS prior to TLSv1.3, where the
maximum legacy version is incorporated in the pre-master secret to
avoid downgrade attacks.

This unbreaks RSA KEX for the TLS client when the non-version specific
method is used with TLSv1.0 or TLSv1.1 (clearly no one does this).

ok tb@


Revision tags: OPENBSD_7_0_BASE
# 1.20 01-Jul-2021 jsing

Merge SSL_METHOD_INTERNAL into SSL_METHOD.

Now that SSL_METHOD is opaque and in internal headers, we can remove
SSL_METHOD_INTERNAL by merging it back into SSL_METHOD.

ok tb@


# 1.19 27-Jun-2021 jsing

Correct handling of SSL_OP_NO_DTLSv1.

When converting to TLS flags, we need to also include SSL_OP_NO_TLSv1,
otherwise the TLS equivalent of SSL_OP_NO_DTLSv1 is TLSv1.0 only, which
does not work so well when we try to switch back to DTLS versions.


Revision tags: OPENBSD_6_9_BASE
# 1.18 19-Mar-2021 tb

Undo previous. As pointed out by jsing I clearly wasn't fully awake...


# 1.17 17-Mar-2021 tb

fix whitespace nit in previous


# 1.16 17-Mar-2021 jsing

Add support for DTLSv1.2 version handling.

This teaches the version functions that handle protocol versions about
DTLSv1.2 and the SSL_OP_NO_DTLS* options. We effectively convert between
TLS and TLS protocol versions where necessary.

ok inoguchi@ tb@


# 1.15 11-Mar-2021 jsing

Remove ssl_downgrade_max_version().

Now that we store our maximum TLS version at the start of the handshake,
we can check against that directly.

ok inoguchi@ tb@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.22 05-Feb-2022 jsing

Bye bye S3I.

S3I has served us well, however now that libssl is fully opaque it is time
to say goodbye. Aside from removing the calloc/free/memset, the rest is
mechanical sed.

ok inoguchi@ tb@


# 1.21 23-Oct-2021 jsing

Provide a way to determine our maximum legacy version.

With the introduction of TLSv1.3, we need the ability to determine our
maximum legacy version and to track our peer's maximum legacy version.
This is needed for both the TLS record layer when using TLSv1.3, plus
it is needed for RSA key exhange in TLS prior to TLSv1.3, where the
maximum legacy version is incorporated in the pre-master secret to
avoid downgrade attacks.

This unbreaks RSA KEX for the TLS client when the non-version specific
method is used with TLSv1.0 or TLSv1.1 (clearly no one does this).

ok tb@


Revision tags: OPENBSD_7_0_BASE
# 1.20 01-Jul-2021 jsing

Merge SSL_METHOD_INTERNAL into SSL_METHOD.

Now that SSL_METHOD is opaque and in internal headers, we can remove
SSL_METHOD_INTERNAL by merging it back into SSL_METHOD.

ok tb@


# 1.19 27-Jun-2021 jsing

Correct handling of SSL_OP_NO_DTLSv1.

When converting to TLS flags, we need to also include SSL_OP_NO_TLSv1,
otherwise the TLS equivalent of SSL_OP_NO_DTLSv1 is TLSv1.0 only, which
does not work so well when we try to switch back to DTLS versions.


Revision tags: OPENBSD_6_9_BASE
# 1.18 19-Mar-2021 tb

Undo previous. As pointed out by jsing I clearly wasn't fully awake...


# 1.17 17-Mar-2021 tb

fix whitespace nit in previous


# 1.16 17-Mar-2021 jsing

Add support for DTLSv1.2 version handling.

This teaches the version functions that handle protocol versions about
DTLSv1.2 and the SSL_OP_NO_DTLS* options. We effectively convert between
TLS and TLS protocol versions where necessary.

ok inoguchi@ tb@


# 1.15 11-Mar-2021 jsing

Remove ssl_downgrade_max_version().

Now that we store our maximum TLS version at the start of the handshake,
we can check against that directly.

ok inoguchi@ tb@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.21 23-Oct-2021 jsing

Provide a way to determine our maximum legacy version.

With the introduction of TLSv1.3, we need the ability to determine our
maximum legacy version and to track our peer's maximum legacy version.
This is needed for both the TLS record layer when using TLSv1.3, plus
it is needed for RSA key exhange in TLS prior to TLSv1.3, where the
maximum legacy version is incorporated in the pre-master secret to
avoid downgrade attacks.

This unbreaks RSA KEX for the TLS client when the non-version specific
method is used with TLSv1.0 or TLSv1.1 (clearly no one does this).

ok tb@


Revision tags: OPENBSD_7_0_BASE
# 1.20 01-Jul-2021 jsing

Merge SSL_METHOD_INTERNAL into SSL_METHOD.

Now that SSL_METHOD is opaque and in internal headers, we can remove
SSL_METHOD_INTERNAL by merging it back into SSL_METHOD.

ok tb@


# 1.19 27-Jun-2021 jsing

Correct handling of SSL_OP_NO_DTLSv1.

When converting to TLS flags, we need to also include SSL_OP_NO_TLSv1,
otherwise the TLS equivalent of SSL_OP_NO_DTLSv1 is TLSv1.0 only, which
does not work so well when we try to switch back to DTLS versions.


Revision tags: OPENBSD_6_9_BASE
# 1.18 19-Mar-2021 tb

Undo previous. As pointed out by jsing I clearly wasn't fully awake...


# 1.17 17-Mar-2021 tb

fix whitespace nit in previous


# 1.16 17-Mar-2021 jsing

Add support for DTLSv1.2 version handling.

This teaches the version functions that handle protocol versions about
DTLSv1.2 and the SSL_OP_NO_DTLS* options. We effectively convert between
TLS and TLS protocol versions where necessary.

ok inoguchi@ tb@


# 1.15 11-Mar-2021 jsing

Remove ssl_downgrade_max_version().

Now that we store our maximum TLS version at the start of the handshake,
we can check against that directly.

ok inoguchi@ tb@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.20 01-Jul-2021 jsing

Merge SSL_METHOD_INTERNAL into SSL_METHOD.

Now that SSL_METHOD is opaque and in internal headers, we can remove
SSL_METHOD_INTERNAL by merging it back into SSL_METHOD.

ok tb@


# 1.19 27-Jun-2021 jsing

Correct handling of SSL_OP_NO_DTLSv1.

When converting to TLS flags, we need to also include SSL_OP_NO_TLSv1,
otherwise the TLS equivalent of SSL_OP_NO_DTLSv1 is TLSv1.0 only, which
does not work so well when we try to switch back to DTLS versions.


Revision tags: OPENBSD_6_9_BASE
# 1.18 19-Mar-2021 tb

Undo previous. As pointed out by jsing I clearly wasn't fully awake...


# 1.17 17-Mar-2021 tb

fix whitespace nit in previous


# 1.16 17-Mar-2021 jsing

Add support for DTLSv1.2 version handling.

This teaches the version functions that handle protocol versions about
DTLSv1.2 and the SSL_OP_NO_DTLS* options. We effectively convert between
TLS and TLS protocol versions where necessary.

ok inoguchi@ tb@


# 1.15 11-Mar-2021 jsing

Remove ssl_downgrade_max_version().

Now that we store our maximum TLS version at the start of the handshake,
we can check against that directly.

ok inoguchi@ tb@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.19 27-Jun-2021 jsing

Correct handling of SSL_OP_NO_DTLSv1.

When converting to TLS flags, we need to also include SSL_OP_NO_TLSv1,
otherwise the TLS equivalent of SSL_OP_NO_DTLSv1 is TLSv1.0 only, which
does not work so well when we try to switch back to DTLS versions.


Revision tags: OPENBSD_6_9_BASE
# 1.18 19-Mar-2021 tb

Undo previous. As pointed out by jsing I clearly wasn't fully awake...


# 1.17 17-Mar-2021 tb

fix whitespace nit in previous


# 1.16 17-Mar-2021 jsing

Add support for DTLSv1.2 version handling.

This teaches the version functions that handle protocol versions about
DTLSv1.2 and the SSL_OP_NO_DTLS* options. We effectively convert between
TLS and TLS protocol versions where necessary.

ok inoguchi@ tb@


# 1.15 11-Mar-2021 jsing

Remove ssl_downgrade_max_version().

Now that we store our maximum TLS version at the start of the handshake,
we can check against that directly.

ok inoguchi@ tb@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.18 19-Mar-2021 tb

Undo previous. As pointed out by jsing I clearly wasn't fully awake...


# 1.17 17-Mar-2021 tb

fix whitespace nit in previous


# 1.16 17-Mar-2021 jsing

Add support for DTLSv1.2 version handling.

This teaches the version functions that handle protocol versions about
DTLSv1.2 and the SSL_OP_NO_DTLS* options. We effectively convert between
TLS and TLS protocol versions where necessary.

ok inoguchi@ tb@


# 1.15 11-Mar-2021 jsing

Remove ssl_downgrade_max_version().

Now that we store our maximum TLS version at the start of the handshake,
we can check against that directly.

ok inoguchi@ tb@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.17 17-Mar-2021 tb

fix whitespace nit in previous


# 1.16 17-Mar-2021 jsing

Add support for DTLSv1.2 version handling.

This teaches the version functions that handle protocol versions about
DTLSv1.2 and the SSL_OP_NO_DTLS* options. We effectively convert between
TLS and TLS protocol versions where necessary.

ok inoguchi@ tb@


# 1.15 11-Mar-2021 jsing

Remove ssl_downgrade_max_version().

Now that we store our maximum TLS version at the start of the handshake,
we can check against that directly.

ok inoguchi@ tb@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.15 11-Mar-2021 jsing

Remove ssl_downgrade_max_version().

Now that we store our maximum TLS version at the start of the handshake,
we can check against that directly.

ok inoguchi@ tb@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.14 10-Mar-2021 jsing

Improve internal version handling.

Add handshake fields for our minimum TLS version, our maximum TLS version
and the TLS version negotiated during the handshake. Initialise our min/max
versions at the start of the handshake and leave these unchanged. The
negotiated TLS version is set in the client once we receive the ServerHello
and in the server at the point we select the highest shared version.

Provide an ssl_effective_version() function that returns the negotiated TLS
version if known, otherwise our maximum TLS version - this is effectively
what is stored in s->version currently.

Convert most of the internal code to use one of these three version fields,
which greatly simplifies code (especially in the TLS extension handling
code).

ok tb@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.13 25-Feb-2021 jsing

Only use TLS versions internally (rather than both TLS and DTLS versions).

DTLS protocol version numbers are the 1's compliment of human readable TLS
version numbers, which means that newer versions decrease in value and
there is no direct mapping between TLS protocol version numbers and DTLS
protocol version numbers.

Rather than having to deal with this internally, only use TLS versions
internally and map between DTLS and TLS protocol versions when necessary.
Rename functions and variables to use 'tls_version' when they contain a
TLS version (and never a DTLS version).

ok tb@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.12 22-Feb-2021 jsing

Factor out/change some of the legacy client version handling code.

This consolidates the version handling code and will make upcoming changes
easier.

ok tb@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.11 20-Feb-2021 jsing

Return a min/max version of zero if set to zero.

OpenSSL's SSL{_CTX,}_get_{min,max}_proto_version() return a version of zero
if the minimum or maximum has been set to zero (which means the minimum or
maximum version supported by the method). Previously we returned the
minimum or maximum version supported by the method, instead of zero. Match
OpenSSL's behaviour by using shadow variables.

Discussed with tb@


# 1.10 20-Feb-2021 jsing

Handle DTLS1_2_VERSION in various places.

ok tb@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.9 07-Feb-2021 jsing

Factor out the legacy stack version checks.

Also check for explicit version numbers, rather than just the major version
value.

ok tb@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.8 04-Jan-2021 tb

whitespace


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.7 14-Oct-2020 jsing

Replace SSL_IS_DTLS with SSL_is_dtls().

Garbage collect the now unused SSL_IS_DTLS macro.

ok tb@


Revision tags: OPENBSD_6_8_BASE
# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.6 31-May-2020 jsing

Replace ssl_max_server_version() with ssl_downgrade_max_version()

Replace the only occurrence of ssl_max_server_version() with a call
to ssl_downgrade_max_version() and remove ssl_max_server_version().

ok beck@ tb@


# 1.5 31-May-2020 jsing

Correct downgrade sentinels when a version pinned method is in use.

Previously only the enabled protocol versions were considered, however we
also have to consider the method in use which may be version pinned.

Found the hard way by danj@ with haproxy and force-tlsv12.

ok beck@ inoguchi@ tb@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


# 1.4 06-Nov-2018 jsing

Include TLSv1.3 in version handling code.

This is effectively a no-op, since most of the code clamps to the maximum
version supported by the TLS method (which are still at TLSv1.2).

ok beck@ bluhm@ tb@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@


Revision tags: OPENBSD_6_2_BASE
# 1.3 06-May-2017 jsing

Provide SSL{,_CTX}_set_{min,max}_proto_version() functions.

Rides minor bump.

ok beck@


# 1.2 06-May-2017 jsing

Add missing $OpenBSD$ tags.


Revision tags: OPENBSD_6_1_BASE
# 1.1 26-Jan-2017 jsing

Move relatively new version range code from ssl_lib.c into a separate
ssl_versions.c file.

ok beck@