Skip to content

Accept SPKI DER in rust_crypto ECDSA verification - #553

Open
mamicicekel wants to merge 2 commits into
Keats:masterfrom
mamicicekel:fix/rust-crypto-ec-der-spki
Open

mamicicekel wants to merge 2 commits into
Keats:masterfrom
mamicicekel:fix/rust-crypto-ec-der-spki

Conversation

@mamicicekel

@mamicicekel mamicicekel commented Oct 28, 2026 •

Copy link
Copy Markdown

Fixes #497.

DecodingKey::from_ec_der is documented as taking a DER-encoded EC public key. The aws_lc_rs verifier already accepts SubjectPublicKeyInfo; rust_crypto always called from_sec1_bytes, so a normal SPKI key failed with InvalidEcdsaKey.

The verifier now uses only from_public_key_der. PEM (from_ec_pem) and JWK (from_ec_components) store the same SPKI DER so those loaders keep working without a SEC1 key-loading path.

from_ec_der documents a DER public key, but the rust_crypto verifier only
called from_sec1_bytes, so SPKI keys from OpenSSL/from_ec_pem failed while
the historical 65-byte SEC1 test keys still need to work.
@arckoor

arckoor commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

I don't really plan on offering sec1 support for key loading currently, this is just a mistake that I haven't gotten around to looking at yet. Just correcting it to the proper DER method is enough.

The rust_crypto verifier no longer falls back to SEC1. PEM extraction
and from_ec_components now keep SubjectPublicKeyInfo so JWK and PEM
round-trips still work.
@mamicicekel

Copy link
Copy Markdown
Author

Thanks — dropped the SEC1 fallback. The verifier only uses from_public_key_der now.

PEM and JWK still have to feed that parser, so from_ec_pem / from_ec_components store SubjectPublicKeyInfo instead of the extracted point. There is no SEC1 loading API.

@arckoor

arckoor commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Hm, this turned out to do more interaction with the secret than I hoped it would, I might pull this out into the dedicated key loading refactor pr after all. Good to keep open for now though, thanks for the work either way

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect behavior when using from_ec_der with rust-crypto provider

2 participants