Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Go - decode/encode asn.1

Tags:

go

asn.1

Does anyone know where there is a good example of how to use the asn1 Marshal and Unmarshal funcs in Go?

I'm familiar with the concept of how DER encoding with ASN.1 works, but do not have experience dealing with it directly in code (usually I'm using another library with wraps it - openldap or whatever).

Yes, I've looked at the documentation (http://golang.org/pkg/encoding/asn1/), which seems to describe a tagging system much like what is available for JSON and XML in Go; however I have yet to find a good practical example of this anywhere for the encoding/asn1 package. (Hm, okay I see the Certificate example in asn1_test.go - anyone know of anything else?)

(Overall, I'm trying to implement a very small subset of LDAP (the server side) in Go.)

UPDATE: My question is flawed by the fact that LDAP uses BER, not DER. So encoding/asn.1 isn't going to help. In any case, I ended up making this: https://github.com/bradleypeabody/godap (which uses this for BER+ASN1: https://github.com/go-asn1-ber/asn1-ber )

like image 463
Brad Peabody Avatar asked Oct 30 '14 23:10

Brad Peabody


1 Answers

https://web.archive.org/web/20160816005220/https://jan.newmarch.name/go/serialisation/chapter-serialisation.html

and

https://ipfs.io/ipfs/QmfYeDhGH9bZzihBUDEQbCbTc5k5FZKURMUoUvfmc27BwL/dataserialisation/asn1.html

have quite a few examples with asn1.Marshal / asn1.Unmarshal

like image 98
dave Avatar answered Sep 19 '22 11:09

dave