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