3 ms·
The difference is really just that the ASN.1 tag really just contains the data type, with limited application-level space to describe it. JSON/XML let you us a
by rkeene2 5y ago
The difference is really just that the ASN.1 tag really just contains the data type, with limited application-level space to describe it. JSON/XML let you us an arbitrary string to "tag" data.
ASN.1, on the other hand, has many more types (as we can see in this article!) including dates, big integers, choices, sequences, and more.
- pas 5y agoSorry, I wasn't precise enough. I meant some kind of JSON with just arrays and cryptic object names - like the OIDs for ASN1 - or XML where everything is just called <node>. So yes, it makes things less "introspectable", but any serious protocol needs a well-defined schema anyway. (And that's why GraphQL and OpenApi/JsonSchema, and before that WSDL/SOAP were so popular.) It seems strange that people "hate" ASN1. At best the problem seems to be the libraries, or that no sane restricted subset has emerged over the years...?
- rkeene2 5y agoI've been thinking about a good way to explain this for a couple of days I think the best way is convert the ASN.1 to some psuedo-typed-JSON. For an X.509v3 public key, the ASN.1 would look like this in JSON-with-types: [ [ [type:<oid>]: "1.2.840.113549.1.1.1", [type:<null>] ], [type:<bitstring>]: <encoded>[ [type:<bigint>]: 39054839120582390568029762340674230..., [type:<bigint>]: 65537 ] ] "<encoded>" here means an ASN.1 value is serialized and then contained as a binary string. As you can see here, you only know the structure and type. This falls apart here at the "bitstring" value -- it's an opaque binary blob, which happens to be ASN.1 again, which you would only know if you know the schema. If we converted this to something more self-describing it would look more like (borrowed kind of from TJSON): { "publicKeyInfo:<o<oid,...>>": { "publicKeyType:<oid>": "1.2.840.113549.1.1.1", "publicKeyParams:<null>": null }, "publicKey:<o>": { "n:<bigint>": "39054839120582390568029762340674230...", "e:<bigint>": "65537" } } Having this kind of human description in addition to the type and structure makes it easier to work with if you don't know what's inside the structures.
- pas 5y agoThanks! This indeed is absolutely horribly insane, yet I guess there are some good-ish reasons for why this is the way this is.