1RSA_METH_NEW(3)                     OpenSSL                    RSA_METH_NEW(3)
2
3
4

NAME

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

SYNOPSIS

20        #include <openssl/rsa.h>
21
22        RSA_METHOD *RSA_meth_new(const char *name, int flags);
23        void RSA_meth_free(RSA_METHOD *meth);
24
25        RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);
26
27        const char *RSA_meth_get0_name(const RSA_METHOD *meth);
28        int RSA_meth_set1_name(RSA_METHOD *meth, const char *name);
29
30        int RSA_meth_get_flags(const RSA_METHOD *meth);
31        int RSA_meth_set_flags(RSA_METHOD *meth, int flags);
32
33        void *RSA_meth_get0_app_data(const RSA_METHOD *meth);
34        int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data);
35
36        int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))(int flen, const unsigned char *from,
37                                                            unsigned char *to, RSA *rsa, int padding);
38        int RSA_meth_set_pub_enc(RSA_METHOD *rsa,
39                                 int (*pub_enc)(int flen, const unsigned char *from,
40                                                unsigned char *to, RSA *rsa,
41                                                int padding));
42
43        int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))
44            (int flen, const unsigned char *from,
45             unsigned char *to, RSA *rsa, int padding);
46        int RSA_meth_set_pub_dec(RSA_METHOD *rsa,
47                                 int (*pub_dec)(int flen, const unsigned char *from,
48                                                unsigned char *to, RSA *rsa,
49                                                int padding));
50
51        int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))(int flen, const unsigned char *from,
52                                                             unsigned char *to, RSA *rsa,
53                                                             int padding);
54        int RSA_meth_set_priv_enc(RSA_METHOD *rsa,
55                                  int (*priv_enc)(int flen, const unsigned char *from,
56                                                  unsigned char *to, RSA *rsa, int padding));
57
58        int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))(int flen, const unsigned char *from,
59                                                             unsigned char *to, RSA *rsa,
60                                                             int padding);
61        int RSA_meth_set_priv_dec(RSA_METHOD *rsa,
62                                  int (*priv_dec)(int flen, const unsigned char *from,
63                                                  unsigned char *to, RSA *rsa, int padding));
64
65        /* Can be null */
66        int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))(BIGNUM *r0, const BIGNUM *i,
67                                                            RSA *rsa, BN_CTX *ctx);
68        int RSA_meth_set_mod_exp(RSA_METHOD *rsa,
69                                 int (*mod_exp)(BIGNUM *r0, const BIGNUM *i, RSA *rsa,
70                                                BN_CTX *ctx));
71
72        /* Can be null */
73        int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))(BIGNUM *r, const BIGNUM *a,
74                                                               const BIGNUM *p, const BIGNUM *m,
75                                                               BN_CTX *ctx, BN_MONT_CTX *m_ctx);
76        int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa,
77                                    int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a,
78                                                      const BIGNUM *p, const BIGNUM *m,
79                                                      BN_CTX *ctx, BN_MONT_CTX *m_ctx));
80
81        /* called at new */
82        int (*RSA_meth_get_init(const RSA_METHOD *meth) (RSA *rsa);
83        int RSA_meth_set_init(RSA_METHOD *rsa, int (*init (RSA *rsa));
84
85        /* called at free */
86        int (*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa);
87        int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish)(RSA *rsa));
88
89        int (*RSA_meth_get_sign(const RSA_METHOD *meth))(int type, const unsigned char *m,
90                                                         unsigned int m_length,
91                                                         unsigned char *sigret,
92                                                         unsigned int *siglen, const RSA *rsa);
93        int RSA_meth_set_sign(RSA_METHOD *rsa,
94                              int (*sign)(int type, const unsigned char *m,
95                                          unsigned int m_length, unsigned char *sigret,
96                                          unsigned int *siglen, const RSA *rsa));
97
98        int (*RSA_meth_get_verify(const RSA_METHOD *meth))(int dtype, const unsigned char *m,
99                                                           unsigned int m_length,
100                                                           const unsigned char *sigbuf,
101                                                           unsigned int siglen, const RSA *rsa);
102        int RSA_meth_set_verify(RSA_METHOD *rsa,
103                                int (*verify)(int dtype, const unsigned char *m,
104                                              unsigned int m_length,
105                                              const unsigned char *sigbuf,
106                                              unsigned int siglen, const RSA *rsa));
107
108        int (*RSA_meth_get_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits, BIGNUM *e,
109                                                           BN_GENCB *cb);
110        int RSA_meth_set_keygen(RSA_METHOD *rsa,
111                                int (*keygen)(RSA *rsa, int bits, BIGNUM *e,
112                                              BN_GENCB *cb));
113
114        int (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits,
115                                                                       int primes, BIGNUM *e,
116                                                                       BN_GENCB *cb);
117
118        int RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth,
119                                            int (*keygen) (RSA *rsa, int bits,
120                                                           int primes, BIGNUM *e,
121                                                           BN_GENCB *cb));
122

DESCRIPTION

124       The RSA_METHOD type is a structure used for the provision of custom RSA
125       implementations. It provides a set of functions used by OpenSSL for the
126       implementation of the various RSA capabilities. See the rsa page for
127       more information.
128
129       RSA_meth_new() creates a new RSA_METHOD structure. It should be given a
130       unique name and a set of flags. The name should be a NULL terminated
131       string, which will be duplicated and stored in the RSA_METHOD object.
132       It is the callers responsibility to free the original string. The flags
133       will be used during the construction of a new RSA object based on this
134       RSA_METHOD. Any new RSA object will have those flags set by default.
135
136       RSA_meth_dup() creates a duplicate copy of the RSA_METHOD object passed
137       as a parameter. This might be useful for creating a new RSA_METHOD
138       based on an existing one, but with some differences.
139
140       RSA_meth_free() destroys an RSA_METHOD structure and frees up any
141       memory associated with it.
142
143       RSA_meth_get0_name() will return a pointer to the name of this
144       RSA_METHOD. This is a pointer to the internal name string and so should
145       not be freed by the caller. RSA_meth_set1_name() sets the name of the
146       RSA_METHOD to name. The string is duplicated and the copy is stored in
147       the RSA_METHOD structure, so the caller remains responsible for freeing
148       the memory associated with the name.
149
150       RSA_meth_get_flags() returns the current value of the flags associated
151       with this RSA_METHOD. RSA_meth_set_flags() provides the ability to set
152       these flags.
153
154       The functions RSA_meth_get0_app_data() and RSA_meth_set0_app_data()
155       provide the ability to associate implementation specific data with the
156       RSA_METHOD. It is the application's responsibility to free this data
157       before the RSA_METHOD is freed via a call to RSA_meth_free().
158
159       RSA_meth_get_sign() and RSA_meth_set_sign() get and set the function
160       used for creating an RSA signature respectively. This function will be
161       called in response to the application calling RSA_sign(). The
162       parameters for the function have the same meaning as for RSA_sign().
163
164       RSA_meth_get_verify() and RSA_meth_set_verify() get and set the
165       function used for verifying an RSA signature respectively. This
166       function will be called in response to the application calling
167       RSA_verify(). The parameters for the function have the same meaning as
168       for RSA_verify().
169
170       RSA_meth_get_mod_exp() and RSA_meth_set_mod_exp() get and set the
171       function used for CRT computations.
172
173       RSA_meth_get_bn_mod_exp() and RSA_meth_set_bn_mod_exp() get and set the
174       function used for CRT computations, specifically the following value:
175
176        r = a ^ p mod m
177
178       Both the mod_exp() and bn_mod_exp() functions are called by the default
179       OpenSSL method during encryption, decryption, signing and verification.
180
181       RSA_meth_get_init() and RSA_meth_set_init() get and set the function
182       used for creating a new RSA instance respectively. This function will
183       be called in response to the application calling RSA_new() (if the
184       current default RSA_METHOD is this one) or RSA_new_method(). The
185       RSA_new() and RSA_new_method() functions will allocate the memory for
186       the new RSA object, and a pointer to this newly allocated structure
187       will be passed as a parameter to the function. This function may be
188       NULL.
189
190       RSA_meth_get_finish() and RSA_meth_set_finish() get and set the
191       function used for destroying an instance of an RSA object respectively.
192       This function will be called in response to the application calling
193       RSA_free(). A pointer to the RSA to be destroyed is passed as a
194       parameter. The destroy function should be used for RSA implementation
195       specific clean up. The memory for the RSA itself should not be freed by
196       this function. This function may be NULL.
197
198       RSA_meth_get_keygen() and RSA_meth_set_keygen() get and set the
199       function used for generating a new RSA key pair respectively. This
200       function will be called in response to the application calling
201       RSA_generate_key_ex(). The parameter for the function has the same
202       meaning as for RSA_generate_key_ex().
203
204       RSA_meth_get_multi_prime_keygen() and RSA_meth_set_multi_prime_keygen()
205       get and set the function used for generating a new multi-prime RSA key
206       pair respectively. This function will be called in response to the
207       application calling RSA_generate_multi_prime_key(). The parameter for
208       the function has the same meaning as for
209       RSA_generate_multi_prime_key().
210
211       RSA_meth_get_pub_enc(), RSA_meth_set_pub_enc(), RSA_meth_get_pub_dec(),
212       RSA_meth_set_pub_dec(), RSA_meth_get_priv_enc(),
213       RSA_meth_set_priv_enc(), RSA_meth_get_priv_dec(),
214       RSA_meth_set_priv_dec() get and set the functions used for public and
215       private key encryption and decryption.  These functions will be called
216       in response to the application calling RSA_public_encrypt(),
217       RSA_private_decrypt(), RSA_private_encrypt() and RSA_public_decrypt()
218       and take the same parameters as those.
219

RETURN VALUES

221       RSA_meth_new() and RSA_meth_dup() return the newly allocated RSA_METHOD
222       object or NULL on failure.
223
224       RSA_meth_get0_name() and RSA_meth_get_flags() return the name and flags
225       associated with the RSA_METHOD respectively.
226
227       All other RSA_meth_get_*() functions return the appropriate function
228       pointer that has been set in the RSA_METHOD, or NULL if no such pointer
229       has yet been set.
230
231       RSA_meth_set1_name and all RSA_meth_set_*() functions return 1 on
232       success or 0 on failure.
233

SEE ALSO

235       RSA_new(3), RSA_generate_key_ex(3), RSA_sign(3), RSA_set_method(3),
236       RSA_size(3), RSA_get0_key(3), RSA_generate_multi_prime_key(3)
237

HISTORY

239       RSA_meth_get_multi_prime_keygen() and RSA_meth_set_multi_prime_keygen()
240       were added in OpenSSL 1.1.1.
241
242       Other functions described here were added in OpenSSL 1.1.0.
243
245       Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
246
247       Licensed under the OpenSSL license (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>.
251
252
253
2541.1.1q                            2022-07-21                   RSA_METH_NEW(3)
Impressum