1RSA_SET_METHOD(3ossl)               OpenSSL              RSA_SET_METHOD(3ossl)
2
3
4

NAME

6       RSA_set_default_method, RSA_get_default_method, RSA_set_method,
7       RSA_get_method, RSA_PKCS1_OpenSSL, RSA_flags, RSA_new_method - select
8       RSA method
9

SYNOPSIS

11        #include <openssl/rsa.h>
12
13       The following functions have been deprecated since OpenSSL 3.0, and can
14       be hidden entirely by defining OPENSSL_API_COMPAT with a suitable
15       version value, see openssl_user_macros(7):
16
17        void RSA_set_default_method(const RSA_METHOD *meth);
18
19        const RSA_METHOD *RSA_get_default_method(void);
20
21        int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
22
23        const RSA_METHOD *RSA_get_method(const RSA *rsa);
24
25        const RSA_METHOD *RSA_PKCS1_OpenSSL(void);
26
27        int RSA_flags(const RSA *rsa);
28
29        RSA *RSA_new_method(ENGINE *engine);
30

DESCRIPTION

32       All of the functions described on this page are deprecated.
33       Applications should instead use the OSSL_PROVIDER APIs.
34
35       An RSA_METHOD specifies the functions that OpenSSL uses for RSA
36       operations. By modifying the method, alternative implementations such
37       as hardware accelerators may be used. IMPORTANT: See the NOTES section
38       for important information about how these RSA API functions are
39       affected by the use of ENGINE API calls.
40
41       Initially, the default RSA_METHOD is the OpenSSL internal
42       implementation, as returned by RSA_PKCS1_OpenSSL().
43
44       RSA_set_default_method() makes meth the default method for all RSA
45       structures created later.  NB: This is true only whilst no ENGINE has
46       been set as a default for RSA, so this function is no longer
47       recommended.  This function is not thread-safe and should not be called
48       at the same time as other OpenSSL functions.
49
50       RSA_get_default_method() returns a pointer to the current default
51       RSA_METHOD. However, the meaningfulness of this result is dependent on
52       whether the ENGINE API is being used, so this function is no longer
53       recommended.
54
55       RSA_set_method() selects meth to perform all operations using the key
56       rsa. This will replace the RSA_METHOD used by the RSA key and if the
57       previous method was supplied by an ENGINE, the handle to that ENGINE
58       will be released during the change. It is possible to have RSA keys
59       that only work with certain RSA_METHOD implementations (e.g. from an
60       ENGINE module that supports embedded hardware-protected keys), and in
61       such cases attempting to change the RSA_METHOD for the key can have
62       unexpected results.
63
64       RSA_get_method() returns a pointer to the RSA_METHOD being used by rsa.
65       This method may or may not be supplied by an ENGINE implementation, but
66       if it is, the return value can only be guaranteed to be valid as long
67       as the RSA key itself is valid and does not have its implementation
68       changed by RSA_set_method().
69
70       RSA_flags() returns the flags that are set for rsa's current
71       RSA_METHOD. See the BUGS section.
72
73       RSA_new_method() allocates and initializes an RSA structure so that
74       engine will be used for the RSA operations. If engine is NULL, the
75       default ENGINE for RSA operations is used, and if no default ENGINE is
76       set, the RSA_METHOD controlled by RSA_set_default_method() is used.
77
78       RSA_flags() returns the flags that are set for rsa's current method.
79
80       RSA_new_method() allocates and initializes an RSA structure so that
81       method will be used for the RSA operations. If method is NULL, the
82       default method is used.
83

THE RSA_METHOD STRUCTURE

85        typedef struct rsa_meth_st
86        {
87            /* name of the implementation */
88            const char *name;
89
90            /* encrypt */
91            int (*rsa_pub_enc)(int flen, unsigned char *from,
92                               unsigned char *to, RSA *rsa, int padding);
93
94            /* verify arbitrary data */
95            int (*rsa_pub_dec)(int flen, unsigned char *from,
96                               unsigned char *to, RSA *rsa, int padding);
97
98            /* sign arbitrary data */
99            int (*rsa_priv_enc)(int flen, unsigned char *from,
100                                unsigned char *to, RSA *rsa, int padding);
101
102            /* decrypt */
103            int (*rsa_priv_dec)(int flen, unsigned char *from,
104                                unsigned char *to, RSA *rsa, int padding);
105
106            /* compute r0 = r0 ^ I mod rsa->n (May be NULL for some implementations) */
107            int (*rsa_mod_exp)(BIGNUM *r0, BIGNUM *I, RSA *rsa);
108
109            /* compute r = a ^ p mod m (May be NULL for some implementations) */
110            int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p,
111                              const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
112
113            /* called at RSA_new */
114            int (*init)(RSA *rsa);
115
116            /* called at RSA_free */
117            int (*finish)(RSA *rsa);
118
119            /*
120             * RSA_FLAG_EXT_PKEY        - rsa_mod_exp is called for private key
121             *                            operations, even if p,q,dmp1,dmq1,iqmp
122             *                            are NULL
123             * RSA_METHOD_FLAG_NO_CHECK - don't check pub/private match
124             */
125            int flags;
126
127            char *app_data; /* ?? */
128
129            int (*rsa_sign)(int type,
130                            const unsigned char *m, unsigned int m_length,
131                            unsigned char *sigret, unsigned int *siglen, const RSA *rsa);
132            int (*rsa_verify)(int dtype,
133                              const unsigned char *m, unsigned int m_length,
134                              const unsigned char *sigbuf, unsigned int siglen,
135                              const RSA *rsa);
136            /* keygen. If NULL built-in RSA key generation will be used */
137            int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
138
139        } RSA_METHOD;
140

RETURN VALUES

142       RSA_PKCS1_OpenSSL(), RSA_PKCS1_null_method(), RSA_get_default_method()
143       and RSA_get_method() return pointers to the respective RSA_METHODs.
144
145       RSA_set_default_method() returns no value.
146
147       RSA_set_method() returns a pointer to the old RSA_METHOD implementation
148       that was replaced. However, this return value should probably be
149       ignored because if it was supplied by an ENGINE, the pointer could be
150       invalidated at any time if the ENGINE is unloaded (in fact it could be
151       unloaded as a result of the RSA_set_method() function releasing its
152       handle to the ENGINE). For this reason, the return type may be replaced
153       with a void declaration in a future release.
154
155       RSA_new_method() returns NULL and sets an error code that can be
156       obtained by ERR_get_error(3) if the allocation fails. Otherwise it
157       returns a pointer to the newly allocated structure.
158

BUGS

160       The behaviour of RSA_flags() is a mis-feature that is left as-is for
161       now to avoid creating compatibility problems. RSA functionality, such
162       as the encryption functions, are controlled by the flags value in the
163       RSA key itself, not by the flags value in the RSA_METHOD attached to
164       the RSA key (which is what this function returns). If the flags element
165       of an RSA key is changed, the changes will be honoured by RSA
166       functionality but will not be reflected in the return value of the
167       RSA_flags() function - in effect RSA_flags() behaves more like an
168       RSA_default_flags() function (which does not currently exist).
169

SEE ALSO

171       RSA_new(3)
172

HISTORY

174       All of these functions were deprecated in OpenSSL 3.0.
175
176       The RSA_null_method(), which was a partial attempt to avoid patent
177       issues, was replaced to always return NULL in OpenSSL 1.1.1.
178
180       Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
181
182       Licensed under the Apache License 2.0 (the "License").  You may not use
183       this file except in compliance with the License.  You can obtain a copy
184       in the file LICENSE in the source distribution or at
185       <https://www.openssl.org/source/license.html>.
186
187
188
1893.0.5                             2022-11-01             RSA_SET_METHOD(3ossl)
Impressum