Internet-Draft | COSE HPKE | October 2023 |
Tschofenig, et al. | Expires 9 April 2024 | [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 9 April 2024.¶
Copyright (c) 2023 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. HPKE utilizes a non-interactive ephemeral-static Diffie-Hellman exchange to establish a shared secret. The motivation for standardizing a public key encryption scheme is explained in the introduction of [RFC9180].¶
The HPKE specification provides a variant of public key encryption of arbitrary-sized plaintexts for a recipient public key. It also includes three authenticated variants, including one that authenticates possession of a pre-shared key, one that authenticates possession of a key encapsulation mechanism (KEM) private key, and one that authenticates possession of both a pre-shared key and a KEM private key.¶
This specification utilizes HPKE as a foundational building block and carries the output to 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:¶
This specification supports two uses of HPKE in COSE, namely¶
In both cases a new COSE header parameter, called 'encapsulated_key', 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 'encapsulated_key' 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.¶
With the one layer structure the information carried inside the COSE_recipient structure is embedded inside the COSE_Encrypt0.¶
HPKE is used to directly encrypt the plaintext and the resulting ciphertext is either included in the COSE_Encrypt0 or is detached. If a payload is transported separately then it is called "detached content". A nil CBOR object is placed in the location of the ciphertext. See Section 5 of [RFC9052] for a description of detached payloads.¶
The sender MUST set the alg parameter in the protected header, which indicates the use of HPKE.¶
The sender MUST place the 'encapsulated_key' parameter into the unprotected header. Although the use of the 'kid' parameter in COSE_Encrypt0 is discouraged by RFC 9052, this profile allows the use of the 'kid' parameter (or other parameters) to 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.¶
HPKE defines an API and this API uses an "aad" parameter as input. When COSE_Encrypt0 is used then there is no AEAD function executed by COSE natively and HPKE offers this functionality.¶
The "aad" parameter provided to the HPKE API is constructed as follows (and the design has been re-used from [RFC9052]):¶
Enc_structure = [ context : "Encrypt0", protected : empty_or_serialized_map, external_aad : bstr ] empty_or_serialized_map = bstr .cbor header_map / bstr .size 0¶
The protected field in the Enc_structure contains the protected attributes from the COSE_Encrypt0 structure at layer 0, encoded in a bstr type.¶
The external_aad field in the Enc_structure contains the Externally Supplied Data described in Section 4.3 and Section 5.3 in RFC 9052. If this field is not supplied, it defaults to a zero-length byte string.¶
The HPKE APIs also use an "info" parameter as input and the details are provided in Section 3.2.¶
Figure 1 shows the COSE_Encrypt0 CDDL structure.¶
The COSE_Encrypt0 MAY be tagged or untagged.¶
An example is shown in Section 5.1.¶
With the two layer structure the HPKE information is conveyed in the COSE_recipient structure, i.e. one COSE_recipient structure per recipient.¶
In this approach the following layers are involved:¶
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.¶
The COSE_recipient structure, shown in Figure 2, is repeated for each recipient.¶
The COSE_Encrypt MAY be tagged or untagged.¶
An example is shown in Section 5.2.¶
The HPKE specification defines the "info" parameter as a context information structure that is used to ensure that the derived keying material is bound to the context of the transaction.¶
This section provides a suggestion for constructing the info structure. HPKE leaves the info parameter for these two functions as optional. Application profiles of this specification MAY populate the fields of the COSE_KDF_Context structure or MAY use a different structure as input to the "info" parameter. If no content for the "info" parameter is not supplied, it defaults to a zero-length byte string.¶
This specification re-uses the context information structure defined in [RFC9053] as a foundation for the info structure. This payload becomes the content of the info parameter for the HPKE functions, when utilized. For better readability of this specification the COSE_KDF_Context structure is repeated in Figure 3.¶
This specification registers a number of ciphersuites for use with HPKE. A ciphersuite is thereby a combination of several algorithm configurations:¶
The "KEM", "KDF", and "AEAD" values are conceptually taken from the HPKE IANA registry [HPKE-IANA]. Hence, COSE-HPKE cannot use a algorithm combination that is not already available with HPKE.¶
For better readability of the algorithm combination ciphersuites labels are build 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]:¶
For a list of ciphersuite registrations, please see Section 7. The following table summarizes the relationship between the ciphersuites registered in this document and the values registered in the HPKE IANA registry [HPKE-IANA].¶
+--------------------------------------------------+------------------+ | COSE-HPKE | HPKE | | Cipher Suite Label | KEM | KDF | AEAD | +--------------------------------------------------+-----+-----+------+ | HPKE-Base-P256-SHA256-AES128GCM |0x10 | 0x1 | 0x1 | | HPKE-Base-P256-SHA256-ChaCha20Poly1305 |0x10 | 0x1 | 0x3 | | HPKE-Base-P384-SHA384-AES256GCM |0x11 | 0x2 | 0x2 | | HPKE-Base-P384-SHA384-ChaCha20Poly1305 |0x11 | 0x2 | 0x3 | | HPKE-Base-P521-SHA512-AES256GCM |0x12 | 0x3 | 0x2 | | HPKE-Base-P521-SHA512-ChaCha20Poly1305 |0x12 | 0x3 | 0x3 | | HPKE-Base-X25519-SHA256-AES128GCM |0x20 | 0x1 | 0x1 | | HPKE-Base-X25519-SHA256-ChaCha20Poly1305 |0x20 | 0x1 | 0x3 | | HPKE-Base-X448-SHA512-AES256GCM |0x21 | 0x3 | 0x2 | | HPKE-Base-X448-SHA512-ChaCha20Poly1305 |0x21 | 0x3 | 0x3 | | HPKE-Base-X25519Kyber768-SHA256-AES256GCM |0x30 | 0x1 | 0x2 | | HPKE-Base-X25519Kyber768-SHA256-ChaCha20Poly1305 |0x30 | 0x1 | 0x3 | | HPKE-Base-CP256-SHA256-ChaCha20Poly1305 |0x13 | 0x1 | 0x3 | | HPKE-Base-CP256-SHA256-AES128GCM |0x13 | 0x1 | 0x1 | | HPKE-Base-CP521-SHA512-ChaCha20Poly1305 |0x15 | 0x3 | 0x3 | | HPKE-Base-CP521-SHA512-AES256GCM |0x15 | 0x3 | 0x2 | +--------------------------------------------------+-----+-----+------+¶
Note that the last four entries in the table refer to the compact encoding of the public keys defined in [I-D.irtf-cfrg-dnhpke].¶
As the list indicates, the ciphersuite labels have been abbreviated at least to some extend to maintain the tradeoff between readability and length.¶
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 COSE_Encrypt0 structure using the HPKE scheme is shown in Figure 4. Line breaks and comments have been inserted for better readability.¶
This example uses HPKE-Base-P256-SHA256-AES128GCM, which corresponds to the following HPKE algorithm combination:¶
In this example we assume that a sender wants to transmit a payload to two recipients using the two-layer structure. 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 5. Line breaks and comments have been inserted for better readability.¶
This example uses AES-128-GCM for encryption of the plaintext "This is the content." with aad="" at layer 0. The ciphertext is detached.¶
At the recipient structure at layer 1, this example uses HPKE-Base-P256-SHA256-AES128GCM as the algorithm, which correspond to the following HPKE algorithm combination:¶
To offer authentication of the sender the payload in Figure 5 is signed with a COSE_Sign1 wrapper, which is outlined in Figure 6. The payload in Figure 6 is meant to contain the content of Figure 5.¶
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.¶
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.¶