RFC 5751

Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.2 Message Specification

๐Ÿ“… published January 2010, from ietf

Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.2 Message Specification ๐Ÿ’Œโœจ

Okay bestie, let's get the vitals first ๐Ÿ’…. This is RFC 5751, a Standards Track document from January 2010, written by B. Ramsdell (Brute Squad Labs) and S. Turner (IECA). It's part of the IETF stream, and its ISSN is 2070-1721. It obsoletes RFC 3851 ๐Ÿฆ‹, so that older spec is officially retired and this one is the new hotness. It doesn't update anything else. Iconic ๐Ÿ‘‘

Abstract โœจ

So this doc defines S/MIME version 3.2 ๐Ÿ’–. S/MIME basically gives you one consistent way to send and receive secure MIME data, which is a whole vibe. Digital signatures bring authentication, message integrity, and non-repudiation with proof of origin ๐Ÿ”. Encryption handles data confidentiality ๐Ÿคซ. Compression is there if you want to shrink your data size ๐ŸŒธ. And yes, this document obsoletes RFC 3851 ๐Ÿ’€.

Status of This Memo ๐Ÿ“œ

This is an Internet Standards Track document ๐Ÿ”ฅ.

It's a product of the Internet Engineering Task Force (IETF), so it represents the consensus of the IETF community. It went through public review and got approved for publication by the Internet Engineering Steering Group (IESG) ๐ŸŽ€. If you want more on Internet Standards, check out Section 2 of RFC 5741 ๐Ÿงš.

Info about the current status of this doc, any errata, and how to give feedback can be found at http://www.rfc-editor.org/info/rfc5751 ๐Ÿฆ‹.

Copyright (c) 2010 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) as they stand on the date this document was published. Please actually read these, because they spell out your rights and restrictions. Code Components pulled out of this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions, and they come without warranty as described in the Simplified BSD License ๐Ÿซถ.

This document may contain material from IETF Documents or IETF Contributions published or made publicly available before November 10, 2008. The people controlling the copyright in some of that material may not have granted the IETF Trust the right to allow modifications outside the IETF Standards Process ๐Ÿ˜ญ. So unless you get an adequate license from those copyright holders, 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. The one exception is formatting it for publication as an RFC or translating it into languages other than English ๐ŸŒˆ.

Table of Contents ๐Ÿ—‚๏ธ

   1. Introduction ....................................................4
      1.1. Specification Overview .....................................4
      1.2. Definitions ................................................5
      1.3. Conventions Used in This Document ..........................6
      1.4. Compatibility with Prior Practice of S/MIME ................7
      1.5. Changes from S/MIME v3 to S/MIME v3.1 ......................7
      1.6. Changes since S/MIME v3.1 ..................................7
   2. CMS Options .....................................................9
      2.1. DigestAlgorithmIdentifier ..................................9
      2.2. SignatureAlgorithmIdentifier ...............................9
      2.3. KeyEncryptionAlgorithmIdentifier ..........................10
      2.4. General Syntax ............................................11
      2.5. Attributes and the SignerInfo Type ........................12
      2.6. SignerIdentifier SignerInfo Type ..........................16
      2.7. ContentEncryptionAlgorithmIdentifier ......................16
   3. Creating S/MIME Messages .......................................18
      3.1. Preparing the MIME Entity for Signing, Enveloping,
           or Compressing ............................................19
      3.2. The application/pkcs7-mime Media Type .....................23
      3.3. Creating an Enveloped-Only Message ........................25
      3.4. Creating a Signed-Only Message ............................26
      3.5. Creating a Compressed-Only Message ........................30
      3.6. Multiple Operations .......................................30
      3.7. Creating a Certificate Management Message .................31
      3.8. Registration Requests .....................................32
      3.9. Identifying an S/MIME Message .............................32
   4. Certificate Processing .........................................32
      4.1. Key Pair Generation .......................................33
      4.2. Signature Generation ......................................33
      4.3. Signature Verification ....................................34
      4.4. Encryption ................................................34
      4.5. Decryption ................................................34
   5. IANA Considerations ............................................34
      5.1. Media Type for application/pkcs7-mime .....................34
      5.2. Media Type for application/pkcs7-signature ................35
   6. Security Considerations ........................................36
   7. References .....................................................38
      7.1. Reference Conventions .....................................38
      7.2. Normative References ......................................39
      7.3. Informative References ....................................41
   Appendix A. ASN.1 Module ..........................................43
   Appendix B. Moving S/MIME v2 Message Specification to Historic
               Status ................................................45
   Appendix C. Acknowledgments .......................................45

1. Introduction ๐ŸŽ€

S/MIME (Secure/Multipurpose Internet Mail Extensions) gives you one consistent way to send and receive secure MIME data ๐Ÿ’–. It builds on the popular Internet MIME standard and provides these cryptographic security services for electronic messaging apps: authentication, message integrity, and non-repudiation of origin (using digital signatures), plus data confidentiality (using encryption) โœจ. On top of that, it's got message compression as a supplementary service ๐Ÿ“ฆ.

S/MIME can be used by traditional mail user agents (MUAs) to add cryptographic security to mail you send, and to interpret the security in mail you receive ๐Ÿ’Œ. But it isn't limited to mail! It works with any transport mechanism that carries MIME data, like HTTP or SIP ๐ŸŒ. Because it uses the object-based features of MIME, secure messages can be exchanged even in mixed-transport systems, which is seriously clever ๐Ÿง .

It can also run in automated message transfer agents, doing crypto stuff that needs zero human involvement, like signing software-generated documents or encrypting FAX messages sent over the Internet ๐Ÿค–๐Ÿ“ .

1.1. Specification Overview ๐Ÿฆ‹

This document describes a protocol for adding cryptographic signature and encryption services to MIME data ๐Ÿ”. The MIME standard [MIME-SPEC] gives the general structure for the content of Internet messages and allows extensions for new content-type-based applications ๐Ÿงฉ.

This spec defines how to create a MIME body part that's been cryptographically enhanced according to the Cryptographic Message Syntax (CMS) RFC 5652 [CMS], which is derived from PKCS #7 [PKCS-7] ๐Ÿ’œ. It also defines the application/pkcs7-mime media type, which can be used to transport those body parts ๐Ÿšš.

This document also talks about how to use the multipart/signed media type defined in [MIME-SECURE] to transport S/MIME signed messages ๐Ÿ–Š๏ธ. multipart/signed is used together with the application/pkcs7-signature media type, which carries a detached S/MIME signature ๐Ÿช„.

To create S/MIME messages, an S/MIME agent MUST follow the specifications in this document, along with the specifications listed in the Cryptographic Message Syntax document [CMS], [CMSALG], [RSAPSS], [RSAOAEP], and [CMS-SHA2] ๐Ÿ“š. Not optional, bestie ๐Ÿ™ˆ.

Throughout this spec, there are requirements and recommendations for how receiving agents handle incoming messages, and separate ones for how sending agents create outgoing messages ๐Ÿ’…. Generally, the best strategy is to "be liberal in what you receive and conservative in what you send" ๐ŸŒธ. Most requirements land on handling incoming messages, and most recommendations are about creating outgoing messages โœจ.

The split between receiving-agent and sending-agent requirements also comes from the fact that S/MIME systems will probably include software that isn't a traditional Internet mail client ๐Ÿค–. S/MIME works with any system that transports MIME data. For example, an automated process that sends an encrypted message might not be able to receive an encrypted message at all ๐Ÿ™ƒ. So the requirements and recommendations for the two kinds of agents are listed separately when that makes sense ๐Ÿซถ.

1.2. Definitions ๐Ÿ“–

For the purposes of this specification, the following definitions apply ๐Ÿ’–.

  • ASN.1: Abstract Syntax Notation One, as defined in ITU-T Recommendation X.680 [X.680] ๐Ÿงพ.
  • BER: Basic Encoding Rules for ASN.1, as defined in ITU-T Recommendation X.690 [X.690] ๐Ÿ”ข.
  • Certificate: A type that binds an entity's name to a public key with a digital signature ๐Ÿชช.
  • DER: Distinguished Encoding Rules for ASN.1, as defined in ITU-T Recommendation X.690 [X.690] ๐Ÿ”ก.
  • 7-bit data: Text data with lines less than 998 characters long, where none of the characters have the 8th bit set, and there are no NULL characters. <CR> and <LF> occur only as part of a <CR><LF> end-of-line delimiter ๐ŸŒ™.
  • 8-bit data: Text data with lines less than 998 characters, where none of the characters are NULL characters. <CR> and <LF> occur only as part of a <CR><LF> end-of-line delimiter ๐ŸŒž.
  • Binary data: Arbitrary data ๐ŸŽฒ.
  • Transfer encoding: A reversible transformation made on data so 8-bit or binary data can be sent over a channel that only transmits 7-bit data ๐Ÿ”.
  • Receiving agent: Software that interprets and processes S/MIME CMS objects, MIME body parts that contain CMS content types, or both ๐Ÿ“ฅ.
  • Sending agent: Software that creates S/MIME CMS content types, MIME body parts that contain CMS content types, or both ๐Ÿ“ค.
  • S/MIME agent: User software that is a receiving agent, a sending agent, or both ๐Ÿฆธโ€โ™€๏ธ.

1.3. Conventions Used in This Document ๐ŸŽ€

okay so bestie, the key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [MUSTSHOULD]. ๐Ÿ’…

we also define some extra terms here, and these are lowkey the spiciest bit โœจ

SHOULD+ This term means the same as SHOULD. However, the authors expect that a requirement marked as SHOULD+ will be promoted at some future time to be a MUST. ๐Ÿฆ‹

SHOULD- This term means the same as SHOULD. However, the authors expect that a requirement marked as SHOULD- will be demoted to a MAY in a future version of this document. ๐Ÿฅ€

MUST- This term means the same as MUST. However, the authors expect that this requirement will no longer be a MUST in a future document. Although its status will be determined at a later time, it is reasonable to expect that if a future revision of a document alters the status of a MUST- requirement, it will remain at least a SHOULD or a SHOULD-. ๐ŸŒธ

1.4. Compatibility with Prior Practice of S/MIME ๐Ÿงš

S/MIME version 3.2 agents ought to attempt to have the greatest interoperability possible with agents for prior versions of S/MIME. ๐Ÿซถ S/MIME version 2 is described in RFC 2311 through RFC 2315 inclusive [SMIMEv2], S/MIME version 3 is described in RFC 2630 through RFC 2634 inclusive and RFC 5035 [SMIMEv3], and S/MIME version 3.1 is described in RFC 3850, RFC 3851, RFC 3852, RFC 2634, and RFC 5035 [SMIMEv3.1]. RFC 2311 also has historical information about the development of S/MIME. ๐Ÿ“š

1.5. Changes from S/MIME v3 to S/MIME v3.1 ๐Ÿ“

the RSA public key algorithm got upgraded to a MUST implement key wrapping algorithm, and the Diffie-Hellman (DH) algorithm became a SHOULD implement. ๐Ÿ”ฅ

the AES symmetric encryption algorithm was added as a SHOULD implement. โœจ

the RSA public key algorithm also became a MUST implement signature algorithm. ๐Ÿ’œ

the "empty" SignedData messages used to send certificates got clarified, because it's now also allowed to send Certificate Revocation Lists that way. ๐Ÿ™ˆ

binary encoding for some MIME entities is now explicitly discussed, bestie. ๐ŸŒˆ

header protection through the message/rfc822 media type got added. ๐Ÿ›ก๏ธ

using the CompressedData CMS type is allowed now, along with required media type and file extension additions. ๐ŸŽ€

1.6. Changes since S/MIME v3.1 ๐Ÿ’–

editorial changes, like "MIME type" becoming "media type" and content-type becoming Content-Type. ๐Ÿ’…

"Conventions Used in This Document" moved to Section 1.3, and definitions for SHOULD+, SHOULD-, and MUST- got added. โœจ

Section 1.1 and Appendix A got references to RFCs for RSASSA-PSS, RSAES-OAEP, and SHA2 CMS algorithms, and the CMS Multiple Signers Clarification got added to the CMS reference. ๐Ÿฆ‹

Section 1.2 got updated references: ASN.1 now points to X.680, and BER and DER point to X.690. ๐ŸŒธ

Section 1.4 got references to S/MIME MSG 3.1 RFCs. ๐Ÿงš

Section 2.1 (digest algorithm): SHA-256 is now a MUST, and SHA-1 and MD5 became SHOULD-. ๐Ÿ”ฅ

Section 2.2 (signature algorithms): RSA with SHA-256 is now a MUST, DSA with SHA-256 is a SHOULD+, RSA with SHA-1, DSA with SHA-1, and RSA with MD5 became SHOULD-, and RSASSA-PSS with SHA-256 is a SHOULD+. There's also a note about what S/MIME v3.1 clients support. ๐Ÿ’œ

Section 2.3 (key encryption): DH became SHOULD-, RSAES-OAEP became SHOULD+, and the key wrap algorithm requirements got elaborated. ๐Ÿ™ˆ

Section 2.5.1: receiving agents MUST support both GeneralizedTime and UTCTime. ๐ŸŒˆ

Section 2.5.2: "sha1WithRSAEncryption" got swapped for "sha256WithRSAEncryption", "DES-3EDE-CBC" got swapped for "AES-128 CBC", and the RC5 example got deleted. ๐ŸŽ€

Section 2.5.2.1: whole section deleted (it talked about the deprecated RC2). ๐Ÿ’€

Section 2.7, 2.7.1, and Appendix A: references to RC2/40 removed. ๐Ÿซถ

Section 2.7 (content encryption): AES-128 CBC is now a MUST, AES-192 and AES-256 CBC are SHOULD+, and tripleDES is now SHOULD-. ๐Ÿ’…

Section 2.7.1: pointers from 2.7.2.1 through 2.7.2.4 got updated to 2.7.1.1 through 2.7.1.2. ๐Ÿฆ‹

Section 3.1.1: text about MIME character sets got removed. ๐Ÿฅ€

Section 3.2.2 and 3.6: "encrypted" got replaced with "enveloped", and the OID example now uses the AES-128 CBC oid. โœจ

Section 3.4.3.2: the micalg parameter for SHA-1 is now sha-1. ๐Ÿ“

Section 4: reference to CERT v3.2 got updated. ๐Ÿงš

Section 4.1: RSA and DSA key size discussion got updated, the last four sentences moved to security considerations, and the reference to randomness requirements for security got updated. ๐Ÿ”ฅ

Section 5: IANA registration templates got added to update the media type registry so it points to this document instead of RFC 2311. ๐ŸŒˆ

Section 6: security considerations got updated. ๐Ÿ‘‘

Section 7: references moved from Appendix B to this section, references got updated, and informational references to SMIMEv2, SMIMEv3, and SMIMEv3.1 got added. ๐Ÿ’œ

Appendix B: added so S/MIME v2 could move to Historic status. ๐Ÿซถ

2. CMS Options ๐ŸŒธ

CMS allows for a wild variety of options in content, attributes, and algorithm support. ๐Ÿคฏ This section puts forth a number of support requirements and recommendations so we get a base level of interoperability across all S/MIME implementations. [CMSALG] and [CMS-SHA2] provide extra details about using the cryptographic algorithms. [ESS] provides extra details about using additional attributes. ๐Ÿ“–

2.1. DigestAlgorithmIdentifier ๐Ÿ”

Sending and receiving agents MUST support SHA-256 [CMS-SHA2] and SHOULD- support SHA-1 [CMSALG]. Receiving agents SHOULD- support MD5 [CMSALG] so they can stay backward compatible with MD5-digested S/MIME v2 SignedData objects. ๐Ÿฅน

2.2. SignatureAlgorithmIdentifier โœ๏ธ

Receiving agents:

   - MUST support RSA with SHA-256.

   - SHOULD+ support DSA with SHA-256.

   - SHOULD+ support RSASSA-PSS with SHA-256.

   - SHOULD- support RSA with SHA-1.

   - SHOULD- support DSA with SHA-1.

   - SHOULD- support RSA with MD5.

Sending agents:

   - MUST support RSA with SHA-256.

   - SHOULD+ support DSA with SHA-256.

   - SHOULD+ support RSASSA-PSS with SHA-256.

   - SHOULD- support RSA with SHA-1 or DSA with SHA-1.

   - SHOULD- support RSA with MD5.

See Section 4.1 for info on key size and algorithm references. ๐Ÿ—๏ธ

Note that S/MIME v3.1 clients support verifying id-dsa-with-sha1 and rsaEncryption, and they might not implement sha256withRSAEncryption. ๐Ÿ™ƒ Note that S/MIME v3 clients might only implement signing or signature verification using id-dsa-with-sha1, and they might also use id-dsa as an AlgorithmIdentifier in this field. Receiving clients SHOULD recognize id-dsa as equivalent to id-dsa-with-sha1, and sending clients MUST use id-dsa-with-sha1 if they use that algorithm. ๐Ÿซฃ Also note that S/MIME v2 clients are only required to verify digital signatures using the rsaEncryption algorithm with SHA-1 or MD5, and they might not implement id-dsa-with-sha1 or id-dsa at all. ๐Ÿ‘ต

2.3. KeyEncryptionAlgorithmIdentifier ๐Ÿ”‘

Receiving and sending agents:

   - MUST support RSA Encryption, as specified in [CMSALG].

   - SHOULD+ support RSAES-OAEP, as specified in [RSAOAEP].

   - SHOULD- support DH ephemeral-static mode, as specified in
     [CMSALG] and [SP800-57].

When DH ephemeral-static is used, a key wrap algorithm is also specified in the KeyEncryptionAlgorithmIdentifier [CMS]. The underlying encryption functions for the key wrap and content encryption algorithm ([CMSALG] and [CMSAES]) and the key sizes for the two algorithms MUST be the same (for example, AES-128 key wrap algorithm with AES-128 content encryption algorithm). ๐ŸŽ€ As AES-128 CBC is the mandatory-to-implement content encryption algorithm, the AES-128 key wrap algorithm MUST also be supported when DH ephemeral-static is used. ๐Ÿ’–

Note that S/MIME v3.1 clients might only implement key encryption and decryption using the rsaEncryption algorithm. Note that S/MIME v3 clients might only implement key encryption and decryption using the Diffie-Hellman algorithm. And S/MIME v2 clients are only capable of decrypting content-encryption keys using the rsaEncryption algorithm. ๐Ÿงš

2.4. General Syntax ๐Ÿ“œ

There are several CMS content types. Of these, only the Data, SignedData, EnvelopedData, and CompressedData content types are currently used for S/MIME. โœจ

2.4.1. Data Content Type ๐Ÿฆ‹

Sending agents MUST use the id-data content type identifier to identify the "inner" MIME message content. For example, when applying a digital signature to MIME data, the CMS SignedData encapContentInfo eContentType MUST include the id-data object identifier, and the media type MUST be stored in the SignedData encapContentInfo eContent OCTET STRING (unless the sending agent is using multipart/signed, in which case the eContent is absent, per Section 3.4.3 of this document). ๐Ÿ™Œ As another example, when applying encryption to MIME data, the CMS EnvelopedData encryptedContentInfo contentType MUST include the id-data object identifier, and the encrypted MIME content MUST be stored in the EnvelopedData encryptedContentInfo encryptedContent OCTET STRING. ๐Ÿ”

2.4.2. SignedData Content Type โœ๏ธ

Sending agents MUST use the SignedData content type to apply a digital signature to a message or, in a degenerate case where there is no signature information, to convey certificates. Applying a signature to a message provides authentication, message integrity, and non-repudiation of origin. ๐Ÿซถ

2.4.3. EnvelopedData Content Type ๐Ÿ’Œ

This content type is used to apply data confidentiality to a message. A sender needs to have access to a public key for each intended message recipient to use this service. ๐Ÿคซ

2.4.4. CompressedData Content Type ๐Ÿ—œ๏ธ

This content type is used to apply data compression to a message. This content type does not provide authentication, message integrity, non-repudiation, or data confidentiality, and it is only used to reduce the message's size. โš ๏ธ

See Section 3.6 for further guidance on using this type alongside other CMS types. ๐Ÿ‘€

2.5. Attributes and the SignerInfo Type ๐Ÿท๏ธ

The SignerInfo type allows the inclusion of unsigned and signed attributes along with a signature. โœจ

Receiving agents MUST be able to handle zero or one instance of each of the signed attributes listed here. Sending agents SHOULD generate one instance of each of the following signed attributes in each S/MIME message:

  • Signing Time (section (Section 2.5.1 in this document)
  • SMIME Capabilities (section (Section 2.5.2 in this document)
  • Encryption Key Preference (section (Section 2.5.3 in this document)
  • Message Digest (section (Section 11.2 in [CMS])
  • Content Type (section (Section 11.1 in [CMS])

Further, receiving agents SHOULD be able to handle zero or one instance of the signingCertificate and signingCertificatev2 signed attributes, as defined in Section 5 of RFC 2634 [ESS] and Section 3 of RFC 5035 [ESS]. ๐Ÿฅฐ

Sending agents SHOULD generate one instance of the signingCertificate or signingCertificatev2 signed attribute in each SignerInfo structure. ๐Ÿ“

Additional attributes and values for these attributes might be defined in the future. Receiving agents SHOULD handle attributes or values that they do not recognize in a graceful manner. ๐ŸŒท

Interactive sending agents that include signed attributes not listed here SHOULD display those attributes to the user, so the user is aware of all of the data being signed. ๐Ÿ‘€๐Ÿ’•

2.5.1. Signing Time Attribute โฐ

okay so the signing-time attribute is how we tell everyone when a message got signed ๐Ÿ•ฐ๏ธ๐Ÿ’– The originator usually picks the time of signing, so it's only as trustworthy as they are. take it with a grain of salt, bestie ๐Ÿง‚

Sending agents MUST encode signing time through the year 2049 as UTCTime, and signing times in 2050 or later MUST be encoded as GeneralizedTime ๐Ÿ“… When the UTCTime CHOICE is used, S/MIME agents MUST interpret the year field (YY) like this:

If YY is greater than or equal to 50, the year is interpreted as 19YY; if YY is less than 50, the year is interpreted as 20YY.

Receiving agents MUST be able to process signing-time attributes that are encoded in either UTCTime or GeneralizedTime ๐Ÿซถ


2.5.2. SMIME Capabilities Attribute ๐ŸŽ€

the SMIMECapabilities attribute is basically a little flex list ๐Ÿ’… It includes signature algorithms (like "sha256WithRSAEncryption"), symmetric algorithms (like "AES-128 CBC"), and key encipherment algorithms (like "rsaEncryption"). It also has identifiers for other optional features, like binary encoding and compression โœจ It was designed to be flexible and extensible, so later on we can add new stuff, like certificates, without breaking current clients. no cap, that's iconic ๐Ÿฆ‹

If present, the SMIMECapabilities attribute MUST be a SignedAttribute; it MUST NOT be an UnsignedAttribute. CMS defines SignedAttributes as a SET OF Attribute. The SignedAttributes in a signerInfo MUST NOT include multiple instances of the SMIMECapabilities attribute. CMS defines the ASN.1 syntax for Attribute to include attrValues SET OF AttributeValue. A SMIMECapabilities attribute MUST only include a single instance of AttributeValue. There MUST NOT be zero or multiple instances of AttributeValue present in the attrValues SET OF AttributeValue. very strict, very important ๐Ÿ‘‘

The semantics here are a partial list of what the announcing client can support. A client does not have to list every capability it supports, and it doesn't need to list all of them so the list doesn't get too long ๐Ÿ™ˆ In a SMIMECapabilities attribute, the object identifiers (OIDs) are listed in order of preference, but they SHOULD be separated logically by category (signature algorithms, symmetric algorithms, key encipherment algorithms, etc.) ๐Ÿ—‚๏ธ

The structure is built for simple table lookups and binary comparisons so matches are easy to spot ๐Ÿ‘€ For instance, the DER-encoding for the SMIMECapability for AES-128 CBC MUST be identically encoded regardless of the implementation. Because of that identical-encoding requirement, anyone documenting algorithms for this attribute SHOULD explicitly document the correct byte sequence for the common cases ๐Ÿงพ

For any capability, the associated parameters for the OID MUST specify all of the parameters needed to tell apart two instances of the same algorithm ๐Ÿ”

The OIDs for algorithms SHOULD use the same OID as the actual algorithm, except when the algorithm's usage is ambiguous from the OID. For example, in an earlier specification, rsaEncryption was ambiguous because it could mean either a signature algorithm or a key encipherment algorithm ๐Ÿฅด If an OID is ambiguous, the maintainer of the registered SMIMECapabilities list has to arbitrate which type of algorithm gets the OID, and a new OID MUST be allocated under the smimeCapabilities OID to cover the other use ๐Ÿงš

The registered SMIMECapabilities list specifies parameters for OIDs that need them, most notably key lengths for variable-length symmetric ciphers ๐Ÿ”‘ If there are no differentiating parameters for a particular OID, the parameters MUST be omitted, and MUST NOT be encoded as NULL. More values for the SMIMECapabilities attribute might be defined in the future. Receiving agents MUST handle a SMIMECapabilities object that has values it does not recognize in a graceful manner ๐Ÿซง

Section 2.7.1 explains a strategy for caching capabilities ๐Ÿ’œ


2.5.3. Encryption Key Preference Attribute ๐Ÿ”

the encryption key preference attribute lets the signer clearly say which of their certificates holds their preferred encryption key ๐Ÿ’Œ It's designed to help out with clients that use separate keys for encryption and signing. Anyone looking at it can tell which listed certificate is the right one to encrypt a session key for future encrypted messages ๐Ÿฆ‹

If present, the SMIMEEncryptionKeyPreference attribute MUST be a SignedAttribute; it MUST NOT be an UnsignedAttribute. CMS defines SignedAttributes as a SET OF Attribute. The SignedAttributes in a signerInfo MUST NOT include multiple instances of the SMIMEEncryptionKeyPreference attribute. CMS defines the ASN.1 syntax for Attribute to include attrValues SET OF AttributeValue. A SMIMEEncryptionKeyPreference attribute MUST only include a single instance of AttributeValue. There MUST NOT be zero or multiple instances of AttributeValue present in the attrValues SET OF AttributeValue. ๐Ÿ™…โ€โ™€๏ธ

The sending agent SHOULD include the referenced certificate in the set of certificates included in the signed message if this attribute is used. The certificate MAY be omitted if it has already been made available to the receiving agent ๐Ÿ“จ Sending agents SHOULD use this attribute if the commonly used or preferred encryption certificate is not the same as the certificate used to sign the message ๐ŸŒธ

Receiving agents SHOULD store the preference data if the signature on the message is valid and the signing time is greater than the currently stored value. (Just like with SMIMECapabilities, the clock skew SHOULD be checked, and the data not used if the skew is too great โณ) Receiving agents SHOULD respect the sender's encryption key preference attribute if possible. Still, this is only a preference, so the receiving agent can use any certificate that is valid when replying to the sender ๐Ÿซถ

Section 2.7.1 explains a strategy for caching preference data ๐Ÿง 

2.5.3.1. Selection of Recipient Key Management Certificate ๐Ÿ—๏ธ

so, to figure out which key management certificate to use when sending a future CMS EnvelopedData message to a particular recipient, the following steps SHOULD be followed:

  • If an SMIMEEncryptionKeyPreference attribute is found in a SignedData object received from the desired recipient, this identifies the X.509 certificate that SHOULD be used as the X.509 key management certificate for the recipient ๐ŸŽฏ
  • If an SMIMEEncryptionKeyPreference attribute is not found in a SignedData object received from the desired recipient, the set of X.509 certificates SHOULD be searched for an X.509 certificate with the same subject name as the signer of an X.509 certificate that can be used for key management ๐Ÿ”Ž
  • Or use some other method of determining the user's key management key. If an X.509 key management certificate is not found, then encryption cannot be done with the signer of the message ๐Ÿšซ If multiple X.509 key management certificates are found, the S/MIME agent can make an arbitrary choice between them ๐ŸŽฒ

2.6. SignerIdentifier SignerInfo Type ๐Ÿชช

S/MIME v3.2 implementations MUST support both issuerAndSerialNumber and subjectKeyIdentifier. Messages that use the subjectKeyIdentifier choice cannot be read by S/MIME v2 clients ๐Ÿ™ˆ

It's important to know that some certificates use a subjectKeyIdentifier value that isn't suitable for uniquely identifying a certificate ๐Ÿ˜ฌ Implementations MUST be prepared for multiple certificates, possibly for different entities, to have the same subjectKeyIdentifier value, and MUST be prepared to try each matching certificate during signature verification before reporting an error condition ๐Ÿ”


2.7. ContentEncryptionAlgorithmIdentifier ๐Ÿ”’

Sending and receiving agents:

  • MUST support encryption and decryption with AES-128 CBC [CMSAES].
  • SHOULD+ support encryption and decryption with AES-192 CBC and AES-256 CBC [CMSAES].
  • SHOULD- support encryption and decryption with DES EDE3 CBC, hereinafter called "tripleDES" [CMSALG].

2.7.1. Deciding Which Encryption Method to Use ๐Ÿค”

when a sending agent makes an encrypted message, it has to decide which type of encryption to use ๐Ÿ’ญ That decision uses info from the capabilities lists in messages it got from the recipient, plus out-of-band stuff like private agreements, user preferences, legal restrictions, and so on ๐Ÿ“‹

Section 2.5.2 defines a way for a sending agent to optionally announce its decrypting capabilities, in order of preference, among other things ๐Ÿ“ฃ The following method for processing and remembering the encryption capabilities attribute in incoming signed messages SHOULD be used:

  • If the receiving agent has not yet created a list of capabilities for the sender's public key, then, after verifying the signature on the incoming message and checking the timestamp, the receiving agent SHOULD create a new list containing at least the signing time and the symmetric capabilities. ๐Ÿ—’๏ธ
  • If such a list already exists, the receiving agent SHOULD verify that the signing time in the incoming message is greater than the signing time stored in the list, and that the signature is valid. If so, the receiving agent SHOULD update both the signing time and capabilities in the list. Signing-time values that lie far in the future (that is, a greater discrepancy than any reasonable clock skew), or a capabilities list in messages whose signature could not be verified, MUST NOT be accepted ๐Ÿšจ

The list of capabilities SHOULD be stored for future use when creating messages ๐Ÿ’พ

Before sending a message, the sending agent MUST decide whether it is willing to use weak encryption for the particular data in the message โš–๏ธ If the sending agent decides weak encryption is unacceptable for this data, then the sending agent MUST NOT use a weak algorithm. This decision overrides any other decision in this section about which encryption algorithm to use ๐Ÿ‘‘

Sections 2.7.1.1 through 2.7.1.2 describe the decisions a sending agent SHOULD use when deciding which type of encryption will be applied to a message. These rules are ordered, so the sending agent SHOULD make its decision in the order given ๐Ÿชœ


2.7.1.1. Rule 1: Known Capabilities ๐Ÿฅ‡

If the sending agent has received a set of capabilities from the recipient for the message it's about to encrypt, then the sending agent SHOULD use that information by selecting the first capability in the list (that is, the capability most preferred by the intended recipient) that the sending agent knows how to encrypt. The sending agent SHOULD use one of the capabilities in the list if it reasonably expects the recipient to be able to decrypt the message ๐Ÿ’–

2.7.1.2. Rule 2: Unknown Capabilities, Unknown Version of S/MIME ๐ŸŒธ

okay so this one is for when you're basically flying blind ๐Ÿ™ˆ If both of these conditions are met:

  • the sending agent has no knowledge of the encryption capabilities of the recipient, and
  • the sending agent has no knowledge of the version of S/MIME of the recipient,

then the sending agent SHOULD use AES-128, because it's a stronger algorithm and it's required by S/MIME v3.2 ๐Ÿ’ชโœจ If the sending agent chooses not to use AES-128 in this step, it SHOULD use tripleDES.

2.7.2. Choosing Weak Encryption ๐Ÿฅบ

ngl this one is a red flag ๐Ÿšฉ All algorithms that use 40-bit keys are considered by many to be weak encryption. So a sending agent that's controlled by a human SHOULD let the human sender understand the risks of sending data with a weak encryption algorithm before the data goes out ๐Ÿ‘€ It can also possibly let the human switch to a stronger method, like tripleDES or AES. Main character choices only ๐Ÿ‘‘

2.7.3. Multiple Recipients ๐Ÿ‘ฏโ€โ™€๏ธ

If a sending agent is composing an encrypted message to a group of recipients whose encryption capabilities don't all overlap, the sending agent is forced to send more than one message ๐Ÿ˜ญ Please note that if the sending agent sends a message encrypted with a strong algorithm, and then sends the same message encrypted with a weak algorithm, someone watching the communications channel could learn the contents of the strongly encrypted message simply by decrypting the weakly encrypted message. Not okay!! ๐Ÿ™…โ€โ™€๏ธ

3. Creating S/MIME Messages โœจ

This section is where we get into how S/MIME messages actually get made ๐ŸŽ€ S/MIME messages are a combo of MIME bodies and CMS content types. Several media types and several CMS content types get used. The data to be secured is always a canonical MIME entity. That MIME entity, plus other stuff like certificates and algorithm identifiers, gets handed to CMS processing facilities, which produce a CMS object. Finally, the CMS object gets wrapped in MIME. The Enhanced Security Services for S/MIME [ESS] document explains how nested, secured S/MIME messages are formatted. ESS also explains how a triple-wrapped S/MIME message is formatted, using multipart/signed and application/pkcs7-mime for the signatures ๐Ÿงš

S/MIME gives you one format for enveloped-only data, several formats for signed-only data, and several formats for signed and enveloped data ๐ŸŒˆ Having several formats is needed to cover several environments, especially for signed messages. The criteria for choosing among these formats are also described.

The reader of this section is expected to understand MIME as described in [MIME-SPEC] and [MIME-SECURE] ๐Ÿ“š

3.1. Preparing the MIME Entity for Signing, Enveloping, or Compressing ๐Ÿ’–

S/MIME is used to secure MIME entities. A MIME entity can be a sub-part, sub-parts of a message, or the whole message with all its sub-parts. A MIME entity that is the whole message includes only the MIME message headers and MIME body, and does not include the RFC-822 header. Also, S/MIME can be used to secure MIME entities in applications other than Internet mail, which is giving versatile ๐Ÿฆ‹ If protection of the RFC-822 header is required, the use of the message/rfc822 media type is explained later in this section.

The MIME entity that gets secured and described in this section can be thought of as the "inside" MIME entity. It's the "innermost" object in what could be a larger MIME message. Processing "outside" MIME entities into CMS content types is described in Sections 3.2, 3.4, and elsewhere.

The procedure for preparing a MIME entity is given in [MIME-SPEC]. The same procedure is used here, with some additional restrictions when signing. The description of the procedures from [MIME-SPEC] is repeated here, but it's suggested that you read that document for the exact procedure. This section also describes additional requirements ๐Ÿค“

A single procedure is used for creating MIME entities that are going to have any combination of signing, enveloping, and compressing applied. Some additional steps are recommended to defend against known corruptions that can happen during mail transport. These matter especially for clear-signing using the multipart/signed format ๐Ÿ›ก๏ธ It's recommended that these additional steps be performed on enveloped messages, or signed and enveloped messages, so the message can be forwarded to any environment without modification.

These steps are descriptive rather than prescriptive. The implementer is free to use any procedure as long as the result is the same โœจ

Step 1. The MIME entity is prepared according to the local conventions.

Step 2. The leaf parts of the MIME entity are converted to canonical form.

Step 3. Appropriate transfer encoding is applied to the leaves of the MIME entity.

When an S/MIME message is received, the security services on the message are processed, and the result is the MIME entity. That MIME entity is typically passed to a MIME-capable user agent, where it's further decoded and presented to the user or receiving application ๐Ÿ’…

To protect outer, non-content-related message header fields (for instance, the Subject, To, From, and Cc fields), the sending client MAY wrap a full MIME message in a message/rfc822 wrapper, so S/MIME security services can be applied to these header fields ๐Ÿซถ It's up to the receiving client to decide how to present this "inner" header along with the unprotected "outer" header.

When an S/MIME message is received, if the top-level protected MIME entity has a Content-Type of message/rfc822, it can be assumed the intent was to provide header protection ๐Ÿ‘€ This entity SHOULD be presented as the top-level message, taking into account header merging issues as previously discussed.

3.1.1. Canonicalization ๐Ÿงผ

Each MIME entity MUST be converted to a canonical form that is uniquely and unambiguously representable in the environment where the signature is created and in the environment where the signature will be verified. MIME entities MUST be canonicalized for enveloping and compressing as well as signing. Not optional, bestie ๐Ÿ™…โ€โ™€๏ธ

The exact details of canonicalization depend on the actual media type and subtype of an entity, and they aren't described here. Instead, the standard for the particular media type SHOULD be consulted. For example, canonicalization of text/plain is different from canonicalization of audio/basic ๐ŸŽง Other than text types, most types have only one representation regardless of computing platform or environment, which can be considered their canonical representation. In general, canonicalization is performed by the non-security part of the sending agent rather than the S/MIME implementation.

The most common and important canonicalization is for text, which is often represented differently in different environments ๐Ÿ“ MIME entities of major type "text" MUST have both their line endings and character set canonicalized. The line ending MUST be the pair of characters <CR><LF>, and the charset SHOULD be a registered charset [CHARSETS]. The details of the canonicalization are specified in [MIME-SPEC].

Note that some charsets, such as ISO-2022, have multiple representations for the same characters ๐Ÿคฏ When preparing such text for signing, the canonical representation specified for the charset MUST be used.

3.1.2. Transfer Encoding ๐Ÿšš

When generating any of the secured MIME entities below, except for signing using the multipart/signed format, no transfer encoding is required at all. S/MIME implementations MUST be able to deal with binary MIME objects. If no Content-Transfer-Encoding header field is present, the transfer encoding is presumed to be 7BIT ๐Ÿงธ

S/MIME implementations SHOULD however use the transfer encoding described in Section 3.1.3 for all MIME entities they secure. The reason for securing only 7-bit MIME entities, even for enveloped data that isn't exposed to the transport, is that it allows the MIME entity to be handled in any environment without changing it ๐ŸŒธ For example, a trusted gateway might remove the envelope, but not the signature, of a message, and then forward the signed message on to the end recipient so they can verify the signatures directly. If the transport internal to the site isn't 8-bit clean, such as on a wide-area network with a single mail gateway, verifying the signature won't be possible unless the original MIME entity was only 7-bit data ๐Ÿ˜ฉ

S/MIME implementations that "know" that all intended recipients are capable of handling inner (all but the outermost) binary MIME objects SHOULD use binary encoding, as opposed to a 7-bit-safe transfer encoding, for the inner entities. Using a 7-bit-safe encoding (such as base64) would unnecessarily expand the message size ๐Ÿ“ฆ Implementations MAY "know" that recipient implementations are capable of handling inner binary MIME entities either by interpreting the id-cap-preferBinaryInside SMIMECapabilities attribute, by prior agreement, or by other means.

If one or more intended recipients are unable to handle inner binary MIME objects, or if this capability is unknown for any of the intended recipients, S/MIME implementations SHOULD use the transfer encoding described in Section 3.1.3 for all MIME entities they secure ๐Ÿซ 

3.1.3. Transfer Encoding for Signing Using multipart/signed ๐Ÿ“ฎ

If a multipart/signed entity is ever going to be transmitted over the standard Internet SMTP infrastructure, or over other transport that's constrained to 7-bit text, it MUST have transfer encoding applied so that it's represented as 7-bit text. MIME entities that are already 7-bit data need no transfer encoding. Entities such as 8-bit text and binary data can be encoded with quoted-printable or base-64 transfer encoding.

The primary reason for the 7-bit requirement is that the Internet mail transport infrastructure can't guarantee transport of 8-bit or binary data. Even though many segments of the transport infrastructure now handle 8-bit and even binary data, it's sometimes not possible to know whether the transport path is 8-bit clean. If a mail message with 8-bit data were to hit a message transfer agent that can't transmit 8-bit or binary data, the agent has three options, and none of them are acceptable for a clear-signed message ๐Ÿ˜ฑ

  • The agent could change the transfer encoding; this would invalidate the signature.
  • The agent could transmit the data anyway, which would most likely result in the 8th bit being corrupted; this too would invalidate the signature.
  • The agent could return the message to the sender.

[MIME-SECURE] prohibits an agent from changing the transfer encoding of the first part of a multipart/signed message. If a compliant agent that can't transmit 8-bit or binary data encounters a multipart/signed message with 8-bit or binary data in the first part, it would have to return the message to the sender as undeliverable ๐Ÿ’€

3.1.4. Sample Canonical MIME Entity ๐ŸŽ€

okay so this example is a multipart/mixed message that's been through full transfer encoding ๐Ÿ’…. It has a text part and an attachment. The text has characters that aren't US-ASCII, so they NEED transfer encoding (that's the whole point of the example โœจ). The line endings aren't shown, but every line ends in <CR><LF>. The line ending of the MIME headers, the text, and the transfer encoded parts MUST all be <CR><LF> ๐Ÿซถ.

Also, heads up: this is NOT an S/MIME message ๐Ÿ™ˆ.

Content-Type: multipart/mixed; boundary=bar

--bar
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

=A1Hola Michael!

How do you like the new S/MIME specification?

It's generally a good idea to encode lines that begin with
From=20because some mail transport agents will insert a greater-
than (>) sign, thus invalidating the signature.

Also, in some cases it might be desirable to encode any =20
trailing whitespace that occurs on lines in order to ensure =20
that the message signature is not invalidated when passing =20
a gateway that modifies such whitespace (like BITNET). =20

--bar
Content-Type: image/jpeg
Content-Transfer-Encoding: base64

iQCVAwUBMJrRF2N9oWBghPDJAQE9UQQAtl7LuRVndBjrk4EqYBIb3h5QXIX/LC//
jJV5bNvkZIGPIcEmI5iFd9boEgvpirHtIREEqLQRkYNoBActFBZmh9GC3C041WGq
uMbrbxc+nIs1TIKlA08rVi9ig/2Yh7LFrK5Ein57U/W72vgSxLhe/zhdfolT9Brn
HOxEa44b+EI=

--bar--

3.2. The application/pkcs7-mime Media Type ๐Ÿฆ‹

okay this is the application/pkcs7-mime media type, and it's the carrier for CMS content types like EnvelopedData, SignedData, and CompressedData ๐Ÿ’–. We'll get into how to actually build these in the next sections. This part is just the general vibe of the type.

The carried CMS object always contains a MIME entity prepared the way Section 3.1 describes, as long as the eContentType is id-data. Other contents MAY be carried when the eContentType has different values. [ESS] has an example of this with signed receipts ๐Ÿงพ.

Since CMS content types are binary data, base-64 transfer encoding is usually the move, especially with SMTP transport ๐ŸŒธ. Which transfer encoding you use depends on the transport the object is sent through. It's not a property of the media type itself, so don't tie the two together ๐Ÿ™…โ€โ™€๏ธ.

Also, this is giving two layers. The transfer encoding of the CMS object (the "outside" MIME entity) is totally separate from, and unrelated to, the transfer encoding of the MIME entity that the CMS object secures (the "inside" object, described in Section 3.1) โœจ. Keep those two straight, bestie ๐Ÿ’œ.

Because there are several kinds of application/pkcs7-mime objects, a sending agent SHOULD do as much as possible to help a receiving agent know what's inside without making it decode the ASN.1 ๐Ÿ’…. The Content-Type header field of all application/pkcs7-mime objects SHOULD include the optional "smime-type" parameter, which we'll cover in the next sections ๐ŸŽ€.

3.2.1. The name and filename Parameters ๐Ÿ“

so for application/pkcs7-mime, sending agents SHOULD emit the optional "name" parameter on the Content-Type field so older systems can still read it ๐Ÿ•ฐ๏ธ. They SHOULD also emit the optional Content-Disposition field [CONTDISP] with the "filename" parameter ๐Ÿ“Ž. If a sending agent emits those parameters, the value SHOULD be a file name with the right extension:

Media Type                                            File Extension
  application/pkcs7-mime (SignedData, EnvelopedData)      .p7m
  application/pkcs7-mime (degenerate SignedData           .p7c
     certificate management message)
  application/pkcs7-mime (CompressedData)                 .p7z
  application/pkcs7-signature (SignedData)                .p7s

Also, the file name SHOULD be limited to eight characters followed by a three-letter extension ๐Ÿ™ˆ. The eight-character base can be any distinct name, BUT using the base "smime" SHOULD be used to show that the MIME entity is associated with S/MIME ๐Ÿ”.

Why bother? Two reasons, obviously ๐Ÿง . It makes S/MIME objects easier to use as files on disk. It can also carry type info across gateways. Here's the tea โ˜•: when an application/pkcs7-mime entity hits a gateway that has no special S/MIME knowledge, the gateway defaults its media type to application/octet-stream and treats it as a generic attachment. That means the type info is lost ๐Ÿ˜ญ. BUT the suggested filename for an attachment often survives the trip across a gateway. That can help the receiving system figure out which app to hand the attachment to, like a stand-alone S/MIME processing application ๐Ÿฆธโ€โ™€๏ธ. Note that this filename trick is just a convenience for certain environments, not the main event. A proper S/MIME implementation MUST use the media types and MUST NOT rely on the file extensions ๐Ÿšซ.

3.2.2. The smime-type Parameter ๐ŸŒˆ

the application/pkcs7-mime content type defines an optional "smime-type" parameter ๐Ÿ‘‘. Its whole job is to tell you what security was applied (signed or enveloped) and what kind of content is inside ๐ŸŽ. This spec defines these smime-types:

Name                   CMS Type                Inner Content
enveloped-data         EnvelopedData           id-data
signed-data            SignedData              id-data
certs-only             SignedData              none
compressed-data        CompressedData          id-data

To keep things consistent with future specs, these guidelines SHOULD be followed when a new smime-type parameter gets assigned ๐Ÿงฉ:

  1. If both signing and encryption can be applied to the content, then two values SHOULD be assigned: "signed-" and "enveloped-". If only one operation applies, you can leave that prefix off. That's why "certs-only" has no "signed-" prefix: it can only be signed, so "signed-" gets omitted ๐Ÿ’….
  2. A common string SHOULD be assigned for a content OID. We use "data" for the id-data content OID when MIME is the inner content ๐Ÿ’–.
  3. If no common string is assigned, then the common string "OID.<oid>" is recommended. For example, "OID.2.16.840.1.101.3.4.1.2" would be AES-128 CBC ๐Ÿ”‘.

This field is explicitly meant to be a handy hint for mail client apps. It tells them whether a message is "signed" or "enveloped" WITHOUT having to dig into the CMS payload ๐Ÿ•ต๏ธโ€โ™€๏ธโœจ.


3.3. Creating an Enveloped-Only Message ๐Ÿ’Œ

this section explains how to envelope a MIME entity WITHOUT signing it. Important tea ๐Ÿซ–: sending enveloped-but-not-signed messages does NOT give you data integrity ๐Ÿ˜ญ. Someone could swap out the ciphertext in a way that the processed message still looks valid, and the meaning could get changed. Yikes ๐Ÿ’€.

Step 1. The MIME entity to be enveloped gets prepared according to Section 3.1 ๐ŸŽ€.

Step 2. The MIME entity and other required data get processed into a CMS object of type EnvelopedData. Besides encrypting a copy of the content-encryption key for each recipient, a copy of the content-encryption key SHOULD be encrypted for the originator and included in the EnvelopedData (see [CMS], Section 6) ๐Ÿ”.

Step 3. The EnvelopedData object gets wrapped in a CMS ContentInfo object ๐ŸŽ.

Step 4. The ContentInfo object gets inserted into an application/pkcs7-mime MIME entity ๐Ÿฆ‹.

For enveloped-only messages, the smime-type parameter is "enveloped-data" and the file extension is ".p7m" ๐Ÿ’œ.

Here's a sample message:

Content-Type: application/pkcs7-mime; smime-type=enveloped-data;
     name=smime.p7m
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=smime.p7m

rfvbnj756tbBghyHhHUujhJhjH77n8HHGT9HG4VQpfyF467GhIGfHfYT6
7n8HHGghyHhHUujhJh4VQpfyF467GhIGfHfYGTrfvbnjT6jH7756tbB9H
f8HHGTrfvhJhjH776tbB9HG4VQbnj7567GhIGfHfYT6ghyHhHUujpfyF4
0GhIGfHfQbnj756YT64V

3.4. Creating a Signed-Only Message ๐ŸŒธ

there are TWO formats for signed messages in S/MIME, babe ๐Ÿ‘‘:

  • application/pkcs7-mime with SignedData.
  • multipart/signed.

Generally, the multipart/signed form is the preferred one for sending ๐Ÿ’…. Receiving agents MUST be able to handle BOTH โœจ.

3.4.1. Choosing a Format for Signed-Only Messages ๐Ÿง 

there's no hard-and-fast rule for which signed-only format to pick ๐Ÿคทโ€โ™€๏ธ. It depends on the capabilities of ALL the receivers, and on how much it matters that S/MIME-capable receivers can verify the signature versus how much it matters that receivers WITHOUT S/MIME software can view the message ๐Ÿฅน.

Messages signed with the multipart/signed format can always be viewed by the receiver, whether or not they have S/MIME software ๐Ÿ‘€. They can also be viewed whether the receiver uses a MIME-native user agent or gets the message translated by a gateway ๐ŸŒˆ. In this context, "be viewed" means the ability to process the message basically as if it weren't signed at all, including any other MIME structure the message might have ๐Ÿฆ‹.

Messages signed with the SignedData format can't be viewed by a recipient unless they have S/MIME facilities ๐Ÿ™ƒ. BUT the SignedData format protects the content from being changed by benign intermediate agents. Those agents might do line wrapping or content-transfer encoding changes that would break the signature ๐Ÿ˜ญ.

3.4.2. Signing Using application/pkcs7-mime with SignedData ๐Ÿ’–

this signing format uses the application/pkcs7-mime media type. Here are the steps:

Step 1. The MIME entity gets prepared according to Section 3.1 ๐ŸŽ€.

Step 2. The MIME entity and other required data are processed into a CMS object of type SignedData ๐Ÿงพ.

Step 3. The SignedData object gets wrapped in a CMS ContentInfo object ๐ŸŽ.

Step 4. The ContentInfo object gets inserted into an application/pkcs7-mime MIME entity ๐Ÿฆ‹.

For messages using application/pkcs7-mime with SignedData, the smime-type parameter is "signed-data" and the file extension is ".p7m" ๐Ÿ’œ.

Here's a sample message:

Content-Type: application/pkcs7-mime; smime-type=signed-data;
     name=smime.p7m
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=smime.p7m

567GhIGfHfYT6ghyHhHUujpfyF4f8HHGTrfvhJhjH776tbB9HG4VQbnj7
77n8HHGT9HG4VQpfyF467GhIGfHfYT6rfvbnj756tbBghyHhHUujhJhjH
HUujhJh4VQpfyF467GhIGfHfYGTrfvbnjT6jH7756tbB9H7n8HHGghyHh
6YT64V0GhIGfHfQbnj75

3.4.3. Signing Using the multipart/signed Format ๐Ÿฆ‹

this format is a clear-signing format โœจ. Recipients WITHOUT any S/MIME or CMS processing facilities can still view the message ๐Ÿ‘€. It uses the multipart/signed media type described in [MIME-SECURE] ๐Ÿ’…. The multipart/signed media type has two parts ๐ŸŽ€. The first part holds the MIME entity that's signed. The second part holds the "detached signature" CMS SignedData object, where the encapContentInfo eContent field is absent ๐Ÿซถ.

3.4.3.1. The application/pkcs7-signature Media Type

okay bestie, this media type is always carrying a CMS ContentInfo wrapping exactly one CMS object of type SignedData ๐ŸŽ€ The SignedData encapContentInfo eContent field MUST be absent ๐Ÿ™ˆ and the signerInfos field holds the signatures for the MIME entity โœจ

Super important: the file extension for signed-only messages using application/pkcs7-signature is .p7s ๐Ÿฆ‹

3.4.3.2. Creating a multipart/signed Message

Let's walk through the steps, it's giving recipe energy ๐Ÿ“

  • Step 1. The MIME entity to be signed is prepared according to Section 3.1, taking special care for clear-signing ๐Ÿ’…
  • Step 2. The MIME entity is presented to CMS processing so you get an object of type SignedData where the encapContentInfo eContent field is absent ๐Ÿงš
  • Step 3. The MIME entity goes into the first part of a multipart/signed message with no processing other than what's described in Section 3.1 ๐ŸŒธ
  • Step 4. Transfer encoding gets applied to the "detached signature" CMS SignedData object, and it gets tucked into a MIME entity of type application/pkcs7-signature ๐Ÿซถ
  • Step 5. That application/pkcs7-signature MIME entity goes into the second part of the multipart/signed entity ๐Ÿ‘‘

The multipart/signed Content-Type has two required parameters: the protocol parameter and the micalg parameter ๐Ÿ’œ

The protocol parameter MUST be "application/pkcs7-signature" ๐Ÿ”ฅ Quotation marks are required around it, because MIME requires that the "/" character in the parameter value MUST be quoted. Lowkey a lot of MUSTs, but that's the vibe ๐Ÿ’€

The micalg parameter allows for one-pass processing when the signature is being verified โœจ Its value depends on the message digest algorithm(s) used in the calculation of the Message Integrity Check. If multiple message digest algorithms are used, they MUST be separated by commas per [MIME-SECURE]. The values to be placed in the micalg parameter SHOULD be from the following:

      Algorithm   Value Used

      MD5         md5
      SHA-1       sha-1
      SHA-224     sha-224
      SHA-256     sha-256
      SHA-384     sha-384
      SHA-512     sha-512
      Any other   (defined separately in algorithm profile or "unknown"
                   if not defined)

(Historical note: some early implementations of S/MIME emitted and expected "rsa-md5", "rsa-sha1", and "sha1" for the micalg parameter ๐Ÿ™ˆ)

Receiving agents SHOULD be able to recover gracefully from a micalg parameter value that they do not recognize ๐ŸŒˆ Future names for this parameter will be consistent with the IANA "Hash Function Textual Names" registry ๐Ÿฆ‹

3.4.3.3. Sample multipart/signed Message

Here's what a full example looks like, iykyk ๐ŸŽ€

       Content-Type: multipart/signed;
          protocol="application/pkcs7-signature";
          micalg=sha1; boundary=boundary42

       --boundary42
       Content-Type: text/plain

       This is a clear-signed message.

       --boundary42
       Content-Type: application/pkcs7-signature; name=smime.p7s
       Content-Transfer-Encoding: base64
       Content-Disposition: attachment; filename=smime.p7s

       ghyHhHUujhJhjH77n8HHGTrfvbnj756tbB9HG4VQpfyF467GhIGfHfYT6
       4VQpfyF467GhIGfHfYT6jH77n8HHGghyHhHUujhJh756tbB9HGTrfvbnj
       n8HHGTrfvhJhjH776tbB9HG4VQbnj7567GhIGfHfYT6ghyHhHUujpfyF4
       7GhIGfHfYT64VQbnj756

      --boundary42--

The content that gets digested (the first part of the multipart/signed) is made up of these bytes ๐Ÿงš

   43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 74 65 78 74 2f 70 6c 61 69
   6e 0d 0a 0d 0a 54 68 69 73 20 69 73 20 61 20 63 6c 65 61 72 2d 73 69
   67 6e 65 64 20 6d 65 73 73 61 67 65 2e 0d 0a

3.5. Creating a Compressed-Only Message

This section explains the format for compressing a MIME entity ๐Ÿ—œ๏ธ Heads up, versions of S/MIME prior to version 3.1 did not specify any use of CompressedData, and will not recognize it ๐Ÿ’€ The use of a capability to indicate the ability to receive CompressedData is described in [CMSCOMPR] and is the preferred method for compatibility โœจ

  • Step 1. The MIME entity to be compressed is prepared according to Section 3.1 ๐Ÿ’…
  • Step 2. The MIME entity and other required data are processed into a CMS object of type CompressedData ๐ŸŒธ
  • Step 3. The CompressedData object gets wrapped in a CMS ContentInfo object ๐ŸŽ€
  • Step 4. The ContentInfo object goes into an application/pkcs7-mime MIME entity ๐Ÿ‘‘

The smime-type parameter for compressed-only messages is "compressed-data" and the file extension is .p7z ๐Ÿฆ‹ A sample message would look like this:

Content-Type: application/pkcs7-mime; smime-type=compressed-data;
   name=smime.p7z
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=smime.p7z

rfvbnj756tbBghyHhHUujhJhjH77n8HHGT9HG4VQpfyF467GhIGfHfYT6
7n8HHGghyHhHUujhJh4VQpfyF467GhIGfHfYGTrfvbnjT6jH7756tbB9H
f8HHGTrfvhJhjH776tbB9HG4VQbnj7567GhIGfHfYT6ghyHhHUujpfyF4
0GhIGfHfQbnj756YT64V

3.6. Multiple Operations

The signed-only, enveloped-only, and compressed-only MIME formats can be nested ๐Ÿช† This works because these formats are all MIME entities that encapsulate other MIME entities โœจ

An S/MIME implementation MUST be able to receive and process arbitrarily nested S/MIME within reasonable resource limits of the recipient computer ๐Ÿ’–

It's possible to apply any of the signing, encrypting, and compressing operations in any order, and it's up to the implementer and the user to choose ๐Ÿงฉ When signing first, the signatories are then securely obscured by the enveloping. When enveloping first, the signatories are exposed, but it's possible to verify signatures without removing the enveloping. This can be useful in an environment where automatic signature verification is desired, since no private key material is required to verify a signature ๐Ÿ”

There are security ramifications to choosing whether to sign first or encrypt first ๐Ÿ˜ญ A recipient of a message that is encrypted and then signed can validate that the encrypted block was unaltered, but cannot determine any relationship between the signer and the unencrypted contents of the message. A recipient of a message that is signed then encrypted can assume that the signed message itself has not been altered, but that a careful attacker could have changed the unauthenticated portions of the encrypted message. Be careful with this one, it's lowkey dramatic ๐Ÿ’€

When using compression, keep these guidelines in mind ๐ŸŒˆ

  • Compression of binary encoded encrypted data is discouraged, since it will not yield significant compression. Base64 encrypted data could very well benefit, however.
  • If a lossy compression algorithm is used with signing, you will need to compress first, then sign.

3.7. Creating a Certificate Management Message

The certificate management message or MIME entity is used to transport certificates and/or Certificate Revocation Lists, such as in response to a registration request ๐Ÿ“œ

  • Step 1. The certificates and/or Certificate Revocation Lists are made available to the CMS generating process that creates a CMS object of type SignedData. The SignedData encapContentInfo eContent field MUST be absent and signerInfos field MUST be empty ๐Ÿ™ˆ
  • Step 2. The SignedData object is wrapped in a CMS ContentInfo object ๐ŸŽ€
  • Step 3. The ContentInfo object is enclosed in an application/pkcs7-mime MIME entity ๐Ÿ’…

The smime-type parameter for a certificate management message is "certs-only", and the file extension for this type of message is .p7c ๐Ÿฆ‹

3.8. Registration Requests

A sending agent that signs messages MUST have a certificate for the signature so that a receiving agent can verify the signature ๐Ÿ”‘ There are many ways of getting certificates, such as through an exchange with a certification authority, through a hardware token or diskette, and so on ๐Ÿงš

S/MIME v2 [SMIMEv2] specified a method for "registering" public keys with certificate authorities using an application/pkcs10 body part. Since then, the IETF PKIX Working Group has developed other methods for requesting certificates. However, S/MIME v3.2 does not require a particular certificate request mechanism ๐ŸŒธ

3.9. Identifying an S/MIME Message

Because S/MIME takes into account interoperation in non-MIME environments, several different mechanisms are used to carry the type information, which makes it a bit tricky to identify S/MIME messages ๐Ÿฅด The table below lists criteria for determining whether or not a message is an S/MIME message. A message counts as an S/MIME message if it matches any of the criteria listed below โœจ

The file suffix in the table below comes from the "name" parameter in the Content-Type header field, or the "filename" parameter on the Content-Disposition header field. These parameters that give the file suffix are not listed below as part of the parameter section ๐ŸŽ€

   Media type:  application/pkcs7-mime
   parameters:  any
   file suffix: any

   Media type:  multipart/signed
   parameters:  protocol="application/pkcs7-signature"
   file suffix: any

   Media type:  application/octet-stream
   parameters:  any
   file suffix: p7m, p7s, p7c, p7z

4. Certificate Processing โœจ

A receiving agent MUST provide some certificate retrieval mechanism so it can gain access to certificates for recipients of digital envelopes ๐Ÿ—๏ธ This specification doesn't cover how S/MIME agents handle certificates, only what they do after a certificate has been validated or rejected. S/MIME certificate issues are covered in [CERT32] ๐Ÿ“–

At a minimum, for initial S/MIME deployment, a user agent could automatically generate a message to an intended recipient asking for that recipient's certificate in a signed return message ๐Ÿ’Œ Receiving and sending agents SHOULD also provide a mechanism that lets a user "store and protect" certificates for correspondents, in such a way as to guarantee their later retrieval ๐Ÿซถ

4.1. Key Pair Generation

All generated key pairs MUST be generated from a good source of non-deterministic random input [RANDOM], and the private key MUST be protected in a secure fashion ๐Ÿ”

An S/MIME user agent MUST NOT generate asymmetric keys less than 512 bits for use with the RSA or DSA signature algorithms ๐Ÿšซ

For 512-bit RSA with SHA-1, see [CMSALG] and [FIPS186-2] without Change Notice 1. For 512-bit RSA with SHA-256, see [CMS-SHA2] and [FIPS186-2] without Change Notice 1. For 1024-bit through 2048-bit RSA with SHA-256, see [CMS-SHA2] and [FIPS186-2] with Change Notice 1. The first reference provides the signature algorithm's object identifier, and the second provides the signature algorithm's definition ๐ŸŒˆ

For 512-bit DSA with SHA-1, see [CMSALG] and [FIPS186-2] without Change Notice 1. For 512-bit DSA with SHA-256, see [CMS-SHA2] and [FIPS186-2] without Change Notice 1. For 1024-bit DSA with SHA-1, see [CMSALG] and [FIPS186-2] with Change Notice 1. For 1024-bit and above DSA with SHA-256, see [CMS-SHA2] and [FIPS186-3]. The first reference provides the signature algorithm's object identifier and the second provides the signature algorithm's definition ๐Ÿงš

For RSASSA-PSS with SHA-256, see [RSAPSS]. For 1024-bit DH, see [CMSALG]. For 1024-bit and larger DH, see [SP800-56A]; regardless, use the KDF, which is from X9.42, specified in [CMSALG]. For RSAES-OAEP, see [RSAOAEP] ๐Ÿ’œ

4.2. Signature Generation

Okay bestie, when an S/MIME agent makes a signature with RSA, RSASSA-PSS, or DSA, the key size decides how strict things get ๐Ÿ’…โœจ Here's the lineup for generated signatures:

           key size <= 1023 : SHOULD NOT (see Security Considerations)
   1024 <= key size <= 2048 : SHOULD     (see Security Considerations)
   2048 <  key size         : MAY        (see Security Considerations)

4.3. Signature Verification

Now the receiving side ๐Ÿซถ When S/MIME receiving agents verify RSA, RSASSA-PSS, or DSA signatures, the same key size ranges come back with their own rules:

           key size <= 1023 : MAY        (see Security Considerations)
   1024 <= key size <= 2048 : MUST       (see Security Considerations)
   2048 <  key size         : MAY        (see Security Considerations)

4.4. Encryption

Encryption time ๐Ÿ” This is the part where an S/MIME agent is setting up keys for content encryption with the RSA, RSA-OAEP, and DH algorithms. Same key size bands, so lock in:

           key size <= 1023 : SHOULD NOT (see Security Considerations)
   1024 <= key size <= 2048 : SHOULD     (see Security Considerations)
   2048 <  key size         : MAY        (see Security Considerations)

4.5. Decryption

And the flip side, decryption ๐Ÿฆ‹ This covers an S/MIME agent establishing keys for content decryption with the RSA, RSAES-OAEP, and DH algorithms. The table is shaped the same way:

           key size <= 1023 : MAY        (see Security Considerations)
   1024 <= key size <= 2048 : MUST       (see Security Considerations)
   2048 <  key size         : MAY        (see Security Considerations)

5. IANA Considerations ๐Ÿ“‹

Okay so this part is the paperwork ๐Ÿ“ The info here updates the media type registration for application/pkcs7-mime and application/pkcs7-signature so they point at this document instead of RFC 2311. Also, other documents are totally allowed to define extra MIME media types for S/MIME, so no one's locked in ๐ŸŒˆ

5.1. Media Type for application/pkcs7-mime

Here's the registration template for application/pkcs7-mime ๐ŸŽ€

   Type name: application

   Subtype Name: pkcs7-mime

   Required Parameters: NONE
   Optional Parameters: smime-type/signed-data
                        smime-type/enveloped-data
                        smime-type/compressed-data
                        smime-type/certs-only
                        name

   Encoding Considerations: See Section 3 of this document

   Security Considerations: See Section 6 of this document

   Interoperability Considerations: See Sections 1-6 of this document

   Published Specification: RFC 2311, RFC 2633, and this document

   Applications that use this media type: Security applications

   Additional information: NONE

   Person & email to contact for further information:
      S/MIME working group chairs smime-chairs@tools.ietf.org

   Intended usage: COMMON

   Restrictions on usage: NONE

   Author: Sean Turner

   Change Controller: S/MIME working group delegated from the IESG

5.2. Media Type for application/pkcs7-signature

And the signature sibling ๐Ÿฆข Same energy, different subtype:

   Type name: application

   Subtype Name: pkcs7-signature

   Required Parameters: NONE

   Optional Parameters: NONE

   Encoding Considerations: See Section 3 of this document

   Security Considerations: See Section 6 of this document

   Interoperability Considerations: See Sections 1-6 of this document

   Published Specification: RFC 2311, RFC 2633, and this document

   Applications that use this media type: Security applications
   Additional information: NONE

   Person & email to contact for further information:
      S/MIME working group chairs smime-chairs@tools.ietf.org

   Intended usage: COMMON

   Restrictions on usage: NONE

   Author: Sean Turner

   Change Controller: S/MIME working group delegated from the IESG

6. Security Considerations ๐Ÿšจ

Okay, this section is the serious one, so grab a snack and pay attention ๐Ÿ˜ญ๐Ÿ”ฅ Cryptographic algorithms get broken or weakened over time. That's just life ๐Ÿ’€ So implementers and users need to keep checking that the algorithms in this document still give the security level they're supposed to. The IETF may put out documents now and then about the current state of the art. A few examples:

  • The Million Message Attack described in RFC 3218 [MMA].
  • The Diffie-Hellman "small-subgroup" attacks described in RFC 2785 [DHSUB].
  • The attacks against hash algorithms described in RFC 4270 [HASH-ATTACK].

This spec uses Public-Key Cryptography technologies, and it assumes the private key is protected so nobody unauthorized can access or change it ๐Ÿ”‘ Super important, no cap.

Now the value question ๐Ÿง  It's basically impossible for most people or software to estimate how much a message's content is worth. It's also impossible to estimate what it actually costs to recover encrypted content made with a key of a given size. And figuring out the cost of a failed decryption, when a recipient can't process the content, is pretty tricky too. So picking key sizes (or picking whether to just send plaintext) is hard for most people or software to judge. BUT decisions like these get made all the time, so this spec gives a framework for using those estimates when choosing algorithms ๐ŸŒธ

The 2048-bit RSA key size in this spec was picked to provide at least 100 bits of security. The key sizes that have to be supported to conform are considered appropriate for the Internet, based on [STRENGTH]. Of course, some environments, like financial and medical systems, may choose different key sizes. For that reason, an implementation MAY support key sizes beyond the ones recommended here ๐Ÿ’–

Receiving agents that validate signatures, and sending agents that encrypt messages, need to be careful about cryptographic processing cost when they use keys bigger than the ones mandated here. An attacker could send certificates with keys that cause excessive processing, for example keys bigger than the mandated sizes, and that could swamp the processing element ๐Ÿ˜ฑ Agents that use such keys without first validating the certificate to a trust anchor are advised to have some kind of cryptographic resource management system to stop these attacks.

Using weak cryptography in S/MIME offers little real security over sending plaintext. Still, other S/MIME features, like the specification of AES and the ability to announce stronger cryptographic capabilities to the people you talk to, let senders create messages that use strong encryption โœจ Using weak cryptography is never recommended unless the only alternative is no cryptography at all.

RSA and DSA keys under 1024 bits are now considered by many experts to be cryptographically insecure (thanks to advances in computing power), and they should no longer be used to protect messages ๐Ÿ™ˆ These keys used to be considered secure, so processing previously received signed and encrypted mail will often mean dealing with weak keys. Implementations that want to support previous versions of S/MIME or process old messages need to weigh the security risks from smaller key sizes (like spoofed messages) against the costs of denial of service. If an implementation supports verifying digital signatures made with RSA and DSA keys under 1024 bits, it MUST warn the user โš ๏ธ Implementers should consider giving different warnings for newly received messages and previously stored ones. Server implementations (like secure mail list servers), where user warnings aren't appropriate, SHOULD reject messages with weak signatures.

Heads up, bestie: multiple active key pairs can belong to one individual. Implementers SHOULD be aware of this. For example, one key pair can handle confidentiality while a different key pair handles digital signatures ๐Ÿงš

Now the sneaky one ๐Ÿ•ต๏ธโ€โ™€๏ธ If a sending agent sends the same message using different strengths of cryptography, an attacker watching the channel might be able to work out the contents of the strongly encrypted version by decrypting the weakly encrypted one. In other words, a sender SHOULD NOT send a copy of a message using weaker cryptography than they used for the original ๐Ÿ’…

Modification of the ciphertext can go undetected if authentication isn't also used. That's what happens when EnvelopedData is sent without being wrapped in SignedData, or without SignedData being enclosed within it ๐Ÿ˜ฌ

If an implementation cares about compliance with National Institute of Standards and Technology (NIST) key size recommendations, check out [SP800-57] ๐Ÿ“

Last one, and it's a big one ๐Ÿ‘‘ If messaging environments use the fact that a message is signed to change how the message gets processed (think running rules or UI display hints), and they do this without first verifying that the message is actually signed and knowing the state of the signature, that can lead to incorrect handling of the message. Visual indicators on messages may need the signature validation code checked periodically if the indicator is supposed to show the current status of a message. Periodt ๐Ÿ’€๐Ÿ’…


7. References ๐Ÿ“š

7.1. Reference Conventions

Last stop, the citation key cheat sheet ๐ŸŽ€ Here's what each bracketed short name stands for:

[CMS] refers to [RFC5652].

[ESS] refers to [RFC2634] and [RFC5035].

[MIME] refers to [RFC2045], [RFC2046], [RFC2047], [RFC2049], [RFC4288], and [RFC4289].

[SMIMEv2] refers to [RFC2311], [RFC2312], [RFC2313], [RFC2314], and [RFC2315].

[SMIMEv3] refers to [RFC2630], [RFC2631], [RFC2632], [RFC2633], [RFC2634], and [RFC5035].

[SMIMv3.1] refers to [RFC2634], [RFC3850], [RFC3851], [RFC3852], and [RFC5035] ๐Ÿฆ‹

7.2. Normative References ๐Ÿ“šโœจ

okay so these are the docs the spec leans on hard, the must-reads ๐Ÿ’… bestie, go through the list

  • [CERT32] Ramsdell, B. and S. Turner, "Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.2 Certificate Handling", RFC 5750, January 2010.
  • [CHARSETS] Character sets assigned by IANA. See http://www.iana.org/assignments/character-sets.
  • [CMSAES] Schaad, J., "Use of the Advanced Encryption Standard (AES) Encryption Algorithm in Cryptographic Message Syntax (CMS)", RFC 3565, July 2003.
  • [CMSALG] Housley, R., "Cryptographic Message Syntax (CMS) Algorithms", RFC 3370, August 2002.
  • [CMSCOMPR] Gutmann, P., "Compressed Data Content Type for Cryptographic Message Syntax (CMS)", RFC 3274, June 2002.
  • [CMS-SHA2] Turner, S., "Using SHA2 Algorithms with Cryptographic Message Syntax", RFC 5754, January 2010.
  • [CONTDISP] Troost, R., Dorner, S., and K. Moore, Ed., "Communicating Presentation Information in Internet Messages: The Content-Disposition Header Field", RFC 2183, August 1997.
  • [FIPS186-2] National Institute of Standards and Technology (NIST), "Digital Signature Standard (DSS)", FIPS Publication 186-2, January 2000. [With Change Notice 1].
  • [FIPS186-3] National Institute of Standards and Technology (NIST), FIPS Publication 186-3: Digital Signature Standard, June 2009.
  • [MIME-SECURE] Galvin, J., Murphy, S., Crocker, S., and N. Freed, "Security Multiparts for MIME: Multipart/Signed and Multipart/Encrypted", RFC 1847, October 1995.
  • [MUSTSHOULD] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.
  • [RANDOM] Eastlake, D., 3rd, Schiller, J., and S. Crocker, "Randomness Requirements for Security", BCP 106, RFC 4086, June 2005.
  • [RFC2045] Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies", RFC 2045, November 1996.
  • [RFC2046] Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types", RFC 2046, November 1996.
  • [RFC2047] Moore, K., "MIME (Multipurpose Internet Mail Extensions) Part Three: Message Header Extensions for Non-ASCII Text", RFC 2047, November 1996.
  • [RFC2049] Freed, N. and N. Borenstein, "Multipurpose Internet Mail Extensions (MIME) Part Five: Conformance Criteria and Examples", RFC 2049, November 1996.
  • [RFC2634] Hoffman, P. Ed., "Enhanced Security Services for S/MIME", RFC 2634, June 1999.
  • [RFC4288] Freed, N. and J. Klensin, "Media Type Specifications and Registration Procedures", BCP 13, RFC 4288, December 2005.
  • [RFC4289] Freed, N. and J. Klensin, "Multipurpose Internet Mail Extensions (MIME) Part Four: Registration Procedures", BCP 13, RFC 4289, December 2005.
  • [RFC5035] Schaad, J., "Enhanced Security Services (ESS) Update: Adding CertID Algorithm Agility", RFC 5035, August 2007.
  • [RFC5652] Housley, R., "Cryptographic Message Syntax (CMS)", RFC 5652, September 2009.
  • [RSAOAEP] Housley, R. "Use of the RSAES-OAEP Key Transport Algorithm in the Cryptographic Message Syntax (CMS)", RFC 3560, July 2003.
  • [RSAPSS] Schaad, J., "Use of the RSASSA-PSS Signature Algorithm in Cryptographic Message Syntax (CMS)", RFC 4056, June 2005.
  • [SP800-56A] National Institute of Standards and Technology (NIST), Special Publication 800-56A: Recommendation Pair-Wise Key Establishment Schemes Using Discrete Logarithm Cryptography (Revised), March 2007.
  • [X.680] ITU-T Recommendation X.680 (2002) | ISO/IEC 8824-1:2002. Information Technology - Abstract Syntax Notation One (ASN.1): Specification of basic notation.
  • [X.690] ITU-T Recommendation X.690 (2002) | ISO/IEC 8825-1:2002. Information Technology - ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER).

7.3. Informative References ๐Ÿฆ‹

these ones are the extra reading, super useful for context but not the core rules ๐ŸŒธ

  • [DHSUB] Zuccherato, R., "Methods for Avoiding the "Small-Subgroup" Attacks on the Diffie-Hellman Key Agreement Method for S/MIME", RFC 2785, March 2000.
  • [HASH-ATTACK] Hoffman, P. and B. Schneier, "Attacks on Cryptographic Hashes in Internet Protocols", RFC 4270, November 2005.
  • [MMA] Rescorla, E., "Preventing the Million Message Attack on Cryptographic Message Syntax", RFC 3218, January 2002.
  • [PKCS-7] Kaliski, B., "PKCS #7: Cryptographic Message Syntax Version 1.5", RFC 2315, March 1998.
  • [RFC2311] Dusse, S., Hoffman, P., Ramsdell, B., Lundblade, L., and L. Repka, "S/MIME Version 2 Message Specification", RFC 2311, March 1998.
  • [RFC2312] Dusse, S., Hoffman, P., Ramsdell, B., and J. Weinstein, "S/MIME Version 2 Certificate Handling", RFC 2312, March 1998.
  • [RFC2313] Kaliski, B., "PKCS #1: RSA Encryption Version 1.5", RFC 2313, March 1998.
  • [RFC2314] Kaliski, B., "PKCS #10: Certification Request Syntax Version 1.5", RFC 2314, March 1998.
  • [RFC2315] Kaliski, B., "PKCS #7: Certification Message Syntax Version 1.5", RFC 2315, March 1998.
  • [RFC2630] Housley, R., "Cryptographic Message Syntax", RFC 2630, June 1999.
  • [RFC2631] Rescorla, E., "Diffie-Hellman Key Agreement Method", RFC 2631, June 1999.
  • [RFC2632] Ramsdell, B., Ed., "S/MIME Version 3 Certificate Handling", RFC 2632, June 1999.
  • [RFC2633] Ramsdell, B., Ed., "S/MIME Version 3 Message Specification", RFC 2633, June 1999.
  • [RFC3850] Ramsdell, B., Ed., "Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.1 Certificate Handling", RFC 3850, July 2004.
  • [RFC3851] Ramsdell, B., Ed., "Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 3.1 Message Specification", RFC 3851, July 2004.
  • [RFC3852] Housley, R., "Cryptographic Message Syntax (CMS)", RFC 3852, July 2004.
  • [SP800-57] National Institute of Standards and Technology (NIST), Special Publication 800-57: Recommendation for Key Management, August 2005.
  • [STRENGTH] Orman, H., and P. Hoffman, "Determining Strengths For Public Keys Used For Exchanging Symmetric Keys", BCP 86, RFC 3766, April 2004.

Appendix A. ASN.1 Module ๐Ÿงฉ๐Ÿ’œ

okay the ASN.1 module is giving pure structure ๐Ÿค“ quick heads up, it's the same as RFC 3851 [SMIMEv3.1] except for one tweak to the prefersBinaryInside comment. it uses the 1988 version of ASN.1 โœจ

SecureMimeMessageV3dot1

  { iso(1) member-body(2) us(840) rsadsi(113549)
         pkcs(1) pkcs-9(9) smime(16) modules(0) msg-v3dot1(21) }

DEFINITIONS IMPLICIT TAGS ::=

BEGIN

IMPORTS

-- Cryptographic Message Syntax [CMS]
   SubjectKeyIdentifier, IssuerAndSerialNumber,
   RecipientKeyIdentifier
       FROM  CryptographicMessageSyntax
             { iso(1) member-body(2) us(840) rsadsi(113549)
               pkcs(1) pkcs-9(9) smime(16) modules(0) cms-2001(14) };

--  id-aa is the arc with all new authenticated and unauthenticated
--  attributes produced by the S/MIME Working Group

id-aa OBJECT IDENTIFIER ::= {iso(1) member-body(2) usa(840)
        rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) attributes(2)}

-- S/MIME Capabilities provides a method of broadcasting the
-- symmetric capabilities understood.  Algorithms SHOULD be ordered
-- by preference and grouped by type

smimeCapabilities OBJECT IDENTIFIER ::= {iso(1) member-body(2)
        us(840) rsadsi(113549) pkcs(1) pkcs-9(9) 15}

SMIMECapability ::= SEQUENCE {
   capabilityID OBJECT IDENTIFIER,
   parameters ANY DEFINED BY capabilityID OPTIONAL }

SMIMECapabilities ::= SEQUENCE OF SMIMECapability

-- Encryption Key Preference provides a method of broadcasting the
-- preferred encryption certificate.

id-aa-encrypKeyPref OBJECT IDENTIFIER ::= {id-aa 11}
SMIMEEncryptionKeyPreference ::= CHOICE {
   issuerAndSerialNumber   [0] IssuerAndSerialNumber,
   receipentKeyId          [1] RecipientKeyIdentifier,
   subjectAltKeyIdentifier [2] SubjectKeyIdentifier
}

-- receipentKeyId is spelt incorrectly, but kept for historical
-- reasons.

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

id-cap  OBJECT IDENTIFIER ::= { id-smime 11 }

-- The preferBinaryInside OID indicates an ability to receive
-- messages with binary encoding inside the CMS wrapper.
-- The preferBinaryInside attribute's value field is ABSENT.

id-cap-preferBinaryInside  OBJECT IDENTIFIER ::= { id-cap 1 }

--  The following list OIDs to be used with S/MIME V3

-- Signature Algorithms Not Found in [CMSALG], [CMS-SHA2], [RSAPSS],
-- and [RSAOAEP]

--
-- md2WithRSAEncryption OBJECT IDENTIFIER ::=
--    {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1)
--     2}

--
-- Other Signed Attributes
--
-- signingTime OBJECT IDENTIFIER ::=
--    {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9)
--     5}
--    See [CMS] for a description of how to encode the attribute
--    value.

SMIMECapabilitiesParametersForRC2CBC ::= INTEGER
--        (RC2 Key Length (number of bits))

END

Appendix B. Moving S/MIME v2 Message Specification to Historic Status ๐Ÿ•ฐ๏ธ

so the S/MIME v3 [SMIMEv3], v3.1 [SMIMEv3.1], and v3.2 (this document) are backwards compatible with the S/MIME v2 Message Specification [SMIMEv2] ๐Ÿค the only exceptions are the algorithms: RC2/40 requirement got dropped, and DSA and RSASSA-PSS requirements got added. so it's recommended that RFC 2311 [SMIMEv2] be moved to Historic status ๐Ÿชฆโœจ


Appendix C. Acknowledgments ๐Ÿซถ

huge thank yous ๐Ÿ’– to the other authors of the S/MIME version 2 Message Specification RFC: Steve Dusse, Paul Hoffman, Laurence Lundblade, and Lisa Repka. honestly without v2 there would be no v3, v3.1, or v3.2 ๐Ÿ˜ญ

a bunch of the S/MIME Working Group folks also worked super hard on this doc. any list of people is doomed to leave someone out, and the author apologizes for that ๐Ÿ™ˆ in alphabetical order, these people stood out because they made direct contributions to this document ๐Ÿ‘‘

Tony Capel, Piers Chivers, Dave Crocker, Bill Flanigan, Peter Gutmann, Alfred Hoenes, Paul Hoffman, Russ Housley, William Ottaway, John Pawling, and Jim Schaad. ๐ŸŒˆ


Authors' Addresses ๐Ÿ“ฎ

Blake Ramsdell
Brute Squad Labs, Inc.

EMail: blaker@gmail.com


Sean Turner
IECA, Inc.
3057 Nutley Street, Suite 106
Fairfax, VA 22031
USA

EMail: turners@ieca.com
๐Ÿ“ฆ where this page comes from