xref: /dflybsd-src/crypto/libressl/include/openssl/rsa.h (revision 961e30ea7dc61d1112b778ea4981eac68129fb86)
1*de0e0e4dSAntonio Huete Jimenez /* $OpenBSD: rsa.h,v 1.58 2022/07/12 14:42:50 kn Exp $ */
2f5b1c8a1SJohn Marino /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3f5b1c8a1SJohn Marino  * All rights reserved.
4f5b1c8a1SJohn Marino  *
5f5b1c8a1SJohn Marino  * This package is an SSL implementation written
6f5b1c8a1SJohn Marino  * by Eric Young (eay@cryptsoft.com).
7f5b1c8a1SJohn Marino  * The implementation was written so as to conform with Netscapes SSL.
8f5b1c8a1SJohn Marino  *
9f5b1c8a1SJohn Marino  * This library is free for commercial and non-commercial use as long as
10f5b1c8a1SJohn Marino  * the following conditions are aheared to.  The following conditions
11f5b1c8a1SJohn Marino  * apply to all code found in this distribution, be it the RC4, RSA,
12f5b1c8a1SJohn Marino  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13f5b1c8a1SJohn Marino  * included with this distribution is covered by the same copyright terms
14f5b1c8a1SJohn Marino  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15f5b1c8a1SJohn Marino  *
16f5b1c8a1SJohn Marino  * Copyright remains Eric Young's, and as such any Copyright notices in
17f5b1c8a1SJohn Marino  * the code are not to be removed.
18f5b1c8a1SJohn Marino  * If this package is used in a product, Eric Young should be given attribution
19f5b1c8a1SJohn Marino  * as the author of the parts of the library used.
20f5b1c8a1SJohn Marino  * This can be in the form of a textual message at program startup or
21f5b1c8a1SJohn Marino  * in documentation (online or textual) provided with the package.
22f5b1c8a1SJohn Marino  *
23f5b1c8a1SJohn Marino  * Redistribution and use in source and binary forms, with or without
24f5b1c8a1SJohn Marino  * modification, are permitted provided that the following conditions
25f5b1c8a1SJohn Marino  * are met:
26f5b1c8a1SJohn Marino  * 1. Redistributions of source code must retain the copyright
27f5b1c8a1SJohn Marino  *    notice, this list of conditions and the following disclaimer.
28f5b1c8a1SJohn Marino  * 2. Redistributions in binary form must reproduce the above copyright
29f5b1c8a1SJohn Marino  *    notice, this list of conditions and the following disclaimer in the
30f5b1c8a1SJohn Marino  *    documentation and/or other materials provided with the distribution.
31f5b1c8a1SJohn Marino  * 3. All advertising materials mentioning features or use of this software
32f5b1c8a1SJohn Marino  *    must display the following acknowledgement:
33f5b1c8a1SJohn Marino  *    "This product includes cryptographic software written by
34f5b1c8a1SJohn Marino  *     Eric Young (eay@cryptsoft.com)"
35f5b1c8a1SJohn Marino  *    The word 'cryptographic' can be left out if the rouines from the library
36f5b1c8a1SJohn Marino  *    being used are not cryptographic related :-).
37f5b1c8a1SJohn Marino  * 4. If you include any Windows specific code (or a derivative thereof) from
38f5b1c8a1SJohn Marino  *    the apps directory (application code) you must include an acknowledgement:
39f5b1c8a1SJohn Marino  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40f5b1c8a1SJohn Marino  *
41f5b1c8a1SJohn Marino  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42f5b1c8a1SJohn Marino  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43f5b1c8a1SJohn Marino  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44f5b1c8a1SJohn Marino  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45f5b1c8a1SJohn Marino  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46f5b1c8a1SJohn Marino  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47f5b1c8a1SJohn Marino  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48f5b1c8a1SJohn Marino  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49f5b1c8a1SJohn Marino  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50f5b1c8a1SJohn Marino  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51f5b1c8a1SJohn Marino  * SUCH DAMAGE.
52f5b1c8a1SJohn Marino  *
53f5b1c8a1SJohn Marino  * The licence and distribution terms for any publically available version or
54f5b1c8a1SJohn Marino  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55f5b1c8a1SJohn Marino  * copied and put under another distribution licence
56f5b1c8a1SJohn Marino  * [including the GNU Public Licence.]
57f5b1c8a1SJohn Marino  */
58f5b1c8a1SJohn Marino 
59f5b1c8a1SJohn Marino #ifndef HEADER_RSA_H
60f5b1c8a1SJohn Marino #define HEADER_RSA_H
61f5b1c8a1SJohn Marino 
62f5b1c8a1SJohn Marino #include <openssl/opensslconf.h>
63f5b1c8a1SJohn Marino 
64f5b1c8a1SJohn Marino #include <openssl/asn1.h>
65f5b1c8a1SJohn Marino 
66f5b1c8a1SJohn Marino #ifndef OPENSSL_NO_BIO
67f5b1c8a1SJohn Marino #include <openssl/bio.h>
68f5b1c8a1SJohn Marino #endif
69f5b1c8a1SJohn Marino #include <openssl/crypto.h>
70f5b1c8a1SJohn Marino #include <openssl/ossl_typ.h>
71f5b1c8a1SJohn Marino #ifndef OPENSSL_NO_DEPRECATED
72f5b1c8a1SJohn Marino #include <openssl/bn.h>
73f5b1c8a1SJohn Marino #endif
74f5b1c8a1SJohn Marino 
75f5b1c8a1SJohn Marino #ifdef OPENSSL_NO_RSA
76f5b1c8a1SJohn Marino #error RSA is disabled.
77f5b1c8a1SJohn Marino #endif
78f5b1c8a1SJohn Marino 
79f5b1c8a1SJohn Marino #ifdef  __cplusplus
80f5b1c8a1SJohn Marino extern "C" {
81f5b1c8a1SJohn Marino #endif
82f5b1c8a1SJohn Marino 
83*de0e0e4dSAntonio Huete Jimenez struct rsa_pss_params_st {
84cca6fc52SDaniel Fojt 	X509_ALGOR *hashAlgorithm;
85cca6fc52SDaniel Fojt 	X509_ALGOR *maskGenAlgorithm;
86cca6fc52SDaniel Fojt 	ASN1_INTEGER *saltLength;
87cca6fc52SDaniel Fojt 	ASN1_INTEGER *trailerField;
88cca6fc52SDaniel Fojt 
89cca6fc52SDaniel Fojt 	/* Hash algorithm decoded from maskGenAlgorithm. */
90cca6fc52SDaniel Fojt 	X509_ALGOR *maskHash;
91*de0e0e4dSAntonio Huete Jimenez } /* RSA_PSS_PARAMS */;
92cca6fc52SDaniel Fojt 
93cca6fc52SDaniel Fojt typedef struct rsa_oaep_params_st {
94cca6fc52SDaniel Fojt 	X509_ALGOR *hashFunc;
95cca6fc52SDaniel Fojt 	X509_ALGOR *maskGenFunc;
96cca6fc52SDaniel Fojt 	X509_ALGOR *pSourceFunc;
97cca6fc52SDaniel Fojt 
98cca6fc52SDaniel Fojt 	/* Hash algorithm decoded from maskGenFunc. */
99cca6fc52SDaniel Fojt 	X509_ALGOR *maskHash;
100cca6fc52SDaniel Fojt } RSA_OAEP_PARAMS;
101cca6fc52SDaniel Fojt 
102f5b1c8a1SJohn Marino #ifndef OPENSSL_RSA_MAX_MODULUS_BITS
103f5b1c8a1SJohn Marino # define OPENSSL_RSA_MAX_MODULUS_BITS	16384
104f5b1c8a1SJohn Marino #endif
105f5b1c8a1SJohn Marino 
106f5b1c8a1SJohn Marino #ifndef OPENSSL_RSA_SMALL_MODULUS_BITS
107f5b1c8a1SJohn Marino # define OPENSSL_RSA_SMALL_MODULUS_BITS	3072
108f5b1c8a1SJohn Marino #endif
109f5b1c8a1SJohn Marino #ifndef OPENSSL_RSA_MAX_PUBEXP_BITS
110f5b1c8a1SJohn Marino # define OPENSSL_RSA_MAX_PUBEXP_BITS	64 /* exponent limit enforced for "large" modulus only */
111f5b1c8a1SJohn Marino #endif
112f5b1c8a1SJohn Marino 
113f5b1c8a1SJohn Marino #define RSA_3	0x3L
114f5b1c8a1SJohn Marino #define RSA_F4	0x10001L
115f5b1c8a1SJohn Marino 
116f5b1c8a1SJohn Marino /* Don't check pub/private match. */
117f5b1c8a1SJohn Marino #define RSA_METHOD_FLAG_NO_CHECK	0x0001
118f5b1c8a1SJohn Marino 
119f5b1c8a1SJohn Marino #define RSA_FLAG_CACHE_PUBLIC		0x0002
120f5b1c8a1SJohn Marino #define RSA_FLAG_CACHE_PRIVATE		0x0004
121f5b1c8a1SJohn Marino #define RSA_FLAG_BLINDING		0x0008
122f5b1c8a1SJohn Marino #define RSA_FLAG_THREAD_SAFE		0x0010
123f5b1c8a1SJohn Marino 
124f5b1c8a1SJohn Marino /*
125f5b1c8a1SJohn Marino  * This flag means the private key operations will be handled by rsa_mod_exp
126f5b1c8a1SJohn Marino  * and that they do not depend on the private key components being present:
127f5b1c8a1SJohn Marino  * for example a key stored in external hardware. Without this flag bn_mod_exp
128f5b1c8a1SJohn Marino  * gets called when private key components are absent.
129f5b1c8a1SJohn Marino  */
130f5b1c8a1SJohn Marino #define RSA_FLAG_EXT_PKEY		0x0020
131f5b1c8a1SJohn Marino 
132f5b1c8a1SJohn Marino /*
133f5b1c8a1SJohn Marino  * This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify functions.
134f5b1c8a1SJohn Marino  */
135f5b1c8a1SJohn Marino #define RSA_FLAG_SIGN_VER		0x0040
136f5b1c8a1SJohn Marino 
137f5b1c8a1SJohn Marino /*
138f5b1c8a1SJohn Marino  * The built-in RSA implementation uses blinding by default, but other engines
139f5b1c8a1SJohn Marino  * might not need it.
140f5b1c8a1SJohn Marino  */
141f5b1c8a1SJohn Marino #define RSA_FLAG_NO_BLINDING		0x0080
142f5b1c8a1SJohn Marino 
143cca6fc52SDaniel Fojt /* Salt length matches digest */
144cca6fc52SDaniel Fojt #define RSA_PSS_SALTLEN_DIGEST		-1
145cca6fc52SDaniel Fojt /* Verify only: auto detect salt length */
146cca6fc52SDaniel Fojt #define RSA_PSS_SALTLEN_AUTO		-2
147cca6fc52SDaniel Fojt /* Set salt length to maximum possible */
148cca6fc52SDaniel Fojt #define RSA_PSS_SALTLEN_MAX		-3
149cca6fc52SDaniel Fojt 
150f5b1c8a1SJohn Marino #define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \
151cca6fc52SDaniel Fojt 	RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_RSA_PADDING, pad, NULL)
152f5b1c8a1SJohn Marino 
153f5b1c8a1SJohn Marino #define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \
154cca6fc52SDaniel Fojt 	RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)
155f5b1c8a1SJohn Marino 
156f5b1c8a1SJohn Marino #define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \
157cca6fc52SDaniel Fojt 	RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \
158cca6fc52SDaniel Fojt 	    EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, NULL)
159cca6fc52SDaniel Fojt 
160cca6fc52SDaniel Fojt #define EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(ctx, len) \
161cca6fc52SDaniel Fojt 	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, EVP_PKEY_OP_KEYGEN, \
162cca6fc52SDaniel Fojt 	    EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, NULL)
163f5b1c8a1SJohn Marino 
164f5b1c8a1SJohn Marino #define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \
165cca6fc52SDaniel Fojt 	RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \
166cca6fc52SDaniel Fojt 	    EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, 0, plen)
167f5b1c8a1SJohn Marino 
168f5b1c8a1SJohn Marino #define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \
169cca6fc52SDaniel Fojt 	RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \
170f5b1c8a1SJohn Marino 	    EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL)
171f5b1c8a1SJohn Marino 
172f5b1c8a1SJohn Marino #define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \
173cca6fc52SDaniel Fojt 	RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_KEYGEN, \
174f5b1c8a1SJohn Marino 	    EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp)
175f5b1c8a1SJohn Marino 
176f5b1c8a1SJohn Marino #define EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md) \
177cca6fc52SDaniel Fojt 	RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \
178cca6fc52SDaniel Fojt 	    EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)(md))
179cca6fc52SDaniel Fojt 
180cca6fc52SDaniel Fojt #define EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(ctx, md) \
181cca6fc52SDaniel Fojt 	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, EVP_PKEY_OP_KEYGEN, \
182cca6fc52SDaniel Fojt 	    EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)(md))
183cca6fc52SDaniel Fojt 
184cca6fc52SDaniel Fojt #define EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md) \
185cca6fc52SDaniel Fojt 	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \
186cca6fc52SDaniel Fojt 	    EVP_PKEY_CTRL_RSA_OAEP_MD, 0, (void *)(md))
187f5b1c8a1SJohn Marino 
188f5b1c8a1SJohn Marino #define EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd) \
189cca6fc52SDaniel Fojt 	RSA_pkey_ctx_ctrl(ctx, EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \
190cca6fc52SDaniel Fojt 	    EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)(pmd))
191cca6fc52SDaniel Fojt 
192cca6fc52SDaniel Fojt #define EVP_PKEY_CTX_get_rsa_oaep_md(ctx, pmd) \
193cca6fc52SDaniel Fojt 	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \
194cca6fc52SDaniel Fojt 	    EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, (void *)(pmd))
195cca6fc52SDaniel Fojt 
196cca6fc52SDaniel Fojt #define EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, l, llen) \
197cca6fc52SDaniel Fojt 	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \
198cca6fc52SDaniel Fojt 	    EVP_PKEY_CTRL_RSA_OAEP_LABEL, llen, (void *)(l))
199cca6fc52SDaniel Fojt 
200cca6fc52SDaniel Fojt #define EVP_PKEY_CTX_get0_rsa_oaep_label(ctx, l) \
201cca6fc52SDaniel Fojt 	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \
202cca6fc52SDaniel Fojt 	    EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, (void *)(l))
203cca6fc52SDaniel Fojt 
204cca6fc52SDaniel Fojt #define EVP_PKEY_CTX_set_rsa_pss_keygen_md(ctx, md) \
205cca6fc52SDaniel Fojt 	EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA_PSS, \
206cca6fc52SDaniel Fojt 	    EVP_PKEY_OP_KEYGEN, EVP_PKEY_CTRL_MD, 0, (void *)(md))
207f5b1c8a1SJohn Marino 
208f5b1c8a1SJohn Marino #define EVP_PKEY_CTRL_RSA_PADDING		(EVP_PKEY_ALG_CTRL + 1)
209f5b1c8a1SJohn Marino #define EVP_PKEY_CTRL_RSA_PSS_SALTLEN		(EVP_PKEY_ALG_CTRL + 2)
210f5b1c8a1SJohn Marino 
211f5b1c8a1SJohn Marino #define EVP_PKEY_CTRL_RSA_KEYGEN_BITS		(EVP_PKEY_ALG_CTRL + 3)
212f5b1c8a1SJohn Marino #define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP		(EVP_PKEY_ALG_CTRL + 4)
213f5b1c8a1SJohn Marino #define EVP_PKEY_CTRL_RSA_MGF1_MD		(EVP_PKEY_ALG_CTRL + 5)
214f5b1c8a1SJohn Marino 
215f5b1c8a1SJohn Marino #define EVP_PKEY_CTRL_GET_RSA_PADDING		(EVP_PKEY_ALG_CTRL + 6)
216f5b1c8a1SJohn Marino #define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN	(EVP_PKEY_ALG_CTRL + 7)
217f5b1c8a1SJohn Marino #define EVP_PKEY_CTRL_GET_RSA_MGF1_MD		(EVP_PKEY_ALG_CTRL + 8)
218f5b1c8a1SJohn Marino 
219cca6fc52SDaniel Fojt #define EVP_PKEY_CTRL_RSA_OAEP_MD		(EVP_PKEY_ALG_CTRL + 9)
220cca6fc52SDaniel Fojt #define EVP_PKEY_CTRL_RSA_OAEP_LABEL		(EVP_PKEY_ALG_CTRL + 10)
221cca6fc52SDaniel Fojt 
222cca6fc52SDaniel Fojt #define EVP_PKEY_CTRL_GET_RSA_OAEP_MD		(EVP_PKEY_ALG_CTRL + 11)
223cca6fc52SDaniel Fojt #define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL	(EVP_PKEY_ALG_CTRL + 12)
224cca6fc52SDaniel Fojt 
225f5b1c8a1SJohn Marino #define RSA_PKCS1_PADDING	1
226f5b1c8a1SJohn Marino #define RSA_SSLV23_PADDING	2
227f5b1c8a1SJohn Marino #define RSA_NO_PADDING		3
228f5b1c8a1SJohn Marino #define RSA_PKCS1_OAEP_PADDING	4
229f5b1c8a1SJohn Marino #define RSA_X931_PADDING	5
230f5b1c8a1SJohn Marino /* EVP_PKEY_ only */
231f5b1c8a1SJohn Marino #define RSA_PKCS1_PSS_PADDING	6
232f5b1c8a1SJohn Marino 
233f5b1c8a1SJohn Marino #define RSA_PKCS1_PADDING_SIZE	11
234f5b1c8a1SJohn Marino 
235f5b1c8a1SJohn Marino #define RSA_set_app_data(s,arg)         RSA_set_ex_data(s,0,arg)
236f5b1c8a1SJohn Marino #define RSA_get_app_data(s)             RSA_get_ex_data(s,0)
237f5b1c8a1SJohn Marino 
238f5b1c8a1SJohn Marino RSA *RSA_new(void);
239f5b1c8a1SJohn Marino RSA *RSA_new_method(ENGINE *engine);
24072c33676SMaxim Ag int RSA_bits(const RSA *rsa);
241f5b1c8a1SJohn Marino int RSA_size(const RSA *rsa);
242f5b1c8a1SJohn Marino 
243f5b1c8a1SJohn Marino /* Deprecated version */
244f5b1c8a1SJohn Marino #ifndef OPENSSL_NO_DEPRECATED
245f5b1c8a1SJohn Marino RSA *RSA_generate_key(int bits, unsigned long e,
246f5b1c8a1SJohn Marino     void (*callback)(int, int, void *), void *cb_arg);
247f5b1c8a1SJohn Marino #endif /* !defined(OPENSSL_NO_DEPRECATED) */
248f5b1c8a1SJohn Marino 
249f5b1c8a1SJohn Marino /* New version */
250f5b1c8a1SJohn Marino int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
251f5b1c8a1SJohn Marino 
252f5b1c8a1SJohn Marino int RSA_check_key(const RSA *);
253f5b1c8a1SJohn Marino /* next 4 return -1 on error */
254f5b1c8a1SJohn Marino int RSA_public_encrypt(int flen, const unsigned char *from,
255f5b1c8a1SJohn Marino     unsigned char *to, RSA *rsa, int padding);
256f5b1c8a1SJohn Marino int RSA_private_encrypt(int flen, const unsigned char *from,
257f5b1c8a1SJohn Marino     unsigned char *to, RSA *rsa, int padding);
258f5b1c8a1SJohn Marino int RSA_public_decrypt(int flen, const unsigned char *from,
259f5b1c8a1SJohn Marino     unsigned char *to, RSA *rsa, int padding);
260f5b1c8a1SJohn Marino int RSA_private_decrypt(int flen, const unsigned char *from,
261f5b1c8a1SJohn Marino     unsigned char *to, RSA *rsa, int padding);
262f5b1c8a1SJohn Marino void RSA_free(RSA *r);
263f5b1c8a1SJohn Marino /* "up" the RSA object's reference count */
264f5b1c8a1SJohn Marino int RSA_up_ref(RSA *r);
265f5b1c8a1SJohn Marino 
266f5b1c8a1SJohn Marino int RSA_flags(const RSA *r);
267f5b1c8a1SJohn Marino 
268f5b1c8a1SJohn Marino void RSA_set_default_method(const RSA_METHOD *meth);
269f5b1c8a1SJohn Marino const RSA_METHOD *RSA_get_default_method(void);
270f5b1c8a1SJohn Marino const RSA_METHOD *RSA_get_method(const RSA *rsa);
271f5b1c8a1SJohn Marino int RSA_set_method(RSA *rsa, const RSA_METHOD *meth);
272f5b1c8a1SJohn Marino 
273cca6fc52SDaniel Fojt const RSA_METHOD *RSA_PKCS1_OpenSSL(void);
274f5b1c8a1SJohn Marino const RSA_METHOD *RSA_PKCS1_SSLeay(void);
275f5b1c8a1SJohn Marino 
276f5b1c8a1SJohn Marino const RSA_METHOD *RSA_null_method(void);
277f5b1c8a1SJohn Marino 
278cca6fc52SDaniel Fojt int RSA_pkey_ctx_ctrl(EVP_PKEY_CTX *ctx, int optype, int cmd, int p1, void *p2);
279cca6fc52SDaniel Fojt 
28072c33676SMaxim Ag RSA *d2i_RSAPublicKey(RSA **a, const unsigned char **in, long len);
28172c33676SMaxim Ag int i2d_RSAPublicKey(const RSA *a, unsigned char **out);
28272c33676SMaxim Ag extern const ASN1_ITEM RSAPublicKey_it;
28372c33676SMaxim Ag RSA *d2i_RSAPrivateKey(RSA **a, const unsigned char **in, long len);
28472c33676SMaxim Ag int i2d_RSAPrivateKey(const RSA *a, unsigned char **out);
28572c33676SMaxim Ag extern const ASN1_ITEM RSAPrivateKey_it;
286f5b1c8a1SJohn Marino 
28772c33676SMaxim Ag RSA_PSS_PARAMS *RSA_PSS_PARAMS_new(void);
28872c33676SMaxim Ag void RSA_PSS_PARAMS_free(RSA_PSS_PARAMS *a);
28972c33676SMaxim Ag RSA_PSS_PARAMS *d2i_RSA_PSS_PARAMS(RSA_PSS_PARAMS **a, const unsigned char **in, long len);
29072c33676SMaxim Ag int i2d_RSA_PSS_PARAMS(RSA_PSS_PARAMS *a, unsigned char **out);
29172c33676SMaxim Ag extern const ASN1_ITEM RSA_PSS_PARAMS_it;
292f5b1c8a1SJohn Marino 
293cca6fc52SDaniel Fojt RSA_OAEP_PARAMS *RSA_OAEP_PARAMS_new(void);
294cca6fc52SDaniel Fojt void RSA_OAEP_PARAMS_free(RSA_OAEP_PARAMS *a);
295cca6fc52SDaniel Fojt RSA_OAEP_PARAMS *d2i_RSA_OAEP_PARAMS(RSA_OAEP_PARAMS **a, const unsigned char **in, long len);
296cca6fc52SDaniel Fojt int i2d_RSA_OAEP_PARAMS(RSA_OAEP_PARAMS *a, unsigned char **out);
297cca6fc52SDaniel Fojt extern const ASN1_ITEM RSA_OAEP_PARAMS_it;
298cca6fc52SDaniel Fojt 
299f5b1c8a1SJohn Marino int RSA_print_fp(FILE *fp, const RSA *r, int offset);
300f5b1c8a1SJohn Marino 
301f5b1c8a1SJohn Marino #ifndef OPENSSL_NO_BIO
302f5b1c8a1SJohn Marino int RSA_print(BIO *bp, const RSA *r, int offset);
303f5b1c8a1SJohn Marino #endif
304f5b1c8a1SJohn Marino 
305f5b1c8a1SJohn Marino /* The following 2 functions sign and verify a X509_SIG ASN1 object
306f5b1c8a1SJohn Marino  * inside PKCS#1 padded RSA encryption */
307f5b1c8a1SJohn Marino int RSA_sign(int type, const unsigned char *m, unsigned int m_length,
308f5b1c8a1SJohn Marino     unsigned char *sigret, unsigned int *siglen, RSA *rsa);
309f5b1c8a1SJohn Marino int RSA_verify(int type, const unsigned char *m, unsigned int m_length,
310f5b1c8a1SJohn Marino     const unsigned char *sigbuf, unsigned int siglen, RSA *rsa);
311f5b1c8a1SJohn Marino 
312f5b1c8a1SJohn Marino /* The following 2 function sign and verify a ASN1_OCTET_STRING
313f5b1c8a1SJohn Marino  * object inside PKCS#1 padded RSA encryption */
314f5b1c8a1SJohn Marino int RSA_sign_ASN1_OCTET_STRING(int type, const unsigned char *m,
315f5b1c8a1SJohn Marino     unsigned int m_length, unsigned char *sigret, unsigned int *siglen,
316f5b1c8a1SJohn Marino     RSA *rsa);
317f5b1c8a1SJohn Marino int RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m,
318f5b1c8a1SJohn Marino     unsigned int m_length, unsigned char *sigbuf, unsigned int siglen,
319f5b1c8a1SJohn Marino     RSA *rsa);
320f5b1c8a1SJohn Marino 
321f5b1c8a1SJohn Marino int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
322f5b1c8a1SJohn Marino void RSA_blinding_off(RSA *rsa);
323f5b1c8a1SJohn Marino BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);
324f5b1c8a1SJohn Marino 
325f5b1c8a1SJohn Marino int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen,
326f5b1c8a1SJohn Marino     const unsigned char *f, int fl);
327f5b1c8a1SJohn Marino int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen,
328f5b1c8a1SJohn Marino     const unsigned char *f, int fl, int rsa_len);
329f5b1c8a1SJohn Marino int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen,
330f5b1c8a1SJohn Marino     const unsigned char *f, int fl);
331f5b1c8a1SJohn Marino int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen,
332f5b1c8a1SJohn Marino     const unsigned char *f, int fl, int rsa_len);
333f5b1c8a1SJohn Marino int PKCS1_MGF1(unsigned char *mask, long len,
334f5b1c8a1SJohn Marino     const unsigned char *seed, long seedlen, const EVP_MD *dgst);
335f5b1c8a1SJohn Marino int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen,
336f5b1c8a1SJohn Marino     const unsigned char *f, int fl,
337f5b1c8a1SJohn Marino     const unsigned char *p, int pl);
338f5b1c8a1SJohn Marino int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen,
339f5b1c8a1SJohn Marino     const unsigned char *f, int fl, int rsa_len,
340f5b1c8a1SJohn Marino     const unsigned char *p, int pl);
341cca6fc52SDaniel Fojt int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
342cca6fc52SDaniel Fojt     const unsigned char *from, int flen, const unsigned char *param, int plen,
343cca6fc52SDaniel Fojt     const EVP_MD *md, const EVP_MD *mgf1md);
344cca6fc52SDaniel Fojt int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,
345cca6fc52SDaniel Fojt     const unsigned char *from, int flen, int num, const unsigned char *param,
346cca6fc52SDaniel Fojt     int plen, const EVP_MD *md, const EVP_MD *mgf1md);
347f5b1c8a1SJohn Marino int RSA_padding_add_none(unsigned char *to, int tlen,
348f5b1c8a1SJohn Marino     const unsigned char *f, int fl);
349f5b1c8a1SJohn Marino int RSA_padding_check_none(unsigned char *to, int tlen,
350f5b1c8a1SJohn Marino     const unsigned char *f, int fl, int rsa_len);
351f5b1c8a1SJohn Marino int RSA_padding_add_X931(unsigned char *to, int tlen,
352f5b1c8a1SJohn Marino     const unsigned char *f, int fl);
353f5b1c8a1SJohn Marino int RSA_padding_check_X931(unsigned char *to, int tlen,
354f5b1c8a1SJohn Marino     const unsigned char *f, int fl, int rsa_len);
355f5b1c8a1SJohn Marino int RSA_X931_hash_id(int nid);
356f5b1c8a1SJohn Marino 
357f5b1c8a1SJohn Marino int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash,
358f5b1c8a1SJohn Marino     const EVP_MD *Hash, const unsigned char *EM, int sLen);
359f5b1c8a1SJohn Marino int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM,
360f5b1c8a1SJohn Marino     const unsigned char *mHash, const EVP_MD *Hash, int sLen);
361f5b1c8a1SJohn Marino 
362f5b1c8a1SJohn Marino int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash,
363f5b1c8a1SJohn Marino     const EVP_MD *Hash, const EVP_MD *mgf1Hash, const unsigned char *EM,
364f5b1c8a1SJohn Marino     int sLen);
365f5b1c8a1SJohn Marino 
366f5b1c8a1SJohn Marino int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM,
367f5b1c8a1SJohn Marino     const unsigned char *mHash, const EVP_MD *Hash, const EVP_MD *mgf1Hash,
368f5b1c8a1SJohn Marino     int sLen);
369f5b1c8a1SJohn Marino 
370f5b1c8a1SJohn Marino int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
371f5b1c8a1SJohn Marino     CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);
372f5b1c8a1SJohn Marino int RSA_set_ex_data(RSA *r, int idx, void *arg);
373f5b1c8a1SJohn Marino void *RSA_get_ex_data(const RSA *r, int idx);
374f5b1c8a1SJohn Marino 
375*de0e0e4dSAntonio Huete Jimenez int RSA_security_bits(const RSA *rsa);
376*de0e0e4dSAntonio Huete Jimenez 
37772c33676SMaxim Ag void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e,
37872c33676SMaxim Ag     const BIGNUM **d);
37972c33676SMaxim Ag int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d);
38072c33676SMaxim Ag void RSA_get0_crt_params(const RSA *r, const BIGNUM **dmp1, const BIGNUM **dmq1,
38172c33676SMaxim Ag     const BIGNUM **iqmp);
38272c33676SMaxim Ag int RSA_set0_crt_params(RSA *r, BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp);
38372c33676SMaxim Ag void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
38472c33676SMaxim Ag int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q);
385*de0e0e4dSAntonio Huete Jimenez const BIGNUM *RSA_get0_n(const RSA *r);
386*de0e0e4dSAntonio Huete Jimenez const BIGNUM *RSA_get0_e(const RSA *r);
387*de0e0e4dSAntonio Huete Jimenez const BIGNUM *RSA_get0_d(const RSA *r);
388*de0e0e4dSAntonio Huete Jimenez const BIGNUM *RSA_get0_p(const RSA *r);
389*de0e0e4dSAntonio Huete Jimenez const BIGNUM *RSA_get0_q(const RSA *r);
390*de0e0e4dSAntonio Huete Jimenez const BIGNUM *RSA_get0_dmp1(const RSA *r);
391*de0e0e4dSAntonio Huete Jimenez const BIGNUM *RSA_get0_dmq1(const RSA *r);
392*de0e0e4dSAntonio Huete Jimenez const BIGNUM *RSA_get0_iqmp(const RSA *r);
393*de0e0e4dSAntonio Huete Jimenez const RSA_PSS_PARAMS *RSA_get0_pss_params(const RSA *r);
39472c33676SMaxim Ag void RSA_clear_flags(RSA *r, int flags);
39572c33676SMaxim Ag int RSA_test_flags(const RSA *r, int flags);
39672c33676SMaxim Ag void RSA_set_flags(RSA *r, int flags);
39772c33676SMaxim Ag 
398f5b1c8a1SJohn Marino RSA *RSAPublicKey_dup(RSA *rsa);
399f5b1c8a1SJohn Marino RSA *RSAPrivateKey_dup(RSA *rsa);
400f5b1c8a1SJohn Marino 
401f5b1c8a1SJohn Marino /* If this flag is set the RSA method is FIPS compliant and can be used
402f5b1c8a1SJohn Marino  * in FIPS mode. This is set in the validated module method. If an
403f5b1c8a1SJohn Marino  * application sets this flag in its own methods it is its responsibility
404f5b1c8a1SJohn Marino  * to ensure the result is compliant.
405f5b1c8a1SJohn Marino  */
406f5b1c8a1SJohn Marino 
407f5b1c8a1SJohn Marino #define RSA_FLAG_FIPS_METHOD			0x0400
408f5b1c8a1SJohn Marino 
409f5b1c8a1SJohn Marino /* If this flag is set the operations normally disabled in FIPS mode are
410f5b1c8a1SJohn Marino  * permitted it is then the applications responsibility to ensure that the
411f5b1c8a1SJohn Marino  * usage is compliant.
412f5b1c8a1SJohn Marino  */
413f5b1c8a1SJohn Marino 
414f5b1c8a1SJohn Marino #define RSA_FLAG_NON_FIPS_ALLOW			0x0400
415f5b1c8a1SJohn Marino /* Application has decided PRNG is good enough to generate a key: don't
416f5b1c8a1SJohn Marino  * check.
417f5b1c8a1SJohn Marino  */
418f5b1c8a1SJohn Marino #define RSA_FLAG_CHECKED			0x0800
419f5b1c8a1SJohn Marino 
42072c33676SMaxim Ag RSA_METHOD *RSA_meth_new(const char *name, int flags);
42172c33676SMaxim Ag void RSA_meth_free(RSA_METHOD *meth);
42272c33676SMaxim Ag RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);
42372c33676SMaxim Ag int RSA_meth_set1_name(RSA_METHOD *meth, const char *name);
42472c33676SMaxim Ag int RSA_meth_set_priv_enc(RSA_METHOD *meth, int (*priv_enc)(int flen,
42572c33676SMaxim Ag     const unsigned char *from, unsigned char *to, RSA *rsa, int padding));
42672c33676SMaxim Ag int RSA_meth_set_priv_dec(RSA_METHOD *meth, int (*priv_dec)(int flen,
42772c33676SMaxim Ag     const unsigned char *from, unsigned char *to, RSA *rsa, int padding));
42872c33676SMaxim Ag int (*RSA_meth_get_finish(const RSA_METHOD *meth))(RSA *rsa);
42972c33676SMaxim Ag int RSA_meth_set_finish(RSA_METHOD *meth, int (*finish)(RSA *rsa));
430cca6fc52SDaniel Fojt int RSA_meth_set_pub_enc(RSA_METHOD *meth, int (*pub_enc)(int flen,
431cca6fc52SDaniel Fojt     const unsigned char *from, unsigned char *to, RSA *rsa, int padding));
432cca6fc52SDaniel Fojt int RSA_meth_set_pub_dec(RSA_METHOD *meth, int (*pub_dec)(int flen,
433cca6fc52SDaniel Fojt     const unsigned char *from, unsigned char *to, RSA *rsa, int padding));
434cca6fc52SDaniel Fojt int RSA_meth_set_mod_exp(RSA_METHOD *meth, int (*mod_exp)(BIGNUM *r0,
435cca6fc52SDaniel Fojt     const BIGNUM *i, RSA *rsa, BN_CTX *ctx));
436cca6fc52SDaniel Fojt int RSA_meth_set_bn_mod_exp(RSA_METHOD *meth, int (*bn_mod_exp)(BIGNUM *r,
437cca6fc52SDaniel Fojt     const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
438cca6fc52SDaniel Fojt     BN_MONT_CTX *m_ctx));
439cca6fc52SDaniel Fojt int RSA_meth_set_init(RSA_METHOD *meth, int (*init)(RSA *rsa));
440cca6fc52SDaniel Fojt int RSA_meth_set_keygen(RSA_METHOD *meth, int (*keygen)(RSA *rsa, int bits,
441cca6fc52SDaniel Fojt     BIGNUM *e, BN_GENCB *cb));
442cca6fc52SDaniel Fojt int RSA_meth_set_flags(RSA_METHOD *meth, int flags);
443cca6fc52SDaniel Fojt int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data);
444cca6fc52SDaniel Fojt const char *RSA_meth_get0_name(const RSA_METHOD *);
445cca6fc52SDaniel Fojt int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth))(int flen,
446cca6fc52SDaniel Fojt     const unsigned char *from, unsigned char *to, RSA *rsa, int padding);
447cca6fc52SDaniel Fojt int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth))(int flen,
448cca6fc52SDaniel Fojt     const unsigned char *from, unsigned char *to, RSA *rsa, int padding);
449cca6fc52SDaniel Fojt int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth))(int flen,
450cca6fc52SDaniel Fojt     const unsigned char *from, unsigned char *to, RSA *rsa, int padding);
451cca6fc52SDaniel Fojt int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth))(int flen,
452cca6fc52SDaniel Fojt     const unsigned char *from, unsigned char *to, RSA *rsa, int padding);
453cca6fc52SDaniel Fojt int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))(BIGNUM *r0, const BIGNUM *i,
454cca6fc52SDaniel Fojt     RSA *rsa, BN_CTX *ctx);
455cca6fc52SDaniel Fojt int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))(BIGNUM *r,
456cca6fc52SDaniel Fojt     const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx,
457cca6fc52SDaniel Fojt     BN_MONT_CTX *m_ctx);
458cca6fc52SDaniel Fojt int (*RSA_meth_get_init(const RSA_METHOD *meth))(RSA *rsa);
459cca6fc52SDaniel Fojt int (*RSA_meth_get_keygen(const RSA_METHOD *meth))(RSA *rsa, int bits, BIGNUM *e,
460cca6fc52SDaniel Fojt     BN_GENCB *cb);
461cca6fc52SDaniel Fojt int RSA_meth_get_flags(const RSA_METHOD *meth);
462cca6fc52SDaniel Fojt void *RSA_meth_get0_app_data(const RSA_METHOD *meth);
463cca6fc52SDaniel Fojt int (*RSA_meth_get_sign(const RSA_METHOD *meth))(int type,
464cca6fc52SDaniel Fojt     const unsigned char *m, unsigned int m_length,
465cca6fc52SDaniel Fojt     unsigned char *sigret, unsigned int *siglen,
466cca6fc52SDaniel Fojt     const RSA *rsa);
467cca6fc52SDaniel Fojt int RSA_meth_set_sign(RSA_METHOD *rsa, int (*sign)(int type,
468cca6fc52SDaniel Fojt     const unsigned char *m, unsigned int m_length, unsigned char *sigret,
469cca6fc52SDaniel Fojt     unsigned int *siglen, const RSA *rsa));
470cca6fc52SDaniel Fojt int (*RSA_meth_get_verify(const RSA_METHOD *meth))(int dtype,
471cca6fc52SDaniel Fojt     const unsigned char *m, unsigned int m_length, const unsigned char *sigbuf,
472cca6fc52SDaniel Fojt     unsigned int siglen, const RSA *rsa);
473cca6fc52SDaniel Fojt int RSA_meth_set_verify(RSA_METHOD *rsa, int (*verify)(int dtype,
474cca6fc52SDaniel Fojt     const unsigned char *m, unsigned int m_length, const unsigned char *sigbuf,
475cca6fc52SDaniel Fojt     unsigned int siglen, const RSA *rsa));
476cca6fc52SDaniel Fojt 
47772c33676SMaxim Ag 
478f5b1c8a1SJohn Marino void ERR_load_RSA_strings(void);
479f5b1c8a1SJohn Marino 
480f5b1c8a1SJohn Marino /* Error codes for the RSA functions. */
481f5b1c8a1SJohn Marino 
482f5b1c8a1SJohn Marino /* Function codes. */
483f5b1c8a1SJohn Marino #define RSA_F_CHECK_PADDING_MD				 140
484f5b1c8a1SJohn Marino #define RSA_F_DO_RSA_PRINT				 146
485f5b1c8a1SJohn Marino #define RSA_F_INT_RSA_VERIFY				 145
486f5b1c8a1SJohn Marino #define RSA_F_MEMORY_LOCK				 100
487f5b1c8a1SJohn Marino #define RSA_F_OLD_RSA_PRIV_DECODE			 147
488f5b1c8a1SJohn Marino #define RSA_F_PKEY_RSA_CTRL				 143
489f5b1c8a1SJohn Marino #define RSA_F_PKEY_RSA_CTRL_STR				 144
490f5b1c8a1SJohn Marino #define RSA_F_PKEY_RSA_SIGN				 142
491f5b1c8a1SJohn Marino #define RSA_F_PKEY_RSA_VERIFY				 154
492f5b1c8a1SJohn Marino #define RSA_F_PKEY_RSA_VERIFYRECOVER			 141
493f5b1c8a1SJohn Marino #define RSA_F_RSA_BUILTIN_KEYGEN			 129
494f5b1c8a1SJohn Marino #define RSA_F_RSA_CHECK_KEY				 123
495f5b1c8a1SJohn Marino #define RSA_F_RSA_EAY_MOD_EXP				 157
496f5b1c8a1SJohn Marino #define RSA_F_RSA_EAY_PRIVATE_DECRYPT			 101
497f5b1c8a1SJohn Marino #define RSA_F_RSA_EAY_PRIVATE_ENCRYPT			 102
498f5b1c8a1SJohn Marino #define RSA_F_RSA_EAY_PUBLIC_DECRYPT			 103
499f5b1c8a1SJohn Marino #define RSA_F_RSA_EAY_PUBLIC_ENCRYPT			 104
500f5b1c8a1SJohn Marino #define RSA_F_RSA_GENERATE_KEY				 105
501f5b1c8a1SJohn Marino #define RSA_F_RSA_GENERATE_KEY_EX			 155
502f5b1c8a1SJohn Marino #define RSA_F_RSA_ITEM_VERIFY				 156
503f5b1c8a1SJohn Marino #define RSA_F_RSA_MEMORY_LOCK				 130
504f5b1c8a1SJohn Marino #define RSA_F_RSA_NEW_METHOD				 106
505f5b1c8a1SJohn Marino #define RSA_F_RSA_NULL					 124
506f5b1c8a1SJohn Marino #define RSA_F_RSA_NULL_MOD_EXP				 131
507f5b1c8a1SJohn Marino #define RSA_F_RSA_NULL_PRIVATE_DECRYPT			 132
508f5b1c8a1SJohn Marino #define RSA_F_RSA_NULL_PRIVATE_ENCRYPT			 133
509f5b1c8a1SJohn Marino #define RSA_F_RSA_NULL_PUBLIC_DECRYPT			 134
510f5b1c8a1SJohn Marino #define RSA_F_RSA_NULL_PUBLIC_ENCRYPT			 135
511f5b1c8a1SJohn Marino #define RSA_F_RSA_PADDING_ADD_NONE			 107
512f5b1c8a1SJohn Marino #define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP		 121
513f5b1c8a1SJohn Marino #define RSA_F_RSA_PADDING_ADD_PKCS1_PSS			 125
514f5b1c8a1SJohn Marino #define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1		 148
515f5b1c8a1SJohn Marino #define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1		 108
516f5b1c8a1SJohn Marino #define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2		 109
517f5b1c8a1SJohn Marino #define RSA_F_RSA_PADDING_ADD_X931			 127
518f5b1c8a1SJohn Marino #define RSA_F_RSA_PADDING_CHECK_NONE			 111
519f5b1c8a1SJohn Marino #define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP		 122
520f5b1c8a1SJohn Marino #define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1		 112
521f5b1c8a1SJohn Marino #define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2		 113
522f5b1c8a1SJohn Marino #define RSA_F_RSA_PADDING_CHECK_X931			 128
523f5b1c8a1SJohn Marino #define RSA_F_RSA_PRINT					 115
524f5b1c8a1SJohn Marino #define RSA_F_RSA_PRINT_FP				 116
525f5b1c8a1SJohn Marino #define RSA_F_RSA_PRIVATE_DECRYPT			 150
526f5b1c8a1SJohn Marino #define RSA_F_RSA_PRIVATE_ENCRYPT			 151
527f5b1c8a1SJohn Marino #define RSA_F_RSA_PRIV_DECODE				 137
528f5b1c8a1SJohn Marino #define RSA_F_RSA_PRIV_ENCODE				 138
529f5b1c8a1SJohn Marino #define RSA_F_RSA_PUBLIC_DECRYPT			 152
530f5b1c8a1SJohn Marino #define RSA_F_RSA_PUBLIC_ENCRYPT			 153
531f5b1c8a1SJohn Marino #define RSA_F_RSA_PUB_DECODE				 139
532f5b1c8a1SJohn Marino #define RSA_F_RSA_SETUP_BLINDING			 136
533f5b1c8a1SJohn Marino #define RSA_F_RSA_SIGN					 117
534f5b1c8a1SJohn Marino #define RSA_F_RSA_SIGN_ASN1_OCTET_STRING		 118
535f5b1c8a1SJohn Marino #define RSA_F_RSA_VERIFY				 119
536f5b1c8a1SJohn Marino #define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING		 120
537f5b1c8a1SJohn Marino #define RSA_F_RSA_VERIFY_PKCS1_PSS			 126
538f5b1c8a1SJohn Marino #define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1			 149
539f5b1c8a1SJohn Marino 
540f5b1c8a1SJohn Marino /* Reason codes. */
541f5b1c8a1SJohn Marino #define RSA_R_ALGORITHM_MISMATCH			 100
542f5b1c8a1SJohn Marino #define RSA_R_BAD_E_VALUE				 101
543f5b1c8a1SJohn Marino #define RSA_R_BAD_FIXED_HEADER_DECRYPT			 102
544f5b1c8a1SJohn Marino #define RSA_R_BAD_PAD_BYTE_COUNT			 103
545f5b1c8a1SJohn Marino #define RSA_R_BAD_SIGNATURE				 104
546f5b1c8a1SJohn Marino #define RSA_R_BLOCK_TYPE_IS_NOT_01			 106
547f5b1c8a1SJohn Marino #define RSA_R_BLOCK_TYPE_IS_NOT_02			 107
548f5b1c8a1SJohn Marino #define RSA_R_DATA_GREATER_THAN_MOD_LEN			 108
549f5b1c8a1SJohn Marino #define RSA_R_DATA_TOO_LARGE				 109
550f5b1c8a1SJohn Marino #define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE		 110
551f5b1c8a1SJohn Marino #define RSA_R_DATA_TOO_LARGE_FOR_MODULUS		 132
552f5b1c8a1SJohn Marino #define RSA_R_DATA_TOO_SMALL				 111
553f5b1c8a1SJohn Marino #define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE		 122
554cca6fc52SDaniel Fojt #define RSA_R_DIGEST_DOES_NOT_MATCH			 158
555cca6fc52SDaniel Fojt #define RSA_R_DIGEST_NOT_ALLOWED			 145
556f5b1c8a1SJohn Marino #define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY		 112
557f5b1c8a1SJohn Marino #define RSA_R_DMP1_NOT_CONGRUENT_TO_D			 124
558f5b1c8a1SJohn Marino #define RSA_R_DMQ1_NOT_CONGRUENT_TO_D			 125
559f5b1c8a1SJohn Marino #define RSA_R_D_E_NOT_CONGRUENT_TO_1			 123
560f5b1c8a1SJohn Marino #define RSA_R_FIRST_OCTET_INVALID			 133
561f5b1c8a1SJohn Marino #define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE	 144
562cca6fc52SDaniel Fojt #define RSA_R_INVALID_DIGEST				 157
563f5b1c8a1SJohn Marino #define RSA_R_INVALID_DIGEST_LENGTH			 143
564f5b1c8a1SJohn Marino #define RSA_R_INVALID_HEADER				 137
565f5b1c8a1SJohn Marino #define RSA_R_INVALID_KEYBITS				 145
566cca6fc52SDaniel Fojt #define RSA_R_INVALID_LABEL				 160
567f5b1c8a1SJohn Marino #define RSA_R_INVALID_MESSAGE_LENGTH			 131
568f5b1c8a1SJohn Marino #define RSA_R_INVALID_MGF1_MD				 156
569cca6fc52SDaniel Fojt #define RSA_R_INVALID_OAEP_PARAMETERS			 161
570f5b1c8a1SJohn Marino #define RSA_R_INVALID_PADDING				 138
571f5b1c8a1SJohn Marino #define RSA_R_INVALID_PADDING_MODE			 141
572f5b1c8a1SJohn Marino #define RSA_R_INVALID_PSS_PARAMETERS			 149
573f5b1c8a1SJohn Marino #define RSA_R_INVALID_PSS_SALTLEN			 146
574f5b1c8a1SJohn Marino #define RSA_R_INVALID_SALT_LENGTH			 150
575f5b1c8a1SJohn Marino #define RSA_R_INVALID_TRAILER				 139
576f5b1c8a1SJohn Marino #define RSA_R_INVALID_X931_DIGEST			 142
577f5b1c8a1SJohn Marino #define RSA_R_IQMP_NOT_INVERSE_OF_Q			 126
578f5b1c8a1SJohn Marino #define RSA_R_KEY_SIZE_TOO_SMALL			 120
579f5b1c8a1SJohn Marino #define RSA_R_LAST_OCTET_INVALID			 134
580f5b1c8a1SJohn Marino #define RSA_R_MODULUS_TOO_LARGE				 105
581cca6fc52SDaniel Fojt #define RSA_R_MGF1_DIGEST_NOT_ALLOWED			 152
582f5b1c8a1SJohn Marino #define RSA_R_NON_FIPS_RSA_METHOD			 157
583f5b1c8a1SJohn Marino #define RSA_R_NO_PUBLIC_EXPONENT			 140
584f5b1c8a1SJohn Marino #define RSA_R_NULL_BEFORE_BLOCK_MISSING			 113
585f5b1c8a1SJohn Marino #define RSA_R_N_DOES_NOT_EQUAL_P_Q			 127
586f5b1c8a1SJohn Marino #define RSA_R_OAEP_DECODING_ERROR			 121
587f5b1c8a1SJohn Marino #define RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE	 158
588f5b1c8a1SJohn Marino #define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE	 148
589f5b1c8a1SJohn Marino #define RSA_R_PADDING_CHECK_FAILED			 114
590cca6fc52SDaniel Fojt #define RSA_R_PSS_SALTLEN_TOO_SMALL			 164
591f5b1c8a1SJohn Marino #define RSA_R_P_NOT_PRIME				 128
592f5b1c8a1SJohn Marino #define RSA_R_Q_NOT_PRIME				 129
593f5b1c8a1SJohn Marino #define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED		 130
594f5b1c8a1SJohn Marino #define RSA_R_SLEN_CHECK_FAILED				 136
595f5b1c8a1SJohn Marino #define RSA_R_SLEN_RECOVERY_FAILED			 135
596f5b1c8a1SJohn Marino #define RSA_R_SSLV3_ROLLBACK_ATTACK			 115
597f5b1c8a1SJohn Marino #define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116
598f5b1c8a1SJohn Marino #define RSA_R_UNKNOWN_ALGORITHM_TYPE			 117
599cca6fc52SDaniel Fojt #define RSA_R_UNKNOWN_DIGEST				 166
600f5b1c8a1SJohn Marino #define RSA_R_UNKNOWN_MASK_DIGEST			 151
601f5b1c8a1SJohn Marino #define RSA_R_UNKNOWN_PADDING_TYPE			 118
602f5b1c8a1SJohn Marino #define RSA_R_UNKNOWN_PSS_DIGEST			 152
603cca6fc52SDaniel Fojt #define RSA_R_UNSUPPORTED_ENCRYPTION_TYPE		 162
604cca6fc52SDaniel Fojt #define RSA_R_UNSUPPORTED_LABEL_SOURCE			 163
605f5b1c8a1SJohn Marino #define RSA_R_UNSUPPORTED_MASK_ALGORITHM		 153
606f5b1c8a1SJohn Marino #define RSA_R_UNSUPPORTED_MASK_PARAMETER		 154
607f5b1c8a1SJohn Marino #define RSA_R_UNSUPPORTED_SIGNATURE_TYPE		 155
608f5b1c8a1SJohn Marino #define RSA_R_VALUE_MISSING				 147
609f5b1c8a1SJohn Marino #define RSA_R_WRONG_SIGNATURE_LENGTH			 119
610f5b1c8a1SJohn Marino 
611f5b1c8a1SJohn Marino #ifdef  __cplusplus
612f5b1c8a1SJohn Marino }
613f5b1c8a1SJohn Marino #endif
614f5b1c8a1SJohn Marino #endif
615