Internet-Draft | COSE HPKE | April 2023 |
Tschofenig & Moran | Expires 15 October 2023 | [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.¶
This document defines the use of the HPKE base mode with COSE. Other modes are supported by HPKE but not by this specification.¶
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 15 October 2023.¶
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 defines several features for use with public key encryption and a subset of those features is applied to COSE ([RFC9052], [RFC9053]). Since COSE provides constructs for authentication, those are not re-used from the HPKE specification. This specification uses the "base" mode, as it is called in HPKE specification language.¶
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¶
HPKE in Base mode requires little information to be provided by the sender, namely¶
In the subsections below we explain how this information is carried inside the COSE_Encrypt0 and the COSE_Encrypt for the one layer and the two layer structure, respectively.¶
In both cases a new structure is used to convey information about the HPKE sender, namely the HPKE sender information structure (HPKE_sender_info).¶
When the alg value is set to 'HPKE-v1-BASE', the HPKE_sender_info structure MUST be present in the unprotected header parameter.¶
The CDDL grammar describing the HPKE_sender_info structure is:¶
HPKE_sender_info = [ kem_id : uint, ; kem identifier kdf_id : uint, ; kdf identifier aead_id : uint, ; aead identifier enc : bstr, ; encapsulated key ]¶
The fields have the following meaning:¶
kem_id: This parameter is used to identify the KEM. The registry for KEM ids has been established with RFC 9180.¶
kdf_id: This parameter contains the KDF identifier. The registry containing the KDF ids has been established with RFC 9180.¶
aead_id: This parameter contains the AEAD identifier. The registry containing the AEAD ids has been established with RFC 9180.¶
enc: This parameter contains the encapsulated key, which is output of the HPKE KEM.¶
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. The resulting ciphertext may be included in the COSE_Encrypt0 or may be 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 HPKE_sender_info structure into the unprotected header. Although the use of the kid parameter in COSE_Encrypt0 is discouraged by RFC 9052, this specification allows profiles of this specification to use 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.¶
Figure 2 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. For example, the content encrypted at layer 0 may be a firmware image. The same encrypted firmware image may need to be sent to many recipients; however, each recipient uses their own private key to obtain the CEK.¶
The COSE_recipient structure, shown in Figure 3, is repeated for each recipient.¶
The COSE_Encrypt MAY be tagged or untagged.¶
An example is shown in Section 5.2.¶
The SealBase(pkR, info, aad, pt) function is used to encrypt a plaintext pt to a recipient's public key (pkR).¶
Two cases of plaintext need to be distinguished:¶
The "aad" and the "info" parameters are described in Section 4.3 and Section 4.4, respectively.¶
If SealBase() is successful, it will output a ciphertext "ct" and an encapsulated key "enc".¶
The recipient will use the OpenBase(enc, skR, info, aad, ct) function with the "enc" and the "ct" parameters received from the sender. The "aad" and the "info" parameters are assumed to be constructed from the context and described in Section 4.3 and Section 4.4, respectively.¶
The OpenBase function will, if successful, decrypt "ct". When decrypted, the result will be either the CEK (when COSE_Encrypt is used), or the content (if COSE_Encrypt0 is used). The CEK is the symmetric key used to decrypt the ciphertext at layer 0.¶
HPKE requires an "aad" parameter to be provided to the SealBase and OpenBase functions. Note that there are three types of additional authenticated data used by this specification:¶
We describe the three variants in the subsections below.¶
When COSE_Encrypt0 is used then there is no separate AEAD function at the content encryption layer provided by COSE natively and HPKE offers this functionality.¶
The "aad" parameter provided to the SealBase and OpenBase functions is constructed as follows:¶
Enc_structure = [ context : "Encrypt0", protected : empty_or_serialized_map, external_aad : bstr ]¶
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 AAD used at the recipient layer re-uses Enc_structure from [RFC9052] and populates it with the following content:¶
Enc_structure = [ context : "Enc_Recipient", protected : empty_or_serialized_map, external_aad : bstr ]¶
The protected field in the Enc_structure contains the protected attributes from the COSE_recipient structure at layer 1, 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. In the COSE_Encrypt case this AAD information is also input to the AAD at layer 0, if an AEAD cipher is used at layer 0. If this field is not supplied, it defaults to a zero-length byte string.¶
The construction of AAD is defined in Section 5.3 of [RFC9052] (see Enc_structure structure).¶
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, when used with SealBase() and OpenBase(). 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 4.¶
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 5. Line breaks and comments have been inserted for better readability.¶
It uses the following algorithm combination: - KEM: DHKEM(P-256, HKDF-SHA256) - KDF: HKDF-SHA256 - AEAD: AES-128-GCM¶
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 6. Line breaks and comments have been inserted for better readability.¶
It uses the following algorithm combination:¶
The algorithm selection is based on the registry of the values offered by the alg parameters (see Section 7).¶
To offer authentication of the sender the payload in Figure 6 is signed with a COSE_Sign1 wrapper, which is shown in Figure 7. The payload in Figure 7 corresponds to the content shown in Figure 6.¶
This specification is based on HPKE and the security considerations of HPKE [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.¶
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 the it MUST be ensured that the guidelines for random number generations are followed.¶
The COSE_Encrypt structure MUST be authenticated using COSE constructs like COSE_Sign, COSE_Sign1, COSE_MAC, or COSE_MAC0.¶
When 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 Algorithm Parameters' registries in the 'Standards Action With Expert Review category.¶
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 for his contributions to the draft as a co-author of initial versions.¶
We would like to thank John Mattsson, Mike Prorock, Michael Richardson, Goeran Selander, Laurence Lundblade and Orie Steele for their review feedback.¶