RSA_meth_new.3ossl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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 "RSA_METH_NEW 3ossl"
  58. .TH RSA_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. RSA_meth_get0_app_data, RSA_meth_set0_app_data,
  65. RSA_meth_new, RSA_meth_free, RSA_meth_dup, RSA_meth_get0_name,
  66. RSA_meth_set1_name, RSA_meth_get_flags, RSA_meth_set_flags,
  67. RSA_meth_get_pub_enc,
  68. RSA_meth_set_pub_enc, RSA_meth_get_pub_dec, RSA_meth_set_pub_dec,
  69. RSA_meth_get_priv_enc, RSA_meth_set_priv_enc, RSA_meth_get_priv_dec,
  70. RSA_meth_set_priv_dec, RSA_meth_get_mod_exp, RSA_meth_set_mod_exp,
  71. RSA_meth_get_bn_mod_exp, RSA_meth_set_bn_mod_exp, RSA_meth_get_init,
  72. RSA_meth_set_init, RSA_meth_get_finish, RSA_meth_set_finish,
  73. RSA_meth_get_sign, RSA_meth_set_sign, RSA_meth_get_verify,
  74. RSA_meth_set_verify, RSA_meth_get_keygen, RSA_meth_set_keygen,
  75. RSA_meth_get_multi_prime_keygen, RSA_meth_set_multi_prime_keygen
  76. \&\- Routines to build up RSA methods
  77. .SH SYNOPSIS
  78. .IX Header "SYNOPSIS"
  79. .Vb 1
  80. \& #include <openssl/rsa.h>
  81. .Ve
  82. .PP
  83. The following functions have been deprecated since OpenSSL 3.0, and can be
  84. hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value,
  85. see \fBopenssl_user_macros\fR\|(7):
  86. .PP
  87. .Vb 2
  88. \& RSA_METHOD *RSA_meth_new(const char *name, int flags);
  89. \& void RSA_meth_free(RSA_METHOD *meth);
  90. \&
  91. \& RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);
  92. \&
  93. \& const char *RSA_meth_get0_name(const RSA_METHOD *meth);
  94. \& int RSA_meth_set1_name(RSA_METHOD *meth, const char *name);
  95. \&
  96. \& int RSA_meth_get_flags(const RSA_METHOD *meth);
  97. \& int RSA_meth_set_flags(RSA_METHOD *meth, int flags);
  98. \&
  99. \& void *RSA_meth_get0_app_data(const RSA_METHOD *meth);
  100. \& int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data);
  101. \&
  102. \& int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))(int flen, const unsigned char *from,
  103. \& unsigned char *to, RSA *rsa, int padding);
  104. \& int RSA_meth_set_pub_enc(RSA_METHOD *rsa,
  105. \& int (*pub_enc)(int flen, const unsigned char *from,
  106. \& unsigned char *to, RSA *rsa,
  107. \& int padding));
  108. \&
  109. \& int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))
  110. \& (int flen, const unsigned char *from,
  111. \& unsigned char *to, RSA *rsa, int padding);
  112. \& int RSA_meth_set_pub_dec(RSA_METHOD *rsa,
  113. \& int (*pub_dec)(int flen, const unsigned char *from,
  114. \& unsigned char *to, RSA *rsa,
  115. \& int padding));
  116. \&
  117. \& int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))(int flen, const unsigned char *from,
  118. \& unsigned char *to, RSA *rsa,
  119. \& int padding);
  120. \& int RSA_meth_set_priv_enc(RSA_METHOD *rsa,
  121. \& int (*priv_enc)(int flen, const unsigned char *from,
  122. \& unsigned char *to, RSA *rsa, int padding));
  123. \&
  124. \& int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))(int flen, const unsigned char *from,
  125. \& unsigned char *to, RSA *rsa,
  126. \& int padding);
  127. \& int RSA_meth_set_priv_dec(RSA_METHOD *rsa,
  128. \& int (*priv_dec)(int flen, const unsigned char *from,
  129. \& unsigned char *to, RSA *rsa, int padding));
  130. \&
  131. \& /* Can be null */
  132. \& int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))(BIGNUM *r0, const BIGNUM *i,
  133. \& RSA *rsa, BN_CTX *ctx);
  134. \& int RSA_meth_set_mod_exp(RSA_METHOD *rsa,
  135. \& int (*mod_exp)(BIGNUM *r0, const BIGNUM *i, RSA *rsa,
  136. \& BN_CTX *ctx));
  137. \&
  138. \& /* Can be null */
  139. \& int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))(BIGNUM *r, const BIGNUM *a,
  140. \& const BIGNUM *p, const BIGNUM *m,
  141. \& BN_CTX *ctx, BN_MONT_CTX *m_ctx);
  142. \& int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa,
  143. \& int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a,
  144. \& const BIGNUM *p, const BIGNUM *m,
  145. \& BN_CTX *ctx, BN_MONT_CTX *m_ctx));
  146. \&
  147. \& /* called at new */
  148. \& int (*RSA_meth_get_init(const RSA_METHOD *meth) (RSA *rsa);
  149. \& int RSA_meth_set_init(RSA_METHOD *rsa, int (*init (RSA *rsa));
  150. \&
  151. \& /* called at free */
  152. \& int (*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa);
  153. \& int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish)(RSA *rsa));
  154. \&
  155. \& int (*RSA_meth_get_sign(const RSA_METHOD *meth))(int type, const unsigned char *m,
  156. \& unsigned int m_length,
  157. \& unsigned char *sigret,
  158. \& unsigned int *siglen, const RSA *rsa);
  159. \& int RSA_meth_set_sign(RSA_METHOD *rsa,
  160. \& int (*sign)(int type, const unsigned char *m,
  161. \& unsigned int m_length, unsigned char *sigret,
  162. \& unsigned int *siglen, const RSA *rsa));
  163. \&
  164. \& int (*RSA_meth_get_verify(const RSA_METHOD *meth))(int dtype, const unsigned char *m,
  165. \& unsigned int m_length,
  166. \& const unsigned char *sigbuf,
  167. \& unsigned int siglen, const RSA *rsa);
  168. \& int RSA_meth_set_verify(RSA_METHOD *rsa,
  169. \& int (*verify)(int dtype, const unsigned char *m,
  170. \& unsigned int m_length,
  171. \& const unsigned char *sigbuf,
  172. \& unsigned int siglen, const RSA *rsa));
  173. \&
  174. \& int (*RSA_meth_get_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits, BIGNUM *e,
  175. \& BN_GENCB *cb);
  176. \& int RSA_meth_set_keygen(RSA_METHOD *rsa,
  177. \& int (*keygen)(RSA *rsa, int bits, BIGNUM *e,
  178. \& BN_GENCB *cb));
  179. \&
  180. \& int (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits,
  181. \& int primes, BIGNUM *e,
  182. \& BN_GENCB *cb);
  183. \&
  184. \& int RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth,
  185. \& int (*keygen) (RSA *rsa, int bits,
  186. \& int primes, BIGNUM *e,
  187. \& BN_GENCB *cb));
  188. .Ve
  189. .SH DESCRIPTION
  190. .IX Header "DESCRIPTION"
  191. All of the functions described on this page are deprecated.
  192. Applications should instead use the OSSL_PROVIDER APIs.
  193. .PP
  194. The \fBRSA_METHOD\fR type is a structure used for the provision of custom
  195. RSA implementations. It provides a set of functions used by OpenSSL
  196. for the implementation of the various RSA capabilities.
  197. .PP
  198. \&\fBRSA_meth_new()\fR creates a new \fBRSA_METHOD\fR structure. It should be
  199. given a unique \fBname\fR and a set of \fBflags\fR. The \fBname\fR should be a
  200. NULL terminated string, which will be duplicated and stored in the
  201. \&\fBRSA_METHOD\fR object. It is the callers responsibility to free the
  202. original string. The flags will be used during the construction of a
  203. new \fBRSA\fR object based on this \fBRSA_METHOD\fR. Any new \fBRSA\fR object
  204. will have those flags set by default.
  205. .PP
  206. \&\fBRSA_meth_dup()\fR creates a duplicate copy of the \fBRSA_METHOD\fR object
  207. passed as a parameter. This might be useful for creating a new
  208. \&\fBRSA_METHOD\fR based on an existing one, but with some differences.
  209. .PP
  210. \&\fBRSA_meth_free()\fR destroys an \fBRSA_METHOD\fR structure and frees up any
  211. memory associated with it. If the argument is NULL, nothing is done.
  212. .PP
  213. \&\fBRSA_meth_get0_name()\fR will return a pointer to the name of this
  214. RSA_METHOD. This is a pointer to the internal name string and so
  215. should not be freed by the caller. \fBRSA_meth_set1_name()\fR sets the name
  216. of the RSA_METHOD to \fBname\fR. The string is duplicated and the copy is
  217. stored in the RSA_METHOD structure, so the caller remains responsible
  218. for freeing the memory associated with the name.
  219. .PP
  220. \&\fBRSA_meth_get_flags()\fR returns the current value of the flags associated
  221. with this RSA_METHOD. \fBRSA_meth_set_flags()\fR provides the ability to set
  222. these flags.
  223. .PP
  224. The functions \fBRSA_meth_get0_app_data()\fR and \fBRSA_meth_set0_app_data()\fR
  225. provide the ability to associate implementation specific data with the
  226. RSA_METHOD. It is the application's responsibility to free this data
  227. before the RSA_METHOD is freed via a call to \fBRSA_meth_free()\fR.
  228. .PP
  229. \&\fBRSA_meth_get_sign()\fR and \fBRSA_meth_set_sign()\fR get and set the function
  230. used for creating an RSA signature respectively. This function will be
  231. called in response to the application calling \fBRSA_sign()\fR. The
  232. parameters for the function have the same meaning as for \fBRSA_sign()\fR.
  233. .PP
  234. \&\fBRSA_meth_get_verify()\fR and \fBRSA_meth_set_verify()\fR get and set the
  235. function used for verifying an RSA signature respectively. This
  236. function will be called in response to the application calling
  237. \&\fBRSA_verify()\fR. The parameters for the function have the same meaning as
  238. for \fBRSA_verify()\fR.
  239. .PP
  240. \&\fBRSA_meth_get_mod_exp()\fR and \fBRSA_meth_set_mod_exp()\fR get and set the
  241. function used for CRT computations.
  242. .PP
  243. \&\fBRSA_meth_get_bn_mod_exp()\fR and \fBRSA_meth_set_bn_mod_exp()\fR get and set
  244. the function used for CRT computations, specifically the following
  245. value:
  246. .PP
  247. .Vb 1
  248. \& r = a ^ p mod m
  249. .Ve
  250. .PP
  251. Both the \fBmod_exp()\fR and \fBbn_mod_exp()\fR functions are called by the
  252. default OpenSSL method during encryption, decryption, signing and
  253. verification.
  254. .PP
  255. \&\fBRSA_meth_get_init()\fR and \fBRSA_meth_set_init()\fR get and set the function
  256. used for creating a new RSA instance respectively. This function will
  257. be called in response to the application calling \fBRSA_new()\fR (if the
  258. current default RSA_METHOD is this one) or \fBRSA_new_method()\fR. The
  259. \&\fBRSA_new()\fR and \fBRSA_new_method()\fR functions will allocate the memory for
  260. the new RSA object, and a pointer to this newly allocated structure
  261. will be passed as a parameter to the function. This function may be
  262. NULL.
  263. .PP
  264. \&\fBRSA_meth_get_finish()\fR and \fBRSA_meth_set_finish()\fR get and set the
  265. function used for destroying an instance of an RSA object respectively.
  266. This function will be called in response to the application calling
  267. \&\fBRSA_free()\fR. A pointer to the RSA to be destroyed is passed as a
  268. parameter. The destroy function should be used for RSA implementation
  269. specific clean up. The memory for the RSA itself should not be freed
  270. by this function. This function may be NULL.
  271. .PP
  272. \&\fBRSA_meth_get_keygen()\fR and \fBRSA_meth_set_keygen()\fR get and set the
  273. function used for generating a new RSA key pair respectively. This
  274. function will be called in response to the application calling
  275. \&\fBRSA_generate_key_ex()\fR. The parameter for the function has the same
  276. meaning as for \fBRSA_generate_key_ex()\fR.
  277. .PP
  278. \&\fBRSA_meth_get_multi_prime_keygen()\fR and \fBRSA_meth_set_multi_prime_keygen()\fR get
  279. and set the function used for generating a new multi-prime RSA key pair
  280. respectively. This function will be called in response to the application calling
  281. \&\fBRSA_generate_multi_prime_key()\fR. The parameter for the function has the same
  282. meaning as for \fBRSA_generate_multi_prime_key()\fR.
  283. .PP
  284. \&\fBRSA_meth_get_pub_enc()\fR, \fBRSA_meth_set_pub_enc()\fR,
  285. \&\fBRSA_meth_get_pub_dec()\fR, \fBRSA_meth_set_pub_dec()\fR,
  286. \&\fBRSA_meth_get_priv_enc()\fR, \fBRSA_meth_set_priv_enc()\fR,
  287. \&\fBRSA_meth_get_priv_dec()\fR, \fBRSA_meth_set_priv_dec()\fR get and set the
  288. functions used for public and private key encryption and decryption.
  289. These functions will be called in response to the application calling
  290. \&\fBRSA_public_encrypt()\fR, \fBRSA_private_decrypt()\fR, \fBRSA_private_encrypt()\fR and
  291. \&\fBRSA_public_decrypt()\fR and take the same parameters as those.
  292. .SH "RETURN VALUES"
  293. .IX Header "RETURN VALUES"
  294. \&\fBRSA_meth_new()\fR and \fBRSA_meth_dup()\fR return the newly allocated
  295. RSA_METHOD object or NULL on failure.
  296. .PP
  297. \&\fBRSA_meth_get0_name()\fR and \fBRSA_meth_get_flags()\fR return the name and
  298. flags associated with the RSA_METHOD respectively.
  299. .PP
  300. All other RSA_meth_get_*() functions return the appropriate function
  301. pointer that has been set in the RSA_METHOD, or NULL if no such
  302. pointer has yet been set.
  303. .PP
  304. RSA_meth_set1_name and all RSA_meth_set_*() functions return 1 on
  305. success or 0 on failure.
  306. .SH "SEE ALSO"
  307. .IX Header "SEE ALSO"
  308. \&\fBRSA_new\fR\|(3), \fBRSA_generate_key_ex\fR\|(3), \fBRSA_sign\fR\|(3),
  309. \&\fBRSA_set_method\fR\|(3), \fBRSA_size\fR\|(3), \fBRSA_get0_key\fR\|(3),
  310. \&\fBRSA_generate_multi_prime_key\fR\|(3)
  311. .SH HISTORY
  312. .IX Header "HISTORY"
  313. All of these functions were deprecated in OpenSSL 3.0.
  314. .PP
  315. \&\fBRSA_meth_get_multi_prime_keygen()\fR and \fBRSA_meth_set_multi_prime_keygen()\fR were
  316. added in OpenSSL 1.1.1.
  317. .PP
  318. Other functions described here were added in OpenSSL 1.1.0.
  319. .SH COPYRIGHT
  320. .IX Header "COPYRIGHT"
  321. Copyright 2016\-2024 The OpenSSL Project Authors. All Rights Reserved.
  322. .PP
  323. Licensed under the Apache License 2.0 (the "License"). You may not use
  324. this file except in compliance with the License. You can obtain a copy
  325. in the file LICENSE in the source distribution or at
  326. <https://www.openssl.org/source/license.html>.