Open hermanbanken opened 1 year ago
Would be nice to write ASN.1 as in https://gist.github.com/hfossli/00adac5c69116e7498e107d8d5ec61d4:
let tlv = ASN1.DER.TLV
.sequence([
.sequence([
.objectIdentifier("1.2.840.10045.2.1"),
.objectIdentifier("1.2.840.10045.3.1.7")
]),
.unknown(Data(hex: "0342000474338D364C1A3FC3A1A854E68CBC55701CB23DAD7D89F6362150E29C57A2DD2BC206FF1F818F0053E166E6838392CB1E574B1DE19CBF6E249FE8032BD07A8773")!)
])
and then write out to Data
🤔
Working a bit on it in https://github.com/DominikHorn/ASN1Parser/compare/main...hermanbanken:ASN1Parser:main.
Maybe this also is what #1 author is trying to do (hence exposing the swiftValue
), or maybe it is just the usage of the digit, not sure. But I also exposed it at first before moving the Encoder inside the fork (had an extension in my own codebase at first).
This package provides amazing Decoding support, but I'm struggling to find how to perform Encoding.
My use case is some CryptoKit.Curve25519.PublicKey data which I want to be encoded as DER, which unfortunately Apple's native API's can't do either (ref and ref).
Wouldn't it be quite straightforward to add
toDER
functions to all types to support this? I don't want to write all tags in my end-user codebase, but rather reuse the ones from a library such as this one.