Tech-invite3GPPspaceIETFspace
96959493929190898887868584838281807978777675747372717069686766656463626160595857565554535251504948474645444342414039383736353433323130292827262524232221201918171615141312111009080706050403020100
in Index   Prev   Next

RFC 3852

Cryptographic Message Syntax (CMS)

Pages: 56
Obsoletes:  3369
Obsoleted by:  5652
Updated by:  48535083
Part 1 of 2 – Pages 1 to 27
None   None   Next

ToP   noToC   RFC3852 - Page 1
Network Working Group                                         R. Housley
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
ToP   noToC   RFC3852 - Page 2
        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
ToP   noToC   RFC3852 - Page 3

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
ToP   noToC   RFC3852 - Page 4
   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.
ToP   noToC   RFC3852 - Page 5
   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-
ToP   noToC   RFC3852 - Page 6
   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 }
ToP   noToC   RFC3852 - Page 7
   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.
ToP   noToC   RFC3852 - Page 8
      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:
ToP   noToC   RFC3852 - Page 9
         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
ToP   noToC   RFC3852 - Page 10
      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.
      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. 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.
ToP   noToC   RFC3852 - Page 11

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 RFC 2311 for S/MIME v2 [OLDMSG] and RFC 3851 for S/MIME v3.1 [MSG]. S/MIME v2 encapsulates the MIME content in a Data type (that is, an OCTET STRING) carried in the SignedData contentInfo content ANY field, and S/MIME v3 carries the MIME content in the SignedData encapContentInfo eContent OCTET STRING. Therefore, in both S/MIME v2 and S/MIME v3, the MIME content is placed in an OCTET STRING and the message digest is computed over the identical portions of the content. That is, the message digest is computed over the octets comprising the value of the OCTET STRING, neither the tag nor length octets are included. There are incompatibilities between the CMS and PKCS #7 SignedData types when the encapsulated content is not formatted using the Data type. For example, when an RFC 2634 [ESS] signed receipt is encapsulated in the CMS SignedData type, then the Receipt SEQUENCE is encoded in the SignedData encapContentInfo eContent OCTET STRING and the message digest is computed using the entire Receipt SEQUENCE encoding (including tag, length and value octets). However, if an RFC 2634 signed receipt is encapsulated in the PKCS #7 SignedData type, then the Receipt SEQUENCE is DER encoded [X.509-88] in the SignedData contentInfo content ANY field (a SEQUENCE, not an OCTET STRING). Therefore, the message digest is computed using only the value octets of the Receipt SEQUENCE encoding. The following strategy can be used to achieve backward compatibility with PKCS #7 when processing SignedData content types. If the implementation is unable to ASN.1 decode the SignedData type using the CMS SignedData encapContentInfo eContent OCTET STRING syntax,
ToP   noToC   RFC3852 - Page 12
   then the implementation MAY attempt to decode the SignedData type
   using the PKCS #7 SignedData contentInfo content ANY syntax and
   compute the message digest accordingly.

   The following strategy can be used to achieve backward compatibility
   with PKCS #7 when creating a SignedData content type in which the
   encapsulated content is not formatted using the Data type.
   Implementations MAY examine the value of the eContentType, and then
   adjust the expected DER encoding of eContent based on the object
   identifier value.  For example, to support Microsoft Authenticode
   [MSAC], the following information MAY be included:

      eContentType Object Identifier is set to { 1 3 6 1 4 1 311 2 1 4 }

      eContent contains DER encoded Authenticode signing information

5.3. SignerInfo Type

Per-signer information is represented in the type SignerInfo: SignerInfo ::= SEQUENCE { version CMSVersion, sid SignerIdentifier, digestAlgorithm DigestAlgorithmIdentifier, signedAttrs [0] IMPLICIT SignedAttributes OPTIONAL, signatureAlgorithm SignatureAlgorithmIdentifier, signature SignatureValue, unsignedAttrs [1] IMPLICIT UnsignedAttributes OPTIONAL } SignerIdentifier ::= CHOICE { issuerAndSerialNumber IssuerAndSerialNumber, subjectKeyIdentifier [0] SubjectKeyIdentifier } SignedAttributes ::= SET SIZE (1..MAX) OF Attribute UnsignedAttributes ::= SET SIZE (1..MAX) OF Attribute Attribute ::= SEQUENCE { attrType OBJECT IDENTIFIER, attrValues SET OF AttributeValue } AttributeValue ::= ANY SignatureValue ::= OCTET STRING
ToP   noToC   RFC3852 - Page 13
   The fields of type SignerInfo have the following meanings:

      version is the syntax version number.  If the SignerIdentifier is
      the CHOICE issuerAndSerialNumber, then the version MUST be 1.  If
      the SignerIdentifier is subjectKeyIdentifier, then the version
      MUST be 3.

      sid specifies the signer's certificate (and thereby the signer's
      public key).  The signer's public key is needed by the recipient
      to verify the signature.  SignerIdentifier provides two
      alternatives for specifying the signer's public key.  The
      issuerAndSerialNumber alternative identifies the signer's
      certificate by the issuer's distinguished name and the certificate
      serial number; the subjectKeyIdentifier identifies the signer's
      certificate by a key identifier.  When an X.509 certificate is
      reference, the key identifier matches the X.509
      subjectKeyIdentifier extension value.  When other certificate
      formats are referenced, the documents that specify the certificate
      format and their use with the CMS must include details on matching
      the key identifier to the appropriate certificate field.
      Implementations MUST support the reception of the
      issuerAndSerialNumber and subjectKeyIdentifier forms of
      SignerIdentifier.  When generating a SignerIdentifier,
      implementations MAY support one of the forms (either
      issuerAndSerialNumber or subjectKeyIdentifier) and always use it,
      or implementations MAY arbitrarily mix the two forms.  However,
      subjectKeyIdentifier MUST be used to refer to a public key
      contained in a non-X.509 certificate.

      digestAlgorithm identifies the message digest algorithm, and any
      associated parameters, used by the signer.  The message digest is
      computed on either the content being signed or the content
      together with the signed attributes using the process described in
      section 5.4.  The message digest algorithm SHOULD be among those
      listed in the digestAlgorithms field of the associated SignerData.
      Implementations MAY fail to validate signatures that use a digest
      algorithm that is not included in the SignedData digestAlgorithms
      set.

      signedAttrs is a collection of attributes that are signed.  The
      field is optional, but it MUST be present if the content type of
      the EncapsulatedContentInfo value being signed is not id-data.
      SignedAttributes MUST be DER encoded, even if the rest of the
      structure is BER encoded.  Useful attribute types, such as signing
      time, are defined in Section 11.  If the field is present, it MUST
      contain, at a minimum, the following two attributes:
ToP   noToC   RFC3852 - Page 14
         A content-type attribute having as its value the content type
         of the EncapsulatedContentInfo value being signed.  Section
         11.1 defines the content-type attribute.  However, the
         content-type attribute MUST NOT be used as part of a
         countersignature unsigned attribute as defined in section 11.4.

         A message-digest attribute, having as its value the message
         digest of the content.  Section 11.2 defines the message-digest
         attribute.

      signatureAlgorithm identifies the signature algorithm, and any
      associated parameters, used by the signer to generate the digital
      signature.

      signature is the result of digital signature generation, using the
      message digest and the signer's private key.  The details of the
      signature depend on the signature algorithm employed.

      unsignedAttrs is a collection of attributes that are not signed.
      The field is optional.  Useful attribute types, such as
      countersignatures, are defined in Section 11.

   The fields of type SignedAttribute and UnsignedAttribute have the
   following meanings:

      attrType indicates the type of attribute.  It is an object
      identifier.

      attrValues is a set of values that comprise the attribute.  The
      type of each value in the set can be determined uniquely by
      attrType.  The attrType can impose restrictions on the number of
      items in the set.

5.4. Message Digest Calculation Process

The message digest calculation process computes a message digest on either the content being signed or the content together with the signed attributes. In either case, the initial input to the message digest calculation process is the "value" of the encapsulated content being signed. Specifically, the initial input is the encapContentInfo eContent OCTET STRING to which the signing process is applied. Only the octets comprising the value of the eContent OCTET STRING are input to the message digest algorithm, not the tag or the length octets. The result of the message digest calculation process depends on whether the signedAttrs field is present. When the field is absent, the result is just the message digest of the content as described
ToP   noToC   RFC3852 - Page 15
   above.  When the field is present, however, the result is the message
   digest of the complete DER encoding of the SignedAttrs value
   contained in the signedAttrs field.  Since the SignedAttrs value,
   when present, must contain the content-type and the message-digest
   attributes, those values are indirectly included in the result.  The
   content-type attribute MUST NOT be included in a countersignature
   unsigned attribute as defined in section 11.4.  A separate encoding
   of the signedAttrs field is performed for message digest calculation.
   The IMPLICIT [0] tag in the signedAttrs is not used for the DER
   encoding, rather an EXPLICIT SET OF tag is used.  That is, the DER
   encoding of the EXPLICIT SET OF tag, rather than of the IMPLICIT [0]
   tag, MUST be included in the message digest calculation along with
   the length and content octets of the SignedAttributes value.

   When the signedAttrs field is absent, only the octets comprising the
   value of the SignedData encapContentInfo eContent OCTET STRING (e.g.,
   the contents of a file) are input to the message digest calculation.
   This has the advantage that the length of the content being signed
   need not be known in advance of the signature generation process.

   Although the encapContentInfo eContent OCTET STRING tag and length
   octets are not included in the message digest calculation, they are
   protected by other means.  The length octets are protected by the
   nature of the message digest algorithm since it is computationally
   infeasible to find any two distinct message contents of any length
   that have the same message digest.

5.5. Signature Generation Process

The input to the signature generation process includes the result of the message digest calculation process and the signer's private key. The details of the signature generation depend on the signature algorithm employed. The object identifier, along with any parameters, that specifies the signature algorithm employed by the signer is carried in the signatureAlgorithm field. The signature value generated by the signer MUST be encoded as an OCTET STRING and carried in the signature field.

5.6. Signature Verification Process

The input to the signature verification process includes the result of the message digest calculation process and the signer's public key. The recipient MAY obtain the correct public key for the signer by any means, but the preferred method is from a certificate obtained from the SignedData certificates field. The selection and validation of the signer's public key MAY be based on certification path
ToP   noToC   RFC3852 - Page 16
   validation (see [PROFILE]) as well as other external context, but is
   beyond the scope of this document.  The details of the signature
   verification depend on the signature algorithm employed.

   The recipient MUST NOT rely on any message digest values computed by
   the originator.  If the SignedData signerInfo includes
   signedAttributes, then the content message digest MUST be calculated
   as described in section 5.4.  For the signature to be valid, the
   message digest value calculated by the recipient MUST be the same as
   the value of the messageDigest attribute included in the
   signedAttributes of the SignedData signerInfo.

   If the SignedData signerInfo includes signedAttributes, then the
   content-type attribute value MUST match the SignedData
   encapContentInfo eContentType value.

6. Enveloped-data Content Type

The enveloped-data content type consists of an encrypted content of any type and encrypted content-encryption keys for one or more recipients. The combination of the encrypted content and one encrypted content-encryption key for a recipient is a "digital envelope" for that recipient. Any type of content can be enveloped for an arbitrary number of recipients using any of the supported key management techniques for each recipient. The typical application of the enveloped-data content type will represent one or more recipients' digital envelopes on content of the data or signed-data content types. Enveloped-data is constructed by the following steps: 1. A content-encryption key for a particular content-encryption algorithm is generated at random. 2. The content-encryption key is encrypted for each recipient. The details of this encryption depend on the key management algorithm used, but four general techniques are supported: key transport: the content-encryption key is encrypted in the recipient's public key; key agreement: the recipient's public key and the sender's private key are used to generate a pairwise symmetric key, then the content-encryption key is encrypted in the pairwise symmetric key;
ToP   noToC   RFC3852 - Page 17
         symmetric key-encryption keys:  the content-encryption key is
         encrypted in a previously distributed symmetric key-encryption
         key; and

         passwords: the content-encryption key is encrypted in a key-
         encryption key that is derived from a password or other shared
         secret value.

      3. For each recipient, the encrypted content-encryption key and
         other recipient-specific information are collected into a
         RecipientInfo value, defined in Section 6.2.

      4. The content is encrypted with the content-encryption key.
         Content encryption may require that the content be padded to a
         multiple of some block size; see Section 6.3.

      5. The RecipientInfo values for all the recipients are collected
         together with the encrypted content to form an EnvelopedData
         value as defined in Section 6.1.

      A recipient opens the digital envelope by decrypting one of the
      encrypted content-encryption keys and then decrypting the
      encrypted content with the recovered content-encryption key.

      This section is divided into four parts.  The first part describes
      the top-level type EnvelopedData, the second part describes the
      per-recipient information type RecipientInfo, and the third and
      fourth parts describe the content-encryption and key-encryption
      processes.

6.1. EnvelopedData Type

The following object identifier identifies the enveloped-data content type: id-envelopedData OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs7(7) 3 } The enveloped-data content type shall have ASN.1 type EnvelopedData: EnvelopedData ::= SEQUENCE { version CMSVersion, originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL, recipientInfos RecipientInfos, encryptedContentInfo EncryptedContentInfo, unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL }
ToP   noToC   RFC3852 - Page 18
    OriginatorInfo ::= SEQUENCE {
     certs [0] IMPLICIT CertificateSet OPTIONAL,
     crls [1] IMPLICIT RevocationInfoChoices OPTIONAL }

    RecipientInfos ::= SET SIZE (1..MAX) OF RecipientInfo

    EncryptedContentInfo ::= SEQUENCE {
     contentType ContentType,
     contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier,
     encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL }

    EncryptedContent ::= OCTET STRING

    UnprotectedAttributes ::= SET SIZE (1..MAX) OF Attribute

   The fields of type EnvelopedData have the following meanings:

      version is the syntax version number.  The appropriate value
      depends on originatorInfo, RecipientInfo, and unprotectedAttrs.
      The version MUST be assigned as follows:

         IF (originatorInfo is present) AND
            ((any certificates with a type of other are present) OR
            (any crls with a type of other are present))
         THEN version is 4
         ELSE
            IF ((originatorInfo is present) AND
               (any version 2 attribute certificates are present)) OR
               (any RecipientInfo structures include pwri) OR
               (any RecipientInfo structures include ori)
            THEN version is 3
            ELSE
               IF (originatorInfo is absent) OR
                  (unprotectedAttrs is absent) OR
                  (all RecipientInfo structures are version 0)
               THEN version is 0
               ELSE version is 2

      originatorInfo optionally provides information about the
      originator.  It is present only if required by the key management
      algorithm.  It may contain certificates and CRLs:

         certs is a collection of certificates.  certs may contain
         originator certificates associated with several different key
         management algorithms.  certs may also contain attribute
         certificates associated with the originator.  The certificates
         contained in certs are intended to be sufficient for all
         recipients to build certification paths from a recognized
ToP   noToC   RFC3852 - Page 19
         "root" or "top-level certification authority."  However, certs
         may contain more certificates than necessary, and there may be
         certificates sufficient to make certification paths from two or
         more independent top-level certification authorities.
         Alternatively, certs may contain 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).

         crls is a collection of CRLs.  It is intended that the set
         contain information sufficient to determine whether or not the
         certificates in the certs field are valid, but such
         correspondence is not necessary.  There MAY be more CRLs than
         necessary, and there MAY also be fewer CRLs than necessary.

      recipientInfos is a collection of per-recipient information.
      There MUST be at least one element in the collection.

      encryptedContentInfo is the encrypted content information.

      unprotectedAttrs is a collection of attributes that are not
      encrypted.  The field is optional.  Useful attribute types are
      defined in Section 11.

   The fields of type EncryptedContentInfo have the following meanings:

      contentType indicates the type of content.

      contentEncryptionAlgorithm identifies the content-encryption
      algorithm, and any associated parameters, used to encrypt the
      content.  The content-encryption process is described in Section
      6.3.  The same content-encryption algorithm and content-encryption
      key are used for all recipients.

      encryptedContent is the result of encrypting the content.  The
      field is optional, and if the field is not present, its intended
      value must be supplied by other means.

   The recipientInfos field comes before the encryptedContentInfo field
   so that an EnvelopedData value may be processed in a single pass.

6.2. RecipientInfo Type

Per-recipient information is represented in the type RecipientInfo. RecipientInfo has a different format for each of the supported key management techniques. Any of the key management techniques can be
ToP   noToC   RFC3852 - Page 20
   used for each recipient of the same encrypted content.  In all cases,
   the encrypted content-encryption key is transferred to one or more
   recipients.

   Since all implementations will not support every possible key
   management algorithm, all implementations MUST gracefully handle
   unimplemented algorithms when they are encountered.  For example, if
   a recipient receives a content-encryption key encrypted in their RSA
   public key using RSA-OAEP and the implementation only supports RSA
   PKCS #1 v1.5, then a graceful failure must be implemented.

   Implementations MUST support key transport, key agreement, and
   previously distributed symmetric key-encryption keys, as represented
   by ktri, kari, and kekri, respectively.  Implementations MAY support
   the password-based key management as represented by pwri.
   Implementations MAY support any other key management technique as
   represented by ori.  Since each recipient can employ a different key
   management technique and future specifications could define
   additional key management techniques, all implementations MUST
   gracefully handle unimplemented alternatives within the RecipientInfo
   CHOICE, all implementations MUST gracefully handle unimplemented
   versions of otherwise supported alternatives within the RecipientInfo
   CHOICE, and all implementations MUST gracefully handle unimplemented
   or unknown ori alternatives.

            RecipientInfo ::= CHOICE {
              ktri KeyTransRecipientInfo,
              kari [1] KeyAgreeRecipientInfo,
              kekri [2] KEKRecipientInfo,
              pwri [3] PasswordRecipientinfo,
              ori [4] OtherRecipientInfo }

            EncryptedKey ::= OCTET STRING

6.2.1. KeyTransRecipientInfo Type

Per-recipient information using key transport is represented in the type KeyTransRecipientInfo. Each instance of KeyTransRecipientInfo transfers the content-encryption key to one recipient. KeyTransRecipientInfo ::= SEQUENCE { version CMSVersion, -- always set to 0 or 2 rid RecipientIdentifier, keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, encryptedKey EncryptedKey }
ToP   noToC   RFC3852 - Page 21
      RecipientIdentifier ::= CHOICE {
        issuerAndSerialNumber IssuerAndSerialNumber,
        subjectKeyIdentifier [0] SubjectKeyIdentifier }

   The fields of type KeyTransRecipientInfo have the following meanings:

      version is the syntax version number.  If the RecipientIdentifier
      is the CHOICE issuerAndSerialNumber, then the version MUST be 0.
      If the RecipientIdentifier is subjectKeyIdentifier, then the
      version MUST be 2.

      rid specifies the recipient's certificate or key that was used by
      the sender to protect the content-encryption key.  The content-
      encryption key is encrypted with the recipient's public key.  The
      RecipientIdentifier provides two alternatives for specifying the
      recipient's certificate, and thereby the recipient's public key.
      The recipient's certificate must contain a key transport public
      key.  Therefore, a recipient X.509 version 3 certificate that
      contains a key usage extension MUST assert the keyEncipherment
      bit.  The issuerAndSerialNumber alternative identifies the
      recipient's certificate by the issuer's distinguished name and the
      certificate serial number; the subjectKeyIdentifier identifies the
      recipient's certificate by a key identifier.  When an X.509
      certificate is referenced, the key identifier matches the X.509
      subjectKeyIdentifier extension value.  When other certificate
      formats are referenced, the documents that specify the certificate
      format and their use with the CMS must include details on matching
      the key identifier to the appropriate certificate field.  For
      recipient processing, implementations MUST support both of these
      alternatives for specifying the recipient's certificate.  For
      sender processing, implementations MUST support at least one of
      these alternatives.

      keyEncryptionAlgorithm identifies the key-encryption algorithm,
      and any associated parameters, used to encrypt the content-
      encryption key for the recipient.  The key-encryption process is
      described in Section 6.4.

      encryptedKey is the result of encrypting the content-encryption
      key for the recipient.

6.2.2. KeyAgreeRecipientInfo Type

Recipient information using key agreement is represented in the type KeyAgreeRecipientInfo. Each instance of KeyAgreeRecipientInfo will transfer the content-encryption key to one or more recipients that use the same key agreement algorithm and domain parameters for that algorithm.
ToP   noToC   RFC3852 - Page 22
      KeyAgreeRecipientInfo ::= SEQUENCE {
        version CMSVersion,  -- always set to 3
        originator [0] EXPLICIT OriginatorIdentifierOrKey,
        ukm [1] EXPLICIT UserKeyingMaterial OPTIONAL,
        keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier,
        recipientEncryptedKeys RecipientEncryptedKeys }

      OriginatorIdentifierOrKey ::= CHOICE {
        issuerAndSerialNumber IssuerAndSerialNumber,
        subjectKeyIdentifier [0] SubjectKeyIdentifier,
        originatorKey [1] OriginatorPublicKey }

      OriginatorPublicKey ::= SEQUENCE {
        algorithm AlgorithmIdentifier,
        publicKey BIT STRING }

      RecipientEncryptedKeys ::= SEQUENCE OF RecipientEncryptedKey

      RecipientEncryptedKey ::= SEQUENCE {
        rid KeyAgreeRecipientIdentifier,
        encryptedKey EncryptedKey }

      KeyAgreeRecipientIdentifier ::= CHOICE {
        issuerAndSerialNumber IssuerAndSerialNumber,
        rKeyId [0] IMPLICIT RecipientKeyIdentifier }

      RecipientKeyIdentifier ::= SEQUENCE {
        subjectKeyIdentifier SubjectKeyIdentifier,
        date GeneralizedTime OPTIONAL,
        other OtherKeyAttribute OPTIONAL }

      SubjectKeyIdentifier ::= OCTET STRING

   The fields of type KeyAgreeRecipientInfo have the following meanings:

      version is the syntax version number.  It MUST always be 3.

      originator is a CHOICE with three alternatives specifying the
      sender's key agreement public key.  The sender uses the
      corresponding private key and the recipient's public key to
      generate a pairwise key.  The content-encryption key is encrypted
      in the pairwise key.  The issuerAndSerialNumber alternative
      identifies the sender's certificate, and thereby the sender's
      public key, by the issuer's distinguished name and the certificate
      serial number.  The subjectKeyIdentifier alternative identifies
      the sender's certificate, and thereby the sender's public key, by
      a key identifier.  When an X.509 certificate is referenced, the
      key identifier matches the X.509 subjectKeyIdentifier extension
ToP   noToC   RFC3852 - Page 23
      value.  When other certificate formats are referenced, the
      documents that specify the certificate format and their use with
      the CMS must include details on matching the key identifier to the
      appropriate certificate field.  The originatorKey alternative
      includes the algorithm identifier and sender's key agreement
      public key.  This alternative permits originator anonymity since
      the public key is not certified.  Implementations MUST support all
      three alternatives for specifying the sender's public key.

      ukm is optional.  With some key agreement algorithms, the sender
      provides a User Keying Material (UKM) to ensure that a different
      key is generated each time the same two parties generate a
      pairwise key.  Implementations MUST accept a KeyAgreeRecipientInfo
      SEQUENCE that includes a ukm field.  Implementations that do not
      support key agreement algorithms that make use of UKMs MUST
      gracefully handle the presence of UKMs.

      keyEncryptionAlgorithm identifies the key-encryption algorithm,
      and any associated parameters, used to encrypt the content-
      encryption key with the key-encryption key.  The key-encryption
      process is described in Section 6.4.

      recipientEncryptedKeys includes a recipient identifier and
      encrypted key for one or more recipients.  The
      KeyAgreeRecipientIdentifier is a CHOICE with two alternatives
      specifying the recipient's certificate, and thereby the
      recipient's public key, that was used by the sender to generate a
      pairwise key-encryption key.  The recipient's certificate must
      contain a key agreement public key.  Therefore, a recipient X.509
      version 3 certificate that contains a key usage extension MUST
      assert the keyAgreement bit.  The content-encryption key is
      encrypted in the pairwise key-encryption key.  The
      issuerAndSerialNumber alternative identifies the recipient's
      certificate by the issuer's distinguished name and the certificate
      serial number; the RecipientKeyIdentifier is described below.  The
      encryptedKey is the result of encrypting the content-encryption
      key in the pairwise key-encryption key generated using the key
      agreement algorithm.  Implementations MUST support both
      alternatives for specifying the recipient's certificate.

   The fields of type RecipientKeyIdentifier have the following
   meanings:

      subjectKeyIdentifier identifies the recipient's certificate by a
      key identifier.  When an X.509 certificate is referenced, the key
      identifier matches the X.509 subjectKeyIdentifier extension value.
      When other certificate formats are referenced, the documents that
ToP   noToC   RFC3852 - Page 24
      specify the certificate format and their use with the CMS must
      include details on matching the key identifier to the appropriate
      certificate field.

      date is optional.  When present, the date specifies which of the
      recipient's previously distributed UKMs was used by the sender.

      other is optional.  When present, this field contains additional
      information used by the recipient to locate the public keying
      material used by the sender.

6.2.3. KEKRecipientInfo Type

Recipient information using previously distributed symmetric keys is represented in the type KEKRecipientInfo. Each instance of KEKRecipientInfo will transfer the content-encryption key to one or more recipients who have the previously distributed key-encryption key. KEKRecipientInfo ::= SEQUENCE { version CMSVersion, -- always set to 4 kekid KEKIdentifier, keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, encryptedKey EncryptedKey } KEKIdentifier ::= SEQUENCE { keyIdentifier OCTET STRING, date GeneralizedTime OPTIONAL, other OtherKeyAttribute OPTIONAL } The fields of type KEKRecipientInfo have the following meanings: version is the syntax version number. It MUST always be 4. kekid specifies a symmetric key-encryption key that was previously distributed to the sender and one or more recipients. keyEncryptionAlgorithm identifies the key-encryption algorithm, and any associated parameters, used to encrypt the content- encryption key with the key-encryption key. The key-encryption process is described in Section 6.4. encryptedKey is the result of encrypting the content-encryption key in the key-encryption key.
ToP   noToC   RFC3852 - Page 25
   The fields of type KEKIdentifier have the following meanings:

      keyIdentifier identifies the key-encryption key that was
      previously distributed to the sender and one or more recipients.

      date is optional.  When present, the date specifies a single key-
      encryption key from a set that was previously distributed.

      other is optional.  When present, this field contains additional
      information used by the recipient to determine the key-encryption
      key used by the sender.

6.2.4. PasswordRecipientInfo Type

Recipient information using a password or shared secret value is represented in the type PasswordRecipientInfo. Each instance of PasswordRecipientInfo will transfer the content-encryption key to one or more recipients who possess the password or shared secret value. The PasswordRecipientInfo Type is specified in RFC 3211 [PWRI]. The PasswordRecipientInfo structure is repeated here for completeness. PasswordRecipientInfo ::= SEQUENCE { version CMSVersion, -- Always set to 0 keyDerivationAlgorithm [0] KeyDerivationAlgorithmIdentifier OPTIONAL, keyEncryptionAlgorithm KeyEncryptionAlgorithmIdentifier, encryptedKey EncryptedKey } The fields of type PasswordRecipientInfo have the following meanings: version is the syntax version number. It MUST always be 0. keyDerivationAlgorithm identifies the key-derivation algorithm, and any associated parameters, used to derive the key-encryption key from the password or shared secret value. If this field is absent, the key-encryption key is supplied from an external source, for example a hardware crypto token such as a smart card. keyEncryptionAlgorithm identifies the encryption algorithm, and any associated parameters, used to encrypt the content-encryption key with the key-encryption key. encryptedKey is the result of encrypting the content-encryption key with the key-encryption key.
ToP   noToC   RFC3852 - Page 26

6.2.5. OtherRecipientInfo Type

Recipient information for additional key management techniques are represented in the type OtherRecipientInfo. The OtherRecipientInfo type allows key management techniques beyond key transport, key agreement, previously distributed symmetric key-encryption keys, and password-based key management to be specified in future documents. An object identifier uniquely identifies such key management techniques. OtherRecipientInfo ::= SEQUENCE { oriType OBJECT IDENTIFIER, oriValue ANY DEFINED BY oriType } The fields of type OtherRecipientInfo have the following meanings: oriType identifies the key management technique. oriValue contains the protocol data elements needed by a recipient using the identified key management technique.

6.3. Content-encryption Process

The content-encryption key for the desired content-encryption algorithm is randomly generated. The data to be protected is padded as described below, then the padded data is encrypted using the content-encryption key. The encryption operation maps an arbitrary string of octets (the data) to another string of octets (the ciphertext) under control of a content-encryption key. The encrypted data is included in the EnvelopedData encryptedContentInfo encryptedContent OCTET STRING. Some content-encryption algorithms assume the input length is a multiple of k octets, where k is greater than one. For such algorithms, the input shall be padded at the trailing end with k-(lth mod k) octets all having value k-(lth mod k), where lth is the length of the input. In other words, the input is padded at the trailing end with one of the following strings: 01 -- if lth mod k = k-1 02 02 -- if lth mod k = k-2 . . . k k ... k k -- if lth mod k = 0
ToP   noToC   RFC3852 - Page 27
   The padding can be removed unambiguously since all input is padded,
   including input values that are already a multiple of the block size,
   and no padding string is a suffix of another.  This padding method is
   well defined if and only if k is less than 256.

6.4. Key-encryption Process

The input to the key-encryption process -- the value supplied to the recipient's key-encryption algorithm -- is just the "value" of the content-encryption key. Any of the aforementioned key management techniques can be used for each recipient of the same encrypted content.


(page 27 continued on part 2)

Next Section