Hybrid Public Key EncryptionCiscorlb@ipv.sxInriakarthikeyan.bhargavan@inria.frInternet-DraftThis document describes a scheme for hybrid public-key encryption (HPKE). This scheme provides authenticated public key
encryption of arbitrary-sized plaintexts for a recipient public key. HPKE works
for any Diffie-Hellman group and has a strong security proof. We provide instantiations
of the scheme using standard and efficient primitives.Hybrid public-key encryption (HPKE) is a substantially more
efficient solution than traditional public key encryption techniques
such as those based on RSA or ElGamal. Encrypted messages convey a
single ciphertext and authentication tag alongside a short public
key, which may be further compressed. The key size and computational
complexity of elliptic curve cryptographic primitives for
authenticated encryption therefore make it compelling for a variety
of use case. This type of public key encryption has many
applications in practice, for example, in PGP and in
the developing Messaging Layer Security protocol
.Currently, there are numerous competing and non-interoperable
standards and variants for hybrid encryption, including ANSI X9.63
, IEEE 1363a , ISO/IEC 18033-2 , and SECG SEC
1 . Lack of a single standard makes selection and deployment
of a compatible, cross-platform and ecosystem solution difficult to
define. This document defines an HPKE scheme that provides a subset
of the functions provided by the collection of schemes above, but
specified with sufficient clarity that they can be interoperably
implemented and formally verified.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
BCP14 when, and only when, they appear in
all capitals, as shown here.As a hybrid authentication encryption algorithm, we desire security
against (adaptive) chosen ciphertext attacks (IND-CCA2 secure). The
HPKE variants described in this document achieve this property under
the Random Oracle model assuming the gap Computational Diffie
Hellman (CDH) problem is hard .The following terms are used throughout this document to describe the
operations, roles, and behaviors of HPKE:Initiator (I): Sender of an encrypted message.Responder (R): Receiver of an encrypted message.Ephemeral (E): A fresh random value meant for one-time use.(skX, pkX): A KEM key pair used in role X; skX is the private
key and pkX is the public keypk(sk): The public key corresponding to a private keylen(x): The one-octet length of the octet string x+: Concatenation of octet strings; 0x01 + 0x02 = 0x0102*: Repetition of an octet string; 0x01 * 4 = 0x01010101^: XOR of octet strings; 0xF0F0 ^ 0x1234 = 0xE2C4HPKE variants rely on the following primitives:A Key Encapsulation Mechanism (KEM):
GenerateKeyPair(): Generate a key pair (sk, pk)Marshal(pk): Produce a fixed-length octet string encoding the
public key pkUnmarshal(enc): Parse a fixed-length octet string to recover a
public keyEncap(pk): Generate an ephemeral symmetric key and a
fixed-length encapsulation of that key that can be decapsulated
by the holder of the private key corresponding to pkDecap(enc, sk): Use the private key sk to recover the ephemeral
symmetric key from its encapsulated representation encAuthEncap(pkR, skI) (optional): Same as Encap(), but the outputs
encode an assurance that the ephemeral shared key is known only
to the holder of the private key skIAuthDecap(skI, pkR) (optional): Same as Decap(), but the holder
of the private key skI is assured that the ephemeral shared
key is known only to the holder of the private key corresponding
to pkIA Key Derivation Function:
Extract(salt, IKM): Extract a pseudorandom key of fixed length
from input keying material IKM and an optional octet string
saltExpand(PRK, info, L): Expand a pseudorandom key PRK using
optional string info into L bytes of output keying materialNh: The output size of the Extract functionAn AEAD encryption algorithm :
Seal(key, nonce, aad, pt): Encrypt and authenticate plaintext
pt with associated data aad using secret key key and nonce
nonce, yielding ciphertext and tag ctOpen(key, nonce, aad, ct): Decrypt ciphertext ct using
associated data aad with secret key key and nonce nonce,
returning plaintext message pt or the error value OpenErrorNk: The length in octets of a key for this algorithmNn: The length in octets of a nonce for this algorithmA set of concrete instantiations of these primitives is provided in
. Ciphersuite values are two octets long.Suppose we are given a Diffie-Hellman group that provides the
following operations:GenerateKeyPair(): Generate an ephemeral key pair (sk, pk)
for the DH group in useDH(sk, pk): Perform a non-interactive DH exchange using the
private key sk and public key pk to produce a shared secretMarshal(pk): Produce a fixed-length octet string encoding the
public key pkThen we can construct a KEM (which we’ll call “DHKEM”) in the
following way:The Marshal and GenerateKeyPair functions are the same as for the
underlying DH group.In this section, we define a few HPKE variants. All cases take a
plaintext pt and a recipient public key pkR and produce an
ciphertext ct and an encapsulated key enc. These outputs are
constructed so that only the holder of the private key corresponding
to pkR can decapsulate the key from enc and decrypt the
ciphertext. All of the algorithms also 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.In addition to the base case of encrypting to a public key, we
include two authenticated variants, one of which authenticates
possession of a pre-shared key, and one of which authenticates
possession of a KEM private key. The following one-octet values
will be used to distinguish between modes:ModeValuemode_base0x00mode_psk0x01mode_auth0x02All of these cases follow the same basic two-step pattern:Set up an encryption context that is shared between the sender
and the recipientUse that context to encrypt or decrypt contentA “context” encodes the AEAD algorithm and key in use, and manages
the nonces used so that the same nonce is not used with multiple
plaintexts.The procedures described in this session are laid out in a
Python-like pseudocode. The ciphersuite in use is left implicit.The most basic function of an HPKE scheme is to enable encryption
for the holder of a given KEM private key. The SetupBaseI() and
SetupBaseR() procedures establish contexts that can be used to
encrypt and decrypt, respectively, for a given private key.The the shared secret produced by the KEM is combined via the KDF
with information describing the key exchange, as well as the
explicit info parameter provided by the caller.Note that the SetupCore() method is also used by the other HPKE
variants describe below. The value 0*Nh in the SetupBase()
procedure represents an all-zero octet string of length Nh.Note that the context construction in the SetupCore procedure is
equivalent to serializing a structure of the following form in the
TLS presentation syntax:This variant extends the base mechansism by allowing the recipient
to authenticate that the sender possessed a given pre-shared key
(PSK). We assume that both parties have been provisioned with both
the PSK value psk and another octet string pskID that is used to
identify which PSK should be used.The primary differences from the base case are:The PSK is used as the salt input to the KDF (instead of 0)The PSK ID is added to the context string used as the info input
to the KDFThis mechanism is not suitable for use with a low-entropy password
as the PSK. A malicious recipient that does not possess the PSK can
use decryption of a plaintext as an oracle for performing offline
dictionary attacks.This variant extends the base mechansism by allowing the recipient
to authenticate that the sender possessed a given KEM private key.
This assurance is based on the assumption that
AuthDecap(enc, skR, pkI) produces the correct shared secret
only if the encapsulated value enc was produced by
AuthEncap(pkR, skI), where skI is the private key corresponding
to pkI. In other words, only two people could have produced this
secret, so if the recipient is one, then the sender must be the
other.The primary differences from the base case are:The calls to Encap and Decap are replaced with calls to
AuthEncap and AuthDecap.The initiator public key is added to the context string used as
the info input to the KDFObviously, this variant can only be used with a KEM that provides
AuthEncap() and AuthDecap() procuedures.This mechanism authenticates only the key pair of the initiator, not
any other identity. If an application wishes to authenticate some
other identity for the sender (e.g., an email address or domain
name), then this identity should be included in the info parameter
to avoid unknown key share attacks.HPKE allows multiple encryption operations to be done based on a
given setup transaction. Since the public-key operations involved
in setup are typically more expensive than symmetric encryption or
decryption, this allows applications to “amortize” the cost of the
public-key operations, reducing the overall overhead.In order to avoid nonce reuse, however, this decryption must be
stateful. Each of the setup procedures above produces a context
object that stores the required state:The AEAD algorithm in useThe key to be used with the AEAD algorithmA base nonce valueA sequence number (initially 0)All of these fields except the sequence number are constant. The
sequence number is used to provide nonce uniqueness: The nonce used
for each encryption or decryption operation is the result of XORing
the base nonce with the current sequence number, encoded as a
big-endian integer of the same length as the nonce. Implementations
MAY use a sequence number that is shorter than the nonce (padding on
the left with zero), but MUST return an error if the sequence number
overflows.Each encryption or decryption operation increments the sequence
number for the context in use. A given context SHOULD be used either
only for encryption or only for decryption.It is up to the application to ensure that encryptions and
decryptions are done in the proper sequence, so that the nonce
values used for encryption and decryption line up.The HPKE variants as presented will function correctly for any
combination of primitives that provides the functions described
above. In this section, we provide specific instantiations of these
primitives for standard groups, including: Curve25519, Curve448
, and the NIST curves P-256 and P-512.ValueKEMKDFAEAD0x0001DHKEM(P-256)HKDF-SHA256AES-GCM-1280x0002DHKEM(P-256)HKDF-SHA256ChaCha20Poly13050x0002DHKEM(Curve25519)HKDF-SHA256AES-GCM-1280x0002DHKEM(Curve25519)HKDF-SHA256ChaCha20Poly13050x0001DHKEM(P-521)HKDF-SHA512AES-GCM-2560x0002DHKEM(P-521)HKDF-SHA512ChaCha20Poly13050x0002DHKEM(Curve448)HKDF-SHA512AES-GCM-2560x0002DHKEM(Curve448)HKDF-SHA512ChaCha20Poly1305For the NIST curves P-256 and P-521, the Marshal function of the DH
scheme produces the normal (non-compressed) representation of the
public key, according to . When these curves are used, the
recipient of an HPKE ciphertext MUST validate that the ephemeral public
key pkE is on the curve. The relevant validation procedures are
defined in For the CFRG curves Curve25519 and Curve448, the Marshal function is
the identity function, since these curves already use fixed-length
octet strings for public keys.The values Nk and Nn for the AEAD algorithms referenced above
are as follows:AEADNkNnAES-GCM-1281612AES-GCM-2563212ChaCha20Poly13053212[[ TODO ]][[ OPEN ISSUE: Should the above table be in an IANA registry? ]]A Proposal for an ISO Standard for Public Key Encryption (verison 2.1)Public Key Cryptography for the Financial Services Industry -- Key Agreement and Key Transport Using Elliptic Curve CryptographyIEEE 1363a, Standard Specifications for Public Key Cryptography - Amendment 1 -- Additional TechniquesISO/IEC 18033-2, Information Technology - Security Techniques - Encryption Algorithms - Part 2 -- Asymmetric CiphersElliptic Curve Cryptography, Standards for Efficient Cryptography Group, ver. 2A Comparison of the Standardized Versions of ECIESRecommendation for Pair-Wise Key Establishment Schemes Using Discrete Logarithm CryptographyKey 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.An Interface and Algorithms for Authenticated EncryptionThis document defines algorithms for Authenticated Encryption with Associated Data (AEAD), and defines a uniform interface and a registry for such algorithms. The interface and registry can be used as an application-independent set of cryptoalgorithm suites. This approach provides advantages in efficiency and security, and promotes the reuse of crypto implementations. [STANDARDS-TRACK]Elliptic Curves for SecurityThis memo specifies two elliptic curves over prime fields that offer a high level of practical security in cryptographic applications, including Transport Layer Security (TLS). These curves are intended to operate at the ~128-bit and ~224-bit security level, respectively, and are generated deterministically based on a list of required properties.Elliptic Curve Cryptography (ECC) in OpenPGPThis document defines an Elliptic Curve Cryptography extension to the OpenPGP public key format and specifies three Elliptic Curves that enjoy broad support by other standards, including standards published by the US National Institute of Standards and Technology. The document specifies the conventions for interoperability between compliant OpenPGP implementations that make use of this extension and these Elliptic Curves. [STANDARDS-TRACK]The Messaging Layer Security (MLS) ProtocolMessaging applications are increasingly making use of end-to-end security mechanisms to ensure that messages are only accessible to the communicating endpoints, and not to any servers involved in delivering messages. Establishing keys to provide such protections is challenging for group chat settings, in which more than two participants need to agree on a key but may not be online at the same time. In this document, we specify a key establishment protocol that provides efficient asynchronous group key establishment with forward secrecy and post-compromise security for groups in size ranging from two to thousands.The following extensions might be worth specifying:Multiple recipients - It might be possible to add some
simplifications / assurances for the case where the same value is
being encrypted to multiple recipients.Test vectors - Obviously, we can provide decryption test vectors
in this document. In order to provide known-answer tests, we
would have to introduce a non-secure deterministic mode where the
ephemeral key pair is derived from the inputs. And to do that
safely, we would need to augment the decrypt function to detect
the deterministic mode and fail.A reference implementation in hacspec or similar