diff options
Diffstat (limited to 'src/lib/libcrypto/rsa/rsa.h')
-rw-r--r-- | src/lib/libcrypto/rsa/rsa.h | 150 |
1 files changed, 72 insertions, 78 deletions
diff --git a/src/lib/libcrypto/rsa/rsa.h b/src/lib/libcrypto/rsa/rsa.h index bda636a365..030a6c88e5 100644 --- a/src/lib/libcrypto/rsa/rsa.h +++ b/src/lib/libcrypto/rsa/rsa.h | |||
@@ -59,13 +59,16 @@ | |||
59 | #ifndef HEADER_RSA_H | 59 | #ifndef HEADER_RSA_H |
60 | #define HEADER_RSA_H | 60 | #define HEADER_RSA_H |
61 | 61 | ||
62 | #ifndef NO_BIO | 62 | #include <openssl/asn1.h> |
63 | |||
64 | #ifndef OPENSSL_NO_BIO | ||
63 | #include <openssl/bio.h> | 65 | #include <openssl/bio.h> |
64 | #endif | 66 | #endif |
65 | #include <openssl/bn.h> | 67 | #include <openssl/bn.h> |
66 | #include <openssl/crypto.h> | 68 | #include <openssl/crypto.h> |
69 | #include <openssl/ossl_typ.h> | ||
67 | 70 | ||
68 | #ifdef NO_RSA | 71 | #ifdef OPENSSL_NO_RSA |
69 | #error RSA is disabled. | 72 | #error RSA is disabled. |
70 | #endif | 73 | #endif |
71 | 74 | ||
@@ -78,16 +81,20 @@ typedef struct rsa_st RSA; | |||
78 | typedef struct rsa_meth_st | 81 | typedef struct rsa_meth_st |
79 | { | 82 | { |
80 | const char *name; | 83 | const char *name; |
81 | int (*rsa_pub_enc)(int flen,unsigned char *from,unsigned char *to, | 84 | int (*rsa_pub_enc)(int flen,const unsigned char *from, |
85 | unsigned char *to, | ||
82 | RSA *rsa,int padding); | 86 | RSA *rsa,int padding); |
83 | int (*rsa_pub_dec)(int flen,unsigned char *from,unsigned char *to, | 87 | int (*rsa_pub_dec)(int flen,const unsigned char *from, |
88 | unsigned char *to, | ||
84 | RSA *rsa,int padding); | 89 | RSA *rsa,int padding); |
85 | int (*rsa_priv_enc)(int flen,unsigned char *from,unsigned char *to, | 90 | int (*rsa_priv_enc)(int flen,const unsigned char *from, |
91 | unsigned char *to, | ||
86 | RSA *rsa,int padding); | 92 | RSA *rsa,int padding); |
87 | int (*rsa_priv_dec)(int flen,unsigned char *from,unsigned char *to, | 93 | int (*rsa_priv_dec)(int flen,const unsigned char *from, |
94 | unsigned char *to, | ||
88 | RSA *rsa,int padding); | 95 | RSA *rsa,int padding); |
89 | int (*rsa_mod_exp)(BIGNUM *r0,BIGNUM *I,RSA *rsa); /* Can be null */ | 96 | int (*rsa_mod_exp)(BIGNUM *r0,const BIGNUM *I,RSA *rsa); /* Can be null */ |
90 | int (*bn_mod_exp)(BIGNUM *r, BIGNUM *a, const BIGNUM *p, | 97 | int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
91 | const BIGNUM *m, BN_CTX *ctx, | 98 | const BIGNUM *m, BN_CTX *ctx, |
92 | BN_MONT_CTX *m_ctx); /* Can be null */ | 99 | BN_MONT_CTX *m_ctx); /* Can be null */ |
93 | int (*init)(RSA *rsa); /* called at new */ | 100 | int (*init)(RSA *rsa); /* called at new */ |
@@ -101,10 +108,12 @@ typedef struct rsa_meth_st | |||
101 | * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER | 108 | * compatibility this functionality is only enabled if the RSA_FLAG_SIGN_VER |
102 | * option is set in 'flags'. | 109 | * option is set in 'flags'. |
103 | */ | 110 | */ |
104 | int (*rsa_sign)(int type, unsigned char *m, unsigned int m_len, | 111 | int (*rsa_sign)(int type, |
105 | unsigned char *sigret, unsigned int *siglen, RSA *rsa); | 112 | const unsigned char *m, unsigned int m_length, |
106 | int (*rsa_verify)(int dtype, unsigned char *m, unsigned int m_len, | 113 | unsigned char *sigret, unsigned int *siglen, const RSA *rsa); |
107 | unsigned char *sigbuf, unsigned int siglen, RSA *rsa); | 114 | int (*rsa_verify)(int dtype, |
115 | const unsigned char *m, unsigned int m_length, | ||
116 | unsigned char *sigbuf, unsigned int siglen, const RSA *rsa); | ||
108 | 117 | ||
109 | } RSA_METHOD; | 118 | } RSA_METHOD; |
110 | 119 | ||
@@ -113,12 +122,10 @@ struct rsa_st | |||
113 | /* The first parameter is used to pickup errors where | 122 | /* The first parameter is used to pickup errors where |
114 | * this is passed instead of aEVP_PKEY, it is set to 0 */ | 123 | * this is passed instead of aEVP_PKEY, it is set to 0 */ |
115 | int pad; | 124 | int pad; |
116 | int version; | 125 | long version; |
117 | #if 0 | 126 | const RSA_METHOD *meth; |
118 | RSA_METHOD *meth; | 127 | /* functional reference if 'meth' is ENGINE-provided */ |
119 | #else | 128 | ENGINE *engine; |
120 | struct engine_st *engine; | ||
121 | #endif | ||
122 | BIGNUM *n; | 129 | BIGNUM *n; |
123 | BIGNUM *e; | 130 | BIGNUM *e; |
124 | BIGNUM *d; | 131 | BIGNUM *d; |
@@ -172,121 +179,108 @@ struct rsa_st | |||
172 | #define RSA_get_app_data(s) RSA_get_ex_data(s,0) | 179 | #define RSA_get_app_data(s) RSA_get_ex_data(s,0) |
173 | 180 | ||
174 | RSA * RSA_new(void); | 181 | RSA * RSA_new(void); |
175 | #if 0 | 182 | RSA * RSA_new_method(ENGINE *engine); |
176 | RSA * RSA_new_method(RSA_METHOD *method); | 183 | int RSA_size(const RSA *); |
177 | #else | ||
178 | RSA * RSA_new_method(struct engine_st *engine); | ||
179 | #endif | ||
180 | int RSA_size(RSA *); | ||
181 | RSA * RSA_generate_key(int bits, unsigned long e,void | 184 | RSA * RSA_generate_key(int bits, unsigned long e,void |
182 | (*callback)(int,int,void *),void *cb_arg); | 185 | (*callback)(int,int,void *),void *cb_arg); |
183 | int RSA_check_key(RSA *); | 186 | int RSA_check_key(const RSA *); |
184 | /* next 4 return -1 on error */ | 187 | /* next 4 return -1 on error */ |
185 | int RSA_public_encrypt(int flen, unsigned char *from, | 188 | int RSA_public_encrypt(int flen, const unsigned char *from, |
186 | unsigned char *to, RSA *rsa,int padding); | 189 | unsigned char *to, RSA *rsa,int padding); |
187 | int RSA_private_encrypt(int flen, unsigned char *from, | 190 | int RSA_private_encrypt(int flen, const unsigned char *from, |
188 | unsigned char *to, RSA *rsa,int padding); | 191 | unsigned char *to, RSA *rsa,int padding); |
189 | int RSA_public_decrypt(int flen, unsigned char *from, | 192 | int RSA_public_decrypt(int flen, const unsigned char *from, |
190 | unsigned char *to, RSA *rsa,int padding); | 193 | unsigned char *to, RSA *rsa,int padding); |
191 | int RSA_private_decrypt(int flen, unsigned char *from, | 194 | int RSA_private_decrypt(int flen, const unsigned char *from, |
192 | unsigned char *to, RSA *rsa,int padding); | 195 | unsigned char *to, RSA *rsa,int padding); |
193 | void RSA_free (RSA *r); | 196 | void RSA_free (RSA *r); |
197 | /* "up" the RSA object's reference count */ | ||
198 | int RSA_up_ref(RSA *r); | ||
194 | 199 | ||
195 | int RSA_flags(RSA *r); | 200 | int RSA_flags(const RSA *r); |
196 | 201 | ||
197 | void RSA_set_default_openssl_method(RSA_METHOD *meth); | 202 | void RSA_set_default_method(const RSA_METHOD *meth); |
198 | RSA_METHOD *RSA_get_default_openssl_method(void); | 203 | const RSA_METHOD *RSA_get_default_method(void); |
199 | RSA_METHOD *RSA_get_method(RSA *rsa); | 204 | const RSA_METHOD *RSA_get_method(const RSA *rsa); |
200 | #if 0 | 205 | int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); |
201 | RSA_METHOD *RSA_set_method(RSA *rsa, RSA_METHOD *meth); | ||
202 | #else | ||
203 | int RSA_set_method(RSA *rsa, struct engine_st *engine); | ||
204 | #endif | ||
205 | 206 | ||
206 | /* This function needs the memory locking malloc callbacks to be installed */ | 207 | /* This function needs the memory locking malloc callbacks to be installed */ |
207 | int RSA_memory_lock(RSA *r); | 208 | int RSA_memory_lock(RSA *r); |
208 | 209 | ||
209 | /* If you have RSAref compiled in. */ | ||
210 | RSA_METHOD *RSA_PKCS1_RSAref(void); | ||
211 | |||
212 | /* these are the actual SSLeay RSA functions */ | 210 | /* these are the actual SSLeay RSA functions */ |
213 | RSA_METHOD *RSA_PKCS1_SSLeay(void); | 211 | const RSA_METHOD *RSA_PKCS1_SSLeay(void); |
214 | 212 | ||
215 | RSA_METHOD *RSA_null_method(void); | 213 | const RSA_METHOD *RSA_null_method(void); |
216 | 214 | ||
217 | void ERR_load_RSA_strings(void ); | 215 | DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey) |
216 | DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey) | ||
218 | 217 | ||
219 | RSA * d2i_RSAPublicKey(RSA **a, unsigned char **pp, long length); | 218 | #ifndef OPENSSL_NO_FP_API |
220 | int i2d_RSAPublicKey(RSA *a, unsigned char **pp); | 219 | int RSA_print_fp(FILE *fp, const RSA *r,int offset); |
221 | RSA * d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length); | ||
222 | int i2d_RSAPrivateKey(RSA *a, unsigned char **pp); | ||
223 | #ifndef NO_FP_API | ||
224 | int RSA_print_fp(FILE *fp, RSA *r,int offset); | ||
225 | #endif | 220 | #endif |
226 | 221 | ||
227 | #ifndef NO_BIO | 222 | #ifndef OPENSSL_NO_BIO |
228 | int RSA_print(BIO *bp, RSA *r,int offset); | 223 | int RSA_print(BIO *bp, const RSA *r,int offset); |
229 | #endif | 224 | #endif |
230 | 225 | ||
231 | int i2d_RSA_NET(RSA *a, unsigned char **pp, int (*cb)(), int sgckey); | 226 | int i2d_RSA_NET(const RSA *a, unsigned char **pp, int (*cb)(), int sgckey); |
232 | RSA *d2i_RSA_NET(RSA **a, unsigned char **pp, long length, int (*cb)(), int sgckey); | 227 | RSA *d2i_RSA_NET(RSA **a, const unsigned char **pp, long length, int (*cb)(), int sgckey); |
233 | RSA *d2i_RSA_NET_2(RSA **a, unsigned char **pp, long length, int (*cb)(), int sgckey); | ||
234 | 228 | ||
235 | int i2d_Netscape_RSA(RSA *a, unsigned char **pp, int (*cb)()); | 229 | int i2d_Netscape_RSA(const RSA *a, unsigned char **pp, int (*cb)()); |
236 | RSA *d2i_Netscape_RSA(RSA **a, unsigned char **pp, long length, int (*cb)()); | 230 | RSA *d2i_Netscape_RSA(RSA **a, const unsigned char **pp, long length, int (*cb)()); |
237 | /* Naughty internal function required elsewhere, to handle a MS structure | ||
238 | * that is the same as the netscape one :-) */ | ||
239 | RSA *d2i_Netscape_RSA_2(RSA **a, unsigned char **pp, long length, int (*cb)()); | ||
240 | 231 | ||
241 | /* The following 2 functions sign and verify a X509_SIG ASN1 object | 232 | /* The following 2 functions sign and verify a X509_SIG ASN1 object |
242 | * inside PKCS#1 padded RSA encryption */ | 233 | * inside PKCS#1 padded RSA encryption */ |
243 | int RSA_sign(int type, unsigned char *m, unsigned int m_len, | 234 | int RSA_sign(int type, const unsigned char *m, unsigned int m_length, |
244 | unsigned char *sigret, unsigned int *siglen, RSA *rsa); | 235 | unsigned char *sigret, unsigned int *siglen, RSA *rsa); |
245 | int RSA_verify(int type, unsigned char *m, unsigned int m_len, | 236 | int RSA_verify(int type, const unsigned char *m, unsigned int m_length, |
246 | unsigned char *sigbuf, unsigned int siglen, RSA *rsa); | 237 | unsigned char *sigbuf, unsigned int siglen, RSA *rsa); |
247 | 238 | ||
248 | /* The following 2 function sign and verify a ASN1_OCTET_STRING | 239 | /* The following 2 function sign and verify a ASN1_OCTET_STRING |
249 | * object inside PKCS#1 padded RSA encryption */ | 240 | * object inside PKCS#1 padded RSA encryption */ |
250 | int RSA_sign_ASN1_OCTET_STRING(int type, unsigned char *m, unsigned int m_len, | 241 | int RSA_sign_ASN1_OCTET_STRING(int type, |
242 | const unsigned char *m, unsigned int m_length, | ||
251 | unsigned char *sigret, unsigned int *siglen, RSA *rsa); | 243 | unsigned char *sigret, unsigned int *siglen, RSA *rsa); |
252 | int RSA_verify_ASN1_OCTET_STRING(int type, unsigned char *m, unsigned int m_len, | 244 | int RSA_verify_ASN1_OCTET_STRING(int type, |
245 | const unsigned char *m, unsigned int m_length, | ||
253 | unsigned char *sigbuf, unsigned int siglen, RSA *rsa); | 246 | unsigned char *sigbuf, unsigned int siglen, RSA *rsa); |
254 | 247 | ||
255 | int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); | 248 | int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); |
256 | void RSA_blinding_off(RSA *rsa); | 249 | void RSA_blinding_off(RSA *rsa); |
257 | 250 | ||
258 | int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen, | 251 | int RSA_padding_add_PKCS1_type_1(unsigned char *to,int tlen, |
259 | unsigned char *f,int fl); | 252 | const unsigned char *f,int fl); |
260 | int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen, | 253 | int RSA_padding_check_PKCS1_type_1(unsigned char *to,int tlen, |
261 | unsigned char *f,int fl,int rsa_len); | 254 | const unsigned char *f,int fl,int rsa_len); |
262 | int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen, | 255 | int RSA_padding_add_PKCS1_type_2(unsigned char *to,int tlen, |
263 | unsigned char *f,int fl); | 256 | const unsigned char *f,int fl); |
264 | int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen, | 257 | int RSA_padding_check_PKCS1_type_2(unsigned char *to,int tlen, |
265 | unsigned char *f,int fl,int rsa_len); | 258 | const unsigned char *f,int fl,int rsa_len); |
266 | int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen, | 259 | int RSA_padding_add_PKCS1_OAEP(unsigned char *to,int tlen, |
267 | unsigned char *f,int fl,unsigned char *p, | 260 | const unsigned char *f,int fl, |
268 | int pl); | 261 | const unsigned char *p,int pl); |
269 | int RSA_padding_check_PKCS1_OAEP(unsigned char *to,int tlen, | 262 | int RSA_padding_check_PKCS1_OAEP(unsigned char *to,int tlen, |
270 | unsigned char *f,int fl,int rsa_len, | 263 | const unsigned char *f,int fl,int rsa_len, |
271 | unsigned char *p,int pl); | 264 | const unsigned char *p,int pl); |
272 | int RSA_padding_add_SSLv23(unsigned char *to,int tlen, | 265 | int RSA_padding_add_SSLv23(unsigned char *to,int tlen, |
273 | unsigned char *f,int fl); | 266 | const unsigned char *f,int fl); |
274 | int RSA_padding_check_SSLv23(unsigned char *to,int tlen, | 267 | int RSA_padding_check_SSLv23(unsigned char *to,int tlen, |
275 | unsigned char *f,int fl,int rsa_len); | 268 | const unsigned char *f,int fl,int rsa_len); |
276 | int RSA_padding_add_none(unsigned char *to,int tlen, | 269 | int RSA_padding_add_none(unsigned char *to,int tlen, |
277 | unsigned char *f,int fl); | 270 | const unsigned char *f,int fl); |
278 | int RSA_padding_check_none(unsigned char *to,int tlen, | 271 | int RSA_padding_check_none(unsigned char *to,int tlen, |
279 | unsigned char *f,int fl,int rsa_len); | 272 | const unsigned char *f,int fl,int rsa_len); |
280 | 273 | ||
281 | int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, | 274 | int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func, |
282 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); | 275 | CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func); |
283 | int RSA_set_ex_data(RSA *r,int idx,void *arg); | 276 | int RSA_set_ex_data(RSA *r,int idx,void *arg); |
284 | void *RSA_get_ex_data(RSA *r, int idx); | 277 | void *RSA_get_ex_data(const RSA *r, int idx); |
285 | 278 | ||
286 | /* BEGIN ERROR CODES */ | 279 | /* BEGIN ERROR CODES */ |
287 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 280 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
288 | * made after this point may be overwritten when the script is next run. | 281 | * made after this point may be overwritten when the script is next run. |
289 | */ | 282 | */ |
283 | void ERR_load_RSA_strings(void); | ||
290 | 284 | ||
291 | /* Error codes for the RSA functions. */ | 285 | /* Error codes for the RSA functions. */ |
292 | 286 | ||
@@ -328,6 +322,7 @@ void *RSA_get_ex_data(RSA *r, int idx); | |||
328 | #define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 | 322 | #define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 |
329 | #define RSA_R_DATA_TOO_LARGE 109 | 323 | #define RSA_R_DATA_TOO_LARGE 109 |
330 | #define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 | 324 | #define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 |
325 | #define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132 | ||
331 | #define RSA_R_DATA_TOO_SMALL 111 | 326 | #define RSA_R_DATA_TOO_SMALL 111 |
332 | #define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 | 327 | #define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 |
333 | #define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 | 328 | #define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 |
@@ -354,4 +349,3 @@ void *RSA_get_ex_data(RSA *r, int idx); | |||
354 | } | 349 | } |
355 | #endif | 350 | #endif |
356 | #endif | 351 | #endif |
357 | |||