we (web engine): Experimental web browser project to understand the limits of Claude

ASN.1 DER parser #52

open opened by pierrelf.com

Phase 5: Pure Rust Crypto#

Implement an ASN.1 DER (Distinguished Encoding Rules) parser in the crypto crate. This is needed for X.509 certificate parsing and RSA/ECDSA key parsing.

Requirements#

  • Parse DER-encoded TLV (Tag-Length-Value) structures
  • Support primitive types: INTEGER, BIT STRING, OCTET STRING, NULL, OID, UTF8String, PrintableString, IA5String, UTCTime, GeneralizedTime, BOOLEAN
  • Support constructed types: SEQUENCE, SET
  • Support context-specific tags (implicit and explicit)
  • OID encoding/decoding (dotted notation and binary)
  • Nested structure traversal

Acceptance Criteria#

  • DerParser that reads TLV items from a byte slice
  • Parse all ASN.1 types needed for X.509 and PKCS#1
  • OID comparison (e.g., oid == OID_SHA256_WITH_RSA)
  • Parse nested SEQUENCE/SET structures
  • Handle context-specific tagged values [0], [1], etc.
  • Reject non-DER encodings (indefinite length, non-minimal integers)
  • Test with real DER-encoded certificate fragments
  • cargo test -p we-crypto passes
  • cargo clippy -p we-crypto -- -D warnings clean
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mgemu42xz62k