Remix.run Logo
lilyball 8 months ago

Oh right, the asn1 crate, which supports CHOICE but only up to 3 alternatives, which means it can't even be used to implement X.509 certificate decoding. Makes me wonder what they're going to do when they get that far.

woodruffw 8 months ago | parent [-]

I don't know why you think this; the asn1-rust crate is in fact used to implement not only X.509 certificate decoding[1] but also path validation[2].

Edit: Here's an example of a CHOICE implemented with rust-asn1 that has more than three variants[3].

[1]: https://cryptography.io/en/latest/x509/reference/

[2]: https://cryptography.io/en/latest/x509/verification/

[3]: https://github.com/pyca/cryptography/blob/be6c53dd03172dde6a...

Arnavion 8 months ago | parent [-]

The asn1 crate provides three builtin Choice enums itself - asn1::{Choice1, Choice2, Choice3} - which support 1, 2 and 3 choices respectively. I assume that is what lilyball is referring to. But as you correctly point out the custom derive supports mapping enums with more variants to CHOICE just fine, so the builtin enums are not a relevant limitation.