Skip to content
RFC Editor - Official home of RFCs

RFC 5652: STD 70: Cryptographic Message Syntax (CMS)

  • R. Housley
Internet Standard
This RFC was updated, see
Network Working Group                                         R. Housley
Request for Comments: 5652                                Vigil Security
Obsoletes:                                            September 2009
Category: Standards Track


                   Cryptographic Message Syntax (CMS)

Abstract

   This document describes the Cryptographic Message Syntax (CMS).  This
   syntax is used to digitally sign, digest, authenticate, or encrypt
   arbitrary message content.

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 and License Notice

   Copyright (c) 2009 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents
   (http://trustee.ietf.org/license-info) in effect on the date of
   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must
   include Simplified BSD License text as described in Section 4.e of
   the Trust Legal Provisions and are provided without warranty as
   described in the BSD License.

   This document may contain material from IETF Documents or IETF
   Contributions published or made publicly available before November
   10, 2008.  The person(s) controlling the copyright in some of this
   material may not have granted the IETF Trust the right to allow
   modifications of such material outside the IETF Standards Process.
   Without obtaining an adequate license from the person(s) controlling
   the copyright in such materials, this document may not be modified
   outside the IETF Standards Process, and derivative works of it may
   not be created outside the IETF Standards Process, except to format
   it for publication as an RFC or to translate it into languages other
   than English.



Housley                     Standards Track                     [Page 1]


              Cryptographic Message Syntax        September 2009


Table of Contents

   1. Introduction ....................................................3
      1.1. Evolution of the CMS .......................................4
           1.1.1. Changes Since PKCS #7 Version 1.5 ...................4
           1.1.2. Changes Since  ..............................4
           1.1.3. Changes Since  ..............................5
           1.1.4. Changes Since  ..............................5
      1.2. Terminology ................................................5
      1.3. Version Numbers ............................................6
   2. General Overview ................................................6
   3. General Syntax ..................................................7
   4. Data Content Type ...............................................7
   5. Signed-data Content Type ........................................8
      5.1. SignedData Type ............................................9
      5.2. EncapsulatedContentInfo Type ..............................11
           5.2.1. Compatibility with PKCS #7 .........................12
      5.3. SignerInfo Type ...........................................13
      5.4. Message Digest Calculation Process ........................16
      5.5. Signature Generation Process ..............................16
      5.6. Signature Verification Process ............................17
   6. Enveloped-Data Content Type ....................................17
      6.1. EnvelopedData Type ........................................18
      6.2. RecipientInfo Type ........................................21
           6.2.1. KeyTransRecipientInfo Type .........................22
           6.2.2. KeyAgreeRecipientInfo Type .........................23
           6.2.3. KEKRecipientInfo Type ..............................25
           6.2.4. PasswordRecipientInfo Type .........................26
           6.2.5. OtherRecipientInfo Type ............................27
      6.3. Content-encryption Process ................................27
      6.4. Key-Encryption Process ....................................28
   7. Digested-Data Content Type .....................................28
   8. Encrypted-Data Content Type ....................................29
   9. Authenticated-Data Content Type ................................30
      9.1. AuthenticatedData Type ....................................31
      9.2. MAC Generation ............................................33
      9.3. MAC Verification ..........................................34
   10. Useful Types ..................................................34
      10.1. Algorithm Identifier Types ...............................35
           10.1.1. DigestAlgorithmIdentifier .........................35
           10.1.2. SignatureAlgorithmIdentifier ......................35
           10.1.3. KeyEncryptionAlgorithmIdentifier ..................35
           10.1.4. ContentEncryptionAlgorithmIdentifier ..............36
           10.1.5. MessageAuthenticationCodeAlgorithm ................36
           10.1.6. KeyDerivationAlgorithmIdentifier ..................36
      10.2. Other Useful Types .......................................36
           10.2.1. RevocationInfoChoices .............................36
           10.2.2. CertificateChoices ................................37



Housley                     Standards Track                     [Page 2]


              Cryptographic Message Syntax        September 2009


           10.2.3. CertificateSet ....................................38
           10.2.4. IssuerAndSerialNumber .............................38
           10.2.5. CMSVersion ........................................39
           10.2.6. UserKeyingMaterial ................................39
           10.2.7. OtherKeyAttribute .................................39
   11. Useful Attributes .............................................39
      11.1. Content Type .............................................40
      11.2. Message Digest ...........................................40
      11.3. Signing Time .............................................41
      11.4. Countersignature .........................................42
   12. ASN.1 Modules .................................................43
      12.1. CMS ASN.1 Module .........................................44
      12.2. Version 1 Attribute Certificate ASN.1 Module .............51
   13. References ....................................................52
      13.1. Normative References .....................................52
      13.2. Informative References ...................................53
   14. Security Considerations .......................................54
   15. Acknowledgments ...............................................56

1.  Introduction

   This document describes the Cryptographic Message Syntax (CMS).  This
   syntax is used to digitally sign, digest, authenticate, or encrypt
   arbitrary message content.

   The CMS describes an encapsulation syntax for data protection.  It
   supports digital signatures and encryption.  The syntax allows
   multiple encapsulations; one encapsulation envelope can be nested
   inside another.  Likewise, one party can digitally sign some
   previously encapsulated data.  It also allows arbitrary attributes,
   such as signing time, to be signed along with the message content,
   and it provides for other attributes such as countersignatures to be
   associated with a signature.

   The CMS can support a variety of architectures for certificate-based
   key management, such as the one defined by the PKIX (Public Key
   Infrastructure using X.509) working group [PROFILE].

   The CMS values are generated using ASN.1 [X.208-88], using BER-
   encoding (Basic Encoding Rules) [X.209-88].  Values are typically
   represented as octet strings.  While many systems are capable of
   transmitting arbitrary octet strings reliably, it is well known that
   many electronic mail systems are not.  This document does not address
   mechanisms for encoding octet strings for reliable transmission in
   such environments.






Housley                     Standards Track                     [Page 3]


              Cryptographic Message Syntax        September 2009


1.1.  Evolution of the CMS

   The CMS is derived from PKCS #7 version 1.5, which is documented in
    [PKCS#7].  PKCS #7 version 1.5 was developed outside of the
   IETF; it was originally published as an RSA Laboratories Technical
   Note in November 1993.  Since that time, the IETF has taken
   responsibility for the development and maintenance of the CMS.
   Today, several important IETF Standards-Track protocols make use of
   the CMS.

   This section describes that changes that the IETF has made to the CMS
   in each of the published versions.

1.1.1.  Changes Since PKCS #7 Version 1.5

    [CMS1] was the first version of the CMS on the IETF
   Standards Track.  Wherever possible, backward compatibility with PKCS
   #7 version 1.5 is preserved; however, changes were made to
   accommodate version 1 attribute certificate transfer and to support
   algorithm-independent key management.  PKCS #7 version 1.5 included
   support only for key transport.   adds support for key
   agreement and previously distributed symmetric key-encryption key
   techniques.

1.1.2.  Changes Since 

    [CMS2] obsoletes  [CMS1] and  [PWRI].
   Password-based key management is included in the CMS specification,
   and an extension mechanism to support new key management schemes
   without further changes to the CMS is specified.  Backward
   compatibility with  and  is preserved; however,
   version 2 attribute certificate transfer is added, and the use of
   version 1 attribute certificates is deprecated.

   Secure/Multipurpose Internet Mail Extensions (S/MIME) v2 signatures
   [MSG2], which are based on PKCS #7 version 1.5, are compatible with
   S/MIME v3 signatures [MSG3]and S/MIME v3.1 signatures [MSG3.1].
   However, there are some subtle compatibility issues with signatures
   based on PKCS #7 version 1.5.  These issues are discussed in Section
   5.2.1.  These issues remain with the current version of the CMS.

   Specific cryptographic algorithms are not discussed in this document,
   but they were discussed in .  The discussion of specific
   cryptographic algorithms has been moved to a separate document
   [CMSALG].  Separation of the protocol and algorithm specifications
   allows the IETF to update each document independently.  This
   specification does not require the implementation of any particular




Housley                     Standards Track                     [Page 4]


              Cryptographic Message Syntax        September 2009


   algorithms.  Rather, protocols that rely on the CMS are expected to
   choose appropriate algorithms for their environment.  The algorithms
   may be selected from [CMSALG] or elsewhere.

1.1.3.  Changes Since 

    [CMS3] obsoletes  [CMS2].  As discussed in the
   previous section,  introduced an extension mechanism to
   support new key management schemes without further changes to the
   CMS.   introduces a similar extension mechanism to support
   additional certificate formats and revocation status information
   formats without further changes to the CMS.  These extensions are
   primarily documented in Sections 10.2.1 and 10.2.2.  Backward
   compatibility with earlier versions of the CMS is preserved.

   The use of version numbers is described in Section 1.3.

   Since the publication of , a few errata have been noted.
   These errata are posted on the RFC Editor web site.  These errors
   have been corrected in this document.

   The text in Section 11.4 that describes the counter signature
   unsigned attribute is clarified.  Hopefully, the revised text is
   clearer about the portion of the SignerInfo signature that is covered
   by a countersignature.

1.1.4.  Changes Since 

   This document obsoletes  [CMS3].  The primary reason for the
   publication of this document is to advance the CMS along the
   standards maturity ladder.

   This document includes the clarifications that were originally
   published in  [CMSMSIG] regarding the proper handling of the
   SignedData protected content type when more than one digital
   signature is present.

   Since the publication of , a few errata have been noted.
   These errata are posted on the RFC Editor web site.  These errors
   have been corrected in this document.

1.2.  Terminology

   In this document, the key words MUST, MUST NOT, REQUIRED, SHOULD,
   SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL are to be interpreted as
   described in [STDWORDS].





Housley                     Standards Track                     [Page 5]


              Cryptographic Message Syntax        September 2009


1.3.  Version Numbers

   Each of the major data structures includes a version number as the
   first item in the data structure.  The version numbers are intended
   to avoid ASN.1 decode errors.  Some implementations do not check the
   version number prior to attempting a decode, and if a decode error
   occurs, then the version number is checked as part of the error
   handling routine.  This is a reasonable approach; it places error
   processing outside of the fast path.  This approach is also forgiving
   when an incorrect version number is used by the sender.

   Most of the initial version numbers were assigned in PKCS #7 version
   1.5.  Others were assigned when the structure was initially created.
   Whenever a structure is updated, a higher version number is assigned.
   However, to ensure maximum interoperability, the higher version
   number is only used when the new syntax feature is employed.  That
   is, the lowest version number that supports the generated syntax is
   used.

2.  General Overview

   The CMS is general enough to support many different content types.
   This document defines one protection content, ContentInfo.
   ContentInfo encapsulates a single identified content type, and the
   identified type may provide further encapsulation.  This document
   defines six content types: data, signed-data, enveloped-data,
   digested-data, encrypted-data, and authenticated-data.  Additional
   content types can be defined outside this document.

   An implementation that conforms to this specification MUST implement
   the protection content, ContentInfo, and MUST implement the data,
   signed-data, and enveloped-data content types.  The other content
   types MAY be implemented.

   As a general design philosophy, each content type permits single pass
   processing using indefinite-length Basic Encoding Rules (BER)
   encoding.  Single-pass operation is especially helpful if content is
   large, stored on tapes, or is "piped" from another process.  Single-
   pass operation has one significant drawback: it is difficult to
   perform encode operations using the Distinguished Encoding Rules
   (DER) [X.509-88] encoding in a single pass since the lengths of the
   various components may not be known in advance.  However, signed
   attributes within the signed-data content type and authenticated
   attributes within the authenticated-data content type need to be
   transmitted in DER form to ensure that recipients can verify a
   content that contains one or more unrecognized attributes.  Signed
   attributes and authenticated attributes are the only data types used
   in the CMS that require DER encoding.



Housley                     Standards Track                     [Page 6]


              Cryptographic Message Syntax        September 2009


3.  General Syntax

   The following object identifier identifies the content information
   type:

      id-ct-contentInfo OBJECT IDENTIFIER ::= { iso(1) member-body(2)
         us(840) rsadsi(113549) pkcs(1) pkcs9(9) smime(16) ct(1) 6 }

   The CMS associates a content type identifier with a content.  The
   syntax MUST have ASN.1 type ContentInfo:

      ContentInfo ::= SEQUENCE {
        contentType ContentType,
        content [0] EXPLICIT ANY DEFINED BY contentType }

      ContentType ::= OBJECT IDENTIFIER

   The fields of ContentInfo have the following meanings:

      contentType indicates the type of the associated content.  It is
      an object identifier; it is a unique string of integers assigned
      by an authority that defines the content type.

      content is the associated content.  The type of content can be
      determined uniquely by contentType.  Content types for data,
      signed-data, enveloped-data, digested-data, encrypted-data, and
      authenticated-data are defined in this document.  If additional
      content types are defined in other documents, the ASN.1 type
      defined SHOULD NOT be a CHOICE type.

4.  Data Content Type

   The following object identifier identifies the data content type:

      id-data OBJECT IDENTIFIER ::= { iso(1) member-body(2)
         us(840) rsadsi(113549) pkcs(1) pkcs7(7) 1 }

   The data content type is intended to refer to arbitrary octet
   strings, such as ASCII text files; the interpretation is left to the
   application.  Such strings need not have any internal structure
   (although they could have their own ASN.1 definition or other
   structure).

   S/MIME uses id-data to identify MIME-encoded content.  The use of
   this content identifier is specified in  for S/MIME v2
   [MSG2],  for S/MIME v3 [MSG3], and  for S/MIME v3.1
   [MSG3.1].




Housley                     Standards Track                     [Page 7]


              Cryptographic Message Syntax        September 2009


   The data content type is generally encapsulated in the signed-data,
   enveloped-data, digested-data, encrypted-data, or authenticated-data
   content type.

5.  Signed-data Content Type

   The signed-data content type consists of a content of any type and
   zero or more signature values.  Any number of signers in parallel can
   sign any type of content.

   The typical application of the signed-data content type represents
   one signer's digital signature on content of the data content type.
   Another typical application disseminates certificates and certificate
   revocation lists (CRLs).

   The process by which signed-data is constructed involves the
   following steps:

   1.  For each signer, a message digest, or hash value, is computed on
       the content with a signer-specific message-digest algorithm.  If
       the signer is signing any information other than the content, the
       message digest of the content and the other information are
       digested with the signer's message digest algorithm (see Section
       5.4), and the result becomes the "message digest."

   2.  For each signer, the message digest is digitally signed using the
       signer's private key.

   3.  For each signer, the signature value and other signer-specific
       information are collected into a SignerInfo value, as defined in
       Section 5.3.  Certificates and CRLs for each signer, and those
       not corresponding to any signer, are collected in this step.

   4.  The message digest algorithms for all the signers and the
       SignerInfo values for all the signers are collected together with
       the content into a SignedData value, as defined in Section 5.1.

   A recipient independently computes the message digest.  This message
   digest and the signer's public key are used to verify the signature
   value.  The signer's public key is referenced in one of two ways.  It
   can be referenced by an issuer distinguished name along with an
   issuer-specific serial number to uniquely identify the certificate
   that contains the public key.  Alternatively, it can be referenced by
   a subject key identifier, which accommodates both certified and
   uncertified public keys.  While not required, the signer's
   certificate can be included in the SignedData certificates field.





Housley                     Standards Track                     [Page 8]


              Cryptographic Message Syntax        September 2009


   When more than one signature is present, the successful validation of
   one signature associated with a given signer is usually treated as a
   successful signature by that signer.  However, there are some
   application environments where other rules are needed.  An
   application that employs a rule other than one valid signature for
   each signer must specify those rules.  Also, where simple matching of
   the signer identifier is not sufficient to determine whether the
   signatures were generated by the same signer, the application
   specification must describe how to determine which signatures were
   generated by the same signer.  Support of different communities of
   recipients is the primary reason that signers choose to include more
   than one signature.  For example, the signed-data content type might
   include signatures generated with the RSA signature algorithm and
   with the Elliptic Curve Digital Signature Algorithm (ECDSA) signature
   algorithm.  This allows recipients to verify the signature associated
   with one algorithm or the other.

   This section is divided into six parts.  The first part describes the
   top-level type SignedData, the second part describes
   EncapsulatedContentInfo, the third part describes the per-signer
   information type SignerInfo, and the fourth, fifth, and sixth parts
   describe the message digest calculation, signature generation, and
   signature verification processes, respectively.

5.1.  SignedData Type

   The following object identifier identifies the signed-data content
   type:

      id-signedData OBJECT IDENTIFIER ::= { iso(1) member-body(2)
         us(840) rsadsi(113549) pkcs(1) pkcs7(7) 2 }

   The signed-data content type shall have ASN.1 type SignedData:

      SignedData ::= SEQUENCE {
        version CMSVersion,
        digestAlgorithms DigestAlgorithmIdentifiers,
        encapContentInfo EncapsulatedContentInfo,
        certificates [0] IMPLICIT CertificateSet OPTIONAL,
        crls [1] IMPLICIT RevocationInfoChoices OPTIONAL,
        signerInfos SignerInfos }

      DigestAlgorithmIdentifiers ::= SET OF DigestAlgorithmIdentifier

      SignerInfos ::= SET OF SignerInfo






Housley                     Standards Track                     [Page 9]


              Cryptographic Message Syntax        September 2009


   The fields of type SignedData have the following meanings:

      version is the syntax version number.  The appropriate value
      depends on certificates, eContentType, and SignerInfo.  The
      version MUST be assigned as follows:

         IF ((certificates is present) AND
            (any certificates with a type of other are present)) OR
            ((crls is present) AND
            (any crls with a type of other are present))
         THEN version MUST be 5
         ELSE
            IF (certificates is present) AND
               (any version 2 attribute certificates are present)
            THEN version MUST be 4
            ELSE
               IF ((certificates is present) AND
                  (any version 1 attribute certificates are present)) OR
                  (any SignerInfo structures are version 3) OR
                  (encapContentInfo eContentType is other than id-data)
               THEN version MUST be 3
               ELSE version MUST be 1

      digestAlgorithms is a collection of message digest algorithm
      identifiers.  There MAY be any number of elements in the
      collection, including zero.  Each element identifies the message
      digest algorithm, along with any associated parameters, used by
      one or more signer.  The collection is intended to list the
      message digest algorithms employed by all of the signers, in any
      order, to facilitate one-pass signature verification.
      Implementations MAY fail to validate signatures that use a digest
      algorithm that is not included in this set.  The message digesting
      process is described in Section 5.4.

      encapContentInfo is the signed content, consisting of a content
      type identifier and the content itself.  Details of the
      EncapsulatedContentInfo type are discussed in Section 5.2.

      certificates is a collection of certificates.  It is intended that
      the set of certificates be sufficient to contain certification
      paths from a recognized "root" or "top-level certification
      authority" to all of the signers in the signerInfos field.  There
      may be more certificates than necessary, and there may be
      certificates sufficient to contain certification paths from two or
      more independent top-level certification authorities.  There may
      also be fewer certificates than necessary, if it is expected that
      recipients have an alternate means of obtaining necessary




Housley                     Standards Track                    [Page 10]


              Cryptographic Message Syntax        September 2009


      certificates (e.g., from a previous set of certificates).  The
      signer's certificate MAY be included.  The use of version 1
      attribute certificates is strongly discouraged.

      crls is a collection of revocation status information.  It is
      intended that the collection contain information sufficient to
      determine whether the certificates in the certificates field are
      valid, but such correspondence is not necessary.  Certificate
      revocation lists (CRLs) are the primary source of revocation
      status information.  There MAY be more CRLs than necessary, and
      there MAY also be fewer CRLs than necessary.

      signerInfos is a collection of per-signer information.  There MAY
      be any number of elements in the collection, including zero.  When
      the collection represents more than one signature, the successful
      validation of one of signature from a given signer ought to be
      treated as a successful signature by that signer.  However, there
      are some application environments where other rules are needed.
      The details of the SignerInfo type are discussed in Section 5.3.
      Since each signer can employ a different digital signature
      technique, and future specifications could update the syntax, all
      implementations MUST gracefully handle unimplemented versions of
      SignerInfo.  Further, since all implementations will not support
      every possible signature algorithm, all implementations MUST
      gracefully handle unimplemented signature algorithms when they are
      encountered.

5.2.  EncapsulatedContentInfo Type

   The content is represented in the type EncapsulatedContentInfo:

      EncapsulatedContentInfo ::= SEQUENCE {
        eContentType ContentType,
        eContent [0] EXPLICIT OCTET STRING OPTIONAL }

      ContentType ::= OBJECT IDENTIFIER

   The fields of type EncapsulatedContentInfo have the following
   meanings:

      eContentType is an object identifier.  The object identifier
      uniquely specifies the content type.

      eContent is the content itself, carried as an octet string.  The
      eContent need not be DER encoded.






Housley                     Standards Track                    [Page 11]


              Cryptographic Message Syntax        September 2009


   The optional omission of the eContent within the
   EncapsulatedContentInfo field makes it possible to construct
   "external signatures".  In the case of external signatures, the
   content being signed is absent from the EncapsulatedContentInfo value
   included in the signed-data content type.  If the eContent value
   within EncapsulatedContentInfo is absent, then the signatureValue is
   calculated and the eContentType is assigned as though the eContent
   value was present.

   In the degenerate case where there are no signers, the
   EncapsulatedContentInfo value being "signed" is irrelevant.  In this
   case, the content type within the EncapsulatedContentInfo value being
   "signed" MUST be id-data (as defined in Section 4), and the content
   field of the EncapsulatedContentInfo value MUST be omitted.

5.2.1.  Compatibility with PKCS #7

   This section contains a word of warning to implementers that wish to
   support both the CMS and PKCS #7 [PKCS#7] SignedData content types.
   Both the CMS and PKCS #7 identify the type of the encapsulated
   content with an object identifier, but the ASN.1 type of the content
   itself is variable in PKCS #7 SignedData content type.

   PKCS #7 defines content as:

      content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL

   The CMS defines eContent as:

      eContent [0] EXPLICIT OCTET STRING OPTIONAL

   The CMS definition is much easier to use in most applications, and it
   is compatible with both S/MIME v2 and S/MIME v3.  S/MIME signed
   messages using the CMS and PKCS #7 are compatible because identical
   signed message formats are specified in  for S/MIME v2
   [