Add legacy include guards to public header files
[openssl.git] / include / openssl / rsa.h
1 /*
2  * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #ifndef OPENSSL_RSA_H
11 # define OPENSSL_RSA_H
12 # pragma once
13
14 # include <openssl/macros.h>
15 # if !OPENSSL_API_3
16 #  define HEADER_RSA_H
17 # endif
18
19 # include <openssl/opensslconf.h>
20
21 # ifndef OPENSSL_NO_RSA
22 # include <openssl/asn1.h>
23 # include <openssl/bio.h>
24 # include <openssl/crypto.h>
25 # include <openssl/types.h>
26 # if !OPENSSL_API_1_1_0
27 #  include <openssl/bn.h>
28 # endif
29 # include <openssl/rsaerr.h>
30 # ifdef  __cplusplus
31 extern "C" {
32 # endif
33
34 /* The types RSA and RSA_METHOD are defined in ossl_typ.h */
35
36 # ifndef OPENSSL_RSA_MAX_MODULUS_BITS
37 #  define OPENSSL_RSA_MAX_MODULUS_BITS   16384
38 # endif
39
40 # define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 1024
41
42 # ifndef OPENSSL_RSA_SMALL_MODULUS_BITS
43 #  define OPENSSL_RSA_SMALL_MODULUS_BITS 3072
44 # endif
45 # ifndef OPENSSL_RSA_MAX_PUBEXP_BITS
46
47 /* exponent limit enforced for "large" modulus only */
48 #  define OPENSSL_RSA_MAX_PUBEXP_BITS    64
49 # endif
50
51 # define RSA_3   0x3L
52 # define RSA_F4  0x10001L
53
54 /* based on RFC 8017 appendix A.1.2 */
55 # define RSA_ASN1_VERSION_DEFAULT        0
56 # define RSA_ASN1_VERSION_MULTI          1
57
58 # define RSA_DEFAULT_PRIME_NUM           2
59
60 # define RSA_METHOD_FLAG_NO_CHECK        0x0001/* don't check pub/private
61                                                 * match */
62
63 # define RSA_FLAG_CACHE_PUBLIC           0x0002
64 # define RSA_FLAG_CACHE_PRIVATE          0x0004
65 # define RSA_FLAG_BLINDING               0x0008
66 # define RSA_FLAG_THREAD_SAFE            0x0010
67 /*
68  * This flag means the private key operations will be handled by rsa_mod_exp
69  * and that they do not depend on the private key components being present:
70  * for example a key stored in external hardware. Without this flag
71  * bn_mod_exp gets called when private key components are absent.
72  */
73 # define RSA_FLAG_EXT_PKEY               0x0020
74
75 /*
76  * new with 0.9.6j and 0.9.7b; the built-in
77  * RSA implementation now uses blinding by
78  * default (ignoring RSA_FLAG_BLINDING),
79  * but other engines might not need it
80  */
81 # define RSA_FLAG_NO_BLINDING            0x0080
82 # if !OPENSSL_API_1_1_0
83 /*
84  * Does nothing. Previously this switched off constant time behaviour.
85  */
86 #  define RSA_FLAG_NO_CONSTTIME           0x0000
87 # endif
88 # if !OPENSSL_API_0_9_8
89 /* deprecated name for the flag*/
90 /*
91  * new with 0.9.7h; the built-in RSA
92  * implementation now uses constant time
93  * modular exponentiation for secret exponents
94  * by default. This flag causes the
95  * faster variable sliding window method to
96  * be used for all exponents.
97  */
98 #  define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME
99 # endif
100
101 # define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \
102         RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_RSA_PADDING, pad, NULL)
103
104 # define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \
105         RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)
106
107 # define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \
108         RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \
109                           EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, NULL)
110 /* Salt length matches digest */
111 # define RSA_PSS_SALTLEN_DIGEST -1
112 /* Verify only: auto detect salt length */
113 # define RSA_PSS_SALTLEN_AUTO   -2
114 /* Set salt length to maximum possible */
115 # define RSA_PSS_SALTLEN_MAX    -3
116 /* Old compatible max salt length for sign only */
117 # define RSA_PSS_SALTLEN_MAX_SIGN    -2
118
119 # define EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(ctx, len) \
120         EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, EVP_PKEY_OP_KEYGEN, \
121                           EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, NULL)
122
123 # define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \
124         RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \
125                           EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, 0, plen)
126
127 # define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \
128         RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \
129                           EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL)
130
131 # define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \
132         RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \
133                           EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp)
134
135 # define EVP_PKEY_CTX_set_rsa_keygen_primes(ctx, primes) \
136         RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \
137                           EVP_PKEY_CTRL_RSA_KEYGEN_PRIMES, primes, NULL)
138
139 # define  EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md) \
140         RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \
141                           EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)(md))
142
143 # define  EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(ctx, md) \
144         EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, EVP_PKEY_OP_KEYGEN, \
145                           EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)(md))
146
147 # define  EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md) \
148         EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \
149                           EVP_PKEY_CTRL_RSA_OAEP_MD, 0, (void *)(md))
150
151 # define  EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd) \
152         RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \
153                           EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)(pmd))
154
155 # define  EVP_PKEY_CTX_get_rsa_oaep_md(ctx, pmd) \
156         EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \
157                           EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, (void *)(pmd))
158
159 # define  EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, l, llen) \
160         EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \
161                           EVP_PKEY_CTRL_RSA_OAEP_LABEL, llen, (void *)(l))
162
163 # define  EVP_PKEY_CTX_get0_rsa_oaep_label(ctx, l) \
164         EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT,  \
165                           EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, (void *)(l))
166
167 # define  EVP_PKEY_CTX_set_rsa_pss_keygen_md(ctx, md) \
168         EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS,  \
169                           EVP_PKEY_OP_KEYGEN, EVP_PKEY_CTRL_MD,  \
170                           0, (void *)(md))
171
172 # define EVP_PKEY_CTRL_RSA_PADDING       (EVP_PKEY_ALG_CTRL + 1)
173 # define EVP_PKEY_CTRL_RSA_PSS_SALTLEN   (EVP_PKEY_ALG_CTRL + 2)
174
175 # define EVP_PKEY_CTRL_RSA_KEYGEN_BITS   (EVP_PKEY_ALG_CTRL + 3)
176 # define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4)
177 # define EVP_PKEY_CTRL_RSA_MGF1_MD       (EVP_PKEY_ALG_CTRL + 5)
178
179 # define EVP_PKEY_CTRL_GET_RSA_PADDING           (EVP_PKEY_ALG_CTRL + 6)
180 # define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN       (EVP_PKEY_ALG_CTRL + 7)
181 # define EVP_PKEY_CTRL_GET_RSA_MGF1_MD           (EVP_PKEY_ALG_CTRL + 8)
182
183 # define EVP_PKEY_CTRL_RSA_OAEP_MD       (EVP_PKEY_ALG_CTRL + 9)
184 # define EVP_PKEY_CTRL_RSA_OAEP_LABEL    (EVP_PKEY_ALG_CTRL + 10)
185
186 # define EVP_PKEY_CTRL_GET_RSA_OAEP_MD   (EVP_PKEY_ALG_CTRL + 11)
187 # define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12)
188
189 # define EVP_PKEY_CTRL_RSA_KEYGEN_PRIMES  (EVP_PKEY_ALG_CTRL + 13)
190
191 # define RSA_PKCS1_PADDING       1
192 # define RSA_SSLV23_PADDING      2
193 # define RSA_NO_PADDING          3
194 # define RSA_PKCS1_OAEP_PADDING  4
195 # define RSA_X931_PADDING        5
196 /* EVP_PKEY_ only */
197 # define RSA_PKCS1_PSS_PADDING   6
198
199 # define RSA_PKCS1_PADDING_SIZE  11
200
201 # define RSA_set_app_data(s,arg)         RSA_set_ex_data(s,0,arg)
202 # define RSA_get_app_data(s)             RSA_get_ex_data(s,0)
203
204 RSA *RSA_new(void);
205 RSA *RSA_new_method(ENGINE *engine);
206 int RSA_bits(const RSA *rsa);
207 int RSA_size(const RSA *rsa);
208 int RSA_security_bits(const RSA *rsa);
209
210 int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
211 int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
212 int RSA_set0_crt_params(RSA *r,BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
213 int RSA_set0_multi_prime_params(RSA *r, BIGNUM *primes[], BIGNUM *exps[],
214                                 BIGNUM *coeffs[], int pnum);
215 void RSA_get0_key(const RSA *r,
216                   const BIGNUM **n, const BIGNUM **e, const BIGNUM **d);
217 void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
218 int RSA_get_multi_prime_extra_count(const RSA *r);
219 int RSA_get0_multi_prime_factors(const RSA *r, const BIGNUM *primes[]);
220 void RSA_get0_crt_params(const RSA *r,
221                          const BIGNUM **dmp1, const BIGNUM **dmq1,
222                          const BIGNUM **iqmp);
223 int RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[],
224                                     const BIGNUM *coeffs[]);
225 const BIGNUM *RSA_get0_n(const RSA *d);
226 const BIGNUM *RSA_get0_e(const RSA *d);
227 const BIGNUM *RSA_get0_d(const RSA *d);
228 const BIGNUM *RSA_get0_p(const RSA *d);
229 const BIGNUM *RSA_get0_q(const RSA *d);
230 const BIGNUM *RSA_get0_dmp1(const RSA *r);
231 const BIGNUM *RSA_get0_dmq1(const RSA *r);
232 const BIGNUM *RSA_get0_iqmp(const RSA *r);
233 void RSA_clear_flags(RSA *r, int flags);
234 int RSA_test_flags(const RSA *r, int flags);
235 void RSA_set_flags(RSA *r, int flags);
236 int RSA_get_version(RSA *r);
237 ENGINE *RSA_get0_engine(const RSA *r);
238
239 /* Deprecated version */
240 DEPRECATEDIN_0_9_8(RSA *RSA_generate_key(int bits, unsigned long e, void
241                                          (*callback) (int, int, void *),
242                                          void *cb_arg))
243
244 /* New version */
245 int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
246 /* Multi-prime version */
247 int RSA_generate_multi_prime_key(RSA *rsa, int bits, int primes,
248                                  BIGNUM *e, BN_GENCB *cb);
249
250 int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1,
251                        BIGNUM *q2, const BIGNUM *Xp1, const BIGNUM *Xp2,
252                        const BIGNUM *Xp, const BIGNUM *Xq1, const BIGNUM *Xq2,
253                        const BIGNUM *Xq, const BIGNUM *e, BN_GENCB *cb);
254 int RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e,
255                              BN_GENCB *cb);
256
257 int RSA_check_key(const RSA *);
258 int RSA_check_key_ex(const RSA *, BN_GENCB *cb);
259         /* next 4 return -1 on error */
260 int RSA_public_encrypt(int flen, const unsigned char *from,
261                        unsigned char *to, RSA *rsa, int padding);
262 int RSA_private_encrypt(int flen, const unsigned char *from,
263                         unsigned char *to, RSA *rsa, int padding);
264 int RSA_public_decrypt(int flen, const unsigned char *from,
265                        unsigned char *to, RSA *rsa, int padding);
266 int RSA_private_decrypt(int flen, const unsigned char *from,
267                         unsigned char *to, RSA *rsa, int padding);
268 void RSA_free(RSA *r);
269 /* "up" the RSA object's reference count */
270 int RSA_up_ref(RSA *r);
271
272 int RSA_flags(const RSA *r);
273
274 void RSA_set_default_method(const RSA_METHOD *meth);
275 const RSA_METHOD *RSA_get_default_method(void);
276 const RSA_METHOD *RSA_null_method(void);
277 const RSA_METHOD *RSA_get_method(const RSA *rsa);
278 int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
279
280 /* these are the actual RSA functions */
281 const RSA_METHOD *RSA_PKCS1_OpenSSL(void);
282
283 int RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2);
284
285 DECLARE_ASN1_ENCODE_FUNCTIONS_name(RSA, RSAPublicKey)
286 DECLARE_ASN1_ENCODE_FUNCTIONS_name(RSA, RSAPrivateKey)
287
288 typedef struct rsa_pss_params_st {
289     X509_ALGOR *hashAlgorithm;
290     X509_ALGOR *maskGenAlgorithm;
291     ASN1_INTEGER *saltLength;
292     ASN1_INTEGER *trailerField;
293     /* Decoded hash algorithm from maskGenAlgorithm */
294     X509_ALGOR *maskHash;
295 } RSA_PSS_PARAMS;
296
297 DECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS)
298
299 typedef struct rsa_oaep_params_st {
300     X509_ALGOR *hashFunc;
301     X509_ALGOR *maskGenFunc;
302     X509_ALGOR *pSourceFunc;
303     /* Decoded hash algorithm from maskGenFunc */
304     X509_ALGOR *maskHash;
305 } RSA_OAEP_PARAMS;
306
307 DECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS)
308
309 # ifndef OPENSSL_NO_STDIO
310 int RSA_print_fp(FILE *fp, const RSA *r, int offset);
311 # endif
312
313 int RSA_print(BIO *bp, const RSA *r, int offset);
314
315 /*
316  * The following 2 functions sign and verify a X509_SIG ASN1 object inside
317  * PKCS#1 padded RSA encryption
318  */
319 int RSA_sign(int type, const unsigned char *m, unsigned int m_length,
320              unsigned char *sigret, unsigned int *siglen, RSA *rsa);
321 int RSA_verify(int type, const unsigned char *m, unsigned int m_length,
322                const unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
323
324 /*
325  * The following 2 function sign and verify a ASN1_OCTET_STRING object inside
326  * PKCS#1 padded RSA encryption
327  */
328 int RSA_sign_ASN1_OCTET_STRING(int type,
329                                const unsigned char *m, unsigned int m_length,
330                                unsigned char *sigret, unsigned int *siglen,
331                                RSA *rsa);
332 int RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m,
333                                  unsigned int m_length, unsigned char *sigbuf,
334                                  unsigned int siglen, RSA *rsa);
335
336 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
337 void RSA_blinding_off(RSA *rsa);
338 BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);
339
340 int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
341                                  const unsigned char *f, int fl);
342 int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
343                                    const unsigned char *f, int fl,
344                                    int rsa_len);
345 int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
346                                  const unsigned char *f, int fl);
347 int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
348                                    const unsigned char *f, int fl,
349                                    int rsa_len);
350 int PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed,
351                long seedlen, const EVP_MD *dgst);
352 int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
353                                const unsigned char *f, int fl,
354                                const unsigned char *p, int pl);
355 int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
356                                  const unsigned char *f, int fl, int rsa_len,
357                                  const unsigned char *p, int pl);
358 int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
359                                     const unsigned char *from, int flen,
360                                     const unsigned char *param, int plen,
361                                     const EVP_MD *md, const EVP_MD *mgf1md);
362 int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
363                                       const unsigned char *from, int flen,
364                                       int num, const unsigned char *param,
365                                       int plen, const EVP_MD *md,
366                                       const EVP_MD *mgf1md);
367 int RSA_padding_add_SSLv23(unsigned char *to, int tlen,
368                            const unsigned char *f, int fl);
369 int RSA_padding_check_SSLv23(unsigned char *to, int tlen,
370                              const unsigned char *f, int fl, int rsa_len);
371 int RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *f,
372                          int fl);
373 int RSA_padding_check_none(unsigned char *to, int tlen,
374                            const unsigned char *f, int fl, int rsa_len);
375 int RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *f,
376                          int fl);
377 int RSA_padding_check_X931(unsigned char *to, int tlen,
378                            const unsigned char *f, int fl, int rsa_len);
379 int RSA_X931_hash_id(int nid);
380
381 int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,
382                          const EVP_MD *Hash, const unsigned char *EM,
383                          int sLen);
384 int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,
385                               const unsigned char *mHash, const EVP_MD *Hash,
386                               int sLen);
387
388 int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,
389                               const EVP_MD *Hash, const EVP_MD *mgf1Hash,
390                               const unsigned char *EM, int sLen);
391
392 int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,
393                                    const unsigned char *mHash,
394                                    const EVP_MD *Hash, const EVP_MD *mgf1Hash,
395                                    int sLen);
396
397 #define RSA_get_ex_new_index(l, p, newf, dupf, freef) \
398     CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, l, p, newf, dupf, freef)
399 int RSA_set_ex_data(RSA *r, int idx, void *arg);
400 void *RSA_get_ex_data(const RSA *r, int idx);
401
402 DECLARE_ASN1_DUP_FUNCTION_name(RSA, RSAPublicKey)
403 DECLARE_ASN1_DUP_FUNCTION_name(RSA, RSAPrivateKey)
404
405 /*
406  * If this flag is set the RSA method is FIPS compliant and can be used in
407  * FIPS mode. This is set in the validated module method. If an application
408  * sets this flag in its own methods it is its responsibility to ensure the
409  * result is compliant.
410  */
411
412 # define RSA_FLAG_FIPS_METHOD                    0x0400
413
414 /*
415  * If this flag is set the operations normally disabled in FIPS mode are
416  * permitted it is then the applications responsibility to ensure that the
417  * usage is compliant.
418  */
419
420 # define RSA_FLAG_NON_FIPS_ALLOW                 0x0400
421 /*
422  * Application has decided PRNG is good enough to generate a key: don't
423  * check.
424  */
425 # define RSA_FLAG_CHECKED                        0x0800
426
427 RSA_METHOD *RSA_meth_new(const char *name, int flags);
428 void RSA_meth_free(RSA_METHOD *meth);
429 RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);
430 const char *RSA_meth_get0_name(const RSA_METHOD *meth);
431 int RSA_meth_set1_name(RSA_METHOD *meth, const char *name);
432 int RSA_meth_get_flags(const RSA_METHOD *meth);
433 int RSA_meth_set_flags(RSA_METHOD *meth, int flags);
434 void *RSA_meth_get0_app_data(const RSA_METHOD *meth);
435 int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data);
436 int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))
437     (int flen, const unsigned char *from,
438      unsigned char *to, RSA *rsa, int padding);
439 int RSA_meth_set_pub_enc(RSA_METHOD *rsa,
440                          int (*pub_enc) (int flen, const unsigned char *from,
441                                          unsigned char *to, RSA *rsa,
442                                          int padding));
443 int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))
444     (int flen, const unsigned char *from,
445      unsigned char *to, RSA *rsa, int padding);
446 int RSA_meth_set_pub_dec(RSA_METHOD *rsa,
447                          int (*pub_dec) (int flen, const unsigned char *from,
448                                          unsigned char *to, RSA *rsa,
449                                          int padding));
450 int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))
451     (int flen, const unsigned char *from,
452      unsigned char *to, RSA *rsa, int padding);
453 int RSA_meth_set_priv_enc(RSA_METHOD *rsa,
454                           int (*priv_enc) (int flen, const unsigned char *from,
455                                            unsigned char *to, RSA *rsa,
456                                            int padding));
457 int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))
458     (int flen, const unsigned char *from,
459      unsigned char *to, RSA *rsa, int padding);
460 int RSA_meth_set_priv_dec(RSA_METHOD *rsa,
461                           int (*priv_dec) (int flen, const unsigned char *from,
462                                            unsigned char *to, RSA *rsa,
463                                            int padding));
464 int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))
465     (BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx);
466 int RSA_meth_set_mod_exp(RSA_METHOD *rsa,
467                          int (*mod_exp) (BIGNUM *r0, const BIGNUM *i, RSA *rsa,
468                                          BN_CTX *ctx));
469 int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))
470     (BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
471      const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
472 int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa,
473                             int (*bn_mod_exp) (BIGNUM *r,
474                                                const BIGNUM *a,
475                                                const BIGNUM *p,
476                                                const BIGNUM *m,
477                                                BN_CTX *ctx,
478                                                BN_MONT_CTX *m_ctx));
479 int (*RSA_meth_get_init(const RSA_METHOD *meth)) (RSA *rsa);
480 int RSA_meth_set_init(RSA_METHOD *rsa, int (*init) (RSA *rsa));
481 int (*RSA_meth_get_finish(const RSA_METHOD *meth)) (RSA *rsa);
482 int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish) (RSA *rsa));
483 int (*RSA_meth_get_sign(const RSA_METHOD *meth))
484     (int type,
485      const unsigned char *m, unsigned int m_length,
486      unsigned char *sigret, unsigned int *siglen,
487      const RSA *rsa);
488 int RSA_meth_set_sign(RSA_METHOD *rsa,
489                       int (*sign) (int type, const unsigned char *m,
490                                    unsigned int m_length,
491                                    unsigned char *sigret, unsigned int *siglen,
492                                    const RSA *rsa));
493 int (*RSA_meth_get_verify(const RSA_METHOD *meth))
494     (int dtype, const unsigned char *m,
495      unsigned int m_length, const unsigned char *sigbuf,
496      unsigned int siglen, const RSA *rsa);
497 int RSA_meth_set_verify(RSA_METHOD *rsa,
498                         int (*verify) (int dtype, const unsigned char *m,
499                                        unsigned int m_length,
500                                        const unsigned char *sigbuf,
501                                        unsigned int siglen, const RSA *rsa));
502 int (*RSA_meth_get_keygen(const RSA_METHOD *meth))
503     (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
504 int RSA_meth_set_keygen(RSA_METHOD *rsa,
505                         int (*keygen) (RSA *rsa, int bits, BIGNUM *e,
506                                        BN_GENCB *cb));
507 int (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth))
508     (RSA *rsa, int bits, int primes, BIGNUM *e, BN_GENCB *cb);
509 int RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth,
510                                     int (*keygen) (RSA *rsa, int bits,
511                                                    int primes, BIGNUM *e,
512                                                    BN_GENCB *cb));
513
514 #  ifdef  __cplusplus
515 }
516 #  endif
517 # endif
518 #endif