Encode primitive vs constructed form #6
Reference in New Issue
Block a user
Delete Branch "feature/constructed"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
SEQUENCEshould always be encoded as0x30which is0b10_0000 | 0x10which means type16in "constructed" form. Bit5 unset means "primitive" form and is illegal forSEQUENCEbut Go is strict and without this patch I couldn't get keys generated and encoded in Rust that Go would accept.Example public key I generated without this patch:
Example now with this patch:
https://github.com/hashgraph/hedera-sdk-rust/blob/master/examples/generate_keys.rs#L8
https://lapo.it/asn1js/ fails to parse
SEQUENCEas0x10as well.This appears to mask off the ASN.1 class associated with this tag. Is there something about large tag values that means that the class must be universal? I would have expected a mask of
0b11011111given the rest of your description.Another question; do you have any sources we can cite, somewhere in a comment, about this annoying thing? [I'll merge the change without such a source, pending the mask issue I pointed out, but I'd love to make this mask be not totally mysterious.]
Not sure I follow.
Class byte should be at most
0b11_00_00_00.Encoding form byte is
0b00_10_00_00.@acw See https://docs.microsoft.com/en-us/windows/desktop/seccertenroll/about-encoded-tag-bytes
Looking back at this we can simply change the sequence tag byte to 0x30 instead of my primitive flag
@acw Cleaned up the PR and cited documentation in the code
I'd appreciate if you could merge and release as soon as you can. I need to cut a new release of
hederaand am blocked on this. Anything else you need me to do, please let me know.... and pushed it to crates. It's version 0.2.1, for your Cargo.toml pleasure.
Thank you very much @acw 😄