Fix: Add ASN header bytes support for CoRIM commands (#23) #44
+363
−0
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.
Overview
This PR resolves issue #23 by adding automatic detection and stripping of ASN header bytes in CoRIM files.
Problem
Several vendors distribute CoRIM manifest files with ASN header bytes (
d9 01 f4 d9 01 f6) at the beginning, which caused cocli to fail with CBOR decoding errors:Solution
stripASNHeaderBytes()function that automatically detects and removes ASN header patternd9 01 f4 d9 01 f6display,verify, andextractnow strip ASN headers before processingsubmitcommand: Intentionally unchanged to maintain original file format when submittingChanges Made
Core Implementation
cmd/common.go: AddedstripASNHeaderBytes()utility functioncmd/corimDisplay.go: Added ASN header stripping to display commandcmd/corimVerify.go: Added ASN header stripping to verify commandcmd/corimExtract.go: Added ASN header stripping to extract commandTesting
cmd/common_test.go: Comprehensive unit tests for ASN header strippingcmd/corim_asn_integration_test.go: End-to-end integration testsTesting Results
All existing tests pass - no breaking changes
New unit tests cover all edge cases
Integration tests verify end-to-end functionality
Manual testing confirms files with ASN headers now work correctly
Usage
Users can now process vendor-distributed CoRIM files with ASN headers without any manual preprocessing:
# These commands now work automatically with files that have ASN headers cocli corim display -f vendor-corim-with-headers.cbor cocli corim verify -f vendor-corim-with-headers.cbor -k key.jwk cocli corim extract -f vendor-corim-with-headers.cbor -o output/Related