Repository navigation
Fix DERSignature serialization length and integer tag - #329
Open
kumar-miskin wants to merge 2 commits into
Open
kumar-miskin wants to merge 2 commits into
kumar-miskin wants to merge 2 commits into
Conversation
Related: petertodd#295. Prior art: petertodd#190 identified the missing sequence length. AI-assisted patch preparation and testing.
Cover exact encodings, leading-zero integer payloads, stream serialization and locally generated signatures that still verify after round-trip. AI-assisted patch preparation and testing.
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.
Fixes #295.
DERSignature.stream_serializeomits the SEQUENCE body length and writes a SEQUENCE tag (0x30) beforeswhere an INTEGER tag (0x02) is required. A valid signature such as3006020101020101currently serializes back as30020101300101, which cannot be deserialized.The change builds the two encoded INTEGER fields in a temporary stream, then writes the length-prefixed body after the SEQUENCE tag. It leaves deserialization and key signing/verification unchanged.
Prior art: #190 already identified the omitted sequence length, but was closed without merging. This patch addresses that omission and the second INTEGER tag reported in #295, with regression coverage. It is not a claim of a new discovery.
Tests:
python3 -m unittest discoverpasses all 152 tests on Linux/Python 3.10.12/OpenSSL 3.0.2.The helper is not used internally for signature serialization, as noted in #190. This is a focused fix to its public serialization behavior, not a change to consensus validation or live wallet signing. No Windows/multi-version test matrix run locally.
AI-assisted patch preparation and testing.