2 * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #ifndef OSSL_CRYPTO_BN_LOCAL_H
11 # define OSSL_CRYPTO_BN_LOCAL_H
14 * The EDK2 build doesn't use bn_conf.h; it sets THIRTY_TWO_BIT or
15 * SIXTY_FOUR_BIT in its own environment since it doesn't re-run our
16 * Configure script and needs to support both 32-bit and 64-bit.
18 # include <openssl/opensslconf.h>
20 # if !defined(OPENSSL_SYS_UEFI)
21 # include "crypto/bn_conf.h"
24 # include "crypto/bn.h"
25 # include "internal/cryptlib.h"
28 * These preprocessor symbols control various aspects of the bignum headers
29 * and library code. They're not defined by any "normal" configuration, as
30 * they are intended for development and testing purposes. NB: defining all
31 * three can be useful for debugging application code as well as openssl
32 * itself. BN_DEBUG - turn on various debugging alterations to the bignum
33 * code BN_DEBUG_RAND - uses random poisoning of unused words to trip up
34 * mismanagement of bignum internals. You must also define BN_DEBUG.
36 /* #define BN_DEBUG */
37 /* #define BN_DEBUG_RAND */
39 # ifndef OPENSSL_SMALL_FOOTPRINT
46 * This next option uses the C libraries (2 word)/(1 word) function. If it is
47 * not defined, I use my C version (which is slower). The reason for this
48 * flag is that when the particular C compiler library routine is used, and
49 * the library is linked with a different compiler, the library is missing.
50 * This mostly happens when the library is built with gcc and then linked
51 * using normal cc. This would be a common occurrence because gcc normally
52 * produces code that is 2 times faster than system compilers for the big
53 * number stuff. For machines with only one compiler (or shared libraries),
54 * this should be on. Again this in only really a problem on machines using
55 * "long long's", are 32bit, and are not using my assembler code.
57 # if defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_WINDOWS) || \
58 defined(OPENSSL_SYS_WIN32) || defined(linux)
63 * 64-bit processor with LP64 ABI
65 # ifdef SIXTY_FOUR_BIT_LONG
66 # define BN_ULLONG unsigned long long
68 # define BN_MASK2 (0xffffffffffffffffL)
69 # define BN_MASK2l (0xffffffffL)
70 # define BN_MASK2h (0xffffffff00000000L)
71 # define BN_MASK2h1 (0xffffffff80000000L)
72 # define BN_DEC_CONV (10000000000000000000UL)
73 # define BN_DEC_NUM 19
74 # define BN_DEC_FMT1 "%lu"
75 # define BN_DEC_FMT2 "%019lu"
79 * 64-bit processor other than LP64 ABI
81 # ifdef SIXTY_FOUR_BIT
85 # define BN_MASK2 (0xffffffffffffffffLL)
86 # define BN_MASK2l (0xffffffffL)
87 # define BN_MASK2h (0xffffffff00000000LL)
88 # define BN_MASK2h1 (0xffffffff80000000LL)
89 # define BN_DEC_CONV (10000000000000000000ULL)
90 # define BN_DEC_NUM 19
91 # define BN_DEC_FMT1 "%llu"
92 # define BN_DEC_FMT2 "%019llu"
95 # ifdef THIRTY_TWO_BIT
97 # if defined(_WIN32) && !defined(__GNUC__)
98 # define BN_ULLONG unsigned __int64
100 # define BN_ULLONG unsigned long long
104 # define BN_MASK2 (0xffffffffL)
105 # define BN_MASK2l (0xffff)
106 # define BN_MASK2h1 (0xffff8000L)
107 # define BN_MASK2h (0xffff0000L)
108 # define BN_DEC_CONV (1000000000L)
109 # define BN_DEC_NUM 9
110 # define BN_DEC_FMT1 "%u"
111 # define BN_DEC_FMT2 "%09u"
116 * Bignum consistency macros
117 * There is one "API" macro, bn_fix_top(), for stripping leading zeroes from
118 * bignum data after direct manipulations on the data. There is also an
119 * "internal" macro, bn_check_top(), for verifying that there are no leading
120 * zeroes. Unfortunately, some auditing is required due to the fact that
121 * bn_fix_top() has become an overabused duct-tape because bignum data is
122 * occasionally passed around in an inconsistent state. So the following
123 * changes have been made to sort this out;
124 * - bn_fix_top()s implementation has been moved to bn_correct_top()
125 * - if BN_DEBUG isn't defined, bn_fix_top() maps to bn_correct_top(), and
126 * bn_check_top() is as before.
127 * - if BN_DEBUG *is* defined;
128 * - bn_check_top() tries to pollute unused words even if the bignum 'top' is
129 * consistent. (ed: only if BN_DEBUG_RAND is defined)
130 * - bn_fix_top() maps to bn_check_top() rather than "fixing" anything.
131 * The idea is to have debug builds flag up inconsistent bignums when they
132 * occur. If that occurs in a bn_fix_top(), we examine the code in question; if
133 * the use of bn_fix_top() was appropriate (ie. it follows directly after code
134 * that manipulates the bignum) it is converted to bn_correct_top(), and if it
135 * was not appropriate, we convert it permanently to bn_check_top() and track
136 * down the cause of the bug. Eventually, no internal code should be using the
137 * bn_fix_top() macro. External applications and libraries should try this with
138 * their own code too, both in terms of building against the openssl headers
139 * with BN_DEBUG defined *and* linking with a version of OpenSSL built with it
140 * defined. This not only improves external code, it provides more test
141 * coverage for openssl's own code.
146 * The new BN_FLG_FIXED_TOP flag marks vectors that were not treated with
147 * bn_correct_top, in other words such vectors are permitted to have zeros
148 * in most significant limbs. Such vectors are used internally to achieve
149 * execution time invariance for critical operations with private keys.
150 * It's BN_DEBUG-only flag, because user application is not supposed to
151 * observe it anyway. Moreover, optimizing compiler would actually remove
152 * all operations manipulating the bit in question in non-BN_DEBUG build.
154 # define BN_FLG_FIXED_TOP 0x10000
155 # ifdef BN_DEBUG_RAND
156 # define bn_pollute(a) \
158 const BIGNUM *_bnum1 = (a); \
159 if (_bnum1->top < _bnum1->dmax) { \
160 unsigned char _tmp_char; \
161 /* We cast away const without the compiler knowing, any \
162 * *genuinely* constant variables that aren't mutable \
163 * wouldn't be constructed with top!=dmax. */ \
164 BN_ULONG *_not_const; \
165 memcpy(&_not_const, &_bnum1->d, sizeof(_not_const)); \
166 RAND_bytes(&_tmp_char, 1); /* Debug only - safe to ignore error return */\
167 memset(_not_const + _bnum1->top, _tmp_char, \
168 sizeof(*_not_const) * (_bnum1->dmax - _bnum1->top)); \
172 # define bn_pollute(a)
174 # define bn_check_top(a) \
176 const BIGNUM *_bnum2 = (a); \
177 if (_bnum2 != NULL) { \
178 int _top = _bnum2->top; \
179 (void)ossl_assert((_top == 0 && !_bnum2->neg) || \
180 (_top && ((_bnum2->flags & BN_FLG_FIXED_TOP) \
181 || _bnum2->d[_top - 1] != 0))); \
182 bn_pollute(_bnum2); \
186 # define bn_fix_top(a) bn_check_top(a)
188 # define bn_check_size(bn, bits) bn_wcheck_size(bn, ((bits+BN_BITS2-1))/BN_BITS2)
189 # define bn_wcheck_size(bn, words) \
191 const BIGNUM *_bnum2 = (bn); \
192 assert((words) <= (_bnum2)->dmax && \
193 (words) >= (_bnum2)->top); \
194 /* avoid unused variable warning with NDEBUG */ \
198 # else /* !BN_DEBUG */
200 # define BN_FLG_FIXED_TOP 0
201 # define bn_pollute(a)
202 # define bn_check_top(a)
203 # define bn_fix_top(a) bn_correct_top(a)
204 # define bn_check_size(bn, bits)
205 # define bn_wcheck_size(bn, words)
209 BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num,
211 BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
212 void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
213 BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
214 BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
216 BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
220 BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit
222 int top; /* Index of last used d +1. */
223 /* The next are internal book keeping for bn_expand. */
224 int dmax; /* Size of the d array. */
225 int neg; /* one if the number is negative */
229 /* Used for montgomery multiplication */
230 struct bn_mont_ctx_st {
231 int ri; /* number of bits in R */
232 BIGNUM RR; /* used to convert to montgomery form,
233 possibly zero-padded */
234 BIGNUM N; /* The modulus */
235 BIGNUM Ni; /* R*(1/R mod N) - N*Ni = 1 (Ni is only
236 * stored for bignum algorithm) */
237 BN_ULONG n0[2]; /* least significant word(s) of Ni; (type
238 * changed with 0.9.9, was "BN_ULONG n0;"
244 * Used for reciprocal division/mod functions It cannot be shared between
247 struct bn_recp_ctx_st {
248 BIGNUM N; /* the divisor */
249 BIGNUM Nr; /* the reciprocal */
255 /* Used for slow "generation" functions. */
257 unsigned int ver; /* To handle binary (in)compatibility */
258 void *arg; /* callback-specific data */
260 /* if (ver==1) - handles old style callbacks */
261 void (*cb_1) (int, int, void *);
262 /* if (ver==2) - new callback style */
263 int (*cb_2) (int, int, BN_GENCB *);
268 * BN_window_bits_for_exponent_size -- macro for sliding window mod_exp functions
271 * For window size 'w' (w >= 2) and a random 'b' bits exponent,
272 * the number of multiplications is a constant plus on average
274 * 2^(w-1) + (b-w)/(w+1);
276 * here 2^(w-1) is for precomputing the table (we actually need
277 * entries only for windows that have the lowest bit set), and
278 * (b-w)/(w+1) is an approximation for the expected number of
279 * w-bit windows, not counting the first one.
284 * w = 5 if 671 > b > 239
285 * w = 4 if 239 > b > 79
286 * w = 3 if 79 > b > 23
289 * (with draws in between). Very small exponents are often selected
290 * with low Hamming weight, so we use w = 1 for b <= 23.
292 # define BN_window_bits_for_exponent_size(b) \
299 * BN_mod_exp_mont_consttime is based on the assumption that the L1 data cache
300 * line width of the target processor is at least the following value.
302 # define MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH ( 64 )
303 # define MOD_EXP_CTIME_MIN_CACHE_LINE_MASK (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - 1)
306 * Window sizes optimized for fixed window size modular exponentiation
307 * algorithm (BN_mod_exp_mont_consttime). To achieve the security goals of
308 * BN_mode_exp_mont_consttime, the maximum size of the window must not exceed
309 * log_2(MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH). Window size thresholds are
310 * defined for cache line sizes of 32 and 64, cache line sizes where
311 * log_2(32)=5 and log_2(64)=6 respectively. A window size of 7 should only be
312 * used on processors that have a 128 byte or greater cache line size.
314 # if MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 64
316 # define BN_window_bits_for_ctime_exponent_size(b) \
321 # define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (6)
323 # elif MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 32
325 # define BN_window_bits_for_ctime_exponent_size(b) \
329 # define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (5)
333 /* Pentium pro 16,16,16,32,64 */
334 /* Alpha 16,16,16,16.64 */
335 # define BN_MULL_SIZE_NORMAL (16)/* 32 */
336 # define BN_MUL_RECURSIVE_SIZE_NORMAL (16)/* 32 less than */
337 # define BN_SQR_RECURSIVE_SIZE_NORMAL (16)/* 32 */
338 # define BN_MUL_LOW_RECURSIVE_SIZE_NORMAL (32)/* 32 */
339 # define BN_MONT_CTX_SET_SIZE_WORD (64)/* 32 */
342 * 2011-02-22 SMS. In various places, a size_t variable or a type cast to
343 * size_t was used to perform integer-only operations on pointers. This
344 * failed on VMS with 64-bit pointers (CC /POINTER_SIZE = 64) because size_t
345 * is still only 32 bits. What's needed in these cases is an integer type
346 * with the same size as a pointer, which size_t is not certain to be. The
347 * only fix here is VMS-specific.
349 # if defined(OPENSSL_SYS_VMS)
350 # if __INITIAL_POINTER_SIZE == 64
351 # define PTR_SIZE_INT long long
352 # else /* __INITIAL_POINTER_SIZE == 64 */
353 # define PTR_SIZE_INT int
354 # endif /* __INITIAL_POINTER_SIZE == 64 [else] */
355 # elif !defined(PTR_SIZE_INT) /* defined(OPENSSL_SYS_VMS) */
356 # define PTR_SIZE_INT size_t
357 # endif /* defined(OPENSSL_SYS_VMS) [else] */
359 # if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) && !defined(PEDANTIC)
361 * BN_UMULT_HIGH section.
362 * If the compiler doesn't support 2*N integer type, then you have to
363 * replace every N*N multiplication with 4 (N/2)*(N/2) accompanied by some
364 * shifts and additions which unavoidably results in severe performance
365 * penalties. Of course provided that the hardware is capable of producing
366 * 2*N result... That's when you normally start considering assembler
367 * implementation. However! It should be pointed out that some CPUs (e.g.,
368 * PowerPC, Alpha, and IA-64) provide *separate* instruction calculating
369 * the upper half of the product placing the result into a general
370 * purpose register. Now *if* the compiler supports inline assembler,
371 * then it's not impossible to implement the "bignum" routines (and have
372 * the compiler optimize 'em) exhibiting "native" performance in C. That's
373 * what BN_UMULT_HIGH macro is about:-) Note that more recent compilers do
374 * support 2*64 integer type, which is also used here.
376 # if defined(__SIZEOF_INT128__) && __SIZEOF_INT128__==16 && \
377 (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG))
378 # define BN_UMULT_HIGH(a,b) (((__uint128_t)(a)*(b))>>64)
379 # define BN_UMULT_LOHI(low,high,a,b) ({ \
380 __uint128_t ret=(__uint128_t)(a)*(b); \
381 (high)=ret>>64; (low)=ret; })
382 # elif defined(__alpha) && (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
385 # define BN_UMULT_HIGH(a,b) (BN_ULONG)asm("umulh %a0,%a1,%v0",(a),(b))
386 # elif defined(__GNUC__) && __GNUC__>=2
387 # define BN_UMULT_HIGH(a,b) ({ \
388 register BN_ULONG ret; \
389 asm ("umulh %1,%2,%0" \
393 # endif /* compiler */
394 # elif defined(_ARCH_PPC64) && defined(SIXTY_FOUR_BIT_LONG)
395 # if defined(__GNUC__) && __GNUC__>=2
396 # define BN_UMULT_HIGH(a,b) ({ \
397 register BN_ULONG ret; \
398 asm ("mulhdu %0,%1,%2" \
402 # endif /* compiler */
403 # elif (defined(__x86_64) || defined(__x86_64__)) && \
404 (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT))
405 # if defined(__GNUC__) && __GNUC__>=2
406 # define BN_UMULT_HIGH(a,b) ({ \
407 register BN_ULONG ret,discard; \
409 : "=a"(discard),"=d"(ret) \
413 # define BN_UMULT_LOHI(low,high,a,b) \
415 : "=a"(low),"=d"(high) \
419 # elif (defined(_M_AMD64) || defined(_M_X64)) && defined(SIXTY_FOUR_BIT)
420 # if defined(_MSC_VER) && _MSC_VER>=1400
421 unsigned __int64 __umulh(unsigned __int64 a, unsigned __int64 b);
422 unsigned __int64 _umul128(unsigned __int64 a, unsigned __int64 b,
423 unsigned __int64 *h);
424 # pragma intrinsic(__umulh,_umul128)
425 # define BN_UMULT_HIGH(a,b) __umulh((a),(b))
426 # define BN_UMULT_LOHI(low,high,a,b) ((low)=_umul128((a),(b),&(high)))
428 # elif defined(__mips) && (defined(SIXTY_FOUR_BIT) || defined(SIXTY_FOUR_BIT_LONG))
429 # if defined(__GNUC__) && __GNUC__>=2
430 # define BN_UMULT_HIGH(a,b) ({ \
431 register BN_ULONG ret; \
432 asm ("dmultu %1,%2" \
434 : "r"(a), "r"(b) : "l"); \
436 # define BN_UMULT_LOHI(low,high,a,b) \
437 asm ("dmultu %2,%3" \
438 : "=l"(low),"=h"(high) \
441 # elif defined(__aarch64__) && defined(SIXTY_FOUR_BIT_LONG)
442 # if defined(__GNUC__) && __GNUC__>=2
443 # define BN_UMULT_HIGH(a,b) ({ \
444 register BN_ULONG ret; \
445 asm ("umulh %0,%1,%2" \
451 # endif /* OPENSSL_NO_ASM */
453 # ifdef BN_DEBUG_RAND
454 # define bn_clear_top2max(a) \
456 int ind = (a)->dmax - (a)->top; \
457 BN_ULONG *ftl = &(a)->d[(a)->top-1]; \
458 for (; ind != 0; ind--) \
462 # define bn_clear_top2max(a)
466 /*******************************************************************
467 * Using the long long type, has to be twice as wide as BN_ULONG...
469 # define Lw(t) (((BN_ULONG)(t))&BN_MASK2)
470 # define Hw(t) (((BN_ULONG)((t)>>BN_BITS2))&BN_MASK2)
472 # define mul_add(r,a,w,c) { \
474 t=(BN_ULLONG)w * (a) + (r) + (c); \
479 # define mul(r,a,w,c) { \
481 t=(BN_ULLONG)w * (a) + (c); \
486 # define sqr(r0,r1,a) { \
488 t=(BN_ULLONG)(a)*(a); \
493 # elif defined(BN_UMULT_LOHI)
494 # define mul_add(r,a,w,c) { \
495 BN_ULONG high,low,ret,tmp=(a); \
497 BN_UMULT_LOHI(low,high,w,tmp); \
499 (c) = (ret<(c))?1:0; \
502 (c) += (ret<low)?1:0; \
506 # define mul(r,a,w,c) { \
507 BN_ULONG high,low,ret,ta=(a); \
508 BN_UMULT_LOHI(low,high,w,ta); \
511 (c) += (ret<low)?1:0; \
515 # define sqr(r0,r1,a) { \
517 BN_UMULT_LOHI(r0,r1,tmp,tmp); \
520 # elif defined(BN_UMULT_HIGH)
521 # define mul_add(r,a,w,c) { \
522 BN_ULONG high,low,ret,tmp=(a); \
524 high= BN_UMULT_HIGH(w,tmp); \
527 (c) = (ret<(c))?1:0; \
530 (c) += (ret<low)?1:0; \
534 # define mul(r,a,w,c) { \
535 BN_ULONG high,low,ret,ta=(a); \
537 high= BN_UMULT_HIGH(w,ta); \
540 (c) += (ret<low)?1:0; \
544 # define sqr(r0,r1,a) { \
547 (r1) = BN_UMULT_HIGH(tmp,tmp); \
551 /*************************************************************
555 # define LBITS(a) ((a)&BN_MASK2l)
556 # define HBITS(a) (((a)>>BN_BITS4)&BN_MASK2l)
557 # define L2HBITS(a) (((a)<<BN_BITS4)&BN_MASK2)
559 # define LLBITS(a) ((a)&BN_MASKl)
560 # define LHBITS(a) (((a)>>BN_BITS2)&BN_MASKl)
561 # define LL2HBITS(a) ((BN_ULLONG)((a)&BN_MASKl)<<BN_BITS2)
563 # define mul64(l,h,bl,bh) \
565 BN_ULONG m,m1,lt,ht; \
573 m=(m+m1)&BN_MASK2; if (m < m1) ht+=L2HBITS((BN_ULONG)1); \
576 lt=(lt+m1)&BN_MASK2; if (lt < m1) ht++; \
581 # define sqr64(lo,ho,in) \
591 h+=(m&BN_MASK2h1)>>(BN_BITS4-1); \
592 m =(m&BN_MASK2l)<<(BN_BITS4+1); \
593 l=(l+m)&BN_MASK2; if (l < m) h++; \
598 # define mul_add(r,a,bl,bh,c) { \
604 mul64(l,h,(bl),(bh)); \
606 /* non-multiply part */ \
607 l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
609 l=(l+(c))&BN_MASK2; if (l < (c)) h++; \
614 # define mul(r,a,bl,bh,c) { \
620 mul64(l,h,(bl),(bh)); \
622 /* non-multiply part */ \
623 l+=(c); if ((l&BN_MASK2) < (c)) h++; \
627 # endif /* !BN_LLONG */
629 void BN_RECP_CTX_init(BN_RECP_CTX *recp);
630 void BN_MONT_CTX_init(BN_MONT_CTX *ctx);
632 void bn_init(BIGNUM *a);
633 void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb);
634 void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
635 void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b);
636 void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp);
637 void bn_sqr_comba8(BN_ULONG *r, const BN_ULONG *a);
638 void bn_sqr_comba4(BN_ULONG *r, const BN_ULONG *a);
639 int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n);
640 int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b, int cl, int dl);
641 void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
642 int dna, int dnb, BN_ULONG *t);
643 void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
644 int n, int tna, int tnb, BN_ULONG *t);
645 void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t);
646 void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n);
647 void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
649 BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
651 int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
652 const BN_ULONG *np, const BN_ULONG *n0, int num);
654 BIGNUM *int_bn_mod_inverse(BIGNUM *in,
655 const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx,
658 static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)
660 if (bits > (INT_MAX - BN_BITS2 + 1))
663 if (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax)
666 return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);
669 int bn_check_prime_int(const BIGNUM *w, int checks, BN_CTX *ctx,
670 int do_trial_division, BN_GENCB *cb);