<?xml version="1.0" encoding="US-ASCII"?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC0934 SYSTEM 'reference.RFC.0934.xml'>
<!ENTITY rfc1421 SYSTEM 'reference.RFC.1421.xml'>
<!ENTITY rfc2119 SYSTEM 'reference.RFC.2119.xml'>
<!ENTITY rfc2986 SYSTEM 'reference.RFC.2986.xml'>
<!ENTITY rfc2315 SYSTEM 'reference.RFC.2315.xml'>
<!ENTITY RFC2585 SYSTEM 'reference.RFC.2585.xml'>
<!ENTITY rfc4648 SYSTEM 'reference.RFC.4648.xml'>
<!ENTITY rfc4716 SYSTEM 'reference.RFC.4716.xml'>
<!ENTITY rfc4880 SYSTEM 'reference.RFC.4880.xml'>
<!ENTITY RFC5208 SYSTEM 'reference.RFC.5208.xml'>
<!ENTITY RFC5234 SYSTEM 'reference.RFC.5234.xml'>
<!ENTITY rfc5280 SYSTEM 'reference.RFC.5280.xml'>
<!ENTITY RFC5652 SYSTEM 'reference.RFC.5652.xml'>
<!ENTITY rfc5755 SYSTEM 'reference.RFC.5755.xml'>
<!ENTITY RFC5958 SYSTEM 'reference.RFC.5958.xml'>
<!ENTITY RFC7292 SYSTEM 'reference.RFC.7292.xml'>
<!ENTITY x690 SYSTEM 'http://xml.resource.org/public/rfc/bibxml2/reference.CCITT.X690.2002.xml'>
]>

<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc compact="yes"?>
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc comments="yes"?>
<?rfc rfcedstyle="yes"?>

<rfc number="7468" category="std" submissionType="IETF" ipr="trust200902">

  <front>

    <title abbrev="PKIX Textual Encodings">Textual Encodings of PKIX, PKCS, and CMS Structures</title>

    <author initials="S." surname="Josefsson" fullname="Simon Josefsson">
      <organization>SJD AB</organization>
      <address>
	<postal>
	  <street>Johan Olof Wallins Vaeg 13</street>
	  <city>Solna</city>
	  <code>171 64</code>
	  <country>Sweden</country>
	</postal>
	<email>simon@josefsson.org</email>
	<uri>http://josefsson.org/</uri>
      </address>
    </author>

		<author fullname="Sean Leonard" initials="S.L." surname="Leonard">
			<organization>Penango, Inc.</organization>
			<address>
				<postal>
					<street>5900 Wilshire Boulevard</street>
					<street>21st Floor</street>
					<city>Los Angeles</city>
					<region>CA</region>
					<code>90036</code>
					<country>United States</country>
				</postal>

				<email>dev+ietf@seantek.com</email>
				<uri>http://www.penango.com/</uri>
				<!-- uri and facsimile elements may also be added -->
			</address>
		</author>

		<date month="March" year="2015"/>

    <keyword>textual encoding</keyword>
    <keyword>PKIX</keyword>
    <keyword>PKCS</keyword>
    <keyword>CMS</keyword>
    <keyword>base64</keyword>
    <keyword>PEM</keyword>
    <keyword>encapsulation boundary</keyword>
    <keyword>X.509</keyword>
    <keyword>certificate</keyword>
    <keyword>cert</keyword>
    <keyword>ASN.1</keyword>
    <keyword>BER</keyword>
    <keyword>DER</keyword>

    <abstract>

      <t>This document describes and discusses the textual encodings of
				the Public-Key Infrastructure X.509 (PKIX),
				Public-Key Cryptography Standards (PKCS), and
				Cryptographic Message Syntax (CMS).
				The textual encodings are well-known, are implemented by several
				applications and libraries, and are widely deployed.  This
				document articulates the de facto rules by which
				existing implementations operate and defines them
				so that future implementations can interoperate.</t>

    </abstract>

  </front>

  <middle>

    <section anchor="intro"
	     title="Introduction">

      <t>Several security-related standards used on the Internet
      define ASN.1 data formats that are normally encoded using <xref
      target="X.690">the Basic Encoding Rules (BER) or
			Distinguished Encoding Rules
      (DER)</xref>, which are binary, octet-oriented encodings.
			This document is about the textual encodings of the following formats:</t>

      <t><list style="numbers">
				<t>Certificates, Certificate Revocation Lists (CRLs),
				and Subject Public Key Info structures in the
				<xref target="RFC5280">Internet X.509 Public Key
				Infrastructure Certificate and Certificate Revocation List
				(CRL) Profile</xref>.</t>

				<t><xref target="RFC2986">PKCS #10: Certification Request
				Syntax</xref>.</t>
	
				<t><xref target="RFC2315">PKCS #7: Cryptographic Message
				Syntax</xref>.</t>

				<t><xref target="RFC5652">Cryptographic Message	Syntax</xref>.
				</t>
				<t><xref target="RFC5208">PKCS #8:
				Private-Key Information Syntax</xref>, renamed to
				One Asymmetric Key in
				<xref target="RFC5958">Asymmetric Key Package</xref>,
				and Encrypted Private-Key Information Syntax
				in the same documents.</t>
				<t>Attribute Certificates in
				<xref target="RFC5755">An Internet Attribute Certificate
				Profile for Authorization</xref>.</t>
      </list></t>
			
      <t>A disadvantage of a binary data format is that it cannot be interchanged in
      textual transports, such as email or text documents.  One
      advantage with text-based encodings is that they are easy to modify
      using common text editors; for example,
      a user may concatenate several certificates to form a certificate
      chain with copy-and-paste operations.</t>

			<t>
				The tradition within the RFC
				series can be traced back to <xref
				target="RFC1421">Privacy-Enhanced Mail (PEM)</xref>,
				based on a proposal by
				Marshall Rose in
				<xref target="RFC0934">Message Encapsulation</xref>.
				Originally called "PEM encapsulation mechanism",
				"encapsulated PEM message", or (arguably)
				"PEM printable encoding", today the format is sometimes referred to as
				"PEM encoding". Variations include <xref target="RFC4880">OpenPGP ASCII armor</xref> and
				<xref target="RFC4716">OpenSSH key file format</xref>.
			</t>
			<t>For reasons that basically boil down to non-coordination
			or inattention, many PKIX, PKCS, and
			CMS libraries implement a text-based encoding
			that is similar to -- but not identical with -- PEM encoding.
			This document specifies the _textual encoding_ format,
			articulates the de facto rules that most implementations operate by,
			and provides recommendations that will promote interoperability
			going forward. This document also provides common nomenclature
			for syntax elements, reflecting the evolution of this
			de facto standard format.
			Peter Gutmann's
      <xref target="X.509SG">"X.509 Style Guide"</xref> contains a
      section "base64 Encoding" that describes the formats and contains
      suggestions similar to what is in this document. All figures
			are real, functional examples, with key lengths and inner contents
			chosen to be as small as practicable.</t>

      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
      NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
      "MAY", and "OPTIONAL" in this document are to be interpreted as
      described in <xref target="RFC2119">RFC 2119</xref>.</t>

     </section>

     <section anchor="general"
	      title="General Considerations">

       <t>Textual encoding begins with a line comprising
       <spanx style="verb" xml:space="preserve">-----BEGIN </spanx>,
			 a label, and
			 <spanx style="verb" xml:space="preserve">-----</spanx>,
			 and ends with a line comprising
			 <spanx style="verb" xml:space="preserve">-----END </spanx>,
			 a label, and
			 <spanx style="verb" xml:space="preserve">-----</spanx>.
       Between these lines, or "encapsulation boundaries", are
			 base64-encoded data according to Section 4 of <xref target="RFC4648" />.
			 (PEM <xref target="RFC1421"/> referred to this data as the "encapsulated text portion".)
			 Data before the encapsulation boundaries
       are permitted, and parsers MUST NOT malfunction when processing such data.
       Furthermore, parsers SHOULD ignore whitespace and other
       non-base64 characters and MUST handle different newline
       conventions.</t>

       <t>The type of data encoded is labeled depending on the type
       label in the <spanx style="verb" xml:space="preserve">-----BEGIN </spanx> line (pre-encapsulation boundary).
			 For example, the line may be
       <spanx style="verb" xml:space="preserve">-----BEGIN CERTIFICATE-----</spanx> to indicate that the content is a
       PKIX certificate (see further below).
			 Generators MUST put the
       same label on the <spanx style="verb" xml:space="preserve">-----END </spanx> line (post-encapsulation boundary)
			 as the corresponding
       <spanx style="verb" xml:space="preserve">-----BEGIN </spanx> line.
			 Labels are formally case-sensitive, uppercase, and comprised of zero or more characters;
			 they do not contain consecutive spaces or hyphen-minuses, nor do
			 they contain spaces or hyphen-minuses at either end.
			 Parsers MAY disregard the label in the post-encapsulation boundary
			 instead of signaling an error if there is a
       label mismatch:
			 some extant implementations require the labels to match;
			 others do not.</t>
			 <t>There is exactly one space character (<spanx style="vbare">SP</spanx>) separating the
			 <spanx style="verb" xml:space="preserve">BEGIN</spanx> or <spanx style="verb" xml:space="preserve">END</spanx>
			 from the label. There are exactly
			 five hyphen-minus (also known as dash) characters
			 (<spanx style="verb" xml:space="preserve">-</spanx>)
			 on both ends of the encapsulation boundaries, no more, no less.</t>
       <t>The label type implies that the encoded data
				 follows the specified syntax.  Parsers MUST handle non-conforming
				 data gracefully. However, not all parsers or generators prior
				 to this document behave consistently.
				 A conforming parser MAY interpret the contents as another label
				 type but ought to be aware of the security implications discussed in
				 the <xref target="security" format="title" /> section.
				 
				 The labels described in this document identify container formats
				 that are not specific to any particular cryptographic algorithm,
				 a property consistent with algorithm agility.
				 These formats use the ASN.1
				 <spanx style="vbare" xml:space="preserve">AlgorithmIdentifier</spanx>
				 structure as described in Section 4.1.1.2 of <xref
				 target="RFC5280"/>.</t>

			 <t>Unlike <xref target="RFC1421">legacy PEM encoding</xref>,
			 OpenPGP ASCII armor, and the OpenSSH key file format,
			 textual encoding does *not*
			 define or permit headers
			 to be encoded alongside the data.
			 Empty space can appear between the pre-encapsulation boundary
			 and the base64, but generators SHOULD NOT emit such any such spacing.
			 (The provision for this empty area is a throwback
			 to PEM, which defined an "encapsulated header portion".)</t>

			 <t>Implementers need to be aware that extant parsers
			 diverge considerably on the handling of whitespace.
			 In this document, "whitespace" means
			 any character or series of characters that represent
			 horizontal or vertical space in typography.
			 In US-ASCII, whitespace means
			 <spanx style="vbare">HT</spanx> (0x09),
			 <spanx style="vbare">VT</spanx> (0x0B),
			 <spanx style="vbare">FF</spanx> (0x0C),
			 <spanx style="vbare">SP</spanx> (0x20),
			 <spanx style="vbare">CR</spanx> (0x0D), and
			 <spanx style="vbare">LF</spanx> (0x0A);
			 "blank" means <spanx style="vbare">HT</spanx> and <spanx style="vbare">SP</spanx>;
			 lines are divided with <spanx style="vbare">CRLF</spanx>,
			 <spanx style="vbare">CR</spanx>, or <spanx style="vbare">LF</spanx>.
			 The common ABNF production <spanx style="vbare">WSP</spanx>
			 is congruent with "blank";
			 a new production <spanx style="vbare">W</spanx>
			 is used for "whitespace".
			 The ABNF in <xref target="abnf" /> is specific to US-ASCII.
			 As these textual encodings can be used on many different systems
			 as well as on long-term archival storage media such as paper or engravings,
			 an implementer ought to use the spirit rather than the letter of
			 the rules when generating or parsing these formats in environments
			 that are not strictly limited to US-ASCII.</t>
			 
			 <t>Most extant parsers ignore blanks at the ends of lines;
			 blanks at the beginnings of lines or in the middle of the base64-encoded data
			 are far less compatible. These observations are codified in
			 <xref target="abnf-fig"/>.
			 The most lax parser implementations are not line-oriented at all
			 and will accept any mixture of whitespace outside of the encapsulation
			 boundaries (see <xref target="abnf-lax-fig"/>).
			 Such lax parsing may run the risk of
			 accepting text that was not intended to be accepted in the first place
			 (e.g., because the text was a snippet or sample).</t>

       <t>Generators MUST wrap the base64-encoded lines so that each
       line consists of exactly 64 characters except for the final
       line, which will encode the remainder of the data (within the
       64-character line boundary), and they MUST NOT emit extraneous whitespace.
			 Parsers MAY handle other line
       sizes. These requirements are consistent with
			 <xref target="RFC1421">PEM</xref>.</t>

			 <t>Files MAY contain multiple textual encoding instances.
			 This is used, for example, when a file
       contains several certificates.  Whether the instances are
      ordered or unordered depends on the context.</t>
     </section>

		<section anchor="abnf" title="ABNF">
			<t>The <xref target="RFC5234">ABNF</xref> of the textual encoding is:</t>


			<figure anchor="abnf-fig" title="ABNF (Standard)">
				<artwork type="abnf"><![CDATA[
textualmsg = preeb *WSP eol
             *eolWSP
             base64text
             posteb *WSP [eol]

preeb      = "-----BEGIN " label "-----" ; unlike [RFC1421] (A)BNF,
                                         ; eol is not required (but
posteb     = "-----END " label "-----"   ; see [RFC1421], Section 4.4)

base64char = ALPHA / DIGIT / "+" / "/"

base64pad  = "="

base64line = 1*base64char *WSP eol

base64finl = *base64char (base64pad *WSP eol base64pad /
                          *2base64pad) *WSP eol
                     ; ...AB= <EOL> = <EOL> is not good, but is valid

base64text = *base64line base64finl
       ; we could also use <encbinbody> from RFC 1421, which requires
       ; 16 groups of 4 chars, which means exactly 64 chars per
       ; line, except the final line, but this is more accurate

labelchar  = %x21-2C / %x2E-7E    ; any printable character,
                                  ; except hyphen-minus

label      = [ labelchar *( ["-" / SP] labelchar ) ]       ; empty ok

eol        = CRLF / CR / LF

eolWSP     = WSP / CR / LF                        ; compare with LWSP]]></artwork></figure>
<figure anchor="abnf-lax-fig" title="ABNF (Lax)">
				<artwork type="abnf"><![CDATA[laxtextualmsg    = *W preeb
                   laxbase64text
                   posteb *W

W                = WSP / CR / LF / %x0B / %x0C           ; whitespace

laxbase64text    = *(W / base64char) [base64pad *W [base64pad *W]]]]></artwork></figure>

<figure anchor="abnf-strict-fig" title="ABNF (Strict)">
				<artwork type="abnf"><![CDATA[stricttextualmsg = preeb eol
                   strictbase64text
                   posteb eol

strictbase64finl = *15(4base64char) (4base64char / 3base64char
                     base64pad / 2base64char 2base64pad) eol

base64fullline   = 64base64char eol

strictbase64text = *base64fullline strictbase64finl]]></artwork></figure>
			<t>New implementations SHOULD emit
				<xref target="abnf-strict-fig">the strict format</xref> specified above.
				The choice of parsing strategy depends on the context of use.</t>
		</section>

		<section anchor="guide" title="Guide">
			<t>For convenience, these figures summarize the structures,
			encodings, and references in the following sections:</t>
			<figure anchor="convenience-guide" title="Convenience Guide"
><artwork><![CDATA[
Sec. Label                  ASN.1 Type              Reference Module
----+----------------------+-----------------------+---------+----------
  5  CERTIFICATE            Certificate             [RFC5280] id-pkix1-e
  6  X509 CRL               CertificateList         [RFC5280] id-pkix1-e
  7  CERTIFICATE REQUEST    CertificationRequest    [RFC2986] id-pkcs10
  8  PKCS7                  ContentInfo             [RFC2315] id-pkcs7*
  9  CMS                    ContentInfo             [RFC5652] id-cms2004
 10  PRIVATE KEY            PrivateKeyInfo ::=      [RFC5208] id-pkcs8
                            OneAsymmetricKey        [RFC5958] id-aKPV1
 11  ENCRYPTED PRIVATE KEY  EncryptedPrivateKeyInfo [RFC5958] id-aKPV1
 12  ATTRIBUTE CERTIFICATE  AttributeCertificate    [RFC5755] id-acv2
 13  PUBLIC KEY             SubjectPublicKeyInfo    [RFC5280] id-pkix1-e]]></artwork>
			</figure><figure anchor="convenience-mods" title="ASN.1 Module Object Identifier Value Assignments"
><artwork><![CDATA[
 -----------------------------------------------------------------------
 id-pkixmod OBJECT IDENTIFIER ::= {iso(1) identified-organization(3)
            dod(6) internet(1) security(5) mechanisms(5) pkix(7) mod(0)}
 id-pkix1-e OBJECT IDENTIFIER ::= {id-pkixmod pkix1-explicit(18)}
 id-acv2    OBJECT IDENTIFIER ::= {id-pkixmod mod-attribute-cert-v2(61)}
 id-pkcs    OBJECT IDENTIFIER ::= {iso(1) member-body(2) us(840)
                                   rsadsi(113549) pkcs(1)}
 id-pkcs10  OBJECT IDENTIFIER ::= {id-pkcs 10 modules(1) pkcs-10(1)}
 id-pkcs7   OBJECT IDENTIFIER ::= {id-pkcs 7 modules(0) pkcs-7(1)}
 id-pkcs8   OBJECT IDENTIFIER ::= {id-pkcs 8 modules(1) pkcs-8(1)}
 id-sm-mod  OBJECT IDENTIFIER ::= {id-pkcs 9 smime(16) modules(0)}
 id-aKPV1   OBJECT IDENTIFIER ::= {id-sm-mod mod-asymmetricKeyPkgV1(50)}
 id-cms2004 OBJECT IDENTIFIER ::= {id-sm-mod cms-2004(24)}]]></artwork>
				<postamble>* This OID does not actually appear in
					<xref target="RFC2315">PKCS #7 v1.5</xref>. It was defined in
					the ASN.1 module to <xref target="P7v1.6">PKCS #7 v1.6</xref>,
					and has been carried forward through <xref target="RFC7292">PKCS #12</xref>.
				</postamble>
			</figure>
		</section>
     <section anchor="certificate"
	      title="Textual Encoding of Certificates">
<section title="Encoding">
       <t>Public-key certificates are encoded using the
			 <spanx style="verb" xml:space="preserve">CERTIFICATE</spanx> label.
       The encoded data MUST be a BER (DER strongly preferred; see <xref target="DERapp"/>)
			 encoded ASN.1 <spanx style="vbare" xml:space="preserve">Certificate</spanx>
       structure as described in Section 4 of <xref
       target="RFC5280"/>.</t>

      <figure anchor="certexample" title="Certificate Example">
	<artwork>-----BEGIN CERTIFICATE-----
MIICLDCCAdKgAwIBAgIBADAKBggqhkjOPQQDAjB9MQswCQYDVQQGEwJCRTEPMA0G
A1UEChMGR251VExTMSUwIwYDVQQLExxHbnVUTFMgY2VydGlmaWNhdGUgYXV0aG9y
aXR5MQ8wDQYDVQQIEwZMZXV2ZW4xJTAjBgNVBAMTHEdudVRMUyBjZXJ0aWZpY2F0
ZSBhdXRob3JpdHkwHhcNMTEwNTIzMjAzODIxWhcNMTIxMjIyMDc0MTUxWjB9MQsw
CQYDVQQGEwJCRTEPMA0GA1UEChMGR251VExTMSUwIwYDVQQLExxHbnVUTFMgY2Vy
dGlmaWNhdGUgYXV0aG9yaXR5MQ8wDQYDVQQIEwZMZXV2ZW4xJTAjBgNVBAMTHEdu
dVRMUyBjZXJ0aWZpY2F0ZSBhdXRob3JpdHkwWTATBgcqhkjOPQIBBggqhkjOPQMB
BwNCAARS2I0jiuNn14Y2sSALCX3IybqiIJUvxUpj+oNfzngvj/Niyv2394BWnW4X
uQ4RTEiywK87WRcWMGgJB5kX/t2no0MwQTAPBgNVHRMBAf8EBTADAQH/MA8GA1Ud
DwEB/wQFAwMHBgAwHQYDVR0OBBYEFPC0gf6YEr+1KLlkQAPLzB9mTigDMAoGCCqG
SM49BAMCA0gAMEUCIDGuwD1KPyG+hRf88MeyMQcqOFZD0TbVleF+UsAGQ4enAiEA
l4wOuDwKQa+upc8GftXE2C//4mKANBC6It01gUaTIpo=
-----END CERTIFICATE-----</artwork>
      </figure>

       <t>Historically, the label
			 <spanx style="verb" xml:space="preserve">X509 CERTIFICATE</spanx> and also
			 less commonly <spanx style="verb" xml:space="preserve">X.509 CERTIFICATE</spanx>
			 have been used.  Generators
       conforming to this document MUST generate
			 <spanx style="verb" xml:space="preserve">CERTIFICATE</spanx> labels
       and MUST NOT generate <spanx style="verb" xml:space="preserve">X509 CERTIFICATE</spanx>
			 or <spanx style="verb" xml:space="preserve">X.509 CERTIFICATE</spanx>
       labels. Parsers SHOULD NOT treat
			 <spanx style="verb" xml:space="preserve">X509 CERTIFICATE</spanx> or
			 <spanx style="verb" xml:space="preserve">X.509 CERTIFICATE</spanx>
			 as equivalent to <spanx style="verb" xml:space="preserve">CERTIFICATE</spanx>,
			 but a valid exception may be for backwards
       compatibility (potentially together with a warning).</t>
	</section>		
				<section title="Explanatory Text">
					<t>Many tools are known to emit explanatory text before the BEGIN
					and after the END lines for PKIX certificates, more than
					any other type. If emitted, such text SHOULD be
					related to the certificate, such as providing a textual representation
					of key data elements in the certificate.</t>
					<figure anchor="certexplexample" title="Certificate Example with Explanatory Text">
						<artwork><![CDATA[
Subject: CN=Atlantis
Issuer: CN=Atlantis
Validity: from 7/9/2012 3:10:38 AM UTC to 7/9/2013 3:10:37 AM UTC
-----BEGIN CERTIFICATE-----
MIIBmTCCAUegAwIBAgIBKjAJBgUrDgMCHQUAMBMxETAPBgNVBAMTCEF0bGFudGlz
MB4XDTEyMDcwOTAzMTAzOFoXDTEzMDcwOTAzMTAzN1owEzERMA8GA1UEAxMIQXRs
YW50aXMwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAu+BXo+miabDIHHx+yquqzqNh
Ryn/XtkJIIHVcYtHvIX+S1x5ErgMoHehycpoxbErZmVR4GCq1S2diNmRFZCRtQID
AQABo4GJMIGGMAwGA1UdEwEB/wQCMAAwIAYDVR0EAQH/BBYwFDAOMAwGCisGAQQB
gjcCARUDAgeAMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDAzA1BgNVHQEE
LjAsgBA0jOnSSuIHYmnVryHAdywMoRUwEzERMA8GA1UEAxMIQXRsYW50aXOCASow
CQYFKw4DAh0FAANBAKi6HRBaNEL5R0n56nvfclQNaXiDT174uf+lojzA4lhVInc0
ILwpnZ1izL4MlI9eCSHhVQBHEp2uQdXJB+d5Byg=
-----END CERTIFICATE-----]]></artwork></figure>
				</section>
				<section title="File Extension">
					<t>Although textual encodings of PKIX structures can occur
					anywhere, many tools are known to offer an option to output
					this encoding when serializing PKIX structures.
					To promote interoperability and to separate DER encodings
					from textual encodings,
					the extension
					<spanx style="verb" xml:space="preserve">.crt</spanx>
					SHOULD be used for the textual encoding of a certificate.
				  Implementations should be aware that in spite of this recommendation,
				  many tools still default to encode certificates in this textual encoding
				  with the extension <spanx style="verb" xml:space="preserve">.cer</spanx>.</t>
					<t>This section does not disturb the official <xref target="RFC2585">application/pkix-cert
					registration</xref> in any way
					(which states that "each '.cer' file contains exactly one certificate, encoded in DER format"),
					but merely articulates a widespread,
					de facto alternative.</t>
				</section>
			</section>

     <section anchor="crl"
	      title="Textual Encoding of Certificate Revocation Lists">

       <t>Certificate Revocation Lists (CRLs)
			 are encoded using the <spanx style="verb" xml:space="preserve">X509 CRL</spanx> label.
			 The encoded data MUST be a BER (DER strongly preferred; see <xref target="DERapp"/>)
			 encoded ASN.1 <spanx style="vbare" xml:space="preserve">CertificateList</spanx>
       structure as described in Section 5 of <xref
       target="RFC5280"/>.</t>

       <figure anchor="crlexample" title="CRL Example">
	 <artwork>-----BEGIN X509 CRL-----
MIIB9DCCAV8CAQEwCwYJKoZIhvcNAQEFMIIBCDEXMBUGA1UEChMOVmVyaVNpZ24s
IEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdvcmsxRjBEBgNVBAsT
PXd3dy52ZXJpc2lnbi5jb20vcmVwb3NpdG9yeS9SUEEgSW5jb3JwLiBieSBSZWYu
LExJQUIuTFREKGMpOTgxHjAcBgNVBAsTFVBlcnNvbmEgTm90IFZhbGlkYXRlZDEm
MCQGA1UECxMdRGlnaXRhbCBJRCBDbGFzcyAxIC0gTmV0c2NhcGUxGDAWBgNVBAMU
D1NpbW9uIEpvc2Vmc3NvbjEiMCAGCSqGSIb3DQEJARYTc2ltb25Aam9zZWZzc29u
Lm9yZxcNMDYxMjI3MDgwMjM0WhcNMDcwMjA3MDgwMjM1WjAjMCECEC4QNwPfRoWd
elUNpllhhTgXDTA2MTIyNzA4MDIzNFowCwYJKoZIhvcNAQEFA4GBAD0zX+J2hkcc
Nbrq1Dn5IKL8nXLgPGcHv1I/le1MNo9t1ohGQxB5HnFUkRPAY82fR6Epor4aHgVy
b+5y+neKN9Kn2mPF4iiun+a4o26CjJ0pArojCL1p8T0yyi9Xxvyc/ezaZ98HiIyP
c3DGMNR+oUmSjKZ0jIhAYmeLxaPHfQwR
-----END X509 CRL-----</artwork>
       </figure>

       <t>Historically, the label <spanx style="verb" xml:space="preserve">CRL</spanx> has rarely been used. Today, it is
       not common and many popular tools do not understand the
       label. Therefore, this document standardizes <spanx style="verb" xml:space="preserve">X509 CRL</spanx>
			 in order to promote interoperability and backwards-compatibility.
			 Generators conforming to this document MUST generate
       <spanx style="verb" xml:space="preserve">X509 CRL</spanx> labels and MUST NOT generate
			 <spanx style="verb" xml:space="preserve">CRL</spanx> labels.  Parsers
       SHOULD NOT treat <spanx style="verb" xml:space="preserve">CRL</spanx>
			 as equivalent to <spanx style="verb" xml:space="preserve">X509 CRL</spanx>.</t>
     </section>

     <section anchor="crs"
	      title="Textual Encoding of PKCS #10 Certification Request Syntax">

       <t>PKCS #10 Certification Requests are encoded using the
       <spanx style="verb" xml:space="preserve">CERTIFICATE REQUEST</spanx>
       label.

			 The encoded data MUST be a BER (DER strongly preferred; see <xref target="DERapp"/>)
       encoded ASN.1 <spanx style="vbare" xml:space="preserve">CertificationRequest</spanx>
			 structure as described in
       <xref target="RFC2986"/>.</t>

       <figure anchor="pkcs10example" title="PKCS #10 Example">
	 <artwork><![CDATA[
-----BEGIN CERTIFICATE REQUEST-----
MIIBWDCCAQcCAQAwTjELMAkGA1UEBhMCU0UxJzAlBgNVBAoTHlNpbW9uIEpvc2Vm
c3NvbiBEYXRha29uc3VsdCBBQjEWMBQGA1UEAxMNam9zZWZzc29uLm9yZzBOMBAG
ByqGSM49AgEGBSuBBAAhAzoABLLPSkuXY0l66MbxVJ3Mot5FCFuqQfn6dTs+9/CM
EOlSwVej77tj56kj9R/j9Q+LfysX8FO9I5p3oGIwYAYJKoZIhvcNAQkOMVMwUTAY
BgNVHREEETAPgg1qb3NlZnNzb24ub3JnMAwGA1UdEwEB/wQCMAAwDwYDVR0PAQH/
BAUDAwegADAWBgNVHSUBAf8EDDAKBggrBgEFBQcDATAKBggqhkjOPQQDAgM/ADA8
AhxBvfhxPFfbBbsE1NoFmCUczOFApEuQVUw3ZP69AhwWXk3dgSUsKnuwL5g/ftAY
dEQc8B8jAcnuOrfU
-----END CERTIFICATE REQUEST-----]]></artwork>
      </figure>

      <t>The label <spanx style="verb" xml:space="preserve">NEW CERTIFICATE REQUEST</spanx> is also in wide use.
      Generators conforming to this document MUST generate
      <spanx style="verb" xml:space="preserve">CERTIFICATE REQUEST</spanx> labels.
			Parsers MAY treat
			<spanx style="verb" xml:space="preserve">NEW CERTIFICATE REQUEST</spanx>
			as equivalent to <spanx style="verb" xml:space="preserve">CERTIFICATE REQUEST</spanx>.</t>
		</section>

     <section anchor="pkcs7"
	      title="Textual Encoding of PKCS #7 Cryptographic Message Syntax">

       <t>PKCS #7 Cryptographic Message Syntax structures are encoded
       using the <spanx style="verb" xml:space="preserve">PKCS7</spanx> label.
			 The encoded data MUST be a BER-encoded ASN.1 <spanx style="vbare" xml:space="preserve">ContentInfo</spanx> structure as described in <xref
       target="RFC2315"/>.</t>

       <figure anchor="pkcs7example" title="PKCS #7 Example">
	 <artwork><![CDATA[-----BEGIN PKCS7-----
MIHjBgsqhkiG9w0BCRABF6CB0zCB0AIBADFho18CAQCgGwYJKoZIhvcNAQUMMA4E
CLfrI6dr0gUWAgITiDAjBgsqhkiG9w0BCRADCTAUBggqhkiG9w0DBwQIZpECRWtz
u5kEGDCjerXY8odQ7EEEromZJvAurk/j81IrozBSBgkqhkiG9w0BBwEwMwYLKoZI
hvcNAQkQAw8wJDAUBggqhkiG9w0DBwQI0tCBcU09nxEwDAYIKwYBBQUIAQIFAIAQ
OsYGYUFdAH0RNc1p4VbKEAQUM2Xo8PMHBoYdqEcsbTodlCFAZH4=
-----END PKCS7-----]]></artwork>
      </figure>

      <t>The label <spanx style="verb" xml:space="preserve">CERTIFICATE CHAIN</spanx> has been in use to denote a
      degenerate PKCS #7 structure that contains only a list of
      certificates (see Section 9 of <xref target="RFC2315"/>).
			Several modern tools do not support this label.
      Generators MUST NOT generate the <spanx style="verb" xml:space="preserve">CERTIFICATE CHAIN</spanx> label.
      Parsers SHOULD NOT treat <spanx style="verb" xml:space="preserve">CERTIFICATE CHAIN</spanx> as
      equivalent to <spanx style="verb" xml:space="preserve">PKCS7</spanx>.</t>

			<t>PKCS #7 is an old specification that has long been superseded
			by <xref target="RFC5652">CMS</xref>.
			Implementations SHOULD NOT generate PKCS #7 when CMS
			is an alternative.</t>
    </section>

     <section anchor="cms"
	      title="Textual Encoding of Cryptographic Message Syntax">

       <t>Cryptographic Message Syntax structures are encoded using
       the <spanx style="verb" xml:space="preserve">CMS</spanx> label.  The encoded data MUST
       be a BER-encoded ASN.1
       <spanx style="vbare" xml:space="preserve">ContentInfo</spanx>
       structure as described in <xref target="RFC5652"/>.</t>

       <figure anchor="cmsexample" title="CMS Example">
	 <artwork><![CDATA[-----BEGIN CMS-----
MIGDBgsqhkiG9w0BCRABCaB0MHICAQAwDQYLKoZIhvcNAQkQAwgwXgYJKoZIhvcN
AQcBoFEET3icc87PK0nNK9ENqSxItVIoSa0o0S/ISczMs1ZIzkgsKk4tsQ0N1nUM
dvb05OXi5XLPLEtViMwvLVLwSE0sKlFIVHAqSk3MBkkBAJv0Fx0=
-----END CMS-----]]></artwork>
      </figure>
      <t>CMS is the IETF successor to PKCS #7. Section 1.1.1
			of <xref target="RFC5652" /> describes the changes since PKCS #7 v1.5. Implementations
			SHOULD generate CMS when it is an alternative, promoting interoperability
			and forwards-compatibility.</t>
    </section>

		<section anchor="pkcs8"
			 title="One Asymmetric Key and the Textual Encoding of PKCS #8 Private Key Info">

			<t>Unencrypted PKCS #8 Private Key Information Syntax structures
				(PrivateKeyInfo),
				renamed to Asymmetric Key Packages
				(OneAsymmetricKey),
				are encoded using the <spanx style="verb" xml:space="preserve">PRIVATE KEY</spanx> label.
				The encoded data MUST be a BER (DER preferred; see <xref target="DERapp"/>)
				encoded ASN.1 <spanx style="vbare" xml:space="preserve">PrivateKeyInfo</spanx> structure as described in
				<xref target="RFC5208">PKCS #8</xref>,
				or a <spanx style="vbare" xml:space="preserve">OneAsymmetricKey</spanx> structure as described in <xref
       target="RFC5958"/>. The two are semantically identical and can be distinguished
				by version number.
			</t>

			<figure anchor="pkcs8example" title="PKCS #8 PrivateKeyInfo (OneAsymmetricKey) Example">
				<artwork><![CDATA[-----BEGIN PRIVATE KEY-----
MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgVcB/UNPxalR9zDYAjQIf
jojUDiQuGnSJrFEEzZPT/92hRANCAASc7UJtgnF/abqWM60T3XNJEzBv5ez9TdwK
H0M6xpM2q+53wmsN/eYLdgtjgBd3DBmHtPilCkiFICXyaA8z9LkJ
-----END PRIVATE KEY-----]]></artwork>
			</figure>
		</section>
		<section anchor="pkcs8enc"
			 title="Textual Encoding of PKCS #8 Encrypted Private Key Info">
			<t>Encrypted PKCS #8 Private Key Information Syntax structures
				(EncryptedPrivateKeyInfo),
				called the same in <xref target="RFC5958" />,
				are encoded using the <spanx style="verb" xml:space="preserve">ENCRYPTED PRIVATE KEY</spanx> label.
				The encoded data MUST be a BER (DER preferred; see <xref target="DERapp"/>)
				encoded ASN.1 <spanx style="vbare" xml:space="preserve">EncryptedPrivateKeyInfo</spanx> structure as described in
				<xref target="RFC5208">PKCS #8</xref>
				and <xref target="RFC5958"/>.
			</t>

			<figure anchor="pkcs8encexample" title="PKCS #8 EncryptedPrivateKeyInfo Example">
				<artwork><![CDATA[-----BEGIN ENCRYPTED PRIVATE KEY-----
MIHNMEAGCSqGSIb3DQEFDTAzMBsGCSqGSIb3DQEFDDAOBAghhICA6T/51QICCAAw
FAYIKoZIhvcNAwcECBCxDgvI59i9BIGIY3CAqlMNBgaSI5QiiWVNJ3IpfLnEiEsW
Z0JIoHyRmKK/+cr9QPLnzxImm0TR9s4JrG3CilzTWvb0jIvbG3hu0zyFPraoMkap
8eRzWsIvC5SVel+CSjoS2mVS87cyjlD+txrmrXOVYDE+eTgMLbrLmsWh3QkCTRtF
QC7k0NNzUHTV9yGDwfqMbw==
-----END ENCRYPTED PRIVATE KEY-----]]></artwork>
			</figure>
		</section>

		<section anchor="attrcert"
	      title="Textual Encoding of Attribute Certificates">

       <t>Attribute certificates are encoded using the
			 <spanx style="verb" xml:space="preserve">ATTRIBUTE CERTIFICATE</spanx>
			 label.  The encoded data MUST be a BER (DER strongly preferred; see <xref target="DERapp"/>) encoded
       ASN.1 <spanx style="vbare" xml:space="preserve">AttributeCertificate</spanx>
			 structure as described in <xref
       target="RFC5755"/>.</t>

       <figure anchor="attrcertexample" title="Attribute Certificate Example">
	 <artwork><![CDATA[-----BEGIN ATTRIBUTE CERTIFICATE-----
MIICKzCCAZQCAQEwgZeggZQwgYmkgYYwgYMxCzAJBgNVBAYTAlVTMREwDwYDVQQI
DAhOZXcgWW9yazEUMBIGA1UEBwwLU3RvbnkgQnJvb2sxDzANBgNVBAoMBkNTRTU5
MjE6MDgGA1UEAwwxU2NvdHQgU3RhbGxlci9lbWFpbEFkZHJlc3M9c3N0YWxsZXJA
aWMuc3VueXNiLmVkdQIGARWrgUUSoIGMMIGJpIGGMIGDMQswCQYDVQQGEwJVUzER
MA8GA1UECAwITmV3IFlvcmsxFDASBgNVBAcMC1N0b255IEJyb29rMQ8wDQYDVQQK
DAZDU0U1OTIxOjA4BgNVBAMMMVNjb3R0IFN0YWxsZXIvZW1haWxBZGRyZXNzPXNz
dGFsbGVyQGljLnN1bnlzYi5lZHUwDQYJKoZIhvcNAQEFBQACBgEVq4FFSjAiGA8z
OTA3MDIwMTA1MDAwMFoYDzM5MTEwMTMxMDUwMDAwWjArMCkGA1UYSDEiMCCGHmh0
dHA6Ly9pZGVyYXNobi5vcmcvaW5kZXguaHRtbDANBgkqhkiG9w0BAQUFAAOBgQAV
M9axFPXXozEFcer06bj9MCBBCQLtAM7ZXcZjcxyva7xCBDmtZXPYUluHf5OcWPJz
5XPus/xS9wBgtlM3fldIKNyNO8RsMp6Ocx+PGlICc7zpZiGmCYLl64lAEGPO/bsw
Smluak1aZIttePeTAHeJJs8izNJ5aR3Wcd3A5gLztQ==
-----END ATTRIBUTE CERTIFICATE-----]]></artwork>
       </figure>

    </section>
		<section anchor="spki"
	      title="Textual Encoding of Subject Public Key Info">

       <t>Public keys are encoded using the <spanx style="verb" xml:space="preserve">PUBLIC KEY</spanx> label.
			 The encoded data MUST be a BER (DER preferred; see <xref target="DERapp"/>) encoded
       ASN.1 <spanx style="vbare" xml:space="preserve">SubjectPublicKeyInfo</spanx> structure as described in
			 Section 4.1.2.7 of <xref target="RFC5280"/>.</t>

       <figure anchor="spkiexample" title="Subject Public Key Info Example">
	 <artwork><![CDATA[-----BEGIN PUBLIC KEY-----
MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEn1LlwLN/KBYQRVH6HfIMTzfEqJOVztLe
kLchp2hi78cCaMY81FBlYs8J9l7krc+M4aBeCGYFjba+hiXttJWPL7ydlE+5UG4U
Nkn3Eos8EiZByi9DVsyfy9eejh+8AXgp
-----END PUBLIC KEY-----]]></artwork>
       </figure>

    </section>

    <section anchor="security"
	     title="Security Considerations">

      <t>Data in this format often originates from untrusted
      sources, thus parsers must be prepared to handle unexpected data
      without causing security vulnerabilities.</t>

      <t>Implementers building implementations that rely on canonical
      representation or the ability to fingerprint a particular data
      object need to understand that this
			document does not define canonical encodings.
			The first ambiguity is introduced by permitting the
			text-encoded representation
			instead of the binary BER or DER encodings, but further
			ambiguities arise when multiple labels
      are treated as similar.
			Variations of whitespace
      and non-base64 alphabetic characters can create further
      ambiguities. Data encoding
      ambiguities also create opportunities for side channels.
			If canonical encodings
			are desired, the encoded structure must be decoded and processed
			into a canonical form (namely, DER encoding).
			</t>

    </section>

  </middle>

  <back>

    <references title="Normative References">
      &rfc2119;
      &rfc2315;
      &rfc2986;
      &rfc4648;
      &rfc5280;
      &RFC5234;
      &RFC5652;
      &rfc5755;
      &RFC5958;
			<reference anchor="X.690">
				<front>
					<title>
					Information Technology - ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER)
					</title>
					<author>
					<organization>International Telecommunications Union</organization>
					</author>
					<date month="November" year="2008"/>
				</front>
				<seriesInfo name="ITU-T" value="Recommendation X.690"/>
				<seriesInfo name="ISO/IEC" value="8825-1:2008"/>
			</reference>
      <!-- &x690; -->
    </references>

    <references title="Informative References">
			&RFC0934;
      &rfc1421;

			&RFC2585;
      &rfc4716;
      &rfc4880;
			&RFC5208;
			&RFC7292;


      <reference anchor="P7v1.6"
			 target="http://www.emc.com/emc-plus/rsa-labs/standards-initiatives/pkcs-7-cryptographic-message-syntax-standar.htm">
				<front>
					<title>Extensions and Revisions to PKCS #7 (Version 1.6 Bulletin)</title>
					<author initials="B." surname="Kaliski" fullname="Burton S. Kaliski Jr., Ph.D."/>
					<author initials="K." surname="Kingdon" fullname="Kevin W. Kingdon"/>
					<date month="May" year="1997" />
				</front>
      </reference>

      <reference anchor="X.509SG"
			 target="http://www.cs.auckland.ac.nz/~pgut001/pubs/x509guide.txt">
				<front>
					<title>X.509 Style Guide</title>
					<author initials="P." surname="Gutmann" fullname="P. Gutmann"/>
					<date month="October" year="2000" />
				</front>
      </reference>

    </references>

    <section title="Non-conforming Examples">

      <t>This appendix contains examples for the non-recommended label
	variants described earlier in this document.  As discussed
	earlier, supporting these is not required and is sometimes
	discouraged.  Still, they can be useful for interoperability
	testing and for easy reference.</t>

      <figure anchor="certexample2"
	      title="Non-standard 'X509' Certificate Example">
	<artwork>-----BEGIN X509 CERTIFICATE-----
MIIBHDCBxaADAgECAgIcxzAJBgcqhkjOPQQBMBAxDjAMBgNVBAMUBVBLSVghMB4X
DTE0MDkxNDA2MTU1MFoXDTI0MDkxNDA2MTU1MFowEDEOMAwGA1UEAxQFUEtJWCEw
WTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATwoQSr863QrR0PoRIYQ96H7WykDePH
Wa0eVAE24bth43wCNc+U5aZ761dhGhSSJkVWRgVH5+prLIr+nzfIq+X4oxAwDjAM
BgNVHRMBAf8EAjAAMAkGByqGSM49BAEDRwAwRAIfMdKS5F63lMnWVhi7uaKJzKCs
NnY/OKgBex6MIEAv2AIhAI2GdvfL+mGvhyPZE+JxRxWChmggb5/9eHdUcmW/jkOH
-----END X509 CERTIFICATE-----</artwork>
      </figure>

      <figure anchor="certexample3"
	      title="Non-standard 'X.509' Certificate Example">
	<artwork>-----BEGIN X.509 CERTIFICATE-----
MIIBHDCBxaADAgECAgIcxzAJBgcqhkjOPQQBMBAxDjAMBgNVBAMUBVBLSVghMB4X
DTE0MDkxNDA2MTU1MFoXDTI0MDkxNDA2MTU1MFowEDEOMAwGA1UEAxQFUEtJWCEw
WTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATwoQSr863QrR0PoRIYQ96H7WykDePH
Wa0eVAE24bth43wCNc+U5aZ761dhGhSSJkVWRgVH5+prLIr+nzfIq+X4oxAwDjAM
BgNVHRMBAf8EAjAAMAkGByqGSM49BAEDRwAwRAIfMdKS5F63lMnWVhi7uaKJzKCs
NnY/OKgBex6MIEAv2AIhAI2GdvfL+mGvhyPZE+JxRxWChmggb5/9eHdUcmW/jkOH
-----END X.509 CERTIFICATE-----</artwork>
      </figure>

      <figure anchor="pkcs10example2"
	      title="Non-standard 'NEW' PKCS #10 Example">
	<artwork>-----BEGIN NEW CERTIFICATE REQUEST-----
MIIBWDCCAQcCAQAwTjELMAkGA1UEBhMCU0UxJzAlBgNVBAoTHlNpbW9uIEpvc2Vm
c3NvbiBEYXRha29uc3VsdCBBQjEWMBQGA1UEAxMNam9zZWZzc29uLm9yZzBOMBAG
ByqGSM49AgEGBSuBBAAhAzoABLLPSkuXY0l66MbxVJ3Mot5FCFuqQfn6dTs+9/CM
EOlSwVej77tj56kj9R/j9Q+LfysX8FO9I5p3oGIwYAYJKoZIhvcNAQkOMVMwUTAY
BgNVHREEETAPgg1qb3NlZnNzb24ub3JnMAwGA1UdEwEB/wQCMAAwDwYDVR0PAQH/
BAUDAwegADAWBgNVHSUBAf8EDDAKBggrBgEFBQcDATAKBggqhkjOPQQDAgM/ADA8
AhxBvfhxPFfbBbsE1NoFmCUczOFApEuQVUw3ZP69AhwWXk3dgSUsKnuwL5g/ftAY
dEQc8B8jAcnuOrfU
-----END NEW CERTIFICATE REQUEST-----</artwork>
      </figure>

      <figure anchor="pkcs7example2"
	      title="Non-standard 'CERTIFICATE CHAIN' Example">
	<artwork>-----BEGIN CERTIFICATE CHAIN-----
MIHjBgsqhkiG9w0BCRABF6CB0zCB0AIBADFho18CAQCgGwYJKoZIhvcNAQUMMA4E
CLfrI6dr0gUWAgITiDAjBgsqhkiG9w0BCRADCTAUBggqhkiG9w0DBwQIZpECRWtz
u5kEGDCjerXY8odQ7EEEromZJvAurk/j81IrozBSBgkqhkiG9w0BBwEwMwYLKoZI
hvcNAQkQAw8wJDAUBggqhkiG9w0DBwQI0tCBcU09nxEwDAYIKwYBBQUIAQIFAIAQ
OsYGYUFdAH0RNc1p4VbKEAQUM2Xo8PMHBoYdqEcsbTodlCFAZH4=
-----END CERTIFICATE CHAIN-----</artwork>
      </figure>

    </section>
		<section anchor="DERapp" title="DER Expectations">
		<t>This appendix is informative. Consult the respective standards
		 for the normative rules.</t>
		<t>DER is a restricted profile of BER <xref target="X.690"/>;
		thus, all DER encodings of data values are BER encodings, but just one
		of the BER encodings is the DER encoding for a data value.
		Canonical encoding matters when performing
		cryptographic operations; additionally,
		canonical encoding has certain efficiency advantages for parsers.
		There are three principal reasons to encode with DER:
		<list style="numbers">
			<t>A digital signature is (supposed to be) computed over
			 the DER encoding of the semantic content,
			 so providing anything other than
			 the DER encoding is senseless. (In practice, an implementer
			 might choose to have an implementation parse and
			 digest the data as is,
			 but this practice amounts to guesswork.)</t>
			<t>In practice, cryptographic hashes are computed over the DER
			 encoding for identification.</t>
			<t>In practice, the content is small. DER always encodes
			data values in definite-length form (where the length is stated
			at the beginning of the encoding); thus, a parser can anticipate
			memory or resource usage up front.</t>
		</list></t>
		<t><xref target="why-use-DER" /> matches the structures in this document
		 with the particular reasons for DER encoding:
		 <figure anchor="why-use-DER" title="Guide for DER Encoding">
		 <artwork><![CDATA[
                 Sec. Label                  Reasons
                 ----+----------------------+-------
                   5  CERTIFICATE            1  2 ~3
                   6  X509 CRL               1
                   7  CERTIFICATE REQUEST    1    ~3
                   8  PKCS7                  *
                   9  CMS                    *
                  10  PRIVATE KEY                  3
                  11  ENCRYPTED PRIVATE KEY        3
                  12  ATTRIBUTE CERTIFICATE  1    ~3
                  13  PUBLIC KEY                2  3

                  Figure 20: Guide for DER Encoding

* Cryptographic Message Syntax is designed for content of any length;
  indefinite-length encoding enables one-pass processing (streaming)
  when generating the encoding.  Only certain parts -- namely, signed 
  and authenticated attributes -- need to be DER encoded.

~ Although not always "small", these encoded structures should not be
  particularly "large" (e.g., more than 16 kilobytes).  The parser
  ought to be informed of large things up front in any event; this is
  yet another reason to DER encode these things in the first place.
]]></artwork></figure></t>

		</section>

    <section anchor="ack"
	     title="Acknowledgements" numbered="no">

      <t>Peter Gutmann suggested to document labels for Attribute
      Certificates and PKCS #7 messages, and to add examples for the
      non-standard variants. Dr. Stephen Henson suggested distinguishing
			when BER versus DER is appropriate or necessary.</t>

    </section>

  </back>
</rfc>
