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

PGPPublicKey.getBitStrenght() returns -1 for keys over curve25519 #972

Closed
vanitasvitae opened this issue Jun 11, 2021 · 2 comments
Closed

Comments

@vanitasvitae
Copy link
Contributor

Hey,
it appears that in the constructor of PGPPublicKey, the bitstrenght field is set by calling

X9ECParameters ecParameters = ECNamedCurveTable.getByOID(((ECPublicBCPGKey)key).getCurveOID());

                if (ecParameters != null)
                {
                    this.keyStrength = ecParameters.getCurve().getFieldSize();
                }
                else
                {
                    this.keyStrength = -1; // unknown
                }

This method does not recognize EdDSA keys, as well as some ECDSA keys, so bitStrength is falsely reported as -1.

In particular, the method fails to identify keys with OIDs

  • 1.3.6.1.4.1.11591.15.1
  • 1.3.6.1.4.1.3029.1.5.1

Could you patch the ECNamedCurveTable to recognize these curves?

vanitasvitae added a commit to pgpainless/pgpainless that referenced this issue Jun 11, 2021
BCs PGPPublicKey.getBitStrenght() appears to fail to recognize some elliptic curves.
In such cases, bitStrength is reported as -1.
I added BCUtil.getBitStrength(publicKey) to manually determine the bit strenght by OID.
See bcgit/bc-java#972 for an upstream bug report.
vanitasvitae added a commit to pgpainless/pgpainless that referenced this issue Jun 15, 2021
BCs PGPPublicKey.getBitStrenght() appears to fail to recognize some elliptic curves.
In such cases, bitStrength is reported as -1.
I added BCUtil.getBitStrength(publicKey) to manually determine the bit strenght by OID.
See bcgit/bc-java#972 for an upstream bug report.
@dghgit
Copy link
Contributor

dghgit commented Sep 3, 2021

I've added recognition for the GNU oid for Ed25519 and Cryptlib Curve-25519. The fix will show up in 170b09.

@dghgit dghgit closed this as completed Sep 3, 2021
@vanitasvitae
Copy link
Contributor Author

Nice! 👍

vanitasvitae added a commit to pgpainless/pgpainless that referenced this issue Jan 10, 2022
vanitasvitae added a commit to pgpainless/pgpainless that referenced this issue Jan 15, 2022
vanitasvitae added a commit to pgpainless/pgpainless that referenced this issue Jan 15, 2022
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

No branches or pull requests

2 participants