第一范文网 - 专业文章范例文档资料分享平台

ASN.1编码规则详解(最全最经典)(1) (10)

来源:用户分享 时间:2020-06-28 本文由凌霜傲雪 分享 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

2.9 字符串类型

Known-multiple Character String Type指字符串中每个字符编码所占字节数都一样。

Table 2-5 字符串类型一览表 类型名字 NumericString PrintableString Tag 字符表 18 19 字符“0”到“9”,空格 字符“A” 到 “Z”,“a”到“z”,“0”到“9”,空格,单引号(’),圆括号(( ,)),加号(+),逗号(,),减号(-),点(.),斜杠(/),冒号(:),等号(=),问号(?) VisibleString ISO646String IA5String 22 26 [ISOReg] entry no. 6; space [ISOReg] entry no. 1 & 6; space, delete TeletexString T61String 20 [ISOReg] entry no. 6, 87, 102, 103, 106, 107, 126, 144, 150, 153, 156, 164, 165, 168; space, delete VideotexString 21 [ISOReg] entry no. 1, 13, 72, 73, 87, 89, 102, 108, 126, 128, 129, 144, 150, 153, 164, 165, 168; space, delete GraphicString 25 all the graphical sets (called `G') of [ISOReg]; space GeneralString 27 all the graphical sets (called 是 是 是 是 是 是 ESC Multi 是 是 类型名字 Tag 字符表 `G') and all the control characters (called `C') of [ISOReg]; space, delete ESC Multi UniversalString BMPString 28 30 [ISO10646-1] the basic multilingual plane [ISO10646-1] (65,536 cells) 是 是 UTF8String

12 [ISO10646-1] 2.10 组合类型与扩展原则

2.10.1 Tag

传输数据时,一定要避免接收方收到数据解码时出现不清楚的地方。具体说,接收方要明确知道每个收到数据的类型,我们就要对各类型进行系统性的编号。在ASN.1的第一种编解码规则BER(Basic Encode Rule)中,对数据编码使用的是三元组规则:或者称为TLV,这里type或者称为tag,它是类型的标识符,在ASN.1中每种类型的tag是唯一的。length是编码数据value的字节数。value是实际数据的编码。 I. Tags与Tagging Classes

分配给每个类型的tag实际上是一个值对:。有四种tagging class:UNIVERSAL,context-specific,APPLICATION和PRIVATE。这种方式实际提供了不同的Tag空间。在一个上下文中,如果Tagging Class不同,则相同number的两个Tag也是不同的。

UNIVERSAL的Tag是ASN.1标准定义的,在描述中不能修改。

Table 2-6 ASN.1中定义的UNIVERSAL类Tag Tag 0 1 类型 BER保留 BOOLEAN Tag 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 类型 INTEGER BIT STRING OCTET STRING NULL OBJECT IDENTIFIER ObjectDescripion EXTERNAL, INSTANCE OF REAL ENUMERATED EMBEDDED PDV UFT8String RELATIVE-OID 保留 保留 SEQUENCE, SEQUENCE OF SET, SET OF NumericString PrintableString TeletexString, T61String VideotexString IA5String UTCTime GeneralizedTime GraphicString VisibleString, ISO646String GeneralString UniversalString Tag 29 30 31 类型 CHARACTER STRING BMPString 保留

context-specific Tag是对SEQUENCE、SET和CHOICE及其成员使用的,可以在描述中自己定义,只要不产生歧义,相同数值可以在不同结构中反复使用。如:

A-possible-type ::= SET {

integer [0] CHOICE {

a [0] INTEGER, b [1] INTEGER },

boolean [1] CHOICE {

a [0] BOOLEAN, b [1] BOOLEAN } }

APPLICATION的Tag是为了“to define a data type that finds wide, scattered use within a particular application and that must be distinguishable (by means of its [ abstract syntax]) from all other data types used in the application”。在APPLICATION作用域内,其Tag也是唯一的。如:

Order-number ::= [APPLICATION 0] NumericString (SIZE (12))

但是因为使用IMPORTS等方式下,很难保证唯一性,所以这种Tag类(APPLICATION的Tag)已经不推荐使用了。

PRIVATE的Tag是为了“use a private-use Tagged [ type] to define a data type that finds use within a particular organization or country and that must be distinguishable (by means of its [ abstract syntax]) from all other data types used by that organization or country”。如一个公司可

能这样扩展传输层PDU:

RejectTPDU ::= SET { destRef yr-tu-nr credit extended }

PRIVATE类的Tag现在也不推荐使用了。 II. Tagging Mode

使用context-specific类Tag,如下: Afters ::= CHOICE {

cheese [0]IA5String, dessert [1]IA5String }

当没有其它更多描述信息,并且使用BER编码时,会将UNIVERSAL类和context-specific类的Tag同时编码出来。这种方式称为EXPLICIT模式。

在下面这种情况: T1 ::= [0] INTEGER 变更为:

T2 ::= [0] CHOICE {

integer INTEGER, real REAL }

当CHOICE取值为integer时不需要变更。

与之相对应的是IMPLICIT模式,它将只编码context-specific类的Tag,直到另一个UNIVERSAL类Tag出现。如:

[0] Reference, [1] TPDUnumber,

[2] Credit,

[PRIVATE 0] BOOLEAN DEFAULT FALSE

搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新初中教育ASN.1编码规则详解(最全最经典)(1) (10)全文阅读和word下载服务。

ASN.1编码规则详解(最全最经典)(1) (10).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/wenku/1106286.html(转载请注明文章来源)
热门推荐
Copyright © 2018-2022 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top