Reject small-order Ed25519 public keys in Validate - #36
Merged
Conversation
…#1352) ed25519PublicKey::Validate checked public-key canonicality but did not reject small-order points. That left the identity-point case from #1352 accepted by Validate even though it is not a valid Ed25519 public key for strict validation. Wire the existing HasSmallOrder helper into ed25519PublicKey::Validate at level >= 2. Canonical encoding checks still run at all validation levels; small-order rejection is part of the stricter validation path. validat7.cpp covers the validation-level boundary: the identity key is accepted at level 0, rejected at level 2, and a fresh keypair remains accepted at level 2. validat9.cpp keeps the non-canonical public-key test scoped to canonicality by running it at level 1. Its baseline pk_id and pk_pminus1 values are also small-order points, so level 2 would test two properties at once.
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.
Summary
This closes the remaining small-order public key part of upstream issue
weidai11/cryptopp#1352.ed25519PublicKey::Validatenow rejects small-order Ed25519 public keys at validation level 2 and above. The existing canonical encoding check still runs at all validation levels, so level 0 behaviour is unchanged.What changed
ed25519PublicKey::Validatenow uses the existingHasSmallOrderhelper at level 2 and above.validat7.cppadds coverage for the level boundary: identity accepted at level 0, identity rejected at level 2, fresh keypair accepted at level 2.validat9.cppnow runs the non-canonical public-key test at level 1 so it stays scoped to canonicality.This follows upstream commit
weidai11/cryptopp@4775a166.