apple / swift-asn1

An implementation of ASN.1 for Swift
https://swiftpackageindex.com/apple/swift-asn1/main/documentation/swiftasn1
Apache License 2.0
137 stars 25 forks source link

Feature request: Extend PEM parsing to support additional formats #49

Open wiedem opened 10 months ago

wiedem commented 10 months ago

The PEM parsing and generation implemented in PEMDocument doesn't fully support the PEM format as defined in RFC1421.

In particular, fields such as Proc-Type and DEK-INFO are not supported, which means that formats as defined in RFC5915 cannot be processed:

-----BEGIN EC PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,A4E9C3555C149C675E03B622A42500D2

<snip>
-----END EC PRIVATE KEY-----

It would be advantageous if the processing of these additional fields were supported by the PEMDocument, as otherwise some PEM files cannot be processed properly.

Lukasa commented 10 months ago

Yeah this is totally an existing limitation. I believe we designed the type such that extending it for this use-case was possible, but the core feature set didn’t require it. We’d welcome a PR to add the function.