DH_meth_new.3ossl 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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 "DH_METH_NEW 3ossl"
  58. .TH DH_METH_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. DH_meth_new, DH_meth_free, DH_meth_dup, DH_meth_get0_name, DH_meth_set1_name,
  65. DH_meth_get_flags, DH_meth_set_flags, DH_meth_get0_app_data,
  66. DH_meth_set0_app_data, DH_meth_get_generate_key, DH_meth_set_generate_key,
  67. DH_meth_get_compute_key, DH_meth_set_compute_key, DH_meth_get_bn_mod_exp,
  68. DH_meth_set_bn_mod_exp, DH_meth_get_init, DH_meth_set_init, DH_meth_get_finish,
  69. DH_meth_set_finish, DH_meth_get_generate_params,
  70. DH_meth_set_generate_params \- Routines to build up DH methods
  71. .SH SYNOPSIS
  72. .IX Header "SYNOPSIS"
  73. .Vb 1
  74. \& #include <openssl/dh.h>
  75. .Ve
  76. .PP
  77. The following functions have been deprecated since OpenSSL 3.0, and can be
  78. hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value,
  79. see \fBopenssl_user_macros\fR\|(7):
  80. .PP
  81. .Vb 1
  82. \& DH_METHOD *DH_meth_new(const char *name, int flags);
  83. \&
  84. \& void DH_meth_free(DH_METHOD *dhm);
  85. \&
  86. \& DH_METHOD *DH_meth_dup(const DH_METHOD *dhm);
  87. \&
  88. \& const char *DH_meth_get0_name(const DH_METHOD *dhm);
  89. \& int DH_meth_set1_name(DH_METHOD *dhm, const char *name);
  90. \&
  91. \& int DH_meth_get_flags(const DH_METHOD *dhm);
  92. \& int DH_meth_set_flags(DH_METHOD *dhm, int flags);
  93. \&
  94. \& void *DH_meth_get0_app_data(const DH_METHOD *dhm);
  95. \& int DH_meth_set0_app_data(DH_METHOD *dhm, void *app_data);
  96. \&
  97. \& int (*DH_meth_get_generate_key(const DH_METHOD *dhm))(DH *);
  98. \& int DH_meth_set_generate_key(DH_METHOD *dhm, int (*generate_key)(DH *));
  99. \&
  100. \& int (*DH_meth_get_compute_key(const DH_METHOD *dhm))
  101. \& (unsigned char *key, const BIGNUM *pub_key, DH *dh);
  102. \& int DH_meth_set_compute_key(DH_METHOD *dhm,
  103. \& int (*compute_key)(unsigned char *key, const BIGNUM *pub_key, DH *dh));
  104. \&
  105. \& int (*DH_meth_get_bn_mod_exp(const DH_METHOD *dhm))
  106. \& (const DH *dh, BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
  107. \& const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
  108. \& int DH_meth_set_bn_mod_exp(DH_METHOD *dhm,
  109. \& int (*bn_mod_exp)(const DH *dh, BIGNUM *r, const BIGNUM *a,
  110. \& const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
  111. \& BN_MONT_CTX *m_ctx));
  112. \&
  113. \& int (*DH_meth_get_init(const DH_METHOD *dhm))(DH *);
  114. \& int DH_meth_set_init(DH_METHOD *dhm, int (*init)(DH *));
  115. \&
  116. \& int (*DH_meth_get_finish(const DH_METHOD *dhm))(DH *);
  117. \& int DH_meth_set_finish(DH_METHOD *dhm, int (*finish)(DH *));
  118. \&
  119. \& int (*DH_meth_get_generate_params(const DH_METHOD *dhm))
  120. \& (DH *, int, int, BN_GENCB *);
  121. \& int DH_meth_set_generate_params(DH_METHOD *dhm,
  122. \& int (*generate_params)(DH *, int, int, BN_GENCB *));
  123. .Ve
  124. .SH DESCRIPTION
  125. .IX Header "DESCRIPTION"
  126. All of the functions described on this page are deprecated.
  127. Applications should instead use the provider APIs.
  128. .PP
  129. The \fBDH_METHOD\fR type is a structure used for the provision of custom DH
  130. implementations. It provides a set of functions used by OpenSSL for the
  131. implementation of the various DH capabilities.
  132. .PP
  133. \&\fBDH_meth_new()\fR creates a new \fBDH_METHOD\fR structure. It should be given a
  134. unique \fBname\fR and a set of \fBflags\fR. The \fBname\fR should be a NULL terminated
  135. string, which will be duplicated and stored in the \fBDH_METHOD\fR object. It is
  136. the callers responsibility to free the original string. The flags will be used
  137. during the construction of a new \fBDH\fR object based on this \fBDH_METHOD\fR. Any
  138. new \fBDH\fR object will have those flags set by default.
  139. .PP
  140. \&\fBDH_meth_dup()\fR creates a duplicate copy of the \fBDH_METHOD\fR object passed as a
  141. parameter. This might be useful for creating a new \fBDH_METHOD\fR based on an
  142. existing one, but with some differences.
  143. .PP
  144. \&\fBDH_meth_free()\fR destroys a \fBDH_METHOD\fR structure and frees up any memory
  145. associated with it. If the argument is NULL, nothing is done.
  146. .PP
  147. \&\fBDH_meth_get0_name()\fR will return a pointer to the name of this DH_METHOD. This
  148. is a pointer to the internal name string and so should not be freed by the
  149. caller. \fBDH_meth_set1_name()\fR sets the name of the DH_METHOD to \fBname\fR. The
  150. string is duplicated and the copy is stored in the DH_METHOD structure, so the
  151. caller remains responsible for freeing the memory associated with the name.
  152. .PP
  153. \&\fBDH_meth_get_flags()\fR returns the current value of the flags associated with this
  154. DH_METHOD. \fBDH_meth_set_flags()\fR provides the ability to set these flags.
  155. .PP
  156. The functions \fBDH_meth_get0_app_data()\fR and \fBDH_meth_set0_app_data()\fR provide the
  157. ability to associate implementation specific data with the DH_METHOD. It is
  158. the application's responsibility to free this data before the DH_METHOD is
  159. freed via a call to \fBDH_meth_free()\fR.
  160. .PP
  161. \&\fBDH_meth_get_generate_key()\fR and \fBDH_meth_set_generate_key()\fR get and set the
  162. function used for generating a new DH key pair respectively. This function will
  163. be called in response to the application calling \fBDH_generate_key()\fR. The
  164. parameter for the function has the same meaning as for \fBDH_generate_key()\fR.
  165. .PP
  166. \&\fBDH_meth_get_compute_key()\fR and \fBDH_meth_set_compute_key()\fR get and set the
  167. function used for computing a new DH shared secret respectively. This function
  168. will be called in response to the application calling \fBDH_compute_key()\fR. The
  169. parameters for the function have the same meaning as for \fBDH_compute_key()\fR.
  170. .PP
  171. \&\fBDH_meth_get_bn_mod_exp()\fR and \fBDH_meth_set_bn_mod_exp()\fR get and set the function
  172. used for computing the following value:
  173. .PP
  174. .Vb 1
  175. \& r = a ^ p mod m
  176. .Ve
  177. .PP
  178. This function will be called by the default OpenSSL function for
  179. \&\fBDH_generate_key()\fR. The result is stored in the \fBr\fR parameter. This function
  180. may be NULL unless using the default generate key function, in which case it
  181. must be present.
  182. .PP
  183. \&\fBDH_meth_get_init()\fR and \fBDH_meth_set_init()\fR get and set the function used
  184. for creating a new DH instance respectively. This function will be
  185. called in response to the application calling \fBDH_new()\fR (if the current default
  186. DH_METHOD is this one) or \fBDH_new_method()\fR. The \fBDH_new()\fR and \fBDH_new_method()\fR
  187. functions will allocate the memory for the new DH object, and a pointer to this
  188. newly allocated structure will be passed as a parameter to the function. This
  189. function may be NULL.
  190. .PP
  191. \&\fBDH_meth_get_finish()\fR and \fBDH_meth_set_finish()\fR get and set the function used
  192. for destroying an instance of a DH object respectively. This function will be
  193. called in response to the application calling \fBDH_free()\fR. A pointer to the DH
  194. to be destroyed is passed as a parameter. The destroy function should be used
  195. for DH implementation specific clean up. The memory for the DH itself should
  196. not be freed by this function. This function may be NULL.
  197. .PP
  198. \&\fBDH_meth_get_generate_params()\fR and \fBDH_meth_set_generate_params()\fR get and set the
  199. function used for generating DH parameters respectively. This function will be
  200. called in response to the application calling \fBDH_generate_parameters_ex()\fR (or
  201. \&\fBDH_generate_parameters()\fR). The parameters for the function have the same
  202. meaning as for \fBDH_generate_parameters_ex()\fR. This function may be NULL.
  203. .SH "RETURN VALUES"
  204. .IX Header "RETURN VALUES"
  205. \&\fBDH_meth_new()\fR and \fBDH_meth_dup()\fR return the newly allocated DH_METHOD object
  206. or NULL on failure.
  207. .PP
  208. \&\fBDH_meth_get0_name()\fR and \fBDH_meth_get_flags()\fR return the name and flags
  209. associated with the DH_METHOD respectively.
  210. .PP
  211. All other DH_meth_get_*() functions return the appropriate function pointer
  212. that has been set in the DH_METHOD, or NULL if no such pointer has yet been
  213. set.
  214. .PP
  215. \&\fBDH_meth_set1_name()\fR and all DH_meth_set_*() functions return 1 on success or
  216. 0 on failure.
  217. .SH "SEE ALSO"
  218. .IX Header "SEE ALSO"
  219. \&\fBDH_new\fR\|(3), \fBDH_new\fR\|(3), \fBDH_generate_parameters\fR\|(3), \fBDH_generate_key\fR\|(3),
  220. \&\fBDH_set_method\fR\|(3), \fBDH_size\fR\|(3), \fBDH_get0_pqg\fR\|(3)
  221. .SH HISTORY
  222. .IX Header "HISTORY"
  223. All of these functions were deprecated in OpenSSL 3.0.
  224. .PP
  225. The functions described here were added in OpenSSL 1.1.0.
  226. .SH COPYRIGHT
  227. .IX Header "COPYRIGHT"
  228. Copyright 2016\-2024 The OpenSSL Project Authors. All Rights Reserved.
  229. .PP
  230. Licensed under the Apache License 2.0 (the "License"). You may not use
  231. this file except in compliance with the License. You can obtain a copy
  232. in the file LICENSE in the source distribution or at
  233. <https://www.openssl.org/source/license.html>.