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