Skip to content

Reduce stack usage in tls13_hkdf_expand - #7297

Closed
bernd-edlinger wants to merge 1 commit into
openssl:masterfrom
bernd-edlinger:reduce_stack_usage_in_tls13_hkdf_expand
Closed

bernd-edlinger wants to merge 1 commit into
openssl:masterfrom
bernd-edlinger:reduce_stack_usage_in_tls13_hkdf_expand

Conversation

@bernd-edlinger

Copy link
Copy Markdown
Member

No description provided.

@bernd-edlinger bernd-edlinger added branch: master Applies to master branch branch: 1.1.1 Applies to OpenSSL_1_1_1-stable branch (EOL) labels Sep 23, 2018
@paulidale paulidale added the approval: done This pull request has the required number of approvals label Sep 24, 2018

@mattcaswell mattcaswell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. That change was made in one of the drafts, and it looks like this code didn't get updated to follow it.

@bernd-edlinger

Copy link
Copy Markdown
Member Author

Yeah, also the rationale for the 12 character limit is broken.
There must have been a draft where the Label was "TLS 1.3, " + "tls13 bla bla"
and if "bla bla" is up to 12 characters,
the resulting HMAC message is
2 + 1 + 9 + 6 + 12 + 1 + 32 + 1 = 64 bytes.

levitte pushed a commit that referenced this pull request Sep 24, 2018
Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #7297)
levitte pushed a commit that referenced this pull request Sep 24, 2018
Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #7297)

(cherry picked from commit ec0c5f5)
@bernd-edlinger

Copy link
Copy Markdown
Member Author

Merged to master and 111. Thanks!

Comment thread ssl/tls13_enc.c
* prefix and label + bytes for the label itself + bytes for the hash
* 2 bytes for length of derived secret + 1 byte for length of combined
* prefix and label + bytes for the label itself + 1 byte length of hash
* + bytes for the hash itself

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to actually add another sizeof(uint8_t) to the addition, for the length of the hash output?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be more clear this way, but then we should subtract one from sizeof(prefix)

@bernd-edlinger bernd-edlinger Sep 24, 2018 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So initially I had this:

sizeof(uint16_t) + sizeof(uint8_t)
 + (sizeof(label_prefix) - 1) + TLS13_MAX_LABEL_LEN
 + sizeof(uint8_t) + EVP_MAX_MD_SIZE

... but dropped it again, since the result is effectively the same.

@nmathewson

Copy link
Copy Markdown
Contributor

(This change introduced a regression for Tor: See #7712)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: done This pull request has the required number of approvals branch: master Applies to master branch branch: 1.1.1 Applies to OpenSSL_1_1_1-stable branch (EOL)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants