3 ms·
What is the cool trick to implementing BER?
by pests 11y ago
What is the cool trick to implementing BER?
- tptacek 11y agoyou encode it back-to-front i don't even care anymore.
- signa11 11y ago> you encode it back-to-front sorry, but i still don't grok it. for example, if you take a person 'object' defined as : Person { name string (or equivalent asn.1 type-name, with type-identifier == 1) age int (or equivalent asn.1 type-name, with type-identifier == 2) } since b.e.r is basically a tlv (type-length-value) encoding, a person with name "james" with age '10' i.e. james_person = Person(name = 'james', age = 10) gets hex-encoded as : "james" : 01 05 6a 61 6d 65 73 "10" : 02 01 0A so the whole thing looks like this: "01 05 6a 61 6d 65 73 02 0A". ofcourse this would be prepended with appropriate type-number for 'Person' with corresponding length. if we assume that 'Person' gets a type-identifier == 3, then 'james_person' instance would be encoded as: "03 06 01 05 6a 61 6d 65 73 02 0A" where '06' == total length (6 bytes) of this instance of person object. may you please elucidate your trick with the above example ? thanks for your insights !