# phpman > man > X25519(7ssl)

[X25519(7SSL)](https://www.chedong.com/phpMan.php/man/X25519/7SSL/markdown)                                   OpenSSL                                  [X25519(7SSL)](https://www.chedong.com/phpMan.php/man/X25519/7SSL/markdown)



## NAME
       X25519, X448 - EVP_PKEY X25519 and X448 support

## DESCRIPTION
       The **X25519** and **X448** EVP_PKEY implementation supports key generation and key derivation using
       **X25519** and **X448**. It has associated private and public key formats compatible with RFC 8410.

       No additional parameters can be set during key generation.

       The peer public key must be set using **EVP**___**PKEY**___**derive**___**set**___**peer()** when performing key
       derivation.

## NOTES
       A context for the **X25519** algorithm can be obtained by calling:

        EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X25519, NULL);

       For the **X448** algorithm a context can be obtained by calling:

        EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X448, NULL);

       X25519 or X448 private keys can be set directly using **EVP**___**PKEY**___**new**___**raw**___**private**___**[key**(3)](https://www.chedong.com/phpMan.php/man/key/3/markdown) or
       loaded from a PKCS#8 private key file using **PEM**___**read**___**bio**___**[PrivateKey**(3)](https://www.chedong.com/phpMan.php/man/PrivateKey/3/markdown) (or similar function).
       Completely new keys can also be generated (see the example below). Setting a private key also
       sets the associated public key.

       X25519 or X448 public keys can be set directly using **EVP**___**PKEY**___**new**___**raw**___**public**___**[key**(3)](https://www.chedong.com/phpMan.php/man/key/3/markdown) or loaded
       from a SubjectPublicKeyInfo structure in a PEM file using **PEM**___**read**___**bio**___**[PUBKEY**(3)](https://www.chedong.com/phpMan.php/man/PUBKEY/3/markdown) (or similar
       function).

## EXAMPLES
       This example generates an **X25519** private key and writes it to standard output in PEM format:

        #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);

       The key derivation example in **EVP**___**PKEY**___**[derive**(3)](https://www.chedong.com/phpMan.php/man/derive/3/markdown) can be used with **X25519** and **X448**.

## SEE ALSO
       **EVP**___**PKEY**___**CTX**___**[new**(3)](https://www.chedong.com/phpMan.php/man/new/3/markdown), **EVP**___**PKEY**___**[keygen**(3)](https://www.chedong.com/phpMan.php/man/keygen/3/markdown), **EVP**___**PKEY**___**[derive**(3)](https://www.chedong.com/phpMan.php/man/derive/3/markdown), **EVP**___**PKEY**___**derive**___**set**___**[peer**(3)](https://www.chedong.com/phpMan.php/man/peer/3/markdown)

## 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>>.



3.0.2                                        2026-06-02                                 [X25519(7SSL)](https://www.chedong.com/phpMan.php/man/X25519/7SSL/markdown)
