EVP_PKEY_CTX_new.pod 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. =pod
  2. =head1 NAME
  3. EVP_PKEY_CTX_new, EVP_PKEY_CTX_new_id, EVP_PKEY_CTX_new_from_name,
  4. EVP_PKEY_CTX_new_from_pkey, EVP_PKEY_CTX_dup, EVP_PKEY_CTX_free,
  5. EVP_PKEY_CTX_is_a
  6. - public key algorithm context functions
  7. =head1 SYNOPSIS
  8. #include <openssl/evp.h>
  9. EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
  10. EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);
  11. EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_name(OSSL_LIB_CTX *libctx,
  12. const char *name,
  13. const char *propquery);
  14. EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_pkey(OSSL_LIB_CTX *libctx,
  15. EVP_PKEY *pkey,
  16. const char *propquery);
  17. EVP_PKEY_CTX *EVP_PKEY_CTX_dup(const EVP_PKEY_CTX *ctx);
  18. void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
  19. int EVP_PKEY_CTX_is_a(EVP_PKEY_CTX *ctx, const char *keytype);
  20. =head1 DESCRIPTION
  21. The EVP_PKEY_CTX_new() function allocates public key algorithm context using
  22. the I<pkey> key type and ENGINE I<e>.
  23. The EVP_PKEY_CTX_new_id() function allocates public key algorithm context
  24. using the key type specified by I<id> and ENGINE I<e>.
  25. The EVP_PKEY_CTX_new_from_name() function allocates a public key algorithm
  26. context using the library context I<libctx> (see L<OSSL_LIB_CTX(3)>), the
  27. key type specified by I<name> and the property query I<propquery>. None
  28. of the arguments are duplicated, so they must remain unchanged for the
  29. lifetime of the returned B<EVP_PKEY_CTX> or of any of its duplicates. Read
  30. further about the possible names in L</NOTES> below.
  31. The EVP_PKEY_CTX_new_from_pkey() function allocates a public key algorithm
  32. context using the library context I<libctx> (see L<OSSL_LIB_CTX(3)>) and the
  33. algorithm specified by I<pkey> and the property query I<propquery>. None of the
  34. arguments are duplicated, so they must remain unchanged for the lifetime of the
  35. returned B<EVP_PKEY_CTX> or any of its duplicates.
  36. EVP_PKEY_CTX_new_id() and EVP_PKEY_CTX_new_from_name() are normally
  37. used when no B<EVP_PKEY> structure is associated with the operations,
  38. for example during parameter generation or key generation for some
  39. algorithms.
  40. EVP_PKEY_CTX_dup() duplicates the context I<ctx>. It is not supported for a
  41. keygen operation.
  42. EVP_PKEY_CTX_free() frees up the context I<ctx>.
  43. If I<ctx> is NULL, nothing is done.
  44. EVP_PKEY_is_a() checks if the key type associated with I<ctx> is I<keytype>.
  45. =head1 NOTES
  46. =head2 On B<EVP_PKEY_CTX>
  47. The B<EVP_PKEY_CTX> structure is an opaque public key algorithm context used
  48. by the OpenSSL high-level public key API. Contexts B<MUST NOT> be shared between
  49. threads: that is it is not permissible to use the same context simultaneously
  50. in two threads.
  51. =head2 On Key Types
  52. We mention "key type" in this manual, which is the same
  53. as "algorithm" in most cases, allowing either term to be used
  54. interchangeably. There are algorithms where the I<key type> and the
  55. I<algorithm> of the operations that use the keys are not the same,
  56. such as EC keys being used for ECDSA and ECDH operations.
  57. Key types are given in two different manners:
  58. =over 4
  59. =item Legacy NID or EVP_PKEY type
  60. This is the I<id> used with EVP_PKEY_CTX_new_id().
  61. These are B<EVP_PKEY_RSA>, B<EVP_PKEY_RSA_PSS>, B<EVP_PKEY_DSA>,
  62. B<EVP_PKEY_DH>, B<EVP_PKEY_EC>, B<EVP_PKEY_SM2>, B<EVP_PKEY_X25519>,
  63. B<EVP_PKEY_X448>, and are used by legacy methods.
  64. =item Name strings
  65. This is the I<name> used with EVP_PKEY_CTX_new_from_name().
  66. These are names like "RSA", "DSA", and what's available depends on what
  67. providers are currently accessible.
  68. The OpenSSL providers offer a set of key types available this way, please
  69. see L<OSSL_PROVIDER-FIPS(7)> and L<OSSL_PROVIDER-default(7)> and related
  70. documentation for more information.
  71. =back
  72. =head1 RETURN VALUES
  73. EVP_PKEY_CTX_new(), EVP_PKEY_CTX_new_id() and EVP_PKEY_CTX_dup() return either
  74. the newly allocated B<EVP_PKEY_CTX> structure or B<NULL> if an error occurred.
  75. EVP_PKEY_CTX_free() does not return a value.
  76. EVP_PKEY_CTX_is_a() returns 1 for true and 0 for false.
  77. =head1 SEE ALSO
  78. L<EVP_PKEY_new(3)>
  79. =head1 HISTORY
  80. The EVP_PKEY_CTX_new(), EVP_PKEY_CTX_new_id(), EVP_PKEY_CTX_dup() and
  81. EVP_PKEY_CTX_free() functions were added in OpenSSL 1.0.0.
  82. The EVP_PKEY_CTX_new_from_name() and EVP_PKEY_CTX_new_from_pkey() functions were
  83. added in OpenSSL 3.0.
  84. =head1 COPYRIGHT
  85. Copyright 2006-2021 The OpenSSL Project Authors. All Rights Reserved.
  86. Licensed under the Apache License 2.0 (the "License"). You may not use
  87. this file except in compliance with the License. You can obtain a copy
  88. in the file LICENSE in the source distribution or at
  89. L<https://www.openssl.org/source/license.html>.
  90. =cut