BER-TLV Open Source Library for Objective-C

I intend to parse the BER-TLV format from a smart card response for data interpretation.

it is similar to JACCAL , but in Objective-C or C ++

Can someone give a link to any open source project or any link for this?

+6
source share
2 answers

Here is a project decoding the ASN.1 BER format. https://github.com/chrisridd/asn1-dump/

main logic located in this file: https://github.com/chrisridd/asn1-dump/blob/master/berd.m

And if you have enough time, it’s not difficult for you to write your own decoder after you read the standard: http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf http: //luca.ntop.org/Teaching/Appunti/asn1.html

the decoding stream looks like this: read in tags, length, sequence of values.

  • From the tag you will receive

    • The data class, as a rule, is universal (a predefined type in the standard form, like "Logical", "Sequence" ...) and context-sensitive (to distinguish different fields of the same type).
    • Primitive (e.g. boolean and integer) or Constructed (usually a sequence). because a built type can contain a primitive or built type. recursive decoding may be required.
    • Tag number, define data types (boolean? Integer? Bitstring?)
  • Length:

    • Determine the length of the content for decoding (recursive decoding may be required). Length
    • has two forms (short and long). you better support both.
  • Value: The actual value to read at the current TLV level. if it is constructed data (for example, a sequence), the value will contain the internal TLV level.

At the end of the standard (http://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf) there is an image showing a multi-level TLV, perhaps it may help you should understand BER.

After you read the standards, the best way: 1) find some GUI viewer to look at some BER certificate file to get to know it. google "ASN.1 viewer" to find. 2) start watching the code https://github.com/chrisridd/asn1-dump/blob/master/berd.m

+4
source

How about tlve? http://tlve.sourceforge.net/

Apple Tokend also seems useful: http://www.opensource.apple.com/source/Tokend/Tokend-36720/PIV/TLV.cpp

jayacard on sourceforge is another project that deals with this now seems abandoned, but the source is here: http://www.codeforge.com/read/7149/tlv.c__html

0
source

All Articles