Skip to content

Conversation

@bnoordhuis
Copy link
Member

Before this commit it computed (1<<(8*(15-iv_len)))-1 for iv_len>=11
and that reduces to (1<<32)-1 for iv_len==11. Left-shifting past
the sign bit and overflowing a signed integral type are both undefined
behaviors.

This commit switches to fixed values and restricts the iv_len==11
case to INT_MAX, as was already the case for all iv_len<=10.

@bnoordhuisbnoordhuis requested a review from tniessenJune 22, 2018 11:11
@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. labels Jun 22, 2018
@bnoordhuisbnoordhuisforce-pushed the fix-crypto-auth-iv-ub branch from 6bdf825 to 19fe529CompareJune 25, 2018 21:46
bnoordhuis added a commit to bnoordhuis/io.js that referenced this pull request Jun 25, 2018
Before this commit it computed `(1<<(8*(15-iv_len)))-1` for `iv_len>=11` and that reduces to `(1<<32)-1` for `iv_len==11`. Left-shifting past the sign bit and overflowing a signed integral type are both undefined behaviors. This commit switches to fixed values and restricts the `iv_len==11` case to `INT_MAX`, as was already the case for all `iv_len<=10`. PR-URL: nodejs#21462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
@bnoordhuisbnoordhuis deleted the fix-crypto-auth-iv-ub branch June 25, 2018 21:46
@bnoordhuis
Copy link
MemberAuthor

Landed in 19fe529.

targos pushed a commit that referenced this pull request Jun 26, 2018
Before this commit it computed `(1<<(8*(15-iv_len)))-1` for `iv_len>=11` and that reduces to `(1<<32)-1` for `iv_len==11`. Left-shifting past the sign bit and overflowing a signed integral type are both undefined behaviors. This commit switches to fixed values and restricts the `iv_len==11` case to `INT_MAX`, as was already the case for all `iv_len<=10`. PR-URL: #21462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
@targostargos mentioned this pull request Jul 3, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++Issues and PRs that require attention from people who are familiar with C++.cryptoIssues and PRs related to the crypto subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@bnoordhuis@nodejs-github-bot@jasnell@cjihrig@tniessen