]>
Commit | Line | Data |
---|---|---|
cd35e6c0 RL |
1 | =pod |
2 | ||
3 | =head1 NAME | |
4 | ||
c952780c | 5 | RSA_meth_get0_app_data, RSA_meth_set0_app_data, |
cd35e6c0 RL |
6 | RSA_meth_new, RSA_meth_free, RSA_meth_dup, RSA_meth_get0_name, |
7 | RSA_meth_set1_name, RSA_meth_get_flags, RSA_meth_set_flags, | |
c952780c | 8 | RSA_meth_get_pub_enc, |
cd35e6c0 RL |
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 | - 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); | |
e9b77246 | 24 | |
cd35e6c0 | 25 | RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth); |
e9b77246 | 26 | |
cd35e6c0 RL |
27 | const char *RSA_meth_get0_name(const RSA_METHOD *meth); |
28 | int RSA_meth_set1_name(RSA_METHOD *meth, const char *name); | |
e9b77246 | 29 | |
cd35e6c0 RL |
30 | int RSA_meth_get_flags(RSA_METHOD *meth); |
31 | int RSA_meth_set_flags(RSA_METHOD *meth, int flags); | |
e9b77246 | 32 | |
cd35e6c0 RL |
33 | void *RSA_meth_get0_app_data(const RSA_METHOD *meth); |
34 | int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data); | |
e9b77246 BB |
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); | |
cd35e6c0 | 38 | int RSA_meth_set_pub_enc(RSA_METHOD *rsa, |
e9b77246 BB |
39 | int (*pub_enc)(int flen, const unsigned char *from, |
40 | unsigned char *to, RSA *rsa, | |
41 | int padding)); | |
42 | ||
cd35e6c0 RL |
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, | |
e9b77246 BB |
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); | |
cd35e6c0 | 54 | int RSA_meth_set_priv_enc(RSA_METHOD *rsa, |
e9b77246 BB |
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); | |
cd35e6c0 | 61 | int RSA_meth_set_priv_dec(RSA_METHOD *rsa, |
e9b77246 BB |
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); | |
cd35e6c0 | 68 | int RSA_meth_set_mod_exp(RSA_METHOD *rsa, |
e9b77246 BB |
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); | |
cd35e6c0 | 76 | int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa, |
e9b77246 BB |
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); | |
cd35e6c0 | 93 | int RSA_meth_set_sign(RSA_METHOD *rsa, |
e9b77246 BB |
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); | |
cd35e6c0 | 102 | int RSA_meth_set_verify(RSA_METHOD *rsa, |
e9b77246 BB |
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); | |
cd35e6c0 | 110 | int RSA_meth_set_keygen(RSA_METHOD *rsa, |
e9b77246 BB |
111 | int (*keygen)(RSA *rsa, int bits, BIGNUM *e, |
112 | BN_GENCB *cb)); | |
cd35e6c0 RL |
113 | |
114 | =head1 DESCRIPTION | |
115 | ||
116 | The B<RSA_METHOD> type is a structure used for the provision of custom | |
a970b14f | 117 | RSA implementations. It provides a set of functions used by OpenSSL |
cd35e6c0 RL |
118 | for the implementation of the various RSA capabilities. See the L<rsa> |
119 | page for more information. | |
120 | ||
121 | RSA_meth_new() creates a new B<RSA_METHOD> structure. It should be | |
122 | given a unique B<name> and a set of B<flags>. The B<name> should be a | |
123 | NULL terminated string, which will be duplicated and stored in the | |
124 | B<RSA_METHOD> object. It is the callers responsibility to free the | |
125 | original string. The flags will be used during the construction of a | |
126 | new B<RSA> object based on this B<RSA_METHOD>. Any new B<RSA> object | |
127 | will have those flags set by default. | |
128 | ||
129 | RSA_meth_dup() creates a duplicate copy of the B<RSA_METHOD> object | |
130 | passed as a parameter. This might be useful for creating a new | |
131 | B<RSA_METHOD> based on an existing one, but with some differences. | |
132 | ||
133 | RSA_meth_free() destroys an B<RSA_METHOD> structure and frees up any | |
134 | memory associated with it. | |
135 | ||
136 | RSA_meth_get0_name() will return a pointer to the name of this | |
137 | RSA_METHOD. This is a pointer to the internal name string and so | |
138 | should not be freed by the caller. RSA_meth_set1_name() sets the name | |
139 | of the RSA_METHOD to B<name>. The string is duplicated and the copy is | |
140 | stored in the RSA_METHOD structure, so the caller remains responsible | |
141 | for freeing the memory associated with the name. | |
142 | ||
143 | RSA_meth_get_flags() returns the current value of the flags associated | |
144 | with this RSA_METHOD. RSA_meth_set_flags() provides the ability to set | |
145 | these flags. | |
146 | ||
147 | The functions RSA_meth_get0_app_data() and RSA_meth_set0_app_data() | |
148 | provide the ability to associate implementation specific data with the | |
149 | RSA_METHOD. It is the application's responsibility to free this data | |
150 | before the RSA_METHOD is freed via a call to RSA_meth_free(). | |
151 | ||
152 | RSA_meth_get_sign() and RSA_meth_set_sign() get and set the function | |
153 | used for creating an RSA signature respectively. This function will be | |
154 | called in response to the application calling RSA_sign(). The | |
155 | parameters for the function have the same meaning as for RSA_sign(). | |
156 | ||
157 | RSA_meth_get_verify() and RSA_meth_set_verify() get and set the | |
158 | function used for verifying an RSA signature respectively. This | |
159 | function will be called in response to the application calling | |
160 | RSA_verify(). The parameters for the function have the same meaning as | |
161 | for RSA_verify(). | |
162 | ||
163 | RSA_meth_get_mod_exp() and RSA_meth_set_mod_exp() get and set the | |
164 | function used for CRT computations. | |
165 | ||
166 | RSA_meth_get_bn_mod_exp() and RSA_meth_set_bn_mod_exp() get and set | |
167 | the function used for CRT computations, specifically the following | |
168 | value: | |
169 | ||
170 | r = a ^ p mod m | |
171 | ||
172 | Both the mod_exp() and bn_mod_exp() functions are called by the | |
173 | default OpenSSL method during encryption, decryption, signing and | |
174 | verification. | |
175 | ||
176 | RSA_meth_get_init() and RSA_meth_set_init() get and set the function | |
177 | used for creating a new RSA instance respectively. This function will | |
178 | be called in response to the application calling RSA_new() (if the | |
179 | current default RSA_METHOD is this one) or RSA_new_method(). The | |
180 | RSA_new() and RSA_new_method() functions will allocate the memory for | |
181 | the new RSA object, and a pointer to this newly allocated structure | |
182 | will be passed as a parameter to the function. This function may be | |
183 | NULL. | |
184 | ||
185 | RSA_meth_get_finish() and RSA_meth_set_finish() get and set the | |
186 | function used for destroying an instance of an RSA object respectively. | |
187 | This function will be called in response to the application calling | |
188 | RSA_free(). A pointer to the RSA to be destroyed is passed as a | |
189 | parameter. The destroy function should be used for RSA implementation | |
190 | specific clean up. The memory for the RSA itself should not be freed | |
191 | by this function. This function may be NULL. | |
192 | ||
193 | RSA_meth_get_keygen() and RSA_meth_set_keygen() get and set the | |
194 | function used for generating a new RSA key pair respectively. This | |
195 | function will be called in response to the application calling | |
196 | RSA_generate_key(). The parameter for the function has the same | |
197 | meaning as for RSA_generate_key(). | |
198 | ||
199 | RSA_meth_get_pub_enc(), RSA_meth_set_pub_enc(), | |
200 | RSA_meth_get_pub_dec(), RSA_meth_set_pub_dec(), | |
201 | RSA_meth_get_priv_enc(), RSA_meth_set_priv_enc(), | |
202 | RSA_meth_get_priv_dec(), RSA_meth_set_priv_dec() get and set the | |
203 | functions used for public and private key encryption and decryption. | |
204 | These functions will be called in response to the application calling | |
205 | RSA_public_encrypt(), RSA_private_decrypt(), RSA_private_encrypt() and | |
206 | RSA_public_decrypt() and take the same parameters as those. | |
207 | ||
208 | ||
209 | =head1 RETURN VALUES | |
210 | ||
211 | RSA_meth_new() and RSA_meth_dup() return the newly allocated | |
212 | RSA_METHOD object or NULL on failure. | |
213 | ||
214 | RSA_meth_get0_name() and RSA_meth_get_flags() return the name and | |
215 | flags associated with the RSA_METHOD respectively. | |
216 | ||
217 | All other RSA_meth_get_*() functions return the appropriate function | |
218 | pointer that has been set in the RSA_METHOD, or NULL if no such | |
219 | pointer has yet been set. | |
220 | ||
221 | RSA_meth_set1_name and all RSA_meth_set_*() functions return 1 on | |
222 | success or 0 on failure. | |
223 | ||
224 | =head1 SEE ALSO | |
225 | ||
53934822 | 226 | L<RSA_new(3)>, L<RSA_generate_key(3)>, L<RSA_sign(3)>, |
cd35e6c0 RL |
227 | L<RSA_set_method(3)>, L<RSA_size(3)>, L<RSA_get0_key(3)> |
228 | ||
229 | =head1 HISTORY | |
230 | ||
e90fc053 | 231 | The functions described here were added in OpenSSL 1.1.0. |
cd35e6c0 | 232 | |
e2f92610 RS |
233 | =head1 COPYRIGHT |
234 | ||
a970b14f | 235 | Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved. |
e2f92610 RS |
236 | |
237 | Licensed under the OpenSSL license (the "License"). You may not use | |
238 | this file except in compliance with the License. You can obtain a copy | |
239 | in the file LICENSE in the source distribution or at | |
240 | L<https://www.openssl.org/source/license.html>. | |
241 | ||
242 | =cut |