Decoding output a bit unintuitive #13
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
In the below script, the function
test_encodeprints:This is unexpected as the structure is the same in both occasions, and it appears to relate to this. I would expect the output to be as it is in
bboth times. I'm not exactly sure if the encoding is being done in the best way, but it conforms to the ASN model I am working with so I can't change it. For reference, the Haskell libraryasn1-encodingproduces the following:Test script:
OK, interesting. Let me track back the reason for that particular
if. Upon first examination, it does seem very suspicious.Also, welcome fellow Haskell/Rust polyglot.
Seems like I introduced that code in #7.
I don’t remember why I wrote it that way, the goal was to parse OpenSSL EC keys, which contains explicitly tagged data. This comment might be the reason:
Hmmmm! Maybe we can work together so we don't replicate each others work? Specifically:
@Flakebi: could you maybe commit an OpenSSL EC key or two in
tests/, and maybe a test case that shows what you need the output to be?@ssadler: could you commit this test case somewhere reasonable, with an
assertfor what you'd expect things to look like?Maybe do this all in a
fix/13branch, since this will all be broken for a bit? Then we can all look for what the best solution is to meet both goals.I've made a branch here with the test: https://github.com/ssadler/simple_asn1/tree/fix/13
It passes without the the
if constructed {block here. There's also a suggested fix for a warning but I don't know if it gives the right behavior.I added a small test with an explicit tag in #14.
So, after doing some digging, I found this interesting quote:
(source, page 409)
Which makes me think that the current implementation is definitely wrong, but that the example @ssadler brings up might also have a not-entirely intuitive resolution. Anyone else find any interesting quotes on the topic of explicit tags?
I don't actually know how ASN works; my only thought is, was it tagged in Explicit mode? In this case there's no schema to indicate what mode it was tagged in, the parsing function just parses what it can according to what it knows.
The only other thing that occurrs to me, and again limited by my lack of knowledge of ASN, is that the parser could eagerly descend into the element and parse the children.