Test PGPSignatures with LegacyEd25519 keys with short MPIs - #1706
Closed
vanitasvitae wants to merge 1 commit into
Closed
Test PGPSignatures with LegacyEd25519 keys with short MPIs#1706vanitasvitae wants to merge 1 commit into
vanitasvitae wants to merge 1 commit into
Conversation
vanitasvitae
commented
Jun 12, 2024
| { | ||
| byte[] a = BigIntegers.asUnsignedByteArray(sigValues[0].getValue()); | ||
| byte[] b = BigIntegers.asUnsignedByteArray(sigValues[1].getValue()); | ||
| if (a.length + b.length == Ed25519.SIGNATURE_SIZE) |
Contributor
Author
There was a problem hiding this comment.
Here, a.length or b.length could be 31 instead of the the expected 32.
Since Ed25519 signatures are shorter than Ed448 signatures, the new comparison should hold.
Contributor
Author
|
The test vector (see as PGP packet here) demonstrates the issue by having a short 31-octet |
vanitasvitae
force-pushed
the
fixEd25519SignatureParsing
branch
2 times, most recently
from
August 8, 2024 10:24
4894655 to
32ecff8
Compare
Contributor
Author
|
Fix is already part of main, so I reduced the PR to only contain the test. |
ligefeiBouncycastle
self-requested a review
September 4, 2024 06:32
hubot
pushed a commit
that referenced
this pull request
Sep 11, 2024
hubot
pushed a commit
that referenced
this pull request
Sep 11, 2024
#1706 Test PGPSignatures with LegacyEd25519 keys with short MPIs See merge request root/bc-java!31
Contributor
Author
|
In main as c51be49 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With legacy ed25519 we need to detect the curve (curve25519 / curve448) based on the length of the encoding (see #1675, most notably 105dbef).
However, I noticed, that some ed25519 signatures MPIs are shorter than the expected 2*32 octets (leading 0s), resulting in the code misinterpreting the signature as an ed448 signature. This in turn causes signature verification failures for good signatures.
This patch catches this edge case by allowing short MPIs.