RFC 5990
Use of the RSA-KEM Key Transport Algorithm in the Cryptographic Message Syntax (CMS)
Title Block π
Okay bestie, this one is RFC 5990 from the IETF, and it's a Standards Track document, so it's an official spec that real implementers rely on π It's titled "Use of the RSA-KEM Key Transport Algorithm in the Cryptographic Message Syntax (CMS)" and it's dated September 2010. The authors are J. Randall (Randall Consulting), B. Kaliski (EMC), J. Brainard (RSA), and S. Turner (IECA). The ISSN is 2070-1721. The title block doesn't list anything this RFC obsoletes or updates π«Ά
Abstract β¨
Okay so the RSA-KEM Key Transport Algorithm is a one-pass (store-and-forward) way to send keying data to someone using their RSA public key π ("KEM" stands for "key encapsulation mechanism"). This doc lays out the conventions for using RSA-KEM with the Cryptographic Message Syntax (CMS). The ASN.1 syntax is lined up with an upcoming change to American National Standard (ANS) X9.44 πΈ
Status of This Memo π¦
This is an Internet Standards Track document. π
It's a product of the Internet Engineering Task Force (IETF), it represents the consensus of the IETF community, it got public review, and the Internet Engineering Steering Group (IESG) approved it for publication. For more on Internet Standards, check Section 2 of RFC 5741 π
For the current status, any errata, and how to send feedback, go to http://www.rfc-editor.org/info/rfc5990 π
Copyright Notice π
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 publication date. Please read these carefully, because they describe your rights and restrictions for this document π Code Components pulled out of this document must include the Simplified BSD License text, as described in Section 4.e of the Trust Legal Provisions, and they come with no warranty, as described in the Simplified BSD License.
Table of Contents π
1. Introduction ....................................................3
1.1. Conventions Used in This Document ..........................4
2. Use in CMS ......................................................4
2.1. Underlying Components ......................................4
2.2. RecipientInfo Conventions ..................................5
2.3. Certificate Conventions ....................................5
2.4. SMIMECapabilities Attribute Conventions ....................6
3. Security Considerations .........................................7
4. IANA Considerations .............................................9
5. Acknowledgements ................................................9
6. References .....................................................10
6.1. Normative References ......................................10
6.2. Informative References ....................................11
Appendix A. RSA-KEM Key Transport Algorithm ......................12
A.1. Underlying Components ....................................12
A.2. Sender's Operations ......................................12
A.3. Recipient's Operations ...................................13
Appendix B. ASN.1 Syntax .........................................15
B.1. RSA-KEM Key Transport Algorithm ..........................16
B.2. Selected Underlying Components ...........................18
B.2.1. Key Derivation Functions ............................18
B.2.2. Symmetric Key-Wrapping Schemes ......................19
B.3. ASN.1 Module .............................................20
B.4. Examples .................................................25
1. Introduction β¨
Okay, the RSA-KEM Key Transport Algorithm is a one-pass (store-and-forward) mechanism for transporting keying data to a recipient, using the recipient's RSA public key π
Most older key transport algorithms built on the RSA public-key cryptosystem (the popular PKCS #1 v1.5 algorithm [PKCS1] is one) follow this general pattern π
- Format or "pad" the keying data to get an integer m.
- Encrypt the integer m with the recipient's RSA public key:
c = m^e mod n
- Output c as the encrypted keying data.
RSA-KEM goes a different way, for higher security assurance π¦ It encrypts a random integer with the recipient's public key, then uses a symmetric key-wrapping scheme to encrypt the keying data. The steps look like this:
- Generate a random integer z between 0 and n-1.
- Encrypt the integer z with the recipient's RSA public key:
c = z^e mod n
- Derive a key-encrypting key KEK from the integer z.
- Wrap the keying data using KEK to get wrapped keying data WK.
- Output c and WK as the encrypted keying data.
Why is this better? Two reasons π§ (a) the input to the underlying RSA operation is effectively a random integer between 0 and n-1, where n is the RSA modulus, so there's no structure for an adversary to exploit. (b) The input doesn't depend on the keying data, so the result of the RSA decryption operation isn't directly available to an adversary. Because of this, the algorithm gets a "tight" security proof in the random oracle model. (In other padding schemes, like PKCS #1 v1.5, the input has structure and/or depends on the keying data, so the provable security assurances aren't as strong.) It's also architecturally convenient, since the public-key operations are separate from the symmetric operations on the keying data πΈ And the length of the keying data is bounded only by the symmetric key-wrapping scheme, not by the size of the RSA modulus.
RSA-KEM, in various forms, is being adopted in several draft standards and in American National Standard (ANS) X9.44 [ANS-X9.44] π It has also been recommended by the New European Schemes for Signatures, Integrity, and Encryption (NESSIE) project [NESSIE]. Originally, [ANS-X9.44] used a different object identifier for RSA-KEM. [ANS-X9.44] used id-ac-generic-hybrid, while this document uses id-rsa-kem. These OIDs show up in the KeyTransportInfo field to say which key encryption algorithm is in use, in certificates to let recipients restrict their public keys to RSA-KEM only, and in SMIME Capability attributes so recipients can advertise RSA-KEM support. If you're a legacy implementation that wants to interoperate with [ANS-X9.44], check that specification for more on id-ac-generic-hybrid π«Ά
For completeness, the algorithm is specified in Appendix A of this document, and the ASN.1 syntax is in Appendix B β¨
NOTE: The term "KEM" stands for "key encapsulation mechanism" and refers to the first three steps of the process above. The formalization of key transport algorithms (or more generally, asymmetric encryption schemes) in terms of key encapsulation mechanisms is described further in research by Victor Shoup leading to the development of the ISO/IEC 18033-2 standard [SHOUP] π€
1.1. Conventions Used in This Document π
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 RFC 2119 [STDWORDS] π
2. Use in CMS π
The RSA-KEM Key Transport Algorithm MAY be used for one or more recipients in the CMS enveloped-data content type (Section 6 of [CMS]). The keying data the algorithm processes is the CMS content-encryption key π
2.1. Underlying Components π§©
Any CMS implementation that supports the RSA-KEM Key Transport Algorithm MUST support at least these underlying components π«Ά
- For the key derivation function: KDF3 (see [ANS-X9.44]) based on SHA-256 (see [FIPS-180-3]). KDF3 is an instantiation of the Concatenation Key Derivation Function defined in [NIST-SP800-56A].
- For the key-wrapping scheme: AES-Wrap-128, which is the AES Key Wrap with a 128-bit key-encrypting key (see [AES-WRAP]).
An implementation SHOULD also support KDF2 (see [ANS-X9.44]) based on SHA-1. This function is also specified as the key derivation function in [ANS-X9.63] π The Camellia key wrap algorithm (see [CAMELLIA]) SHOULD be supported if Camellia is supported as a content-encryption cipher. The Triple-DES Key Wrap (see [3DES-WRAP]) SHOULD also be supported if Triple-DES is supported as a content-encryption cipher.
An implementation MAY support other underlying components. When AES or Camellia is used, the data block size is 128 bits and the key size can be 128, 192, or 256 bits. Triple-DES, on the other hand, needs a data block size of 64 bits and a key size of 112 or 168 bits π
2.2. RecipientInfo Conventions π
When the RSA-KEM Key Transport Algorithm is used for a recipient, the RecipientInfo alternative for that recipient MUST be KeyTransRecipientInfo. The algorithm-specific fields of the KeyTransRecipientInfo value MUST have these values π
keyEncryptionAlgorithm.algorithmMUST beid-rsa-kem(see Appendix B);keyEncryptionAlgorithm.parametersMUST be a value of typeGenericHybridParameters, identifying the RSA-KEM key encapsulation mechanism (see Appendix B);encryptedKeyMUST be the encrypted keying data output by the algorithm, where the keying data is the content-encryption key (see Appendix A) π₯
2.3. Certificate Conventions β¨
okay so this section is basically the rules for how an RSA public key gets labelled inside a certificate, and it's extending RFC 5280 [PROFILE], so it's building on top of that base. no cap, it's giving precision π
A recipient who uses the RSA-KEM Key Transport Algorithm MAY identify the public key in a certificate with the same AlgorithmIdentifier as the PKCS #1 v1.5 algorithm, which means the rsaEncryption object identifier [PKCS1]. bestie, the catch is that using this identifier does NOT tell anyone the user will accept RSA-KEM with that key π the way that signal can instead be sent using the appropriate SMIME Capabilities, either in a message or in the certificate. MAY again, so totally optional πΈ
Now, if the recipient ONLY wants to use the RSA-KEM Key Transport Algorithm with a given public key, then they MUST identify that key in the certificate with the id-rsa-kem object identifier (see Appendix B) π and when id-rsa-kem shows up in the SubjectPublicKeyInfo algorithm field, the encoding SHALL omit the parameters field from AlgorithmIdentifier. so the AlgorithmIdentifier SHALL be a SEQUENCE of one component, which is just the object identifier id-rsa-kem. iconic, clean, no extras β¨
No matter which AlgorithmIdentifier is used, the RSA public key gets encoded the same way inside the subject public key information. the RSA public key MUST be encoded using the RSAPublicKey type:
RSAPublicKey ::= SEQUENCE {
modulus INTEGER, -- n
publicExponent INTEGER -- e
}
So the modulus is n, the publicExponent is e, and the DER-encoded RSAPublicKey goes in the subjectPublicKey BIT STRING within the subject public key information π§
The intended application for the key MAY be flagged in the key usage certificate extension (see [PROFILE], Section 4.2.1.3). If the keyUsage extension is present in a certificate that carries an RSA public key with the id-rsa-kem object identifier, then the key usage extension MUST contain this value:
keyEncipherment
dataEncipherment SHOULD NOT be present. So a key meant ONLY for the RSA-KEM Key Transport Algorithm SHOULD NOT also be used for data encryption or for authentication like signatures. good crypto practice is one RSA key pair per scheme, because that way a weakness in one scheme can't drag down the other, and it may be essential for provable security π
2.4. SMIMECapabilities Attribute Conventions π
RFC 3851 [MSG], Section 2.5.2 defines the SMIMECapabilities signed attribute (a SEQUENCE of SMIMECapability SEQUENCEs) that lists a partial set of algorithms the announcing software can support. when building a signedData object, compliant software MAY include the SMIMECapabilities signed attribute to announce that it supports the RSA-KEM Key Transport Algorithm π¦
The SMIMECapability SEQUENCE for the RSA-KEM Key Transport Algorithm MUST include the id-rsa-kem object identifier (see Appendix B) in the capabilityID field, and MUST include a GenericHybridParameters value in the parameters field that identifies the components the algorithm will be used with.
The DER encoding of a SMIMECapability SEQUENCE is the same as the DER encoding of an AlgorithmIdentifier. example DER encodings for typical sets of components are in Appendix B.4 π
3. Security Considerations π
okay this is the serious part, so read it slowly bestie π
The RSA-KEM Key Transport Algorithm SHOULD be considered for new CMS-based applications as a replacement for the widely implemented RSA encryption algorithm from PKCS #1 v1.5 (see [PKCS1] and Section 4.2.1 of [CMSALGS]), which is vulnerable to chosen-ciphertext attacks. the RSA Encryption Scheme - Optimal Asymmetric Encryption Padding (RSAES-OAEP) Key Transport Algorithm has also been proposed as a replacement (see [PKCS1] and [CMS-OAEP]). RSA-KEM has the advantage over RSAES-OAEP of a tighter security proof, but the disadvantage of slightly longer encrypted keying data π
The security of the RSA-KEM Key Transport Algorithm described here can be shown to be tightly related to the difficulty of either solving the RSA problem or breaking the underlying symmetric key-wrapping scheme, IF the underlying key derivation function is modeled as a random oracle, and assuming the symmetric key-wrapping scheme satisfies the properties of a data encapsulation mechanism [SHOUP]. while in practice a random-oracle result does NOT give an actual security proof for any particular key derivation function, it does give assurance that the general construction is reasonable. a key derivation function would need to be particularly weak to lead to an attack that isn't possible in the random oracle model π₯
The RSA key size and the underlying components SHOULD be selected consistent with the desired symmetric security level for an application. several security levels are identified in NIST FIPS PUB 800-57 [NIST-GUIDELINE]. for brevity, the first three levels are mentioned here:
- 80-bit security. The RSA key size SHOULD be at least 1024 bits, the hash function underlying the KDF SHOULD be SHA-1 or above, and the symmetric key-wrapping scheme SHOULD be AES Key Wrap, Triple-DES Key Wrap, or Camellia Key Wrap.
- 112-bit security. The RSA key size SHOULD be at least 2048 bits, the hash function underlying the KDF SHOULD be SHA-224 or above, and the symmetric key-wrapping scheme SHOULD be AES Key Wrap, Triple-DES Key Wrap, or Camellia Key Wrap.
- 128-bit security. The RSA key size SHOULD be at least 3072 bits, the hash function underlying the KDF SHOULD be SHA-256 or above, and the symmetric key-wrapping scheme SHOULD be AES Key Wrap or Camellia Key Wrap.
Note that AES Key Wrap or Camellia Key Wrap MAY be used at all three of these levels. using AES or Camellia does not require a 128-bit security level for other components π
Implementations MUST protect the RSA private key and the content-encryption key. compromise of the RSA private key may result in disclosure of ALL messages protected with that key, and compromise of the content-encryption key may result in disclosure of the associated encrypted content. this part is non-negotiable, babe π¨
Additional considerations related to key management may be found in [NIST-GUIDELINE].
The security of the algorithm also depends on the strength of the random number generator, which SHOULD have a comparable security level. for further discussion on random number generation, see [RANDOM] π²
Implementations SHOULD NOT reveal information about intermediate values or calculations, whether by timing or other "side channels", or otherwise an opponent may be able to determine information about the keying data and/or the recipient's private key. not all intermediate information may be useful to an opponent, but it is preferable to conceal as much as is practical, unless analysis specifically indicates that the information would not be useful π«Ά
Generally, good cryptographic practice employs a given RSA key pair in only one scheme. this avoids the risk that a vulnerability in one scheme may compromise the security of the other, and may be essential to maintain provable security. while RSA public keys have often been used for multiple purposes, such as key transport and digital signature, without any known bad interactions, for increased security assurance, such combined use of an RSA key pair is NOT RECOMMENDED in the future (unless the different schemes are specifically designed to be used together) π
So an RSA key pair used for the RSA-KEM Key Transport Algorithm SHOULD NOT also be used for digital signatures. (fun fact: the Accredited Standards Committee X9 (ASC X9) requires that separation between key establishment key pairs and digital signature key pairs.) continuing this principle of key separation, a key pair used for the RSA-KEM Key Transport Algorithm SHOULD NOT be used with other key establishment schemes, or for data encryption, or with more than one set of underlying algorithm components π§
Parties MAY formalize the assurance that one another's implementations are correct through implementation validation, e.g., NIST's Cryptographic Module Validation Program (CMVP) β¨
4. IANA Considerations πΈ
Within the CMS, algorithms are identified by object identifiers (OIDs). with one exception, all of the OIDs used in this document were assigned in other IETF documents, in ISO/IEC standards documents, by the National Institute of Standards and Technology (NIST), and in Public-Key Cryptography Standards (PKCS) documents. the two exceptions are the ASN.1 module's identifier (see Appendix B.3) and id-rsa-kem, which are both assigned in this document. the module object identifiers are defined in an arc delegated by the former company RSA Data Security Inc. to the S/MIME Working Group. when the S/MIME Working Group closes, this arc and its registration procedures will be transferred to IANA π¦
5. Acknowledgements π
This document is one part of a strategy to align algorithm standards produced by ASC X9, ISO/IEC JTC1 SC27, NIST, and the IETF. we would like to thank the members of the ASC X9F1 working group for their contributions to drafts of ANS X9.44, which led to this specification π
Our thanks to Russ Housley as well for his guidance and encouragement. we also appreciate the helpful direction we've received from Blake Ramsdell and Jim Schaad in bringing this document to fruition. a special thanks to Magnus Nystrom for his assistance on Appendix B. thanks also to Bob Griffin and John Linn for both editorial direction and procedural guidance π«Ά
6. References π
6.1. Normative References πβ¨
okay bestie, these are the must-read refs π«Ά and I'm keeping every single one exactly as it is:
[3DES-WRAP] Housley, R., "Triple-DES and RC2 Key Wrapping",
RFC 3217, December 2001.
[AES-WRAP] Schaad, J. and R. Housley, "Advanced Encryption
Standard (AES) Key Wrap Algorithm", RFC 3394,
September 2002.
[ANS-X9.44] ASC X9F1 Working Group. American National Standard
X9.44: Public Key Cryptography for the Financial
Services Industry -- Key Establishment Using
Integer Factorization Cryptography. 2007.
[ANS-X9.63] American National Standard X9.63-2002: Public Key
Cryptography for the Financial Services Industry:
Key Agreement and Key Transport Using Elliptic
Curve Cryptography.
[CAMELLIA] Moriai, S. and A. Kato, "Use of the Camellia
Encryption Algorithm in Cryptographic Message
Syntax (CMS)", RFC 3657, January 2004.
[CMS] Housley, R., "Cryptographic Message Syntax (CMS)",
RFC 5652, September 2009.
[CMSALGS] Housley, R., "Cryptographic Message Syntax (CMS)
Algorithms", RFC 3370, August 2002.
[FIPS-180-3] National Institute of Standards and Technology
(NIST). FIPS 180-3: Secure Hash Standard. October
2008.
[MSG] Ramsdell, B. and S. Turner, "Secure/Multipurpose
Internet Mail Extensions (S/MIME) Version 3.2
Message Specification", RFC 5751, January 2010.
[PROFILE] Cooper, D., Santesson, S., Farrell, S., Boeyen, S.,
Housley, R., and W. Polk, "Internet X.509 Public
Key Infrastructure Certificate and Certificate
Revocation List (CRL) Profile", RFC 5280, May 2008.
[STDWORDS] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, March 1997.
6.2. Informative References πΈ
these ones are the extra reading that's good to know about π
[AES-WRAP-PAD] Housley, R. and M. Dworkin, "Advanced Encryption
Standard (AES) Key Wrap with Padding Algorithm",
RFC 5649, September 2009.
[CMS-OAEP] Housley, R., "Use of the RSAES-OAEP Key Transport
Algorithm in Cryptographic Message Syntax (CMS)",
RFC 3560, July 2003.
[NESSIE] NESSIE Consortium. Portfolio of Recommended
Cryptographic Primitives. February 2003.
http://www.cryptonessie.org/.
[NIST-GUIDELINE] National Institute of Standards and Technology.
Special Publication 800-57: Recommendation for Key
Management - Part 1: General (Revised). March
2007.
http://csrc.nist.gov/publications/index.html.
[NIST-SP800-56A] National Institute of Standards and Technology.
Special Publication 800-56A: Recommendation for
Pair-Wise Key Establishment Schemes Using Discrete
Logarithm Cryptography (Revised). March 2007.
http://csrc.nist.gov/publications/index.html.
[PKCS1] Jonsson, J. and B. Kaliski, "Public-Key
Cryptography Standards (PKCS) #1: RSA Cryptography
Specifications Version 2.1", RFC 3447, February
2003.
[RANDOM] Eastlake 3rd, D., Schiller, J., and S. Crocker,
"Randomness Requirements for Security", BCP 106,
RFC 4086, June 2005.
[SHOUP] Shoup, V. A Proposal for an ISO Standard for
Public Key Encryption. Version 2.1, December 20,
2001. http://eprint.iacr.org/2001/112.
Appendix A. RSA-KEM Key Transport Algorithm π
okay so the RSA-KEM Key Transport Algorithm is giving one-pass, store-and-forward energy π. It moves keying data to a recipient using the recipient's RSA public key.
the vibe is that the sender scrambles the keying data with the recipient's public key to get encrypted keying data, and then the recipient unscrambles it with their private key to get the keying data back β¨
A.1. Underlying Components π§©
the algorithm has these two underlying components:
- KDF, a key derivation function, which derives keying data of a specified length from a shared secret value;
- Wrap, a symmetric key-wrapping scheme, which encrypts keying Data using a key-encrypting key.
in what follows, kekLen is the length in bytes of the key-encrypting key for the underlying symmetric key-wrapping scheme.
here's the big rule π: the length of the keying data being transported MUST be one of the lengths the underlying symmetric key-wrapping scheme supports. (Both the AES and Camellia Key Wraps, for instance, need the keying data length to be a multiple of 8 bytes, and at least 16 bytes.) How the keying data is used and formatted (like parity adjustment for Triple-DES keys) is outside the scope of this algorithm. Some key derivation functions can take other information besides the shared secret value as input, and some symmetric key-wrapping schemes can attach a label to the keying data. None of that is directly supported by CMS, so it's outside the scope of this document π
A.2. Sender's Operations π
let (n,e) be the recipient's RSA public key (see [PKCS1] for details), and let K be the keying data to be transported.
let nLen be the length in bytes of the modulus n, which means the least integer such that 2^{8*nLen} > n.
the sender does the following steps:
- Generate a random integer z between 0 and n-1 (see note), and convert z to a byte string Z of length nLen, most significant byte first:
z = RandomInteger (0, n-1)
Z = IntegerToString (z, nLen)
- Encrypt the random integer z using the recipient's public key (n,e), and convert the resulting integer c to a ciphertext C, a byte string of length nLen:
c = z^e mod n
C = IntegerToString (c, nLen)
- Derive a key-encrypting key KEK of length kekLen bytes from the byte string Z using the underlying key derivation function:
KEK = KDF (Z, kekLen)
- Wrap the keying data K with the key-encrypting key KEK using the underlying key-wrapping scheme to obtain wrapped keying data WK:
WK = Wrap (KEK, K)
- Concatenate the ciphertext C and the wrapped keying data WK to obtain the encrypted keying data EK:
EK = C || WK
- Output the encrypted keying data EK.
NOTE: The random integer z MUST be generated independently at random for different encryption operations, whether for the same or different recipients.
A.3. Recipient's Operations π¦
let (n,d) be the recipient's RSA private key (see [PKCS1]; other private key formats are allowed), and let EK be the encrypted keying data.
let nLen be the length in bytes of the modulus n.
the recipient does the following steps:
- Separate the encrypted keying data EK into a ciphertext C of length nLen bytes and wrapped keying data WK:
C || WK = EK
If the length of the encrypted keying data is less than nLen bytes, output "decryption error", and stop.
- Convert the ciphertext C to an integer c, most significant byte first. Decrypt the integer c using the recipient's private key (n,d) to recover an integer z (see note):
c = StringToInteger (C)
z = c^d mod n
If the integer c is not between 0 and n-1, output "decryption error", and stop.
- Convert the integer z to a byte string Z of length nLen, most significant byte first (see note):
Z = IntegerToString (z, nLen)
- Derive a key-encrypting key KEK of length kekLen bytes from the byte string Z using the underlying key derivation function (see note):
KEK = KDF (Z, kekLen)
- Unwrap the wrapped keying data WK with the key-encrypting key KEK using the underlying key-wrapping scheme to recover the keying data K:
K = Unwrap (KEK, WK)
If the unwrapping operation outputs an error, output "decryption error", and stop.
- Output the keying data K.
NOTE: Implementations SHOULD NOT reveal information about the integer z and the string Z, nor about the calculation of the exponentiation in Step 2, the conversion in Step 3, or the key derivation in Step 4, whether by timing or other "side channels". The observable behavior of the implementation SHOULD be the same at these steps for all ciphertexts C that are in range. (For example, IntegerToString conversion should take the same amount of time regardless of the actual value of the integer z.) The integer z, the string Z, and other intermediate results MUST be securely deleted when they are no longer needed.
Appendix B. ASN.1 Syntax π
the ASN.1 syntax that identifies the RSA-KEM Key Transport Algorithm is an extension of the syntax for the "generic hybrid cipher" in ANS X9.44 [ANS-X9.44]. The syntax for the scheme is in Appendix B.1, and the syntax for the selected underlying components, including the ones mentioned above, is in Appendix B.2 π
these object identifier prefixes get used in the definitions below:
is18033-2 OID ::= { iso(1) standard(0) is18033(18033) part2(2) }
nistAlgorithm OID ::= {
joint-iso-itu-t(2) country(16) us(840) organization(1)
gov(101) csor(3) nistAlgorithm(4)
}
pkcs-1 OID ::= {
iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1)
}
x9-44 OID ::= { iso(1) identified-organization(3) tc68(133)
country(16) x9(840) x9Standards(9) x9-44(44) }
x9-44-components OID ::= { x9-44 components(1) }
NullParms is a more descriptive synonym for NULL when an algorithm identifier has null parameters:
NullParms ::= NULL
the material in this Appendix is based on ANS X9.44. π
B.1. RSA-KEM Key Transport Algorithm β¨
Okay bestie, the object identifier for the RSA-KEM Key Transport Algorithm is id-rsa-kem π¦, and this doc defines it like this:
id-rsa-kem OID ::= {
iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1)
pkcs-9(9) smime(16) alg(3) 14
}
So whenever id-rsa-kem shows up in an AlgorithmIdentifier, the parameters MUST employ the GenericHybridParameters syntax π
. And when it's in the SubjectPublicKeyInfo field, the parameters MUST be absent π. GenericHybridParameters looks like this:
GenericHybridParameters ::= {
kem KeyEncapsulationMechanism,
dem DataEncapsulationMechanism
}
Here's what the fields of type GenericHybridParameters mean, no cap π§
- kem names the underlying key encapsulation mechanism, which in this case is also called RSA-KEM.
- dem names the underlying data encapsulation mechanism. For alignment with ANS X9.44, it MUST be an X9-approved symmetric key-wrapping scheme. Other symmetric key-wrapping schemes MAY be used with CMS. Peep Appendix B.2.2 for the syntax for the AES, Triple-DES, and Camellia Key Wraps π
For the kem part, the object identifier for RSA-KEM (as a key encapsulation mechanism) is id-kem-rsa, given as:
id-kem-rsa OID ::= {
is18033-2 key-encapsulation-mechanism(2) rsa(4)
}
The associated parameters for id-kem-rsa have type RsaKemParameters:
RsaKemParameters ::= {
keyDerivationFunction KeyDerivationFunction,
keyLength KeyLength
}
The fields of type RsaKemParameters mean this πΈ
- keyDerivationFunction identifies the underlying key derivation function. For alignment with ANS X9.44, it MUST be KDF2 or KDF3. However, other key derivation functions MAY be used with CMS. Please see Appendix B.2.1 for the syntax for KDF2 and KDF3.
- keyLength is the length in bytes of the key-encrypting key, which depends on the underlying symmetric key-wrapping scheme.
KeyDerivationFunction ::=
AlgorithmIdentifier {{KDFAlgorithms}}
KDFAlgorithms ALGORITHM ::= {
kdf2 | kdf3,
... -- implementations may define other methods
}
KeyLength ::= INTEGER (1..MAX)
Now the dem part, with its full syntax:
DataEncapsulationMechanism ::=
AlgorithmIdentifier {{DEMAlgorithms}}
DEMAlgorithms ALGORITHM ::= {
X9-SymmetricKeyWrappingSchemes,
Camellia-KeyWrappingSchemes,
... -- implementations may define other methods
}
X9-SymmetricKeyWrappingSchemes ALGORITHM ::= {
aes128-Wrap | aes192-Wrap | aes256-Wrap | tdes-Wrap,
... -- allows for future expansion
}
Camellia-KeyWrappingSchemes ALGORITHM ::= {
Camellia128-Wrap | Camellia192-Wrap | Camellia256-Wrap
}
B.2. Selected Underlying Components π
B.2.1. Key Derivation Functions π₯
The object identifier for KDF2 (see [ANS-X9.44]) is:
id-kdf-kdf2 OID ::= { x9-44-components kdf2(1) }
The associated parameters identify the underlying hash function. For alignment with ANS X9.44, the hash function MUST be an ASC X9-approved hash function. However, other hash functions MAY be used with CMS.
kdf2 ALGORITHM ::= { OID id-kdf-kdf2 PARMS KDF2-HashFunction }
KDF2-HashFunction ::= AlgorithmIdentifier {{KDF2-HashFunctions}}
KDF2-HashFunctions ALGORITHM ::= {
X9-HashFunctions,
... -- implementations may define other methods
}
X9-HashFunctions ALGORITHM ::= {
sha1 | sha224 | sha256 | sha384 | sha512,
... -- allows for future expansion
}
The object identifier for SHA-1 is:
id-sha1 OID ::= {
iso(1) identified-organization(3) oiw(14) secsig(3)
algorithms(2) sha1(26)
}
The object identifiers for SHA-224, SHA-256, SHA-384, and SHA-512 are:
id-sha224 OID ::= { nistAlgorithm hashAlgs(2) sha224(4) }
id-sha256 OID ::= { nistAlgorithm hashAlgs(2) sha256(1) }
id-sha384 OID ::= { nistAlgorithm hashAlgs(2) sha384(2) }
id-sha512 OID ::= { nistAlgorithm hashAlgs(2) sha512(3) }
Okay, so there's been some confusion about whether the various SHA object identifiers have a NULL parameter or no parameters at all π. As also discussed in [PKCS1], implementations SHOULD generate algorithm identifiers without parameters, and they MUST accept algorithm identifiers either without parameters or with NULL parameters π.
sha1 ALGORITHM ::= { OID id-sha1 } -- NULLParms MUST be
sha224 ALGORITHM ::= { OID id-sha224 } -- accepted for these
sha256 ALGORITHM ::= { OID id-sha256 } -- OIDs
sha384 ALGORITHM ::= { OID id-sha384 } -- ""
sha512 ALGORITHM ::= { OID id-sha512 } -- ""
The object identifier for KDF3 (see [ANS-X9.44]) is:
id-kdf-kdf3 OID ::= { x9-44-components kdf3(2) }
The associated parameters identify the underlying hash function. For alignment with the draft ANS X9.44, the hash function MUST be an ASC X9-approved hash function. However, other hash functions MAY be used with CMS.
kdf3 ALGORITHM ::= { OID id-kdf-kdf3 PARMS KDF3-HashFunction }
KDF3-HashFunction ::= AlgorithmIdentifier { KDF3-HashFunctions }
KDF3-HashFunctions ALGORITHM ::= {
X9-HashFunctions,
... -- implementations may define other methods
}
B.2.2. Symmetric Key-Wrapping Schemes π¦
The object identifiers for the AES Key Wrap depend on the size of the key-encrypting key. There are three of them (see [AES-WRAP]):
id-aes128-Wrap OID ::= { nistAlgorithm aes(1) aes128-Wrap(5) }
id-aes192-Wrap OID ::= { nistAlgorithm aes(1) aes192-Wrap(25) }
id-aes256-Wrap OID ::= { nistAlgorithm aes(1) aes256-Wrap(45) }
These object identifiers have no associated parameters π
aes128-Wrap ALGORITHM ::= { OID id-aes128-Wrap }
aes192-Wrap ALGORITHM ::= { OID id-aes192-Wrap }
aes256-Wrap ALGORITHM ::= { OID id-aes256-Wrap }
The object identifier for the Triple-DES Key Wrap (see [3DES-WRAP]) is:
id-alg-CMS3DESwrap OBJECT IDENTIFIER ::= {
iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9)
smime(16) alg(3) 6
}
This object identifier has a NULL parameter π§
tdes-Wrap ALGORITHM ::=
{ OID id-alg-CMS3DESwrap PARMS NullParms }
NOTE: ASC X9 has not yet incorporated AES Key Wrap with Padding [AES-WRAP-PAD] into ANS X9.44. When ASC X9.44 adds AES Key Wrap with Padding, this document will also be updated. π
The object identifiers for the Camellia Key Wrap depend on the size of the key-encrypting key. There are three of them:
id-camellia128-Wrap OBJECT IDENTIFIER ::=
{ iso(1) member-body(2) 392 200011 61 security(1)
algorithm(1) key-wrap-algorithm(3)
camellia128-wrap(2) }
id-camellia192-Wrap OBJECT IDENTIFIER ::=
{ iso(1) member-body(2) 392 200011 61 security(1)
algorithm(1) key-wrap-algorithm(3)
camellia192-wrap(3) }
id-camellia256-Wrap OBJECT IDENTIFIER ::=
{ iso(1) member-body(2) 392 200011 61 security(1)
algorithm(1) key-wrap-algorithm(3)
camellia256-wrap(4) }
These object identifiers have no associated parameters π«Ά
camellia128-Wrap ALGORITHM ::= { OID id-camellia128-Wrap }
camellia192-Wrap ALGORITHM ::= { OID id-camellia192-Wrap }
camellia256-Wrap ALGORITHM ::= { OID id-camellia256-Wrap }
B.3. ASN.1 Module π
Here's the whole ASN.1 module, bestie. It's the official blueprint for every OID and parameter we just talked about, so don't go changing a single character π
CMS-RSA-KEM
{ iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1)
pkcs-9(9) smime(16) modules(0) cms-rsa-kem(21) }
DEFINITIONS ::=
BEGIN
-- EXPORTS ALL
-- IMPORTS None
-- Useful types and definitions
OID ::= OBJECT IDENTIFIER -- alias
-- Unless otherwise stated, if an object identifier has associated
-- parameters (i.e., the PARMS element is specified), the
-- parameters field shall be included in algorithm identifier
-- values. The parameters field shall be omitted if and only if
-- the object identifier does not have associated parameters
-- (i.e., the PARMS element is omitted), unless otherwise stated.
ALGORITHM ::= CLASS {
&id OBJECT IDENTIFIER UNIQUE,
&Type OPTIONAL
}
WITH SYNTAX { OID &id [PARMS &Type] }
AlgorithmIdentifier { ALGORITHM:IOSet } ::= SEQUENCE {
algorithm ALGORITHM.&id( {IOSet} ),
parameters ALGORITHM.&Type( {IOSet}{@algorithm} ) OPTIONAL
}
NullParms ::= NULL
-- ISO/IEC 18033-2 arc
is18033-2 OID ::= { iso(1) standard(0) is18033(18033) part2(2) }
-- NIST algorithm arc
nistAlgorithm OID ::= {
joint-iso-itu-t(2) country(16) us(840) organization(1)
gov(101) csor(3) nistAlgorithm(4)
}
-- PKCS #1 arc
pkcs-1 OID ::= {
iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1)
}
-- RSA-KEM Key Transport Algorithm
id-rsa-kem OID ::= {
iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1)
pkcs-9(9) smime(16) alg(3) 14
}
GenericHybridParameters ::= SEQUENCE {
kem KeyEncapsulationMechanism,
dem DataEncapsulationMechanism
}
KeyEncapsulationMechanism ::= AlgorithmIdentifier {{KEMAlgorithms}}
KEMAlgorithms ALGORITHM ::= { kem-rsa, ... }
kem-rsa ALGORITHM ::= { OID id-kem-rsa PARMS RsaKemParameters }
id-kem-rsa OID ::= {
is18033-2 key-encapsulation-mechanism(2) rsa(4)
}
RsaKemParameters ::= SEQUENCE {
keyDerivationFunction KeyDerivationFunction,
keyLength KeyLength
}
KeyDerivationFunction ::= AlgorithmIdentifier {{KDFAlgorithms}}
KDFAlgorithms ALGORITHM ::= {
kdf2 | kdf3,
... -- implementations may define other methods
}
KeyLength ::= INTEGER (1..MAX)
DataEncapsulationMechanism ::= AlgorithmIdentifier {{DEMAlgorithms}}
DEMAlgorithms ALGORITHM ::= {
X9-SymmetricKeyWrappingSchemes |
Camellia-KeyWrappingSchemes,
... -- implementations may define other methods
}
X9-SymmetricKeyWrappingSchemes ALGORITHM ::= {
aes128-Wrap | aes192-Wrap | aes256-Wrap | tdes-Wrap,
... -- allows for future expansion
}
X9-SymmetricKeyWrappingScheme ::=
AlgorithmIdentifier {{ X9-SymmetricKeyWrappingSchemes }}
Camellia-KeyWrappingSchemes ALGORITHM ::= {
camellia128-Wrap | camellia192-Wrap | camellia256-Wrap,
... -- allows for future expansion
}
Camellia-KeyWrappingScheme ::=
AlgorithmIdentifier {{ Camellia-KeyWrappingSchemes }}
-- Key Derivation Functions
id-kdf-kdf2 OID ::= { x9-44-components kdf2(1) }
-- Base arc
x9-44 OID ::= {
iso(1) identified-organization(3) tc68(133) country(16) x9(840)
x9Standards(9) x9-44(44)
}
x9-44-components OID ::= { x9-44 components(1) }
kdf2 ALGORITHM ::= { OID id-kdf-kdf2 PARMS KDF2-HashFunction }
KDF2-HashFunction ::= AlgorithmIdentifier {{ KDF2-HashFunctions }}
KDF2-HashFunctions ALGORITHM ::= {
X9-HashFunctions,
... -- implementations may define other methods
}
id-kdf-kdf3 OID ::= { x9-44-components kdf3(2) }
kdf3 ALGORITHM ::= { OID id-kdf-kdf3 PARMS KDF3-HashFunction }
KDF3-HashFunction ::= AlgorithmIdentifier {{ KDF3-HashFunctions }}
KDF3-HashFunctions ALGORITHM ::= {
X9-HashFunctions,
... -- implementations may define other methods
}
-- Hash Functions
X9-HashFunctions ALGORITHM ::= {
sha1 | sha224 | sha256 | sha384 | sha512,
... -- allows for future expansion
}
id-sha1 OID ::= {
iso(1) identified-organization(3) oiw(14) secsig(3)
algorithms(2) sha1(26)
}
id-sha224 OID ::= { nistAlgorithm hashAlgs(2) sha224(4) }
id-sha256 OID ::= { nistAlgorithm hashAlgs(2) sha256(1) }
id-sha384 OID ::= { nistAlgorithm hashAlgs(2) sha384(2) }
id-sha512 OID ::= { nistAlgorithm hashAlgs(2) sha512(3) }
sha1 ALGORITHM ::= { OID id-sha1 } -- NullParms MUST be
sha224 ALGORITHM ::= { OID id-sha224 } -- accepted for these
sha256 ALGORITHM ::= { OID id-sha256 } -- OIDs
sha384 ALGORITHM ::= { OID id-sha384 } -- ""
sha512 ALGORITHM ::= { OID id-sha512 } -- ""
-- Symmetric Key-Wrapping Schemes
id-aes128-Wrap OID ::= { nistAlgorithm aes(1) aes128-Wrap(5) }
id-aes192-Wrap OID ::= { nistAlgorithm aes(1) aes192-Wrap(25) }
id-aes256-Wrap OID ::= { nistAlgorithm aes(1) aes256-Wrap(45) }
aes128-Wrap ALGORITHM ::= { OID id-aes128-Wrap }
aes192-Wrap ALGORITHM ::= { OID id-aes192-Wrap }
aes256-Wrap ALGORITHM ::= { OID id-aes256-Wrap }
id-alg-CMS3DESwrap OBJECT IDENTIFIER ::= {
iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9)
smime(16) alg(3) 6
}
tdes-Wrap ALGORITHM ::= { OID id-alg-CMS3DESwrap PARMS NullParms }
id-camellia128-Wrap OBJECT IDENTIFIER ::=
{ iso(1) member-body(2) 392 200011 61 security(1)
algorithm(1) key-wrap-algorithm(3)
camellia128-wrap(2) }
id-camellia192-Wrap OBJECT IDENTIFIER ::=
{ iso(1) member-body(2) 392 200011 61 security(1)
algorithm(1) key-wrap-algorithm(3)
camellia192-wrap(3) }
id-camellia256-Wrap OBJECT IDENTIFIER ::=
{ iso(1) member-body(2) 392 200011 61 security(1)
algorithm(1) key-wrap-algorithm(3)
camellia256-wrap(4) }
camellia128-Wrap ALGORITHM ::= { OID id-camellia128-Wrap }
camellia192-Wrap ALGORITHM ::= { OID id-camellia192-Wrap }
camellia256-Wrap ALGORITHM ::= { OID id-camellia256-Wrap }
END
B.4. Examples π§
Okay, let's do a real example, because seeing it in action is everything β¨ Say the key derivation function is KDF3 based on SHA-256 and the symmetric key-wrapping scheme is the AES Key Wrap with a 128-bit KEK. Then the AlgorithmIdentifier for the RSA-KEM Key Transport Algorithm ends up looking like this π
SEQUENCE {
id-rsa-kem, -- RSA-KEM cipher
SEQUENCE { -- GenericHybridParameters
SEQUENCE { -- key encapsulation mechanism
id-kem-rsa, -- RSA-KEM
SEQUENCE { -- RsaKemParameters
SEQUENCE { -- key derivation function
id-kdf-kdf3, -- KDF3
SEQUENCE { -- KDF3-HashFunction
id-sha256 -- SHA-256; no parameters (preferred)
},
16 -- KEK length in bytes
},
SEQUENCE { -- data encapsulation mechanism
id-aes128-Wrap -- AES-128 Wrap; no parameters
}
}
}
And here's the DER encoding of that exact value. It's giving hex dump, but make it cute π¦
30 47
06 0b 2a 86 48 86 f7 0d 01 09 10 03 0e -- id-rsa-kem
30 38
30 29
06 07 28 81 8c 71 02 02 04 -- id-kem-rsa
30 1e
30 19
06 0a 2b 81 05 10 86 48 09 2c 01 02 -- id-kdf-kdf3
30 0b
06 09 60 86 48 01 65 03 04 02 01 -- id-sha256
02 01 10 -- 16 bytes
30 0b
06 09 60 86 48 01 65 03 04 01 05 -- id-aes128-Wrap
Other typical sets of underlying components have their own DER encodings too, and these are the ones we've got π
- KDF3 based on SHA-384, with AES Key Wrap and a 192-bit KEK:
30 47 06 0b 2a 86 48 86 f7 0d 01 09 10 03 0e 30
38 30 29 06 07 28 81 8c 71 02 02 04 30 1e 30 19
06 0a 2b 81 05 10 86 48 09 2c 01 02 30 0b 06 09
60 86 48 01 65 03 04 02 02 02 01 18 30 0b 06 09
60 86 48 01 65 03 04 01 19
- KDF3 based on SHA-512, with AES Key Wrap and a 256-bit KEK:
30 47 06 0b 2a 86 48 86 f7 0d 01 09 10 03 0e 30
38 30 29 06 07 28 81 8c 71 02 02 04 30 1e 30 19
06 0a 2b 81 05 10 86 48 09 2c 01 02 30 0b 06 09
60 86 48 01 65 03 04 02 03 02 01 20 30 0b 06 09
60 86 48 01 65 03 04 01 2d
- KDF2 based on SHA-1, with Triple-DES Key Wrap and a 128-bit KEK (two-key Triple-DES):
30 45 06 0b 2a 86 48 86 f7 0d 01 09 10 03 0e 30
36 30 25 06 07 28 81 8c 71 02 02 04 30 1a 30 15
06 0a 2b 81 05 10 86 48 09 2c 01 01 30 07 06 05
2b 0e 03 02 1a 02 01 10 30 0d 06 0b 2a 86 48 86
f7 0d 01 09 10 03 06
Authors' Addresses β¨
James Randall
Randall Consulting
55 Sandpiper Drive
Dover, NH 03820
USA
EMail: jdrandall@comcast.net
Burt Kaliski
EMC
176 South Street
Hopkinton, MA 01748
USA
EMail: burt.kaliski@emc.com
John Brainard
RSA, The Security Division of EMC
174 Middlesex Turnpike
Bedford, MA 01730
USA
EMail: jbrainard@rsa.com
Sean Turner
IECA, Inc.
3057 Nutley Street, Suite 106
Fairfax, VA 22031
USA
EMail: turners@ieca.com
π¦ where this page comes from
- ietf: rfc5990 2010-09
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms