Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASN.1 Encoding #3

Open
hermanbanken opened this issue Sep 19, 2022 · 2 comments
Open

ASN.1 Encoding #3

hermanbanken opened this issue Sep 19, 2022 · 2 comments

Comments

@hermanbanken
Copy link

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.

@hermanbanken
Copy link
Author

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 🤔

@hermanbanken
Copy link
Author

Working a bit on it in 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).

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

No branches or pull requests

1 participant