diff options
Diffstat (limited to 'src/lib/libssl/src/crypto/bn/bn.h')
-rw-r--r-- | src/lib/libssl/src/crypto/bn/bn.h | 177 |
1 files changed, 102 insertions, 75 deletions
diff --git a/src/lib/libssl/src/crypto/bn/bn.h b/src/lib/libssl/src/crypto/bn/bn.h index b232c2ceae..d25b49c9d8 100644 --- a/src/lib/libssl/src/crypto/bn/bn.h +++ b/src/lib/libssl/src/crypto/bn/bn.h | |||
@@ -59,24 +59,22 @@ | |||
59 | #ifndef HEADER_BN_H | 59 | #ifndef HEADER_BN_H |
60 | #define HEADER_BN_H | 60 | #define HEADER_BN_H |
61 | 61 | ||
62 | #ifndef NO_FP_API | 62 | #include <openssl/e_os2.h> |
63 | #ifndef OPENSSL_NO_FP_API | ||
63 | #include <stdio.h> /* FILE */ | 64 | #include <stdio.h> /* FILE */ |
64 | #endif | 65 | #endif |
65 | #include <openssl/opensslconf.h> | ||
66 | 66 | ||
67 | #ifdef __cplusplus | 67 | #ifdef __cplusplus |
68 | extern "C" { | 68 | extern "C" { |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | #ifdef VMS | 71 | #ifdef OPENSSL_SYS_VMS |
72 | #undef BN_LLONG /* experimental, so far... */ | 72 | #undef BN_LLONG /* experimental, so far... */ |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | #define BN_MUL_COMBA | 75 | #define BN_MUL_COMBA |
76 | #define BN_SQR_COMBA | 76 | #define BN_SQR_COMBA |
77 | #define BN_RECURSION | 77 | #define BN_RECURSION |
78 | #define RECP_MUL_MOD | ||
79 | #define MONT_MUL_MOD | ||
80 | 78 | ||
81 | /* This next option uses the C libraries (2 word)/(1 word) function. | 79 | /* This next option uses the C libraries (2 word)/(1 word) function. |
82 | * If it is not defined, I use my C version (which is slower). | 80 | * If it is not defined, I use my C version (which is slower). |
@@ -89,8 +87,11 @@ extern "C" { | |||
89 | * For machines with only one compiler (or shared libraries), this should | 87 | * For machines with only one compiler (or shared libraries), this should |
90 | * be on. Again this in only really a problem on machines | 88 | * be on. Again this in only really a problem on machines |
91 | * using "long long's", are 32bit, and are not using my assembler code. */ | 89 | * using "long long's", are 32bit, and are not using my assembler code. */ |
92 | #if defined(MSDOS) || defined(WINDOWS) || defined(WIN32) || defined(linux) | 90 | #if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \ |
93 | #define BN_DIV2W | 91 | defined(OPENSSL_SYS_WIN32) || defined(linux) |
92 | # ifndef BN_DIV2W | ||
93 | # define BN_DIV2W | ||
94 | # endif | ||
94 | #endif | 95 | #endif |
95 | 96 | ||
96 | /* assuming long is 64bit - this is the DEC Alpha | 97 | /* assuming long is 64bit - this is the DEC Alpha |
@@ -142,7 +143,7 @@ extern "C" { | |||
142 | #endif | 143 | #endif |
143 | 144 | ||
144 | #ifdef THIRTY_TWO_BIT | 145 | #ifdef THIRTY_TWO_BIT |
145 | #if defined(WIN32) && !defined(__GNUC__) | 146 | #if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) |
146 | #define BN_ULLONG unsigned _int64 | 147 | #define BN_ULLONG unsigned _int64 |
147 | #else | 148 | #else |
148 | #define BN_ULLONG unsigned long long | 149 | #define BN_ULLONG unsigned long long |
@@ -153,7 +154,7 @@ extern "C" { | |||
153 | #define BN_BYTES 4 | 154 | #define BN_BYTES 4 |
154 | #define BN_BITS2 32 | 155 | #define BN_BITS2 32 |
155 | #define BN_BITS4 16 | 156 | #define BN_BITS4 16 |
156 | #ifdef WIN32 | 157 | #ifdef OPENSSL_SYS_WIN32 |
157 | /* VC++ doesn't like the LL suffix */ | 158 | /* VC++ doesn't like the LL suffix */ |
158 | #define BN_MASK (0xffffffffffffffffL) | 159 | #define BN_MASK (0xffffffffffffffffL) |
159 | #else | 160 | #else |
@@ -238,18 +239,8 @@ typedef struct bignum_st | |||
238 | int flags; | 239 | int flags; |
239 | } BIGNUM; | 240 | } BIGNUM; |
240 | 241 | ||
241 | /* Used for temp variables */ | 242 | /* Used for temp variables (declaration hidden in bn_lcl.h) */ |
242 | #define BN_CTX_NUM 16 | 243 | typedef struct bignum_ctx BN_CTX; |
243 | #define BN_CTX_NUM_POS 12 | ||
244 | typedef struct bignum_ctx | ||
245 | { | ||
246 | int tos; | ||
247 | BIGNUM bn[BN_CTX_NUM]; | ||
248 | int flags; | ||
249 | int depth; | ||
250 | int pos[BN_CTX_NUM_POS]; | ||
251 | int too_many; | ||
252 | } BN_CTX; | ||
253 | 244 | ||
254 | typedef struct bn_blinding_st | 245 | typedef struct bn_blinding_st |
255 | { | 246 | { |
@@ -283,9 +274,6 @@ typedef struct bn_recp_ctx_st | |||
283 | int flags; | 274 | int flags; |
284 | } BN_RECP_CTX; | 275 | } BN_RECP_CTX; |
285 | 276 | ||
286 | #define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ | ||
287 | r,a,&((mont)->RR),(mont),ctx) | ||
288 | |||
289 | #define BN_prime_checks 0 /* default: select number of iterations | 277 | #define BN_prime_checks 0 /* default: select number of iterations |
290 | based on the size of the number */ | 278 | based on the size of the number */ |
291 | 279 | ||
@@ -308,17 +296,22 @@ typedef struct bn_recp_ctx_st | |||
308 | /* b >= 100 */ 27) | 296 | /* b >= 100 */ 27) |
309 | 297 | ||
310 | #define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) | 298 | #define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) |
311 | #define BN_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) | 299 | |
312 | #define BN_is_zero(a) (((a)->top == 0) || BN_is_word(a,0)) | 300 | /* Note that BN_abs_is_word does not work reliably for w == 0 */ |
313 | #define BN_is_one(a) (BN_is_word((a),1)) | 301 | #define BN_abs_is_word(a,w) (((a)->top == 1) && ((a)->d[0] == (BN_ULONG)(w))) |
314 | #define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) | 302 | #define BN_is_zero(a) (((a)->top == 0) || BN_abs_is_word(a,0)) |
303 | #define BN_is_one(a) (BN_abs_is_word((a),1) && !(a)->neg) | ||
304 | #define BN_is_word(a,w) ((w) ? BN_abs_is_word((a),(w)) && !(a)->neg : \ | ||
305 | BN_is_zero((a))) | ||
306 | #define BN_is_odd(a) (((a)->top > 0) && ((a)->d[0] & 1)) | ||
307 | |||
315 | #define BN_one(a) (BN_set_word((a),1)) | 308 | #define BN_one(a) (BN_set_word((a),1)) |
316 | #define BN_zero(a) (BN_set_word((a),0)) | 309 | #define BN_zero(a) (BN_set_word((a),0)) |
317 | 310 | ||
318 | /*#define BN_ascii2bn(a) BN_hex2bn(a) */ | 311 | /*#define BN_ascii2bn(a) BN_hex2bn(a) */ |
319 | /*#define BN_bn2ascii(a) BN_bn2hex(a) */ | 312 | /*#define BN_bn2ascii(a) BN_bn2hex(a) */ |
320 | 313 | ||
321 | BIGNUM *BN_value_one(void); | 314 | const BIGNUM *BN_value_one(void); |
322 | char * BN_options(void); | 315 | char * BN_options(void); |
323 | BN_CTX *BN_CTX_new(void); | 316 | BN_CTX *BN_CTX_new(void); |
324 | void BN_CTX_init(BN_CTX *c); | 317 | void BN_CTX_init(BN_CTX *c); |
@@ -329,51 +322,70 @@ void BN_CTX_end(BN_CTX *ctx); | |||
329 | int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); | 322 | int BN_rand(BIGNUM *rnd, int bits, int top,int bottom); |
330 | int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom); | 323 | int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom); |
331 | int BN_rand_range(BIGNUM *rnd, BIGNUM *range); | 324 | int BN_rand_range(BIGNUM *rnd, BIGNUM *range); |
325 | int BN_pseudo_rand_range(BIGNUM *rnd, BIGNUM *range); | ||
332 | int BN_num_bits(const BIGNUM *a); | 326 | int BN_num_bits(const BIGNUM *a); |
333 | int BN_num_bits_word(BN_ULONG); | 327 | int BN_num_bits_word(BN_ULONG); |
334 | BIGNUM *BN_new(void); | 328 | BIGNUM *BN_new(void); |
335 | void BN_init(BIGNUM *); | 329 | void BN_init(BIGNUM *); |
336 | void BN_clear_free(BIGNUM *a); | 330 | void BN_clear_free(BIGNUM *a); |
337 | BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); | 331 | BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); |
332 | void BN_swap(BIGNUM *a, BIGNUM *b); | ||
338 | BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret); | 333 | BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret); |
339 | int BN_bn2bin(const BIGNUM *a, unsigned char *to); | 334 | int BN_bn2bin(const BIGNUM *a, unsigned char *to); |
340 | BIGNUM *BN_mpi2bn(unsigned char *s,int len,BIGNUM *ret); | 335 | BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret); |
341 | int BN_bn2mpi(const BIGNUM *a, unsigned char *to); | 336 | int BN_bn2mpi(const BIGNUM *a, unsigned char *to); |
342 | int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); | 337 | int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); |
343 | int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); | 338 | int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); |
344 | int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); | 339 | int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); |
345 | int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); | 340 | int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); |
346 | int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); | 341 | int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); |
342 | int BN_sqr(BIGNUM *r, const BIGNUM *a,BN_CTX *ctx); | ||
343 | |||
347 | int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, | 344 | int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, |
348 | BN_CTX *ctx); | 345 | BN_CTX *ctx); |
349 | int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx); | 346 | #define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) |
350 | int BN_sqr(BIGNUM *r, BIGNUM *a,BN_CTX *ctx); | 347 | int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); |
348 | int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); | ||
349 | int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); | ||
350 | int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); | ||
351 | int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); | ||
352 | int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | ||
353 | const BIGNUM *m, BN_CTX *ctx); | ||
354 | int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); | ||
355 | int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); | ||
356 | int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); | ||
357 | int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx); | ||
358 | int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m); | ||
359 | |||
351 | BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); | 360 | BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); |
352 | BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); | 361 | BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); |
353 | int BN_mul_word(BIGNUM *a, BN_ULONG w); | 362 | int BN_mul_word(BIGNUM *a, BN_ULONG w); |
354 | int BN_add_word(BIGNUM *a, BN_ULONG w); | 363 | int BN_add_word(BIGNUM *a, BN_ULONG w); |
355 | int BN_sub_word(BIGNUM *a, BN_ULONG w); | 364 | int BN_sub_word(BIGNUM *a, BN_ULONG w); |
356 | int BN_set_word(BIGNUM *a, BN_ULONG w); | 365 | int BN_set_word(BIGNUM *a, BN_ULONG w); |
357 | BN_ULONG BN_get_word(BIGNUM *a); | 366 | BN_ULONG BN_get_word(const BIGNUM *a); |
367 | |||
358 | int BN_cmp(const BIGNUM *a, const BIGNUM *b); | 368 | int BN_cmp(const BIGNUM *a, const BIGNUM *b); |
359 | void BN_free(BIGNUM *a); | 369 | void BN_free(BIGNUM *a); |
360 | int BN_is_bit_set(const BIGNUM *a, int n); | 370 | int BN_is_bit_set(const BIGNUM *a, int n); |
361 | int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); | 371 | int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); |
362 | int BN_lshift1(BIGNUM *r, BIGNUM *a); | 372 | int BN_lshift1(BIGNUM *r, const BIGNUM *a); |
363 | int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p,BN_CTX *ctx); | 373 | int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,BN_CTX *ctx); |
364 | int BN_mod_exp(BIGNUM *r, BIGNUM *a, const BIGNUM *p, | 374 | |
365 | const BIGNUM *m,BN_CTX *ctx); | 375 | int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
366 | int BN_mod_exp_mont(BIGNUM *r, BIGNUM *a, const BIGNUM *p, | 376 | const BIGNUM *m,BN_CTX *ctx); |
367 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | 377 | int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
378 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | ||
368 | int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, | 379 | int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, |
369 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | 380 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); |
370 | int BN_mod_exp2_mont(BIGNUM *r, BIGNUM *a1, BIGNUM *p1,BIGNUM *a2, | 381 | int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, |
371 | BIGNUM *p2,BIGNUM *m,BN_CTX *ctx,BN_MONT_CTX *m_ctx); | 382 | const BIGNUM *a2, const BIGNUM *p2,const BIGNUM *m, |
372 | int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, | 383 | BN_CTX *ctx,BN_MONT_CTX *m_ctx); |
373 | BIGNUM *m,BN_CTX *ctx); | 384 | int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
385 | const BIGNUM *m,BN_CTX *ctx); | ||
386 | |||
374 | int BN_mask_bits(BIGNUM *a,int n); | 387 | int BN_mask_bits(BIGNUM *a,int n); |
375 | int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); | 388 | #ifndef OPENSSL_NO_FP_API |
376 | #ifndef NO_FP_API | ||
377 | int BN_print_fp(FILE *fp, const BIGNUM *a); | 389 | int BN_print_fp(FILE *fp, const BIGNUM *a); |
378 | #endif | 390 | #endif |
379 | #ifdef HEADER_BIO_H | 391 | #ifdef HEADER_BIO_H |
@@ -381,9 +393,9 @@ int BN_print(BIO *fp, const BIGNUM *a); | |||
381 | #else | 393 | #else |
382 | int BN_print(void *fp, const BIGNUM *a); | 394 | int BN_print(void *fp, const BIGNUM *a); |
383 | #endif | 395 | #endif |
384 | int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx); | 396 | int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); |
385 | int BN_rshift(BIGNUM *r, BIGNUM *a, int n); | 397 | int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); |
386 | int BN_rshift1(BIGNUM *r, BIGNUM *a); | 398 | int BN_rshift1(BIGNUM *r, const BIGNUM *a); |
387 | void BN_clear(BIGNUM *a); | 399 | void BN_clear(BIGNUM *a); |
388 | BIGNUM *BN_dup(const BIGNUM *a); | 400 | BIGNUM *BN_dup(const BIGNUM *a); |
389 | int BN_ucmp(const BIGNUM *a, const BIGNUM *b); | 401 | int BN_ucmp(const BIGNUM *a, const BIGNUM *b); |
@@ -393,23 +405,30 @@ char * BN_bn2hex(const BIGNUM *a); | |||
393 | char * BN_bn2dec(const BIGNUM *a); | 405 | char * BN_bn2dec(const BIGNUM *a); |
394 | int BN_hex2bn(BIGNUM **a, const char *str); | 406 | int BN_hex2bn(BIGNUM **a, const char *str); |
395 | int BN_dec2bn(BIGNUM **a, const char *str); | 407 | int BN_dec2bn(BIGNUM **a, const char *str); |
396 | int BN_gcd(BIGNUM *r,BIGNUM *in_a,BIGNUM *in_b,BN_CTX *ctx); | 408 | int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); |
397 | BIGNUM *BN_mod_inverse(BIGNUM *ret,BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); | 409 | int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ |
398 | BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe,BIGNUM *add, | 410 | BIGNUM *BN_mod_inverse(BIGNUM *ret, |
399 | BIGNUM *rem,void (*callback)(int,int,void *),void *cb_arg); | 411 | const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); |
412 | BIGNUM *BN_mod_sqrt(BIGNUM *ret, | ||
413 | const BIGNUM *a, const BIGNUM *n,BN_CTX *ctx); | ||
414 | BIGNUM *BN_generate_prime(BIGNUM *ret,int bits,int safe, | ||
415 | const BIGNUM *add, const BIGNUM *rem, | ||
416 | void (*callback)(int,int,void *),void *cb_arg); | ||
400 | int BN_is_prime(const BIGNUM *p,int nchecks, | 417 | int BN_is_prime(const BIGNUM *p,int nchecks, |
401 | void (*callback)(int,int,void *), | 418 | void (*callback)(int,int,void *), |
402 | BN_CTX *ctx,void *cb_arg); | 419 | BN_CTX *ctx,void *cb_arg); |
403 | int BN_is_prime_fasttest(const BIGNUM *p,int nchecks, | 420 | int BN_is_prime_fasttest(const BIGNUM *p,int nchecks, |
404 | void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg, | 421 | void (*callback)(int,int,void *),BN_CTX *ctx,void *cb_arg, |
405 | int do_trial_division); | 422 | int do_trial_division); |
406 | void ERR_load_BN_strings(void ); | ||
407 | 423 | ||
408 | BN_MONT_CTX *BN_MONT_CTX_new(void ); | 424 | BN_MONT_CTX *BN_MONT_CTX_new(void ); |
409 | void BN_MONT_CTX_init(BN_MONT_CTX *ctx); | 425 | void BN_MONT_CTX_init(BN_MONT_CTX *ctx); |
410 | int BN_mod_mul_montgomery(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_MONT_CTX *mont, | 426 | int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b, |
411 | BN_CTX *ctx); | 427 | BN_MONT_CTX *mont, BN_CTX *ctx); |
412 | int BN_from_montgomery(BIGNUM *r,BIGNUM *a,BN_MONT_CTX *mont,BN_CTX *ctx); | 428 | #define BN_to_montgomery(r,a,mont,ctx) BN_mod_mul_montgomery(\ |
429 | (r),(a),&((mont)->RR),(mont),(ctx)) | ||
430 | int BN_from_montgomery(BIGNUM *r,const BIGNUM *a, | ||
431 | BN_MONT_CTX *mont, BN_CTX *ctx); | ||
413 | void BN_MONT_CTX_free(BN_MONT_CTX *mont); | 432 | void BN_MONT_CTX_free(BN_MONT_CTX *mont); |
414 | int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *modulus,BN_CTX *ctx); | 433 | int BN_MONT_CTX_set(BN_MONT_CTX *mont,const BIGNUM *modulus,BN_CTX *ctx); |
415 | BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from); | 434 | BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to,BN_MONT_CTX *from); |
@@ -427,12 +446,12 @@ void BN_RECP_CTX_init(BN_RECP_CTX *recp); | |||
427 | BN_RECP_CTX *BN_RECP_CTX_new(void); | 446 | BN_RECP_CTX *BN_RECP_CTX_new(void); |
428 | void BN_RECP_CTX_free(BN_RECP_CTX *recp); | 447 | void BN_RECP_CTX_free(BN_RECP_CTX *recp); |
429 | int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx); | 448 | int BN_RECP_CTX_set(BN_RECP_CTX *recp,const BIGNUM *rdiv,BN_CTX *ctx); |
430 | int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, | 449 | int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, |
431 | BN_RECP_CTX *recp,BN_CTX *ctx); | 450 | BN_RECP_CTX *recp,BN_CTX *ctx); |
432 | int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | 451 | int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
433 | const BIGNUM *m, BN_CTX *ctx); | 452 | const BIGNUM *m, BN_CTX *ctx); |
434 | int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, | 453 | int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, |
435 | BN_RECP_CTX *recp, BN_CTX *ctx); | 454 | BN_RECP_CTX *recp, BN_CTX *ctx); |
436 | 455 | ||
437 | /* library internal functions */ | 456 | /* library internal functions */ |
438 | 457 | ||
@@ -440,6 +459,7 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, | |||
440 | (a):bn_expand2((a),(bits)/BN_BITS2+1)) | 459 | (a):bn_expand2((a),(bits)/BN_BITS2+1)) |
441 | #define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) | 460 | #define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words))) |
442 | BIGNUM *bn_expand2(BIGNUM *a, int words); | 461 | BIGNUM *bn_expand2(BIGNUM *a, int words); |
462 | BIGNUM *bn_dup_expand(const BIGNUM *a, int words); | ||
443 | 463 | ||
444 | #define bn_fix_top(a) \ | 464 | #define bn_fix_top(a) \ |
445 | { \ | 465 | { \ |
@@ -451,15 +471,15 @@ BIGNUM *bn_expand2(BIGNUM *a, int words); | |||
451 | } \ | 471 | } \ |
452 | } | 472 | } |
453 | 473 | ||
454 | BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w); | 474 | BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); |
455 | BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w); | 475 | BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w); |
456 | void bn_sqr_words(BN_ULONG *rp, BN_ULONG *ap, int num); | 476 | void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num); |
457 | BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); | 477 | BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d); |
458 | BN_ULONG bn_add_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num); | 478 | BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); |
459 | BN_ULONG bn_sub_words(BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int num); | 479 | BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num); |
460 | 480 | ||
461 | #ifdef BN_DEBUG | 481 | #ifdef BN_DEBUG |
462 | void bn_dump1(FILE *o, const char *a, BN_ULONG *b,int n); | 482 | void bn_dump1(FILE *o, const char *a, const BN_ULONG *b,int n); |
463 | # define bn_print(a) {fprintf(stderr, #a "="); BN_print_fp(stderr,a); \ | 483 | # define bn_print(a) {fprintf(stderr, #a "="); BN_print_fp(stderr,a); \ |
464 | fprintf(stderr,"\n");} | 484 | fprintf(stderr,"\n");} |
465 | # define bn_dump(a,n) bn_dump1(stderr,#a,a,n); | 485 | # define bn_dump(a,n) bn_dump1(stderr,#a,a,n); |
@@ -474,6 +494,7 @@ int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom); | |||
474 | /* The following lines are auto generated by the script mkerr.pl. Any changes | 494 | /* The following lines are auto generated by the script mkerr.pl. Any changes |
475 | * made after this point may be overwritten when the script is next run. | 495 | * made after this point may be overwritten when the script is next run. |
476 | */ | 496 | */ |
497 | void ERR_load_BN_strings(void); | ||
477 | 498 | ||
478 | /* Error codes for the BN functions. */ | 499 | /* Error codes for the BN functions. */ |
479 | 500 | ||
@@ -488,11 +509,14 @@ int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom); | |||
488 | #define BN_F_BN_CTX_NEW 106 | 509 | #define BN_F_BN_CTX_NEW 106 |
489 | #define BN_F_BN_DIV 107 | 510 | #define BN_F_BN_DIV 107 |
490 | #define BN_F_BN_EXPAND2 108 | 511 | #define BN_F_BN_EXPAND2 108 |
512 | #define BN_F_BN_EXPAND_INTERNAL 120 | ||
491 | #define BN_F_BN_MOD_EXP2_MONT 118 | 513 | #define BN_F_BN_MOD_EXP2_MONT 118 |
492 | #define BN_F_BN_MOD_EXP_MONT 109 | 514 | #define BN_F_BN_MOD_EXP_MONT 109 |
493 | #define BN_F_BN_MOD_EXP_MONT_WORD 117 | 515 | #define BN_F_BN_MOD_EXP_MONT_WORD 117 |
494 | #define BN_F_BN_MOD_INVERSE 110 | 516 | #define BN_F_BN_MOD_INVERSE 110 |
517 | #define BN_F_BN_MOD_LSHIFT_QUICK 119 | ||
495 | #define BN_F_BN_MOD_MUL_RECIPROCAL 111 | 518 | #define BN_F_BN_MOD_MUL_RECIPROCAL 111 |
519 | #define BN_F_BN_MOD_SQRT 121 | ||
496 | #define BN_F_BN_MPI2BN 112 | 520 | #define BN_F_BN_MPI2BN 112 |
497 | #define BN_F_BN_NEW 113 | 521 | #define BN_F_BN_NEW 113 |
498 | #define BN_F_BN_RAND 114 | 522 | #define BN_F_BN_RAND 114 |
@@ -507,14 +531,17 @@ int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom); | |||
507 | #define BN_R_DIV_BY_ZERO 103 | 531 | #define BN_R_DIV_BY_ZERO 103 |
508 | #define BN_R_ENCODING_ERROR 104 | 532 | #define BN_R_ENCODING_ERROR 104 |
509 | #define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 | 533 | #define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 |
534 | #define BN_R_INPUT_NOT_REDUCED 110 | ||
510 | #define BN_R_INVALID_LENGTH 106 | 535 | #define BN_R_INVALID_LENGTH 106 |
511 | #define BN_R_INVALID_RANGE 115 | 536 | #define BN_R_INVALID_RANGE 115 |
537 | #define BN_R_NOT_A_SQUARE 111 | ||
512 | #define BN_R_NOT_INITIALIZED 107 | 538 | #define BN_R_NOT_INITIALIZED 107 |
513 | #define BN_R_NO_INVERSE 108 | 539 | #define BN_R_NO_INVERSE 108 |
540 | #define BN_R_P_IS_NOT_PRIME 112 | ||
541 | #define BN_R_TOO_MANY_ITERATIONS 113 | ||
514 | #define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 | 542 | #define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 |
515 | 543 | ||
516 | #ifdef __cplusplus | 544 | #ifdef __cplusplus |
517 | } | 545 | } |
518 | #endif | 546 | #endif |
519 | #endif | 547 | #endif |
520 | |||