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
proposal: encoding/asn1: extend support to rfc2578, application-define types and opaque sub-types #63399
Comments
What does support look like for the package? API changes, behaviour changes, etc. |
Given the exiting tag-based design, I would suggest: The additional un/marshal tags to be added
The default marshaling behavior to change from
|
CC @agl @FiloSottile @golang/security |
Ok I was able to get most of the integer, application types working by playing with the existing
It would definitely be more clear as a single I have not been able encode any of the Opaque sub-types yet though. |
Ok, after looking into this more I wrote some comparison tests against
Given this, I'd like to refine the proposal further with: The default marshaling behavior to change from
and the only additional
So this tag would use opaque encoding for |
It's not clear to me that we should add this functionality to encoding/asn1. These specific types are not ASN.1 base types, they are SMI/SNMP application types, and as such they should be handled by the user (the application), rather than being handled by encoding/asn1. From a quick skim of the specification almost all of these types can be handled without any fancy encoding using the
The opaque types are a bit weird, given that they are arbitrary encodings, wrapped in an OCTET STRING, but this can be accomplished by just using a []byte field and populating it with the result of the defined encoding (most of these encodings seem unrelated to BER, the float one appears to use the textual encoding from RFC 6340) for the wrapped type, before marshaling the entire struct (or just the byte slice if you're not marshaling a struct). I.e.
|
@rolandshoemaker my bad. I think I have just been looking at too much SNMP code that doesn't delineate where ASN.1 stops and SMI begins. The |
I was working on
gosnmp/gosnmp
and noticed it needed to ASN1 encode many values internally. When I tried to offload this work toencoding/asn1
instead, I found that it did not provide support for rfc2578 application-defined types used often in SNMP:In addition to the above types, SNMP libraries also normaly explicitly support
Opaque
subtypes:OpaqueFloats
,OpaqueDouble
,OpaqueI64
andOpaqueU64
as defined in this draft rfc. While I am not thrilled that it is a draft RFC, it is adopted explicitly by net-snmp, other SNMP libraries followed suit, and then it showed up in MIBs (example MIB usage getting battery charge level).I also imagine these types would/could be used in x509 encoding, but i don't have any examples offhand.
The text was updated successfully, but these errors were encountered: