RFC 3642
Common Elements of Generic String Encoding Rules (GSER) Encodings
Common Elements of Generic String Encoding Rules (GSER) Encodings π
RFC 3642 π was written by S. Legg at Adacel Technologies and dated October 2003. It's Informational, so it's sharing useful info rather than setting a standard. The title block doesn't list anything it obsoletes or updates. It's giving "reference material for the Internet community" energy π«Ά
Status of This Memo β¨
Okay so this memo is just here to provide information for the Internet community. It does not specify an Internet standard of any kind, and distribution is unlimited π
Copyright Notice π
Copyright (C) The Internet Society (2003). All Rights Reserved.
Abstract πΈ
Okay, the Generic String Encoding Rules (GSER) are a human readable text encoding for an Abstract Syntax Notation One (ASN.1) value of any ASN.1 type π₯ Specs that use GSER might want to include an equivalent Augmented Backus-Naur Form (ABNF) description of the GSER encoding for a particular ASN.1 type, as a convenience for implementors. This document is the bestie that supplies that equivalent ABNF for the GSER encodings of ASN.1 types that commonly show up in Lightweight Directory Access Protocol (LDAP) syntaxes. Iconic π
Table of Contents π§
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Conventions. . . . . . . . . . . . . . . . . . . . . . . . . . 2
3. Separators . . . . . . . . . . . . . . . . . . . . . . . . . . 2
4. ASN.1 Built-in Types . . . . . . . . . . . . . . . . . . . . . 2
5. ASN.1 Restricted String Types. . . . . . . . . . . . . . . . . 7
6. Directory ASN.1 Types. . . . . . . . . . . . . . . . . . . . . 9
7. Security Considerations. . . . . . . . . . . . . . . . . . . . 10
8. References . . . . . . . . . . . . . . . . . . . . . . . . . . 10
8.1. Normative References . . . . . . . . . . . . . . . . . . 10
8.2. Informative References . . . . . . . . . . . . . . . . . 11
9. Intellectual Property Notice . . . . . . . . . . . . . . . . . 12
10. Author's Address . . . . . . . . . . . . . . . . . . . . . . . 12
11. Full Copyright Statement . . . . . . . . . . . . . . . . . . . 13
1. Introduction π¦
So GSER [7] gives you a human readable text encoding, built on ASN.1 [8] value notation, for an ASN.1 value of any ASN.1 type β¨ Specs using GSER might like to add a non-normative equivalent ABNF [3] description of the GSER encoding for a particular ASN.1 type, to help implementors who aren't familiar with ASN.1 yet π«Ά This document is that helper. It gives equivalent ABNF for the GSER encodings of ASN.1 types that commonly appear in LDAP [10] or X.500 [11] attribute and assertion syntaxes, plus equivalent ABNF for the GSER encodings of the ASN.1 built-in types. Main character energy π
The ABNF in here does not replace or change GSER in any way, bestie π If the ABNF here ever disagrees with the encoding defined by GSER [7], then GSER wins. It's definitive. No debate π
2. Conventions π
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", and "MAY" in this doc get read the way BCP 14, RFC 2119 [1] describes β¨ Also, "OPTIONAL" is used exclusively with its ASN.1 meaning, so it's not a BCP 14 thing here π§
3. Separators π
Some separators get used a lot when you're building equivalent ABNF for SET and SEQUENCE types π
sp = *%x20 ; zero, one or more space characters
msp = 1*%x20 ; one or more space characters
sep = [ "," ]
The <sep> rule is used in the ABNF for the encoding of ASN.1 SET or SEQUENCE types where every component is either OPTIONAL or DEFAULT. Here's the tea β It encodes to an empty string if and only if the character right before it in the encoding is "{". So it's only empty for the first optional component that's actually present in the SET or SEQUENCE value being encoded. It's giving precision π₯
4. ASN.1 Built-in Types β¨
okay bestie, this section is where we get into the GSER encoding for the ASN.1 built-in types π The one thing we're skipping is the restricted character string types, so don't look for those here π
The <BIT-STRING> rule covers the BIT STRING type when there's no named bit list π¦ It's either bstring or hstring, and the choice depends on how many bits you've got:
BIT-STRING = bstring / hstring
Okay, so here's the deal. If the number of bits in a BIT STRING value is a multiple of four, the <hstring> form of <BIT-STRING> MAY be used πΈ If it's not, you use the <bstring> form. <bstring> writes every bit as a "0" or a "1", going from the first bit to the last π <hstring> groups the bits in fours, and each group becomes one hexadecimal number where the first bit is the most significant one π An odd number of hexadecimal digits is allowed too, which is lowkey a nice touch β¨
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"
squote = %x27 ; ' (single quote)
The <BOOLEAN> rule is the GSER encoding for the BOOLEAN type. It's just two options, TRUE or FALSE, so it's very easy to get right π
BOOLEAN = %x54.52.55.45 / ; "TRUE"
%x46.41.4C.53.45 ; "FALSE"
Next up is <CHARACTER-STRING>, which is the GSER encoding for the unrestricted CHARACTER STRING type π§ It's a little bit of a structure, with an identification part and a data-value part π«Ά
CHARACTER-STRING = "{" sp id-identification msp Identification ","
sp id-data-value msp OCTET-STRING
sp "}"
id-identification = %x69.64.65.6E.74.69.66.69.63.61.74.69.6F.6E
; "identification"
id-data-value = %x64.61.74.61.2D.76.61.6C.75.65 ; "data-value"
Identification = ( id-syntaxes ":" Syntaxes ) /
( id-syntax ":" OBJECT-IDENTIFIER ) /
( id-presentation-context-id ":" INTEGER ) /
( id-context-negotiation ":"
ContextNegotiation ) /
( id-transfer-syntax ":" OBJECT-IDENTIFIER ) /
( id-fixed ":" NULL )
id-syntaxes = %x73.79.6E.74.61.78.65.73
; "syntaxes"
id-syntax = %x73.79.6E.74.61.78 ; "syntax"
id-presentation-context-id = %x70.72.65.73.65.6E.74.61.74.69.6F.6E
%x2D.63.6F.6E.74.65.78.74.2D.69.64
; "presentation-context-id"
id-context-negotiation = %x63.6F.6E.74.65.78.74.2D.6E.65.67.6F
%x74.69.61.74.69.6F.6E
; "context-negotiation"
id-transfer-syntax = %x74.72.61.6E.73.66.65.72.2D.73.79.6E
%x74.61.78 ; "transfer-syntax"
id-fixed = %x66.69.78.65.64 ; "fixed"
Syntaxes = "{" sp id-abstract msp OBJECT-IDENTIFIER ","
sp id-transfer msp OBJECT-IDENTIFIER
sp "}"
id-abstract = %x61.62.73.74.72.61.63.74 ; "abstract"
id-transfer = %x74.72.61.6E.73.66.65.72 ; "transfer"
ContextNegotiation = "{" sp id-presentation-context-id msp
INTEGER ","
sp id-transfer-syntax msp
OBJECT-IDENTIFIER
sp "}"
Now the integers π₯ <INTEGER> covers the INTEGER type without a named number list. <INTEGER-0-MAX> is for the constrained INTEGER (0..MAX), and <INTEGER-1-MAX> is for INTEGER (1..MAX) π
INTEGER = "0" / positive-number / ("-" positive-number)
INTEGER-0-MAX = "0" / positive-number
INTEGER-1-MAX = positive-number
positive-number = non-zero-digit *decimal-digit
decimal-digit = %x30-39 ; "0" to "9"
non-zero-digit = %x31-39 ; "1" to "9"
<EMBEDDED-PDV> is the GSER encoding for the EMBEDDED PDV type π It has the same shape as the CHARACTER STRING one above, so it'll feel very familiar π¦
EMBEDDED-PDV = "{" sp id-identification msp Identification ","
sp id-data-value msp OCTET-STRING
sp "}"
<EXTERNAL> is the GSER encoding for the EXTERNAL type π This one is more flexible, since the direct-reference, indirect-reference and data-value-descriptor parts are all optional, but the encoding part is always there πΈ
EXTERNAL = "{" [ sp id-direct-reference msp
OBJECT-IDENTIFIER "," ]
[ sp id-indirect-reference msp INTEGER "," ]
[ sp id-data-value-descriptor msp
ObjectDescriptor "," ]
sp id-encoding msp Encoding
sp "}"
id-direct-reference = %x64.69.72.65.63.74.2D.72.65.66.65.72
%x65.6E.63.65
; "direct-reference"
id-indirect-reference = %x69.6E.64.69.72.65.63.74.2D.72.65.66
%x65.72.65.6E.63.65
; "indirect-reference"
id-data-value-descriptor = %x64.61.74.61.2D.76.61.6C.75.65.2D.64
%x65.73.63.72.69.70.74.6F.72
; "data-value-descriptor"
id-encoding = %x65.6E.63.6F.64.69.6E.67
; "encoding"
Encoding = ( id-single-ASN1-type ":" Value ) /
( id-octet-aligned ":" OCTET-STRING ) /
( id-arbitrary ":" BIT-STRING )
id-single-ASN1-type = %x73.69.6E.67.6C.65.2D.41.53.4E.31.2D.74.79
%x70.65
; "single-ASN1-type"
id-octet-aligned = %x6F.63.74.65.74.2D.61.6C.69.67.6E.65.64
; "octet-aligned"
id-arbitrary = %x61.72.62.69.74.72.61.72.79
; "arbitrary"
The <Value> rule comes from GSER [7] π§ It's the GSER encoding of one value of the ASN.1 type that's pointed to by the direct-reference and/or indirect-reference components.
The <Value> rule is defined by GSER [7]. It represents the GSER
encoding of a single value of the ASN.1 type identified by the
direct-reference and/or indirect-reference components.
Next is <NULL>, which is the GSER encoding for the NULL type. It's literally just the word NULL π
NULL = %x4E.55.4C.4C ; "NULL"
<OBJECT-IDENTIFIER> is the GSER encoding for OBJECT IDENTIFIER values π¦ You can write them in dotted decimal form or as an object descriptor name, which the spec calls <descr>. That <descr> rule comes from RFC 2252 [4]. Heads up, though: an object descriptor name can be ambiguous, so use it with care π
OBJECT-IDENTIFIER = numeric-oid / descr
numeric-oid = oid-component 1*( "." oid-component )
oid-component = "0" / positive-number
<OCTET-STRING> is the GSER encoding for OCTET STRING values, and it's just an hstring under the hood π
OCTET-STRING = hstring
The octets go in order, from the first to the last π Each octet becomes a pair of hexadecimal digits, and the first digit holds the four most significant bits of that octet π If the hex string has an odd number of digits, the four least significant bits of the last octet are assumed to be zero π«Ά
<REAL> is the GSER encoding for the REAL type, and it's the most complicated one in this section π Zero is written as "0", the infinities get their own names, and the nonzero values come in base 10 or base 2 forms β¨
REAL = "0" ; zero
/ PLUS-INFINITY ; positive infinity
/ MINUS-INFINITY ; negative infinity
/ realnumber ; positive base 10 REAL value
/ ( "-" realnumber ) ; negative base 10 REAL value
/ real-sequence-value ; non-zero base 2 or 10 REAL value
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"
realnumber = mantissa exponent
mantissa = (positive-number [ "." *decimal-digit ])
/ ( "0." *("0") positive-number )
exponent = "E" ( "0" / ([ "-" ] positive-number))
real-sequence-value = "{" sp id-mantissa msp INTEGER ","
sp id-base msp ( "2" / "10" ) ","
sp id-exponent msp INTEGER sp "}"
id-mantissa = %x6D.61.6E.74.69.73.73.61 ; "mantissa"
id-base = %x62.61.73.65 ; "base"
id-exponent = %x65.78.70.6F.6E.65.6E.74 ; "exponent"
Now the important rule β A REAL value that is zero MUST be encoded as "0", so there's no wiggle room on that one π₯
A value of the REAL type MUST be encoded as "0" if it is zero.
Last but not least, <RELATIVE-OID> is the GSER encoding for RELATIVE-OID values, and it's built from the same oid-component pieces we saw earlier π
RELATIVE-OID = oid-component *( "." oid-component )
5. ASN.1 Restricted String Types β¨
okay so this section is all about how GSER writes down values of the ASN.1 restricted character string types π the characters always end up as a UTF-8 string wrapped in double quotes, bestie π sometimes that means translating first, and some string types only allow a smaller set of characters. any double quote inside gets escaped by being doubled up, but only where the character set even allows double quotes in the first place π«Ά
The <UTF8String> rule is the simplest one πΈ its characters don't need any translation before they get encoded:
UTF8String = StringValue
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
The <NumericString>, <PrintableString>, <VisibleString>, <ISO646String>, <IA5String>, <GeneralizedTime> and <UTCTime> rules cover the GSER encoding of the correspondingly named ASN.1 types π¦ their characters are already compatible with UTF-8, so nothing needs translating before encoding. The GeneralizedTime and UTCTime types use the VisibleString character set, but they have a strictly defined format π
NumericString = dquote *(decimal-digit / space) dquote
space = %x20
PrintableString = dquote *PrintableCharacter dquote
PrintableCharacter = decimal-digit / space
/ %x41-5A ; A to Z
/ %x61-7A ; a to z
/ %x27-29 ; ' ( )
/ %x2B-2F ; + , - . /
/ %x3A ; :
/ %x3D ; =
/ %x3F ; ?
ISO646String = VisibleString
VisibleString = dquote *SafeVisibleCharacter dquote
SafeVisibleCharacter = %x20-21
/ %x23-7E ; printable ASCII minus dquote
/ dquote dquote ; escaped double quote
IA5String = dquote *SafeIA5Character dquote
SafeIA5Character = %x00-21 / %x23-7F ; ASCII minus dquote
/ dquote dquote ; escaped double quote
century = 2(%x30-39) ; "00" to "99"
year = 2(%x30-39) ; "00" to "99"
month = ( %x30 %x31-39 ) ; "01" (January) to "09"
/ ( %x31 %x30-32 ) ; "10" to "12"
day = ( %x30 %x31-39 ) ; "01" to "09"
/ ( %x31-32 %x30-39 ) ; "10" to "29"
/ ( %x32 %x30-31 ) ; "30" to "31"
hour = ( %x30-31 %x30-39 ) / ( %x32 %x30-33 ) ; "00" to "23"
minute = %x30-35 %x30-39 ; "00" to "59"
second = ( %x30-35 %x30-39 ) ; "00" to "59"
/ ( %x36 %x30 ) ; "60" (a leap second)
UTCTime = dquote year month day hour minute [ second ]
[ %x5A / u-differential ] dquote
u-differential = ( "-" / "+" ) hour minute
GeneralizedTime = dquote century year month day hour
[ minute [ second ] ] [ fraction ]
[ %x5A / g-differential ] dquote
fraction = ( "." / "," ) 1*(%x30-39)
g-differential = ( "-" / "+" ) hour [ minute ]
The <BMPString> and <UniversalString> rules cover the GSER encoding of the BMPString and UniversalString types, respectively β¨ BMPString (UCS-2) and UniversalString (UCS-4) values get translated into UTF-8 [6] character strings before they're encoded according to <StringValue> π
BMPString = StringValue
UniversalString = StringValue
The <TeletexString>, <T61String>, <VideotexString>, <GraphicString>, <GeneralString> and <ObjectDescriptor> rules cover the GSER encoding of the correspondingly named ASN.1 types π§ values of these string types get translated into UTF-8 character strings before being encoded according to <StringValue>. The ObjectDescriptor type uses the GraphicString character set π
TeletexString = StringValue
T61String = StringValue
VideotexString = StringValue
GraphicString = StringValue
GeneralString = StringValue
ObjectDescriptor = GraphicString
6. Directory ASN.1 Types π
this section covers the GSER encoding of some ASN.1 types defined for LDAP and X.500 π the ABNF rule names that start with uppercase letters describe the GSER encoding of the ASN.1 type with the same name π
AttributeType = OBJECT-IDENTIFIER
The characters of a DirectoryString get translated into UTF-8 characters as required, then they're wrapped in double quotes with any embedded double quotes escaped by being repeated π
DirectoryString = StringValue /
( id-teletexString ":" TeletexString ) /
( id-printableString ":" PrintableString ) /
( id-bmpString ":" BMPString ) /
( id-universalString ":" UniversalString ) /
( id-uTF8String ":" UTF8String )
id-teletexString = %x74.65.6C.65.74.65.78.53.74.72.69.6E.67
; "teletexString"
id-printableString = %x70.72.69.6E.74.61.62.6C.65
%x53.74.72.69.6E.67 ; "printableString"
id-bmpString = %x62.6D.70.53.74.72.69.6E.67 ; "bmpString"
id-universalString = %x75.6E.69.76.65.72.73.61.6C
%x53.74.72.69.6E.67 ; "universalString"
id-uTF8String = %x75.54.46.38.53.74.72.69.6E.67
; "uTF8String"
The <RDNSequence> rule covers the GSER encoding of values of the RDNSequence type, which is syntactically equivalent to the DistinguishedName and LocalName types β¨ it encodes a name as an LDAPDN character string between double quotes. That character string is first derived according to the <distinguishedName> rule in Section 3 of RFC 2253 [5], and then it's wrapped in double quotes with any embedded double quotes escaped by being repeated π«Ά
DistinguishedName = RDNSequence
LocalName = RDNSequence
RDNSequence = dquote *SafeUTF8Character dquote
The <RelativeDistinguishedName> rule covers the GSER encoding of values of the RelativeDistinguishedName type that aren't part of an RDNSequence value π¦ it encodes an RDN as a double quoted string containing the RDN as it would appear in an LDAPDN character string. That character string is first derived according to the <name-component> rule in Section 3 of RFC 2253 [5], and then any embedded double quote characters get escaped by being repeated. The resulting string is output between double quotes π
RelativeDistinguishedName = dquote *SafeUTF8Character dquote
The <ORAddress> rule encodes an X.400 address as an IA5 character string between double quotes πΈ the character string is first derived according to Section 4.1 of RFC 2156 [2], and then any embedded double quotes are escaped by being repeated. The resulting string is output between double quotes π
ORAddress = dquote *SafeIA5Character dquote
7. Security Considerations π
This document contains an alternative description of parts of the Generic String Encoding Rules, but it does not replace or alter GSER in any way π for the full security implications of using GSER, see the Security Considerations section for GSER [7] π₯
8. References π
8.1. Normative References
[1] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.
[2] Kille, S., "MIXER (Mime Internet X.400 Enhanced Relay): Mapping between X.400 and RFC 822/MIME", RFC 2156, January 1998.
[3] Crocker, D. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", RFC 2234, November 1997.
[4] Wahl, M., Coulbeck, A., Howes, T. and S. Kille, "Lightweight Directory Access Protocol (v3): Attribute Syntax Definitions", RFC 2252, December 1997.
[5] Wahl, M., Kille, S. and T. Howes, "Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names", RFC 2253, December 1997.
[6] Yergeau, F., "UTF-8, a transformation format of ISO 10646", RFC 2279, January 1998.
[7] Legg, S., "Generic String Encoding Rules (GSER) for ASN.1 Types", RFC 3641, October 2003.
[8] ITU-T Recommendation X.680 (07/02) | ISO/IEC 8824-1:2002 Information technology - Abstract Syntax Notation One (ASN.1): Specification of basic notation
8.2. Informative References
[9] Hovey, R. and S. Bradner, "The Organizations Involved in the IETF Standards Process", BCP 11, RFC 2028, October 1996.
[10] Hodges, J. and R. Morgan, "Lightweight Directory Access Protocol (v3): Technical Specification", RFC 3377, September 2002.
[11] ITU-T Recommendation X.500 (1993) | ISO/IEC 9594-1:1994, Information Technology - Open Systems Interconnection - The Directory: Overview of concepts, models and services
9. Intellectual Property Notice π
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 BCP-11. 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 π
10. Author's Address π¦
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
11. Full Copyright Statement π
Copyright (C) The Internet Society (2003). All Rights Reserved. π¦
okay so you can copy and share this document and translations of it, bestie πβ¨ You can also make derivative works that comment on or explain it, or help people implement it, and publish and distribute those too, in whole or in part, with no restrictions at all π . The one catch is that the above copyright notice and this paragraph have to be included on every copy and derivative work π«Ά
BUT the document itself can't be modified in any way π ββοΈ That means no removing the copyright notice or the references to the Internet Society or other Internet organizations. The exceptions are: using it for developing Internet standards, where the copyright procedures in the Internet Standards process must be followed, or translating it into languages other than English π
The limited permissions above are perpetual, meaning they will never be revoked by the Internet Society or its successors or assignees π Forever and ever, periodt π
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. π§
π¦ where this page comes from
- ietf: rfc3642 2003-10
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms