EVP_PKEY_CTX_new.3ossl 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "EVP_PKEY_CTX_NEW 3ossl"
  58. .TH EVP_PKEY_CTX_NEW 3ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. EVP_PKEY_CTX_new, EVP_PKEY_CTX_new_id, EVP_PKEY_CTX_new_from_name,
  65. EVP_PKEY_CTX_new_from_pkey, EVP_PKEY_CTX_dup, EVP_PKEY_CTX_free,
  66. EVP_PKEY_CTX_is_a
  67. \&\- public key algorithm context functions
  68. .SH SYNOPSIS
  69. .IX Header "SYNOPSIS"
  70. .Vb 1
  71. \& #include <openssl/evp.h>
  72. \&
  73. \& EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
  74. \& EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);
  75. \& EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_name(OSSL_LIB_CTX *libctx,
  76. \& const char *name,
  77. \& const char *propquery);
  78. \& EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_pkey(OSSL_LIB_CTX *libctx,
  79. \& EVP_PKEY *pkey,
  80. \& const char *propquery);
  81. \& EVP_PKEY_CTX *EVP_PKEY_CTX_dup(const EVP_PKEY_CTX *ctx);
  82. \& void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
  83. \& int EVP_PKEY_CTX_is_a(EVP_PKEY_CTX *ctx, const char *keytype);
  84. .Ve
  85. .SH DESCRIPTION
  86. .IX Header "DESCRIPTION"
  87. The \fBEVP_PKEY_CTX_new()\fR function allocates public key algorithm context using
  88. the \fIpkey\fR key type and ENGINE \fIe\fR.
  89. .PP
  90. The \fBEVP_PKEY_CTX_new_id()\fR function allocates public key algorithm context
  91. using the key type specified by \fIid\fR and ENGINE \fIe\fR.
  92. .PP
  93. The \fBEVP_PKEY_CTX_new_from_name()\fR function allocates a public key algorithm
  94. context using the library context \fIlibctx\fR (see \fBOSSL_LIB_CTX\fR\|(3)), the
  95. key type specified by \fIname\fR and the property query \fIpropquery\fR. None
  96. of the arguments are duplicated, so they must remain unchanged for the
  97. lifetime of the returned \fBEVP_PKEY_CTX\fR or of any of its duplicates. Read
  98. further about the possible names in "NOTES" below.
  99. .PP
  100. The \fBEVP_PKEY_CTX_new_from_pkey()\fR function allocates a public key algorithm
  101. context using the library context \fIlibctx\fR (see \fBOSSL_LIB_CTX\fR\|(3)) and the
  102. algorithm specified by \fIpkey\fR and the property query \fIpropquery\fR. None of the
  103. arguments are duplicated, so they must remain unchanged for the lifetime of the
  104. returned \fBEVP_PKEY_CTX\fR or any of its duplicates.
  105. .PP
  106. \&\fBEVP_PKEY_CTX_new_id()\fR and \fBEVP_PKEY_CTX_new_from_name()\fR are normally
  107. used when no \fBEVP_PKEY\fR structure is associated with the operations,
  108. for example during parameter generation or key generation for some
  109. algorithms.
  110. .PP
  111. \&\fBEVP_PKEY_CTX_dup()\fR duplicates the context \fIctx\fR. It is not supported for a
  112. keygen operation.
  113. .PP
  114. \&\fBEVP_PKEY_CTX_free()\fR frees up the context \fIctx\fR.
  115. If \fIctx\fR is NULL, nothing is done.
  116. .PP
  117. \&\fBEVP_PKEY_is_a()\fR checks if the key type associated with \fIctx\fR is \fIkeytype\fR.
  118. .SH NOTES
  119. .IX Header "NOTES"
  120. .SS "On \fBEVP_PKEY_CTX\fP"
  121. .IX Subsection "On EVP_PKEY_CTX"
  122. The \fBEVP_PKEY_CTX\fR structure is an opaque public key algorithm context used
  123. by the OpenSSL high-level public key API. Contexts \fBMUST NOT\fR be shared between
  124. threads: that is it is not permissible to use the same context simultaneously
  125. in two threads.
  126. .SS "On Key Types"
  127. .IX Subsection "On Key Types"
  128. We mention "key type" in this manual, which is the same
  129. as "algorithm" in most cases, allowing either term to be used
  130. interchangeably. There are algorithms where the \fIkey type\fR and the
  131. \&\fIalgorithm\fR of the operations that use the keys are not the same,
  132. such as EC keys being used for ECDSA and ECDH operations.
  133. .PP
  134. Key types are given in two different manners:
  135. .IP "Legacy NID or EVP_PKEY type" 4
  136. .IX Item "Legacy NID or EVP_PKEY type"
  137. This is the \fIid\fR used with \fBEVP_PKEY_CTX_new_id()\fR.
  138. .Sp
  139. These are \fBEVP_PKEY_RSA\fR, \fBEVP_PKEY_RSA_PSS\fR, \fBEVP_PKEY_DSA\fR,
  140. \&\fBEVP_PKEY_DH\fR, \fBEVP_PKEY_EC\fR, \fBEVP_PKEY_SM2\fR, \fBEVP_PKEY_X25519\fR,
  141. \&\fBEVP_PKEY_X448\fR, and are used by legacy methods.
  142. .IP "Name strings" 4
  143. .IX Item "Name strings"
  144. This is the \fIname\fR used with \fBEVP_PKEY_CTX_new_from_name()\fR.
  145. .Sp
  146. These are names like "RSA", "DSA", and what's available depends on what
  147. providers are currently accessible.
  148. .Sp
  149. The OpenSSL providers offer a set of key types available this way, please
  150. see \fBOSSL_PROVIDER\-FIPS\fR\|(7) and \fBOSSL_PROVIDER\-default\fR\|(7) and related
  151. documentation for more information.
  152. .SH "RETURN VALUES"
  153. .IX Header "RETURN VALUES"
  154. \&\fBEVP_PKEY_CTX_new()\fR, \fBEVP_PKEY_CTX_new_id()\fR and \fBEVP_PKEY_CTX_dup()\fR return either
  155. the newly allocated \fBEVP_PKEY_CTX\fR structure or \fBNULL\fR if an error occurred.
  156. .PP
  157. \&\fBEVP_PKEY_CTX_free()\fR does not return a value.
  158. .PP
  159. \&\fBEVP_PKEY_CTX_is_a()\fR returns 1 for true and 0 for false.
  160. .SH "SEE ALSO"
  161. .IX Header "SEE ALSO"
  162. \&\fBEVP_PKEY_new\fR\|(3)
  163. .SH HISTORY
  164. .IX Header "HISTORY"
  165. The \fBEVP_PKEY_CTX_new()\fR, \fBEVP_PKEY_CTX_new_id()\fR, \fBEVP_PKEY_CTX_dup()\fR and
  166. \&\fBEVP_PKEY_CTX_free()\fR functions were added in OpenSSL 1.0.0.
  167. .PP
  168. The \fBEVP_PKEY_CTX_new_from_name()\fR and \fBEVP_PKEY_CTX_new_from_pkey()\fR functions were
  169. added in OpenSSL 3.0.
  170. .SH COPYRIGHT
  171. .IX Header "COPYRIGHT"
  172. Copyright 2006\-2021 The OpenSSL Project Authors. All Rights Reserved.
  173. .PP
  174. Licensed under the Apache License 2.0 (the "License"). You may not use
  175. this file except in compliance with the License. You can obtain a copy
  176. in the file LICENSE in the source distribution or at
  177. <https://www.openssl.org/source/license.html>.