| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 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 3SSL" |
| 58 |
.TH RSA_SET_METHOD 3SSL 2026-04-07 3.6.2 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 1 for success. It always succeeds. |
| 213 |
.PP |
| 214 |
\&\fBRSA_new_method()\fR returns NULL and sets an error code that can be obtained |
| 215 |
by \fBERR_get_error\fR\|(3) if the allocation fails. Otherwise |
| 216 |
it returns a pointer to the newly allocated structure. |
| 217 |
.SH BUGS |
| 218 |
.IX Header "BUGS" |
| 219 |
The behaviour of \fBRSA_flags()\fR is a mis-feature that is left as-is for now |
| 220 |
to avoid creating compatibility problems. RSA functionality, such as the |
| 221 |
encryption functions, are controlled by the \fBflags\fR value in the RSA key |
| 222 |
itself, not by the \fBflags\fR value in the RSA_METHOD attached to the RSA key |
| 223 |
(which is what this function returns). If the flags element of an RSA key |
| 224 |
is changed, the changes will be honoured by RSA functionality but will not |
| 225 |
be reflected in the return value of the \fBRSA_flags()\fR function \- in effect |
| 226 |
\&\fBRSA_flags()\fR behaves more like an \fBRSA_default_flags()\fR function (which does |
| 227 |
not currently exist). |
| 228 |
.SH "SEE ALSO" |
| 229 |
.IX Header "SEE ALSO" |
| 230 |
\&\fBRSA_new\fR\|(3) |
| 231 |
.SH HISTORY |
| 232 |
.IX Header "HISTORY" |
| 233 |
All of these functions were deprecated in OpenSSL 3.0. |
| 234 |
.PP |
| 235 |
The \fBRSA_null_method()\fR, which was a partial attempt to avoid patent issues, |
| 236 |
was replaced to always return NULL in OpenSSL 1.1.1. |
| 237 |
.SH COPYRIGHT |
| 238 |
.IX Header "COPYRIGHT" |
| 239 |
Copyright 2000\-2026 The OpenSSL Project Authors. All Rights Reserved. |
| 240 |
.PP |
| 241 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 242 |
this file except in compliance with the License. You can obtain a copy |
| 243 |
in the file LICENSE in the source distribution or at |
| 244 |
<https://www.openssl.org/source/license.html>. |