RFC 5958
Asymmetric Key Packages
RFC 5958: Asymmetric Key Packages πβ¨
okay bestie, let's knock out the paperwork first ππ This is RFC 5958, called Asymmetric Key Packages. S. Turner from IECA wrote it. It's a Standards Track document, dated August 2010, and it obsoletes RFC 5208 (the older version it replaces π«Ά). It's also listed under ISSN 2070-1721.
Abstract πΈ
this doc defines the syntax for private-key information and a content type for it π private-key info includes a private key for a specified public-key algorithm plus a set of attributes. the Cryptographic Message Syntax (CMS), as defined in RFC 5652, can be used to digitally sign, digest, authenticate, or encrypt the asymmetric key format content type. this document obsoletes RFC 5208.
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, received public review, and was approved for publication by the Internet Engineering Steering Group (IESG). if you want more on Internet Standards, check Section 2 of RFC 5741.
for the current status, any errata, and how to give feedback, go to http://www.rfc-editor.org/info/rfc5958 π¦
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 in effect on the date of publication. please read these carefully, because they describe your rights and restrictions for this document π Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions, and they're provided 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 exceptions are formatting it for publication as an RFC or translating it into languages other than English π
1. Introduction π
okay so this document defines the syntax for private-key information and a Cryptographic Message Syntax (CMS) [RFC5652] content type for it π private-key info includes a private key for a specified public-key algorithm plus a set of attributes. the CMS can be used to digitally sign, digest, authenticate, or encrypt the asymmetric key format content type. this document obsoletes PKCS #8 v1.2 [RFC5208] π«Ά
1.1. Requirements Terminology π
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 [RFC2119] β¨
1.2. ASN.1 Syntax Notation π§
the key package is defined using ASN.1 [X.680], [X.681], [X.682], and [X.683] π
1.3. Summary of Updates to RFC 5208 π
here's the tea on what changed since [RFC5208] π the following summarizes the updates to [RFC5208]:
- ok first, we changed the name "PrivateKeyInfo" to "OneAsymmetricKey" π this reflects the addition of the publicKey field, so both parts of the asymmetric key can be conveyed separately. not every algorithm will use both fields, but the publicKey field was added for completeness.
- we defined the Asymmetric Key Package CMS content type β¨
- we removed the redundant IMPLICIT from attributes π§Ή
- we added publicKey to OneAsymmetricKey and updated the version number π₯
- we added that PKCS #9 attributes may be supported πΈ
- we added some discussion of compatibility with other private-key formats π¦
- we added requirements for an encoding rule set π
- we changed the imports from PKCS #5 to [RFC5912] and [RFC5911] π
- we replaced ALGORITHM-IDENTIFIER with ALGORITHM from [RFC5912] π
- we registered the application/pkcs8 media type and the .p8 file extension π
2. Asymmetric Key Package CMS Content Type ποΈ
the asymmetric key package CMS content type is used to transfer one or more plaintext asymmetric keys from one party to another π an asymmetric key package MAY be encapsulated in one or more CMS protecting content types (see Section 4). earlier versions of this specification [RFC5208] did not specify a particular encoding rule set, but generators SHOULD use DER [X.690] and receivers MUST support BER [X.690], which also includes DER [X.690] π«Ά
the asymmetric key package content type has the following syntax π
ct-asymmetric-key-package CONTENT-TYPE ::=
{ AsymmetricKeyPackage IDENTIFIED BY id-ct-KP-aKeyPackage }
id-ct-KP-aKeyPackage OBJECT IDENTIFIER ::=
{ joint-iso-itu-t(2) country(16) us(840) organization(1)
gov(101) dod(2) infosec(1) formats(2)
key-package-content-types(78) 5
}
AsymmetricKeyPackage ::= SEQUENCE SIZE (1..MAX) OF OneAsymmetricKey
OneAsymmetricKey ::= SEQUENCE {
version Version,
privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
privateKey PrivateKey,
attributes [0] Attributes OPTIONAL,
...,
[[2: publicKey [1] PublicKey OPTIONAL ]],
...
}
PrivateKeyInfo ::= OneAsymmetricKey
-- PrivateKeyInfo is used by [P12]. If any items tagged as version
-- 2 are used, the version must be v2, else the version should be
-- v1. When v1, PrivateKeyInfo is the same as it was in [RFC5208].
Version ::= INTEGER { v1(0), v2(1) } (v1, ..., v2)
PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
{ PUBLIC-KEY,
{ PrivateKeyAlgorithms } }
PrivateKey ::= OCTET STRING
-- Content varies based on type of key. The
-- algorithm identifier dictates the format of
-- the key.
PublicKey ::= BIT STRING
-- Content varies based on type of key. The
-- algorithm identifier dictates the format of
-- the key.
Attributes ::= SET OF Attribute { { OneAsymmetricKeyAttributes } }
the AsymmetricKeyPackage contains one or more OneAsymmetricKey elements π
the syntax of OneAsymmetricKey fits a version number, an indication of the asymmetric algorithm to be used with the private key, a private key, optional keying material attributes (e.g., userCertificate from [X.520]), and an optional public key π in general, either the public key or the certificate will be present. in very rare cases both will be present, which means two copies of the public key π OneAsymmetricKey renames the PrivateKeyInfo syntax defined in [RFC5208]. the new name better reflects the ability to carry both private- and public-key components. backwards compatibility with the original PrivateKeyInfo is preserved via the version number. here's how the fields in OneAsymmetricKey work π§
- version identifies the version of OneAsymmetricKey. if publicKey is present, then version is set to v2; otherwise version is set to v1.
- privateKeyAlgorithm identifies the private-key algorithm and optionally contains parameters associated with the asymmetric key pair. the algorithm is identified by an object identifier (OID), and the format of the parameters depends on the OID. the PrivateKeyAlgorithms information object set restricts which OIDs are permissible. the value placed in privateKeyAlgorithmIdentifier is the value an originator would apply to indicate which algorithm is to be used with the private key.
- privateKey is an OCTET STRING that contains the value of the private key. its interpretation is defined in the registration of the private-key algorithm. for example, a DSA key is an INTEGER, an RSA key is represented as RSAPrivateKey as defined in [RFC3447], and an Elliptic Curve Cryptography (ECC) key is represented as ECPrivateKey as defined in [RFC5915] β¨
- attributes is OPTIONAL. it contains information corresponding to the public key (e.g., certificates). the attributes field uses the class ATTRIBUTE, which is restricted by the OneAsymmetricKeyAttributes information object set. OneAsymmetricKeyAttributes is an open-ended set in this document, and other documents can constrain these values. attributes from [RFC2985] MAY be supported πΈ
- publicKey is OPTIONAL. when present, it contains the public key encoded in a BIT STRING. any structure within the BIT STRING depends on the privateKeyAlgorithm. for example, a DSA key is an INTEGER. note that RSA public keys are included in RSAPrivateKey (i.e., n and e are present), as per [RFC3447], and ECC public keys are included in ECPrivateKey (i.e., in the publicKey field), as per [RFC5915] π¦
5. Other Private-Key Format Considerations β¨
okay so this doc is about a content type that moves asymmetric private keys around π, but there are two OTHER formats people have used for the same job, and we need to talk about them bestie π
- Personal Information Exchange (PFX) Syntax Standard [P12] π, which everyone just calls PKCS #12 or P12, is a transfer syntax for personal identity info. That covers private keys, certificates, miscellaneous secrets, and extensions. OneAsymmetricKey, PrivateKeyInfo, and EncryptedPrivateKeyInfo can all ride inside a P12 message. The private key info (OneAsymmetricKey and PrivateKeyInfo) lives in the P12 keyBag BAG-TYPE, and EncryptedPrivateKeyInfo goes in the pkcs8ShroudedKeyBag BAG-TYPE. In current implementations,
.pfxand.p12file extensions can be used interchangeably π¦ - Microsoft's private-key proprietary transfer syntax π», which uses the
.pvkfile extension for local storage.
The .pvk and .p12/.pfx formats are NOT interchangeable, but conversion tools exist to go from one to the other π so you're not totally stuck.
Now, to actually pull the private-key info out of an AsymmetricKeyPackage, you have to peel off the encapsulating layers first π§ At a minimum, the outer ContentInfo [RFC5652] layer has to go. If the AsymmetricKeyPackage is wrapped in a SignedData [RFC5652], then the SignedData and EncapsulatedContentInfo layers [RFC5652] also need to come off. Same deal for EnvelopedData, EncryptedData, and AuthenticatedData (all from [RFC5652]), plus AuthEnvelopedData from [RFC5083]. Once every outer layer is gone, you've got as many sets of private-key info as you have OneAsymmetricKey structures π
Here's the fun bit: OneAsymmetricKey and PrivateKeyInfo are the same structure, so either one can be saved as a .p8 file or dropped into the P12 KeyBag BAG-TYPE. π But HEADS UP, removing those encapsulating security layers will invalidate any signature AND may expose the key to unauthorized disclosure π > Do not peel the layers off in a sketchy place!
.p8 files are sometimes PEM-encoded β¨ and when they are, they use the .pem file extension. PEM encoding is either:
- the Base64 encoding (from Section 4 of [RFC4648]) of the DER-encoded EncryptedPrivateKeyInfo, sandwiched between these lines:
-----BEGIN ENCRYPTED PRIVATE KEY-----
-----END ENCRYPTED PRIVATE KEY-----
- or the Base64 encoding (see Section 4 of [RFC4648]) of the DER-encoded PrivateKeyInfo, sandwiched between these lines:
-----BEGIN PRIVATE KEY-----
-----END PRIVATE KEY-----
6. Security Considerations π
Okay, this section is SERIOUS and I'm not gonna sugarcoat it π Protecting the private-key info is vital to public-key cryptography. If the private-key material gets disclosed to another entity, that can lead to masquerades (someone pretending to be you, basically π±). The encryption algorithm used in the encryption process has to be as 'strong' as the key it's protecting. A weak lock on a gold vault is NOT it, periodt π
Also, the asymmetric key package contents are NOT protected by this content type on their own π This content type can be combined with a security protocol to protect what's inside the package, so pair it up with something that does the job.
7. IANA Considerations πΈ
This document uses object identifiers to identify a CMS content type and the ASN.1 module found in Appendix A. The CMS content type OID is registered in a DoD arc, and the ASN.1 module OID is registered in an arc delegated by RSADSI to the SMIME Working Group. No further action by IANA is necessary for this document or for any anticipated updates. Done and dusted β
This spec also defines a new media subtype, which IANA has registered at http://www.iana.org/.
7.1. Registration of media subtype application/pkcs8
Here's the registration template, copied exactly so nothing gets lost in translation π§
Type name: application
Subtype name: pkcs8
Required parameters: None
Optional parameters: None
Encoding considerations: binary
Security considerations: Carries a cryptographic private key.
See section 6.
Interoperability considerations:
The PKCS #8 object inside this media type MUST be DER-encoded
PrivateKeyInfo.
Published specification: RFC 5958
Applications which use this media type:
Any MIME-compliant transport that processes asymmetric keys.
Additional information:
Magic number(s): None
File extension(s): .p8
Macintosh File Type Code(s):
Person & email address to contact for further information:
Sean Turner <turners@ieca.com>
Restrictions on usage: none
Author:
Sean Turner <turners@ieca.com>
Intended usage: COMMON
Change controller:
The IESG
The big rule in there is that the PKCS #8 object inside this media type MUST be DER-encoded PrivateKeyInfo π₯ That one is non-negotiable, bestie.
8. References π
8.1. Normative References
These are the must-reads, the ones the spec leans on hard π«Ά
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, March 1997.
[RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data
Encodings", RFC 4648, October 2006.
[RFC5652] Housley, R., "Cryptographic Message Syntax (CMS)", STD
70, RFC 5652, September 2009.
[RFC5911] Hoffman, P. and J. Schaad, "New ASN.1 Modules for
Cryptographic Message Syntax (CMS) and S/MIME", RFC 5911,
June 2010.
[RFC5912] Hoffman, P. and J. Schaad, "New ASN.1 Modules for the
Public Key Infrastructure Using X.509 (PKIX)", RFC 5912,
June 2010.
[X.680] ITU-T Recommendation X.680 (2002) | ISO/IEC 8824-1:2002.
Information Technology - Abstract Syntax Notation One.
[X.681] ITU-T Recommendation X.681 (2002) | ISO/IEC 8824-2:2002.
Information Technology - Abstract Syntax Notation One:
Information Object Specification.
[X.682] ITU-T Recommendation X.682 (2002) | ISO/IEC 8824-3:2002.
Information Technology - Abstract Syntax Notation One:
Constraint Specification.
[X.683] ITU-T Recommendation X.683 (2002) | ISO/IEC 8824-4:2002.
Information Technology - Abstract Syntax Notation One:
Parameterization of ASN.1 Specifications.
[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).
8.2. Informative References
These are the extra-credit reads, the background stuff that's helpful but not required π€
[P12] RSA Laboratories, "PKCS #12 v1.0: Personal Information
Exchange Syntax", June 1999.
[RFC2985] Nystrom, M. and B. Kaliski, "PKCS #9: Selected Object
Classes and Attribute Types Version 2.0", RFC 2985,
November 2000.
[RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography
Standards (PKCS) #1: RSA Cryptography Specifications
Version 2.1", RFC 3447, February 2003.
[RFC5083] Housley, R., "Cryptographic Message Syntax (CMS)
Authenticated-Enveloped-Data Content Type", RFC 5083,
November 2007.
[RFC5208] Kaliski, B., "Public-Key Cryptography Standards (PKCS)
#8: Private-Key Information Syntax Specification Version
1.2", RFC 5208, May 2008.
[X.520] ITU-T Recommendation X.520 (2005) | ISO/IEC 9594-6:2005,
Information technology - Open Systems Interconnection -
The Directory: Selected attribute types.
[RFC5915] Turner, S. and D. Brown, "Elliptic Curve Private Key
Structure", RFC 5915, June 2010.
Appendix A. ASN.1 Module β¨
okay bestie, this annex is where the whole spec gets its official ASN.1 definitions π It's written in ASN.1 as defined in [X.680] through [X.683], so if you ever need the exact structures, this is the source of truth π€
Heads up: this block is normative, which means it's the real deal and not just a nice-to-have π₯
AsymmetricKeyPackageModuleV1
{ iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9)
smime(16) modules(0) id-mod-asymmetricKeyPkgV1(50) }
DEFINITIONS IMPLICIT TAGS ::=
BEGIN
-- EXPORTS ALL
IMPORTS
-- FROM New SMIME ASN.1 [RFC5911]
Attribute{}, CONTENT-TYPE
FROM CryptographicMessageSyntax-2009
{ iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-9(9)
smime(16) modules(0) id-mod-cms-2004-02(41) }
-- From New PKIX ASN.1 [RFC5912]
ATTRIBUTE
FROM PKIX-CommonTypes-2009
{ iso(1) identified-organization(3) dod(6) internet(1)
security(5) mechanisms(5) pkix(7) id-mod(0)
id-mod-pkixCommon-02(57) }
-- From New PKIX ASN.1 [RFC5912]
AlgorithmIdentifier{}, ALGORITHM, PUBLIC-KEY, CONTENT-ENCRYPTION
FROM AlgorithmInformation-2009
{ iso(1) identified-organization(3) dod(6) internet(1)
security(5) mechanisms(5) pkix(7) id-mod(0)
id-mod-algorithmInformation-02(58) }
;
ContentSet CONTENT-TYPE ::= {
ct-asymmetric-key-package,
... -- Expect additional content types --
}
ct-asymmetric-key-package CONTENT-TYPE ::=
{ AsymmetricKeyPackage IDENTIFIED BY id-ct-KP-aKeyPackage }
id-ct-KP-aKeyPackage OBJECT IDENTIFIER ::=
{ joint-iso-itu-t(2) country(16) us(840) organization(1)
gov(101) dod(2) infosec(1) formats(2)
key-package-content-types(78) 5
}
AsymmetricKeyPackage ::= SEQUENCE SIZE (1..MAX) OF OneAsymmetricKey
OneAsymmetricKey ::= SEQUENCE {
version Version,
privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
privateKey PrivateKey,
attributes [0] Attributes OPTIONAL,
...,
[[2: publicKey [1] PublicKey OPTIONAL ]],
...
}
PrivateKeyInfo ::= OneAsymmetricKey
-- PrivateKeyInfo is used by [P12]. If any items tagged as version
-- 2 are used, the version must be v2, else the version should be
-- v1. When v1, PrivateKeyInfo is the same as it was in [RFC5208].
Version ::= INTEGER { v1(0), v2(1) } (v1, ..., v2)
PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
{ PUBLIC-KEY,
{ PrivateKeyAlgorithms } }
PrivateKey ::= OCTET STRING
-- Content varies based on type of key. The
-- algorithm identifier dictates the format of
-- the key.
PublicKey ::= BIT STRING
-- Content varies based on type of key. The
-- algorithm identifier dictates the format of
-- the key.
Attributes ::= SET OF Attribute { { OneAsymmetricKeyAttributes } }
OneAsymmetricKeyAttributes ATTRIBUTE ::= {
... -- For local profiles
}
-- An alternate representation that makes full use of ASN.1
-- constraints follows. Also note that PUBLIC-KEY needs to be
-- imported from the new PKIX ASN.1 Algorithm Information module
-- and PrivateKeyAlgorithms needs to be commented out.
-- OneAsymmetricKey ::= SEQUENCE {
-- version Version,
-- privateKeyAlgorithm SEQUENCE {
-- algorithm PUBLIC-KEY.&id({PublicKeySet}),
-- parameters PUBLIC-KEY.&Params({PublicKeySet}
-- {@privateKeyAlgorithm.algorithm})
-- OPTIONAL}
-- privateKey OCTET STRING (CONTAINING
-- PUBLIC-KEY.&PrivateKey({PublicKeySet}
-- {@privateKeyAlgorithm.algorithm})),
-- attributes [0] Attributes OPTIONAL,
-- ...,
-- [[2: publicKey [1] BIT STRING (CONTAINING
-- PUBLIC-KEY.&Params({PublicKeySet}
-- {@privateKeyAlgorithm.algorithm})
-- OPTIONAL,
-- ...
-- }
EncryptedPrivateKeyInfo ::= SEQUENCE {
encryptionAlgorithm EncryptionAlgorithmIdentifier,
encryptedData EncryptedData }
EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
{ CONTENT-ENCRYPTION,
{ KeyEncryptionAlgorithms } }
EncryptedData ::= OCTET STRING -- Encrypted PrivateKeyInfo
PrivateKeyAlgorithms ALGORITHM ::= {
... -- Extensible
}
KeyEncryptionAlgorithms ALGORITHM ::= {
... -- Extensible
}
END
Acknowledgements π«Ά
okay the people who made this possible!! πΈ Burt Kaliski and Jim Randall at RSA get the first big thank-you, because this whole doc wouldn't exist without the earlier version they wrote π
Then a massive shout-out to Pasi Eronen, Roni Even, Alfred Hoenes, Russ Housley, Jim Schaad, and Carl Wallace π you all are literally iconic β¨
Author's Address π¦
Sean Turner IECA, Inc. 3057 Nutley Street, Suite 106 Fairfax, VA 22031 USA
EMail: turners@ieca.com
and that's a wrap on RFC 5958, bestie!! ππ
π¦ where this page comes from
- ietf: rfc5958 2010-08
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms