1 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893
|
<pre>Network Working Group S. Legg
Request for Comments: 3641 Adacel Technologies
Category: Standards Track October 2003
<span class="h1">Generic String Encoding Rules (GSER) for ASN.1 Types</span>
Status of this Memo
This document specifies an Internet standards track protocol for the
Internet community, and requests discussion and suggestions for
improvements. Please refer to the current edition of the "Internet
Official Protocol Standards" (STD 1) for the standardization state
and status of this protocol. Distribution of this memo is unlimited.
Copyright Notice
Copyright (C) The Internet Society (2003). All Rights Reserved.
Abstract
This document defines a set of Abstract Syntax Notation One (ASN.1)
encoding rules, called the Generic String Encoding Rules (GSER), that
produce a human readable text encoding for values of any given ASN.1
data type.
Table of Contents
<a href="#section-1">1</a>. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-2">2</a>
<a href="#section-2">2</a>. Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-3">3</a>
<a href="#section-3">3</a>. Generic String Encoding Rules. . . . . . . . . . . . . . . . . <a href="#page-3">3</a>
<a href="#section-3.1">3.1</a>. Type Referencing Notations . . . . . . . . . . . . . . . <a href="#page-3">3</a>
<a href="#section-3.2">3.2</a>. Restricted Character String Types. . . . . . . . . . . . <a href="#page-4">4</a>
<a href="#section-3.3">3.3</a>. ChoiceOfStrings Types. . . . . . . . . . . . . . . . . . <a href="#page-5">5</a>
<a href="#section-3.4">3.4</a>. Identifiers. . . . . . . . . . . . . . . . . . . . . . . <a href="#page-6">6</a>
<a href="#section-3.5">3.5</a>. BIT STRING . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-7">7</a>
<a href="#section-3.6">3.6</a>. BOOLEAN. . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-7">7</a>
<a href="#section-3.7">3.7</a>. ENUMERATED . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-3.8">3.8</a>. INTEGER. . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-3.9">3.9</a>. NULL . . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-3.10">3.10</a>. OBJECT IDENTIFIER and RELATIVE-OID . . . . . . . . . . . <a href="#page-8">8</a>
<a href="#section-3.11">3.11</a>. OCTET STRING . . . . . . . . . . . . . . . . . . . . . . <a href="#page-9">9</a>
<a href="#section-3.12">3.12</a>. CHOICE . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-9">9</a>
<a href="#section-3.13">3.13</a>. SEQUENCE and SET . . . . . . . . . . . . . . . . . . . . <a href="#page-10">10</a>
<a href="#section-3.14">3.14</a>. SEQUENCE OF and SET OF . . . . . . . . . . . . . . . . . <a href="#page-10">10</a>
<a href="#section-3.15">3.15</a>. CHARACTER STRING . . . . . . . . . . . . . . . . . . . . <a href="#page-11">11</a>
<a href="#section-3.16">3.16</a>. EMBEDDED PDV . . . . . . . . . . . . . . . . . . . . . . <a href="#page-11">11</a>
<a href="#section-3.17">3.17</a>. EXTERNAL . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-11">11</a>
<span class="grey">Legg Standards Track [Page 1]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-2" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
<a href="#section-3.18">3.18</a>. INSTANCE OF. . . . . . . . . . . . . . . . . . . . . . . <a href="#page-11">11</a>
<a href="#section-3.19">3.19</a>. REAL . . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-11">11</a>
<a href="#section-3.20">3.20</a>. Variant Encodings. . . . . . . . . . . . . . . . . . . . <a href="#page-12">12</a>
<a href="#section-4">4</a>. GSER Transfer Syntax . . . . . . . . . . . . . . . . . . . . . <a href="#page-13">13</a>
<a href="#section-5">5</a>. Security Considerations. . . . . . . . . . . . . . . . . . . . <a href="#page-13">13</a>
<a href="#section-6">6</a>. References . . . . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-13">13</a>
<a href="#section-6.1">6.1</a>. Normative References . . . . . . . . . . . . . . . . . . <a href="#page-13">13</a>
<a href="#section-6.2">6.2</a>. Informative References . . . . . . . . . . . . . . . . . <a href="#page-14">14</a>
<a href="#section-7">7</a>. Intellectual Property Notice . . . . . . . . . . . . . . . . . <a href="#page-15">15</a>
<a href="#section-8">8</a>. Author's Address . . . . . . . . . . . . . . . . . . . . . . . <a href="#page-15">15</a>
<a href="#section-9">9</a>. Full Copyright Statement . . . . . . . . . . . . . . . . . . . <a href="#page-16">16</a>
<span class="h2"><a class="selflink" id="section-1" href="#section-1">1</a>. Introduction</span>
This document defines a set of ASN.1 [<a href="#ref-8">8</a>] encoding rules, called the
Generic String Encoding Rules or GSER, that produce a human readable
UTF-8 [<a href="#ref-6" title=""UTF-8, a transformation format of ISO 10646"">6</a>] character string encoding of ASN.1 values of any given
arbitrary ASN.1 type.
Note that "ASN.1 value" does not mean a Basic Encoding Rules (BER)
[<a href="#ref-12">12</a>] encoded value. The ASN.1 value is an abstract concept that is
independent of any particular encoding. BER is just one possible
encoding of an ASN.1 value.
GSER is based on ASN.1 value notation [<a href="#ref-8">8</a>], with changes to
accommodate the notation's use as a transfer syntax, and to support
well established ad-hoc string encodings for Lightweight Directory
Access Protocol (LDAP) [<a href="#ref-14" title=""Lightweight Directory Access Protocol (v3): Technical Specification"">14</a>] directory data types.
Though primarily intended for defining the LDAP-specific encoding of
new LDAP attribute syntaxes and assertion syntaxes, these encoding
rules could also be used in other domains where human readable
renderings of ASN.1 values would be useful.
Referencing GSER is sufficient to define a human readable text
encoding for values of a specific ASN.1 type, however other
specifications may wish to provide a customized Augmented Backus-Naur
Form (ABNF) [<a href="#ref-3" title=""Augmented BNF for Syntax Specifications: ABNF"">3</a>] description, independent of the ASN.1, as a
convenience for the implementor (equivalent ABNF for the GSER
encodings for ASN.1 types commonly occurring in LDAP syntaxes is
provided in a separate document [<a href="#ref-15" title=""Common Elements of Generic String Encoding Rules (GSER) Encodings"">15</a>]). Such a specification SHOULD
state that if there is a discrepancy between the customized ABNF and
the GSER encoding defined by this document, that the GSER encoding
takes precedence.
<span class="grey">Legg Standards Track [Page 2]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-3" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
<span class="h2"><a class="selflink" id="section-2" href="#section-2">2</a>. Conventions</span>
Throughout this document, "type" shall be taken to mean an ASN.1
type, and "value" shall be taken to mean an ASN.1 value.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in <a href="https://www.rfc-editor.org/bcp/bcp14">BCP 14</a>, <a href="./rfc2119">RFC 2119</a> [<a href="#ref-1" title=""Key words for use in RFCs to Indicate Requirement Levels"">1</a>].
<span class="h2"><a class="selflink" id="section-3" href="#section-3">3</a>. Generic String Encoding Rules</span>
The GSER encoding of a value of any ASN.1 type is described by the
following ABNF [<a href="#ref-3" title=""Augmented BNF for Syntax Specifications: ABNF"">3</a>]:
Value = BitStringValue /
BooleanValue /
CharacterStringValue /
ChoiceValue /
EmbeddedPDVValue /
EnumeratedValue /
ExternalValue /
GeneralizedTimeValue /
IntegerValue /
InstanceOfValue /
NullValue /
ObjectDescriptorValue /
ObjectIdentifierValue /
OctetStringValue /
RealValue /
RelativeOIDValue /
SequenceOfValue /
SequenceValue /
SetOfValue /
SetValue /
StringValue /
UTCTimeValue /
VariantEncoding
The ABNF for each of the above rules is given in the following
sections.
<span class="h3"><a class="selflink" id="section-3.1" href="#section-3.1">3.1</a> Type Referencing Notations</span>
A value of a type with a defined type name is encoded according to
the type definition on the right hand side of the type assignment for
the type name.
<span class="grey">Legg Standards Track [Page 3]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-4" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
A value of a type denoted by the use of a parameterized type with
actual parameters is encoded according to the parameterized type with
the DummyReferences [<a href="#ref-11">11</a>] substituted with the actual parameters.
A value of a tagged or constrained type is encoded as a value of the
type without the tag or constraint, respectively. Tags do not appear
in the string encodings defined by this document. See X.680 [<a href="#ref-8">8</a>] and
X.682 [<a href="#ref-10">10</a>] for the details of ASN.1 constraint notation.
A value of an open type denoted by an ObjectClassFieldType (Clause 14
of X.681 [<a href="#ref-9">9</a>]) is encoded according to the specific type of the value.
A value of a fixed type denoted by an ObjectClassFieldType is encoded
according to that fixed type.
A value of a selection type is encoded according to the type
referenced by the selection type.
A value of a type described by TypeFromObject notation (Clause 15 of
X.681 [<a href="#ref-9">9</a>]) is encoded according to the denoted type.
A value of a type described by ValueSetFromObjects notation (Clause
15 of X.681 [<a href="#ref-9">9</a>]) is encoded according to the governing type.
<span class="h3"><a class="selflink" id="section-3.2" href="#section-3.2">3.2</a>. Restricted Character String Types</span>
The contents of a string value are encoded as a UTF-8 character
string between double quotes, regardless of the ASN.1 string type.
Depending on the ASN.1 string type and an application's internal
representation of that string type, a translation to or from the
UTF-8 character encoding may be required. NumericString,
PrintableString, IA5String, and VisibleString (ISO646String) are
compatible with UTF-8 and do not require any translation. BMPString
(UCS-2) and UniversalString (UCS-4) have a direct mapping to and from
UTF-8 [<a href="#ref-6" title=""UTF-8, a transformation format of ISO 10646"">6</a>]. For the remaining string types see X.680 [<a href="#ref-8">8</a>]. Any
embedded double quotes in the resulting UTF-8 character string are
escaped by repeating the double quote characters.
A value of the NumericString, PrintableString, TeletexString
(T61String), VideotexString, IA5String, GraphicString, VisibleString
(ISO646String), GeneralString, BMPString, UniversalString or
UTF8String type is encoded according to the <StringValue> rule.
<span class="grey">Legg Standards Track [Page 4]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-5" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
StringValue = dquote *SafeUTF8Character dquote
dquote = %x22 ; " (double quote)
SafeUTF8Character = %x00-21 / %x23-7F / ; ASCII minus dquote
dquote dquote / ; escaped double quote
%xC0-DF %x80-BF / ; 2 byte UTF-8 character
%xE0-EF 2(%x80-BF) / ; 3 byte UTF-8 character
%xF0-F7 3(%x80-BF) ; 4 byte UTF-8 character
A value of the GeneralizedTime type, UTCTime type or ObjectDescriptor
type is encoded as a string value. GeneralizedTime and UTCTime use
the VisibleString character set so the conversion to UTF-8 is
trivial. ObjectDescriptor uses the GraphicString type.
GeneralizedTimeValue = StringValue
UTCTimeValue = StringValue
ObjectDescriptorValue = StringValue
<span class="h3"><a class="selflink" id="section-3.3" href="#section-3.3">3.3</a>. ChoiceOfStrings Types</span>
It is not uncommon for ASN.1 specifications to define types that
offer a CHOICE between two or more alternative ASN.1 string types,
where the particular alternative chosen carries no semantic
significance (DirectoryString [<a href="#ref-7">7</a>] being a prime example). Such types
are defined to avoid having to use a complicated character encoding
for all values when most values could use a simpler string type, or
to deal with evolving requirements that compel the use of a broader
character set while still maintaining backward compatibility.
GSER encodes values of all the ASN.1 string types as UTF-8 character
strings so the particular alternative that is chosen from a purely
syntactic CHOICE of string types makes no material difference to the
final encoding of the string value.
While there are certain ASN.1 constructs that betray the semantic
significance of the alternatives within a CHOICE type, the absence of
those constructs does not necessarily mean that a CHOICE type is
purely syntactic. Therefore, it is necessary for specifications to
declare the purely syntactic CHOICE types so that they may be more
compactly encoded (see <a href="#section-3.12">Section 3.12</a>). These declared CHOICE types
are referred to as ChoiceOfStrings types.
To be eligible to be declared a ChoiceOfStrings type, an ASN.1 type
MUST satisfy the following conditions.
a) The type is a CHOICE type.
<span class="grey">Legg Standards Track [Page 5]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-6" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
b) The component type of each alternative is one of the following
ASN.1 restricted string types: NumericString, PrintableString,
TeletexString (T61String), VideotexString, IA5String,
GraphicString, VisibleString (ISO646String), GeneralString,
BMPString, UniversalString or UTF8String.
c) All the alternatives are of different restricted string types,
i.e., no two alternatives have the same ASN.1 restricted string
type.
d) Either none of the alternatives has a constraint, or all of the
alternatives have exactly the same constraint.
Tagging on the alternative types is ignored.
Consider the ASN.1 parameterized type definition of DirectoryString.
DirectoryString { INTEGER : maxSize } ::= CHOICE {
teletexString TeletexString (SIZE (1..maxSize)),
printableString PrintableString (SIZE (1..maxSize)),
bmpString BMPString (SIZE (1..maxSize)),
universalString UniversalString (SIZE (1..maxSize)),
uTF8String UTF8String (SIZE (1..maxSize)) }
Any use of the DirectoryString parameterized type with an actual
parameter defines an ASN.1 type that satisfies the above conditions.
Recognising that the alternative within a DirectoryString carries no
semantic significance, this document declares (each and every use of)
DirectoryString{} to be a ChoiceOfStrings type.
Other specifications MAY declare other types satisfying the above
conditions to be ChoiceOfStrings types. The declaration SHOULD be
made at the point where the ASN.1 type is defined, otherwise it
SHOULD be made at the point where it is introduced as, or in, an LDAP
attribute or assertion syntax.
<span class="h3"><a class="selflink" id="section-3.4" href="#section-3.4">3.4</a>. Identifiers</span>
An <identifier> conforms to the definition of an identifier in ASN.1
notation (Clause 11.3 of X.680 [<a href="#ref-8">8</a>]). It begins with a lowercase
letter and is followed by zero or more letters, digits, and hyphens.
A hyphen is not permitted to be the last character, nor is it to be
followed by another hyphen. The case of letters in an identifier is
always significant.
<span class="grey">Legg Standards Track [Page 6]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-7" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
identifier = lowercase *alphanumeric *(hyphen 1*alphanumeric)
alphanumeric = uppercase / lowercase / decimal-digit
uppercase = %x41-5A ; "A" to "Z"
lowercase = %x61-7A ; "a" to "z"
decimal-digit = %x30-39 ; "0" to "9"
hyphen = "-"
<span class="h3"><a class="selflink" id="section-3.5" href="#section-3.5">3.5</a>. BIT STRING</span>
A value of the BIT STRING type is encoded according to the
<BitStringValue> rule. If the definition of the BIT STRING type
includes a named bit list, the <bit-list> form of <BitStringValue>
MAY be used. If the number of bits in a BIT STRING value is a
multiple of four, the <hstring> form of <BitStringValue> MAY be used.
Otherwise, the <bstring> form of <BitStringValue> is used.
BitStringValue = bstring / hstring / bit-list
The <bit-list> rule encodes the one bits in the bit string value as a
comma separated list of identifiers. Each <identifier> MUST be one
of the identifiers in the named bit list, and MUST NOT appear more
than once in the same <bit-list>. The <bstring> rule encodes each
bit as the character "0" or "1" in order from the first bit to the
last bit. The <hstring> rule encodes each group of four bits as a
hexadecimal number where the first bit is the most significant. An
odd number of hexadecimal digits is permitted.
bit-list = "{" [ sp identifier
*( "," sp identifier ) ] sp "}"
hstring = squote *hexadecimal-digit squote %x48 ; '...'H
hexadecimal-digit = %x30-39 / ; "0" to "9"
%x41-46 ; "A" to "F"
bstring = squote *binary-digit squote %x42 ; '...'B
binary-digit = "0" / "1"
sp = *%x20 ; zero, one or more space characters
squote = %x27 ; ' (single quote)
<span class="h3"><a class="selflink" id="section-3.6" href="#section-3.6">3.6</a>. BOOLEAN</span>
A value of the BOOLEAN type is encoded according to the
<BooleanValue> rule.
BooleanValue = %x54.52.55.45 / ; "TRUE"
%x46.41.4C.53.45 ; "FALSE"
<span class="grey">Legg Standards Track [Page 7]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-8" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
<span class="h3"><a class="selflink" id="section-3.7" href="#section-3.7">3.7</a>. ENUMERATED</span>
A value of the ENUMERATED type is encoded according to the
<EnumeratedValue> rule. The <identifier> MUST be one of those in the
list of enumerations in the definition of the ENUMERATED type.
EnumeratedValue = identifier
<span class="h3"><a class="selflink" id="section-3.8" href="#section-3.8">3.8</a>. INTEGER</span>
A value of the INTEGER type is encoded according to the
<IntegerValue> rule. If the definition of the INTEGER type includes
a named number list, the <identifier> form of <IntegerValue> MAY be
used, in which case the <identifier> MUST be one of the identifiers
in the named number list.
IntegerValue = "0" /
positive-number /
("-" positive-number) /
identifier
positive-number = non-zero-digit *decimal-digit
non-zero-digit = %x31-39 ; "1" to "9"
<span class="h3"><a class="selflink" id="section-3.9" href="#section-3.9">3.9</a>. NULL</span>
A value of the NULL type is encoded according to the <NullValue>
rule.
NullValue = %x4E.55.4C.4C ; "NULL"
<span class="h3"><a class="selflink" id="section-3.10" href="#section-3.10">3.10</a>. OBJECT IDENTIFIER and RELATIVE-OID</span>
A value of the OBJECT IDENTIFIER type is encoded according to the
<ObjectIdentifierValue> rule. The <ObjectIdentifierValue> rule
allows either a dotted decimal representation of the OBJECT
IDENTIFIER value or an object descriptor name, i.e., <descr>. The
<descr> rule is described in <a href="./rfc2252">RFC 2252</a> [<a href="#ref-4" title=""Lightweight Directory Access Protocol (v3): Attribute Syntax Definitions"">4</a>]. An object descriptor name
is potentially ambiguous and should be used with care.
ObjectIdentifierValue = numeric-oid / descr
numeric-oid = oid-component 1*( "." oid-component )
oid-component = "0" / positive-number
A value of the RELATIVE-OID type is encoded according to the
<RelativeOIDValue> rule.
RelativeOIDValue = oid-component *( "." oid-component )
<span class="grey">Legg Standards Track [Page 8]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-9" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
<span class="h3"><a class="selflink" id="section-3.11" href="#section-3.11">3.11</a>. OCTET STRING</span>
A value of the OCTET STRING type is encoded according to the
<OctetStringValue> rule. The octets are encoded in order from the
first octet to the last octet. Each octet is encoded as a pair of
hexadecimal digits where the first digit corresponds to the four most
significant bits of the octet. If the hexadecimal string does not
have an even number of digits, the four least significant bits in the
last octet are assumed to be zero.
OctetStringValue = hstring
<span class="h3"><a class="selflink" id="section-3.12" href="#section-3.12">3.12</a>. CHOICE</span>
A value of a CHOICE type is encoded according to the <ChoiceValue>
rule. The <ChoiceOfStringsValue> encoding MAY be used if the
corresponding CHOICE type has been declared a ChoiceOfStrings type.
This document declares DirectoryString to be a ChoiceOfStrings type
(see <a href="#section-3.3">Section 3.3</a>). Otherwise, the <IdentifiedChoiceValue> form of
<ChoiceValue> is used.
ChoiceValue = IdentifiedChoiceValue /
ChoiceOfStringsValue
IdentifiedChoiceValue = identifier ":" Value
ChoiceOfStringsValue = StringValue
For implementations that recognise the internal structure of the
DirectoryString CHOICE type (e.g., X.500 directories [<a href="#ref-16" title=" Information Technology - Open Systems Interconnection - The Directory: Overview of concepts">16</a>]), if the
character string between the quotes in a <StringValue> contains only
characters that are permitted in a PrintableString, the
DirectoryString is assumed to use the printableString alternative,
otherwise it is assumed to use the uTF8String alternative. The
<IdentifiedChoiceValue> rule MAY be used for a value of type
DirectoryString to indicate an alternative other than the one that
would be assumed from the string contents. No matter what
alternative is chosen, the <Value> will still be a UTF-8 encoded
character string. However, it is a syntax error if the characters in
the UTF-8 string cannot be represented in the string type of the
chosen alternative.
Implementations that do not care about the internal structure of a
DirectoryString value MUST be able to parse the
<IdentifiedChoiceValue> form for a DirectoryString value, though the
particular identifier found will be of no interest.
<span class="grey">Legg Standards Track [Page 9]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-10" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
<span class="h3"><a class="selflink" id="section-3.13" href="#section-3.13">3.13</a>. SEQUENCE and SET</span>
A value of a SEQUENCE type is encoded according to the
<SequenceValue> rule. The <ComponentList> rule encodes a comma
separated list of the particular component values present in the
SEQUENCE value, where each component value is preceded by the
corresponding identifier from the SEQUENCE type definition. The
components are encoded in the order of their definition in the
SEQUENCE type.
SequenceValue = ComponentList
ComponentList = "{" [ sp NamedValue *( "," sp NamedValue) ] sp "}"
NamedValue = identifier msp Value
msp = 1*%x20 ; one or more space characters
A value of a SET type is encoded according to the <SetValue> rule.
The components are encoded in the order of their definition in the
SET type (i.e., just like a SEQUENCE value). This is a deliberate
departure from ASN.1 value notation where the components of a SET can
be written in any order.
SetValue = ComponentList
SEQUENCE and SET type definitions are sometimes extended by the
inclusion of additional component types, so an implementation SHOULD
be capable of skipping over any <NamedValue> encoding with an
identifier that is not recognised, on the assumption that the sender
is using a more recent definition of the SEQUENCE or SET type.
<span class="h3"><a class="selflink" id="section-3.14" href="#section-3.14">3.14</a>. SEQUENCE OF and SET OF</span>
A value of a SEQUENCE OF type is encoded according to the
<SequenceOfValue> rule, as a comma separated list of the instances in
the value. Each instance is encoded according to the component type
of the SEQUENCE OF type.
SequenceOfValue = "{" [ sp Value *( "," sp Value) ] sp "}"
A value of a SET OF type is encoded according to the <SetOfValue>
rule, as a list of the instances in the value. Each instance is
encoded according to the component type of the SET OF type.
SetOfValue = "{" [ sp Value *( "," sp Value) ] sp "}"
<span class="grey">Legg Standards Track [Page 10]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-11" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
<span class="h3"><a class="selflink" id="section-3.15" href="#section-3.15">3.15</a>. CHARACTER STRING</span>
A value of the unrestricted CHARACTER STRING type is encoded
according to the corresponding SEQUENCE type defined in Clause 40.5
of X.680 [<a href="#ref-8">8</a>] (see [<a href="#ref-15" title=""Common Elements of Generic String Encoding Rules (GSER) Encodings"">15</a>] for equivalent ABNF).
CharacterStringValue = SequenceValue
<span class="h3"><a class="selflink" id="section-3.16" href="#section-3.16">3.16</a>. EMBEDDED PDV</span>
A value of the EMBEDDED PDV type is encoded according to the
corresponding SEQUENCE type defined in Clause 33.5 of X.680 [<a href="#ref-8">8</a>] (see
[<a href="#ref-15" title=""Common Elements of Generic String Encoding Rules (GSER) Encodings"">15</a>] for equivalent ABNF).
EmbeddedPDVValue = SequenceValue
<span class="h3"><a class="selflink" id="section-3.17" href="#section-3.17">3.17</a>. EXTERNAL</span>
A value of the EXTERNAL type is encoded according to the
corresponding SEQUENCE type defined in Clause 8.18.1 of X.690 [<a href="#ref-12">12</a>]
(see [<a href="#ref-15" title=""Common Elements of Generic String Encoding Rules (GSER) Encodings"">15</a>] for equivalent ABNF).
ExternalValue = SequenceValue
<span class="h3"><a class="selflink" id="section-3.18" href="#section-3.18">3.18</a>. INSTANCE OF</span>
A value of the INSTANCE OF type is encoded according to the
corresponding SEQUENCE type defined in Annex C of X.681 [<a href="#ref-9">9</a>].
InstanceOfValue = SequenceValue
<span class="h3"><a class="selflink" id="section-3.19" href="#section-3.19">3.19</a>. REAL</span>
A value of the REAL type MUST be encoded as "0" if it is zero,
otherwise it is encoded as the special value <PLUS-INFINITY>, the
special value <MINUS-INFINITY>, an optionally signed <realnumber>, or
as a value of the corresponding SEQUENCE type for REAL defined in
Clause 20.5 of X.680 [<a href="#ref-8">8</a>] (see [<a href="#ref-15" title=""Common Elements of Generic String Encoding Rules (GSER) Encodings"">15</a>] for equivalent ABNF).
RealValue = "0" ; zero REAL value
/ PLUS-INFINITY ; positive infinity
/ MINUS-INFINITY ; negative infinity
/ realnumber ; positive base 10 REAL value
/ "-" realnumber ; negative base 10 REAL value
/ SequenceValue ; non-zero REAL value, base 2 or 10
<span class="grey">Legg Standards Track [Page 11]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-12" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
realnumber = mantissa exponent
mantissa = (positive-number [ "." *decimal-digit ])
/ ( "0." *("0") positive-number )
exponent = "E" ( "0" / ([ "-" ] positive-number))
PLUS-INFINITY = %x50.4C.55.53.2D.49.4E.46.49.4E.49.54.59
; "PLUS-INFINITY"
MINUS-INFINITY = %x4D.49.4E.55.53.2D.49.4E.46.49.4E.49.54.59
; "MINUS-INFINITY"
<span class="h3"><a class="selflink" id="section-3.20" href="#section-3.20">3.20</a>. Variant Encodings</span>
The values of some named complex ASN.1 types have special string
encodings. These special encodings are always used instead of the
encoding that would otherwise apply based on the ASN.1 type
definition.
VariantEncoding = RDNSequenceValue /
RelativeDistinguishedNameValue /
ORAddressValue
A value of the RDNSequence type, i.e., a distinguished name, is
encoded according to the <RDNSequenceValue> rule, as a quoted LDAPDN
character string. The character string is first derived according to
the <distinguishedName> rule in <a href="./rfc2253#section-3">Section 3 of RFC 2253</a> [<a href="#ref-5" title=""Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names"">5</a>], and then
encoded as if it were a UTF8String value, i.e., between double quotes
with any embedded double quotes escaped by being repeated.
RDNSequenceValue = StringValue
A RelativeDistinguishedName value that is not part of an RDNSequence
value is encoded according to the <RelativeDistinguishedNameValue>
rule as a quoted character string. The character string is first
derived according to the <name-component> rule in Section 3 of <a href="./rfc2253">RFC</a>
<a href="./rfc2253">2253</a> [<a href="#ref-5" title=""Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names"">5</a>], and then encoded as if it were a UTF8String value.
RelativeDistinguishedNameValue = StringValue
A value of the ORAddress type is encoded according to the
<ORAddressValue> rule as a quoted character string. The character
string is first derived according to the textual representation of
MTS.ORAddress from <a href="./rfc2156">RFC 2156</a> [<a href="#ref-2" title=""MIXER (Mime Internet X.400 Enhanced Relay): Mapping between X.400 and RFC 822/MIME"">2</a>], and then encoded as if it were an
IA5String value.
ORAddressValue = StringValue
<span class="grey">Legg Standards Track [Page 12]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-13" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
<span class="h2"><a class="selflink" id="section-4" href="#section-4">4</a>. GSER Transfer Syntax</span>
The following OBJECT IDENTIFIER has been assigned by Adacel
Technologies, under an arc assigned to Adacel by Standards Australia,
to identify the Generic String Encoding Rules:
{ 1 2 36 79672281 0 0 }
This OBJECT IDENTIFIER would be used, for example, to describe the
transfer syntax for a GSER encoded data-value in an EMBEDDED PDV
value.
<span class="h2"><a class="selflink" id="section-5" href="#section-5">5</a>. Security Considerations</span>
The Generic String Encoding Rules do not define a canonical encoding.
That is, a transformation from a GSER encoding into some other
encoding (e.g., BER) and back into GSER will not necessarily
reproduce the original GSER octet encoding. Therefore, GSER MUST NOT
be used where a canonical encoding is needed.
Furthermore, GSER does not necessarily enable the exact octet
encoding of values of the TeletexString, VideotexString,
GraphicString or GeneralString types to be reconstructed, so a
transformation from a Distinguished Encoding Rules (DER) [<a href="#ref-12">12</a>]
encoding to GSER and back to DER may not reproduce the original DER
encoding. Therefore, GSER MUST NOT be used to re-encode, whether for
storage or transmission, ASN.1 abstract values whose original binary
encoding must be recoverable. Such recovery is needed for the
verification of digital signatures. In such cases, protocols ought
to use DER or a DER-reversible encoding.
When interpreting security-sensitive fields, and in particular fields
used to grant or deny access, implementations MUST ensure that any
comparisons are done on the underlying abstract value, regardless of
the particular encoding used.
<span class="h2"><a class="selflink" id="section-6" href="#section-6">6</a>. References</span>
<span class="h3"><a class="selflink" id="section-6.1" href="#section-6.1">6.1</a>. Normative References</span>
[<a id="ref-1">1</a>] Bradner, S., "Key words for use in RFCs to Indicate Requirement
Levels", <a href="https://www.rfc-editor.org/bcp/bcp14">BCP 14</a>, <a href="./rfc2119">RFC 2119</a>, March 1997.
[<a id="ref-2">2</a>] Kille, S., "MIXER (Mime Internet X.400 Enhanced Relay): Mapping
between X.400 and <a href="./rfc822">RFC 822</a>/MIME", <a href="./rfc2156">RFC 2156</a>, January 1998.
[<a id="ref-3">3</a>] Crocker, D. and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", <a href="./rfc2234">RFC 2234</a>, November 1997.
<span class="grey">Legg Standards Track [Page 13]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-14" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
[<a id="ref-4">4</a>] Wahl, M., Coulbeck, A., Howes, T. and S. Kille, "Lightweight
Directory Access Protocol (v3): Attribute Syntax Definitions",
<a href="./rfc2252">RFC 2252</a>, December 1997.
[<a id="ref-5">5</a>] Wahl, M., Kille S. and T. Howes. "Lightweight Directory Access
Protocol (v3): UTF-8 String Representation of Distinguished
Names", <a href="./rfc2253">RFC 2253</a>, December 1997.
[<a id="ref-6">6</a>] Yergeau, F., "UTF-8, a transformation format of ISO 10646", <a href="./rfc2279">RFC</a>
<a href="./rfc2279">2279</a>, January 1998.
[<a id="ref-7">7</a>] ITU-T Recommendation X.520 (1993) | ISO/IEC 9594-6:1994,
Information Technology - Open Systems Interconnection - The
Directory: Selected attribute types
[<a id="ref-8">8</a>] ITU-T Recommendation X.680 (07/02) | ISO/IEC 8824-1:2002
Information technology - Abstract Syntax Notation One (ASN.1):
Specification of basic notation
[<a id="ref-9">9</a>] ITU-T Recommendation X.681 (07/02) | ISO/IEC 8824-2:2002
Information technology - Abstract Syntax Notation One (ASN.1):
Information object specification
[<a id="ref-10">10</a>] ITU-T Recommendation X.682 (07/02) | ISO/IEC 8824-3:2002
Information technology - Abstract Syntax Notation One (ASN.1):
Constraint specification
[<a id="ref-11">11</a>] ITU-T Recommendation X.683 (07/02) | ISO/IEC 8824-4:2002
Information technology - Abstract Syntax Notation One (ASN.1):
Parameterization of ASN.1 specifications
[<a id="ref-12">12</a>] ITU-T Recommendation X.690 (07/02) | ISO/IEC 8825-1:2002
Information technology - ASN.1 encoding rules: Specification of
Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and
Distinguished Encoding Rules (DER)
<span class="h3"><a class="selflink" id="section-6.2" href="#section-6.2">6.2</a>. Informative References</span>
[<a id="ref-13">13</a>] Hovey, R. and S. Bradner, "The Organizations Involved in the
IETF Standards Process", <a href="https://www.rfc-editor.org/bcp/bcp11">BCP 11</a>, <a href="./rfc2028">RFC 2028</a>, October 1996.
[<a id="ref-14">14</a>] Hodges, J. and R. Morgan, "Lightweight Directory Access Protocol
(v3): Technical Specification", <a href="./rfc3377">RFC 3377</a>, September 2002.
[<a id="ref-15">15</a>] Legg, S., "Common Elements of Generic String Encoding Rules
(GSER) Encodings", <a href="./rfc3642">RFC 3642</a>, October 2003.
<span class="grey">Legg Standards Track [Page 14]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-15" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
[<a id="ref-16">16</a>] ITU-T Recommendation X.500 (1993) | ISO/IEC 9594-1:1994,
Information Technology - Open Systems Interconnection - The
Directory: Overview of concepts, models and services
<span class="h2"><a class="selflink" id="section-7" href="#section-7">7</a>. Intellectual Property Notice</span>
The IETF takes no position regarding the validity or scope of any
intellectual property or other rights that might be claimed to
pertain to the implementation or use of the technology described in
this document or the extent to which any license under such rights
might or might not be available; neither does it represent that it
has made any effort to identify any such rights. Information on the
IETF's procedures with respect to rights in standards-track and
standards-related documentation can be found in <a href="https://www.rfc-editor.org/bcp/bcp11">BCP-11</a>. Copies of
claims of rights made available for publication and any assurances of
licenses to be made available, or the result of an attempt made to
obtain a general license or permission for the use of such
proprietary rights by implementors or users of this specification can
be obtained from the IETF Secretariat.
The IETF invites any interested party to bring to its attention any
copyrights, patents or patent applications, or other proprietary
rights which may cover technology that may be required to practice
this standard. Please address the information to the IETF Executive
Director.
<span class="h2"><a class="selflink" id="section-8" href="#section-8">8</a>. Author's Address</span>
Steven Legg
Adacel Technologies Ltd.
250 Bay Street
Brighton, Victoria 3186
AUSTRALIA
Phone: +61 3 8530 7710
Fax: +61 3 8530 7888
EMail: steven.legg@adacel.com.au
<span class="grey">Legg Standards Track [Page 15]</span></pre>
<hr class='noprint'/><!--NewPage--><pre class='newpage'><span id="page-16" ></span>
<span class="grey"><a href="./rfc3641">RFC 3641</a> Generic String Encoding Rules October 2003</span>
<span class="h2"><a class="selflink" id="section-9" href="#section-9">9</a>. Full Copyright Statement</span>
Copyright (C) The Internet Society (2003). All Rights Reserved.
This document and translations of it may be copied and furnished to
others, and derivative works that comment on or otherwise explain it
or assist in its implementation may be prepared, copied, published
and distributed, in whole or in part, without restriction of any
kind, provided that the above copyright notice and this paragraph are
included on all such copies and derivative works. However, this
document itself may not be modified in any way, such as by removing
the copyright notice or references to the Internet Society or other
Internet organizations, except as needed for the purpose of
developing Internet standards in which case the procedures for
copyrights defined in the Internet Standards process must be
followed, or as required to translate it into languages other than
English.
The limited permissions granted above are perpetual and will not be
revoked by the Internet Society or its successors or assignees.
This document and the information contained herein is provided on an
"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Acknowledgement
Funding for the RFC Editor function is currently provided by the
Internet Society.
Legg Standards Track [Page 16]
</pre>
|