1 /* $OpenBSD: rsa.h,v 1.51 2019/11/04 12:30:56 jsing Exp $ */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3  * All rights reserved.
4  *
5  * This package is an SSL implementation written
6  * by Eric Young (eay@cryptsoft.com).
7  * The implementation was written so as to conform with Netscapes SSL.
8  *
9  * This library is free for commercial and non-commercial use as core.stdc.config.c_long as
10  * the following conditions are aheared to.  The following conditions
11  * apply to all code found in this distribution, be it the RC4, RSA,
12  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13  * included with this distribution is covered by the same copyright terms
14  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15  *
16  * Copyright remains Eric Young's, and as such any Copyright notices in
17  * the code are not to be removed.
18  * If this package is used in a product, Eric Young should be given attribution
19  * as the author of the parts of the library used.
20  * This can be in the form of a textual message at program startup or
21  * in documentation (online or textual) provided with the package.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions
25  * are met:
26  * 1. Redistributions of source code must retain the copyright
27  *    notice, this list of conditions and the following disclaimer.
28  * 2. Redistributions in binary form must reproduce the above copyright
29  *    notice, this list of conditions and the following disclaimer in the
30  *    documentation and/or other materials provided with the distribution.
31  * 3. All advertising materials mentioning features or use of this software
32  *    must display the following acknowledgement:
33  *    "This product includes cryptographic software written by
34  *     Eric Young (eay@cryptsoft.com)"
35  *    The word 'cryptographic' can be left out if the rouines from the library
36  *    being used are not cryptographic related :-).
37  * 4. If you include any Windows specific code (or a derivative thereof) from
38  *    the apps directory (application code) you must include an acknowledgement:
39  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40  *
41  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  *
53  * The licence and distribution terms for any publically available version or
54  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55  * copied and put under another distribution licence
56  * [including the GNU Public Licence.]
57  */
58 module libressl_d.openssl.rsa;
59 
60 
61 private static import core.stdc.config;
62 private static import libressl_d.compat.stdio;
63 private static import libressl_d.openssl.evp;
64 private static import libressl_d.openssl.rsa;
65 public import libressl_d.openssl.asn1;
66 public import libressl_d.openssl.crypto;
67 public import libressl_d.openssl.opensslconf;
68 public import libressl_d.openssl.ossl_typ;
69 
70 version (OPENSSL_NO_BIO) {
71 } else {
72 	public import libressl_d.openssl.bio;
73 }
74 
75 version (OPENSSL_NO_DEPRECATED) {
76 } else {
77 	public import libressl_d.openssl.bn;
78 }
79 
80 version (OPENSSL_NO_RSA) {
81 	static assert(false, "RSA is disabled.");
82 }
83 
84 extern (C):
85 nothrow @nogc:
86 
87 /* Declared already in ossl_typ.h */
88 /* alias RSA = libressl_d.openssl.rsa.rsa_st; */
89 /* alias RSA_METHOD = libressl_d.openssl.rsa.rsa_meth_st; */
90 
91 struct rsa_pss_params_st
92 {
93 	libressl_d.openssl.ossl_typ.X509_ALGOR* hashAlgorithm;
94 	libressl_d.openssl.ossl_typ.X509_ALGOR* maskGenAlgorithm;
95 	libressl_d.openssl.ossl_typ.ASN1_INTEGER* saltLength;
96 	libressl_d.openssl.ossl_typ.ASN1_INTEGER* trailerField;
97 
98 	/* Hash algorithm decoded from maskGenAlgorithm. */
99 	libressl_d.openssl.ossl_typ.X509_ALGOR* maskHash;
100 }
101 
102 alias RSA_PSS_PARAMS = .rsa_pss_params_st;
103 
104 struct rsa_oaep_params_st
105 {
106 	libressl_d.openssl.ossl_typ.X509_ALGOR* hashFunc;
107 	libressl_d.openssl.ossl_typ.X509_ALGOR* maskGenFunc;
108 	libressl_d.openssl.ossl_typ.X509_ALGOR* pSourceFunc;
109 
110 	/* Hash algorithm decoded from maskGenFunc. */
111 	libressl_d.openssl.ossl_typ.X509_ALGOR* maskHash;
112 }
113 
114 alias RSA_OAEP_PARAMS = .rsa_oaep_params_st;
115 
116 struct rsa_meth_st
117 {
118 	const (char)* name;
119 	int function(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding) rsa_pub_enc;
120 	int function(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding) rsa_pub_dec;
121 	int function(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding) rsa_priv_enc;
122 	int function(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding) rsa_priv_dec;
123 
124 	/**
125 	 * Can be null
126 	 */
127 	int function(libressl_d.openssl.ossl_typ.BIGNUM* r0, const (libressl_d.openssl.ossl_typ.BIGNUM)* I, libressl_d.openssl.ossl_typ.RSA* rsa, libressl_d.openssl.ossl_typ.BN_CTX* ctx) rsa_mod_exp;
128 
129 	///Ditto
130 	int function(libressl_d.openssl.ossl_typ.BIGNUM* r, const (libressl_d.openssl.ossl_typ.BIGNUM)* a, const (libressl_d.openssl.ossl_typ.BIGNUM)* p, const (libressl_d.openssl.ossl_typ.BIGNUM)* m, libressl_d.openssl.ossl_typ.BN_CTX* ctx, libressl_d.openssl.ossl_typ.BN_MONT_CTX* m_ctx) bn_mod_exp;
131 
132 	/**
133 	 * called at new
134 	 */
135 	int function(libressl_d.openssl.ossl_typ.RSA* rsa) init;
136 
137 	/**
138 	 * called at free
139 	 */
140 	int function(libressl_d.openssl.ossl_typ.RSA* rsa) finish;
141 
142 	/**
143 	 * RSA_METHOD_FLAG_* things
144 	 */
145 	int flags;
146 
147 	/**
148 	 * may be needed!
149 	 */
150 	char* app_data;
151 
152 	/*
153 	 * New sign and verify functions: some libraries don't allow arbitrary data
154 	 * to be signed/verified: this allows them to be used. Note: for this to work
155 	 * the RSA_public_decrypt() and RSA_private_encrypt() should *NOT* be used
156 	 * RSA_sign(), RSA_verify() should be used instead. Note: for backwards
157 	 * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER
158 	 * option is set in 'flags'.
159 	 */
160 	int function(int type, const (ubyte)* m, uint m_length, ubyte* sigret, uint* siglen, const (libressl_d.openssl.ossl_typ.RSA)* rsa) rsa_sign;
161 	int function(int dtype, const (ubyte)* m, uint m_length, const (ubyte)* sigbuf, uint siglen, const (libressl_d.openssl.ossl_typ.RSA)* rsa) rsa_verify;
162 
163 	/**
164 	 * If this callback is null, the builtin software RSA key-gen will be used. This
165 	 * is for behavioural compatibility whilst the code gets rewired, but one day
166 	 * it would be nice to assume there are no such things as "builtin software"
167 	 * implementations.
168 	 */
169 	int function(libressl_d.openssl.ossl_typ.RSA* rsa, int bits, libressl_d.openssl.ossl_typ.BIGNUM* e, libressl_d.openssl.ossl_typ.BN_GENCB* cb) rsa_keygen;
170 }
171 
172 struct rsa_st
173 {
174 	/**
175 	 * The first parameter is used to pickup errors where
176 	 * this is passed instead of aEVP_PKEY, it is set to 0
177 	 */
178 	int pad;
179 
180 	core.stdc.config.c_long version_;
181 	const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth;
182 
183 	/**
184 	 * functional reference if 'meth' is ENGINE-provided
185 	 */
186 	libressl_d.openssl.ossl_typ.ENGINE* engine;
187 
188 	libressl_d.openssl.ossl_typ.BIGNUM* n;
189 	libressl_d.openssl.ossl_typ.BIGNUM* e;
190 	libressl_d.openssl.ossl_typ.BIGNUM* d;
191 	libressl_d.openssl.ossl_typ.BIGNUM* p;
192 	libressl_d.openssl.ossl_typ.BIGNUM* q;
193 	libressl_d.openssl.ossl_typ.BIGNUM* dmp1;
194 	libressl_d.openssl.ossl_typ.BIGNUM* dmq1;
195 	libressl_d.openssl.ossl_typ.BIGNUM* iqmp;
196 
197 	/**
198 	 * Parameter restrictions for PSS only keys.
199 	 */
200 	.RSA_PSS_PARAMS* pss;
201 
202 	/* be careful using this if the RSA structure is shared */
203 	libressl_d.openssl.ossl_typ.CRYPTO_EX_DATA ex_data;
204 	int references;
205 	int flags;
206 
207 	/* Used to cache montgomery values */
208 	libressl_d.openssl.ossl_typ.BN_MONT_CTX* _method_mod_n;
209 	libressl_d.openssl.ossl_typ.BN_MONT_CTX* _method_mod_p;
210 	libressl_d.openssl.ossl_typ.BN_MONT_CTX* _method_mod_q;
211 
212 	/*
213 	 * all BIGNUM values are actually in the following data, if it is not
214 	 * null
215 	 */
216 	libressl_d.openssl.ossl_typ.BN_BLINDING* blinding;
217 	libressl_d.openssl.ossl_typ.BN_BLINDING* mt_blinding;
218 }
219 
220 //#if !defined(OPENSSL_RSA_MAX_MODULUS_BITS)
221 	enum OPENSSL_RSA_MAX_MODULUS_BITS = 16384;
222 //#endif
223 
224 //#if !defined(OPENSSL_RSA_SMALL_MODULUS_BITS)
225 	enum OPENSSL_RSA_SMALL_MODULUS_BITS = 3072;
226 //#endif
227 
228 //#if !defined(OPENSSL_RSA_MAX_PUBEXP_BITS)
229 	/**
230 	 * exponent limit enforced for "large" modulus only
231 	 */
232 	enum OPENSSL_RSA_MAX_PUBEXP_BITS = 64;
233 //#endif
234 
235 enum RSA_3 = 0x03L;
236 enum RSA_F4 = 0x010001L;
237 
238 /**
239  * Don't check pub/private match.
240  */
241 enum RSA_METHOD_FLAG_NO_CHECK = 0x0001;
242 
243 enum RSA_FLAG_CACHE_PUBLIC = 0x0002;
244 enum RSA_FLAG_CACHE_PRIVATE = 0x0004;
245 enum RSA_FLAG_BLINDING = 0x0008;
246 enum RSA_FLAG_THREAD_SAFE = 0x0010;
247 
248 /**
249  * This flag means the private key operations will be handled by rsa_mod_exp
250  * and that they do not depend on the private key components being present:
251  * for example a key stored in external hardware. Without this flag bn_mod_exp
252  * gets called when private key components are absent.
253  */
254 enum RSA_FLAG_EXT_PKEY = 0x0020;
255 
256 /**
257  * This flag in the RSA_METHOD enables the new rsa_sign, rsa_verify functions.
258  */
259 enum RSA_FLAG_SIGN_VER = 0x0040;
260 
261 /**
262  * The built-in RSA implementation uses blinding by default, but other engines
263  * might not need it.
264  */
265 enum RSA_FLAG_NO_BLINDING = 0x0080;
266 
267 /**
268  * Salt length matches digest
269  */
270 enum RSA_PSS_SALTLEN_DIGEST = -1;
271 
272 /**
273  * Verify only: auto detect salt length
274  */
275 enum RSA_PSS_SALTLEN_AUTO = -2;
276 
277 /**
278  * Set salt length to maximum possible
279  */
280 enum RSA_PSS_SALTLEN_MAX = -3;
281 
282 pragma(inline, true)
283 int EVP_PKEY_CTX_set_rsa_padding(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, int pad)
284 
285 	do
286 	{
287 		return .RSA_pkey_ctx_ctrl(ctx, -1, .EVP_PKEY_CTRL_RSA_PADDING, pad, null);
288 	}
289 
290 pragma(inline, true)
291 int EVP_PKEY_CTX_get_rsa_padding(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, void* ppad)
292 
293 	do
294 	{
295 		return .RSA_pkey_ctx_ctrl(ctx, -1, .EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad);
296 	}
297 
298 pragma(inline, true)
299 int EVP_PKEY_CTX_set_rsa_pss_saltlen(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, int len)
300 
301 	do
302 	{
303 		return .RSA_pkey_ctx_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_OP_SIGN | libressl_d.openssl.evp.EVP_PKEY_OP_VERIFY, .EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, null);
304 	}
305 
306 pragma(inline, true)
307 int EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, int len)
308 
309 	do
310 	{
311 		return libressl_d.openssl.evp.EVP_PKEY_CTX_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_RSA_PSS, libressl_d.openssl.evp.EVP_PKEY_OP_KEYGEN, .EVP_PKEY_CTRL_RSA_PSS_SALTLEN, len, null);
312 	}
313 
314 pragma(inline, true)
315 int EVP_PKEY_CTX_get_rsa_pss_saltlen(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, void* plen)
316 
317 	do
318 	{
319 		return .RSA_pkey_ctx_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_OP_SIGN | libressl_d.openssl.evp.EVP_PKEY_OP_VERIFY, .EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, 0, plen);
320 	}
321 
322 pragma(inline, true)
323 int EVP_PKEY_CTX_set_rsa_keygen_bits(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, int bits)
324 
325 	do
326 	{
327 		return .RSA_pkey_ctx_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_OP_KEYGEN, .EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, null);
328 	}
329 
330 pragma(inline, true)
331 int EVP_PKEY_CTX_set_rsa_keygen_pubexp(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, void* pubexp)
332 
333 	do
334 	{
335 		return .RSA_pkey_ctx_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_OP_KEYGEN, .EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp);
336 	}
337 
338 pragma(inline, true)
339 int EVP_PKEY_CTX_set_rsa_mgf1_md(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, void* md)
340 
341 	do
342 	{
343 		return .RSA_pkey_ctx_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_OP_TYPE_SIG | libressl_d.openssl.evp.EVP_PKEY_OP_TYPE_CRYPT, .EVP_PKEY_CTRL_RSA_MGF1_MD, 0, md);
344 	}
345 
346 pragma(inline, true)
347 int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, void* md)
348 
349 	do
350 	{
351 		return libressl_d.openssl.evp.EVP_PKEY_CTX_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_RSA_PSS, libressl_d.openssl.evp.EVP_PKEY_OP_KEYGEN, .EVP_PKEY_CTRL_RSA_MGF1_MD, 0, md);
352 	}
353 
354 pragma(inline, true)
355 int EVP_PKEY_CTX_set_rsa_oaep_md(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, void* md)
356 
357 	do
358 	{
359 		return libressl_d.openssl.evp.EVP_PKEY_CTX_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_RSA, libressl_d.openssl.evp.EVP_PKEY_OP_TYPE_CRYPT, .EVP_PKEY_CTRL_RSA_OAEP_MD, 0, md);
360 	}
361 
362 pragma(inline, true)
363 int EVP_PKEY_CTX_get_rsa_mgf1_md(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, void* pmd)
364 
365 	do
366 	{
367 		return .RSA_pkey_ctx_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_OP_TYPE_SIG | libressl_d.openssl.evp.EVP_PKEY_OP_TYPE_CRYPT, .EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, pmd);
368 	}
369 
370 pragma(inline, true)
371 int EVP_PKEY_CTX_get_rsa_oaep_md(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, void* pmd)
372 
373 	do
374 	{
375 		return libressl_d.openssl.evp.EVP_PKEY_CTX_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_RSA, libressl_d.openssl.evp.EVP_PKEY_OP_TYPE_CRYPT, .EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, pmd);
376 	}
377 
378 pragma(inline, true)
379 int EVP_PKEY_CTX_set0_rsa_oaep_label(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, void* l, int llen)
380 
381 	do
382 	{
383 		return libressl_d.openssl.evp.EVP_PKEY_CTX_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_RSA, libressl_d.openssl.evp.EVP_PKEY_OP_TYPE_CRYPT, .EVP_PKEY_CTRL_RSA_OAEP_LABEL, llen, l);
384 	}
385 
386 pragma(inline, true)
387 int EVP_PKEY_CTX_get0_rsa_oaep_label(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, void* l)
388 
389 	do
390 	{
391 		return libressl_d.openssl.evp.EVP_PKEY_CTX_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_RSA, libressl_d.openssl.evp.EVP_PKEY_OP_TYPE_CRYPT, .EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, l);
392 	}
393 
394 pragma(inline, true)
395 int s(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, void* md)
396 
397 	do
398 	{
399 		return libressl_d.openssl.evp.EVP_PKEY_CTX_ctrl(ctx, libressl_d.openssl.evp.EVP_PKEY_RSA_PSS, libressl_d.openssl.evp.EVP_PKEY_OP_KEYGEN, libressl_d.openssl.evp.EVP_PKEY_CTRL_MD, 0, md);
400 	}
401 
402 enum EVP_PKEY_CTRL_RSA_PADDING = libressl_d.openssl.evp.EVP_PKEY_ALG_CTRL + 1;
403 enum EVP_PKEY_CTRL_RSA_PSS_SALTLEN = libressl_d.openssl.evp.EVP_PKEY_ALG_CTRL + 2;
404 
405 enum EVP_PKEY_CTRL_RSA_KEYGEN_BITS = libressl_d.openssl.evp.EVP_PKEY_ALG_CTRL + 3;
406 enum EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP = libressl_d.openssl.evp.EVP_PKEY_ALG_CTRL + 4;
407 enum EVP_PKEY_CTRL_RSA_MGF1_MD = libressl_d.openssl.evp.EVP_PKEY_ALG_CTRL + 5;
408 
409 enum EVP_PKEY_CTRL_GET_RSA_PADDING = libressl_d.openssl.evp.EVP_PKEY_ALG_CTRL + 6;
410 enum EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN = libressl_d.openssl.evp.EVP_PKEY_ALG_CTRL + 7;
411 enum EVP_PKEY_CTRL_GET_RSA_MGF1_MD = libressl_d.openssl.evp.EVP_PKEY_ALG_CTRL + 8;
412 
413 enum EVP_PKEY_CTRL_RSA_OAEP_MD = libressl_d.openssl.evp.EVP_PKEY_ALG_CTRL + 9;
414 enum EVP_PKEY_CTRL_RSA_OAEP_LABEL = libressl_d.openssl.evp.EVP_PKEY_ALG_CTRL + 10;
415 
416 enum EVP_PKEY_CTRL_GET_RSA_OAEP_MD = libressl_d.openssl.evp.EVP_PKEY_ALG_CTRL + 11;
417 enum EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL = libressl_d.openssl.evp.EVP_PKEY_ALG_CTRL + 12;
418 
419 enum RSA_PKCS1_PADDING = 1;
420 enum RSA_SSLV23_PADDING = 2;
421 enum RSA_NO_PADDING = 3;
422 enum RSA_PKCS1_OAEP_PADDING = 4;
423 enum RSA_X931_PADDING = 5;
424 /* EVP_PKEY_ only */
425 enum RSA_PKCS1_PSS_PADDING = 6;
426 
427 enum RSA_PKCS1_PADDING_SIZE = 11;
428 
429 pragma(inline, true)
430 int RSA_set_app_data(libressl_d.openssl.ossl_typ.RSA* s, void* arg)
431 
432 	do
433 	{
434 		return .RSA_set_ex_data(s, 0, arg);
435 	}
436 
437 pragma(inline, true)
438 void* RSA_get_app_data(const (libressl_d.openssl.ossl_typ.RSA)* s)
439 
440 	do
441 	{
442 		return .RSA_get_ex_data(s, 0);
443 	}
444 
445 libressl_d.openssl.ossl_typ.RSA* RSA_new();
446 libressl_d.openssl.ossl_typ.RSA* RSA_new_method(libressl_d.openssl.ossl_typ.ENGINE* engine);
447 int RSA_bits(const (libressl_d.openssl.ossl_typ.RSA)* rsa);
448 int RSA_size(const (libressl_d.openssl.ossl_typ.RSA)* rsa);
449 
450 /* Deprecated version */
451 version (OPENSSL_NO_DEPRECATED) {
452 } else {
453 	libressl_d.openssl.ossl_typ.RSA* RSA_generate_key(int bits, core.stdc.config.c_ulong e, void function(int, int, void*) callback, void* cb_arg);
454 }
455 
456 /**
457  * New version
458  */
459 int RSA_generate_key_ex(libressl_d.openssl.ossl_typ.RSA* rsa, int bits, libressl_d.openssl.ossl_typ.BIGNUM* e, libressl_d.openssl.ossl_typ.BN_GENCB* cb);
460 
461 int RSA_check_key(const (libressl_d.openssl.ossl_typ.RSA)*);
462 /* next 4 return -1 on error */
463 int RSA_public_encrypt(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding);
464 int RSA_private_encrypt(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding);
465 int RSA_public_decrypt(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding);
466 int RSA_private_decrypt(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding);
467 void RSA_free(libressl_d.openssl.ossl_typ.RSA* r);
468 
469 /**
470  * "up" the RSA object's reference count
471  */
472 int RSA_up_ref(libressl_d.openssl.ossl_typ.RSA* r);
473 
474 int RSA_flags(const (libressl_d.openssl.ossl_typ.RSA)* r);
475 
476 void RSA_set_default_method(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth);
477 const (libressl_d.openssl.ossl_typ.RSA_METHOD)* RSA_get_default_method();
478 const (libressl_d.openssl.ossl_typ.RSA_METHOD)* RSA_get_method(const (libressl_d.openssl.ossl_typ.RSA)* rsa);
479 int RSA_set_method(libressl_d.openssl.ossl_typ.RSA* rsa, const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth);
480 
481 const (libressl_d.openssl.ossl_typ.RSA_METHOD)* RSA_PKCS1_OpenSSL();
482 const (libressl_d.openssl.ossl_typ.RSA_METHOD)* RSA_PKCS1_SSLeay();
483 
484 const (libressl_d.openssl.ossl_typ.RSA_METHOD)* RSA_null_method();
485 
486 int RSA_pkey_ctx_ctrl(libressl_d.openssl.ossl_typ.EVP_PKEY_CTX* ctx, int optype, int cmd, int p1, void* p2);
487 
488 libressl_d.openssl.ossl_typ.RSA* d2i_RSAPublicKey(libressl_d.openssl.ossl_typ.RSA** a, const (ubyte)** in_, core.stdc.config.c_long len);
489 int i2d_RSAPublicKey(const (libressl_d.openssl.ossl_typ.RSA)* a, ubyte** out_);
490 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM RSAPublicKey_it;
491 libressl_d.openssl.ossl_typ.RSA* d2i_RSAPrivateKey(libressl_d.openssl.ossl_typ.RSA** a, const (ubyte)** in_, core.stdc.config.c_long len);
492 int i2d_RSAPrivateKey(const (libressl_d.openssl.ossl_typ.RSA)* a, ubyte** out_);
493 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM RSAPrivateKey_it;
494 
495 .RSA_PSS_PARAMS* RSA_PSS_PARAMS_new();
496 void RSA_PSS_PARAMS_free(.RSA_PSS_PARAMS* a);
497 .RSA_PSS_PARAMS* d2i_RSA_PSS_PARAMS(.RSA_PSS_PARAMS** a, const (ubyte)** in_, core.stdc.config.c_long len);
498 int i2d_RSA_PSS_PARAMS(.RSA_PSS_PARAMS* a, ubyte** out_);
499 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM RSA_PSS_PARAMS_it;
500 
501 .RSA_OAEP_PARAMS* RSA_OAEP_PARAMS_new();
502 void RSA_OAEP_PARAMS_free(.RSA_OAEP_PARAMS* a);
503 .RSA_OAEP_PARAMS* d2i_RSA_OAEP_PARAMS(.RSA_OAEP_PARAMS** a, const (ubyte)** in_, core.stdc.config.c_long len);
504 int i2d_RSA_OAEP_PARAMS(.RSA_OAEP_PARAMS* a, ubyte** out_);
505 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM RSA_OAEP_PARAMS_it;
506 
507 int RSA_print_fp(libressl_d.compat.stdio.FILE* fp, const (libressl_d.openssl.ossl_typ.RSA)* r, int offset);
508 
509 version (OPENSSL_NO_BIO) {
510 } else {
511 	int RSA_print(libressl_d.openssl.bio.BIO* bp, const (libressl_d.openssl.ossl_typ.RSA)* r, int offset);
512 }
513 
514 version (OPENSSL_NO_RC4) {
515 } else {
516 	int i2d_RSA_NET(const (libressl_d.openssl.ossl_typ.RSA)* a, ubyte** pp, int function(char* buf, int len, const (char)* prompt, int verify) cb, int sgckey);
517 	libressl_d.openssl.ossl_typ.RSA* d2i_RSA_NET(libressl_d.openssl.ossl_typ.RSA** a, const (ubyte)** pp, core.stdc.config.c_long length_, int function(char* buf, int len, const (char)* prompt, int verify) cb, int sgckey);
518 
519 	int i2d_Netscape_RSA(const (libressl_d.openssl.ossl_typ.RSA)* a, ubyte** pp, int function(char* buf, int len, const (char)* prompt, int verify) cb);
520 	libressl_d.openssl.ossl_typ.RSA* d2i_Netscape_RSA(libressl_d.openssl.ossl_typ.RSA** a, const (ubyte)** pp, core.stdc.config.c_long length_, int function(char* buf, int len, const (char)* prompt, int verify) cb);
521 }
522 
523 /*
524  * The following 2 functions sign and verify a X509_SIG ASN1 object
525  * inside PKCS#1 padded RSA encryption
526  */
527 int RSA_sign(int type, const (ubyte)* m, uint m_length, ubyte* sigret, uint* siglen, libressl_d.openssl.ossl_typ.RSA* rsa);
528 int RSA_verify(int type, const (ubyte)* m, uint m_length, const (ubyte)* sigbuf, uint siglen, libressl_d.openssl.ossl_typ.RSA* rsa);
529 
530 /*
531  * The following 2 function sign and verify a ASN1_OCTET_STRING
532  * object inside PKCS#1 padded RSA encryption
533  */
534 int RSA_sign_ASN1_OCTET_STRING(int type, const (ubyte)* m, uint m_length, ubyte* sigret, uint* siglen, libressl_d.openssl.ossl_typ.RSA* rsa);
535 int RSA_verify_ASN1_OCTET_STRING(int type, const (ubyte)* m, uint m_length, ubyte* sigbuf, uint siglen, libressl_d.openssl.ossl_typ.RSA* rsa);
536 
537 int RSA_blinding_on(libressl_d.openssl.ossl_typ.RSA* rsa, libressl_d.openssl.ossl_typ.BN_CTX* ctx);
538 void RSA_blinding_off(libressl_d.openssl.ossl_typ.RSA* rsa);
539 libressl_d.openssl.ossl_typ.BN_BLINDING* RSA_setup_blinding(libressl_d.openssl.ossl_typ.RSA* rsa, libressl_d.openssl.ossl_typ.BN_CTX* ctx);
540 
541 int RSA_padding_add_PKCS1_type_1(ubyte* to, int tlen, const (ubyte)* f, int fl);
542 int RSA_padding_check_PKCS1_type_1(ubyte* to, int tlen, const (ubyte)* f, int fl, int rsa_len);
543 int RSA_padding_add_PKCS1_type_2(ubyte* to, int tlen, const (ubyte)* f, int fl);
544 int RSA_padding_check_PKCS1_type_2(ubyte* to, int tlen, const (ubyte)* f, int fl, int rsa_len);
545 int PKCS1_MGF1(ubyte* mask, core.stdc.config.c_long len, const (ubyte)* seed, core.stdc.config.c_long seedlen, const (libressl_d.openssl.ossl_typ.EVP_MD)* dgst);
546 int RSA_padding_add_PKCS1_OAEP(ubyte* to, int tlen, const (ubyte)* f, int fl, const (ubyte)* p, int pl);
547 int RSA_padding_check_PKCS1_OAEP(ubyte* to, int tlen, const (ubyte)* f, int fl, int rsa_len, const (ubyte)* p, int pl);
548 int RSA_padding_add_PKCS1_OAEP_mgf1(ubyte* to, int tlen, const (ubyte)* from, int flen, const (ubyte)* param, int plen, const (libressl_d.openssl.ossl_typ.EVP_MD)* md, const (libressl_d.openssl.ossl_typ.EVP_MD)* mgf1md);
549 int RSA_padding_check_PKCS1_OAEP_mgf1(ubyte* to, int tlen, const (ubyte)* from, int flen, int num, const (ubyte)* param, int plen, const (libressl_d.openssl.ossl_typ.EVP_MD)* md, const (libressl_d.openssl.ossl_typ.EVP_MD)* mgf1md);
550 int RSA_padding_add_none(ubyte* to, int tlen, const (ubyte)* f, int fl);
551 int RSA_padding_check_none(ubyte* to, int tlen, const (ubyte)* f, int fl, int rsa_len);
552 int RSA_padding_add_X931(ubyte* to, int tlen, const (ubyte)* f, int fl);
553 int RSA_padding_check_X931(ubyte* to, int tlen, const (ubyte)* f, int fl, int rsa_len);
554 int RSA_X931_hash_id(int nid);
555 
556 int RSA_verify_PKCS1_PSS(libressl_d.openssl.ossl_typ.RSA* rsa, const (ubyte)* mHash, const (libressl_d.openssl.ossl_typ.EVP_MD)* Hash, const (ubyte)* EM, int sLen);
557 int RSA_padding_add_PKCS1_PSS(libressl_d.openssl.ossl_typ.RSA* rsa, ubyte* EM, const (ubyte)* mHash, const (libressl_d.openssl.ossl_typ.EVP_MD)* Hash, int sLen);
558 
559 int RSA_verify_PKCS1_PSS_mgf1(libressl_d.openssl.ossl_typ.RSA* rsa, const (ubyte)* mHash, const (libressl_d.openssl.ossl_typ.EVP_MD)* Hash, const (libressl_d.openssl.ossl_typ.EVP_MD)* mgf1Hash, const (ubyte)* EM, int sLen);
560 
561 int RSA_padding_add_PKCS1_PSS_mgf1(libressl_d.openssl.ossl_typ.RSA* rsa, ubyte* EM, const (ubyte)* mHash, const (libressl_d.openssl.ossl_typ.EVP_MD)* Hash, const (libressl_d.openssl.ossl_typ.EVP_MD)* mgf1Hash, int sLen);
562 
563 int RSA_get_ex_new_index(core.stdc.config.c_long argl, void* argp, libressl_d.openssl.ossl_typ.CRYPTO_EX_new* new_func, libressl_d.openssl.ossl_typ.CRYPTO_EX_dup* dup_func, libressl_d.openssl.ossl_typ.CRYPTO_EX_free* free_func);
564 int RSA_set_ex_data(libressl_d.openssl.ossl_typ.RSA* r, int idx, void* arg);
565 void* RSA_get_ex_data(const (libressl_d.openssl.ossl_typ.RSA)* r, int idx);
566 
567 void RSA_get0_key(const (libressl_d.openssl.ossl_typ.RSA)* r, const (libressl_d.openssl.ossl_typ.BIGNUM)** n, const (libressl_d.openssl.ossl_typ.BIGNUM)** e, const (libressl_d.openssl.ossl_typ.BIGNUM)** d);
568 int RSA_set0_key(libressl_d.openssl.ossl_typ.RSA* r, libressl_d.openssl.ossl_typ.BIGNUM* n, libressl_d.openssl.ossl_typ.BIGNUM* e, libressl_d.openssl.ossl_typ.BIGNUM* d);
569 void RSA_get0_crt_params(const (libressl_d.openssl.ossl_typ.RSA)* r, const (libressl_d.openssl.ossl_typ.BIGNUM)** dmp1, const (libressl_d.openssl.ossl_typ.BIGNUM)** dmq1, const (libressl_d.openssl.ossl_typ.BIGNUM)** iqmp);
570 int RSA_set0_crt_params(libressl_d.openssl.ossl_typ.RSA* r, libressl_d.openssl.ossl_typ.BIGNUM* dmp1, libressl_d.openssl.ossl_typ.BIGNUM* dmq1, libressl_d.openssl.ossl_typ.BIGNUM* iqmp);
571 void RSA_get0_factors(const (libressl_d.openssl.ossl_typ.RSA)* r, const (libressl_d.openssl.ossl_typ.BIGNUM)** p, const (libressl_d.openssl.ossl_typ.BIGNUM)** q);
572 int RSA_set0_factors(libressl_d.openssl.ossl_typ.RSA* r, libressl_d.openssl.ossl_typ.BIGNUM* p, libressl_d.openssl.ossl_typ.BIGNUM* q);
573 void RSA_clear_flags(libressl_d.openssl.ossl_typ.RSA* r, int flags);
574 int RSA_test_flags(const (libressl_d.openssl.ossl_typ.RSA)* r, int flags);
575 void RSA_set_flags(libressl_d.openssl.ossl_typ.RSA* r, int flags);
576 
577 libressl_d.openssl.ossl_typ.RSA* RSAPublicKey_dup(libressl_d.openssl.ossl_typ.RSA* rsa);
578 libressl_d.openssl.ossl_typ.RSA* RSAPrivateKey_dup(libressl_d.openssl.ossl_typ.RSA* rsa);
579 
580 /**
581  * If this flag is set the RSA method is FIPS compliant and can be used
582  * in FIPS mode. This is set in the validated module method. If an
583  * application sets this flag in its own methods it is its responsibility
584  * to ensure the result is compliant.
585  */
586 enum RSA_FLAG_FIPS_METHOD = 0x0400;
587 
588 /**
589  * If this flag is set the operations normally disabled in FIPS mode are
590  * permitted it is then the applications responsibility to ensure that the
591  * usage is compliant.
592  */
593 enum RSA_FLAG_NON_FIPS_ALLOW = 0x0400;
594 
595 /**
596  * Application has decided PRNG is good enough to generate a key: don't
597  * check.
598  */
599 enum RSA_FLAG_CHECKED = 0x0800;
600 
601 libressl_d.openssl.ossl_typ.RSA_METHOD* RSA_meth_new(const (char)* name, int flags);
602 void RSA_meth_free(libressl_d.openssl.ossl_typ.RSA_METHOD* meth);
603 libressl_d.openssl.ossl_typ.RSA_METHOD* RSA_meth_dup(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth);
604 int RSA_meth_set1_name(libressl_d.openssl.ossl_typ.RSA_METHOD* meth, const (char)* name);
605 int RSA_meth_set_priv_enc(libressl_d.openssl.ossl_typ.RSA_METHOD* meth, int function(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding) priv_enc);
606 int RSA_meth_set_priv_dec(libressl_d.openssl.ossl_typ.RSA_METHOD* meth, int function(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding) priv_dec);
607 //int (*RSA_meth_get_finish(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth))(libressl_d.openssl.ossl_typ.RSA* rsa);
608 int RSA_meth_set_finish(libressl_d.openssl.ossl_typ.RSA_METHOD* meth, int function(libressl_d.openssl.ossl_typ.RSA* rsa) finish);
609 int RSA_meth_set_pub_enc(libressl_d.openssl.ossl_typ.RSA_METHOD* meth, int function(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding) pub_enc);
610 int RSA_meth_set_pub_dec(libressl_d.openssl.ossl_typ.RSA_METHOD* meth, int function(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding) pub_dec);
611 int RSA_meth_set_mod_exp(libressl_d.openssl.ossl_typ.RSA_METHOD* meth, int function(libressl_d.openssl.ossl_typ.BIGNUM* r0, const (libressl_d.openssl.ossl_typ.BIGNUM)* i, libressl_d.openssl.ossl_typ.RSA* rsa, libressl_d.openssl.ossl_typ.BN_CTX* ctx) mod_exp);
612 int RSA_meth_set_bn_mod_exp(libressl_d.openssl.ossl_typ.RSA_METHOD* meth, int function(libressl_d.openssl.ossl_typ.BIGNUM* r, const (libressl_d.openssl.ossl_typ.BIGNUM)* a, const (libressl_d.openssl.ossl_typ.BIGNUM)* p, const (libressl_d.openssl.ossl_typ.BIGNUM)* m, libressl_d.openssl.ossl_typ.BN_CTX* ctx, libressl_d.openssl.ossl_typ.BN_MONT_CTX* m_ctx) bn_mod_exp);
613 int RSA_meth_set_init(libressl_d.openssl.ossl_typ.RSA_METHOD* meth, int function(libressl_d.openssl.ossl_typ.RSA* rsa) init);
614 int RSA_meth_set_keygen(libressl_d.openssl.ossl_typ.RSA_METHOD* meth, int function(libressl_d.openssl.ossl_typ.RSA* rsa, int bits, libressl_d.openssl.ossl_typ.BIGNUM* e, libressl_d.openssl.ossl_typ.BN_GENCB* cb) keygen);
615 int RSA_meth_set_flags(libressl_d.openssl.ossl_typ.RSA_METHOD* meth, int flags);
616 int RSA_meth_set0_app_data(libressl_d.openssl.ossl_typ.RSA_METHOD* meth, void* app_data);
617 const (char)* RSA_meth_get0_name(const (libressl_d.openssl.ossl_typ.RSA_METHOD)*);
618 //int (*RSA_meth_get_pub_enc(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth))(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding);
619 //int (*RSA_meth_get_pub_dec(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth))(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding);
620 //int (*RSA_meth_get_priv_enc(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth))(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding);
621 //int (*RSA_meth_get_priv_dec(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth))(int flen, const (ubyte)* from, ubyte* to, libressl_d.openssl.ossl_typ.RSA* rsa, int padding);
622 //int (*RSA_meth_get_mod_exp(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth))(libressl_d.openssl.ossl_typ.BIGNUM* r0, const (libressl_d.openssl.ossl_typ.BIGNUM)* i, libressl_d.openssl.ossl_typ.RSA* rsa, libressl_d.openssl.ossl_typ.BN_CTX* ctx);
623 //int (*RSA_meth_get_bn_mod_exp(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth))(libressl_d.openssl.ossl_typ.BIGNUM* r, const (libressl_d.openssl.ossl_typ.BIGNUM)* a, const (libressl_d.openssl.ossl_typ.BIGNUM)* p, const (libressl_d.openssl.ossl_typ.BIGNUM)* m, libressl_d.openssl.ossl_typ.BN_CTX* ctx, libressl_d.openssl.ossl_typ.BN_MONT_CTX* m_ctx);
624 //int (*RSA_meth_get_init(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth))(libressl_d.openssl.ossl_typ.RSA* rsa);
625 //int (*RSA_meth_get_keygen(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth))(libressl_d.openssl.ossl_typ.RSA* rsa, int bits, libressl_d.openssl.ossl_typ.BIGNUM* e, libressl_d.openssl.ossl_typ.BN_GENCB* cb);
626 int RSA_meth_get_flags(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth);
627 void* RSA_meth_get0_app_data(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth);
628 //int (*RSA_meth_get_sign(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth))(int type, const (ubyte)* m, uint m_length, ubyte* sigret, uint* siglen, const (libressl_d.openssl.ossl_typ.RSA)* rsa);
629 int RSA_meth_set_sign(libressl_d.openssl.ossl_typ.RSA_METHOD* rsa, int function(int type, const (ubyte)* m, uint m_length, ubyte* sigret, uint* siglen, const (libressl_d.openssl.ossl_typ.RSA)* rsa) sign);
630 //int (*RSA_meth_get_verify(const (libressl_d.openssl.ossl_typ.RSA_METHOD)* meth))(int dtype, const (ubyte)* m, uint m_length, const (ubyte)* sigbuf, uint siglen, const (libressl_d.openssl.ossl_typ.RSA)* rsa);
631 int RSA_meth_set_verify(libressl_d.openssl.ossl_typ.RSA_METHOD* rsa, int function(int dtype, const (ubyte)* m, uint m_length, const (ubyte)* sigbuf, uint siglen, const (libressl_d.openssl.ossl_typ.RSA)* rsa) verify);
632 
633 /* BEGIN ERROR CODES */
634 /**
635  * The following lines are auto generated by the script mkerr.pl. Any changes
636  * made after this point may be overwritten when the script is next run.
637  */
638 void ERR_load_RSA_strings();
639 
640 /* Error codes for the RSA functions. */
641 
642 /* Function codes. */
643 enum RSA_F_CHECK_PADDING_MD = 140;
644 enum RSA_F_DO_RSA_PRINT = 146;
645 enum RSA_F_INT_RSA_VERIFY = 145;
646 enum RSA_F_MEMORY_LOCK = 100;
647 enum RSA_F_OLD_RSA_PRIV_DECODE = 147;
648 enum RSA_F_PKEY_RSA_CTRL = 143;
649 enum RSA_F_PKEY_RSA_CTRL_STR = 144;
650 enum RSA_F_PKEY_RSA_SIGN = 142;
651 enum RSA_F_PKEY_RSA_VERIFY = 154;
652 enum RSA_F_PKEY_RSA_VERIFYRECOVER = 141;
653 enum RSA_F_RSA_BUILTIN_KEYGEN = 129;
654 enum RSA_F_RSA_CHECK_KEY = 123;
655 enum RSA_F_RSA_EAY_MOD_EXP = 157;
656 enum RSA_F_RSA_EAY_PRIVATE_DECRYPT = 101;
657 enum RSA_F_RSA_EAY_PRIVATE_ENCRYPT = 102;
658 enum RSA_F_RSA_EAY_PUBLIC_DECRYPT = 103;
659 enum RSA_F_RSA_EAY_PUBLIC_ENCRYPT = 104;
660 enum RSA_F_RSA_GENERATE_KEY = 105;
661 enum RSA_F_RSA_GENERATE_KEY_EX = 155;
662 enum RSA_F_RSA_ITEM_VERIFY = 156;
663 enum RSA_F_RSA_MEMORY_LOCK = 130;
664 enum RSA_F_RSA_NEW_METHOD = 106;
665 enum RSA_F_RSA_NULL = 124;
666 enum RSA_F_RSA_NULL_MOD_EXP = 131;
667 enum RSA_F_RSA_NULL_PRIVATE_DECRYPT = 132;
668 enum RSA_F_RSA_NULL_PRIVATE_ENCRYPT = 133;
669 enum RSA_F_RSA_NULL_PUBLIC_DECRYPT = 134;
670 enum RSA_F_RSA_NULL_PUBLIC_ENCRYPT = 135;
671 enum RSA_F_RSA_PADDING_ADD_NONE = 107;
672 enum RSA_F_RSA_PADDING_ADD_PKCS1_OAEP = 121;
673 enum RSA_F_RSA_PADDING_ADD_PKCS1_PSS = 125;
674 enum RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1 = 148;
675 enum RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 = 108;
676 enum RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 = 109;
677 enum RSA_F_RSA_PADDING_ADD_X931 = 127;
678 enum RSA_F_RSA_PADDING_CHECK_NONE = 111;
679 enum RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP = 122;
680 enum RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 = 112;
681 enum RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 = 113;
682 enum RSA_F_RSA_PADDING_CHECK_X931 = 128;
683 enum RSA_F_RSA_PRINT = 115;
684 enum RSA_F_RSA_PRINT_FP = 116;
685 enum RSA_F_RSA_PRIVATE_DECRYPT = 150;
686 enum RSA_F_RSA_PRIVATE_ENCRYPT = 151;
687 enum RSA_F_RSA_PRIV_DECODE = 137;
688 enum RSA_F_RSA_PRIV_ENCODE = 138;
689 enum RSA_F_RSA_PUBLIC_DECRYPT = 152;
690 enum RSA_F_RSA_PUBLIC_ENCRYPT = 153;
691 enum RSA_F_RSA_PUB_DECODE = 139;
692 enum RSA_F_RSA_SETUP_BLINDING = 136;
693 enum RSA_F_RSA_SIGN = 117;
694 enum RSA_F_RSA_SIGN_ASN1_OCTET_STRING = 118;
695 enum RSA_F_RSA_VERIFY = 119;
696 enum RSA_F_RSA_VERIFY_ASN1_OCTET_STRING = 120;
697 enum RSA_F_RSA_VERIFY_PKCS1_PSS = 126;
698 enum RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1 = 149;
699 
700 /* Reason codes. */
701 enum RSA_R_ALGORITHM_MISMATCH = 100;
702 enum RSA_R_BAD_E_VALUE = 101;
703 enum RSA_R_BAD_FIXED_HEADER_DECRYPT = 102;
704 enum RSA_R_BAD_PAD_BYTE_COUNT = 103;
705 enum RSA_R_BAD_SIGNATURE = 104;
706 enum RSA_R_BLOCK_TYPE_IS_NOT_01 = 106;
707 enum RSA_R_BLOCK_TYPE_IS_NOT_02 = 107;
708 enum RSA_R_DATA_GREATER_THAN_MOD_LEN = 108;
709 enum RSA_R_DATA_TOO_LARGE = 109;
710 enum RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE = 110;
711 enum RSA_R_DATA_TOO_LARGE_FOR_MODULUS = 132;
712 enum RSA_R_DATA_TOO_SMALL = 111;
713 enum RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE = 122;
714 enum RSA_R_DIGEST_DOES_NOT_MATCH = 158;
715 enum RSA_R_DIGEST_NOT_ALLOWED = 145;
716 enum RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY = 112;
717 enum RSA_R_DMP1_NOT_CONGRUENT_TO_D = 124;
718 enum RSA_R_DMQ1_NOT_CONGRUENT_TO_D = 125;
719 enum RSA_R_D_E_NOT_CONGRUENT_TO_1 = 123;
720 enum RSA_R_FIRST_OCTET_INVALID = 133;
721 enum RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE = 144;
722 enum RSA_R_INVALID_DIGEST = 157;
723 enum RSA_R_INVALID_DIGEST_LENGTH = 143;
724 enum RSA_R_INVALID_HEADER = 137;
725 enum RSA_R_INVALID_KEYBITS = 145;
726 enum RSA_R_INVALID_LABEL = 160;
727 enum RSA_R_INVALID_MESSAGE_LENGTH = 131;
728 enum RSA_R_INVALID_MGF1_MD = 156;
729 enum RSA_R_INVALID_OAEP_PARAMETERS = 161;
730 enum RSA_R_INVALID_PADDING = 138;
731 enum RSA_R_INVALID_PADDING_MODE = 141;
732 enum RSA_R_INVALID_PSS_PARAMETERS = 149;
733 enum RSA_R_INVALID_PSS_SALTLEN = 146;
734 enum RSA_R_INVALID_SALT_LENGTH = 150;
735 enum RSA_R_INVALID_TRAILER = 139;
736 enum RSA_R_INVALID_X931_DIGEST = 142;
737 enum RSA_R_IQMP_NOT_INVERSE_OF_Q = 126;
738 enum RSA_R_KEY_SIZE_TOO_SMALL = 120;
739 enum RSA_R_LAST_OCTET_INVALID = 134;
740 enum RSA_R_MODULUS_TOO_LARGE = 105;
741 enum RSA_R_MGF1_DIGEST_NOT_ALLOWED = 152;
742 enum RSA_R_NON_FIPS_RSA_METHOD = 157;
743 enum RSA_R_NO_PUBLIC_EXPONENT = 140;
744 enum RSA_R_NULL_BEFORE_BLOCK_MISSING = 113;
745 enum RSA_R_N_DOES_NOT_EQUAL_P_Q = 127;
746 enum RSA_R_OAEP_DECODING_ERROR = 121;
747 enum RSA_R_OPERATION_NOT_ALLOWED_IN_FIPS_MODE = 158;
748 enum RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE = 148;
749 enum RSA_R_PADDING_CHECK_FAILED = 114;
750 enum RSA_R_PSS_SALTLEN_TOO_SMALL = 164;
751 enum RSA_R_P_NOT_PRIME = 128;
752 enum RSA_R_Q_NOT_PRIME = 129;
753 enum RSA_R_RSA_OPERATIONS_NOT_SUPPORTED = 130;
754 enum RSA_R_SLEN_CHECK_FAILED = 136;
755 enum RSA_R_SLEN_RECOVERY_FAILED = 135;
756 enum RSA_R_SSLV3_ROLLBACK_ATTACK = 115;
757 enum RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD = 116;
758 enum RSA_R_UNKNOWN_ALGORITHM_TYPE = 117;
759 enum RSA_R_UNKNOWN_DIGEST = 166;
760 enum RSA_R_UNKNOWN_MASK_DIGEST = 151;
761 enum RSA_R_UNKNOWN_PADDING_TYPE = 118;
762 enum RSA_R_UNKNOWN_PSS_DIGEST = 152;
763 enum RSA_R_UNSUPPORTED_ENCRYPTION_TYPE = 162;
764 enum RSA_R_UNSUPPORTED_LABEL_SOURCE = 163;
765 enum RSA_R_UNSUPPORTED_MASK_ALGORITHM = 153;
766 enum RSA_R_UNSUPPORTED_MASK_PARAMETER = 154;
767 enum RSA_R_UNSUPPORTED_SIGNATURE_TYPE = 155;
768 enum RSA_R_VALUE_MISSING = 147;
769 enum RSA_R_WRONG_SIGNATURE_LENGTH = 119;