X25519.pod 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. =pod
  2. =head1 NAME
  3. X25519,
  4. X448
  5. - EVP_PKEY X25519 and X448 support
  6. =head1 DESCRIPTION
  7. The B<X25519> and B<X448> EVP_PKEY implementation supports key generation and
  8. key derivation using B<X25519> and B<X448>. It has associated private and public
  9. key formats compatible with RFC 8410.
  10. No additional parameters can be set during key generation.
  11. The peer public key must be set using EVP_PKEY_derive_set_peer() when
  12. performing key derivation.
  13. =head1 NOTES
  14. A context for the B<X25519> algorithm can be obtained by calling:
  15. EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X25519, NULL);
  16. For the B<X448> algorithm a context can be obtained by calling:
  17. EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X448, NULL);
  18. X25519 or X448 private keys can be set directly using
  19. L<EVP_PKEY_new_raw_private_key(3)> or loaded from a PKCS#8 private key file
  20. using L<PEM_read_bio_PrivateKey(3)> (or similar function). Completely new keys
  21. can also be generated (see the example below). Setting a private key also sets
  22. the associated public key.
  23. X25519 or X448 public keys can be set directly using
  24. L<EVP_PKEY_new_raw_public_key(3)> or loaded from a SubjectPublicKeyInfo
  25. structure in a PEM file using L<PEM_read_bio_PUBKEY(3)> (or similar function).
  26. =head1 EXAMPLES
  27. This example generates an B<X25519> private key and writes it to standard
  28. output in PEM format:
  29. #include <openssl/evp.h>
  30. #include <openssl/pem.h>
  31. ...
  32. EVP_PKEY *pkey = NULL;
  33. EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_X25519, NULL);
  34. EVP_PKEY_keygen_init(pctx);
  35. EVP_PKEY_keygen(pctx, &pkey);
  36. EVP_PKEY_CTX_free(pctx);
  37. PEM_write_PrivateKey(stdout, pkey, NULL, NULL, 0, NULL, NULL);
  38. The key derivation example in L<EVP_PKEY_derive(3)> can be used with
  39. B<X25519> and B<X448>.
  40. =head1 SEE ALSO
  41. L<EVP_PKEY_CTX_new(3)>,
  42. L<EVP_PKEY_keygen(3)>,
  43. L<EVP_PKEY_derive(3)>,
  44. L<EVP_PKEY_derive_set_peer(3)>
  45. =head1 COPYRIGHT
  46. Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
  47. Licensed under the Apache License 2.0 (the "License"). You may not use
  48. this file except in compliance with the License. You can obtain a copy
  49. in the file LICENSE in the source distribution or at
  50. L<https://www.openssl.org/source/license.html>.
  51. =cut