xref: /onnv-gate/usr/src/common/openssl/crypto/rsa/rsa.h (revision 2864:0fad37eee08f)
10Sstevel@tonic-gate /* crypto/rsa/rsa.h */
20Sstevel@tonic-gate /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
30Sstevel@tonic-gate  * All rights reserved.
40Sstevel@tonic-gate  *
50Sstevel@tonic-gate  * This package is an SSL implementation written
60Sstevel@tonic-gate  * by Eric Young (eay@cryptsoft.com).
70Sstevel@tonic-gate  * The implementation was written so as to conform with Netscapes SSL.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * This library is free for commercial and non-commercial use as long as
100Sstevel@tonic-gate  * the following conditions are aheared to.  The following conditions
110Sstevel@tonic-gate  * apply to all code found in this distribution, be it the RC4, RSA,
120Sstevel@tonic-gate  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
130Sstevel@tonic-gate  * included with this distribution is covered by the same copyright terms
140Sstevel@tonic-gate  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
150Sstevel@tonic-gate  *
160Sstevel@tonic-gate  * Copyright remains Eric Young's, and as such any Copyright notices in
170Sstevel@tonic-gate  * the code are not to be removed.
180Sstevel@tonic-gate  * If this package is used in a product, Eric Young should be given attribution
190Sstevel@tonic-gate  * as the author of the parts of the library used.
200Sstevel@tonic-gate  * This can be in the form of a textual message at program startup or
210Sstevel@tonic-gate  * in documentation (online or textual) provided with the package.
220Sstevel@tonic-gate  *
230Sstevel@tonic-gate  * Redistribution and use in source and binary forms, with or without
240Sstevel@tonic-gate  * modification, are permitted provided that the following conditions
250Sstevel@tonic-gate  * are met:
260Sstevel@tonic-gate  * 1. Redistributions of source code must retain the copyright
270Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer.
280Sstevel@tonic-gate  * 2. Redistributions in binary form must reproduce the above copyright
290Sstevel@tonic-gate  *    notice, this list of conditions and the following disclaimer in the
300Sstevel@tonic-gate  *    documentation and/or other materials provided with the distribution.
310Sstevel@tonic-gate  * 3. All advertising materials mentioning features or use of this software
320Sstevel@tonic-gate  *    must display the following acknowledgement:
330Sstevel@tonic-gate  *    "This product includes cryptographic software written by
340Sstevel@tonic-gate  *     Eric Young (eay@cryptsoft.com)"
350Sstevel@tonic-gate  *    The word 'cryptographic' can be left out if the rouines from the library
360Sstevel@tonic-gate  *    being used are not cryptographic related :-).
370Sstevel@tonic-gate  * 4. If you include any Windows specific code (or a derivative thereof) from
380Sstevel@tonic-gate  *    the apps directory (application code) you must include an acknowledgement:
390Sstevel@tonic-gate  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
400Sstevel@tonic-gate  *
410Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
420Sstevel@tonic-gate  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
430Sstevel@tonic-gate  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
440Sstevel@tonic-gate  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
450Sstevel@tonic-gate  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
460Sstevel@tonic-gate  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
470Sstevel@tonic-gate  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
480Sstevel@tonic-gate  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
490Sstevel@tonic-gate  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
500Sstevel@tonic-gate  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
510Sstevel@tonic-gate  * SUCH DAMAGE.
520Sstevel@tonic-gate  *
530Sstevel@tonic-gate  * The licence and distribution terms for any publically available version or
540Sstevel@tonic-gate  * derivative of this code cannot be changed.  i.e. this code cannot simply be
550Sstevel@tonic-gate  * copied and put under another distribution licence
560Sstevel@tonic-gate  * [including the GNU Public Licence.]
570Sstevel@tonic-gate  */
580Sstevel@tonic-gate 
590Sstevel@tonic-gate #ifndef HEADER_RSA_H
600Sstevel@tonic-gate #define HEADER_RSA_H
610Sstevel@tonic-gate 
620Sstevel@tonic-gate #include <openssl/asn1.h>
630Sstevel@tonic-gate 
640Sstevel@tonic-gate #ifndef OPENSSL_NO_BIO
650Sstevel@tonic-gate #include <openssl/bio.h>
660Sstevel@tonic-gate #endif
670Sstevel@tonic-gate #include <openssl/crypto.h>
680Sstevel@tonic-gate #include <openssl/ossl_typ.h>
692139Sjp161948 #ifndef OPENSSL_NO_DEPRECATED
702139Sjp161948 #include <openssl/bn.h>
712139Sjp161948 #endif
720Sstevel@tonic-gate 
730Sstevel@tonic-gate #ifdef OPENSSL_NO_RSA
740Sstevel@tonic-gate #error RSA is disabled.
750Sstevel@tonic-gate #endif
760Sstevel@tonic-gate 
770Sstevel@tonic-gate #ifdef  __cplusplus
780Sstevel@tonic-gate extern "C" {
790Sstevel@tonic-gate #endif
800Sstevel@tonic-gate 
812139Sjp161948 /* Declared already in ossl_typ.h */
822139Sjp161948 /* typedef struct rsa_st RSA; */
832139Sjp161948 /* typedef struct rsa_meth_st RSA_METHOD; */
840Sstevel@tonic-gate 
852139Sjp161948 struct rsa_meth_st
860Sstevel@tonic-gate 	{
870Sstevel@tonic-gate 	const char *name;
880Sstevel@tonic-gate 	int (*rsa_pub_enc)(int flen,const unsigned char *from,
890Sstevel@tonic-gate 			   unsigned char *to,
900Sstevel@tonic-gate 			   RSA *rsa,int padding);
910Sstevel@tonic-gate 	int (*rsa_pub_dec)(int flen,const unsigned char *from,
920Sstevel@tonic-gate 			   unsigned char *to,
930Sstevel@tonic-gate 			   RSA *rsa,int padding);
940Sstevel@tonic-gate 	int (*rsa_priv_enc)(int flen,const unsigned char *from,
950Sstevel@tonic-gate 			    unsigned char *to,
960Sstevel@tonic-gate 			    RSA *rsa,int padding);
970Sstevel@tonic-gate 	int (*rsa_priv_dec)(int flen,const unsigned char *from,
980Sstevel@tonic-gate 			    unsigned char *to,
990Sstevel@tonic-gate 			    RSA *rsa,int padding);
1002139Sjp161948 	int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa,BN_CTX *ctx); /* Can be null */
1010Sstevel@tonic-gate 	int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
1020Sstevel@tonic-gate 			  const BIGNUM *m, BN_CTX *ctx,
1030Sstevel@tonic-gate 			  BN_MONT_CTX *m_ctx); /* Can be null */
1040Sstevel@tonic-gate 	int (*init)(RSA *rsa);		/* called at new */
1050Sstevel@tonic-gate 	int (*finish)(RSA *rsa);	/* called at free */
1060Sstevel@tonic-gate 	int flags;			/* RSA_METHOD_FLAG_* things */
1070Sstevel@tonic-gate 	char *app_data;			/* may be needed! */
1080Sstevel@tonic-gate /* New sign and verify functions: some libraries don't allow arbitrary data
1090Sstevel@tonic-gate  * to be signed/verified: this allows them to be used. Note: for this to work
1100Sstevel@tonic-gate  * the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used
1110Sstevel@tonic-gate  * RSA_sign(), RSA_verify() should be used instead. Note: for backwards
1120Sstevel@tonic-gate  * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER
1130Sstevel@tonic-gate  * option is set in 'flags'.
1140Sstevel@tonic-gate  */
1150Sstevel@tonic-gate 	int (*rsa_sign)(int type,
1160Sstevel@tonic-gate 		const unsigned char *m, unsigned int m_length,
1170Sstevel@tonic-gate 		unsigned char *sigret, unsigned int *siglen, const RSA *rsa);
1180Sstevel@tonic-gate 	int (*rsa_verify)(int dtype,
1190Sstevel@tonic-gate 		const unsigned char *m, unsigned int m_length,
1200Sstevel@tonic-gate 		unsigned char *sigbuf, unsigned int siglen, const RSA *rsa);
1212139Sjp161948 /* If this callback is NULL, the builtin software RSA key-gen will be used. This
1222139Sjp161948  * is for behavioural compatibility whilst the code gets rewired, but one day
1232139Sjp161948  * it would be nice to assume there are no such things as "builtin software"
1242139Sjp161948  * implementations. */
1252139Sjp161948 	int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
1262139Sjp161948 	};
1270Sstevel@tonic-gate 
1280Sstevel@tonic-gate struct rsa_st
1290Sstevel@tonic-gate 	{
1300Sstevel@tonic-gate 	/* The first parameter is used to pickup errors where
1310Sstevel@tonic-gate 	 * this is passed instead of aEVP_PKEY, it is set to 0 */
1320Sstevel@tonic-gate 	int pad;
1330Sstevel@tonic-gate 	long version;
1340Sstevel@tonic-gate 	const RSA_METHOD *meth;
1350Sstevel@tonic-gate 	/* functional reference if 'meth' is ENGINE-provided */
1360Sstevel@tonic-gate 	ENGINE *engine;
1370Sstevel@tonic-gate 	BIGNUM *n;
1380Sstevel@tonic-gate 	BIGNUM *e;
1390Sstevel@tonic-gate 	BIGNUM *d;
1400Sstevel@tonic-gate 	BIGNUM *p;
1410Sstevel@tonic-gate 	BIGNUM *q;
1420Sstevel@tonic-gate 	BIGNUM *dmp1;
1430Sstevel@tonic-gate 	BIGNUM *dmq1;
1440Sstevel@tonic-gate 	BIGNUM *iqmp;
1450Sstevel@tonic-gate 	/* be careful using this if the RSA structure is shared */
1460Sstevel@tonic-gate 	CRYPTO_EX_DATA ex_data;
1470Sstevel@tonic-gate 	int references;
1480Sstevel@tonic-gate 	int flags;
1490Sstevel@tonic-gate 
1500Sstevel@tonic-gate 	/* Used to cache montgomery values */
1510Sstevel@tonic-gate 	BN_MONT_CTX *_method_mod_n;
1520Sstevel@tonic-gate 	BN_MONT_CTX *_method_mod_p;
1530Sstevel@tonic-gate 	BN_MONT_CTX *_method_mod_q;
1540Sstevel@tonic-gate 
1550Sstevel@tonic-gate 	/* all BIGNUM values are actually in the following data, if it is not
1560Sstevel@tonic-gate 	 * NULL */
1570Sstevel@tonic-gate 	char *bignum_data;
1580Sstevel@tonic-gate 	BN_BLINDING *blinding;
1592139Sjp161948 	BN_BLINDING *mt_blinding;
1600Sstevel@tonic-gate 	};
1610Sstevel@tonic-gate 
162*2864Sjp161948 #ifndef OPENSSL_RSA_MAX_MODULUS_BITS
163*2864Sjp161948 # define OPENSSL_RSA_MAX_MODULUS_BITS  16384
164*2864Sjp161948 #endif
165*2864Sjp161948 
166*2864Sjp161948 #ifndef OPENSSL_RSA_SMALL_MODULUS_BITS
167*2864Sjp161948 # define OPENSSL_RSA_SMALL_MODULUS_BITS        3072
168*2864Sjp161948 #endif
169*2864Sjp161948 #ifndef OPENSSL_RSA_MAX_PUBEXP_BITS
170*2864Sjp161948 # define OPENSSL_RSA_MAX_PUBEXP_BITS   64 /* exponent limit enforced for "large" modulus only */
171*2864Sjp161948 #endif
172*2864Sjp161948 
1730Sstevel@tonic-gate #define RSA_3	0x3L
1740Sstevel@tonic-gate #define RSA_F4	0x10001L
1750Sstevel@tonic-gate 
1762139Sjp161948 #define RSA_METHOD_FLAG_NO_CHECK	0x0001 /* don't check pub/private match */
1770Sstevel@tonic-gate 
1782139Sjp161948 #define RSA_FLAG_CACHE_PUBLIC		0x0002
1792139Sjp161948 #define RSA_FLAG_CACHE_PRIVATE		0x0004
1802139Sjp161948 #define RSA_FLAG_BLINDING		0x0008
1812139Sjp161948 #define RSA_FLAG_THREAD_SAFE		0x0010
1820Sstevel@tonic-gate /* This flag means the private key operations will be handled by rsa_mod_exp
1830Sstevel@tonic-gate  * and that they do not depend on the private key components being present:
1840Sstevel@tonic-gate  * for example a key stored in external hardware. Without this flag bn_mod_exp
1850Sstevel@tonic-gate  * gets called when private key components are absent.
1860Sstevel@tonic-gate  */
1872139Sjp161948 #define RSA_FLAG_EXT_PKEY		0x0020
1880Sstevel@tonic-gate 
1890Sstevel@tonic-gate /* This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify functions.
1900Sstevel@tonic-gate  */
1912139Sjp161948 #define RSA_FLAG_SIGN_VER		0x0040
1920Sstevel@tonic-gate 
1932139Sjp161948 #define RSA_FLAG_NO_BLINDING		0x0080 /* new with 0.9.6j and 0.9.7b; the built-in
1942139Sjp161948                                                 * RSA implementation now uses blinding by
1952139Sjp161948                                                 * default (ignoring RSA_FLAG_BLINDING),
1962139Sjp161948                                                 * but other engines might not need it
1972139Sjp161948                                                 */
1982139Sjp161948 #define RSA_FLAG_NO_EXP_CONSTTIME	0x0100 /* new with 0.9.7h; the built-in RSA
1992139Sjp161948                                                 * implementation now uses constant time
2002139Sjp161948                                                 * modular exponentiation for secret exponents
2012139Sjp161948                                                 * by default. This flag causes the
2022139Sjp161948                                                 * faster variable sliding window method to
2032139Sjp161948                                                 * be used for all exponents.
2042139Sjp161948                                                 */
2050Sstevel@tonic-gate 
2060Sstevel@tonic-gate #define RSA_PKCS1_PADDING	1
2070Sstevel@tonic-gate #define RSA_SSLV23_PADDING	2
2080Sstevel@tonic-gate #define RSA_NO_PADDING		3
2090Sstevel@tonic-gate #define RSA_PKCS1_OAEP_PADDING	4
2102139Sjp161948 #define RSA_X931_PADDING	5
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate #define RSA_PKCS1_PADDING_SIZE	11
2130Sstevel@tonic-gate 
2140Sstevel@tonic-gate #define RSA_set_app_data(s,arg)         RSA_set_ex_data(s,0,arg)
2150Sstevel@tonic-gate #define RSA_get_app_data(s)             RSA_get_ex_data(s,0)
2160Sstevel@tonic-gate 
2170Sstevel@tonic-gate RSA *	RSA_new(void);
2180Sstevel@tonic-gate RSA *	RSA_new_method(ENGINE *engine);
2190Sstevel@tonic-gate int	RSA_size(const RSA *);
2202139Sjp161948 
2212139Sjp161948 /* Deprecated version */
2222139Sjp161948 #ifndef OPENSSL_NO_DEPRECATED
2230Sstevel@tonic-gate RSA *	RSA_generate_key(int bits, unsigned long e,void
2240Sstevel@tonic-gate 		(*callback)(int,int,void *),void *cb_arg);
2252139Sjp161948 #endif /* !defined(OPENSSL_NO_DEPRECATED) */
2262139Sjp161948 
2272139Sjp161948 /* New version */
2282139Sjp161948 int	RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
2292139Sjp161948 
2300Sstevel@tonic-gate int	RSA_check_key(const RSA *);
2310Sstevel@tonic-gate 	/* next 4 return -1 on error */
2320Sstevel@tonic-gate int	RSA_public_encrypt(int flen, const unsigned char *from,
2330Sstevel@tonic-gate 		unsigned char *to, RSA *rsa,int padding);
2340Sstevel@tonic-gate int	RSA_private_encrypt(int flen, const unsigned char *from,
2350Sstevel@tonic-gate 		unsigned char *to, RSA *rsa,int padding);
2360Sstevel@tonic-gate int	RSA_public_decrypt(int flen, const unsigned char *from,
2370Sstevel@tonic-gate 		unsigned char *to, RSA *rsa,int padding);
2380Sstevel@tonic-gate int	RSA_private_decrypt(int flen, const unsigned char *from,
2390Sstevel@tonic-gate 		unsigned char *to, RSA *rsa,int padding);
2400Sstevel@tonic-gate void	RSA_free (RSA *r);
2410Sstevel@tonic-gate /* "up" the RSA object's reference count */
2420Sstevel@tonic-gate int	RSA_up_ref(RSA *r);
2430Sstevel@tonic-gate 
2440Sstevel@tonic-gate int	RSA_flags(const RSA *r);
2450Sstevel@tonic-gate 
2460Sstevel@tonic-gate void RSA_set_default_method(const RSA_METHOD *meth);
2470Sstevel@tonic-gate const RSA_METHOD *RSA_get_default_method(void);
2480Sstevel@tonic-gate const RSA_METHOD *RSA_get_method(const RSA *rsa);
2490Sstevel@tonic-gate int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
2500Sstevel@tonic-gate 
2510Sstevel@tonic-gate /* This function needs the memory locking malloc callbacks to be installed */
2520Sstevel@tonic-gate int RSA_memory_lock(RSA *r);
2530Sstevel@tonic-gate 
2540Sstevel@tonic-gate /* these are the actual SSLeay RSA functions */
2550Sstevel@tonic-gate const RSA_METHOD *RSA_PKCS1_SSLeay(void);
2560Sstevel@tonic-gate 
2570Sstevel@tonic-gate const RSA_METHOD *RSA_null_method(void);
2580Sstevel@tonic-gate 
2590Sstevel@tonic-gate DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey)
2600Sstevel@tonic-gate DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey)
2610Sstevel@tonic-gate 
2620Sstevel@tonic-gate #ifndef OPENSSL_NO_FP_API
2630Sstevel@tonic-gate int	RSA_print_fp(FILE *fp, const RSA *r,int offset);
2640Sstevel@tonic-gate #endif
2650Sstevel@tonic-gate 
2660Sstevel@tonic-gate #ifndef OPENSSL_NO_BIO
2670Sstevel@tonic-gate int	RSA_print(BIO *bp, const RSA *r,int offset);
2680Sstevel@tonic-gate #endif
2690Sstevel@tonic-gate 
2702139Sjp161948 int i2d_RSA_NET(const RSA *a, unsigned char **pp,
2712139Sjp161948 		int (*cb)(char *buf, int len, const char *prompt, int verify),
2722139Sjp161948 		int sgckey);
2732139Sjp161948 RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length,
2742139Sjp161948 		 int (*cb)(char *buf, int len, const char *prompt, int verify),
2752139Sjp161948 		 int sgckey);
2760Sstevel@tonic-gate 
2772139Sjp161948 int i2d_Netscape_RSA(const RSA *a, unsigned char **pp,
2782139Sjp161948 		     int (*cb)(char *buf, int len, const char *prompt,
2792139Sjp161948 			       int verify));
2802139Sjp161948 RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length,
2812139Sjp161948 		      int (*cb)(char *buf, int len, const char *prompt,
2822139Sjp161948 				int verify));
2830Sstevel@tonic-gate 
2840Sstevel@tonic-gate /* The following 2 functions sign and verify a X509_SIG ASN1 object
2850Sstevel@tonic-gate  * inside PKCS#1 padded RSA encryption */
2860Sstevel@tonic-gate int RSA_sign(int type, const unsigned char *m, unsigned int m_length,
2870Sstevel@tonic-gate 	unsigned char *sigret, unsigned int *siglen, RSA *rsa);
2880Sstevel@tonic-gate int RSA_verify(int type, const unsigned char *m, unsigned int m_length,
2890Sstevel@tonic-gate 	unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
2900Sstevel@tonic-gate 
2910Sstevel@tonic-gate /* The following 2 function sign and verify a ASN1_OCTET_STRING
2920Sstevel@tonic-gate  * object inside PKCS#1 padded RSA encryption */
2930Sstevel@tonic-gate int RSA_sign_ASN1_OCTET_STRING(int type,
2940Sstevel@tonic-gate 	const unsigned char *m, unsigned int m_length,
2950Sstevel@tonic-gate 	unsigned char *sigret, unsigned int *siglen, RSA *rsa);
2960Sstevel@tonic-gate int RSA_verify_ASN1_OCTET_STRING(int type,
2970Sstevel@tonic-gate 	const unsigned char *m, unsigned int m_length,
2980Sstevel@tonic-gate 	unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
2990Sstevel@tonic-gate 
3000Sstevel@tonic-gate int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
3010Sstevel@tonic-gate void RSA_blinding_off(RSA *rsa);
3022139Sjp161948 BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);
3030Sstevel@tonic-gate 
3040Sstevel@tonic-gate int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen,
3050Sstevel@tonic-gate 	const unsigned char *f,int fl);
3060Sstevel@tonic-gate int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen,
3070Sstevel@tonic-gate 	const unsigned char *f,int fl,int rsa_len);
3080Sstevel@tonic-gate int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen,
3090Sstevel@tonic-gate 	const unsigned char *f,int fl);
3100Sstevel@tonic-gate int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen,
3110Sstevel@tonic-gate 	const unsigned char *f,int fl,int rsa_len);
3122139Sjp161948 int PKCS1_MGF1(unsigned char *mask, long len,
3132139Sjp161948 	const unsigned char *seed, long seedlen, const EVP_MD *dgst);
3140Sstevel@tonic-gate int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen,
3150Sstevel@tonic-gate 	const unsigned char *f,int fl,
3160Sstevel@tonic-gate 	const unsigned char *p,int pl);
3170Sstevel@tonic-gate int RSA_padding_check_PKCS1_OAEP(unsigned char *to,int tlen,
3180Sstevel@tonic-gate 	const unsigned char *f,int fl,int rsa_len,
3190Sstevel@tonic-gate 	const unsigned char *p,int pl);
3200Sstevel@tonic-gate int RSA_padding_add_SSLv23(unsigned char *to,int tlen,
3210Sstevel@tonic-gate 	const unsigned char *f,int fl);
3220Sstevel@tonic-gate int RSA_padding_check_SSLv23(unsigned char *to,int tlen,
3230Sstevel@tonic-gate 	const unsigned char *f,int fl,int rsa_len);
3240Sstevel@tonic-gate int RSA_padding_add_none(unsigned char *to,int tlen,
3250Sstevel@tonic-gate 	const unsigned char *f,int fl);
3260Sstevel@tonic-gate int RSA_padding_check_none(unsigned char *to,int tlen,
3270Sstevel@tonic-gate 	const unsigned char *f,int fl,int rsa_len);
3282139Sjp161948 int RSA_padding_add_X931(unsigned char *to,int tlen,
3292139Sjp161948 	const unsigned char *f,int fl);
3302139Sjp161948 int RSA_padding_check_X931(unsigned char *to,int tlen,
3312139Sjp161948 	const unsigned char *f,int fl,int rsa_len);
3322139Sjp161948 int RSA_X931_hash_id(int nid);
3332139Sjp161948 
3342139Sjp161948 int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,
3352139Sjp161948 			const EVP_MD *Hash, const unsigned char *EM, int sLen);
3362139Sjp161948 int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,
3372139Sjp161948 			const unsigned char *mHash,
3382139Sjp161948 			const EVP_MD *Hash, int sLen);
3390Sstevel@tonic-gate 
3400Sstevel@tonic-gate int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
3410Sstevel@tonic-gate 	CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
3420Sstevel@tonic-gate int RSA_set_ex_data(RSA *r,int idx,void *arg);
3430Sstevel@tonic-gate void *RSA_get_ex_data(const RSA *r, int idx);
3440Sstevel@tonic-gate 
3450Sstevel@tonic-gate RSA *RSAPublicKey_dup(RSA *rsa);
3460Sstevel@tonic-gate RSA *RSAPrivateKey_dup(RSA *rsa);
3470Sstevel@tonic-gate 
3480Sstevel@tonic-gate /* BEGIN ERROR CODES */
3490Sstevel@tonic-gate /* The following lines are auto generated by the script mkerr.pl. Any changes
3500Sstevel@tonic-gate  * made after this point may be overwritten when the script is next run.
3510Sstevel@tonic-gate  */
3520Sstevel@tonic-gate void ERR_load_RSA_strings(void);
3530Sstevel@tonic-gate 
3540Sstevel@tonic-gate /* Error codes for the RSA functions. */
3550Sstevel@tonic-gate 
3560Sstevel@tonic-gate /* Function codes. */
3570Sstevel@tonic-gate #define RSA_F_MEMORY_LOCK				 100
3582139Sjp161948 #define RSA_F_RSA_BUILTIN_KEYGEN			 129
3590Sstevel@tonic-gate #define RSA_F_RSA_CHECK_KEY				 123
3600Sstevel@tonic-gate #define RSA_F_RSA_EAY_PRIVATE_DECRYPT			 101
3610Sstevel@tonic-gate #define RSA_F_RSA_EAY_PRIVATE_ENCRYPT			 102
3620Sstevel@tonic-gate #define RSA_F_RSA_EAY_PUBLIC_DECRYPT			 103
3630Sstevel@tonic-gate #define RSA_F_RSA_EAY_PUBLIC_ENCRYPT			 104
3640Sstevel@tonic-gate #define RSA_F_RSA_GENERATE_KEY				 105
3652139Sjp161948 #define RSA_F_RSA_MEMORY_LOCK				 130
3660Sstevel@tonic-gate #define RSA_F_RSA_NEW_METHOD				 106
3670Sstevel@tonic-gate #define RSA_F_RSA_NULL					 124
3682139Sjp161948 #define RSA_F_RSA_NULL_MOD_EXP				 131
3692139Sjp161948 #define RSA_F_RSA_NULL_PRIVATE_DECRYPT			 132
3702139Sjp161948 #define RSA_F_RSA_NULL_PRIVATE_ENCRYPT			 133
3712139Sjp161948 #define RSA_F_RSA_NULL_PUBLIC_DECRYPT			 134
3722139Sjp161948 #define RSA_F_RSA_NULL_PUBLIC_ENCRYPT			 135
3730Sstevel@tonic-gate #define RSA_F_RSA_PADDING_ADD_NONE			 107
3740Sstevel@tonic-gate #define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP		 121
3752139Sjp161948 #define RSA_F_RSA_PADDING_ADD_PKCS1_PSS			 125
3760Sstevel@tonic-gate #define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1		 108
3770Sstevel@tonic-gate #define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2		 109
3780Sstevel@tonic-gate #define RSA_F_RSA_PADDING_ADD_SSLV23			 110
3792139Sjp161948 #define RSA_F_RSA_PADDING_ADD_X931			 127
3800Sstevel@tonic-gate #define RSA_F_RSA_PADDING_CHECK_NONE			 111
3810Sstevel@tonic-gate #define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP		 122
3820Sstevel@tonic-gate #define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1		 112
3830Sstevel@tonic-gate #define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2		 113
3840Sstevel@tonic-gate #define RSA_F_RSA_PADDING_CHECK_SSLV23			 114
3852139Sjp161948 #define RSA_F_RSA_PADDING_CHECK_X931			 128
3860Sstevel@tonic-gate #define RSA_F_RSA_PRINT					 115
3870Sstevel@tonic-gate #define RSA_F_RSA_PRINT_FP				 116
3882139Sjp161948 #define RSA_F_RSA_SETUP_BLINDING			 136
3890Sstevel@tonic-gate #define RSA_F_RSA_SIGN					 117
3900Sstevel@tonic-gate #define RSA_F_RSA_SIGN_ASN1_OCTET_STRING		 118
3910Sstevel@tonic-gate #define RSA_F_RSA_VERIFY				 119
3920Sstevel@tonic-gate #define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING		 120
3932139Sjp161948 #define RSA_F_RSA_VERIFY_PKCS1_PSS			 126
3940Sstevel@tonic-gate 
3950Sstevel@tonic-gate /* Reason codes. */
3960Sstevel@tonic-gate #define RSA_R_ALGORITHM_MISMATCH			 100
3970Sstevel@tonic-gate #define RSA_R_BAD_E_VALUE				 101
3980Sstevel@tonic-gate #define RSA_R_BAD_FIXED_HEADER_DECRYPT			 102
3990Sstevel@tonic-gate #define RSA_R_BAD_PAD_BYTE_COUNT			 103
4000Sstevel@tonic-gate #define RSA_R_BAD_SIGNATURE				 104
4010Sstevel@tonic-gate #define RSA_R_BLOCK_TYPE_IS_NOT_01			 106
4020Sstevel@tonic-gate #define RSA_R_BLOCK_TYPE_IS_NOT_02			 107
4030Sstevel@tonic-gate #define RSA_R_DATA_GREATER_THAN_MOD_LEN			 108
4040Sstevel@tonic-gate #define RSA_R_DATA_TOO_LARGE				 109
4050Sstevel@tonic-gate #define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE		 110
4060Sstevel@tonic-gate #define RSA_R_DATA_TOO_LARGE_FOR_MODULUS		 132
4070Sstevel@tonic-gate #define RSA_R_DATA_TOO_SMALL				 111
4080Sstevel@tonic-gate #define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE		 122
4090Sstevel@tonic-gate #define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY		 112
4100Sstevel@tonic-gate #define RSA_R_DMP1_NOT_CONGRUENT_TO_D			 124
4110Sstevel@tonic-gate #define RSA_R_DMQ1_NOT_CONGRUENT_TO_D			 125
4120Sstevel@tonic-gate #define RSA_R_D_E_NOT_CONGRUENT_TO_1			 123
4132139Sjp161948 #define RSA_R_FIRST_OCTET_INVALID			 133
4142139Sjp161948 #define RSA_R_INVALID_HEADER				 137
4150Sstevel@tonic-gate #define RSA_R_INVALID_MESSAGE_LENGTH			 131
4162139Sjp161948 #define RSA_R_INVALID_PADDING				 138
4172139Sjp161948 #define RSA_R_INVALID_TRAILER				 139
4180Sstevel@tonic-gate #define RSA_R_IQMP_NOT_INVERSE_OF_Q			 126
4190Sstevel@tonic-gate #define RSA_R_KEY_SIZE_TOO_SMALL			 120
4202139Sjp161948 #define RSA_R_LAST_OCTET_INVALID			 134
421*2864Sjp161948 #define RSA_R_MODULUS_TOO_LARGE				 105
4222139Sjp161948 #define RSA_R_NO_PUBLIC_EXPONENT			 140
4230Sstevel@tonic-gate #define RSA_R_NULL_BEFORE_BLOCK_MISSING			 113
4240Sstevel@tonic-gate #define RSA_R_N_DOES_NOT_EQUAL_P_Q			 127
4250Sstevel@tonic-gate #define RSA_R_OAEP_DECODING_ERROR			 121
4262139Sjp161948 #define RSA_R_SLEN_RECOVERY_FAILED			 135
4270Sstevel@tonic-gate #define RSA_R_PADDING_CHECK_FAILED			 114
4280Sstevel@tonic-gate #define RSA_R_P_NOT_PRIME				 128
4290Sstevel@tonic-gate #define RSA_R_Q_NOT_PRIME				 129
4300Sstevel@tonic-gate #define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED		 130
4310Sstevel@tonic-gate #define RSA_R_SSLV3_ROLLBACK_ATTACK			 115
4320Sstevel@tonic-gate #define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
4330Sstevel@tonic-gate #define RSA_R_UNKNOWN_ALGORITHM_TYPE			 117
4340Sstevel@tonic-gate #define RSA_R_UNKNOWN_PADDING_TYPE			 118
4350Sstevel@tonic-gate #define RSA_R_WRONG_SIGNATURE_LENGTH			 119
4362139Sjp161948 #define RSA_R_SLEN_CHECK_FAILED				 136
4370Sstevel@tonic-gate 
4380Sstevel@tonic-gate #ifdef  __cplusplus
4390Sstevel@tonic-gate }
4400Sstevel@tonic-gate #endif
4410Sstevel@tonic-gate #endif
442