[openssl/openssl] a56686: Move initial TLS write record layer code into new ...

Matt Caswell noreply at github.com
Fri Sep 23 14:03:58 UTC 2022


  Branch: refs/heads/master
  Home:   https://github.com/openssl/openssl
  Commit: a566864b607317fc95cbe190bbf0b8b928fcfa77
      https://github.com/openssl/openssl/commit/a566864b607317fc95cbe190bbf0b8b928fcfa77
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/dtls_meth.c
    M ssl/record/methods/ktls_meth.c
    M ssl/record/methods/recmethod_local.h
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_d1.c
    M ssl/record/rec_layer_s3.c
    M ssl/record/record.h
    M ssl/record/recordmethod.h
    M ssl/s3_msg.c

  Log Message:
  -----------
  Move initial TLS write record layer code into new structure

The new write record layer architecture splits record writing into
a "write_records" call and a "retry_write_records" call - where multiple
records can be sent to "write_records" in one go. We restructure the code
into that format in order that future commits can move these functions into
the new record layer more easily.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 2b71b042202d11854801682d48ccf4e4e34cd5cf
      https://github.com/openssl/openssl/commit/2b71b042202d11854801682d48ccf4e4e34cd5cf
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/dtls_meth.c
    M ssl/record/methods/ktls_meth.c
    M ssl/record/methods/recmethod_local.h
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_s3.c
    M ssl/record/record.h
    M ssl/record/recordmethod.h
    M ssl/s3_enc.c
    M ssl/s3_msg.c
    M ssl/ssl_lib.c
    M ssl/t1_enc.c
    M ssl/tls13_enc.c

  Log Message:
  -----------
  Create the write record layer method and object and use it

Make sure we set the write record layer method and create the object
where appropriate. Move the newly restructured writing code into the
record layer object.

For now we are cheating and still accessing the underlying SSL_CONNECTION
object. This will be removed in subsequent commits.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 3eaead7166ef5aff027e571a9be0def6581ef20c
      https://github.com/openssl/openssl/commit/3eaead7166ef5aff027e571a9be0def6581ef20c
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_s3.c

  Log Message:
  -----------
  Move checking for alerts to dispatch out of the record layer

This isn't a record layer responsibility so should be removed from
write_records.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 310590139e45116d86627dcc85e83f2e3fcbb6b4
      https://github.com/openssl/openssl/commit/310590139e45116d86627dcc85e83f2e3fcbb6b4
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/tls_common.c

  Log Message:
  -----------
  Use the record layer msg_callback not the SSL object msg_callback

This removes unnecessary usage of the SSL object from the record layer.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: b5cf81f7c9775d2502730ba126893ce8af4db90e
      https://github.com/openssl/openssl/commit/b5cf81f7c9775d2502730ba126893ce8af4db90e
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/ktls_meth.c
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_s3.c
    M ssl/s3_msg.c
    M ssl/ssl_lib.c

  Log Message:
  -----------
  Replace references to s->wbio with rl->bio

We use the record layer reference to the BIO rather than the SSL object
reference. This removes an unneeded SSL object usage.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 151f313e53c1515f2730b3b36e3fc966e1a8010b
      https://github.com/openssl/openssl/commit/151f313e53c1515f2730b3b36e3fc966e1a8010b
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/recmethod_local.h
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_s3.c
    M ssl/record/ssl3_buffer.c
    M ssl/t1_enc.c
    M ssl/tls13_enc.c

  Log Message:
  -----------
  Move write buffer management into the write record layer

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: e7694c69b5fed37f5cdf72b70f507c7188db7e3d
      https://github.com/openssl/openssl/commit/e7694c69b5fed37f5cdf72b70f507c7188db7e3d
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/recmethod_local.h
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_d1.c
    M ssl/record/record.h

  Log Message:
  -----------
  Move numwpipes in the write record layer

We retain a numwpipes for now in the old record layer structure for use
by DTLS. This will eventually be removed when DTLS moves over to the new
way of doing things.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 1d3676778c280ef05044c4c9e696a4f8096530ea
      https://github.com/openssl/openssl/commit/1d3676778c280ef05044c4c9e696a4f8096530ea
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_s3.c
    M ssl/record/record.h
    M ssl/record/recordmethod.h
    M ssl/s3_msg.c
    M ssl/statem/extensions_clnt.c
    M ssl/statem/statem_clnt.c
    M ssl/statem/statem_lib.c

  Log Message:
  -----------
  Move logic for figuring out the record version out of record layer

This calculation is based on lots of information from state machine and
elsewhere that the record layer cannot access. In reality it is sufficient
to simply tell the record layer what version to use.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 91141aa1b0ff9d92323e2545bb9f6f0d1e2a8844
      https://github.com/openssl/openssl/commit/91141aa1b0ff9d92323e2545bb9f6f0d1e2a8844
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/tls_common.c
    M ssl/ssl_local.h

  Log Message:
  -----------
  Remove empty_fragment_done

Now that we are no longer recursively addinng the prefix record this
doesn't seem necessary any more. We always add it every time we do
tls_write_records.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: b9e4e78342df6575b358def3d951227e9c6cebda
      https://github.com/openssl/openssl/commit/b9e4e78342df6575b358def3d951227e9c6cebda
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/recmethod_local.h
    M ssl/record/methods/tls_common.c
    M ssl/s3_enc.c
    M ssl/ssl_local.h
    M ssl/t1_enc.c

  Log Message:
  -----------
  Move need_empty_fragments inside the record layer

This flag can now be managed entirely by the new record layer code so we
move it into ossl_record_layer_st.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: f2892e21619a2c59e957f7f9121f24713bcad3e9
      https://github.com/openssl/openssl/commit/f2892e21619a2c59e957f7f9121f24713bcad3e9
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/tls_common.c

  Log Message:
  -----------
  Remove use of SSL_CONNECTION_TREAT_AS_TLS13() from the record layer

In all cases we should be able to replace this with a simple check
against rl->version.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 5f95eb77e780cc0b90a7da6cc4f79c7bb153ca64
      https://github.com/openssl/openssl/commit/5f95eb77e780cc0b90a7da6cc4f79c7bb153ca64
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/recmethod_local.h
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_s3.c
    M ssl/record/record.h

  Log Message:
  -----------
  Move the record padding callback fully into the record layer

We wrap the callback and pass it to the record layer via the dispatch
array, in order to avoid accessing it directly via SSL_CONNECTION.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: eb7d6c2a9b3b9d1582e3e1b65c9d431cf3209207
      https://github.com/openssl/openssl/commit/eb7d6c2a9b3b9d1582e3e1b65c9d431cf3209207
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M include/openssl/core_names.h
    M ssl/record/methods/ktls_meth.c
    M ssl/record/methods/recmethod_local.h
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_s3.c
    M ssl/record/record.h
    M ssl/ssl_lib.c
    M ssl/ssl_local.h
    M ssl/tls13_enc.c

  Log Message:
  -----------
  Move the record block_padding capability fully into the record layer

Previously we were referencing the block_padding value through the
SSL_CONNECTION. Now it is held within OSSL_RECORD_LAYER.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 5361a5a9664046aefcd1a72858826bcb4c93ad9f
      https://github.com/openssl/openssl/commit/5361a5a9664046aefcd1a72858826bcb4c93ad9f
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/tls_common.c

  Log Message:
  -----------
  Remove some miscellaneous references to SSL_CONNECTION

There were a small number of references to the SSL_CONNECTION that can
be removed easily and replaced with record layer equivalents.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 320145d5b3a11492427fe1cab9ca4de52402c72d
      https://github.com/openssl/openssl/commit/320145d5b3a11492427fe1cab9ca4de52402c72d
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_d1.c
    M ssl/record/rec_layer_s3.c
    M ssl/record/record.h
    M ssl/s3_msg.c

  Log Message:
  -----------
  Convert the write record layer to supply proper return values

This also means we can convert SSLfatal calls to RLAYERfatal

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 02719d5c4c1e64350b4dddb17e703864809e130a
      https://github.com/openssl/openssl/commit/02719d5c4c1e64350b4dddb17e703864809e130a
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/recmethod_local.h
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_s3.c
    M ssl/record/recordmethod.h

  Log Message:
  -----------
  Make sure we call get_max_records() in the record layer code

We use the returned data to decide how to split the data we want to write
into records.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 23bf52a4b40deb033de0a257b724012afe32b169
      https://github.com/openssl/openssl/commit/23bf52a4b40deb033de0a257b724012afe32b169
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/recmethod_local.h
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_s3.c
    M ssl/record/recordmethod.h

  Log Message:
  -----------
  Re-enable the multiblock code and move it into the record layer

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: c6d5f343336532a7aba4368099b0631a457194a6
      https://github.com/openssl/openssl/commit/c6d5f343336532a7aba4368099b0631a457194a6
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/rec_layer_s3.c

  Log Message:
  -----------
  Resove some outstanding TODOs

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: c6186792b98e93cf2d5d2a9fb85e4aeab31db890
      https://github.com/openssl/openssl/commit/c6186792b98e93cf2d5d2a9fb85e4aeab31db890
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/tls_common.c
    M ssl/record/rec_layer_s3.c

  Log Message:
  -----------
  Move the pipelining code into the record layer

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 85b358b01a36757d07da118795a0ad13c9c2b4d7
      https://github.com/openssl/openssl/commit/85b358b01a36757d07da118795a0ad13c9c2b4d7
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/tls_common.c

  Log Message:
  -----------
  Ensure that prefix records use a small buffer

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 4fed6ee1ce4a3374d7223654db13132144275c05
      https://github.com/openssl/openssl/commit/4fed6ee1ce4a3374d7223654db13132144275c05
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/tls_common.c

  Log Message:
  -----------
  Remove some outstanding TODOs

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: bafe524b5ce425105ac321f9fffa23e2d5b06845
      https://github.com/openssl/openssl/commit/bafe524b5ce425105ac321f9fffa23e2d5b06845
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/record/methods/build.info
    M ssl/record/methods/ktls_meth.c
    M ssl/record/methods/recmethod_local.h
    M ssl/record/methods/ssl3_meth.c
    M ssl/record/methods/tls13_meth.c
    M ssl/record/methods/tls1_meth.c
    M ssl/record/methods/tls_common.c
    A ssl/record/methods/tls_multib.c
    M ssl/record/methods/tlsany_meth.c

  Log Message:
  -----------
  Restructure the write code

Move the multiblock code into a separate file and introduce the usage of
record_functions_st for some write functions.

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


  Commit: 9ff519542387d32ab1c3a8b1f45a375e1712a383
      https://github.com/openssl/openssl/commit/9ff519542387d32ab1c3a8b1f45a375e1712a383
  Author: Matt Caswell <matt at openssl.org>
  Date:   2022-09-23 (Fri, 23 Sep 2022)

  Changed paths:
    M ssl/ssl_lib.c

  Log Message:
  -----------
  Fix a record layer mem leak

Make sure we free the record layer before we free the connection BIOs

Reviewed-by: Hugo Landau <hlandau at openssl.org>
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19198)


Compare: https://github.com/openssl/openssl/compare/c5d061290baa...9ff519542387


More information about the openssl-commits mailing list