EVP_KEM-EC(7SSL)

πŸ’– EVP_KEM-EC β€” the OpenSSL manual, but make it cute πŸ’–

okay bestie so this is EVP_KEM-EC(7SSL) from the OpenSSL manual set, and it's lowkey one of the most satisfying little pages ever because it's just: elliptic curve keytype, but make it encapsulate. ✨


🌸 NAME 🌸

EVP_KEM-EC β€” the EVP_KEM EC keytype, plus all the algorithm support that comes with it. no cap, that's the whole vibe. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

So the EC keytype and all its lil parameters are described over in EVP_PKEY-EC(7) β€” that's your homework, go read it, I'll wait. πŸ’…

And for the actual encapsulate/decapsulate tea, you want EVP_PKEY_encapsulate(3) and EVP_PKEY_decapsulate(3). they have the deets.

πŸ”‘ EC KEM parameters πŸ”‘

"operation" (OSSL_KEM_PARAM_OPERATION) β€” <UTF8 string>

This one sets the operating mode, and the OpenSSL EC Key Encapsulation Mechanisms only support one default operation. one. singular. iconic behavior honestly.

  • "DHKEM" (OSSL_KEM_PARAM_OPERATION_DHKEM) β€” the default operating mode, and here's what it actually does, bestie, sit down:

The encapsulate function generates an ephemeral keypair. it then produces keymaterial by doing an ECDH key exchange using the ephemeral private key and a supplied recipient public key. then a HKDF operation using that keymaterial and a kem context produces a shared secret. the shared secret and the ephemeral public key get returned. πŸ’«

The decapsulate function then takes the recipient private key and the ephemeral public key to produce the same keymaterial, which can then be used to produce the same shared secret. it's giving symmetry. it's giving matching friendship bracelets. πŸŽ€

See <https://www.rfc-editor.org/rfc/rfc9180.html#name-dh-based-kem-dhkem> for the full lore.

You can set this using either EVP_PKEY_CTX_set_kem_op() or EVP_PKEY_CTX_set_params(). two doors, same room. pick your fave. πŸšͺ

"ikme" (OSSL_KEM_PARAM_IKME) β€” <octet string>

This is the key material used for generation of the ephemeral key. ✨

⚠️ bestie this one matters: this value should not be reused for other purposes. i'm so serious. don't be out here recycling your ikme.

It can only be used for the curves "P-256", "P-384" and "P-521", and it should have a length of at least the size of the encoded private key β€” that's 32, 48 and 66 for the listed curves, in that order, queen. πŸ‘‘

If this value is not set, then a random ikm is used. so like, no stress, it's got a fallback. πŸ’œ


🌈 CONFORMING TO 🌈

RFC9180

look at her, standards-compliant AND gorgeous. 😌


πŸ‘€ SEE ALSO πŸ‘€

the whole friend group, fr fr. 🫢


πŸ“œ HISTORY πŸ“œ

This functionality was added in OpenSSL 3.2. πŸ’–

The "operation" (operating mode) was a required parameter prior to OpenSSL 3.5. so like, before 3.5 you had to say it out loud. As of OpenSSL 3.5, "DHKEM" is the default operating mode, and no explicit value need be specified. glow-up behavior. ✨


Copyright 2022-2025 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page, bestie!! πŸ’…βœ¨ this was version 4.0.3, dated 2026-09-29, and it lives at EVP_KEM-EC(7SSL) in the OpenSSL manual. go forth and encapsulate responsibly. slay. πŸ‘‘πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from