Skip to content

Conversation

@bbbrumley
Copy link
Contributor

Backport of #9727 to 1.0.2.

I still want to do some more testing, but it will have to wait until Sunday night. I thought I'd at least get the PR up for review.

The cofactor argument to EC_GROUP_set_generator is optional, and SCA
mitigations for ECC currently use it. So the library currently falls
back to very old SCA-vulnerable code if the cofactor is not present.

This PR allows EC_GROUP_set_generator to compute the cofactor for all
curves of cryptographic interest. Steering scalar multiplication to more
SCA-robust code.

This issue affects persisted private keys in explicit parameter form,
where the (optional) cofactor field is zero or absent.

It also affects curves not built-in to the library, but constructed
programatically with explicit parameters, then calling
EC_GROUP_set_generator with a nonsensical value (NULL, zero).

The very old scalar multiplication code is known to be vulnerable to
local uarch attacks, outside of the OpenSSL threat model. New results
suggest the code path is also vulnerable to traditional wall clock
timing attacks.

CVE-2019-1547
Copy link
Member

@mattcaswell mattcaswell left a comment

Choose a reason for hiding this comment

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

Needs a CHANGES entry

@romen romen added the branch: 1.0.2 Applies to OpenSSL_1_0_2-stable branch (EOL) label Sep 7, 2019
@romen romen self-assigned this Sep 7, 2019
Copy link
Member

@romen romen left a comment

Choose a reason for hiding this comment

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

LGTM

I also confirmed in gdb that the cofactor is correctly calculated and single point EC_POINT_mul() goes through ec_mul_consttime() as expected.

@romen
Copy link
Member

romen commented Sep 7, 2019

Needs a CHANGES entry

This has been fixed

@romen romen added the hold label Sep 7, 2019
@romen
Copy link
Member

romen commented Sep 7, 2019

I put the hold label just to remind us that @bbbrumley wanted to do more testing before merging.

@bbbrumley
Copy link
Contributor Author

Thanks @romen for cleaning up my PRs. Enjoy your vacation :)

I carved out some time this morning to finish testing this.

The "hack test" with the assert from the other PR went swell again. I also verified the codepath in gdb that it early exits to ladder. Basically confirming what @romen did above.

I wanted to still test manually with a few custom PEMs, since 1.0.2 doesn't have robust evp_test support. That testing also went swell.

So ... ready to go from my behalf.

@mattcaswell mattcaswell added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Sep 9, 2019
@mattcaswell
Copy link
Member

Pushed. Thanks.

@mattcaswell mattcaswell closed this Sep 9, 2019
levitte pushed a commit that referenced this pull request Sep 9, 2019
The cofactor argument to EC_GROUP_set_generator is optional, and SCA
mitigations for ECC currently use it. So the library currently falls
back to very old SCA-vulnerable code if the cofactor is not present.

This PR allows EC_GROUP_set_generator to compute the cofactor for all
curves of cryptographic interest. Steering scalar multiplication to more
SCA-robust code.

This issue affects persisted private keys in explicit parameter form,
where the (optional) cofactor field is zero or absent.

It also affects curves not built-in to the library, but constructed
programatically with explicit parameters, then calling
EC_GROUP_set_generator with a nonsensical value (NULL, zero).

The very old scalar multiplication code is known to be vulnerable to
local uarch attacks, outside of the OpenSSL threat model. New results
suggest the code path is also vulnerable to traditional wall clock
timing attacks.

CVE-2019-1547

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #9799)
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: 1.0.2 Applies to OpenSSL_1_0_2-stable branch (EOL)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants