3

我有以下 BERTLV: 61394F0BA00000030800001001234579074F05A000012345500E49442D4F6E65205049562042494F5F50107777772E6F626572746875722E636F6D7F66080202800002028000

我正在尝试以递归方式解析它,因此我将第一部分视为 TLV。

标签: 0x61, Len: 0x39, 值:4F0BA00000030800001001234579074F05A000012345500E49442D4F6E65205049562042494F5F50107777772E6F626572746875722E636F6D

然后我进一步分解它,得到

标签: 0x4F, Len: 0x0B, 值: A000000308000010012345

现在,我该如何停下来?在这一点上,我知道这个值是这个 TLV 的最后一段,而不是另一个嵌套的 TLV。

4

2 回答 2

5

好吧,经过大量挖掘,我发现简单TAG实际上不仅仅是一个数字,它TAG本身实际上编码了其中的早午餐信息。我为了找出TLV包含是否嵌套TLV,以便我的代码知道何时继续处理以及何时停止,我必须解码TAG.

所以TAG包含 8 位,每个位都有特殊含义:

TLV TAG 及其位的含义

我需要的一点是B5为了确定 current 是否TLVConstructed……什么时候Constructed意味着 currentTLV由多个 组成TLV,所以对于我的代码,我正在使用这些信息递归地挖掘嵌套的TLV.

TLV不是 Constructed是我停止冒泡的情况。

这是我通过解析数据并检查位的递归函数B5输出TAG

11:20:38.428 Parsing: 61394F0BA00000030800001000010079074F05A000000308500E49442D4F6E65205049562042494F5F50107777772E6F626572746875722E636F6D7F66080202800002028000
11:20:38.436 Constructed Data Object
11:20:38.437 Parsing: 4F0BA00000030800001000010079074F05A000000308500E49442D4F6E65205049562042494F5F50107777772E6F626572746875722E636F6D
11:20:38.437 Primitive Data Object
11:20:38.437 tag: 79, len: 11, value: A000000308000010000100
11:20:38.437 Constructed Data Object
11:20:38.437 Parsing: 4F05A000000308
11:20:38.437 Primitive Data Object
11:20:38.437 tag: 79, len: 5, value: A000000308
11:20:38.437 Primitive Data Object
11:20:38.437 tag: 80, len: 14, value: 49442D4F6E65205049562042494F
11:20:38.437 MultiByte tag
11:20:38.437 Primitive Data Object
11:20:38.437 tag: 24400, len: 16, value: 7777772E6F626572746875722E636F6D
11:20:38.438 MultiByte tag
11:20:38.438 Constructed Data Object
11:20:38.438 Parsing: 0202800002028000
11:20:38.438 Primitive Data Object
11:20:38.438 tag: 2, len: 2, value: 8000
11:20:38.438 Primitive Data Object
11:20:38.438 tag: 2, len: 2, value: 8000
于 2017-01-26T16:24:28.333 回答
1

问:现在,我该如何停止?

A: TAG Length (0x0B) 以 HEX 表示,并显示 Value 中的字节数。您的示例中的每个字节表示为 2(两个)十六进制字符。因此,十进制 11 的 0x0B 显示要使用的值中有 11*2 = 22 个字符。

这是由https://iso8583.info/lib/EMV/TLVs工具解析的 BER-TLV 缓冲区的解析示例:

---
# Cheef's parser.
# Copyright (C) 2008-2017 Alexander Shevelev. https://iso8583.info/
# lib   : "/lib/EMV/" - Integrated Circuit Card Specifications for Payment Systems
# tool  : "TLVs"
# stat  : 40 nodes, 4 lookup tables, 25.00% passed (1/4)

TLVs:#"61394F0BA00000030800001001234579074F05A000012345500E49442D4F..8000" # EMV, Tag + Length + Value (TLV) series
- x61:#"61394F0BA00000030800001001234579074F05A000012345500E49442D4F..6F6D" # ISO 7816, Template, Application
  - tag: "61"
  - len: "39" #  // 57
  - val:#"4F0BA00000030800001001234579074F05A000012345500E49442D4F6E65..6F6D" # Template, Application.
    - x4F:#"4F0BA000000308000010012345" # ISO 7816, Application Identifier (AID), Card
      - tag: "4F"
      - len: "0B" #  // 11
      - val:#"A000000308000010012345" # AID, Card.
        - RID: "A000000308" # Registered Application Provider Identifier (RID) // National Institute of Standards and Technology
        - PIX: "000010012345" # Proprietary Application Identifier Extension (PIX)
    - x79:#"79074F05A000012345" # ISO 7816, Coexistent Tag Allocation Authority
      - tag: "79"
      - len: "07" #  // 7
      - val:#"4F05A000012345"
        - x4F:#"4F05A000012345" # ISO 7816, Application Identifier (AID), Card
          - tag: "4F"
          - len: "05" #  // 5
          - val:#"A000012345" # AID, Card.
            - RID: "A000012345" # Registered Application Provider Identifier (RID)
    - x50:#"500E49442D4F6E65205049562042494F" # ISO 7816, Application Label
      - tag: "50"
      - len: "0E" #  // 14
      - val: "49442D4F6E65205049562042494F" # Application Label. // ID-One PIV BIO
    - x5F50:#"5F50107777772E6F626572746875722E636F6D" # ISO 7816, Uniform resource locator (URL)
      - tag: "5F50"
      - len: "10" #  // 16
      - val: "7777772E6F626572746875722E636F6D" # URL. // www.oberthur.com
- x7F66:#"7F66080202800002028000"
  - tag: "7F66"
  - len: "08" #  // 8
  - val:#"0202800002028000"
    - x02:#"02028000"
      - tag: "02"
      - len: "02" #  // 2
      - val: "8000"
    - x02:#"02028000"
      - tag: "02"
      - len: "02" #  // 2
      - val: "8000"
于 2017-01-26T07:31:36.407 回答