ASN structure reading optimizations#107
Merged
microshine merged 8 commits intomasterfrom Sep 8, 2025
Merged
Conversation
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.
Overview
This update introduces significant performance improvements focused on optimizing the reading and parsing of ASN.1 structures, particularly for large certificates, CRLs, and certificate requests. The changes implement lazy loading patterns and leverage existing raw ASN.1 data to reduce computational overhead.
Key Changes
1. Lazy Property Loading
Impact: Expensive computations (parsing extensions, creating Name objects) are deferred until properties are actually accessed, improving initialization time for large structures.
2. Raw ASN.1 Data Utilization
asn.tbsCertificateRawfor ToBeSigned blockasn.tbsCertListRawfor ToBeSigned blockasn.certificationRequestInfoRawfor ToBeSigned blockImpact: Eliminates redundant serialization of already-parsed ASN.1 data, reducing memory usage and CPU time for large certificates.
3. Optimized CRL Entry Search
BufferSourceConverter.isEqual()for byte-level serial number comparisonX509CrlEntryobjects when matches are foundImpact: Dramatically improves performance for large CRLs by avoiding full parsing of all revoked certificates during search operations.
4. DER Detection Optimization
Impact: Faster processing of large DER-encoded data by avoiding unnecessary conversions.
5. Constructor Improvements
Backward Compatibility
All changes maintain full backward compatibility. Existing code will continue to work without modifications, but will benefit from the performance improvements automatically.
Version Recommendation
It is recommended to release this update as a minor version bump due to the internal changes from public properties to getters. While the public API remains the same, the type declarations have changed, which may cause minor TypeScript compatibility issues when upgrading from older versions. This ensures users are aware of the potential need to update their type definitions or rebuild their projects.