-
Notifications
You must be signed in to change notification settings - Fork 20
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
How to represent "ANY IDENTIFIED BY ..." #14
Comments
I'd use a choice and postprocessing, similar to how we do it in X.509: https://github.com/mirleft/ocaml-x509/blob/master/lib/asn_grammars.ml#L332-L418 (no EC support there yet). Maybe the parsing code (and esp. the ASN OID registry) should be a separate OPAM package, so that we do not have to duplicate this information in all the packages? |
I see what you mean. You cannot encode different I had a combinator in mind would would allow expressing this cleanly. I'll hack it in the next few days, and get back to you. In the meantime, would you mind checking how does the other branch work for you? The parser changed and has different performance tradeoffs, but that's the branch I intend to continue working from. |
Sure ! I'll give it a try |
Ok so I installed the new The following is the base64 encoding of the DER-encoded EC private key we use as test
This is how the grammar was expressed:
The test passes with the current version and fails with the one you gave me. And this is how it should be:
This passes the test with both the current and the future version. |
Guys, I'm trying to implement PKCS12 (https://tools.ietf.org/html/rfc7292) and I ran into the same problem:
KeyBag and CertBag are both sequences and I tried to implement them through |
FWIW, I took a look on PKCS12 some time ago at mirleft/ocaml-x509#114 and avoided the ANY issue (though the asn1 looks pretty ugly) |
Oh, it would be better for me, if I had found this PR before started :) (NightBlues/ocaml-x509#1) |
First of all I'd like to thank you for your work, asn1-combinators is a great library and
I'm using it every day.
At cryptosense we're open sourcing some the of the asn1 cryptographic key parsers we've wrote
so far and we're facing an issue.
I'm trying to express an ASN grammar for
algorithmIdentifier
which is defined inRFC 5280 as:
When only considering RSA and DSA, it works well because RSA params are
NULL
and DSA ones area 3 integer sequence. The thing is when adding EC keys to the equation the grammar becomes
ambiguous because EC parameters can also be a sequence, even though it's completely
different from the DSA one.
Currently we have a different grammar for each key types and the generic
decode
functionis a very ugly doubly nested
try ... with Asn.Parse_error _ ->
.I wrote a wildcard grammar with
choice
andfix
allowing me to accept "almost" everythingbut then I have to manipulate the recursive type and to write converters from and to it which
adds a lot of code and doesn't really look prettier in the end.
ASN.1 construction like:
is pretty usual and I guess I'm not the only one that could run into this kind of problem.
I'd really like to know what you suggest to adress this issue.
Thank you :)
The text was updated successfully, but these errors were encountered: