Internet-Draft | COSE HPKE | January 2025 |
Tschofenig, et al. | Expires 22 July 2025 | [Page] |
This specification defines hybrid public-key encryption (HPKE) for use with CBOR Object Signing and Encryption (COSE). HPKE offers a variant of public-key encryption of arbitrary-sized plaintexts for a recipient public key.¶
HPKE works for any combination of an asymmetric key encapsulation mechanism (KEM), key derivation function (KDF), and authenticated encryption with additional data (AEAD) function. Authentication for HPKE in COSE is provided by COSE-native security mechanisms or by one of the authenticated variants of HPKE.¶
This document defines the use of the HPKE with COSE.¶
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.¶
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.¶
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."¶
This Internet-Draft will expire on 22 July 2025.¶
Copyright (c) 2025 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 (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
This document may contain material from IETF Documents or IETF Contributions published or made publicly available before November 10, 2008. The person(s) controlling the copyright in some of this material may not have granted the IETF Trust the right to allow modifications of such material outside the IETF Standards Process. Without obtaining an adequate license from the person(s) controlling the copyright in such materials, 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, except to format it for publication as an RFC or to translate it into languages other than English.¶
Hybrid public-key encryption (HPKE) [RFC9180] is a scheme that provides public key encryption of arbitrary-sized plaintexts given a recipient's public key.¶
This document defines the use of the HPKE with COSE ([RFC9052], [RFC9053]).¶
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.¶
This specification uses the following abbreviations and terms:¶
Content-encryption key (CEK), a term defined in CMS [RFC2630].¶
Hybrid Public Key Encryption (HPKE) is defined in [RFC9180].¶
pkR is the public key of the recipient, as defined in [RFC9180].¶
skR is the private key of the recipient, as defined in [RFC9180].¶
Authenticated Encryption with Associated Data (AEAD), see [RFC9180].¶
This specification supports two modes of HPKE in COSE, namely¶
HPKE Direct Encryption mode, where HPKE is used to encrypt the plaintext. This mode can only be used with a single recipient. Section 3.1.1 provides the details.¶
HPKE Key Encryption mode, where HPKE is used to encrypt a content encryption key (CEK) and the CEK is subsequently used to encrypt the plaintext. This mode supports multiple recipients. Section 3.1.2 provides the details.¶
In both cases a new COSE header parameter, called 'ek', is used to convey the content of the enc structure defined in the HPKE specification. "Enc" represents the serialized public key.¶
For use with HPKE the 'ek' header parameter MUST be present in the unprotected header parameter and MUST contain the encapsulated key, which is output of the HPKE KEM, and it is a bstr.¶
This mode is selected if COSE_Encrypt0 structure uses a COSE-HPKE algoritm.¶
Because there are no recipients, COSE_Encrypt structure MUST NOT be used.¶
Because COSE-HPKE supports header protection by definition, if 'alg' parameter is present, it MUST be in protected bucket, and SHALL be a COSE-HPKE algorithm.¶
Although the use of the 'kid' parameter in COSE_Encrypt0 is discouraged by RFC 9052, this documents RECOMMENDS the use of the 'kid' parameter (or other parameters) to explicitly identify the static recipient public key used by the sender. If the COSE_Encrypt0 contains the 'kid' then the recipient may use it to select the appropriate private key.¶
When encrypting, the inputs to the HPKE Seal operation are set as follows:¶
kem_id: Depends on the COSE-HPKE algorithm used.¶
pkR: The recipient public key, converted into HPKE public key.¶
kdf_id: Depends on the COSE-HPKE algorithm used.¶
aead_id: Depends on the COSE-HPKE algorithm used.¶
info: empty string.¶
aad: Canonical encoding of the Enc_structure from [RFC9052]).¶
pt: The raw message plaintext.¶
The outputs are used as follows:¶
enc: MUST be placed raw into the 'ek' (encapsulated key) parameter in the unprotected bucket.¶
ct: MUST be used as layer ciphertext. If not using detached content, this is directly placed as ciphertext in COSE_Encrypt0 structure. Otherwise, it is transported separately and the ciphertext field is nil. See Section 5 of [RFC9052] for a description of detached payloads.¶
When decrypting, the inputs to the HPKE Open operation are set as follows:¶
kem_id: Depends on the COSE-HPKE algorithm used.¶
skR: The recipient private key, converted into HPKE private key.¶
kdf_id: Depends on the COSE-HPKE algorithm used.¶
aead_id: Depends on the COSE-HPKE algorithm used.¶
info: empty string.¶
aad: Canonical encoding of the Enc_structure from [RFC9052]).¶
enc: The contents of the layer 'ek' parameter.¶
ct: The contents of the layer ciphertext.¶
The plaintext output is the raw message plaintext.¶
The COSE_Encrypt0 MAY be tagged or untagged.¶
An example is shown in Section 5.1.¶
This mode is selected if COSE_recipient structure uses a COSE-HPKE algorithm.¶
In this approach the following layers are involved:¶
Layer 0 (corresponding to the COSE_Encrypt structure) contains the content (plaintext) encrypted with the CEK. This ciphertext may be detached, and if not detached, then it is included in the COSE_Encrypt structure.¶
Layer 1 (corresponding to a recipient structure) contains parameters needed for HPKE to generate a shared secret used to encrypt the CEK. This layer conveys the encrypted CEK in the COSE_recipient structure using a COSE-HPKE algorithm. The unprotected header MAY contain the kid parameter to identify the static recipient public key the sender has been using with HPKE.¶
This two-layer structure is used to encrypt content that can also be shared with multiple parties at the expense of a single additional encryption operation. As stated above, the specification uses a CEK to encrypt the content at layer 0.¶
This describes the Recipient_structure. It serves instead of COSE_KDF_Context for COSE-HPKE recipients (and possibly other COSE algorithms defined outside this document). It MUST be used for COSE-HPKE recipients as it provides the protection for recipient protected headers. It is patterned after the Enc_structure in [RFC9052], but is specifically for a COSE_recipient, never a COSE_Encrypt. The COSE_KDF_Context MUST NOT be used in COSE-HPKE.¶
Recipient_structure = [ context: "Recipient", next_layer_alg: int/tstr, recipient_protected_header: empty_or_serialize_map, recipient_aad: bstr ]¶
"next_layer_alg" is the algorithm ID of the COSE layer for which the COSE_recipient is encrypting a key. It is the algorithm that the key MUST be used with. This value MUST match the alg parameter in the next lower COSE layer. (This serves the same purpose as the alg ID in the COSE_KDF_Context. It also mitigates attacks where a person-in-the-middle changes the following layer algorithm from an AEAD algorithm to one that is not foiling the protection of the following layer headers).¶
"recipient_protected_header" contains the protected headers from the COSE_recipient CBOR-encoded deterministically with the "Core Deterministic Encoding Requirements", specified in Section 4.2.1 of RFC 8949 [STD94].¶
"recipient_aad" contains any additional context the application wishes to protect. If none, it is a zero-length string. This is distinct from the external_aad for the whole COSE encrypt. It is per-recipient. Since it is not a header, it may be secret data that is not transmitted. It provides a means to convey many of the fields in COSE_KDF_Context.¶
Because COSE-HPKE supports header protection by definition, if 'alg' parameter is present, it MUST be in protected bucket, and SHALL be a COSE-HPKE algorithm.¶
The unprotected header MAY contain the kid parameter to identify the static recipient public key the sender used.¶
When encrypting, the inputs to the HPKE Seal operation are set as follows:¶
kem_id: Depends on the COSE-HPKE algorithm used.¶
pkR: The recipient public key, converted into HPKE public key.¶
kdf_id: Depends on the COSE-HPKE algorithm used.¶
aead_id: Depends on the COSE-HPKE algorithm used.¶
info: empty string.¶
aad: Canonical encoding of the Recipient_structure.¶
pt: The raw key for the next layer down.¶
The outputs are used as follows:¶
enc: MUST be placed raw into the 'ek' (encapsulated key) parameter in the unprotected bucket.¶
ct: MUST be placed raw in the ciphertext field in the COSE_recipient.¶
When decrypting, the inputs to the HPKE Open operation are set as follows:¶
kem_id: Depends on the COSE-HPKE algorithm used.¶
skR: The recipient private key, converted into HPKE private key.¶
kdf_id: Depends on the COSE-HPKE algorithm used.¶
aead_id: Depends on the COSE-HPKE algorithm used.¶
info: empty string.¶
aad: Canonical encoding of the Recipient_structure.¶
enc: The contents of the layer 'ek' parameter.¶
ct: The contents of the layer ciphertext field.¶
The plaintext output is the raw key for the next layer down.¶
It is not necessary to fill in recipient_aad as HPKE itself covers the attacks that recipient_aad (and COSE_KDF_Context (and SP800-56A)) are used to mitigate. COSE-HPKE use cases may use it for any purpose they wish, but it should generally be for small identifiers, context or secrets, not to protect bulk external data. Bulk external data should be protected at layer 0 with external_aad.¶
The COSE_recipient structure is repeated for each recipient.¶
When encrypting the content at layer 0 then the instructions in Section 5.3 of [RFC9052] MUST to be followed, which includes the calculation of the authenticated data strcture.¶
An example is shown in Section 5.2.¶
The COSE_Key with the existing key types can be used to represent KEM private or public keys. When using a COSE_Key for COSE-HPKE, the following checks are made:¶
If the "kty" field is "AKP", then the public and private keys SHALL be raw HPKE public and private keys (respectively) for the KEM used by the algorithm.¶
Otherwise, the key MUST be suitable for the KEM used by the algorithm. In case the "kty" parameter is "EC2" or "OKP", this means the value of "crv" parameter is suitable. For the algorithms defined in this document, the valid combinations of the KEM, "kty" and "crv" are shown in Figure 1.¶
If the "key_ops" field is present, it MUST include only "derive bits" for the private key and MUST be empty for the public key.¶
Examples of the COSE_Key for COSE-HPKE are shown in Section 5.3.¶
A ciphersuite is a group of algorithms, often sharing component algorithms such as hash functions, targeting a security level. A COSE-HPKE algorithm is composed of the following choices:¶
The "KEM", "KDF", and "AEAD" values are chosen from the HPKE IANA registry [HPKE-IANA].¶
For readability the algorithm ciphersuites labels are built according to the following scheme:¶
HPKE-<Version>-<Mode>-<KEM>-<KDF>-<AEAD>¶
The "Mode" indicator may be populated with the following values from Table 1 of [RFC9180]:¶
"Base" refers to "mode_base" described in Section 5.1.1 of [RFC9180], which only enables encryption to the holder of a given KEM private key.¶
"PSK" refers to "mode_psk", described in Section 5.1.2 of [RFC9180], which authenticates using a pre-shared key.¶
"Auth" refers to "mode_auth", described in Section 5.1.3 of [RFC9180], which authenticates using an asymmetric key.¶
"Auth_Psk" refers to "mode_auth_psk", described in Section 5.1.4 of [RFC9180], which authenticates using both a PSK and an asymmetric key.¶
For a list of ciphersuite registrations, please see Section 7. The following table summarizes the relationship between the ciphersuites registered in this document, which all use the "Base" mode and the values registered in the HPKE IANA registry [HPKE-IANA].¶
+--------------------------------------------------+------------------+ | COSE-HPKE | HPKE | | Cipher Suite Label | KEM | KDF | AEAD | +--------------------------------------------------+-----+-----+------+ | HPKE-0 |0x10 | 0x1 | 0x1 | | HPKE-1 |0x11 | 0x2 | 0x2 | | HPKE-2 |0x12 | 0x3 | 0x2 | | HPKE-3 |0x20 | 0x1 | 0x1 | | HPKE-4 |0x20 | 0x1 | 0x3 | | HPKE-5 |0x21 | 0x3 | 0x2 | | HPKE-6 |0x21 | 0x3 | 0x3 | +--------------------------------------------------+-----+-----+------+¶
As the list indicates, the ciphersuite labels have been abbreviated at least to some extend to maintain the tradeoff between readability and length.¶
The ciphersuite list above is a minimal starting point. Additional ciphersuites can be registered into the already existing registry. For example, once post-quantum cryptographic algorithms have been standardized it might be beneficial to register ciphersuites for use with COSE-HPKE. Additionally, ciphersuites utilizing the compact encoding of the public keys, as defined in [I-D.irtf-cfrg-dnhpke], may be standardized for use in constrained environments.¶
As a guideline for ciphersuite submissions to the IANA CoSE algorithm registry, the designated experts must only register combinations of (KEM, KDF, AEAD) triple that consitute valid combinations for use with HPKE, the KDF used should (if possible) match one internally used by the KEM, and components should not be mixed between global and national standards.¶
The COSE-HPKE algorithm uniquely determines the KEM for which a COSE_Key is used. The following mapping table shows the valid combinations of the KEM used, COSE_Key type and its curve/key subtype.¶
This section provides a set of examples that shows all COSE message types (COSE_Encrypt0, COSE_Encrypt and COSE_MAC) to which the COSE-HPKE can be applied, and also provides some examples of key representation for HPKE KEM.¶
Each example of the COSE message includes the following information that can be used to check the interoperability of COSE-HPKE implementations:¶
plaintext: Original data of the encrypted payload.¶
external_aad: Externally supplied AAD.¶
skR: A recipient private key.¶
skE: An ephemeral sender private key paired with the encapsulated key.¶
This example assumes that a sender wants to communicate an encrypted payload to a single recipient in the most efficient way.¶
An example of the HPKE Direct Encryption Mode is shown in Figure 2. Line breaks and comments have been inserted for better readability.¶
This example uses the following:¶
alg: HPKE-0¶
plaintext: "This is the content."¶
external_aad: "COSE-HPKE app"¶
skR: h'57c92077664146e876760c9520d054aa93c3afb04e306705db6090308507b4d3'¶
skE: h'42dd125eefc409c3b57366e721a40043fb5a58e346d51c133128a77237160218'¶
In this example we assume that a sender wants to transmit a payload to two recipients using the HPKE Key Encryption mode. Note that it is possible to send two single-layer payloads, although it will be less efficient.¶
An example of the COSE_Encrypt structure using the HPKE scheme is shown in Figure 3. Line breaks and comments have been inserted for better readability.¶
This example uses the following:¶
TODO: recompute this for Recipient_structure¶
Encryption alg: AES-128-GCM¶
plaintext: "This is the content."¶
detatched ciphertext: h'cc168c4e148c52a83010a75250935a47ccb8682deebcef8fce5d60c161e849f53a2dc664'¶
kid:"01"¶
kid:"02"¶
To offer authentication of the sender the payload in Figure 3 is signed with a COSE_Sign1 wrapper, which is outlined in Figure 4. The payload in Figure 4 is meant to contain the content of Figure 3.¶
Examples of private and public KEM key representation are shown below.¶
This specification is based on HPKE and the security considerations of [RFC9180] are therefore applicable also to this specification.¶
HPKE assumes the sender is in possession of the public key of the recipient and HPKE COSE makes the same assumptions. Hence, some form of public key distribution mechanism is assumed to exist but outside the scope of this document.¶
HPKE relies on a source of randomness to be available on the device. Additionally, with the two layer structure the CEK is randomly generated and it MUST be ensured that the guidelines in [RFC8937] for random number generations are followed.¶
HPKE in Base mode does not offer authentication as part of the HPKE KEM. In this case COSE constructs like COSE_Sign, COSE_Sign1, COSE_MAC, or COSE_MAC0 can be used to add authentication. HPKE also offers modes that offer authentication.¶
If COSE_Encrypt or COSE_Encrypt0 is used with a detached ciphertext then the subsequently applied integrity protection via COSE_Sign, COSE_Sign1, COSE_MAC, or COSE_MAC0 does not cover this detached ciphertext. Implementers MUST ensure that the detached ciphertext also experiences integrity protection. This is, for example, the case when an AEAD cipher is used to produce the detached ciphertext but may not be guaranteed by non-AEAD ciphers.¶
This document requests IANA to add new values to the 'COSE Algorithms' and to the 'COSE Header Parameters' registries.¶
Name: HPKE-0¶
Value: TBD1 (Assumed: 35)¶
Description: Cipher suite for COSE-HPKE in Base Mode that uses the DHKEM(P-256, HKDF-SHA256) KEM, the HKDF-SHA256 KDF and the AES-128-GCM AEAD.¶
Capabilities: [kty]¶
Change Controller: IESG¶
Reference: [[TBD: This RFC]]¶
Recommended: Yes¶
Name: HPKE-1¶
Value: TBD3 (Assumed: 37)¶
Description: Cipher suite for COSE-HPKE in Base Mode that uses the DHKEM(P-384, HKDF-SHA384) KEM, the HKDF-SHA384 KDF, and the AES-256-GCM AEAD.¶
Capabilities: [kty]¶
Change Controller: IESG¶
Reference: [[TBD: This RFC]]¶
Recommended: Yes¶
Name: HPKE-2¶
Value: TBD5 (Assumed: 39)¶
Description: Cipher suite for COSE-HPKE in Base Mode that uses the DHKEM(P-521, HKDF-SHA512) KEM, the HKDF-SHA512 KDF, and the AES-256-GCM AEAD.¶
Capabilities: [kty]¶
Change Controller: IESG¶
Reference: [[TBD: This RFC]]¶
Recommended: Yes¶
Name: HPKE-3¶
Value: TBD7 (Assumed: 41)¶
Description: Cipher suite for COSE-HPKE in Base Mode that uses the DHKEM(X25519, HKDF-SHA256) KEM, the HKDF-SHA256 KDF, and the AES-128-GCM AEAD.¶
Capabilities: [kty]¶
Change Controller: IESG¶
Reference: [[TBD: This RFC]]¶
Recommended: Yes¶
Name: HPKE-4¶
Value: TBD8 (Assumed: 42)¶
Description: Cipher suite for COSE-HPKE in Base Mode that uses the DHKEM(X25519, HKDF-SHA256) KEM, the HKDF-SHA256 KDF, and the ChaCha20Poly1305 AEAD.¶
Capabilities: [kty]¶
Change Controller: IESG¶
Reference: [[TBD: This RFC]]¶
Recommended: Yes¶
Name: HPKE-5¶
Value: TBD9 (Assumed: 43)¶
Description: Cipher suite for COSE-HPKE in Base Mode that uses the DHKEM(X448, HKDF-SHA512) KEM, the HKDF-SHA512 KDF, and the AES-256-GCM AEAD.¶
Capabilities: [kty]¶
Change Controller: IESG¶
Reference: [[TBD: This RFC]]¶
Recommended: Yes¶
Name: HPKE-6¶
Value: TBD10 (Assumed: 44)¶
Description: Cipher suite for COSE-HPKE in Base Mode that uses the DHKEM(X448, HKDF-SHA512) KEM, the HKDF-SHA512 KDF, and the ChaCha20Poly1305 AEAD.¶
Capabilities: [kty]¶
Change Controller: IESG¶
Reference: [[TBD: This RFC]]¶
Recommended: Yes¶
We would like thank the following individuals for their contributions to the design of embedding the HPKE output into the COSE structure following a long and lively mailing list discussion:¶
Finally, we would like to thank Russ Housley and Brendan Moran for their contributions to the draft as co-authors of initial versions.¶
We would like to thank John Mattsson, Mike Prorock, Michael Richardson, and Goeran Selander for their review feedback.¶