Request for Comments: 3852 Vigil Security
Obsoletes: 3369 July 2004
Category: Standards Track
Cryptographic Message Syntax (CMS)
Status of this Memo
This document specifies an Internet standards track protocol for the
Internet community, and requests discussion and suggestions for
improvements. Please refer to the current edition of the "Internet
Official Protocol Standards" (STD 1) for the standardization state
and status of this protocol. Distribution of this memo is unlimited.
Copyright Notice
Copyright (C) The Internet Society (2004).
Abstract
This document describes the Cryptographic Message Syntax (CMS). This
syntax is used to digitally sign, digest, authenticate, or encrypt
arbitrary message content.
Table of Contents
1. Introduction. . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1. Evolution of the CMS . . . . . . . . . . . . . . . . . 3
1.1.1. Changes Since PKCS #7 Version 1.5. . . . . . . 3
1.1.2. Changes Since RFC 2630 . . . . . . . . . . . . 4
1.1.3. Changes Since RFC 3369 . . . . . . . . . . . . 4
1.2. Terminology . . . . . . . . . . . . . . . . . . . . . . 5
1.3. Version Numbers . . . . . . . . . . . . . . . . . . . . 5
2. General Overview. . . . . . . . . . . . . . . . . . . . . . . 5
3. General Syntax . . . . . . . . . . . . . . . . . . . . . . . 6
4. Data Content Type . . . . . . . . . . . . . . . . . . . . . . 6
5. Signed-data Content Type. . . . . . . . . . . . . . . . . . . 7
5.1. SignedData Type. . . . . . . . . . . . . . . . . . . . 8
5.2. EncapsulatedContentInfo Type . . . . . . . . . . . . . 10
5.2.1. Compatibility with PKCS #7. . . . . . . . . . 11
5.3. SignerInfo Type. . . . . . . . . . . . . . . . . . . . 12
5.4. Message Digest Calculation Process . . . . . . . . . . 14
5.5. Signature Generation Process . . . . . . . . . . . . . 15
5.6. Signature Verification Process . . . . . . . . . . . . 15
6. Enveloped-data Content Type . . . . . . . . . . . . . . . . . 16
6.1. EnvelopedData Type . . . . . . . . . . . . . . . . . . 17
6.2. RecipientInfo Type . . . . . . . . . . . . . . . . . . 19
6.2.1. KeyTransRecipientInfo Type. . . . . . . . . . 20
6.2.2. KeyAgreeRecipientInfo Type. . . . . . . . . . 21
6.2.3. KEKRecipientInfo Type . . . . . . . . . . . . 24
6.2.4. PasswordRecipientInfo Type. . . . . . . . . . 25
6.2.5. OtherRecipientInfo Type . . . . . . . . . . . 26
6.3. Content-encryption Process . . . . . . . . . . . . . . 26
6.4. Key-encryption Process . . . . . . . . . . . . . . . . 27
7. Digested-data Content Type. . . . . . . . . . . . . . . . . . 27
8. Encrypted-data Content Type . . . . . . . . . . . . . . . . . 28
9. Authenticated-data Content Type . . . . . . . . . . . . . . . 29
9.1. AuthenticatedData Type . . . . . . . . . . . . . . . . 30
9.2. MAC Generation . . . . . . . . . . . . . . . . . . . . 32
9.3. MAC Verification . . . . . . . . . . . . . . . . . . . 33
10. Useful Types. . . . . . . . . . . . . . . . . . . . . . . . . 33
10.1. Algorithm Identifier Types . . . . . . . . . . . . . . 33
10.1.1. DigestAlgorithmIdentifier . . . . . . . . . . 34
10.1.2. SignatureAlgorithmIdentifier. . . . . . . . . 34
10.1.3. KeyEncryptionAlgorithmIdentifier. . . . . . . 34
10.1.4. ContentEncryptionAlgorithmIdentifier. . . . . 34
10.1.5. MessageAuthenticationCodeAlgorithm. . . . . . 35
10.1.6. KeyDerivationAlgorithmIdentifier. . . . . . . 35
10.2. Other Useful Types . . . . . . . . . . . . . . . . . . 35
10.2.1. RevocationInfoChoices . . . . . . . . . . . . 35
10.2.2. CertificateChoices. . . . . . . . . . . . . . 36
10.2.3. CertificateSet. . . . . . . . . . . . . . . . 37
10.2.4. IssuerAndSerialNumber . . . . . . . . . . . . 37
10.2.5. CMSVersion. . . . . . . . . . . . . . . . . . 38
10.2.6. UserKeyingMaterial. . . . . . . . . . . . . . 38
10.2.7. OtherKeyAttribute . . . . . . . . . . . . . . 38
11. Useful Attributes . . . . . . . . . . . . . . . . . . . . . . 38
11.1. Content Type . . . . . . . . . . . . . . . . . . . . . 39
11.2. Message Digest . . . . . . . . . . . . . . . . . . . . 39
11.3. Signing Time . . . . . . . . . . . . . . . . . . . . . 40
11.4. Countersignature . . . . . . . . . . . . . . . . . . . 41
12. ASN.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . 42
12.1. CMS ASN.1 Module . . . . . . . . . . . . . . . . . . . 43
12.2. Version 1 Attribute Certificate ASN.1 Module . . . . . 50
13. References . . . . . . . . . . . . . . . . . . . . . . . . . 51
13.1. Normative References . . . . . . . . . . . . . . . . . 51
13.2. Informative References . . . . . . . . . . . . . . . . 52
14. Security Considerations . . . . . . . . . . . . . . . . . . . 53
15. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 55
16. Author’s Address. . . . . . . . . . . . . . . . . . . . . . . 55
17. Full Copyright Statement. . . . . . . . . . . . . . . . . . . 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 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 working group
[PROFILE].
The CMS values are generated using ASN.1 [X.208-88], using BER-
encoding [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.
1.1. Evolution of the CMS
The CMS is derived from PKCS #7 version 1.5, which is documented in
RFC 2315 [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 the 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
RFC 2630 [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. RFC 2630 adds support for key
agreement and previously distributed symmetric key-encryption key
techniques.
1.1.2. Changes Since RFC 2630
RFC 3369 [CMS2] obsoletes RFC 2630 [CMS1] and RFC 3211 [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 RFC 2630 and RFC 3211 is preserved; however,
version 2 attribute certificate transfer is added, and the use of
version 1 attribute certificates is deprecated.
S/MIME v2 signatures [OLDMSG], which are based on PKCS#7 version 1.5,
are compatible with S/MIME v3 signatures [MSG], which are based on
RFC 2630. 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 RFC 2630. 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
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 RFC 3369
This document obsoletes RFC 3369 [CMS2]. As discussed in the
previous section, RFC 3369 introduced an extension mechanism to
support new key management schemes without further changes to the
CMS. This document 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 section 10.2.1 and section
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 RFC 3369, 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.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].
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.
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 RFC 2311 for S/MIME v2
[OLDMSG] and RFC 3851 for S/MIME v3.1 [MSG].
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 either by an issuer
distinguished name along with an issuer-specific serial number or by
a subject key identifier that uniquely identifies the certificate
containing the public key. The signer’s certificate can be included
in the SignedData certificates field.
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
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
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. The
details of the SignerInfo type are discussed in section 5.3.
Since each signer can employ a digital signature technique and
future specifications could update the syntax, all implementations
MUST gracefully handle unimplemented versions of SignerInfo.