yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 1 | /* integer.h |
| 2 | * |
| 3 | * Copyright (C) 2006-2021 wolfSSL Inc. |
| 4 | * |
| 5 | * This file is part of wolfSSL. |
| 6 | * |
| 7 | * wolfSSL is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * wolfSSL is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA |
| 20 | */ |
| 21 | |
| 22 | |
| 23 | /* |
| 24 | * Based on public domain LibTomMath 0.38 by Tom St Denis, tomstdenis@iahu.ca, |
| 25 | * http://math.libtomcrypt.com |
| 26 | */ |
| 27 | |
| 28 | |
| 29 | #ifndef WOLF_CRYPT_INTEGER_H |
| 30 | #define WOLF_CRYPT_INTEGER_H |
| 31 | |
| 32 | /* may optionally use fast math instead, not yet supported on all platforms and |
| 33 | may not be faster on all |
| 34 | */ |
| 35 | #include <wolfssl/wolfcrypt/types.h> /* will set MP_xxBIT if not default */ |
| 36 | #if defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL) |
| 37 | #include <wolfssl/wolfcrypt/sp_int.h> |
| 38 | #elif defined(USE_FAST_MATH) |
| 39 | #include <wolfssl/wolfcrypt/tfm.h> |
| 40 | #else |
| 41 | |
| 42 | #include <wolfssl/wolfcrypt/random.h> |
| 43 | |
| 44 | #ifndef CHAR_BIT |
| 45 | #if defined(WOLFSSL_LINUXKM) |
| 46 | #include <linux/limits.h> |
| 47 | #else |
| 48 | #include <limits.h> |
| 49 | #endif |
| 50 | #endif |
| 51 | |
| 52 | #include <wolfssl/wolfcrypt/mpi_class.h> |
| 53 | |
| 54 | |
| 55 | #ifdef __cplusplus |
| 56 | extern "C" { |
| 57 | |
| 58 | /* C++ compilers don't like assigning void * to mp_digit * */ |
| 59 | #define OPT_CAST(x) (x *) |
| 60 | |
| 61 | #elif defined(_SH3) |
| 62 | |
| 63 | /* SuperH SH3 compiler doesn't like assigning voi* to mp_digit* */ |
| 64 | #define OPT_CAST(x) (x *) |
| 65 | |
| 66 | #else |
| 67 | |
| 68 | /* C on the other hand doesn't care */ |
| 69 | #define OPT_CAST(x) |
| 70 | |
| 71 | #endif /* __cplusplus */ |
| 72 | |
| 73 | |
| 74 | /* detect 64-bit mode if possible */ |
| 75 | #if (defined(__x86_64__) || defined(__aarch64__)) && !(defined (_MSC_VER) && defined(__clang__)) |
| 76 | #if !(defined(MP_64BIT) && defined(MP_16BIT) && defined(MP_8BIT)) |
| 77 | #define MP_64BIT |
| 78 | #endif |
| 79 | #endif |
| 80 | /* if intel compiler doesn't provide 128 bit type don't turn on 64bit */ |
| 81 | #if defined(MP_64BIT) && defined(__INTEL_COMPILER) && !defined(HAVE___UINT128_T) |
| 82 | #undef MP_64BIT |
| 83 | #endif |
| 84 | |
| 85 | |
| 86 | /* allow user to define on mp_digit, mp_word, DIGIT_BIT types */ |
| 87 | #ifndef WOLFSSL_BIGINT_TYPES |
| 88 | |
| 89 | /* some default configurations. |
| 90 | * |
| 91 | * A "mp_digit" must be able to hold DIGIT_BIT + 1 bits |
| 92 | * A "mp_word" must be able to hold 2*DIGIT_BIT + 1 bits |
| 93 | * |
| 94 | * At the very least a mp_digit must be able to hold 7 bits |
| 95 | * [any size beyond that is ok provided it doesn't overflow the data type] |
| 96 | */ |
| 97 | #ifdef MP_8BIT |
| 98 | /* 8-bit */ |
| 99 | typedef unsigned char mp_digit; |
| 100 | typedef unsigned short mp_word; |
| 101 | /* don't define DIGIT_BIT, so its calculated below */ |
| 102 | #elif defined(MP_16BIT) |
| 103 | /* 16-bit */ |
| 104 | typedef unsigned int mp_digit; |
| 105 | typedef unsigned long mp_word; |
| 106 | /* don't define DIGIT_BIT, so its calculated below */ |
| 107 | #elif defined(NO_64BIT) |
| 108 | /* 32-bit forced to 16-bit */ |
| 109 | typedef unsigned short mp_digit; |
| 110 | typedef unsigned int mp_word; |
| 111 | #define DIGIT_BIT 12 |
| 112 | #elif defined(MP_64BIT) |
| 113 | /* 64-bit */ |
| 114 | /* for GCC only on supported platforms */ |
| 115 | typedef unsigned long long mp_digit; /* 64 bit type, 128 uses mode(TI) */ |
| 116 | typedef unsigned long mp_word __attribute__ ((mode(TI))); |
| 117 | #define DIGIT_BIT 60 |
| 118 | #else |
| 119 | /* 32-bit default case */ |
| 120 | |
| 121 | #if defined(_MSC_VER) || defined(__BORLANDC__) |
| 122 | typedef unsigned __int64 ulong64; |
| 123 | #else |
| 124 | typedef unsigned long long ulong64; |
| 125 | #endif |
| 126 | |
| 127 | typedef unsigned int mp_digit; /* long could be 64 now, changed TAO */ |
| 128 | typedef ulong64 mp_word; |
| 129 | |
| 130 | #ifdef MP_31BIT |
| 131 | /* this is an extension that uses 31-bit digits */ |
| 132 | #define DIGIT_BIT 31 |
| 133 | #else |
| 134 | /* default case is 28-bit digits, defines MP_28BIT as a handy test macro */ |
| 135 | #define DIGIT_BIT 28 |
| 136 | #define MP_28BIT |
| 137 | #endif |
| 138 | #endif |
| 139 | |
| 140 | #endif /* WOLFSSL_BIGINT_TYPES */ |
| 141 | |
| 142 | /* otherwise the bits per digit is calculated automatically from the size of |
| 143 | a mp_digit */ |
| 144 | #ifndef DIGIT_BIT |
| 145 | #define DIGIT_BIT ((int)((CHAR_BIT * sizeof(mp_digit) - 1))) |
| 146 | /* bits per digit */ |
| 147 | #endif |
| 148 | |
| 149 | #define MP_DIGIT_BIT DIGIT_BIT |
| 150 | #define MP_MASK ((((mp_digit)1)<<((mp_digit)DIGIT_BIT))-((mp_digit)1)) |
| 151 | #define MP_DIGIT_MAX MP_MASK |
| 152 | |
| 153 | /* equalities */ |
| 154 | #define MP_LT -1 /* less than */ |
| 155 | #define MP_EQ 0 /* equal to */ |
| 156 | #define MP_GT 1 /* greater than */ |
| 157 | |
| 158 | #define MP_ZPOS 0 /* positive integer */ |
| 159 | #define MP_NEG 1 /* negative */ |
| 160 | |
| 161 | #define MP_OKAY 0 /* ok result */ |
| 162 | #define MP_MEM -2 /* out of mem */ |
| 163 | #define MP_VAL -3 /* invalid input */ |
| 164 | #define MP_NOT_INF -4 /* point not at infinity */ |
| 165 | #define MP_RANGE MP_NOT_INF |
| 166 | |
| 167 | #define MP_YES 1 /* yes response */ |
| 168 | #define MP_NO 0 /* no response */ |
| 169 | |
| 170 | /* Primality generation flags */ |
| 171 | #define LTM_PRIME_BBS 0x0001 /* BBS style prime */ |
| 172 | #define LTM_PRIME_SAFE 0x0002 /* Safe prime (p-1)/2 == prime */ |
| 173 | #define LTM_PRIME_2MSB_ON 0x0008 /* force 2nd MSB to 1 */ |
| 174 | |
| 175 | typedef int mp_err; |
| 176 | |
| 177 | /* define this to use lower memory usage routines (exptmods mostly) */ |
| 178 | #define MP_LOW_MEM |
| 179 | |
| 180 | /* default precision */ |
| 181 | #ifndef MP_PREC |
| 182 | #ifndef MP_LOW_MEM |
| 183 | #define MP_PREC 32 /* default digits of precision */ |
| 184 | #else |
| 185 | #define MP_PREC 1 /* default digits of precision */ |
| 186 | #endif |
| 187 | #endif |
| 188 | |
| 189 | /* size of comba arrays, should be at least 2 * 2**(BITS_PER_WORD - |
| 190 | BITS_PER_DIGIT*2) */ |
| 191 | #define MP_WARRAY ((mp_word)1 << (sizeof(mp_word) * CHAR_BIT - 2 * DIGIT_BIT + 1)) |
| 192 | |
| 193 | #ifdef HAVE_WOLF_BIGINT |
| 194 | /* raw big integer */ |
| 195 | typedef struct WC_BIGINT { |
| 196 | byte* buf; |
| 197 | word32 len; |
| 198 | void* heap; |
| 199 | } WC_BIGINT; |
| 200 | #define WOLF_BIGINT_DEFINED |
| 201 | #endif |
| 202 | |
| 203 | /* the mp_int structure */ |
| 204 | typedef struct mp_int { |
| 205 | int used, alloc, sign; |
| 206 | mp_digit *dp; |
| 207 | |
| 208 | #ifdef HAVE_WOLF_BIGINT |
| 209 | struct WC_BIGINT raw; /* unsigned binary (big endian) */ |
| 210 | #endif |
| 211 | } mp_int; |
| 212 | |
| 213 | /* wolf big int and common functions */ |
| 214 | #include <wolfssl/wolfcrypt/wolfmath.h> |
| 215 | |
| 216 | |
| 217 | /* callback for mp_prime_random, should fill dst with random bytes and return |
| 218 | how many read [up to len] */ |
| 219 | typedef int ltm_prime_callback(unsigned char *dst, int len, void *dat); |
| 220 | |
| 221 | |
| 222 | #define USED(m) ((m)->used) |
| 223 | #define DIGIT(m,k) ((m)->dp[(k)]) |
| 224 | #define SIGN(m) ((m)->sign) |
| 225 | |
| 226 | |
| 227 | /* ---> Basic Manipulations <--- */ |
| 228 | #define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO) |
| 229 | #define mp_isone(a) \ |
| 230 | (((((a)->used == 1)) && ((a)->dp[0] == 1u) && ((a)->sign == MP_ZPOS)) \ |
| 231 | ? MP_YES : MP_NO) |
| 232 | #define mp_iseven(a) \ |
| 233 | (((a)->used > 0 && (((a)->dp[0] & 1u) == 0u)) ? MP_YES : MP_NO) |
| 234 | #define mp_isodd(a) \ |
| 235 | (((a)->used > 0 && (((a)->dp[0] & 1u) == 1u)) ? MP_YES : MP_NO) |
| 236 | #define mp_isneg(a) (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO) |
| 237 | #define mp_isword(a, w) \ |
| 238 | ((((a)->used == 1) && ((a)->dp[0] == w)) || ((w == 0) && ((a)->used == 0)) \ |
| 239 | ? MP_YES : MP_NO) |
| 240 | |
| 241 | /* number of primes */ |
| 242 | #ifdef MP_8BIT |
| 243 | #define PRIME_SIZE 31 |
| 244 | #else |
| 245 | #define PRIME_SIZE 256 |
| 246 | #endif |
| 247 | |
| 248 | #ifndef MAX_INVMOD_SZ |
| 249 | #if defined(WOLFSSL_MYSQL_COMPATIBLE) |
| 250 | #define MAX_INVMOD_SZ 8192 |
| 251 | #else |
| 252 | #define MAX_INVMOD_SZ 4096 |
| 253 | #endif |
| 254 | #endif |
| 255 | |
| 256 | #define mp_prime_random(a, t, size, bbs, cb, dat) \ |
| 257 | mp_prime_random_ex(a, t, ((size) * 8) + 1, (bbs==1)?LTM_PRIME_BBS:0, cb, dat) |
| 258 | |
| 259 | #define mp_read_mag(mp, str, len) mp_read_unsigned_bin((mp), (str), (len)) |
| 260 | #define mp_mag_size(mp) mp_unsigned_bin_size(mp) |
| 261 | #define mp_tomag(mp, str) mp_to_unsigned_bin((mp), (str)) |
| 262 | |
| 263 | #define MP_RADIX_BIN 2 |
| 264 | #define MP_RADIX_OCT 8 |
| 265 | #define MP_RADIX_DEC 10 |
| 266 | #define MP_RADIX_HEX 16 |
| 267 | #define MP_RADIX_MAX 64 |
| 268 | |
| 269 | #define mp_tobinary(M, S) mp_toradix((M), (S), MP_RADIX_BIN) |
| 270 | #define mp_tooctal(M, S) mp_toradix((M), (S), MP_RADIX_OCT) |
| 271 | #define mp_todecimal(M, S) mp_toradix((M), (S), MP_RADIX_DEC) |
| 272 | #define mp_tohex(M, S) mp_toradix((M), (S), MP_RADIX_HEX) |
| 273 | |
| 274 | #define s_mp_mul(a, b, c) s_mp_mul_digs(a, b, c, (a)->used + (b)->used + 1) |
| 275 | |
| 276 | #if defined(HAVE_ECC) || defined(WOLFSSL_KEY_GEN) || defined(HAVE_COMP_KEY) || \ |
| 277 | defined(WOLFSSL_DEBUG_MATH) || defined(DEBUG_WOLFSSL) |
| 278 | extern const char *mp_s_rmap; |
| 279 | #endif |
| 280 | |
| 281 | /* 6 functions needed by Rsa */ |
| 282 | MP_API int mp_init (mp_int * a); |
| 283 | MP_API void mp_clear (mp_int * a); |
| 284 | MP_API void mp_free (mp_int * a); |
| 285 | MP_API void mp_forcezero(mp_int * a); |
| 286 | MP_API int mp_unsigned_bin_size(const mp_int * a); |
| 287 | MP_API int mp_read_unsigned_bin (mp_int * a, const unsigned char *b, int c); |
| 288 | MP_API int mp_to_unsigned_bin_at_pos(int x, mp_int *t, unsigned char *b); |
| 289 | MP_API int mp_to_unsigned_bin (mp_int * a, unsigned char *b); |
| 290 | MP_API int mp_to_unsigned_bin_len(mp_int * a, unsigned char *b, int c); |
| 291 | MP_API int mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y); |
| 292 | MP_API int mp_exptmod_ex (mp_int * G, mp_int * X, int digits, mp_int * P, |
| 293 | mp_int * Y); |
| 294 | /* end functions needed by Rsa */ |
| 295 | |
| 296 | /* functions added to support above needed, removed TOOM and KARATSUBA */ |
| 297 | MP_API int mp_count_bits (const mp_int * a); |
| 298 | MP_API int mp_leading_bit (mp_int * a); |
| 299 | MP_API int mp_init_copy (mp_int * a, mp_int * b); |
| 300 | MP_API int mp_copy (const mp_int * a, mp_int * b); |
| 301 | MP_API int mp_grow (mp_int * a, int size); |
| 302 | MP_API int mp_div_2d (mp_int * a, int b, mp_int * c, mp_int * d); |
| 303 | MP_API void mp_zero (mp_int * a); |
| 304 | MP_API void mp_clamp (mp_int * a); |
| 305 | MP_API void mp_exch (mp_int * a, mp_int * b); |
| 306 | MP_API int mp_cond_swap_ct (mp_int * a, mp_int * b, int c, int m); |
| 307 | MP_API void mp_rshd (mp_int * a, int b); |
| 308 | MP_API void mp_rshb (mp_int * a, int b); |
| 309 | MP_API int mp_mod_2d (mp_int * a, int b, mp_int * c); |
| 310 | MP_API int mp_mul_2d (mp_int * a, int b, mp_int * c); |
| 311 | MP_API int mp_lshd (mp_int * a, int b); |
| 312 | MP_API int mp_abs (mp_int * a, mp_int * b); |
| 313 | MP_API int mp_invmod (mp_int * a, mp_int * b, mp_int * c); |
| 314 | int fast_mp_invmod (mp_int * a, mp_int * b, mp_int * c); |
| 315 | MP_API int mp_invmod_slow (mp_int * a, mp_int * b, mp_int * c); |
| 316 | MP_API int mp_cmp_mag (mp_int * a, mp_int * b); |
| 317 | MP_API int mp_cmp (mp_int * a, mp_int * b); |
| 318 | MP_API int mp_cmp_d(mp_int * a, mp_digit b); |
| 319 | MP_API int mp_set (mp_int * a, mp_digit b); |
| 320 | MP_API int mp_is_bit_set (mp_int * a, mp_digit b); |
| 321 | MP_API int mp_mod (mp_int * a, mp_int * b, mp_int * c); |
| 322 | MP_API int mp_div(mp_int * a, mp_int * b, mp_int * c, mp_int * d); |
| 323 | MP_API int mp_div_2(mp_int * a, mp_int * b); |
| 324 | MP_API int mp_div_2_mod_ct (mp_int* a, mp_int* b, mp_int* c); |
| 325 | MP_API int mp_add (mp_int * a, mp_int * b, mp_int * c); |
| 326 | int s_mp_add (mp_int * a, mp_int * b, mp_int * c); |
| 327 | int s_mp_sub (mp_int * a, mp_int * b, mp_int * c); |
| 328 | MP_API int mp_sub (mp_int * a, mp_int * b, mp_int * c); |
| 329 | MP_API int mp_reduce_is_2k_l(mp_int *a); |
| 330 | MP_API int mp_reduce_is_2k(mp_int *a); |
| 331 | MP_API int mp_dr_is_modulus(mp_int *a); |
| 332 | MP_API int mp_exptmod_fast (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, |
| 333 | int); |
| 334 | MP_API int mp_exptmod_base_2 (mp_int * X, mp_int * P, mp_int * Y); |
| 335 | #define mp_exptmod_nct(G,X,P,Y) mp_exptmod_fast(G,X,P,Y,0) |
| 336 | MP_API int mp_montgomery_setup (mp_int * n, mp_digit * rho); |
| 337 | int fast_mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho); |
| 338 | MP_API int mp_montgomery_reduce (mp_int * x, mp_int * n, mp_digit rho); |
| 339 | #define mp_montgomery_reduce_ex(x, n, rho, ct) mp_montgomery_reduce (x, n, rho) |
| 340 | MP_API void mp_dr_setup(mp_int *a, mp_digit *d); |
| 341 | MP_API int mp_dr_reduce (mp_int * x, mp_int * n, mp_digit k); |
| 342 | MP_API int mp_reduce_2k(mp_int *a, mp_int *n, mp_digit d); |
| 343 | int fast_s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs); |
| 344 | int s_mp_mul_high_digs (mp_int * a, mp_int * b, mp_int * c, int digs); |
| 345 | MP_API int mp_reduce_2k_setup_l(mp_int *a, mp_int *d); |
| 346 | MP_API int mp_reduce_2k_l(mp_int *a, mp_int *n, mp_int *d); |
| 347 | MP_API int mp_reduce (mp_int * x, mp_int * m, mp_int * mu); |
| 348 | MP_API int mp_reduce_setup (mp_int * a, mp_int * b); |
| 349 | int s_mp_exptmod (mp_int * G, mp_int * X, mp_int * P, mp_int * Y, int redmode); |
| 350 | MP_API int mp_montgomery_calc_normalization (mp_int * a, mp_int * b); |
| 351 | int s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs); |
| 352 | int s_mp_sqr (mp_int * a, mp_int * b); |
| 353 | int fast_s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs); |
| 354 | int fast_s_mp_sqr (mp_int * a, mp_int * b); |
| 355 | MP_API int mp_init_size (mp_int * a, int size); |
| 356 | MP_API int mp_div_3 (mp_int * a, mp_int *c, mp_digit * d); |
| 357 | MP_API int mp_mul_2(mp_int * a, mp_int * b); |
| 358 | MP_API int mp_mul (mp_int * a, mp_int * b, mp_int * c); |
| 359 | MP_API int mp_sqr (mp_int * a, mp_int * b); |
| 360 | MP_API int mp_mulmod (mp_int * a, mp_int * b, mp_int * c, mp_int * d); |
| 361 | MP_API int mp_submod (mp_int* a, mp_int* b, mp_int* c, mp_int* d); |
| 362 | MP_API int mp_addmod (mp_int* a, mp_int* b, mp_int* c, mp_int* d); |
| 363 | MP_API int mp_submod_ct (mp_int* a, mp_int* b, mp_int* c, mp_int* d); |
| 364 | MP_API int mp_addmod_ct (mp_int* a, mp_int* b, mp_int* c, mp_int* d); |
| 365 | MP_API int mp_mul_d (mp_int * a, mp_digit b, mp_int * c); |
| 366 | MP_API int mp_2expt (mp_int * a, int b); |
| 367 | MP_API int mp_set_bit (mp_int * a, int b); |
| 368 | MP_API int mp_reduce_2k_setup(mp_int *a, mp_digit *d); |
| 369 | MP_API int mp_add_d (mp_int* a, mp_digit b, mp_int* c); |
| 370 | MP_API int mp_set_int (mp_int * a, unsigned long b); |
| 371 | MP_API int mp_sub_d (mp_int * a, mp_digit b, mp_int * c); |
| 372 | /* end support added functions */ |
| 373 | |
| 374 | /* added */ |
| 375 | MP_API int mp_init_multi(mp_int* a, mp_int* b, mp_int* c, mp_int* d, mp_int* e, |
| 376 | mp_int* f); |
| 377 | MP_API int mp_toradix (mp_int *a, char *str, int radix); |
| 378 | MP_API int mp_radix_size (mp_int * a, int radix, int *size); |
| 379 | |
| 380 | #ifdef WOLFSSL_DEBUG_MATH |
| 381 | MP_API void mp_dump(const char* desc, mp_int* a, byte verbose); |
| 382 | #else |
| 383 | #define mp_dump(desc, a, verbose) |
| 384 | #endif |
| 385 | |
| 386 | #if defined(HAVE_ECC) || defined(WOLFSSL_KEY_GEN) || !defined(NO_RSA) || \ |
| 387 | !defined(NO_DSA) || !defined(NO_DH) |
| 388 | MP_API int mp_sqrmod(mp_int* a, mp_int* b, mp_int* c); |
| 389 | #endif |
| 390 | #if !defined(NO_DSA) || defined(HAVE_ECC) |
| 391 | MP_API int mp_read_radix(mp_int* a, const char* str, int radix); |
| 392 | #endif |
| 393 | |
| 394 | #if defined(WOLFSSL_KEY_GEN) || !defined(NO_RSA) || !defined(NO_DSA) || !defined(NO_DH) |
| 395 | MP_API int mp_prime_is_prime (mp_int * a, int t, int *result); |
| 396 | MP_API int mp_prime_is_prime_ex (mp_int * a, int t, int *result, WC_RNG*); |
| 397 | #endif /* WOLFSSL_KEY_GEN NO_RSA NO_DSA NO_DH */ |
| 398 | #ifdef WOLFSSL_KEY_GEN |
| 399 | MP_API int mp_gcd (mp_int * a, mp_int * b, mp_int * c); |
| 400 | MP_API int mp_lcm (mp_int * a, mp_int * b, mp_int * c); |
| 401 | MP_API int mp_rand_prime(mp_int* N, int len, WC_RNG* rng, void* heap); |
| 402 | #endif |
| 403 | |
| 404 | MP_API int mp_cnt_lsb(mp_int *a); |
| 405 | MP_API int mp_mod_d(mp_int* a, mp_digit b, mp_digit* c); |
| 406 | |
| 407 | |
| 408 | #ifdef __cplusplus |
| 409 | } |
| 410 | #endif |
| 411 | |
| 412 | |
| 413 | #endif /* USE_FAST_MATH */ |
| 414 | |
| 415 | #endif /* WOLF_CRYPT_INTEGER_H */ |
| 416 | |