Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert the TLSv1.3 crypto code and KTLS to use the new write record layer #19343

Closed
wants to merge 17 commits into from

Conversation

mattcaswell
Copy link
Member

This is built on top of #19217 and includes those commits. This converts the TLSv1.3 code and all remaining KTLS code to use the new write record layer.

@mattcaswell mattcaswell added the branch: master Merge to master branch label Oct 4, 2022
@mattcaswell mattcaswell marked this pull request as draft October 4, 2022 16:16
@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Oct 4, 2022
We also clean up some of the KTLS code while we are doing it now that all
users of KTLS have been moved to the new write record layer.
Most of this was unnecessary anyway since DTLS isn't using these codepaths.
This field was used to track whether a cipher ctx was valid for writing
or not, and also whether we should write out plaintext alerts. With the new
record layer design we no longer need to track whether a cipher ctx is valid
since the whole record layer will be aborted if it is not. Also we have a
different mechanism for tracking whether we should write out plaintext
alerts. Therefore this field is removed from the SSL object.
…code

We move some protocol specific code for write buffer and WPACKET allocation
and initialisation out of tls_common.c and into the protocol specific files.
Remove TLSv1.3 specific processing of the record type out of tls_common.c
and into tls13_meth.c
We introduce a new function to prepare the record header. KTLS has its own
version since this is done by the kernel.
The KTLS cipher function is a no-op so it doesn't matter if we call it.
We shouldn't special case KTLS in tls_common.c
Only tls13_meth.c needs to handle adding record padding. All other
*_meth.c files can ignore it.
This applies any mac that might be necessary, ensures that we have
enough space in the WPACKET to perform the encryption and sets up the
SSL3_RECORD ready for that encryption.
For example in this we add the MAC if we are doing encrypt-then-mac.
The KTLS code no longer calls this function so this is not necessary.
This removes some KTLS specific code from tls_retry_write_records().
@mattcaswell mattcaswell marked this pull request as ready for review October 5, 2022 15:34
@mattcaswell
Copy link
Member Author

I've now taken this PR out of draft. It has been rebased to pull in all the commits from #19217 which have now been merged and all CI runs are passing (except 1 which appears to be due to a temporary network glitch and not related to this PR).

Ping for review!

@mattcaswell mattcaswell added approval: review pending This pull request needs review by a committer approval: otc review pending This pull request needs review by an OTC member labels Oct 5, 2022
ssl/record/methods/tls_common.c Outdated Show resolved Hide resolved
ssl/record/methods/tls_common.c Outdated Show resolved Hide resolved
@mattcaswell
Copy link
Member Author

@hlandau - fixup applied following your feedback. Please take another look.

@hlandau hlandau removed the approval: otc review pending This pull request needs review by an OTC member label Oct 6, 2022
@t8m t8m added the triaged: refactor The issue/pr requests/implements refactoring label Oct 7, 2022
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
This field was used to track whether a cipher ctx was valid for writing
or not, and also whether we should write out plaintext alerts. With the new
record layer design we no longer need to track whether a cipher ctx is valid
since the whole record layer will be aborted if it is not. Also we have a
different mechanism for tracking whether we should write out plaintext
alerts. Therefore this field is removed from the SSL object.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
…code

We move some protocol specific code for write buffer and WPACKET allocation
and initialisation out of tls_common.c and into the protocol specific files.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
Remove TLSv1.3 specific processing of the record type out of tls_common.c
and into tls13_meth.c

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
We introduce a new function to prepare the record header. KTLS has its own
version since this is done by the kernel.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
The KTLS cipher function is a no-op so it doesn't matter if we call it.
We shouldn't special case KTLS in tls_common.c

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
Only tls13_meth.c needs to handle adding record padding. All other
*_meth.c files can ignore it.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
This applies any mac that might be necessary, ensures that we have
enough space in the WPACKET to perform the encryption and sets up the
SSL3_RECORD ready for that encryption.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
For example in this we add the MAC if we are doing encrypt-then-mac.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
The KTLS code no longer calls this function so this is not necessary.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
This removes some KTLS specific code from tls_retry_write_records().

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
openssl-machine pushed a commit that referenced this pull request Oct 12, 2022
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
We also clean up some of the KTLS code while we are doing it now that all
users of KTLS have been moved to the new write record layer.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Most of this was unnecessary anyway since DTLS isn't using these codepaths.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
This field was used to track whether a cipher ctx was valid for writing
or not, and also whether we should write out plaintext alerts. With the new
record layer design we no longer need to track whether a cipher ctx is valid
since the whole record layer will be aborted if it is not. Also we have a
different mechanism for tracking whether we should write out plaintext
alerts. Therefore this field is removed from the SSL object.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
…code

We move some protocol specific code for write buffer and WPACKET allocation
and initialisation out of tls_common.c and into the protocol specific files.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Remove TLSv1.3 specific processing of the record type out of tls_common.c
and into tls13_meth.c

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
We introduce a new function to prepare the record header. KTLS has its own
version since this is done by the kernel.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
The KTLS cipher function is a no-op so it doesn't matter if we call it.
We shouldn't special case KTLS in tls_common.c

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Only tls13_meth.c needs to handle adding record padding. All other
*_meth.c files can ignore it.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
This applies any mac that might be necessary, ensures that we have
enough space in the WPACKET to perform the encryption and sets up the
SSL3_RECORD ready for that encryption.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
For example in this we add the MAC if we are doing encrypt-then-mac.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
The KTLS code no longer calls this function so this is not necessary.

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
This removes some KTLS specific code from tls_retry_write_records().

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from openssl#19343)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Merge to master branch severity: fips change The pull request changes FIPS provider sources triaged: refactor The issue/pr requests/implements refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants