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

proposal: encoding/asn1: allow setting params on elements of slices #39027

Open
rolandshoemaker opened this issue May 12, 2020 · 0 comments
Open
Labels
Proposal Proposal-Crypto Proposal related to crypto packages or other security issues
Milestone

Comments

@rolandshoemaker
Copy link
Member

rolandshoemaker commented May 12, 2020

encoding/asn1 currently provides a number of struct field tags to manipulate how fields are parsed/encoded, notably setting the time type, string type, or marking slices or structs as a SET rather than a SEQUENCE.

Unfortunately it is impossible to set these fields on elements of a slice. This makes it impossible to encode certain things like SEQUENCE OF IA5String or parse SEQUENCE OF SET (see #27426 and #18834 for examples).

The only real workaround for this is manually encoding/parsing each element of a slice with MarshalWithParams/UnmarshalWithParams, and then constructing/parsing a SEQUENCE yourself, which is obviously quite prone to errors and overly complex.

Ideally there would be a way to set parameters for each member of the slice. Probably the simplest solution to this problem would be adding a new struct tag, element-param:x or something, which would be passed through to makeField/parseField. For example this would then allow the following struct

type example struct {
	A []string `asn1:"element-param:ia5"`
}

to be encoded as a SEQUENCE OF IA5String.

cc @FiloSottile @katiehockman

@gopherbot gopherbot added this to the Proposal milestone May 12, 2020
@rsc rsc added the Proposal-Crypto Proposal related to crypto packages or other security issues label Jun 10, 2020
@ianlancetaylor ianlancetaylor added this to Incoming in Proposals (old) Jan 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Proposal Proposal-Crypto Proposal related to crypto packages or other security issues
Projects
Status: Incoming
Development

No branches or pull requests

3 participants