Monday, 22 August 2011

BER-TLV Parsing

One of the EMV devices I need to connect to uses the BER-TLV (wiki) protocol for communications. Simply put, data fields are defined by a (T)ag, (L)ength and (V)alue.
  •  The tag field (T) consists of one or more consecutive bytes. It codes a class, a type, and
    a number:

  • The length field (L) consists of one or more consecutive bytes. It codes the length of
    the following field.
  • The value field (V) codes the value of the data object
Sample code removed

8 comments:

  1. Nice - but where is ByteList defined?

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. @drshade - Thanks, seems I left that out. I don't have ready access to the code right now, but for this purpose, you can just create your own:

    public class ByteList : List
    etc.

    ReplyDelete
  4. Struggling to format the code here. ByteList just extends a generic List of type byte...

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete