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