fix(ecdsa): narrow hex char validation in Signature::from_str#1253
Closed
PrarthanaPurohit wants to merge 3 commits intoRustCrypto:masterfrom
Closed
fix(ecdsa): narrow hex char validation in Signature::from_str#1253PrarthanaPurohit wants to merge 3 commits intoRustCrypto:masterfrom
PrarthanaPurohit wants to merge 3 commits intoRustCrypto:masterfrom
Conversation
Member
|
Closing in favor of #1255. |
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.
The Issue:
The original code was validating hex strings with an incorrect pattern:
This was checking for:
0-9✓a-z✗ (should be onlya-f)A-Z✗ (should be onlyA-F)The Problem:
The validation was accepting invalid hexadecimal characters like
g-zandG-Z, which would cause parsing errors later when trying to convert the string to a signature.The Fix:
Changed to the correct hex validation pattern:
Now it properly validates only valid hexadecimal characters (0-9, a-f, A-F), preventing invalid input from passing the initial check and ensuring the
from_strimplementation correctly rejects non-hex strings early.