Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-03 09:18:32

0001 /*
0002  * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
0003  *
0004  * Licensed under the Apache License 2.0 (the "License").  You may not use
0005  * this file except in compliance with the License.  You can obtain a copy
0006  * in the file LICENSE in the source distribution or at
0007  * https://www.openssl.org/source/license.html
0008  */
0009 
0010 #ifndef OPENSSL_RSA_H
0011 #define OPENSSL_RSA_H
0012 #pragma once
0013 
0014 #include <openssl/macros.h>
0015 #ifndef OPENSSL_NO_DEPRECATED_3_0
0016 #define HEADER_RSA_H
0017 #endif
0018 
0019 #include <openssl/opensslconf.h>
0020 
0021 #include <openssl/asn1.h>
0022 #include <openssl/bio.h>
0023 #include <openssl/crypto.h>
0024 #include <openssl/types.h>
0025 #ifndef OPENSSL_NO_DEPRECATED_1_1_0
0026 #include <openssl/bn.h>
0027 #endif
0028 #include <openssl/rsaerr.h>
0029 #include <openssl/safestack.h>
0030 #ifndef OPENSSL_NO_STDIO
0031 #include <stdio.h>
0032 #endif
0033 
0034 #ifdef __cplusplus
0035 extern "C" {
0036 #endif
0037 
0038 #ifndef OPENSSL_RSA_MAX_MODULUS_BITS
0039 #define OPENSSL_RSA_MAX_MODULUS_BITS 16384
0040 #endif
0041 
0042 #define RSA_3 0x3L
0043 #define RSA_F4 0x10001L
0044 
0045 #ifndef OPENSSL_NO_DEPRECATED_3_0
0046 /* The types RSA and RSA_METHOD are defined in ossl_typ.h */
0047 
0048 #define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 2048
0049 
0050 #ifndef OPENSSL_RSA_SMALL_MODULUS_BITS
0051 #define OPENSSL_RSA_SMALL_MODULUS_BITS 3072
0052 #endif
0053 
0054 /* exponent limit enforced for "large" modulus only */
0055 #ifndef OPENSSL_RSA_MAX_PUBEXP_BITS
0056 #define OPENSSL_RSA_MAX_PUBEXP_BITS 64
0057 #endif
0058 /* based on RFC 8017 appendix A.1.2 */
0059 #define RSA_ASN1_VERSION_DEFAULT 0
0060 #define RSA_ASN1_VERSION_MULTI 1
0061 
0062 #define RSA_DEFAULT_PRIME_NUM 2
0063 
0064 #define RSA_METHOD_FLAG_NO_CHECK 0x0001
0065 #define RSA_FLAG_CACHE_PUBLIC 0x0002
0066 #define RSA_FLAG_CACHE_PRIVATE 0x0004
0067 #define RSA_FLAG_BLINDING 0x0008
0068 #define RSA_FLAG_THREAD_SAFE 0x0010
0069 /*
0070  * This flag means the private key operations will be handled by rsa_mod_exp
0071  * and that they do not depend on the private key components being present:
0072  * for example a key stored in external hardware. Without this flag
0073  * bn_mod_exp gets called when private key components are absent.
0074  */
0075 #define RSA_FLAG_EXT_PKEY 0x0020
0076 
0077 /*
0078  * new with 0.9.6j and 0.9.7b; the built-in
0079  * RSA implementation now uses blinding by
0080  * default (ignoring RSA_FLAG_BLINDING),
0081  * but other engines might not need it
0082  */
0083 #define RSA_FLAG_NO_BLINDING 0x0080
0084 #endif /* OPENSSL_NO_DEPRECATED_3_0 */
0085 /*
0086  * Does nothing. Previously this switched off constant time behaviour.
0087  */
0088 #ifndef OPENSSL_NO_DEPRECATED_1_1_0
0089 #define RSA_FLAG_NO_CONSTTIME 0x0000
0090 #endif
0091 /* deprecated name for the flag*/
0092 /*
0093  * new with 0.9.7h; the built-in RSA
0094  * implementation now uses constant time
0095  * modular exponentiation for secret exponents
0096  * by default. This flag causes the
0097  * faster variable sliding window method to
0098  * be used for all exponents.
0099  */
0100 #ifndef OPENSSL_NO_DEPRECATED_0_9_8
0101 #define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME
0102 #endif
0103 
0104 /*-
0105  * New with 3.0: use part of the flags to denote exact type of RSA key,
0106  * some of which are limited to specific signature and encryption schemes.
0107  * These different types share the same RSA structure, but indicate the
0108  * use of certain fields in that structure.
0109  * Currently known are:
0110  * RSA          - this is the "normal" unlimited RSA structure (typenum 0)
0111  * RSASSA-PSS   - indicates that the PSS parameters are used.
0112  * RSAES-OAEP   - no specific field used for the moment, but OAEP padding
0113  *                is expected.  (currently unused)
0114  *
0115  * 4 bits allow for 16 types
0116  */
0117 #define RSA_FLAG_TYPE_MASK 0xF000
0118 #define RSA_FLAG_TYPE_RSA 0x0000
0119 #define RSA_FLAG_TYPE_RSASSAPSS 0x1000
0120 #define RSA_FLAG_TYPE_RSAESOAEP 0x2000
0121 
0122 int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int pad_mode);
0123 int EVP_PKEY_CTX_get_rsa_padding(EVP_PKEY_CTX *ctx, int *pad_mode);
0124 
0125 int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int saltlen);
0126 int EVP_PKEY_CTX_get_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int *saltlen);
0127 
0128 int EVP_PKEY_CTX_set_rsa_keygen_bits(EVP_PKEY_CTX *ctx, int bits);
0129 int EVP_PKEY_CTX_set1_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp);
0130 int EVP_PKEY_CTX_set_rsa_keygen_primes(EVP_PKEY_CTX *ctx, int primes);
0131 int EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(EVP_PKEY_CTX *ctx, int saltlen);
0132 #ifndef OPENSSL_NO_DEPRECATED_3_0
0133 OSSL_DEPRECATEDIN_3_0
0134 int EVP_PKEY_CTX_set_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp);
0135 #endif
0136 
0137 /* Salt length matches digest */
0138 #define RSA_PSS_SALTLEN_DIGEST -1
0139 /* Verify only: auto detect salt length */
0140 #define RSA_PSS_SALTLEN_AUTO -2
0141 /* Set salt length to maximum possible */
0142 #define RSA_PSS_SALTLEN_MAX -3
0143 /* Auto-detect on verify, set salt length to min(maximum possible, digest
0144  * length) on sign */
0145 #define RSA_PSS_SALTLEN_AUTO_DIGEST_MAX -4
0146 /* Old compatible max salt length for sign only */
0147 #define RSA_PSS_SALTLEN_MAX_SIGN -2
0148 
0149 int EVP_PKEY_CTX_set_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
0150 int EVP_PKEY_CTX_set_rsa_mgf1_md_name(EVP_PKEY_CTX *ctx, const char *mdname,
0151     const char *mdprops);
0152 int EVP_PKEY_CTX_get_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD **md);
0153 int EVP_PKEY_CTX_get_rsa_mgf1_md_name(EVP_PKEY_CTX *ctx, char *name,
0154     size_t namelen);
0155 int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
0156 int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md_name(EVP_PKEY_CTX *ctx,
0157     const char *mdname);
0158 
0159 int EVP_PKEY_CTX_set_rsa_pss_keygen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
0160 int EVP_PKEY_CTX_set_rsa_pss_keygen_md_name(EVP_PKEY_CTX *ctx,
0161     const char *mdname,
0162     const char *mdprops);
0163 
0164 int EVP_PKEY_CTX_set_rsa_oaep_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
0165 int EVP_PKEY_CTX_set_rsa_oaep_md_name(EVP_PKEY_CTX *ctx, const char *mdname,
0166     const char *mdprops);
0167 int EVP_PKEY_CTX_get_rsa_oaep_md(EVP_PKEY_CTX *ctx, const EVP_MD **md);
0168 int EVP_PKEY_CTX_get_rsa_oaep_md_name(EVP_PKEY_CTX *ctx, char *name,
0169     size_t namelen);
0170 int EVP_PKEY_CTX_set0_rsa_oaep_label(EVP_PKEY_CTX *ctx, void *label, int llen);
0171 int EVP_PKEY_CTX_get0_rsa_oaep_label(EVP_PKEY_CTX *ctx, unsigned char **label);
0172 
0173 #define EVP_PKEY_CTRL_RSA_PADDING (EVP_PKEY_ALG_CTRL + 1)
0174 #define EVP_PKEY_CTRL_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 2)
0175 
0176 #define EVP_PKEY_CTRL_RSA_KEYGEN_BITS (EVP_PKEY_ALG_CTRL + 3)
0177 #define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4)
0178 #define EVP_PKEY_CTRL_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 5)
0179 
0180 #define EVP_PKEY_CTRL_GET_RSA_PADDING (EVP_PKEY_ALG_CTRL + 6)
0181 #define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 7)
0182 #define EVP_PKEY_CTRL_GET_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 8)
0183 
0184 #define EVP_PKEY_CTRL_RSA_OAEP_MD (EVP_PKEY_ALG_CTRL + 9)
0185 #define EVP_PKEY_CTRL_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 10)
0186 
0187 #define EVP_PKEY_CTRL_GET_RSA_OAEP_MD (EVP_PKEY_ALG_CTRL + 11)
0188 #define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12)
0189 
0190 #define EVP_PKEY_CTRL_RSA_KEYGEN_PRIMES (EVP_PKEY_ALG_CTRL + 13)
0191 
0192 #define EVP_PKEY_CTRL_RSA_IMPLICIT_REJECTION (EVP_PKEY_ALG_CTRL + 14)
0193 
0194 #define RSA_PKCS1_PADDING 1
0195 #define RSA_NO_PADDING 3
0196 #define RSA_PKCS1_OAEP_PADDING 4
0197 #define RSA_X931_PADDING 5
0198 
0199 /* EVP_PKEY_ only */
0200 #define RSA_PKCS1_PSS_PADDING 6
0201 #define RSA_PKCS1_WITH_TLS_PADDING 7
0202 
0203 /* internal RSA_ only */
0204 #define RSA_PKCS1_NO_IMPLICIT_REJECT_PADDING 8
0205 
0206 #define RSA_PKCS1_PADDING_SIZE 11
0207 
0208 #define RSA_set_app_data(s, arg) RSA_set_ex_data(s, 0, arg)
0209 #define RSA_get_app_data(s) RSA_get_ex_data(s, 0)
0210 
0211 #ifndef OPENSSL_NO_DEPRECATED_3_0
0212 OSSL_DEPRECATEDIN_3_0 RSA *RSA_new(void);
0213 OSSL_DEPRECATEDIN_3_0 RSA *RSA_new_method(ENGINE *engine);
0214 OSSL_DEPRECATEDIN_3_0 int RSA_bits(const RSA *rsa);
0215 OSSL_DEPRECATEDIN_3_0 int RSA_size(const RSA *rsa);
0216 OSSL_DEPRECATEDIN_3_0 int RSA_security_bits(const RSA *rsa);
0217 
0218 OSSL_DEPRECATEDIN_3_0 int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
0219 OSSL_DEPRECATEDIN_3_0 int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
0220 OSSL_DEPRECATEDIN_3_0 int RSA_set0_crt_params(RSA *r,
0221     BIGNUM *dmp1, BIGNUM *dmq1,
0222     BIGNUM *iqmp);
0223 OSSL_DEPRECATEDIN_3_0 int RSA_set0_multi_prime_params(RSA *r,
0224     BIGNUM *primes[],
0225     BIGNUM *exps[],
0226     BIGNUM *coeffs[],
0227     int pnum);
0228 OSSL_DEPRECATEDIN_3_0 void RSA_get0_key(const RSA *r,
0229     const BIGNUM **n, const BIGNUM **e,
0230     const BIGNUM **d);
0231 OSSL_DEPRECATEDIN_3_0 void RSA_get0_factors(const RSA *r,
0232     const BIGNUM **p, const BIGNUM **q);
0233 OSSL_DEPRECATEDIN_3_0 int RSA_get_multi_prime_extra_count(const RSA *r);
0234 OSSL_DEPRECATEDIN_3_0 int RSA_get0_multi_prime_factors(const RSA *r,
0235     const BIGNUM *primes[]);
0236 OSSL_DEPRECATEDIN_3_0 void RSA_get0_crt_params(const RSA *r,
0237     const BIGNUM **dmp1,
0238     const BIGNUM **dmq1,
0239     const BIGNUM **iqmp);
0240 OSSL_DEPRECATEDIN_3_0
0241 int RSA_get0_multi_prime_crt_params(const RSA *r, const BIGNUM *exps[],
0242     const BIGNUM *coeffs[]);
0243 OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_n(const RSA *d);
0244 OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_e(const RSA *d);
0245 OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_d(const RSA *d);
0246 OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_p(const RSA *d);
0247 OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_q(const RSA *d);
0248 OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_dmp1(const RSA *r);
0249 OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_dmq1(const RSA *r);
0250 OSSL_DEPRECATEDIN_3_0 const BIGNUM *RSA_get0_iqmp(const RSA *r);
0251 OSSL_DEPRECATEDIN_3_0 const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r);
0252 OSSL_DEPRECATEDIN_3_0 void RSA_clear_flags(RSA *r, int flags);
0253 OSSL_DEPRECATEDIN_3_0 int RSA_test_flags(const RSA *r, int flags);
0254 OSSL_DEPRECATEDIN_3_0 void RSA_set_flags(RSA *r, int flags);
0255 OSSL_DEPRECATEDIN_3_0 int RSA_get_version(RSA *r);
0256 OSSL_DEPRECATEDIN_3_0 ENGINE *RSA_get0_engine(const RSA *r);
0257 #endif /* !OPENSSL_NO_DEPRECATED_3_0 */
0258 
0259 #define EVP_RSA_gen(bits) \
0260     EVP_PKEY_Q_keygen(NULL, NULL, "RSA", (size_t)(0 + (bits)))
0261 
0262 /* Deprecated version */
0263 #ifndef OPENSSL_NO_DEPRECATED_0_9_8
0264 OSSL_DEPRECATEDIN_0_9_8 RSA *RSA_generate_key(int bits, unsigned long e, void (*callback)(int, int, void *),
0265     void *cb_arg);
0266 #endif
0267 
0268 /* New version */
0269 #ifndef OPENSSL_NO_DEPRECATED_3_0
0270 OSSL_DEPRECATEDIN_3_0 int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e,
0271     BN_GENCB *cb);
0272 /* Multi-prime version */
0273 OSSL_DEPRECATEDIN_3_0 int RSA_generate_multi_prime_key(RSA *rsa, int bits,
0274     int primes, BIGNUM *e,
0275     BN_GENCB *cb);
0276 
0277 OSSL_DEPRECATEDIN_3_0
0278 int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2,
0279     BIGNUM *q1, BIGNUM *q2,
0280     const BIGNUM *Xp1, const BIGNUM *Xp2,
0281     const BIGNUM *Xp, const BIGNUM *Xq1,
0282     const BIGNUM *Xq2, const BIGNUM *Xq,
0283     const BIGNUM *e, BN_GENCB *cb);
0284 OSSL_DEPRECATEDIN_3_0 int RSA_X931_generate_key_ex(RSA *rsa, int bits,
0285     const BIGNUM *e,
0286     BN_GENCB *cb);
0287 
0288 OSSL_DEPRECATEDIN_3_0 int RSA_check_key(const RSA *);
0289 OSSL_DEPRECATEDIN_3_0 int RSA_check_key_ex(const RSA *, BN_GENCB *cb);
0290 /* next 4 return -1 on error */
0291 OSSL_DEPRECATEDIN_3_0
0292 int RSA_public_encrypt(int flen, const unsigned char *from, unsigned char *to,
0293     RSA *rsa, int padding);
0294 OSSL_DEPRECATEDIN_3_0
0295 int RSA_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
0296     RSA *rsa, int padding);
0297 OSSL_DEPRECATEDIN_3_0
0298 int RSA_public_decrypt(int flen, const unsigned char *from, unsigned char *to,
0299     RSA *rsa, int padding);
0300 OSSL_DEPRECATEDIN_3_0
0301 int RSA_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
0302     RSA *rsa, int padding);
0303 OSSL_DEPRECATEDIN_3_0 void RSA_free(RSA *r);
0304 /* "up" the RSA object's reference count */
0305 OSSL_DEPRECATEDIN_3_0 int RSA_up_ref(RSA *r);
0306 OSSL_DEPRECATEDIN_3_0 int RSA_flags(const RSA *r);
0307 
0308 OSSL_DEPRECATEDIN_3_0 void RSA_set_default_method(const RSA_METHOD *meth);
0309 OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_get_default_method(void);
0310 OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_null_method(void);
0311 OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_get_method(const RSA *rsa);
0312 OSSL_DEPRECATEDIN_3_0 int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
0313 
0314 /* these are the actual RSA functions */
0315 OSSL_DEPRECATEDIN_3_0 const RSA_METHOD *RSA_PKCS1_OpenSSL(void);
0316 
0317 DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(OSSL_DEPRECATEDIN_3_0,
0318     RSA, RSAPublicKey)
0319 DECLARE_ASN1_ENCODE_FUNCTIONS_name_attr(OSSL_DEPRECATEDIN_3_0,
0320     RSA, RSAPrivateKey)
0321 #endif /* !OPENSSL_NO_DEPRECATED_3_0 */
0322 
0323 int RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2);
0324 
0325 struct rsa_pss_params_st {
0326     X509_ALGOR *hashAlgorithm;
0327     X509_ALGOR *maskGenAlgorithm;
0328     ASN1_INTEGER *saltLength;
0329     ASN1_INTEGER *trailerField;
0330     /* Decoded hash algorithm from maskGenAlgorithm */
0331     X509_ALGOR *maskHash;
0332 };
0333 
0334 DECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS)
0335 DECLARE_ASN1_DUP_FUNCTION(RSA_PSS_PARAMS)
0336 
0337 typedef struct rsa_oaep_params_st {
0338     X509_ALGOR *hashFunc;
0339     X509_ALGOR *maskGenFunc;
0340     X509_ALGOR *pSourceFunc;
0341     /* Decoded hash algorithm from maskGenFunc */
0342     X509_ALGOR *maskHash;
0343 } RSA_OAEP_PARAMS;
0344 
0345 DECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS)
0346 
0347 #ifndef OPENSSL_NO_DEPRECATED_3_0
0348 #ifndef OPENSSL_NO_STDIO
0349 OSSL_DEPRECATEDIN_3_0 int RSA_print_fp(FILE *fp, const RSA *r, int offset);
0350 #endif
0351 
0352 OSSL_DEPRECATEDIN_3_0 int RSA_print(BIO *bp, const RSA *r, int offset);
0353 
0354 /*
0355  * The following 2 functions sign and verify a X509_SIG ASN1 object inside
0356  * PKCS#1 padded RSA encryption
0357  */
0358 OSSL_DEPRECATEDIN_3_0 int RSA_sign(int type, const unsigned char *m,
0359     unsigned int m_length, unsigned char *sigret,
0360     unsigned int *siglen, RSA *rsa);
0361 OSSL_DEPRECATEDIN_3_0 int RSA_verify(int type, const unsigned char *m,
0362     unsigned int m_length,
0363     const unsigned char *sigbuf,
0364     unsigned int siglen, RSA *rsa);
0365 
0366 /*
0367  * The following 2 function sign and verify a ASN1_OCTET_STRING object inside
0368  * PKCS#1 padded RSA encryption
0369  */
0370 OSSL_DEPRECATEDIN_3_0
0371 int RSA_sign_ASN1_OCTET_STRING(int type,
0372     const unsigned char *m, unsigned int m_length,
0373     unsigned char *sigret, unsigned int *siglen,
0374     RSA *rsa);
0375 OSSL_DEPRECATEDIN_3_0
0376 int RSA_verify_ASN1_OCTET_STRING(int type,
0377     const unsigned char *m, unsigned int m_length,
0378     unsigned char *sigbuf, unsigned int siglen,
0379     RSA *rsa);
0380 
0381 OSSL_DEPRECATEDIN_3_0 int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
0382 OSSL_DEPRECATEDIN_3_0 void RSA_blinding_off(RSA *rsa);
0383 OSSL_DEPRECATEDIN_3_0 BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);
0384 
0385 OSSL_DEPRECATEDIN_3_0
0386 int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
0387     const unsigned char *f, int fl);
0388 OSSL_DEPRECATEDIN_3_0
0389 int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
0390     const unsigned char *f, int fl,
0391     int rsa_len);
0392 OSSL_DEPRECATEDIN_3_0
0393 int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
0394     const unsigned char *f, int fl);
0395 OSSL_DEPRECATEDIN_3_0
0396 int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
0397     const unsigned char *f, int fl,
0398     int rsa_len);
0399 OSSL_DEPRECATEDIN_3_0 int PKCS1_MGF1(unsigned char *mask, long len,
0400     const unsigned char *seed, long seedlen,
0401     const EVP_MD *dgst);
0402 OSSL_DEPRECATEDIN_3_0
0403 int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
0404     const unsigned char *f, int fl,
0405     const unsigned char *p, int pl);
0406 OSSL_DEPRECATEDIN_3_0
0407 int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
0408     const unsigned char *f, int fl, int rsa_len,
0409     const unsigned char *p, int pl);
0410 OSSL_DEPRECATEDIN_3_0
0411 int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
0412     const unsigned char *from, int flen,
0413     const unsigned char *param, int plen,
0414     const EVP_MD *md, const EVP_MD *mgf1md);
0415 OSSL_DEPRECATEDIN_3_0
0416 int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
0417     const unsigned char *from, int flen,
0418     int num,
0419     const unsigned char *param, int plen,
0420     const EVP_MD *md, const EVP_MD *mgf1md);
0421 OSSL_DEPRECATEDIN_3_0 int RSA_padding_add_none(unsigned char *to, int tlen,
0422     const unsigned char *f, int fl);
0423 OSSL_DEPRECATEDIN_3_0 int RSA_padding_check_none(unsigned char *to, int tlen,
0424     const unsigned char *f, int fl,
0425     int rsa_len);
0426 OSSL_DEPRECATEDIN_3_0 int RSA_padding_add_X931(unsigned char *to, int tlen,
0427     const unsigned char *f, int fl);
0428 OSSL_DEPRECATEDIN_3_0 int RSA_padding_check_X931(unsigned char *to, int tlen,
0429     const unsigned char *f, int fl,
0430     int rsa_len);
0431 OSSL_DEPRECATEDIN_3_0 int RSA_X931_hash_id(int nid);
0432 
0433 OSSL_DEPRECATEDIN_3_0
0434 int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,
0435     const EVP_MD *Hash, const unsigned char *EM,
0436     int sLen);
0437 OSSL_DEPRECATEDIN_3_0
0438 int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,
0439     const unsigned char *mHash, const EVP_MD *Hash,
0440     int sLen);
0441 
0442 OSSL_DEPRECATEDIN_3_0
0443 int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,
0444     const EVP_MD *Hash, const EVP_MD *mgf1Hash,
0445     const unsigned char *EM, int sLen);
0446 
0447 OSSL_DEPRECATEDIN_3_0
0448 int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,
0449     const unsigned char *mHash,
0450     const EVP_MD *Hash, const EVP_MD *mgf1Hash,
0451     int sLen);
0452 
0453 #define RSA_get_ex_new_index(l, p, newf, dupf, freef) \
0454     CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, l, p, newf, dupf, freef)
0455 OSSL_DEPRECATEDIN_3_0 int RSA_set_ex_data(RSA *r, int idx, void *arg);
0456 OSSL_DEPRECATEDIN_3_0 void *RSA_get_ex_data(const RSA *r, int idx);
0457 
0458 DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSAPublicKey)
0459 DECLARE_ASN1_DUP_FUNCTION_name_attr(OSSL_DEPRECATEDIN_3_0, RSA, RSAPrivateKey)
0460 
0461 /*
0462  * If this flag is set the RSA method is FIPS compliant and can be used in
0463  * FIPS mode. This is set in the validated module method. If an application
0464  * sets this flag in its own methods it is its responsibility to ensure the
0465  * result is compliant.
0466  */
0467 
0468 #define RSA_FLAG_FIPS_METHOD 0x0400
0469 
0470 /*
0471  * If this flag is set the operations normally disabled in FIPS mode are
0472  * permitted it is then the applications responsibility to ensure that the
0473  * usage is compliant.
0474  */
0475 
0476 #define RSA_FLAG_NON_FIPS_ALLOW 0x0400
0477 /*
0478  * Application has decided PRNG is good enough to generate a key: don't
0479  * check.
0480  */
0481 #define RSA_FLAG_CHECKED 0x0800
0482 
0483 OSSL_DEPRECATEDIN_3_0 RSA_METHOD *RSA_meth_new(const char *name, int flags);
0484 OSSL_DEPRECATEDIN_3_0 void RSA_meth_free(RSA_METHOD *meth);
0485 OSSL_DEPRECATEDIN_3_0 RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);
0486 OSSL_DEPRECATEDIN_3_0 const char *RSA_meth_get0_name(const RSA_METHOD *meth);
0487 OSSL_DEPRECATEDIN_3_0 int RSA_meth_set1_name(RSA_METHOD *meth,
0488     const char *name);
0489 OSSL_DEPRECATEDIN_3_0 int RSA_meth_get_flags(const RSA_METHOD *meth);
0490 OSSL_DEPRECATEDIN_3_0 int RSA_meth_set_flags(RSA_METHOD *meth, int flags);
0491 OSSL_DEPRECATEDIN_3_0 void *RSA_meth_get0_app_data(const RSA_METHOD *meth);
0492 OSSL_DEPRECATEDIN_3_0 int RSA_meth_set0_app_data(RSA_METHOD *meth,
0493     void *app_data);
0494 OSSL_DEPRECATEDIN_3_0
0495 int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))(int flen,
0496     const unsigned char *from,
0497     unsigned char *to,
0498     RSA *rsa, int padding);
0499 OSSL_DEPRECATEDIN_3_0
0500 int RSA_meth_set_pub_enc(RSA_METHOD *rsa,
0501     int (*pub_enc)(int flen, const unsigned char *from,
0502         unsigned char *to, RSA *rsa,
0503         int padding));
0504 OSSL_DEPRECATEDIN_3_0
0505 int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))(int flen,
0506     const unsigned char *from,
0507     unsigned char *to,
0508     RSA *rsa, int padding);
0509 OSSL_DEPRECATEDIN_3_0
0510 int RSA_meth_set_pub_dec(RSA_METHOD *rsa,
0511     int (*pub_dec)(int flen, const unsigned char *from,
0512         unsigned char *to, RSA *rsa,
0513         int padding));
0514 OSSL_DEPRECATEDIN_3_0
0515 int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))(int flen,
0516     const unsigned char *from,
0517     unsigned char *to,
0518     RSA *rsa, int padding);
0519 OSSL_DEPRECATEDIN_3_0
0520 int RSA_meth_set_priv_enc(RSA_METHOD *rsa,
0521     int (*priv_enc)(int flen, const unsigned char *from,
0522         unsigned char *to, RSA *rsa,
0523         int padding));
0524 OSSL_DEPRECATEDIN_3_0
0525 int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))(int flen,
0526     const unsigned char *from,
0527     unsigned char *to,
0528     RSA *rsa, int padding);
0529 OSSL_DEPRECATEDIN_3_0
0530 int RSA_meth_set_priv_dec(RSA_METHOD *rsa,
0531     int (*priv_dec)(int flen, const unsigned char *from,
0532         unsigned char *to, RSA *rsa,
0533         int padding));
0534 OSSL_DEPRECATEDIN_3_0
0535 int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))(BIGNUM *r0,
0536     const BIGNUM *i,
0537     RSA *rsa, BN_CTX *ctx);
0538 OSSL_DEPRECATEDIN_3_0
0539 int RSA_meth_set_mod_exp(RSA_METHOD *rsa,
0540     int (*mod_exp)(BIGNUM *r0, const BIGNUM *i, RSA *rsa,
0541         BN_CTX *ctx));
0542 OSSL_DEPRECATEDIN_3_0
0543 int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))(BIGNUM *r,
0544     const BIGNUM *a,
0545     const BIGNUM *p,
0546     const BIGNUM *m,
0547     BN_CTX *ctx,
0548     BN_MONT_CTX *m_ctx);
0549 OSSL_DEPRECATEDIN_3_0
0550 int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa,
0551     int (*bn_mod_exp)(BIGNUM *r,
0552         const BIGNUM *a,
0553         const BIGNUM *p,
0554         const BIGNUM *m,
0555         BN_CTX *ctx,
0556         BN_MONT_CTX *m_ctx));
0557 OSSL_DEPRECATEDIN_3_0
0558 int (*RSA_meth_get_init(const RSA_METHOD *meth))(RSA *rsa);
0559 OSSL_DEPRECATEDIN_3_0
0560 int RSA_meth_set_init(RSA_METHOD *rsa, int (*init)(RSA *rsa));
0561 OSSL_DEPRECATEDIN_3_0
0562 int (*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa);
0563 OSSL_DEPRECATEDIN_3_0
0564 int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish)(RSA *rsa));
0565 OSSL_DEPRECATEDIN_3_0
0566 int (*RSA_meth_get_sign(const RSA_METHOD *meth))(int type,
0567     const unsigned char *m,
0568     unsigned int m_length,
0569     unsigned char *sigret,
0570     unsigned int *siglen,
0571     const RSA *rsa);
0572 OSSL_DEPRECATEDIN_3_0
0573 int RSA_meth_set_sign(RSA_METHOD *rsa,
0574     int (*sign)(int type, const unsigned char *m,
0575         unsigned int m_length,
0576         unsigned char *sigret, unsigned int *siglen,
0577         const RSA *rsa));
0578 OSSL_DEPRECATEDIN_3_0
0579 int (*RSA_meth_get_verify(const RSA_METHOD *meth))(int dtype,
0580     const unsigned char *m,
0581     unsigned int m_length,
0582     const unsigned char *sigbuf,
0583     unsigned int siglen,
0584     const RSA *rsa);
0585 OSSL_DEPRECATEDIN_3_0
0586 int RSA_meth_set_verify(RSA_METHOD *rsa,
0587     int (*verify)(int dtype, const unsigned char *m,
0588         unsigned int m_length,
0589         const unsigned char *sigbuf,
0590         unsigned int siglen, const RSA *rsa));
0591 OSSL_DEPRECATEDIN_3_0
0592 int (*RSA_meth_get_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits,
0593     BIGNUM *e, BN_GENCB *cb);
0594 OSSL_DEPRECATEDIN_3_0
0595 int RSA_meth_set_keygen(RSA_METHOD *rsa,
0596     int (*keygen)(RSA *rsa, int bits, BIGNUM *e,
0597         BN_GENCB *cb));
0598 OSSL_DEPRECATEDIN_3_0
0599 int (*RSA_meth_get_multi_prime_keygen(const RSA_METHOD *meth))(RSA *rsa,
0600     int bits,
0601     int primes,
0602     BIGNUM *e,
0603     BN_GENCB *cb);
0604 OSSL_DEPRECATEDIN_3_0
0605 int RSA_meth_set_multi_prime_keygen(RSA_METHOD *meth,
0606     int (*keygen)(RSA *rsa, int bits,
0607         int primes, BIGNUM *e,
0608         BN_GENCB *cb));
0609 #endif /* !OPENSSL_NO_DEPRECATED_3_0 */
0610 
0611 #ifdef __cplusplus
0612 }
0613 #endif
0614 #endif