X25519(7ossl)
π X25519 β the glow-up era (OpenSSL, section 7ossl)
okay bestie, gather round, because this one is actually iconic. We're talking X25519 and X448 β the two cool kids of the EVP_PKEY world β living their best life inside OpenSSL. π¦
β¨ NAME β¨
X25519, X448 β the EVP_PKEY X25519 and X448 support. That's the whole vibe. No cap.
πΈ DESCRIPTION πΈ
So the X25519 and X448 EVP_PKEY implementation is out here doing key generation and key derivation using X25519 and X448, and honestly? Slay. π
It comes with associated private and public key formats that are compatible with RFC 8410 β yes, the actual RFC, we're being so valid and standards-compliant today.
π«Ά tiny little caveat, bestie: no additional parameters can be set during key generation. Like, at all. Zero. The parameter menu is empty. Periodt.
And when you're doing key derivation, the peer public key must be set using EVP_PKEY_derive_set_peer(). You can't just show up without it β that's not how this works. π
π NOTES π
Wanna get yourself a context for the X25519 algorithm? Say less. Just call:
EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X25519, NULL);
And for the X448 algorithm, the exact same energy, just swap the name:
EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X448, NULL);
Now β setting your keys. This is the part where it gets good. π
- Private keys:
X25519orX448private keys can be set directly usingEVP_PKEY_new_raw_private_key(3), or loaded from aPKCS#8private key file usingPEM_read_bio_PrivateKey(3)(or a similar function β iykyk). - Brand-new keys can also be generated from scratch (peep the example below π). And here's the little magic trick: setting a private key also sets the associated public key. Not me getting a two-for-one. π₯
- Public keys:
X25519orX448public keys can be set directly usingEVP_PKEY_new_raw_public_key(3), or loaded from aSubjectPublicKeyInfostructure in a PEM file usingPEM_read_bio_PUBKEY(3)(or similar function).
π EXAMPLES π
okay so this example generates an X25519 private key and writes it to standard output in PEM format. It's giving main character energy and it works:
#include <openssl/evp.h>
#include <openssl/pem.h>
...
EVP_PKEY *pkey = NULL;
EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X25519, NULL);
EVP_PKEY_keygen_init(pctx);
EVP_PKEY_keygen(pctx, &pkey);
EVP_PKEY_CTX_free(pctx);
PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL, NULL);
And for key derivation? The key derivation example over in EVP_PKEY_derive(3) can be used with X25519 and X448. Go off, honestly. π
β SEE ALSO β
π COPYRIGHT π
Copyright 2017-2020 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>.
π fr fr, read the license before you ship it. That's the vibe check nobody wants to fail.
k bye bestie, go forth and derive those keys πβ¨ππ¦πΈπ π«Ά
β this page is X25519(7ossl) from the OpenSSL fam, version 3.5.0, dated 2026-09-25. mwah π
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms