Skip to content

UPSTREAM PR #30940: Avoid duplicate export of EC key point format#686

Open
loci-dev wants to merge 3 commits into
mainfrom
loci/pr-30940-dedup-ec-ptfmt
Open

UPSTREAM PR #30940: Avoid duplicate export of EC key point format#686
loci-dev wants to merge 3 commits into
mainfrom
loci/pr-30940-dedup-ec-ptfmt

Conversation

@loci-dev
Copy link
Copy Markdown

Note

Source pull request: openssl/openssl#30940

  • Make the group (rather than the key) the source of the point conversion form.
  • Filter EC certs against our own advertised point formats

See commits for more details. The second fixes a bug in TLS 1.2 certificate selection and exercises the first.

Checklist
  • documentation is added or updated
  • tests are added or updated

Viktor Dukhovni added 3 commits April 26, 2026 04:29
The EC point conversion form was stored in two places that could
disagree: the EC_KEY's conv_form and the EC_GROUP's asn1_form.
Encoders read the key, but provider keygen wrote only the group,
so genpkey -pkeyopt point-format:compressed produced keys whose
encoded public point was uncompressed.

Make the group canonical.  Encoders, OSSL_PARAM output, and the
EVP_PKEY_get_ec_point_conv_form() legacy fallback all read
EC_GROUP_get_point_conversion_form().  EC_KEY_oct2key mirrors the
decoded form onto the group, and provider keygen mirrors the
group's form onto the key, so the two fields stay aligned.

The deprecated EC_KEY_set_conv_form() and EC_KEY_get_conv_form()
remain functional for legacy callers.

openssl genpkey -pkeyopt point-format:<format> now outputs the
specified form.
tls1_check_pkey_comp() only compared the cert's point form to the
peer's advertised list, never to our own.  If a server held a
compressed EC leaf, the peer advertised compressed, and we didn't,
the cert-selector picked the leaf anyway and the peer responded with
an illegal_parameter alert -- the mismatch only got caught after the
cert had already gone out on the wire.  Now we also require the
cert's form to appear in our own advertised list.

The new 33-compressed-spki ssl_new test runs through ten stanzas:
both sides advertise compressed (cert selected), either side leaves
the option off (server aborts), TLS 1.3 (the option is unused),
mixed RSA+EC fallback, and an uncompressed control to confirm we're
filtering by point form rather than cert type.

This is also our first end-to-end TLS test of compressed EC public keys in
certificates, made possible now that genpkey has working support for:

  -algorithm ec -pkeyopt point-format:compressed
@loci-review
Copy link
Copy Markdown

loci-review Bot commented Apr 26, 2026

Flame Graph: libssl.so::t1_lib.c_tls1_check_pkey_comp

Target version:

Flame Graph: libssl.so::t1_lib.c_tls1_check_pkey_comp

The target version adds tls1_get_formatlist (48 ns) to the call chain, accounting for 51% of the 93 ns regression. The remaining increase comes from additional validation logic and stack operations for the security fix.

💬 Questions? Tag @loci-dev

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant