Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PGP EC Key Conversion #1671

Closed
wants to merge 4 commits into from

Conversation

vanitasvitae
Copy link
Contributor

This PR is based on #1663 and fixes JcaPGPKeyConverter conversions for Elliptic Curve keys (Brainpool, NIST etc.).

The test from aeb001d shows that conversion between Jca and BC keys fails for some elliptic curve based keys, because some keys report the wrong OID (X9ObjectIdentifiers.id_ecPublicKey).
The patch from 87bbd5d drills down on the key to detect the proper OID by iterating over all known curves (a bit inefficient, is there a cleaner way?).

@vanitasvitae
Copy link
Contributor Author

Some observations:
JcaPGPKeyConverter still fails to convert EC keys over prime256v1 and P-256 if no BouncyCastleProvider is set.

@dghgit dghgit self-assigned this May 23, 2024
@dghgit
Copy link
Contributor

dghgit commented May 29, 2024

Thanks. Merged with revision - you'll find the changes in JcaPGPKeyConverter, I've generalized it to deal with non-BC keys and also added use of the X962Parameters type which is the ASN.1 construct you'll find in a key of type id_ecPublicKey. It would be worth having a look as it explains what's going on internally in the actual Java providers (well at least the ones I have seen to date).

@dghgit dghgit closed this May 29, 2024
hubot pushed a commit that referenced this pull request May 30, 2024
…9.62 parameters for curve OID finding (relates to github #1671)
@vanitasvitae vanitasvitae deleted the fixECKeyConversion branch September 17, 2024 12:59
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.

2 participants