RSA_set_method.3ossl 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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_SET_METHOD 3ossl"
  58. .TH RSA_SET_METHOD 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_set_default_method, RSA_get_default_method, RSA_set_method,
  65. RSA_get_method, RSA_PKCS1_OpenSSL, RSA_flags,
  66. RSA_new_method \- select RSA method
  67. .SH SYNOPSIS
  68. .IX Header "SYNOPSIS"
  69. .Vb 1
  70. \& #include <openssl/rsa.h>
  71. .Ve
  72. .PP
  73. The following functions have been deprecated since OpenSSL 3.0, and can be
  74. hidden entirely by defining \fBOPENSSL_API_COMPAT\fR with a suitable version value,
  75. see \fBopenssl_user_macros\fR\|(7):
  76. .PP
  77. .Vb 1
  78. \& void RSA_set_default_method(const RSA_METHOD *meth);
  79. \&
  80. \& const RSA_METHOD *RSA_get_default_method(void);
  81. \&
  82. \& int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
  83. \&
  84. \& const RSA_METHOD *RSA_get_method(const RSA *rsa);
  85. \&
  86. \& const RSA_METHOD *RSA_PKCS1_OpenSSL(void);
  87. \&
  88. \& int RSA_flags(const RSA *rsa);
  89. \&
  90. \& RSA *RSA_new_method(ENGINE *engine);
  91. .Ve
  92. .SH DESCRIPTION
  93. .IX Header "DESCRIPTION"
  94. All of the functions described on this page are deprecated.
  95. Applications should instead use the OSSL_PROVIDER APIs.
  96. .PP
  97. An \fBRSA_METHOD\fR specifies the functions that OpenSSL uses for RSA
  98. operations. By modifying the method, alternative implementations such as
  99. hardware accelerators may be used. IMPORTANT: See the NOTES section for
  100. important information about how these RSA API functions are affected by the
  101. use of \fBENGINE\fR API calls.
  102. .PP
  103. Initially, the default RSA_METHOD is the OpenSSL internal implementation,
  104. as returned by \fBRSA_PKCS1_OpenSSL()\fR.
  105. .PP
  106. \&\fBRSA_set_default_method()\fR makes \fBmeth\fR the default method for all RSA
  107. structures created later.
  108. \&\fBNB\fR: This is true only whilst no ENGINE has
  109. been set as a default for RSA, so this function is no longer recommended.
  110. This function is not thread-safe and should not be called at the same time
  111. as other OpenSSL functions.
  112. .PP
  113. \&\fBRSA_get_default_method()\fR returns a pointer to the current default
  114. RSA_METHOD. However, the meaningfulness of this result is dependent on
  115. whether the ENGINE API is being used, so this function is no longer
  116. recommended.
  117. .PP
  118. \&\fBRSA_set_method()\fR selects \fBmeth\fR to perform all operations using the key
  119. \&\fBrsa\fR. This will replace the RSA_METHOD used by the RSA key and if the
  120. previous method was supplied by an ENGINE, the handle to that ENGINE will
  121. be released during the change. It is possible to have RSA keys that only
  122. work with certain RSA_METHOD implementations (e.g. from an ENGINE module
  123. that supports embedded hardware-protected keys), and in such cases
  124. attempting to change the RSA_METHOD for the key can have unexpected
  125. results.
  126. .PP
  127. \&\fBRSA_get_method()\fR returns a pointer to the RSA_METHOD being used by \fBrsa\fR.
  128. This method may or may not be supplied by an ENGINE implementation, but if
  129. it is, the return value can only be guaranteed to be valid as long as the
  130. RSA key itself is valid and does not have its implementation changed by
  131. \&\fBRSA_set_method()\fR.
  132. .PP
  133. \&\fBRSA_flags()\fR returns the \fBflags\fR that are set for \fBrsa\fR's current
  134. RSA_METHOD. See the BUGS section.
  135. .PP
  136. \&\fBRSA_new_method()\fR allocates and initializes an RSA structure so that
  137. \&\fBengine\fR will be used for the RSA operations. If \fBengine\fR is NULL, the
  138. default ENGINE for RSA operations is used, and if no default ENGINE is set,
  139. the RSA_METHOD controlled by \fBRSA_set_default_method()\fR is used.
  140. .PP
  141. \&\fBRSA_flags()\fR returns the \fBflags\fR that are set for \fBrsa\fR's current method.
  142. .PP
  143. \&\fBRSA_new_method()\fR allocates and initializes an \fBRSA\fR structure so that
  144. \&\fBmethod\fR will be used for the RSA operations. If \fBmethod\fR is \fBNULL\fR,
  145. the default method is used.
  146. .SH "THE RSA_METHOD STRUCTURE"
  147. .IX Header "THE RSA_METHOD STRUCTURE"
  148. .Vb 4
  149. \& typedef struct rsa_meth_st
  150. \& {
  151. \& /* name of the implementation */
  152. \& const char *name;
  153. \&
  154. \& /* encrypt */
  155. \& int (*rsa_pub_enc)(int flen, unsigned char *from,
  156. \& unsigned char *to, RSA *rsa, int padding);
  157. \&
  158. \& /* verify arbitrary data */
  159. \& int (*rsa_pub_dec)(int flen, unsigned char *from,
  160. \& unsigned char *to, RSA *rsa, int padding);
  161. \&
  162. \& /* sign arbitrary data */
  163. \& int (*rsa_priv_enc)(int flen, unsigned char *from,
  164. \& unsigned char *to, RSA *rsa, int padding);
  165. \&
  166. \& /* decrypt */
  167. \& int (*rsa_priv_dec)(int flen, unsigned char *from,
  168. \& unsigned char *to, RSA *rsa, int padding);
  169. \&
  170. \& /* compute r0 = r0 ^ I mod rsa\->n (May be NULL for some implementations) */
  171. \& int (*rsa_mod_exp)(BIGNUM *r0, BIGNUM *I, RSA *rsa);
  172. \&
  173. \& /* compute r = a ^ p mod m (May be NULL for some implementations) */
  174. \& int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
  175. \& const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
  176. \&
  177. \& /* called at RSA_new */
  178. \& int (*init)(RSA *rsa);
  179. \&
  180. \& /* called at RSA_free */
  181. \& int (*finish)(RSA *rsa);
  182. \&
  183. \& /*
  184. \& * RSA_FLAG_EXT_PKEY \- rsa_mod_exp is called for private key
  185. \& * operations, even if p,q,dmp1,dmq1,iqmp
  186. \& * are NULL
  187. \& * RSA_METHOD_FLAG_NO_CHECK \- don\*(Aqt check pub/private match
  188. \& */
  189. \& int flags;
  190. \&
  191. \& char *app_data; /* ?? */
  192. \&
  193. \& int (*rsa_sign)(int type,
  194. \& const unsigned char *m, unsigned int m_length,
  195. \& unsigned char *sigret, unsigned int *siglen, const RSA *rsa);
  196. \& int (*rsa_verify)(int dtype,
  197. \& const unsigned char *m, unsigned int m_length,
  198. \& const unsigned char *sigbuf, unsigned int siglen,
  199. \& const RSA *rsa);
  200. \& /* keygen. If NULL built\-in RSA key generation will be used */
  201. \& int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
  202. \&
  203. \& } RSA_METHOD;
  204. .Ve
  205. .SH "RETURN VALUES"
  206. .IX Header "RETURN VALUES"
  207. \&\fBRSA_PKCS1_OpenSSL()\fR, \fBRSA_PKCS1_null_method()\fR, \fBRSA_get_default_method()\fR
  208. and \fBRSA_get_method()\fR return pointers to the respective RSA_METHODs.
  209. .PP
  210. \&\fBRSA_set_default_method()\fR returns no value.
  211. .PP
  212. \&\fBRSA_set_method()\fR returns a pointer to the old RSA_METHOD implementation
  213. that was replaced. However, this return value should probably be ignored
  214. because if it was supplied by an ENGINE, the pointer could be invalidated
  215. at any time if the ENGINE is unloaded (in fact it could be unloaded as a
  216. result of the \fBRSA_set_method()\fR function releasing its handle to the
  217. ENGINE). For this reason, the return type may be replaced with a \fBvoid\fR
  218. declaration in a future release.
  219. .PP
  220. \&\fBRSA_new_method()\fR returns NULL and sets an error code that can be obtained
  221. by \fBERR_get_error\fR\|(3) if the allocation fails. Otherwise
  222. it returns a pointer to the newly allocated structure.
  223. .SH BUGS
  224. .IX Header "BUGS"
  225. The behaviour of \fBRSA_flags()\fR is a mis-feature that is left as-is for now
  226. to avoid creating compatibility problems. RSA functionality, such as the
  227. encryption functions, are controlled by the \fBflags\fR value in the RSA key
  228. itself, not by the \fBflags\fR value in the RSA_METHOD attached to the RSA key
  229. (which is what this function returns). If the flags element of an RSA key
  230. is changed, the changes will be honoured by RSA functionality but will not
  231. be reflected in the return value of the \fBRSA_flags()\fR function \- in effect
  232. \&\fBRSA_flags()\fR behaves more like an \fBRSA_default_flags()\fR function (which does
  233. not currently exist).
  234. .SH "SEE ALSO"
  235. .IX Header "SEE ALSO"
  236. \&\fBRSA_new\fR\|(3)
  237. .SH HISTORY
  238. .IX Header "HISTORY"
  239. All of these functions were deprecated in OpenSSL 3.0.
  240. .PP
  241. The \fBRSA_null_method()\fR, which was a partial attempt to avoid patent issues,
  242. was replaced to always return NULL in OpenSSL 1.1.1.
  243. .SH COPYRIGHT
  244. .IX Header "COPYRIGHT"
  245. Copyright 2000\-2020 The OpenSSL Project Authors. All Rights Reserved.
  246. .PP
  247. Licensed under the Apache License 2.0 (the "License"). You may not use
  248. this file except in compliance with the License. You can obtain a copy
  249. in the file LICENSE in the source distribution or at
  250. <https://www.openssl.org/source/license.html>.