AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 19 Bitcoin

Merge bitcoin-core/secp256k1#1924: tests: add coverage for the DER long form length encoding

Public commit record

What the developer wrote

Authored by merge-script

96/100 · Strong
Merge bitcoin-core/secp256k1#1924: tests: add coverage for the DER long form length encoding

ddb1dfa77038442dff86ba90e6d0a30adfddef17 tests: add coverage for the DER long form length encoding (Bruno Garcia)

Pull request description:

random_ber_signature only emits long form lengths in signatures it marks as certainly_not_der, so run_ecdsa_der_parse asserts that such inputs are rejected but never that a well-formed long form length is accepted. As a result, inverting any of the four conditions in secp256k1_der_read_len that govern the long form goes unnoticed by the test suite.

Add the accepting cases, together with the two rejecting ones that share their boundaries: a length below 128, which must use the short form, and length octets with a leading zero. Since DER permits the long form only for lengths of at least 128, which a signature with two in-range scalars never reaches, the R integers in the accepting cases necessarily overflow to zero; the test checks the parsed values so this stays pinned down.

I noticed this lack in the tests while working on mutation testing for the ecdsa impl. So these tests kill the following mutants: https://secp256k1.space/src/ecdsa_impl.h#863, https://secp256k1.space/src/ecdsa_impl.h#878 and https://secp256k1.space/src/ecdsa_impl.h#896

ACKs for top commit:
real-or-random:
utACK ddb1dfa77038442dff86ba90e6d0a30adfddef17
theStack:
ACK ddb1dfa77038442dff86ba90e6d0a30adfddef17

Tree-SHA512: 281460890a96f3beaa294e3a14dc447316cc698f36f9087b36ae8e2bbaa422152588f083c4b293cad7fe4b84497a24fde55d04977e8f306f35fd51353f41cc28
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit only adds new test cases to the libsecp256k1 test suite. It does not change any production cryptographic code. The new tests check that the DER signature parser correctly handles an unusual but valid length-encoding format (the 'long form'), and that it rejects certain invalid variants. It is a hardening of test coverage, not a fix for a known bug or vulnerability.

Recommended action

No security action required. Treat as normal test-suite improvement. If auditing, verify that the existing secp256k1_der_read_len behavior matches the test expectations, but the commit itself introduces no defect.

Security signals we found

01

Adds test coverage for DER long-form length encoding acceptance and rejection

02

Targets secp256k1_der_read_len boundary conditions

03

No changes to src/ecdsa_impl.h or any production parsing logic

04

Pull request description frames this as mutation-testing hardening, not a vulnerability fix

Risk score

Why this scored 19/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 5/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.