Skip to content

Harden ASN.1 stream materialization, add id-kp-imUri, and lower PBE iteration ceiling#137

Merged
Xor-el merged 4 commits into
masterfrom
enhancements/Asn1-related-refactorings
Jul 7, 2026
Merged

Harden ASN.1 stream materialization, add id-kp-imUri, and lower PBE iteration ceiling#137
Xor-el merged 4 commits into
masterfrom
enhancements/Asn1-related-refactorings

Conversation

@Xor-el

@Xor-el Xor-el commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add TKeyPurposeId.IdKpImUri (1.3.6.1.5.5.7.3.40) for RFC 5280 key purpose identification.
  • Harden ASN.1 stream materialization:
    • Add TLimitedInputStream leave-open support and update PipeAllLimited accordingly.
    • Materialize definite-length payloads incrementally via TLimitedCapacityMemoryStream instead of allocating the full declared length up front.
    • On FPC, CopyTo / ReadAll / ReadFully dispatch through Read(var), so move bulk-read logic onto Read(var) for definite-length, indefinite-length, constructed octet, and constructed bit streams (TArray delegates down). This avoids byte-at-a-time fallback paths when materializing large BER/DER payloads.
  • Lower the default PBE/PBKDF2 iteration ceiling from 10_000_000 to 5_000_000, expose CheckPbeIterationCount for early validation, and add PKCS#8/PBES2 regression tests for the new limit.

Xor-el added 4 commits July 7, 2026 23:07
Add TKeyPurposeId.IdKpImUri (1.3.6.1.5.5.7.3.40), TLimitedInputStream
leave-open support with PipeAllLimited updated accordingly, and
incremental DefiniteLength ToArray via TLimitedCapacityMemoryStream.
On FPC, CopyTo/ReadAll/ReadFully dispatch through Read(var), so move bulk
read logic onto Read(var) for DefiniteLength, IndefiniteLength,
ConstructedOctet, and ConstructedBit streams (TArray delegates down).
This ensures large BER/DER payloads materialize through efficient bulk
reads instead of byte-at-a-time fallback paths.
…ests.

Lower default PBE iteration ceiling to 5_000_000 and add regression tests.

Expose CheckPbeIterationCount so callers can validate PBKDF2 iteration
counts before key derivation, and add PKCS#8/PBES2 tests for the new limit.
@Xor-el Xor-el merged commit a9e30df into master Jul 7, 2026
24 checks passed
@Xor-el Xor-el deleted the enhancements/Asn1-related-refactorings branch July 7, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant