1RSA_METH_NEW(3ossl) OpenSSL RSA_METH_NEW(3ossl)
2
3
4
6 RSA_meth_get0_app_data, RSA_meth_set0_app_data, RSA_meth_new,
7 RSA_meth_free, RSA_meth_dup, RSA_meth_get0_name, RSA_meth_set1_name,
8 RSA_meth_get_flags, RSA_meth_set_flags, RSA_meth_get_pub_enc,
9 RSA_meth_set_pub_enc, RSA_meth_get_pub_dec, RSA_meth_set_pub_dec,
10 RSA_meth_get_priv_enc, RSA_meth_set_priv_enc, RSA_meth_get_priv_dec,
11 RSA_meth_set_priv_dec, RSA_meth_get_mod_exp, RSA_meth_set_mod_exp,
12 RSA_meth_get_bn_mod_exp, RSA_meth_set_bn_mod_exp, RSA_meth_get_init,
13 RSA_meth_set_init, RSA_meth_get_finish, RSA_meth_set_finish,
14 RSA_meth_get_sign, RSA_meth_set_sign, RSA_meth_get_verify,
15 RSA_meth_set_verify, RSA_meth_get_keygen, RSA_meth_set_keygen,
16 RSA_meth_get_multi_prime_keygen, RSA_meth_set_multi_prime_keygen -
17 Routines to build up RSA methods
18
20 #include <openssl/rsa.h>
21
22 The following functions have been deprecated since OpenSSL 3.0, and can
23 be hidden entirely by defining OPENSSL_API_COMPAT with a suitable
24 version value, see openssl_user_macros(7):
25
26 RSA_METHOD *RSA_meth_new(const char *name, int flags);
27 void RSA_meth_free(RSA_METHOD *meth);
28
29 RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);
30
31 const char *RSA_meth_get0_name(const RSA_METHOD *meth);
32 int RSA_meth_set1_name(RSA_METHOD *meth, const char *name);
33
34 int RSA_meth_get_flags(const RSA_METHOD *meth);
35 int RSA_meth_set_flags(RSA_METHOD *meth, int flags);
36
37 void *RSA_meth_get0_app_data(const RSA_METHOD *meth);
38 int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data);
39
40 int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))(int flen, const unsigned char *from,
41 unsigned char *to, RSA *rsa, int padding);
42 int RSA_meth_set_pub_enc(RSA_METHOD *rsa,
43 int (*pub_enc)(int flen, const unsigned char *from,
44 unsigned char *to, RSA *rsa,
45 int padding));
46
47 int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))
48 (int flen, const unsigned char *from,
49 unsigned char *to, RSA *rsa, int padding);
50 int RSA_meth_set_pub_dec(RSA_METHOD *rsa,
51 int (*pub_dec)(int flen, const unsigned char *from,
52 unsigned char *to, RSA *rsa,
53 int padding));
54
55 int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))(int flen, const unsigned char *from,
56 unsigned char *to, RSA *rsa,
57 int padding);
58 int RSA_meth_set_priv_enc(RSA_METHOD *rsa,
59 int (*priv_enc)(int flen, const unsigned char *from,
60 unsigned char *to, RSA *rsa, int padding));
61
62 int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))(int flen, const unsigned char *from,
63 unsigned char *to, RSA *rsa,
64 int padding);
65 int RSA_meth_set_priv_dec(RSA_METHOD *rsa,
66 int (*priv_dec)(int flen, const unsigned char *from,
67 unsigned char *to, RSA *rsa, int padding));
68
69 /* Can be null */
70 int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))(BIGNUM *r0, const BIGNUM *i,
71 RSA *rsa, BN_CTX *ctx);
72 int RSA_meth_set_mod_exp(RSA_METHOD *rsa,
73 int (*mod_exp)(BIGNUM *r0, const BIGNUM *i, RSA *rsa,
74 BN_CTX *ctx));
75
76 /* Can be null */
77 int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))(BIGNUM *r, const BIGNUM *a,
78 const BIGNUM *p, const BIGNUM *m,
79 BN_CTX *ctx, BN_MONT_CTX *m_ctx);
80 int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa,
81 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a,
82 const BIGNUM *p, const BIGNUM *m,
83 BN_CTX *ctx, BN_MONT_CTX *m_ctx));
84
85 /* called at new */
86 int (*RSA_meth_get_init(const RSA_METHOD *meth) (RSA *rsa);
87 int RSA_meth_set_init(RSA_METHOD *rsa, int (*init (RSA *rsa));
88
89 /* called at free */
90 int (*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa);
91 int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish)(RSA *rsa));
92
93 int (*RSA_meth_get_sign(const RSA_METHOD *meth))(int type, const unsigned char *m,
94 unsigned int m_length,
95 unsigned char *sigret,
96 unsigned int *siglen, const RSA *rsa);
97 int RSA_meth_set_sign(RSA_METHOD *rsa,
98 int (*sign)(int type, const unsigned char *m,
99 unsigned int m_length, unsigned char *sigret,
100 unsigned int *siglen, const RSA *rsa));
101
102 int (*RSA_meth_get_verify(const RSA_METHOD *meth))(int dtype, const unsigned char *m,
103 unsigned int m_length,
104 const unsigned char *sigbuf,
105 unsigned int siglen, const RSA *rsa);
106 int RSA_meth_set_verify(RSA_METHOD *rsa,
107 int (*verify)(int dtype, const unsigned char *m,
108 unsigned int m_length,
109 const unsigned char *sigbuf,
110 unsigned int siglen, const RSA *rsa));
111
112 int (*RSA_meth_get_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits, BIGNUM *e,
113 BN_GENCB *cb);
114 int RSA_meth_set_keygen(RSA_METHOD *rsa,
115 int (*keygen)(RSA *rsa, int bits, BIGNUM *e,
116 BN_GENCB *cb));
117
118 int (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits,
119 int primes, BIGNUM *e,
120 BN_GENCB *cb);
121
122 int RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth,
123 int (*keygen) (RSA *rsa, int bits,
124 int primes, BIGNUM *e,
125 BN_GENCB *cb));
126
128 All of the functions described on this page are deprecated.
129 Applications should instead use the OSSL_PROVIDER APIs.
130
131 The RSA_METHOD type is a structure used for the provision of custom RSA
132 implementations. It provides a set of functions used by OpenSSL for the
133 implementation of the various RSA capabilities.
134
135 RSA_meth_new() creates a new RSA_METHOD structure. It should be given a
136 unique name and a set of flags. The name should be a NULL terminated
137 string, which will be duplicated and stored in the RSA_METHOD object.
138 It is the callers responsibility to free the original string. The flags
139 will be used during the construction of a new RSA object based on this
140 RSA_METHOD. Any new RSA object will have those flags set by default.
141
142 RSA_meth_dup() creates a duplicate copy of the RSA_METHOD object passed
143 as a parameter. This might be useful for creating a new RSA_METHOD
144 based on an existing one, but with some differences.
145
146 RSA_meth_free() destroys an RSA_METHOD structure and frees up any
147 memory associated with it.
148
149 RSA_meth_get0_name() will return a pointer to the name of this
150 RSA_METHOD. This is a pointer to the internal name string and so should
151 not be freed by the caller. RSA_meth_set1_name() sets the name of the
152 RSA_METHOD to name. The string is duplicated and the copy is stored in
153 the RSA_METHOD structure, so the caller remains responsible for freeing
154 the memory associated with the name.
155
156 RSA_meth_get_flags() returns the current value of the flags associated
157 with this RSA_METHOD. RSA_meth_set_flags() provides the ability to set
158 these flags.
159
160 The functions RSA_meth_get0_app_data() and RSA_meth_set0_app_data()
161 provide the ability to associate implementation specific data with the
162 RSA_METHOD. It is the application's responsibility to free this data
163 before the RSA_METHOD is freed via a call to RSA_meth_free().
164
165 RSA_meth_get_sign() and RSA_meth_set_sign() get and set the function
166 used for creating an RSA signature respectively. This function will be
167 called in response to the application calling RSA_sign(). The
168 parameters for the function have the same meaning as for RSA_sign().
169
170 RSA_meth_get_verify() and RSA_meth_set_verify() get and set the
171 function used for verifying an RSA signature respectively. This
172 function will be called in response to the application calling
173 RSA_verify(). The parameters for the function have the same meaning as
174 for RSA_verify().
175
176 RSA_meth_get_mod_exp() and RSA_meth_set_mod_exp() get and set the
177 function used for CRT computations.
178
179 RSA_meth_get_bn_mod_exp() and RSA_meth_set_bn_mod_exp() get and set the
180 function used for CRT computations, specifically the following value:
181
182 r = a ^ p mod m
183
184 Both the mod_exp() and bn_mod_exp() functions are called by the default
185 OpenSSL method during encryption, decryption, signing and verification.
186
187 RSA_meth_get_init() and RSA_meth_set_init() get and set the function
188 used for creating a new RSA instance respectively. This function will
189 be called in response to the application calling RSA_new() (if the
190 current default RSA_METHOD is this one) or RSA_new_method(). The
191 RSA_new() and RSA_new_method() functions will allocate the memory for
192 the new RSA object, and a pointer to this newly allocated structure
193 will be passed as a parameter to the function. This function may be
194 NULL.
195
196 RSA_meth_get_finish() and RSA_meth_set_finish() get and set the
197 function used for destroying an instance of an RSA object respectively.
198 This function will be called in response to the application calling
199 RSA_free(). A pointer to the RSA to be destroyed is passed as a
200 parameter. The destroy function should be used for RSA implementation
201 specific clean up. The memory for the RSA itself should not be freed by
202 this function. This function may be NULL.
203
204 RSA_meth_get_keygen() and RSA_meth_set_keygen() get and set the
205 function used for generating a new RSA key pair respectively. This
206 function will be called in response to the application calling
207 RSA_generate_key_ex(). The parameter for the function has the same
208 meaning as for RSA_generate_key_ex().
209
210 RSA_meth_get_multi_prime_keygen() and RSA_meth_set_multi_prime_keygen()
211 get and set the function used for generating a new multi-prime RSA key
212 pair respectively. This function will be called in response to the
213 application calling RSA_generate_multi_prime_key(). The parameter for
214 the function has the same meaning as for
215 RSA_generate_multi_prime_key().
216
217 RSA_meth_get_pub_enc(), RSA_meth_set_pub_enc(), RSA_meth_get_pub_dec(),
218 RSA_meth_set_pub_dec(), RSA_meth_get_priv_enc(),
219 RSA_meth_set_priv_enc(), RSA_meth_get_priv_dec(),
220 RSA_meth_set_priv_dec() get and set the functions used for public and
221 private key encryption and decryption. These functions will be called
222 in response to the application calling RSA_public_encrypt(),
223 RSA_private_decrypt(), RSA_private_encrypt() and RSA_public_decrypt()
224 and take the same parameters as those.
225
227 RSA_meth_new() and RSA_meth_dup() return the newly allocated RSA_METHOD
228 object or NULL on failure.
229
230 RSA_meth_get0_name() and RSA_meth_get_flags() return the name and flags
231 associated with the RSA_METHOD respectively.
232
233 All other RSA_meth_get_*() functions return the appropriate function
234 pointer that has been set in the RSA_METHOD, or NULL if no such pointer
235 has yet been set.
236
237 RSA_meth_set1_name and all RSA_meth_set_*() functions return 1 on
238 success or 0 on failure.
239
241 RSA_new(3), RSA_generate_key_ex(3), RSA_sign(3), RSA_set_method(3),
242 RSA_size(3), RSA_get0_key(3), RSA_generate_multi_prime_key(3)
243
245 All of these functions were deprecated in OpenSSL 3.0.
246
247 RSA_meth_get_multi_prime_keygen() and RSA_meth_set_multi_prime_keygen()
248 were added in OpenSSL 1.1.1.
249
250 Other functions described here were added in OpenSSL 1.1.0.
251
253 Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
254
255 Licensed under the Apache License 2.0 (the "License"). You may not use
256 this file except in compliance with the License. You can obtain a copy
257 in the file LICENSE in the source distribution or at
258 <https://www.openssl.org/source/license.html>.
259
260
261
2623.0.9 2023-07-27 RSA_METH_NEW(3ossl)