X25519.html 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?xml version="1.0" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>X25519</title>
  6. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  7. <link rev="made" href="mailto:root@localhost" />
  8. </head>
  9. <body>
  10. <ul id="index">
  11. <li><a href="#NAME">NAME</a></li>
  12. <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
  13. <li><a href="#NOTES">NOTES</a></li>
  14. <li><a href="#EXAMPLES">EXAMPLES</a></li>
  15. <li><a href="#SEE-ALSO">SEE ALSO</a></li>
  16. <li><a href="#COPYRIGHT">COPYRIGHT</a></li>
  17. </ul>
  18. <h1 id="NAME">NAME</h1>
  19. <p>X25519, X448 - EVP_PKEY X25519 and X448 support</p>
  20. <h1 id="DESCRIPTION">DESCRIPTION</h1>
  21. <p>The <b>X25519</b> and <b>X448</b> EVP_PKEY implementation supports key generation and key derivation using <b>X25519</b> and <b>X448</b>. It has associated private and public key formats compatible with RFC 8410.</p>
  22. <p>No additional parameters can be set during key generation.</p>
  23. <p>The peer public key must be set using EVP_PKEY_derive_set_peer() when performing key derivation.</p>
  24. <h1 id="NOTES">NOTES</h1>
  25. <p>A context for the <b>X25519</b> algorithm can be obtained by calling:</p>
  26. <pre><code> EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X25519, NULL);</code></pre>
  27. <p>For the <b>X448</b> algorithm a context can be obtained by calling:</p>
  28. <pre><code> EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X448, NULL);</code></pre>
  29. <p>X25519 or X448 private keys can be set directly using <a href="../man3/EVP_PKEY_new_raw_private_key.html">EVP_PKEY_new_raw_private_key(3)</a> or loaded from a PKCS#8 private key file using <a href="../man3/PEM_read_bio_PrivateKey.html">PEM_read_bio_PrivateKey(3)</a> (or similar function). Completely new keys can also be generated (see the example below). Setting a private key also sets the associated public key.</p>
  30. <p>X25519 or X448 public keys can be set directly using <a href="../man3/EVP_PKEY_new_raw_public_key.html">EVP_PKEY_new_raw_public_key(3)</a> or loaded from a SubjectPublicKeyInfo structure in a PEM file using <a href="../man3/PEM_read_bio_PUBKEY.html">PEM_read_bio_PUBKEY(3)</a> (or similar function).</p>
  31. <h1 id="EXAMPLES">EXAMPLES</h1>
  32. <p>This example generates an <b>X25519</b> private key and writes it to standard output in PEM format:</p>
  33. <pre><code> #include &lt;openssl/evp.h&gt;
  34. #include &lt;openssl/pem.h&gt;
  35. ...
  36. EVP_PKEY *pkey = NULL;
  37. EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X25519, NULL);
  38. EVP_PKEY_keygen_init(pctx);
  39. EVP_PKEY_keygen(pctx, &amp;pkey);
  40. EVP_PKEY_CTX_free(pctx);
  41. PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL, NULL);</code></pre>
  42. <p>The key derivation example in <a href="../man3/EVP_PKEY_derive.html">EVP_PKEY_derive(3)</a> can be used with <b>X25519</b> and <b>X448</b>.</p>
  43. <h1 id="SEE-ALSO">SEE ALSO</h1>
  44. <p><a href="../man3/EVP_PKEY_CTX_new.html">EVP_PKEY_CTX_new(3)</a>, <a href="../man3/EVP_PKEY_keygen.html">EVP_PKEY_keygen(3)</a>, <a href="../man3/EVP_PKEY_derive.html">EVP_PKEY_derive(3)</a>, <a href="../man3/EVP_PKEY_derive_set_peer.html">EVP_PKEY_derive_set_peer(3)</a></p>
  45. <h1 id="COPYRIGHT">COPYRIGHT</h1>
  46. <p>Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.</p>
  47. <p>Licensed under the OpenSSL license (the &quot;License&quot;). 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 <a href="https://www.openssl.org/source/license.html">https://www.openssl.org/source/license.html</a>.</p>
  48. </body>
  49. </html>