当CHOICE本身与隐式标签一起使用时,CHOICE类型的编码(使用具体的例子:CRLDistPoints)。

问题描述 投票:0回答:1

ISO CRLDistributionPoint 并实际上抛出一个异常,如果扩展的任何 "高级 "属性被设置为Botan所不期望的。

因此,我试着给这个扩展的解码打补丁,但我遇到了一个问题,就是如何根据标签来正确判断编码对象的类型。要么是这个扩展的规范中的疏忽(我对此表示怀疑),要么是我对编码解码规则有根本性的误解。

以下是规范的相关部分

CertificateExtensions {joint-iso-itu-t ds(5) module(1)
  certificateExtensions(26) 5} DEFINITIONS IMPLICIT TAGS

CRLDistPointsSyntax ::= SEQUENCE SIZE (1..MAX) OF DistributionPoint

DistributionPoint ::= SEQUENCE {
  distributionPoint  [0]  DistributionPointName OPTIONAL,
  reasons            [1]  ReasonFlags OPTIONAL,
  cRLIssuer          [2]  GeneralNames OPTIONAL
}

DistributionPointName ::= CHOICE {
  fullName                 [0]  GeneralNames,
  nameRelativeToCRLIssuer  [1]  RelativeDistinguishedName
}

该模块采用 隐性 默认为标签。在下面的内容中,这一点很重要。A DistributionPoint 是一个SEQUENCE,其中所有属性都是可选的。第一个可选属性 distributionPoint 具有类型标签0,且类型为 DistributionPointName. 反过来说: DistributionPointName 是一个CHOICE,其可能的选择是标签0(如果 GeneralNames 选择了)或标签1(如果 RelativeDistinguishedName 被选中)。)

根据我的理解,如果是 隐性 标记一个 CHOICE 类型是使用所选类型的标记进行编码的。换句话说,CHOICE 类型不是以某种方式 "嵌套 "的,而是在使用 CHOICE 类型的同一层次上进行编码。但是 DistributionPointName 已经被赋予了0的标签。

具体的问题是:如何将 DistributionPoint 编码,如果 nameRelativeToCRLIssuer (标签1)被选为选择。DistributionPointName 的标签1不发生冲突。reasons 属性?

下面是我的问题说明。

     30        // Type tag for outer SEQUENCE, DistributionPoint starts here
     ll        // Length of SEQUENCE, omitted here for editorial purposes
+--> 00 vs 01  // Type tag for distributionPoint
|              // At first glance, 00 according to SEQUENCE definition for OPTIONAL DistributionPointName,
|              // but maybe 01 if RelativeDistinguishedName is the selected CHOICE
|    kk        // Length of RelativeDistinguishedName, omitted here for editorial purposes
|    vv        // Encoding of RelativeDistinguishedName begins
|    vv
|    vv        // Encoding of RelativeDistinguishedName ends, accordingly to length kk
+--> 01        // Type tag for OPTIONAL ReasonsFlags
     jj        // Length of ReasonsFlags
     ww        // Encoding of ReasonsFlags begins
     ww
     ww        // Encoding of ReasonsFlags ends, accordingly to length jj
               // Encoding of DistributionPoint ends, too, accordingly to length ll

在第三行中,类型标签应该是00来表示OPTIONAL DistributionPointName的存在,这也避免了与第8行中OPTIONAL ReasonFlags的类型标签01发生冲突。这也避免了与第8行中OPTIONAL ReasonFlags的类型标签01的冲突。然而,在第三行中,类型标签也应该表明DistributionPointName选择了哪种类型。

x509 asn.1
1个回答
2
投票

根据我的理解,在隐式标记的情况下,CHOICE类型将使用所选类型的标记进行编码。换句话说,CHOICE类型不是以某种方式 "嵌套 "的,而是在使用CHOICE类型的同一层次上进行编码。但是DistributionPointName已经被赋予了0的标签。

这恐怕是相反的。CHOICE标签总是显式的,不管默认的标签是什么... ...

在X.680文档中,有以下说明

如果以下任何一种情况成立,标签结构就会指定显式标签。

c)使用 "标签类型 "备选方案,模块的 "TagDefault "的值是IMPLICIT TAGS或AUTOMATIC TAGS,但 "Type "定义的类型是未标记的选择类型、未标记的开放类型或未标记的 "DummyReference"(见Rec.ITU-T X.683 IEC 8824-4,8.3)。

所以,如果选择RelativeDistinguishedName,distributionPoint组件标记将为0(distributionPoint),然后为1(RelativeDistinguishedName)。

原因是CHOICE没有一个UNIVERSAL的标签

© www.soinside.com 2019 - 2024. All rights reserved.