Skip to content

Conversation

raycoll
Copy link
Contributor

@raycoll raycoll commented Apr 24, 2021

This change preserves the previous ecc fallback behavior while
allowing for a preference list that does not contain secp256r1.

Comment on lines +251 to +253
/* P-256 is the preferred fallback option. These prefs don't support it, so choose whatever curve is first. */
conn->secure.server_ecc_evp_params.negotiated_curve = ecc_pref->ecc_curves[0];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it guaranteed that we always have at least one curve?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we need a defensive check. Can add one to the conditional here but also thinking of other places to have the check to short circuit this logic sooner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a sanity check during s2n_security_policies_init() where @zz85's previous p256 check was.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe POSIX_ENSURE_GT(ecc_pref->count, 0); for extra paranoia? (:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

decided to put that check with the rest of the ecc_pref validations in this function rather than nested in the conditional where we access the first element.

This change preserves the previous ecc fallback behavior while
allowing for a preference list that does not contain secp256r1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants