Reduce num dependencies, improve class implementation and add explicit tags #7
Reference in New Issue
Block a user
Delete Branch "master"
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?
Hi,
I used yasna to parse ASN.1 before, but as it is not maintained anymore since a while I switched to this library. It works great for almost everything I want to do, just one thing is missing to encode OpenSSL EC keys.
OpenSSL uses for some reason an explicitely tagged value, which is in general used to distinguish multiple optional values with the same type. In the encoding it is a block where the
constructedflag is set and the type is notUniversalwhich wraps another block.I did some reading on ASN.1 and DER (mostly this) and came up with the following:
The default datatypes always have Universal as their class. If we
encounter another class while parsing, it is a tagged block.
I am not sure how (and if at all) we can distinguish explicitly and
implicitly tagged data. For now they should be parsed as unknown (or
explicit if they are a valid ASN.1 block).
PS: As a small change I copied a small pull request from yasna, that reduces the dependencies quite a bit by only importing the needed num crates.
Interesting. The version number stuff is a no-brainer, obviously. Thanks for that.
I'm curious, do you have an online citation for your class/tag interaction? I'm not doubting you -- I looked at what I'll admit was a pretty basic set of resources when I wrote this -- but I'd love to have something I could point at. Failing that, I should accept that if my test cases pass, this must be a correct interpretation of spec. :)
Thanks for taking the time to look at my pr.
I got most information from http://luca.ntop.org/Teaching/Appunti/asn1.html.
Sometimes it is a bit cryptic to read. In the beginning of section 2, it talks about the different classes of tags and for me it seems like only for
Universal, the types are defined.This StackOverflow answer gives a nice explanation why tagging is sometimes needed: https://stackoverflow.com/questions/3296761/i-need-an-example-to-understand-implicit-tagging-in-asn-1
I am by no mean an asn.1 expert, so if you find something that looks fishy, tell me.
Btw your quickcheck tests were really valuable and found one or two bugs in my changes. :)
Cool, that helps. And yes, I ❤️ QuickCheck :)
... and this is now pushed to crates.io as 0.3.0. Thanks for the patch!
Thanks!
With this change,
ToASN1::to_asn1_classfeels very odd to use (as it passes in a class and ASN1Blocks no longer take the class in all forms.@acw Also, have you thought about #5 ?