I spent a year of my life making an ASN.1 compiler in D Published: 2025/10/23 | Updated: 2025/10/23 … and it’s still nowhere near complete. In this post I’ll just rambling about ASN.1; parts of the compiler implementation, and some of the tool’s output rather than the tool itself as its still too WIP to really advertise on its own yet. This post is unstructured, so you can just pick somewhere random and start reading from there with no/minimal context lost. Note: the name of the tool is dasn1. Summary Motivation I’m currently writing Juptune - a toy async I/O framework that attempts to implement as much of its stack as possible in pure D. I’m really interested in writing an implementation of TLS, which means I need to be able to handle x.509 certificates (i.e. TLS/SSL certs), which means I need to be able to handle their underlying data encoding: ASN.1’s DER encoding. So basically I just wanted to do this for fun at the end of the day, nothing much deeper than that. I’ve never written or worked on a proper compiler project before that wasn’t toy-sized so I saw a ton of growth potential… the main thing that’s grown however is the mental scar ASN.1’s left on me. I’ve succesfully generated code that can parse a couple of x.509 certificates I’ve thrown at it, and I’ve started work on an almost-D-native (excluding crypto primitives) implementation of TLS 1.3. I’m constantly amazed about how much of modern life relies on these ancient, overly complicated specs from the 90s. ASN.1 is used everywhere in some form or another and yet I bet you’ve never even heard of it before, just have a look on wikipedia. Very briefly - what is ASN.1? ASN.1 is the result of a bunch of graybeards from the late 80s+ trying to design an overengineered data specification language. In other words, it’s protobuf on steroids. There’s two parts of ASN.1: There’s the ASN.1 notation (defined by x.680, x.681, x.682, and x.683), and then there’s the various encodings (BER, CER, DER, PER, XER, JER…). In...
First seen: 2025-10-23 13:31
Last seen: 2025-10-24 14:37