Skip to content

Fix PGP EC Key Conversion - #1671

Closed
vanitasvitae wants to merge 4 commits into
bcgit:mainfrom
pgpainless:fixECKeyConversion
Closed

Fix PGP EC Key Conversion#1671
vanitasvitae wants to merge 4 commits into
bcgit:mainfrom
pgpainless:fixECKeyConversion

Conversation

@vanitasvitae

Copy link
Copy Markdown
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
Copy Markdown
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

dghgit commented May 29, 2024

Copy link
Copy Markdown
Contributor

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