Use of Hybrid Public-Key Encryption (HPKE) with CBOR Object Signing and Encryption (COSE)Arm Limitedhannes.tschofenig@arm.comVigil Security, LLChousley@vigilsec.comArm LimitedBrendan.Moran@arm.com
Security
COSEInternet-DraftThis 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) encryption function. Authentication for HPKE in COSE is
provided by COSE-native security mechanisms.Hybrid public-key encryption (HPKE) 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 .The HPKE specification defines several features for use with public key encryption
and a subset of those features is applied to COSE . 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
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 .
- Hybrid Public Key Encryption (HPKE) is defined in .
- pkR is the public key of the recipient, as defined in .
- skR is the private key of the recipient, as defined in .This specification supports two uses of HPKE in COSE, namelyHPKE in a single sender - single recipient setup.
This use cases uses a one layer structure for efficiency.
provides the details.HPKE in a single sender - multiple recipient setup.
This use case requires a two layer structure.
provides the details.HPKE in “base” mode requires little information to be exchanged between
a sender and a recipient, namelyalgorithm information,the ephemeral public key, andan identifier of the static recipient key.In the subsections below we explain how this information is carried
inside the COSE_Encrypt0 and the COSE_Encrypt1 for the one layer and the
two layer structure, respectively.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.A sender MUST set the alg parameter in the protected header, which
indicates the use of HPKE. The values for the alg parameter MUST be
taken from , or values registered in the future with the
COSE_ALG_HPKE_* prefix.The sender MUST place the kid and ephemeral public key into the unprotected
header. shows the COSE_Encrypt0 CDDL structure.The COSE_Encrypt0 MAY be tagged or untagged.An example is shown in .The SealBase(pkR, info, aad, pt) function is used to encrypt a plaintext pt to
a recipient’s public key (pkR).For use in COSE_Encrypt0, the plaintext “pt” passed into the SealBase
is the raw plaintext.In the absence of an application profile standard specifying
otherwise a COSE-HPKE-compliant application MUST use an empty “info” parameter. The
Enc_structure, defined in Section 5.3 of , is used as input to the “aad”
parameter.The CDDL fragment is defined as:The “external_aad” is empty, unless an application profile standard specifies
otherwise.If SealBase() is successful, it will output a ciphertext “ct” and an encapsulated
key “enc”. The content of enc is the ephemeral public key.The recipient will use the OpenBase(enc, skR, info, aad, ct) function with the enc and
ct parameters received from the sender.In the absence of an application profile standard specifying
otherwise a COSE-HPKE-compliant application MUST use an empty “info” parameter. The
Enc_structure, defined in Section 5.3 of , is used as input to the “aad”
parameter. The CDDL fragment is shown in the previous section.The OpenBase function will, if successful, decrypt “ct”. When decrypted, the result
is the raw plaintext.This example shows a COSE_Encrypt0 structure.
HPKE was used to encrypt plaintext with AES-128-GCM.
The ephemeral NIST P-256 key key generated by
the HPKE SealBase().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:Layer 0 (corresponding to the COSE_Encrypt structure) contains content (plaintext)
encrypted with the CEK. This ciphertext may be detached. 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 encCEK structure. The protected header MUST contain the algorithm
information and the unprotected header MUST contain the ephemeral public key and the
key id (kid) of the static recipient public key.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 ciphertext firmware image is processed by all of the recipients;
however, each recipient uses their own private key to obtain the CEK.The COSE_recipient structure shown in is repeated for each
recipient.The COSE_Encrypt MAY be tagged or untagged.HPKE algorithms take an info parameter that can be used to influence the generation of
keys (e.g., to fold in identity information) and an aad parameter that provides additional
authenticated data to the AEAD algorithm in use.An example is shown in .The SealBase(pkR, info, aad, pt) function is used to encrypt a plaintext pt to
a recipient’s public key (pkR).For use in COSE_Encrypt, the plaintext “pt” passed into the
SealBase is the CEK. The CEK is a random byte sequence of length
appropriate for the encryption algorithm selected in layer 0. For
example, AES-128-GCM requires a 16 byte key and the CEK would
therefore be 16 bytes long.In the absence of an application profile standard specifying otherwise, a COSE-HPKE-compliant
implementation MUST leave the info and the aad parameters empty when used with the two layer structure.If SealBase() is successful, it will output a ciphertext “ct” and an encapsulated
key “enc”. The content of enc is the ephemeral public key.The recipient will use the OpenBase(enc, skR, info, aad, ct) function with the enc and
ct parameters received from the sender. The “aad” and the “info” parameters are obtained
via the context of the usage.In the absence of an application profile standard specifying otherwise, a COSE-HPKE-compliant
implementation MUST leave the info and the aad parameters empty when used with the two layer structure.The OpenBase function will, if successful, decrypt “ct”. When decrypted, the result
will be the CEK. The CEK is the symmetric key used to decrypt
the ciphertext in layer 0 of the COSE_Encrypt structure.An example of the COSE_Encrypt structure using the HPKE scheme is
shown in . Line breaks and comments have been
inserted for better readability. It uses the following algorithm
combination:AES-GCM-128 for encryption of detached ciphertext in layer 0.Encryption of the CEK in layer 1 utilizing HPKE with NIST P-256
and HKDF-SHA256 as a Key Encapsulation Mechanism (KEM).The algorithm selection is based on the registry of the values offered
by the alg parameters (see ).To offer authentication of the sender the payload in
is signed with a COSE_Sign1 wrapper, which is shown in .
The payload in corresponds to the content shown in
.This specification is based on HPKE and the security considerations of HPKE
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 registry
and to the COSE Elliptic Curves registry, defined in (in the Standards
Action With Expert Review category).Name: COSE_ALG_HPKE_AES_128_GCMValue: TBD1Description: HPKE with AES-128-GCMCapabilities: [kty]Change Controller: IESGReference: [[TBD: This RFC]]Recommended: YesName: COSE_ALG_HPKE_AES_256_GCMValue: TBD2Description: HPKE with AES-256-GCMCapabilities: [kty]Change Controller: IESGReference: [[TBD: This RFC]]Recommended: YesName: COSE_ALG_HPKE_CHACHA20_POLY1305Value: TBD3Description: HPKE with CHACHA20-POLY1305Capabilities: [kty]Change Controller: IESGReference: [[TBD: This RFC]]Recommended: YesName: COSE_CRV_HPKE_P256_SHA256Value: TBD4Key Type:Description: NIST P256 and SHA256 for use with HPKEChange Controller: IESGReference: [[TBD: This RFC]]Recommended: YesName: COSE_CRV_HPKE_P384_SHA384Value: TBD5Key Type:Description: NIST P384 and SHA384 for use with HPKEChange Controller: IESGReference: [[TBD: This RFC]]Recommended: YesName: COSE_CRV_HPKE_P521_SHA512Value: TBD6Key Type:Description: NIST P521 and SHA512 for use with HPKEChange Controller: IESGReference: [[TBD: This RFC]]Recommended: YesName: COSE_CRV_HPKE_X25519_SHA256Value: TBD7Key Type:Description: X25519 and SHA256 for use with HPKEChange Controller: IESGReference: [[TBD: This RFC]]Recommended: YesName: COSE_CRV_HPKE_X448_SHA512Value: TBD8Key Type:Description: X448 and SHA512 for use with HPKEChange Controller: IESGReference: [[TBD: This RFC]]Recommended: YesKey words for use in RFCs to Indicate Requirement LevelsIn many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.Ambiguity of Uppercase vs Lowercase in RFC 2119 Key WordsRFC 2119 specifies common key words that may be used in protocol specifications. This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.Hybrid Public Key EncryptionThis document describes a scheme for hybrid public key encryption (HPKE). This scheme 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 and two optional ones that authenticate possession of a key encapsulation mechanism (KEM) private key. HPKE works for any combination of an asymmetric KEM, key derivation function (KDF), and authenticated encryption with additional data (AEAD) encryption function. Some authenticated variants may not be supported by all KEMs. We provide instantiations of the scheme using widely used and efficient primitives, such as Elliptic Curve Diffie-Hellman (ECDH) key agreement, HMAC-based key derivation function (HKDF), and SHA2.This document is a product of the Crypto Forum Research Group (CFRG) in the IRTF.CBOR Object Signing and Encryption (COSE)Concise Binary Object Representation (CBOR) is a data format designed for small code size and small message size. There is a need for the ability to have basic security services defined for this data format. This document defines the CBOR Object Signing and Encryption (COSE) protocol. This specification describes how to create and process signatures, message authentication codes, and encryption using CBOR for serialization. This specification additionally describes how to represent cryptographic keys using CBOR.Randomness Improvements for Security ProtocolsRandomness is a crucial ingredient for Transport Layer Security (TLS) and related security protocols. Weak or predictable "cryptographically secure" pseudorandom number generators (CSPRNGs) can be abused or exploited for malicious purposes. An initial entropy source that seeds a CSPRNG might be weak or broken as well, which can also lead to critical and systemic security problems. This document describes a way for security protocol implementations to augment their CSPRNGs using long-term private keys. This improves randomness from broken or otherwise subverted CSPRNGs.This document is a product of the Crypto Forum Research Group (CFRG) in the IRTF.Cryptographic Message SyntaxThis document describes the Cryptographic Message Syntax. This syntax is used to digitally sign, digest, authenticate, or encrypt arbitrary messages. [STANDARDS-TRACK]We would like to thank Goeran Selander, John Mattsson and Ilari Liusvaara for their review feedback.