Lines Matching full:bignum
167 /* BN_new creates a new, allocated BIGNUM and initialises it. */
168 OPENSSL_EXPORT BIGNUM *BN_new(void);
170 /* BN_init initialises a stack allocated |BIGNUM|. */
171 OPENSSL_EXPORT void BN_init(BIGNUM *bn);
175 OPENSSL_EXPORT void BN_free(BIGNUM *bn);
179 OPENSSL_EXPORT void BN_clear_free(BIGNUM *bn);
181 /* BN_dup allocates a new BIGNUM and sets it equal to |src|. It returns the
182 * allocated BIGNUM on success or NULL otherwise. */
183 OPENSSL_EXPORT BIGNUM *BN_dup(const BIGNUM *src);
187 OPENSSL_EXPORT BIGNUM *BN_copy(BIGNUM *dest, const BIGNUM *src);
190 OPENSSL_EXPORT void BN_clear(BIGNUM *bn);
192 /* BN_value_one returns a static BIGNUM with value 1. */
193 OPENSSL_EXPORT const BIGNUM *BN_value_one(void);
195 /* BN_with_flags initialises a stack allocated |BIGNUM| with pointers to the
200 OPENSSL_EXPORT void BN_with_flags(BIGNUM *out, const BIGNUM *in, int flags);
207 OPENSSL_EXPORT unsigned BN_num_bits(const BIGNUM *bn);
211 OPENSSL_EXPORT unsigned BN_num_bytes(const BIGNUM *bn);
214 OPENSSL_EXPORT void BN_zero(BIGNUM *bn);
218 OPENSSL_EXPORT int BN_one(BIGNUM *bn);
222 OPENSSL_EXPORT int BN_set_word(BIGNUM *bn, BN_ULONG value);
225 OPENSSL_EXPORT void BN_set_negative(BIGNUM *bn, int sign);
228 OPENSSL_EXPORT int BN_is_negative(const BIGNUM *bn);
231 OPENSSL_EXPORT int BN_get_flags(const BIGNUM *bn, int flags);
234 OPENSSL_EXPORT void BN_set_flags(BIGNUM *bn, int flags);
241 * |BIGNUM| is allocated and returned. It returns NULL on allocation
243 OPENSSL_EXPORT BIGNUM *BN_bin2bn(const uint8_t *in, size_t len, BIGNUM *ret);
248 OPENSSL_EXPORT size_t BN_bn2bin(const BIGNUM *in, uint8_t *out);
254 OPENSSL_EXPORT int BN_bn2bin_padded(uint8_t *out, size_t len, const BIGNUM *in);
257 OPENSSL_EXPORT int BN_bn2cbb_padded(CBB *out, size_t len, const BIGNUM *in);
262 OPENSSL_EXPORT char *BN_bn2hex(const BIGNUM *bn);
266 * If |outp| is not NULL, it constructs a BIGNUM equal to the hex number and
267 * stores it in |*outp|. If |*outp| is NULL then it allocates a new BIGNUM and
270 OPENSSL_EXPORT int BN_hex2bn(BIGNUM **outp, const char *in);
275 OPENSSL_EXPORT char *BN_bn2dec(const BIGNUM *a);
279 * non-decimal data. If |outp| is not NULL, it constructs a BIGNUM equal to the
281 * allocates a new BIGNUM and updates |*outp|. It returns the number of bytes
283 OPENSSL_EXPORT int BN_dec2bn(BIGNUM **outp, const char *in);
289 OPENSSL_EXPORT int BN_asc2bn(BIGNUM **outp, const char *in);
293 OPENSSL_EXPORT int BN_print(BIO *bio, const BIGNUM *a);
296 OPENSSL_EXPORT int BN_print_fp(FILE *fp, const BIGNUM *a);
301 OPENSSL_EXPORT BN_ULONG BN_get_word(const BIGNUM *bn);
308 OPENSSL_EXPORT int BN_cbs2unsigned(CBS *cbs, BIGNUM *ret);
312 OPENSSL_EXPORT int BN_cbs2unsigned_buggy(CBS *cbs, BIGNUM *ret);
316 OPENSSL_EXPORT int BN_bn2cbb(CBB *cbb, const BIGNUM *bn);
322 * BIGNUM values. However, be sure that no other function in this file does
327 OPENSSL_EXPORT void bn_correct_top(BIGNUM *bn);
332 OPENSSL_EXPORT BIGNUM *bn_wexpand(BIGNUM *bn, size_t words);
335 /* BIGNUM pools.
337 * Certain BIGNUM operations need to use many temporary variables and
344 * repeatedly to obtain temporary |BIGNUM|s. All |BN_CTX_get| calls must be made
348 * When |BN_CTX_end| is called, the |BIGNUM| pointers obtained from
362 /* BN_CTX_get returns a new |BIGNUM|, or NULL on allocation failure. Once
365 OPENSSL_EXPORT BIGNUM *BN_CTX_get(BN_CTX *ctx);
367 /* BN_CTX_end invalidates all |BIGNUM|s returned from |BN_CTX_get| since the
376 OPENSSL_EXPORT int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
381 OPENSSL_EXPORT int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
384 OPENSSL_EXPORT int BN_add_word(BIGNUM *a, BN_ULONG w);
388 OPENSSL_EXPORT int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
393 OPENSSL_EXPORT int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
397 OPENSSL_EXPORT int BN_sub_word(BIGNUM *a, BN_ULONG w);
401 OPENSSL_EXPORT int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
406 OPENSSL_EXPORT int BN_mul_word(BIGNUM *bn, BN_ULONG w);
411 OPENSSL_EXPORT int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
418 OPENSSL_EXPORT int BN_div(BIGNUM *quotient, BIGNUM *rem,
419 const BIGNUM *numerator, const BIGNUM *divisor,
424 OPENSSL_EXPORT BN_ULONG BN_div_word(BIGNUM *numerator, BN_ULONG divisor);
426 /* BN_sqrt sets |*out_sqrt| (which may be the same |BIGNUM| as |in|) to the
430 OPENSSL_EXPORT int BN_sqrt(BIGNUM *out_sqrt, const BIGNUM *in, BN_CTX *ctx);
437 OPENSSL_EXPORT int BN_cmp(const BIGNUM *a, const BIGNUM *b);
442 OPENSSL_EXPORT int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
446 OPENSSL_EXPORT int BN_abs_is_word(const BIGNUM *bn, BN_ULONG w);
449 OPENSSL_EXPORT int BN_is_zero(const BIGNUM *bn);
452 OPENSSL_EXPORT int BN_is_one(const BIGNUM *bn);
455 OPENSSL_EXPORT int BN_is_word(const BIGNUM *bn, BN_ULONG w);
458 OPENSSL_EXPORT int BN_is_odd(const BIGNUM *bn);
464 * same |BIGNUM|. It returns one on success and zero on allocation failure. */
465 OPENSSL_EXPORT int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
469 OPENSSL_EXPORT int BN_lshift1(BIGNUM *r, const BIGNUM *a);
473 OPENSSL_EXPORT int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
477 OPENSSL_EXPORT int BN_rshift1(BIGNUM *r, const BIGNUM *a);
482 OPENSSL_EXPORT int BN_set_bit(BIGNUM *a, int n);
487 OPENSSL_EXPORT int BN_clear_bit(BIGNUM *a, int n);
491 OPENSSL_EXPORT int BN_is_bit_set(const BIGNUM *a, int n);
495 OPENSSL_EXPORT int BN_mask_bits(BIGNUM *a, int n);
501 OPENSSL_EXPORT BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
510 OPENSSL_EXPORT int BN_nnmod(BIGNUM *rem, const BIGNUM *numerator,
511 const BIGNUM *divisor, BN_CTX *ctx);
515 OPENSSL_EXPORT int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
516 const BIGNUM *m, BN_CTX *ctx);
520 OPENSSL_EXPORT int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
521 const BIGNUM *m);
525 OPENSSL_EXPORT int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
526 const BIGNUM *m, BN_CTX *ctx);
530 OPENSSL_EXPORT int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
531 const BIGNUM *m);
535 OPENSSL_EXPORT int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
536 const BIGNUM *m, BN_CTX *ctx);
540 OPENSSL_EXPORT int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m,
545 OPENSSL_EXPORT int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n,
546 const BIGNUM *m, BN_CTX *ctx);
550 OPENSSL_EXPORT int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n,
551 const BIGNUM *m);
555 OPENSSL_EXPORT int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m,
560 OPENSSL_EXPORT int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a,
561 const BIGNUM *m);
563 /* BN_mod_sqrt returns a |BIGNUM|, r, such that r^2 == a (mod p). */
564 OPENSSL_EXPORT BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p,
579 OPENSSL_EXPORT int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
582 OPENSSL_EXPORT int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
586 OPENSSL_EXPORT int BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
589 OPENSSL_EXPORT int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
597 OPENSSL_EXPORT int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
598 const BIGNUM *priv,
651 OPENSSL_EXPORT int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
652 const BIGNUM *add, const BIGNUM *rem,
675 const BIGNUM *candidate, int checks,
690 OPENSSL_EXPORT int BN_is_prime_fasttest_ex(const BIGNUM *candidate, int checks,
698 OPENSSL_EXPORT int BN_is_prime_ex(const BIGNUM *candidate, int checks,
706 OPENSSL_EXPORT int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
711 BIGNUM is allocated. It returns the result
713 OPENSSL_EXPORT BIGNUM *BN_mod_inverse(BIGNUM *out, const BIGNUM *a,
714 const BIGNUM *n, BN_CTX *ctx);
720 OPENSSL_EXPORT BIGNUM *BN_mod_inverse_ex(BIGNUM *out, int *out_no_inverse,
721 const BIGNUM *a, const BIGNUM *n,
726 OPENSSL_EXPORT int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
747 OPENSSL_EXPORT int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod,
756 const BIGNUM *mod, BN_CTX *bn_ctx);
760 OPENSSL_EXPORT int BN_to_montgomery(BIGNUM *ret, const BIGNUM *a,
765 OPENSSL_EXPORT int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a,
771 OPENSSL_EXPORT int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a,
772 const BIGNUM *b,
781 OPENSSL_EXPORT int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
788 OPENSSL_EXPORT int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
789 const BIGNUM *m, BN_CTX *ctx);
791 OPENSSL_EXPORT int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
792 const BIGNUM *m, BN_CTX *ctx,
795 OPENSSL_EXPORT int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a,
796 const BIGNUM *p, const BIGNUM *m,
800 OPENSSL_EXPORT int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
801 const BIGNUM *m, BN_CTX *ctx,
803 OPENSSL_EXPORT int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1,
804 const BIGNUM *p1, const BIGNUM *a2,
805 const BIGNUM *p2, const BIGNUM *m,
817 OPENSSL_EXPORT size_t BN_bn2mpi(const BIGNUM *in, uint8_t *out);
822 * If |out| is NULL then a fresh |BIGNUM| is allocated and returned, otherwise
825 OPENSSL_EXPORT BIGNUM *BN_mpi2bn(const uint8_t *in, size_t len, BIGNUM *out);
840 BIGNUM RR; /* used to convert to montgomery form */
841 BIGNUM N; /* The modulus */
861 OPENSSL_EXPORT BIGNUM *get_rfc3526_prime_1536(BIGNUM *bn);