Information technology — ASN.1 encoding rules — Part 1: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER)

This document specifies a set of basic encoding rules that may be used to derive the specification of a transfer syntax for values of types defined using the notation specified in Rec. ITU-T X.680 | ISO/IEC 8824‑1, Rec. ITU-T X.681 | ISO/IEC 8824-2, Rec. ITU-T X.682 | ISO/IEC 8824-3, and Rec. ITU-T X.683 | ISO/IEC 8824-4, collectively referred to as Abstract Syntax Notation One or ASN.1. These basic encoding rules are also to be applied for decoding such a transfer syntax in order to identify the data values being transferred. It also specifies a set of canonical and distinguished encoding rules that restrict the encoding of values to just one of the alternatives provided by the basic encoding rules.

Technologies de l'information — Règles de codage ASN.1 — Partie 1: Spécification des règles de codage de base (BER), des règles de codage canoniques (CER) et des règles de codage distinctives (DER)

General Information

Status
Published
Publication Date
29-Jun-2021
Current Stage
6060 - International Standard published
Start Date
30-Jun-2021
Completion Date
30-Jun-2021
Ref Project

RELATIONS

Buy Standard

Standard
ISO/IEC 8825-1:2021 - Information technology -- ASN.1 encoding rules
English language
28 pages
sale 15% off
Preview
sale 15% off
Preview

Standards Content (sample)

INTERNATIONAL ISO/IEC
STANDARD 8825-1
Sixth edition
2021-06
Information technology — ASN.1
encoding rules —
Part 1:
Specification of Basic Encoding Rules
(BER), Canonical Encoding Rules
(CER) and Distinguished Encoding
Rules (DER)
Technologies de l'information — Règles de codage ASN.1 —
Partie 1: Spécification des règles de codage de base (BER), des règles
de codage canoniques (CER) et des règles de codage distinctives
(DER)
Reference number
ISO/IEC 8825-1:2021(E)
ISO/IEC 2021
---------------------- Page: 1 ----------------------
ISO/IEC 8825-1:2021(E)
COPYRIGHT PROTECTED DOCUMENT
© ISO/IEC 2021

All rights reserved. Unless otherwise specified, or required in the context of its implementation, no part of this publication may

be reproduced or utilized otherwise in any form or by any means, electronic or mechanical, including photocopying, or posting

on the internet or an intranet, without prior written permission. Permission can be requested from either ISO at the address

below or ISO’s member body in the country of the requester.
ISO copyright office
CP 401 • Ch. de Blandonnet 8
CH-1214 Vernier, Geneva
Phone: +41 22 749 01 11
Email: copyright@iso.org
Website: www.iso.org
Published in Switzerland
ii © ISO/IEC 2021 – All rights reserved
---------------------- Page: 2 ----------------------
ISO/IEC 8825-1:2021(E)
Foreword

ISO (the International Organization for Standardization) and IEC (the International Electrotechnical

Commission) form the specialized system for worldwide standardization. National bodies that are

members of ISO or IEC participate in the development of International Standards through technical

committees established by the respective organization to deal with particular fields of technical activity.

ISO and IEC technical committees collaborate in fields of mutual interest. Other international

organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the

work.

The procedures used to develop this document and those intended for its further maintenance are

described in the ISO/IEC Directives, Part 1. In particular, the different approval criteria needed for

the different types of document should be noted. This document was drafted in accordance with

the editorial rules of the ISO/IEC Directives, Part 2 (see www.iso.org/directives or

www.iec.ch/members_experts/refdocs)

Attention is drawn to the possibility that some of the elements of this document may be the subject of

patent rights. ISO and IEC shall not be held responsible for identifying any or all such patent rights. Details

of any patent rights identified during the development of the document will be in the Introduction and/or

on the ISO list of patent declarations received (see www.iso.org/patents) or the IEC list of patent

declarations received (see patents.iec.ch).

Any trade name used in this document is information given for the convenience of users and does not

constitute an endorsement.

For an explanation of the voluntary nature of standards, the meaning of ISO specific terms and

expressions related to conformity assessment, as well as information about ISO's adherence to the

World Trade Organization (WTO) principles in the Technical Barriers to Trade (TBT)

see www.iso.org/iso/foreword.html. In the IEC, see www.iec.ch/understanding-standards.

This document was prepared by Joint Technical Committee ISO/IEC JTC 1, Information technology,

Subcommittee SC 6, Telecommunications and information exchange between systems, in collaboration

with ITU-T. The identical text is published as ITU-T X.690 (02/2021).

This sixth edition cancels and replaces the fifth edition (ISO/IEC 8825-1:2015), which has been

technically revised.

A list of all parts in the ISO/IEC 8825 series can be found on the ISO and IEC websites.

Any feedback or questions on this document should be directed to the user’s national standards body. A

complete listing of these bodies can be found at www.iso.org/members.html and www.iec.ch/national-

committees.
© ISO/IEC 2021 – All rights reserved iii
---------------------- Page: 3 ----------------------
ISO/IEC 8825-1:2021(E)
CONTENTS
Page

Introduction ........................................................................................................................................ v

1 Scope ........................................................................................................................................ 1

2 Normative references .................................................................................................................................. 1

2.1 Identical Recommendations | International Standards....................................................................... 1

2.2 Additional references ....................................................................................................................... 1

3 Definitions ........................................................................................................................................ 2

4 Abbreviations ........................................................................................................................................ 2

5 Notation ........................................................................................................................................ 3

6 Convention ........................................................................................................................................ 3

7 Conformance ........................................................................................................................................ 3

8 Basic encoding rules ................................................................................................................................... 3

8.1 General rules for encoding ............................................................................................................... 3

8.1.1 Structure of an encoding .................................................................................................. 3

8.1.2 Identifier octets ............................................................................................................... 4

8.1.3 Length octets ................................................................................................................... 5

8.1.4 Contents octets ................................................................................................................ 6

8.1.5 End-of-contents octets ..................................................................................................... 6

8.2 Encoding of a boolean value ............................................................................................................ 7

8.3 Encoding of an integer value............................................................................................................ 7

8.4 Encoding of an enumerated value .................................................................................................... 7

8.5 Encoding of a real value .................................................................................................................. 7

8.6 Encoding of a bitstring value ........................................................................................................... 9

8.7 Encoding of an octetstring value ...................................................................................................... 10

8.8 Encoding of a null value .................................................................................................................. 10

8.9 Encoding of a sequence value .......................................................................................................... 10

8.10 Encoding of a sequence-of value ...................................................................................................... 11

8.11 Encoding of a set value .................................................................................................................... 11

8.12 Encoding of a set-of value ............................................................................................................... 11

8.13 Encoding of a choice value .............................................................................................................. 11

8.14 Encoding of a value of a prefixed type ............................................................................................. 11

8.15 Encoding of an open type ................................................................................................................ 12

8.16 Encoding of an instance-of value ..................................................................................................... 12

8.17 Encoding of a value of the embedded-pdv type ................................................................................ 13

8.18 Encoding of a value of the external type .......................................................................................... 13

8.19 Encoding of an object identifier value .............................................................................................. 14

8.20 Encoding of a relative object identifier value ................................................................................... 15

8.21 Encoding of an OID internationalized resource identifier value........................................................ 15

8.22 Encoding of a relative OID internationalized resource identifier value ............................................. 15

8.23 Encoding for values of the restricted character string types .............................................................. 15

8.24 Encoding for values of the unrestricted character string type ............................................................ 18

8.25 Encoding for values of the Useful Types .......................................................................................... 18

8.26 Encoding for values of the TIME type and the useful time types ...................................................... 18

8.26.1 Encoding for values of the TIME type ............................................................................. 18

8.26.2 Encoding for values of the DATE type ............................................................................. 18

8.26.3 Encoding for values of the TIME-OF-DAY type ............................................................... 18

8.26.4 Encoding for values of the DATE-TIME type ................................................................... 18

8.26.5 Encoding for values of the DURATION type .................................................................... 18

Rec. ITU-T X.690 (02/2021) iii
© ISO/IEC 2021 – All rights reserved
---------------------- Page: 4 ----------------------
ISO/IEC 8825-1:2021(E)

9 Canonical encoding rules ............................................................................................................................ 19

9.1 Length forms ................................................................................................................................... 19

9.2 String encoding forms ...................................................................................................................... 19

9.3 Set components................................................................................................................................ 19

10 Distinguished encoding rules ...................................................................................................................... 19

10.1 Length forms ................................................................................................................................... 19

10.2 String encoding forms ...................................................................................................................... 20

10.3 Set components................................................................................................................................ 20

11 Restrictions on BER employed by both CER and DER ............................................................................... 20

11.1 Boolean values ................................................................................................................................ 20

11.2 Unused bits ...................................................................................................................................... 20

11.3 Real values ...................................................................................................................................... 20

11.4 GeneralString values ........................................................................................................................ 21

11.5 Set and sequence components with default value ............................................................................. 21

11.6 Set-of components ........................................................................................................................... 21

11.7 GeneralizedTime ............................................................................................................................. 21

11.8 UTCTime ........................................................................................................................................ 21

11.8.4 Examples of valid representations ................................................................................... 22

11.8.5 Examples of invalid representations ................................................................................ 22

11.9 The TIME type and the useful time types ......................................................................................... 22

12 Use of BER, CER and DER in transfer syntax definition ............................................................................ 22

Annex A – Example of encodings.......................................................................................................................... 24

A.1 ASN.1 description of the record structure ........................................................................................ 24

A.2 ASN.1 description of a record value ................................................................................................ 24

A.3 Representation of this record value .................................................................................................. 24

Annex B – Identification of Encoding Rules .......................................................................................................... 26

Annex C – Illustration of real value encoding ........................................................................................................ 27

iv Rec. ITU-T X.690 (02/2021)
© ISO/IEC 2021 – All rights reserved
---------------------- Page: 5 ----------------------
ISO/IEC 8825-1:2021(E)
Introduction

Rec. ITU-T X.680 | ISO/IEC 8824-1, Rec. ITU-T X.681 | ISO/IEC 8824-2, Rec. ITU-T X.682 | ISO/IEC 8824-3, Rec.

ITU-T X.683 | ISO/IEC 8824-4 (Abstract Syntax Notation One or ASN.1) together specify a notation for the definition

of abstract syntaxes, enabling application standards to define the types of information they need to transfer. It also

specifies a notation for the specification of values of a defined type.

This Recommendation | International Standard defines encoding rules that may be applied to values of types defined using

the ASN.1 notation. Application of these encoding rules produces a transfer syntax for such values. It is implicit in the

specification of these encoding rules that they are also to be used for decoding.

There may be more than one set of encoding rules that can be applied to values of types that are defined using the ASN.1

notation. This Recommendation | International Standard defines three sets of encoding rules, called basic encoding rules,

canonical encoding rules and distinguished encoding rules. Whereas the basic encoding rules give the sender of an

encoding various choices as to how data values may be encoded, the canonical and distinguished encoding rules select

just one encoding from those allowed by the basic encoding rules, eliminating all of the sender's options. The canonical

and distinguished encoding rules differ from each other in the set of restrictions that they place on the basic encoding

rules.

The distinguished encoding rules is more suitable than the canonical encoding rules if the encoded value is small enough

to fit into the available memory and there is a need to rapidly skip over some nested values. The canonical encoding rules

is more suitable than the distinguished encoding rules if there is a need to encode values that are so large that they cannot

readily fit into the available memory or it is necessary to encode and transmit a part of a value before the entire value is

available. The basic encoding rules is more suitable than the canonical or distinguished encoding rules if the encoding

contains a set value or set-of value and there is no need for the restrictions that the canonical and distinguished encoding

rules impose. This is due to the memory and CPU overhead that the latter encoding rules exact in order to guarantee that

set values and set-of values have just one possible encoding.

Annex A gives an example of the application of the basic encoding rules. It does not form an integral part of this

Recommendation | International Standard.

Annex B summarizes the assignment of object identifier and OID internationalized resource identifier values made in this

Recommendation | International Standard. It does not form an integral part of this Recommendation | International

Standard.

Annex C gives examples of applying the basic encoding rules for encoding reals. It does not form an integral part of this

Recommendation | International Standard.
Rec. ITU-T X.690 (02/2021) v
© ISO/IEC 2021 – All rights reserved
---------------------- Page: 6 ----------------------
ISO/IEC 8825-1:2021 (E)
INTERNATIONAL STANDARD
ITU-T RECOMMENDATION
Information technology – ASN.1 encoding rules:
Specification of Basic Encoding Rules (BER),
Canonical Encoding Rules (CER)
and Distinguished Encoding Rules (DER)
1 Scope

This Recommendation | International Standard specifies a set of basic encoding rules that may be used to derive the

specification of a transfer syntax for values of types defined using the notation specified in Rec. ITU-T X.680 |

ISO/IEC 8824-1, Rec. ITU-T X.681 | ISO/IEC 8824-2, Rec. ITU-T X.682 | ISO/IEC 8824-3, and Rec. ITU-T X.683 |

ISO/IEC 8824-4, collectively referred to as Abstract Syntax Notation One or ASN.1. These basic encoding rules are also to

be applied for decoding such a transfer syntax in order to identify the data values being transferred. It also specifies a set of

canonical and distinguished encoding rules that restrict the encoding of values to just one of the alternatives provided by the

basic encoding rules.
2 Normative references

The following Recommendations and International Standards contain provisions which, through reference in this text,

constitute provisions of this Recommendation | International Standard. At the time of publication, the editions indicated were

valid. All Recommendations and Standards are subject to revision, and parties to agreements based on this Recommendation

| International Standard are encouraged to investigate the possibility of applying the most recent edition of the

Recommendations and Standards listed below. Members of IEC and ISO maintain registers of currently valid International

Standards. The Telecommunication Standardization Bureau of the ITU maintains a list of currently valid ITU-T

Recommendations.

NOTE – This Recommendation | International Standard is based on ISO/IEC 10646:2003. It cannot be applied using later versions of

this standard.
2.1 Identical Recommendations | International Standards

– Recommendation ITU-T X.200 (1994) | ISO/IEC 7498-1: 1994, Information technology – Open Systems

Interconnection – Basic Reference Model: The basic model.

– Recommendation ITU-T X.680 (2021) | ISO/IEC 8824-1:2021, Information technology – Abstract Syntax

Notation One (ASN.1): Specification of basic notation.

– Recommendation ITU-T X.681 (2021) | ISO/IEC 8824-2:2021, Information technology – Abstract Syntax

Notation One (ASN.1): Information object specification.

– Recommendation ITU-T X.682 (2021) | ISO/IEC 8824-3:2021, Information technology – Abstract Syntax

Notation One (ASN.1): Constraint specification.

– Recommendation ITU-T X.683 (2021) | ISO/IEC 8824-4:2021, Information technology – Abstract Syntax

Notation One (ASN.1): Parameterization of ASN.1 specifications.

NOTE – The references above shall be interpreted as references to the identified Recommendations | International Standards together

with all their published amendments and technical corrigenda.
2.2 Additional references

– ISO International Register of Coded Character Sets to be used with Escape Sequences.

– ISO/IEC 2022:1994, Information technology – Character code structure and extension techniques.

– ISO/IEC 2375:2003, Information technology – Procedure for registration of escape sequences and coded

character sets.
Rec. ITU-T X.690 (02/2021) 1
© ISO/IEC 2021 – All rights reserved
---------------------- Page: 7 ----------------------
ISO/IEC 8825-1:2021 (E)

– ISO 6093:1985, Information processing – Representation of numerical values in character strings for

information interchange.

– ISO/IEC 6429:1992, Information technology – Control functions for coded character sets.

– ISO/IEC 10646:2003, Information technology – Universal Multiple-Octet Coded Character Set (UCS).

3 Definitions

For the purposes of this Recommendation | International Standard, the definitions of Rec. ITU-T X.200 | ISO/IEC 7498-1 and

Rec. ITU-T X.680 | ISO/IEC 8824-1 and the following definitions apply.

3.1 canonical encoding: A complete encoding of an abstract value obtained by the application of encoding rules that

have no implementation-dependent options. Such rules result in the definition of a 1-1 mapping between unambiguous and

unique encodings and values in the abstract syntax.

3.2 constructed encoding: A data value encoding in which the contents octets are the complete encoding of one or

more data values.

3.3 contents octets: That part of a data value encoding which represents a particular value, to distinguish it from other

values of the same type.

3.4 data value: Information specified as the value of a type; the type and the value are defined using ASN.1.

3.5 dynamic conformance: A statement of the requirement for an implementation to adhere to the prescribed behaviour

in an instance of communication.

3.6 encoding (of a data value): The complete sequence of octets used to represent the data value.

3.7 end-of-contents octets: Part of a data value encoding, occurring at its end, which is used to determine the end of

the encoding.
NOTE – Not all encodings require end-of-contents octets.

3.8 identifier octets: Part of a data value encoding which is used to identify the type of the value.

NOTE – Some ITU-T Recommendations use the term "data element" for this sequence of octets, but the term is not used in this

Recommendation | International Standard, as other Recommendations | International Standards use it to mean "data value".

3.9 length octets: Part of a data value encoding following the identifier octets which is used to determine the end of the

encoding.

3.10 primitive encoding: A data value encoding in which the contents octets directly represent the value.

3.11 receiver: An implementation decoding the octets produced by a sender, in order to identify the data value which

was encoded.
3.12 sender: An implementation encoding a data value for transfer.

3.13 static conformance: A statement of the requirement for support by an implementation of a valid set of features

from among the defined features.
3.14 trailing 0 bit: A 0 in the last position of a bitstring value.

NOTE – The 0 in a bitstring value consisting of a single 0 bit is a trailing 0 bit. Its removal produces an empty bitstring.

4 Abbreviations

For the purposes of this Recommendation | International Standard, the following abbreviations apply:

ASN.1 Abstract Syntax Notation One
BER Basic Encoding Rules of ASN.1
CER Canonical Encoding Rules of ASN.1
DER Distinguished Encoding Rules of ASN.1
ULA Upper Layer Architecture
2 Rec. ITU-T X.690 (02/2021)
© ISO/IEC 2021 – All rights reserved
---------------------- Page: 8 ----------------------
ISO/IEC 8825-1:2021 (E)
UTF8 Universal Transformation Function 8-bit (see ISO/IEC 10646, Annex D)
5 Notation

This Recommendation | International Standard references the notation defined by Rec. ITU-T X.680 | ISO/IEC 8824-1.

6 Convention

6.1 This Recommendation | International Standard specifies the value of each octet in an encoding by use of the terms

"most significant bit" and "least significant bit".

NOTE – Lower layer specifications use the same notation to define the order of bit transmission on a serial line, or the assignment of

bits to parallel channels.

6.2 For the purposes of this Recommendation | International Standard only, the bits of an octet are numbered from 8 to

1, where bit 8 is the "most significant bit", and bit 1 is the "least significant bit".

6.3 For the purpose of this Recommendation | International Standard, two octet strings can be compared. One octet

string is equal to another if they are of the same length and are the same at each octet position. An octet string, S , is greater

than another, S , if and only if either:

a) S and S have identical octets in every position up to and including the final octet in S , but S is longer; or

1 2 2 1

b) S and S have different octets in one or more positions, and in the first such position, the octet in S is greater

1 2 1
n–1

than that in S , considering the octets as unsigned binary numbers whose bit n has weight 2 .

7 Conformance
7.1 Dynamic conformance is specified by clauses 8 to 12 inclusive.

7.2 Static conformance is specified by those standards which specify the application of one or more of these encoding

rules.

7.3 Alternative encodings are permitted by the basic encoding rules as a sender's option. Receivers who claim

conformance to the basic encoding rules shall support all alternatives.
NOTE – Examples of such alternative encodings appear in 8.1.3.2 b) and Table 3.

7.4 No alternative encodings are permitted by the Canonical Encoding Rules or Distinguished Encoding Rules.

8 Basic encoding rules
8.1 General rules for encoding
8.1.1 Structure of an encoding

8.1.1.1 The encoding of a data value shall consist of four components which shall appear in the following order:

a) identifier octets (see 8.1.2);
b) length octets (see 8.1.3);
c) contents octets (see 8.1.4);
d) end-of-contents octets (see 8.1.5).

8.1.1.2 The end-of-contents octets shall not be present unless the value of the length octets requires them to be present (see

8.1.3).
Rec. ITU-T X.690 (02/2021) 3
© ISO/IEC 2021 – All rights reserved
---------------------- Page: 9 ----------------------
ISO/IEC 8825-1:2021 (E)

8.1.1.3 Figure 1 illustrates the structure of an encoding (primitive or constructed). Figure 2 illustrates an alternative

constructed encoding.
Figure 1 – Structure of an encoding
Figure 2 – An alternative constructed encoding

8.1.1.4 Encodings specified in this Recommendation | International Standard are not affected by either the ASN.1 subtype

notation or the ASN.1 type extensibility notation.

NOTE – This means that all constraint notation is ignored when determining encodings, and all extensibility markers in CHOICE,

SEQUENCE and SET are ignored, with the extensions treated as if they were in the extension root of the type.

8.1.1.5 There are no encoding instructions (see Rec. ITU-T X.680 | ISO/IEC 8824-1, 3.8.27) defined for the encoding rules

specified in this Recommendation | International Standard.
8.1.2 Identifier octets

8.1.2.1 The identifier octets shall encode the ASN.1 tag (class and number) of the type of the data value.

8.1.2.2 For tags with a number ranging from zero to 30 (inclusive), the identifier octets shall comprise a single octet encoded

as follows:

a) bits 8 and 7 shall be encoded to represent the class of the tag as specified in Table 1;

b) bit 6 shall be a zero or a one according to the rules of 8.1.2.5;

c) bits 5 to 1 shall encode the number of the tag as a binary integer with bit 5 as the most significant bit.

Table 1 – Encoding of class of tag
Class Bit 8 Bit 7
Universal 0 0
Application 0 1
Context-specific 1 0
Private 1 1
4 Rec. ITU-T X.690 (02/2021)
© ISO/IEC 2021 – All rights reserved
---------------------- Page: 10 ----------------------
ISO/IEC 8825-1:2021 (E)

8.1.2.3 Figure 3 illustrates the form of an identifier octet for a type with a tag whose number is in the range zero

to 30 (inclusive).
Figure 3 – Identifier octet (low tag number)

8.1.2.4 For tags with a number greater than or equal to 31, the identifier shall comprise a leading octet followed by one or

more subsequent octets.
8.1.2.4.1 The leading octet shall be encoded as follows:

a) bits 8 and 7 shall be encoded to represent the class of the tag as listed in Table 1;

b) bit 6 shall be a zero or a one according to the rules of 8.1.2.5;
c) bits 5 to 1 shall be encoded as 11111 .
8.1.2.4.2 The subsequent octets shall encode the number of the tag as follows:
a) bit 8 of each octet shall be set to one unless it is the la
...

Questions, Comments and Discussion

Ask us and Technical Secretary will try to provide an answer. You can facilitate discussion about the standard in here.