diff options
Diffstat (limited to 'src/lib/libssl/src/crypto/bn/bn.h')
-rw-r--r-- | src/lib/libssl/src/crypto/bn/bn.h | 181 |
1 files changed, 92 insertions, 89 deletions
diff --git a/src/lib/libssl/src/crypto/bn/bn.h b/src/lib/libssl/src/crypto/bn/bn.h index f1719a5877..e484b7fc11 100644 --- a/src/lib/libssl/src/crypto/bn/bn.h +++ b/src/lib/libssl/src/crypto/bn/bn.h | |||
@@ -56,6 +56,59 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | /* ==================================================================== | 58 | /* ==================================================================== |
59 | * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. | ||
60 | * | ||
61 | * Redistribution and use in source and binary forms, with or without | ||
62 | * modification, are permitted provided that the following conditions | ||
63 | * are met: | ||
64 | * | ||
65 | * 1. Redistributions of source code must retain the above copyright | ||
66 | * notice, this list of conditions and the following disclaimer. | ||
67 | * | ||
68 | * 2. Redistributions in binary form must reproduce the above copyright | ||
69 | * notice, this list of conditions and the following disclaimer in | ||
70 | * the documentation and/or other materials provided with the | ||
71 | * distribution. | ||
72 | * | ||
73 | * 3. All advertising materials mentioning features or use of this | ||
74 | * software must display the following acknowledgment: | ||
75 | * "This product includes software developed by the OpenSSL Project | ||
76 | * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
77 | * | ||
78 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
79 | * endorse or promote products derived from this software without | ||
80 | * prior written permission. For written permission, please contact | ||
81 | * openssl-core@openssl.org. | ||
82 | * | ||
83 | * 5. Products derived from this software may not be called "OpenSSL" | ||
84 | * nor may "OpenSSL" appear in their names without prior written | ||
85 | * permission of the OpenSSL Project. | ||
86 | * | ||
87 | * 6. Redistributions of any form whatsoever must retain the following | ||
88 | * acknowledgment: | ||
89 | * "This product includes software developed by the OpenSSL Project | ||
90 | * for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
91 | * | ||
92 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
93 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
94 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
95 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
96 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
97 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
98 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
99 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
100 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
101 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
102 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
103 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
104 | * ==================================================================== | ||
105 | * | ||
106 | * This product includes cryptographic software written by Eric Young | ||
107 | * (eay@cryptsoft.com). This product includes software written by Tim | ||
108 | * Hudson (tjh@cryptsoft.com). | ||
109 | * | ||
110 | */ | ||
111 | /* ==================================================================== | ||
59 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 112 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
60 | * | 113 | * |
61 | * Portions of the attached software ("Contribution") are developed by | 114 | * Portions of the attached software ("Contribution") are developed by |
@@ -77,6 +130,7 @@ | |||
77 | #include <stdio.h> /* FILE */ | 130 | #include <stdio.h> /* FILE */ |
78 | #endif | 131 | #endif |
79 | #include <openssl/ossl_typ.h> | 132 | #include <openssl/ossl_typ.h> |
133 | #include <openssl/crypto.h> | ||
80 | 134 | ||
81 | #ifdef __cplusplus | 135 | #ifdef __cplusplus |
82 | extern "C" { | 136 | extern "C" { |
@@ -94,9 +148,11 @@ extern "C" { | |||
94 | /* #define BN_DEBUG */ | 148 | /* #define BN_DEBUG */ |
95 | /* #define BN_DEBUG_RAND */ | 149 | /* #define BN_DEBUG_RAND */ |
96 | 150 | ||
151 | #ifndef OPENSSL_SMALL_FOOTPRINT | ||
97 | #define BN_MUL_COMBA | 152 | #define BN_MUL_COMBA |
98 | #define BN_SQR_COMBA | 153 | #define BN_SQR_COMBA |
99 | #define BN_RECURSION | 154 | #define BN_RECURSION |
155 | #endif | ||
100 | 156 | ||
101 | /* This next option uses the C libraries (2 word)/(1 word) function. | 157 | /* This next option uses the C libraries (2 word)/(1 word) function. |
102 | * If it is not defined, I use my C version (which is slower). | 158 | * If it is not defined, I use my C version (which is slower). |
@@ -137,6 +193,8 @@ extern "C" { | |||
137 | #define BN_DEC_FMT1 "%lu" | 193 | #define BN_DEC_FMT1 "%lu" |
138 | #define BN_DEC_FMT2 "%019lu" | 194 | #define BN_DEC_FMT2 "%019lu" |
139 | #define BN_DEC_NUM 19 | 195 | #define BN_DEC_NUM 19 |
196 | #define BN_HEX_FMT1 "%lX" | ||
197 | #define BN_HEX_FMT2 "%016lX" | ||
140 | #endif | 198 | #endif |
141 | 199 | ||
142 | /* This is where the long long data type is 64 bits, but long is 32. | 200 | /* This is where the long long data type is 64 bits, but long is 32. |
@@ -162,83 +220,37 @@ extern "C" { | |||
162 | #define BN_DEC_FMT1 "%llu" | 220 | #define BN_DEC_FMT1 "%llu" |
163 | #define BN_DEC_FMT2 "%019llu" | 221 | #define BN_DEC_FMT2 "%019llu" |
164 | #define BN_DEC_NUM 19 | 222 | #define BN_DEC_NUM 19 |
223 | #define BN_HEX_FMT1 "%llX" | ||
224 | #define BN_HEX_FMT2 "%016llX" | ||
165 | #endif | 225 | #endif |
166 | 226 | ||
167 | #ifdef THIRTY_TWO_BIT | 227 | #ifdef THIRTY_TWO_BIT |
168 | #ifdef BN_LLONG | 228 | #ifdef BN_LLONG |
169 | # if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__) | 229 | # if defined(_WIN32) && !defined(__GNUC__) |
170 | # define BN_ULLONG unsigned __int64 | 230 | # define BN_ULLONG unsigned __int64 |
231 | # define BN_MASK (0xffffffffffffffffI64) | ||
171 | # else | 232 | # else |
172 | # define BN_ULLONG unsigned long long | 233 | # define BN_ULLONG unsigned long long |
234 | # define BN_MASK (0xffffffffffffffffLL) | ||
173 | # endif | 235 | # endif |
174 | #endif | 236 | #endif |
175 | #define BN_ULONG unsigned long | 237 | #define BN_ULONG unsigned int |
176 | #define BN_LONG long | 238 | #define BN_LONG int |
177 | #define BN_BITS 64 | 239 | #define BN_BITS 64 |
178 | #define BN_BYTES 4 | 240 | #define BN_BYTES 4 |
179 | #define BN_BITS2 32 | 241 | #define BN_BITS2 32 |
180 | #define BN_BITS4 16 | 242 | #define BN_BITS4 16 |
181 | #ifdef OPENSSL_SYS_WIN32 | ||
182 | /* VC++ doesn't like the LL suffix */ | ||
183 | #define BN_MASK (0xffffffffffffffffL) | ||
184 | #else | ||
185 | #define BN_MASK (0xffffffffffffffffLL) | ||
186 | #endif | ||
187 | #define BN_MASK2 (0xffffffffL) | 243 | #define BN_MASK2 (0xffffffffL) |
188 | #define BN_MASK2l (0xffff) | 244 | #define BN_MASK2l (0xffff) |
189 | #define BN_MASK2h1 (0xffff8000L) | 245 | #define BN_MASK2h1 (0xffff8000L) |
190 | #define BN_MASK2h (0xffff0000L) | 246 | #define BN_MASK2h (0xffff0000L) |
191 | #define BN_TBIT (0x80000000L) | 247 | #define BN_TBIT (0x80000000L) |
192 | #define BN_DEC_CONV (1000000000L) | 248 | #define BN_DEC_CONV (1000000000L) |
193 | #define BN_DEC_FMT1 "%lu" | ||
194 | #define BN_DEC_FMT2 "%09lu" | ||
195 | #define BN_DEC_NUM 9 | ||
196 | #endif | ||
197 | |||
198 | #ifdef SIXTEEN_BIT | ||
199 | #ifndef BN_DIV2W | ||
200 | #define BN_DIV2W | ||
201 | #endif | ||
202 | #define BN_ULLONG unsigned long | ||
203 | #define BN_ULONG unsigned short | ||
204 | #define BN_LONG short | ||
205 | #define BN_BITS 32 | ||
206 | #define BN_BYTES 2 | ||
207 | #define BN_BITS2 16 | ||
208 | #define BN_BITS4 8 | ||
209 | #define BN_MASK (0xffffffff) | ||
210 | #define BN_MASK2 (0xffff) | ||
211 | #define BN_MASK2l (0xff) | ||
212 | #define BN_MASK2h1 (0xff80) | ||
213 | #define BN_MASK2h (0xff00) | ||
214 | #define BN_TBIT (0x8000) | ||
215 | #define BN_DEC_CONV (100000) | ||
216 | #define BN_DEC_FMT1 "%u" | 249 | #define BN_DEC_FMT1 "%u" |
217 | #define BN_DEC_FMT2 "%05u" | 250 | #define BN_DEC_FMT2 "%09u" |
218 | #define BN_DEC_NUM 5 | 251 | #define BN_DEC_NUM 9 |
219 | #endif | 252 | #define BN_HEX_FMT1 "%X" |
220 | 253 | #define BN_HEX_FMT2 "%08X" | |
221 | #ifdef EIGHT_BIT | ||
222 | #ifndef BN_DIV2W | ||
223 | #define BN_DIV2W | ||
224 | #endif | ||
225 | #define BN_ULLONG unsigned short | ||
226 | #define BN_ULONG unsigned char | ||
227 | #define BN_LONG char | ||
228 | #define BN_BITS 16 | ||
229 | #define BN_BYTES 1 | ||
230 | #define BN_BITS2 8 | ||
231 | #define BN_BITS4 4 | ||
232 | #define BN_MASK (0xffff) | ||
233 | #define BN_MASK2 (0xff) | ||
234 | #define BN_MASK2l (0xf) | ||
235 | #define BN_MASK2h1 (0xf8) | ||
236 | #define BN_MASK2h (0xf0) | ||
237 | #define BN_TBIT (0x80) | ||
238 | #define BN_DEC_CONV (100) | ||
239 | #define BN_DEC_FMT1 "%u" | ||
240 | #define BN_DEC_FMT2 "%02u" | ||
241 | #define BN_DEC_NUM 2 | ||
242 | #endif | 254 | #endif |
243 | 255 | ||
244 | #define BN_DEFAULT_BITS 1280 | 256 | #define BN_DEFAULT_BITS 1280 |
@@ -303,12 +315,8 @@ struct bn_mont_ctx_st | |||
303 | BIGNUM N; /* The modulus */ | 315 | BIGNUM N; /* The modulus */ |
304 | BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 | 316 | BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 |
305 | * (Ni is only stored for bignum algorithm) */ | 317 | * (Ni is only stored for bignum algorithm) */ |
306 | #if 0 | 318 | BN_ULONG n0[2];/* least significant word(s) of Ni; |
307 | /* OpenSSL 0.9.9 preview: */ | 319 | (type changed with 0.9.9, was "BN_ULONG n0;" before) */ |
308 | BN_ULONG n0[2];/* least significant word(s) of Ni */ | ||
309 | #else | ||
310 | BN_ULONG n0; /* least significant word of Ni */ | ||
311 | #endif | ||
312 | int flags; | 320 | int flags; |
313 | }; | 321 | }; |
314 | 322 | ||
@@ -504,6 +512,7 @@ char * BN_bn2hex(const BIGNUM *a); | |||
504 | char * BN_bn2dec(const BIGNUM *a); | 512 | char * BN_bn2dec(const BIGNUM *a); |
505 | int BN_hex2bn(BIGNUM **a, const char *str); | 513 | int BN_hex2bn(BIGNUM **a, const char *str); |
506 | int BN_dec2bn(BIGNUM **a, const char *str); | 514 | int BN_dec2bn(BIGNUM **a, const char *str); |
515 | int BN_asc2bn(BIGNUM **a, const char *str); | ||
507 | int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); | 516 | int BN_gcd(BIGNUM *r,const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); |
508 | int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ | 517 | int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ |
509 | BIGNUM *BN_mod_inverse(BIGNUM *ret, | 518 | BIGNUM *BN_mod_inverse(BIGNUM *ret, |
@@ -531,17 +540,6 @@ int BN_is_prime_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, BN_GENCB *cb); | |||
531 | int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, | 540 | int BN_is_prime_fasttest_ex(const BIGNUM *p,int nchecks, BN_CTX *ctx, |
532 | int do_trial_division, BN_GENCB *cb); | 541 | int do_trial_division, BN_GENCB *cb); |
533 | 542 | ||
534 | int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx); | ||
535 | |||
536 | int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, | ||
537 | const BIGNUM *Xp, const BIGNUM *Xp1, const BIGNUM *Xp2, | ||
538 | const BIGNUM *e, BN_CTX *ctx, BN_GENCB *cb); | ||
539 | int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, | ||
540 | BIGNUM *Xp1, BIGNUM *Xp2, | ||
541 | const BIGNUM *Xp, | ||
542 | const BIGNUM *e, BN_CTX *ctx, | ||
543 | BN_GENCB *cb); | ||
544 | |||
545 | BN_MONT_CTX *BN_MONT_CTX_new(void ); | 543 | BN_MONT_CTX *BN_MONT_CTX_new(void ); |
546 | void BN_MONT_CTX_init(BN_MONT_CTX *ctx); | 544 | void BN_MONT_CTX_init(BN_MONT_CTX *ctx); |
547 | int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b, | 545 | int BN_mod_mul_montgomery(BIGNUM *r,const BIGNUM *a,const BIGNUM *b, |
@@ -560,19 +558,22 @@ BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock, | |||
560 | #define BN_BLINDING_NO_UPDATE 0x00000001 | 558 | #define BN_BLINDING_NO_UPDATE 0x00000001 |
561 | #define BN_BLINDING_NO_RECREATE 0x00000002 | 559 | #define BN_BLINDING_NO_RECREATE 0x00000002 |
562 | 560 | ||
563 | BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, /* const */ BIGNUM *mod); | 561 | BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod); |
564 | void BN_BLINDING_free(BN_BLINDING *b); | 562 | void BN_BLINDING_free(BN_BLINDING *b); |
565 | int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); | 563 | int BN_BLINDING_update(BN_BLINDING *b,BN_CTX *ctx); |
566 | int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); | 564 | int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); |
567 | int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); | 565 | int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); |
568 | int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); | 566 | int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); |
569 | int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); | 567 | int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); |
568 | #ifndef OPENSSL_NO_DEPRECATED | ||
570 | unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); | 569 | unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); |
571 | void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); | 570 | void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); |
571 | #endif | ||
572 | CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *); | ||
572 | unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); | 573 | unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); |
573 | void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); | 574 | void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); |
574 | BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, | 575 | BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, |
575 | const BIGNUM *e, /* const */ BIGNUM *m, BN_CTX *ctx, | 576 | const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, |
576 | int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | 577 | int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
577 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), | 578 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), |
578 | BN_MONT_CTX *m_ctx); | 579 | BN_MONT_CTX *m_ctx); |
@@ -625,24 +626,24 @@ int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | |||
625 | * t^p[0] + t^p[1] + ... + t^p[k] | 626 | * t^p[0] + t^p[1] + ... + t^p[k] |
626 | * where m = p[0] > p[1] > ... > p[k] = 0. | 627 | * where m = p[0] > p[1] > ... > p[k] = 0. |
627 | */ | 628 | */ |
628 | int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[]); | 629 | int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]); |
629 | /* r = a mod p */ | 630 | /* r = a mod p */ |
630 | int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | 631 | int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
631 | const unsigned int p[], BN_CTX *ctx); /* r = (a * b) mod p */ | 632 | const int p[], BN_CTX *ctx); /* r = (a * b) mod p */ |
632 | int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const unsigned int p[], | 633 | int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], |
633 | BN_CTX *ctx); /* r = (a * a) mod p */ | 634 | BN_CTX *ctx); /* r = (a * a) mod p */ |
634 | int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const unsigned int p[], | 635 | int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[], |
635 | BN_CTX *ctx); /* r = (1 / b) mod p */ | 636 | BN_CTX *ctx); /* r = (1 / b) mod p */ |
636 | int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | 637 | int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
637 | const unsigned int p[], BN_CTX *ctx); /* r = (a / b) mod p */ | 638 | const int p[], BN_CTX *ctx); /* r = (a / b) mod p */ |
638 | int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, | 639 | int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, |
639 | const unsigned int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */ | 640 | const int p[], BN_CTX *ctx); /* r = (a ^ b) mod p */ |
640 | int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, | 641 | int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, |
641 | const unsigned int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */ | 642 | const int p[], BN_CTX *ctx); /* r = sqrt(a) mod p */ |
642 | int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, | 643 | int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, |
643 | const unsigned int p[], BN_CTX *ctx); /* r^2 + r = a mod p */ | 644 | const int p[], BN_CTX *ctx); /* r^2 + r = a mod p */ |
644 | int BN_GF2m_poly2arr(const BIGNUM *a, unsigned int p[], int max); | 645 | int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max); |
645 | int BN_GF2m_arr2poly(const unsigned int p[], BIGNUM *a); | 646 | int BN_GF2m_arr2poly(const int p[], BIGNUM *a); |
646 | 647 | ||
647 | /* faster mod functions for the 'NIST primes' | 648 | /* faster mod functions for the 'NIST primes' |
648 | * 0 <= a < p^2 */ | 649 | * 0 <= a < p^2 */ |
@@ -751,10 +752,12 @@ int RAND_pseudo_bytes(unsigned char *buf,int num); | |||
751 | #define bn_correct_top(a) \ | 752 | #define bn_correct_top(a) \ |
752 | { \ | 753 | { \ |
753 | BN_ULONG *ftl; \ | 754 | BN_ULONG *ftl; \ |
754 | if ((a)->top > 0) \ | 755 | int tmp_top = (a)->top; \ |
756 | if (tmp_top > 0) \ | ||
755 | { \ | 757 | { \ |
756 | for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \ | 758 | for (ftl= &((a)->d[tmp_top-1]); tmp_top > 0; tmp_top--) \ |
757 | if (*(ftl--)) break; \ | 759 | if (*(ftl--)) break; \ |
760 | (a)->top = tmp_top; \ | ||
758 | } \ | 761 | } \ |
759 | bn_pollute(a); \ | 762 | bn_pollute(a); \ |
760 | } | 763 | } |