Repository navigation
ecparams: accept zero-padded curve constants and non-DER cA BOOLEAN - #37
Merged
Merged
Conversation
Compare the explicit-parameter curve constants A and B as numbers so a leading 0x00 pad (UAE CSCA 02, 49-byte P-384 A/B) still matches a known curve, and normalise a BER-style TRUE cA BOOLEAN in basicConstraints (CSCA-UKRAINE) for the stdlib parse while restoring the original bytes. Adds both real CSCAs as testdata, padded/BER tests and fuzz seeds. Closes #36 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Split normalizeBasicConstraints into readExtensions/patchBasicConstraints and factor shared test helpers. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Some fuzz seeds cannot reach the intended parser path, and public documentation overstates the accepted padding behavior.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds opt-in support for padded EC constants and BER-style basicConstraints booleans.
Changes:
- Compares EC constants numerically.
- Normalizes non-DER
cAbooleans while preserving original bytes. - Adds fixtures, tests, fuzz seeds, and documentation.
| File | Description |
|---|---|
README.md |
Documents accepted encodings. |
ecparams/ecparams.go |
Implements normalization and numeric comparison. |
ecparams/helpers_test.go |
Extends certificate test builders. |
ecparams/padding_bool_test.go |
Adds regression and tampering tests. |
ecparams/fuzz_test.go |
Adds fuzz seeds. |
ecparams/testdata/csca_are_padded_constants.pem |
Adds UAE certificate fixture. |
ecparams/testdata/csca_ukr_ber_boolean.pem |
Adds Ukraine certificate fixture. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…claim to A and B Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
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
Fixes the two certificates left unparsed by the
ecparamsMaster List run (#36), both opt-in (nothing changes unlessecparams.Registeris called):0x00pad (49-byte A/B on P-384, UAE CSCA 02) still matches the known curve. Every value must still equal the known number exactly. TheVerifierpath re-derives the key on the table curve and handles the certificate (tested).basicConstraintsextension whosecABOOLEAN is BER-style TRUE (any non-zero octet, e.g.0x01in CSCA-UKRAINE) is normalised to0xFFfor the stdlib parse only. Same-length patch of that one octet in a copy; the original extension value,Raw,RawTBSCertificate,Signatureare restored, nothing is re-encoded in the result.What stays rejected
Tests
Hand-built padded-A/B certificates on all 7 curves (P-384 and a brainpool curve included) parse and verify; BER-boolean certificates (named curve, explicit params, with pathLen); both real CSCAs added to
ecparams/testdatawith provenance headers (sha256 checked in the test); fuzz seeds extended (fuzzed 30s, no findings). ecparams coverage 97.2%; golangci-lint/vet/gofmt clean.Real numbers (BSI German Master List, 608 certificates)
Before: 606 parsable, 2 failing. After:
Docs: ecparams package doc and README section updated.
Note for release: v0.7.1
Closes #36
🤖 Generated with Claude Code