summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rsa/rsa.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa.h')
-rw-r--r--src/lib/libcrypto/rsa/rsa.h96
1 files changed, 27 insertions, 69 deletions
diff --git a/src/lib/libcrypto/rsa/rsa.h b/src/lib/libcrypto/rsa/rsa.h
index 6b5e4f8a9a..dbed701e89 100644
--- a/src/lib/libcrypto/rsa/rsa.h
+++ b/src/lib/libcrypto/rsa/rsa.h
@@ -64,25 +64,25 @@
64#ifndef OPENSSL_NO_BIO 64#ifndef OPENSSL_NO_BIO
65#include <openssl/bio.h> 65#include <openssl/bio.h>
66#endif 66#endif
67#include <openssl/bn.h>
67#include <openssl/crypto.h> 68#include <openssl/crypto.h>
68#include <openssl/ossl_typ.h> 69#include <openssl/ossl_typ.h>
69#ifndef OPENSSL_NO_DEPRECATED
70#include <openssl/bn.h>
71#endif
72 70
73#ifdef OPENSSL_NO_RSA 71#ifdef OPENSSL_NO_RSA
74#error RSA is disabled. 72#error RSA is disabled.
75#endif 73#endif
76 74
75#if defined(OPENSSL_FIPS)
76#define FIPS_RSA_SIZE_T int
77#endif
78
77#ifdef __cplusplus 79#ifdef __cplusplus
78extern "C" { 80extern "C" {
79#endif 81#endif
80 82
81/* Declared already in ossl_typ.h */ 83typedef struct rsa_st RSA;
82/* typedef struct rsa_st RSA; */
83/* typedef struct rsa_meth_st RSA_METHOD; */
84 84
85struct rsa_meth_st 85typedef struct rsa_meth_st
86 { 86 {
87 const char *name; 87 const char *name;
88 int (*rsa_pub_enc)(int flen,const unsigned char *from, 88 int (*rsa_pub_enc)(int flen,const unsigned char *from,
@@ -97,7 +97,7 @@ struct rsa_meth_st
97 int (*rsa_priv_dec)(int flen,const unsigned char *from, 97 int (*rsa_priv_dec)(int flen,const unsigned char *from,
98 unsigned char *to, 98 unsigned char *to,
99 RSA *rsa,int padding); 99 RSA *rsa,int padding);
100 int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa,BN_CTX *ctx); /* Can be null */ 100 int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa); /* Can be null */
101 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, 101 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
102 const BIGNUM *m, BN_CTX *ctx, 102 const BIGNUM *m, BN_CTX *ctx,
103 BN_MONT_CTX *m_ctx); /* Can be null */ 103 BN_MONT_CTX *m_ctx); /* Can be null */
@@ -118,12 +118,8 @@ struct rsa_meth_st
118 int (*rsa_verify)(int dtype, 118 int (*rsa_verify)(int dtype,
119 const unsigned char *m, unsigned int m_length, 119 const unsigned char *m, unsigned int m_length,
120 unsigned char *sigbuf, unsigned int siglen, const RSA *rsa); 120 unsigned char *sigbuf, unsigned int siglen, const RSA *rsa);
121/* If this callback is NULL, the builtin software RSA key-gen will be used. This 121
122 * is for behavioural compatibility whilst the code gets rewired, but one day 122 } RSA_METHOD;
123 * it would be nice to assume there are no such things as "builtin software"
124 * implementations. */
125 int (*rsa_keygen)(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
126 };
127 123
128struct rsa_st 124struct rsa_st
129 { 125 {
@@ -156,19 +152,12 @@ struct rsa_st
156 * NULL */ 152 * NULL */
157 char *bignum_data; 153 char *bignum_data;
158 BN_BLINDING *blinding; 154 BN_BLINDING *blinding;
159 BN_BLINDING *mt_blinding;
160 }; 155 };
161 156
162#ifndef OPENSSL_RSA_MAX_MODULUS_BITS 157#define OPENSSL_RSA_MAX_MODULUS_BITS 16384
163# define OPENSSL_RSA_MAX_MODULUS_BITS 16384
164#endif
165 158
166#ifndef OPENSSL_RSA_SMALL_MODULUS_BITS 159#define OPENSSL_RSA_SMALL_MODULUS_BITS 3072
167# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072 160#define OPENSSL_RSA_MAX_PUBEXP_BITS 64 /* exponent limit enforced for "small" modulus only */
168#endif
169#ifndef OPENSSL_RSA_MAX_PUBEXP_BITS
170# define OPENSSL_RSA_MAX_PUBEXP_BITS 64 /* exponent limit enforced for "large" modulus only */
171#endif
172 161
173#define RSA_3 0x3L 162#define RSA_3 0x3L
174#define RSA_F4 0x10001L 163#define RSA_F4 0x10001L
@@ -195,27 +184,13 @@ struct rsa_st
195 * default (ignoring RSA_FLAG_BLINDING), 184 * default (ignoring RSA_FLAG_BLINDING),
196 * but other engines might not need it 185 * but other engines might not need it
197 */ 186 */
198#define RSA_FLAG_NO_CONSTTIME 0x0100 /* new with 0.9.8f; the built-in RSA 187#define RSA_FLAG_NO_EXP_CONSTTIME 0x0100 /* new with 0.9.7h; the built-in RSA
199 * implementation now uses constant time
200 * operations by default in private key operations,
201 * e.g., constant time modular exponentiation,
202 * modular inverse without leaking branches,
203 * division without leaking branches. This
204 * flag disables these constant time
205 * operations and results in faster RSA
206 * private key operations.
207 */
208#ifndef OPENSSL_NO_DEPRECATED
209#define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME /* deprecated name for the flag*/
210 /* new with 0.9.7h; the built-in RSA
211 * implementation now uses constant time 188 * implementation now uses constant time
212 * modular exponentiation for secret exponents 189 * modular exponentiation for secret exponents
213 * by default. This flag causes the 190 * by default. This flag causes the
214 * faster variable sliding window method to 191 * faster variable sliding window method to
215 * be used for all exponents. 192 * be used for all exponents.
216 */ 193 */
217#endif
218
219 194
220#define RSA_PKCS1_PADDING 1 195#define RSA_PKCS1_PADDING 1
221#define RSA_SSLV23_PADDING 2 196#define RSA_SSLV23_PADDING 2
@@ -231,17 +206,18 @@ struct rsa_st
231RSA * RSA_new(void); 206RSA * RSA_new(void);
232RSA * RSA_new_method(ENGINE *engine); 207RSA * RSA_new_method(ENGINE *engine);
233int RSA_size(const RSA *); 208int RSA_size(const RSA *);
234
235/* Deprecated version */
236#ifndef OPENSSL_NO_DEPRECATED
237RSA * RSA_generate_key(int bits, unsigned long e,void 209RSA * RSA_generate_key(int bits, unsigned long e,void
238 (*callback)(int,int,void *),void *cb_arg); 210 (*callback)(int,int,void *),void *cb_arg);
239#endif /* !defined(OPENSSL_NO_DEPRECATED) */
240
241/* New version */
242int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb);
243
244int RSA_check_key(const RSA *); 211int RSA_check_key(const RSA *);
212#ifdef OPENSSL_FIPS
213int RSA_X931_derive(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1, BIGNUM *q2,
214 void (*cb)(int, int, void *), void *cb_arg,
215 const BIGNUM *Xp1, const BIGNUM *Xp2, const BIGNUM *Xp,
216 const BIGNUM *Xq1, const BIGNUM *Xq2, const BIGNUM *Xq,
217 const BIGNUM *e);
218RSA *RSA_X931_generate_key(int bits, const BIGNUM *e,
219 void (*cb)(int,int,void *), void *cb_arg);
220#endif
245 /* next 4 return -1 on error */ 221 /* next 4 return -1 on error */
246int RSA_public_encrypt(int flen, const unsigned char *from, 222int RSA_public_encrypt(int flen, const unsigned char *from,
247 unsigned char *to, RSA *rsa,int padding); 223 unsigned char *to, RSA *rsa,int padding);
@@ -281,19 +257,11 @@ int RSA_print_fp(FILE *fp, const RSA *r,int offset);
281int RSA_print(BIO *bp, const RSA *r,int offset); 257int RSA_print(BIO *bp, const RSA *r,int offset);
282#endif 258#endif
283 259
284int i2d_RSA_NET(const RSA *a, unsigned char **pp, 260int i2d_RSA_NET(const RSA *a, unsigned char **pp, int (*cb)(), int sgckey);
285 int (*cb)(char *buf, int len, const char *prompt, int verify), 261RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, int (*cb)(), int sgckey);
286 int sgckey);
287RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length,
288 int (*cb)(char *buf, int len, const char *prompt, int verify),
289 int sgckey);
290 262
291int i2d_Netscape_RSA(const RSA *a, unsigned char **pp, 263int i2d_Netscape_RSA(const RSA *a, unsigned char **pp, int (*cb)());
292 int (*cb)(char *buf, int len, const char *prompt, 264RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length, int (*cb)());
293 int verify));
294RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length,
295 int (*cb)(char *buf, int len, const char *prompt,
296 int verify));
297 265
298/* The following 2 functions sign and verify a X509_SIG ASN1 object 266/* The following 2 functions sign and verify a X509_SIG ASN1 object
299 * inside PKCS#1 padded RSA encryption */ 267 * inside PKCS#1 padded RSA encryption */
@@ -313,7 +281,6 @@ int RSA_verify_ASN1_OCTET_STRING(int type,
313 281
314int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); 282int RSA_blinding_on(RSA *rsa, BN_CTX *ctx);
315void RSA_blinding_off(RSA *rsa); 283void RSA_blinding_off(RSA *rsa);
316BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx);
317 284
318int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen, 285int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen,
319 const unsigned char *f,int fl); 286 const unsigned char *f,int fl);
@@ -369,21 +336,14 @@ void ERR_load_RSA_strings(void);
369 336
370/* Function codes. */ 337/* Function codes. */
371#define RSA_F_MEMORY_LOCK 100 338#define RSA_F_MEMORY_LOCK 100
372#define RSA_F_RSA_BUILTIN_KEYGEN 129
373#define RSA_F_RSA_CHECK_KEY 123 339#define RSA_F_RSA_CHECK_KEY 123
374#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 101 340#define RSA_F_RSA_EAY_PRIVATE_DECRYPT 101
375#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 102 341#define RSA_F_RSA_EAY_PRIVATE_ENCRYPT 102
376#define RSA_F_RSA_EAY_PUBLIC_DECRYPT 103 342#define RSA_F_RSA_EAY_PUBLIC_DECRYPT 103
377#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104 343#define RSA_F_RSA_EAY_PUBLIC_ENCRYPT 104
378#define RSA_F_RSA_GENERATE_KEY 105 344#define RSA_F_RSA_GENERATE_KEY 105
379#define RSA_F_RSA_MEMORY_LOCK 130
380#define RSA_F_RSA_NEW_METHOD 106 345#define RSA_F_RSA_NEW_METHOD 106
381#define RSA_F_RSA_NULL 124 346#define RSA_F_RSA_NULL 124
382#define RSA_F_RSA_NULL_MOD_EXP 131
383#define RSA_F_RSA_NULL_PRIVATE_DECRYPT 132
384#define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 133
385#define RSA_F_RSA_NULL_PUBLIC_DECRYPT 134
386#define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 135
387#define RSA_F_RSA_PADDING_ADD_NONE 107 347#define RSA_F_RSA_PADDING_ADD_NONE 107
388#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121 348#define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121
389#define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 125 349#define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 125
@@ -399,7 +359,6 @@ void ERR_load_RSA_strings(void);
399#define RSA_F_RSA_PADDING_CHECK_X931 128 359#define RSA_F_RSA_PADDING_CHECK_X931 128
400#define RSA_F_RSA_PRINT 115 360#define RSA_F_RSA_PRINT 115
401#define RSA_F_RSA_PRINT_FP 116 361#define RSA_F_RSA_PRINT_FP 116
402#define RSA_F_RSA_SETUP_BLINDING 136
403#define RSA_F_RSA_SIGN 117 362#define RSA_F_RSA_SIGN 117
404#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118 363#define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118
405#define RSA_F_RSA_VERIFY 119 364#define RSA_F_RSA_VERIFY 119
@@ -433,7 +392,6 @@ void ERR_load_RSA_strings(void);
433#define RSA_R_KEY_SIZE_TOO_SMALL 120 392#define RSA_R_KEY_SIZE_TOO_SMALL 120
434#define RSA_R_LAST_OCTET_INVALID 134 393#define RSA_R_LAST_OCTET_INVALID 134
435#define RSA_R_MODULUS_TOO_LARGE 105 394#define RSA_R_MODULUS_TOO_LARGE 105
436#define RSA_R_NO_PUBLIC_EXPONENT 140
437#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 395#define RSA_R_NULL_BEFORE_BLOCK_MISSING 113
438#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127 396#define RSA_R_N_DOES_NOT_EQUAL_P_Q 127
439#define RSA_R_OAEP_DECODING_ERROR 121 397#define RSA_R_OAEP_DECODING_ERROR 121