Home | History | Annotate | Download | only in openssl

Lines Matching full:bignum

169 /* BN_new creates a new, allocated BIGNUM and initialises it. */
170 OPENSSL_EXPORT BIGNUM *BN_new(void);
172 /* BN_init initialises a stack allocated |BIGNUM|. */
173 OPENSSL_EXPORT void BN_init(BIGNUM *bn);
177 OPENSSL_EXPORT void BN_free(BIGNUM *bn);
181 OPENSSL_EXPORT void BN_clear_free(BIGNUM *bn);
183 /* BN_dup allocates a new BIGNUM and sets it equal to |src|. It returns the
184 * allocated BIGNUM on success or NULL otherwise. */
185 OPENSSL_EXPORT BIGNUM *BN_dup(const BIGNUM *src);
189 OPENSSL_EXPORT BIGNUM *BN_copy(BIGNUM *dest, const BIGNUM *src);
192 OPENSSL_EXPORT void BN_clear(BIGNUM *bn);
194 /* BN_value_one returns a static BIGNUM with value 1. */
195 OPENSSL_EXPORT const BIGNUM *BN_value_one(void);
202 OPENSSL_EXPORT unsigned BN_num_bits(const BIGNUM *bn);
206 OPENSSL_EXPORT unsigned BN_num_bytes(const BIGNUM *bn);
209 OPENSSL_EXPORT void BN_zero(BIGNUM *bn);
213 OPENSSL_EXPORT int BN_one(BIGNUM *bn);
217 OPENSSL_EXPORT int BN_set_word(BIGNUM *bn, BN_ULONG value);
221 OPENSSL_EXPORT int BN_set_u64(BIGNUM *bn, uint64_t value);
224 OPENSSL_EXPORT void BN_set_negative(BIGNUM *bn, int sign);
227 OPENSSL_EXPORT int BN_is_negative(const BIGNUM *bn);
234 * |BIGNUM| is allocated and returned. It returns NULL on allocation
236 OPENSSL_EXPORT BIGNUM *BN_bin2bn(const uint8_t *in, size_t len, BIGNUM *ret);
241 OPENSSL_EXPORT size_t BN_bn2bin(const BIGNUM *in, uint8_t *out);
245 * |BIGNUM| is allocated and returned. It returns NULL on allocation
247 OPENSSL_EXPORT BIGNUM *BN_le2bn(const uint8_t *in, size_t len, BIGNUM *ret);
253 OPENSSL_EXPORT int BN_bn2le_padded(uint8_t *out, size_t len, const BIGNUM *in);
259 OPENSSL_EXPORT int BN_bn2bin_padded(uint8_t *out, size_t len, const BIGNUM *in);
262 OPENSSL_EXPORT int BN_bn2cbb_padded(CBB *out, size_t len, const BIGNUM *in);
267 OPENSSL_EXPORT char *BN_bn2hex(const BIGNUM *bn);
271 * If |outp| is not NULL, it constructs a BIGNUM equal to the hex number and
272 * stores it in |*outp|. If |*outp| is NULL then it allocates a new BIGNUM and
275 OPENSSL_EXPORT int BN_hex2bn(BIGNUM **outp, const char *in);
280 OPENSSL_EXPORT char *BN_bn2dec(const BIGNUM *a);
284 * non-decimal data. If |outp| is not NULL, it constructs a BIGNUM equal to the
286 * allocates a new BIGNUM and updates |*outp|. It returns the number of bytes
288 OPENSSL_EXPORT int BN_dec2bn(BIGNUM **outp, const char *in);
294 OPENSSL_EXPORT int BN_asc2bn(BIGNUM **outp, const char *in);
298 OPENSSL_EXPORT int BN_print(BIO *bio, const BIGNUM *a);
301 OPENSSL_EXPORT int BN_print_fp(FILE *fp, const BIGNUM *a);
306 OPENSSL_EXPORT BN_ULONG BN_get_word(const BIGNUM *bn);
311 OPENSSL_EXPORT int BN_get_u64(const BIGNUM *bn, uint64_t *out);
318 OPENSSL_EXPORT int BN_parse_asn1_unsigned(CBS *cbs, BIGNUM *ret);
322 OPENSSL_EXPORT int BN_parse_asn1_unsigned_buggy(CBS *cbs, BIGNUM *ret);
326 OPENSSL_EXPORT int BN_marshal_asn1(CBB *cbb, const BIGNUM *bn);
332 * BIGNUM values. However, be sure that no other function in this file does
337 OPENSSL_EXPORT void bn_correct_top(BIGNUM *bn);
342 OPENSSL_EXPORT BIGNUM *bn_wexpand(BIGNUM *bn, size_t words);
345 /* BIGNUM pools.
347 * Certain BIGNUM operations need to use many temporary variables and
354 * repeatedly to obtain temporary |BIGNUM|s. All |BN_CTX_get| calls must be made
358 * When |BN_CTX_end| is called, the |BIGNUM| pointers obtained from
372 /* BN_CTX_get returns a new |BIGNUM|, or NULL on allocation failure. Once
375 OPENSSL_EXPORT BIGNUM *BN_CTX_get(BN_CTX *ctx);
377 /* BN_CTX_end invalidates all |BIGNUM|s returned from |BN_CTX_get| since the
386 OPENSSL_EXPORT int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
391 OPENSSL_EXPORT int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
394 OPENSSL_EXPORT int BN_add_word(BIGNUM *a, BN_ULONG w);
398 OPENSSL_EXPORT int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
403 OPENSSL_EXPORT int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
407 OPENSSL_EXPORT int BN_sub_word(BIGNUM *a, BN_ULONG w);
411 OPENSSL_EXPORT int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
416 OPENSSL_EXPORT int BN_mul_word(BIGNUM *bn, BN_ULONG w);
421 OPENSSL_EXPORT int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx);
428 OPENSSL_EXPORT int BN_div(BIGNUM *quotient, BIGNUM *rem,
429 const BIGNUM *numerator, const BIGNUM *divisor,
434 OPENSSL_EXPORT BN_ULONG BN_div_word(BIGNUM *numerator, BN_ULONG divisor);
436 /* BN_sqrt sets |*out_sqrt| (which may be the same |BIGNUM| as |in|) to the
440 OPENSSL_EXPORT int BN_sqrt(BIGNUM *out_sqrt, const BIGNUM *in, BN_CTX *ctx);
447 OPENSSL_EXPORT int BN_cmp(const BIGNUM *a, const BIGNUM *b);
450 * |BN_ULONG| instead of a |BIGNUM|. */
451 OPENSSL_EXPORT int BN_cmp_word(const BIGNUM *a, BN_ULONG b);
456 OPENSSL_EXPORT int BN_ucmp(const BIGNUM *a, const BIGNUM *b);
461 OPENSSL_EXPORT int BN_equal_consttime(const BIGNUM *a, const BIGNUM *b);
465 OPENSSL_EXPORT int BN_abs_is_word(const BIGNUM *bn, BN_ULONG w);
468 OPENSSL_EXPORT int BN_is_zero(const BIGNUM *bn);
471 OPENSSL_EXPORT int BN_is_one(const BIGNUM *bn);
474 OPENSSL_EXPORT int BN_is_word(const BIGNUM *bn, BN_ULONG w);
477 OPENSSL_EXPORT int BN_is_odd(const BIGNUM *bn);
480 OPENSSL_EXPORT int BN_is_pow2(const BIGNUM *a);
485 * same |BIGNUM|. It returns one on success and zero on allocation failure. */
486 OPENSSL_EXPORT int BN_lshift(BIGNUM *r, const BIGNUM *a, int n);
490 OPENSSL_EXPORT int BN_lshift1(BIGNUM *r, const BIGNUM *a);
494 OPENSSL_EXPORT int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
498 OPENSSL_EXPORT int BN_rshift1(BIGNUM *r, const BIGNUM *a);
503 OPENSSL_EXPORT int BN_set_bit(BIGNUM *a, int n);
508 OPENSSL_EXPORT int BN_clear_bit(BIGNUM *a, int n);
512 OPENSSL_EXPORT int BN_is_bit_set(const BIGNUM *a, int n);
516 OPENSSL_EXPORT int BN_mask_bits(BIGNUM *a, int n);
522 OPENSSL_EXPORT BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
526 OPENSSL_EXPORT int BN_mod_pow2(BIGNUM *r, const BIGNUM *a, size_t e);
530 OPENSSL_EXPORT int BN_nnmod_pow2(BIGNUM *r, const BIGNUM *a, size_t e);
539 OPENSSL_EXPORT int BN_nnmod(BIGNUM *rem, const BIGNUM *numerator,
540 const BIGNUM *divisor, BN_CTX *ctx);
544 OPENSSL_EXPORT int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
545 const BIGNUM *m, BN_CTX *ctx);
549 OPENSSL_EXPORT int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
550 const BIGNUM *m);
554 OPENSSL_EXPORT int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
555 const BIGNUM *m, BN_CTX *ctx);
559 OPENSSL_EXPORT int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
560 const BIGNUM *m);
564 OPENSSL_EXPORT int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
565 const BIGNUM *m, BN_CTX *ctx);
569 OPENSSL_EXPORT int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m,
574 OPENSSL_EXPORT int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n,
575 const BIGNUM *m, BN_CTX *ctx);
579 OPENSSL_EXPORT int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n,
580 const BIGNUM *m);
584 OPENSSL_EXPORT int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m,
589 OPENSSL_EXPORT int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a,
590 const BIGNUM *m);
592 /* BN_mod_sqrt returns a newly-allocated |BIGNUM|, r, such that
596 OPENSSL_EXPORT BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p,
623 OPENSSL_EXPORT int BN_rand(BIGNUM *rnd, int bits, int top, int bottom);
626 OPENSSL_EXPORT int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom);
630 OPENSSL_EXPORT int BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
635 OPENSSL_EXPORT int BN_rand_range_ex(BIGNUM *r, BN_ULONG min_inclusive,
636 const BIGNUM *max_exclusive);
639 OPENSSL_EXPORT int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
647 OPENSSL_EXPORT int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range,
648 const BIGNUM *priv,
701 OPENSSL_EXPORT int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe,
702 const BIGNUM *add, const BIGNUM *rem,
725 const BIGNUM *candidate, int checks,
740 OPENSSL_EXPORT int BN_is_prime_fasttest_ex(const BIGNUM *candidate, int checks,
748 OPENSSL_EXPORT int BN_is_prime_ex(const BIGNUM *candidate, int checks,
756 OPENSSL_EXPORT int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
760 * fresh BIGNUM is allocated. It returns the result or NULL on error.
768 OPENSSL_EXPORT BIGNUM *BN_mod_inverse(BIGNUM *out, const BIGNUM *a,
769 const BIGNUM *n, BN_CTX *ctx);
777 int BN_mod_inverse_blinded(BIGNUM *out, int *out_no_inverse, const BIGNUM *a,
789 int BN_mod_inverse_odd(BIGNUM *out, int *out_no_inverse, const BIGNUM *a,
790 const BIGNUM *n, BN_CTX *ctx);
794 OPENSSL_EXPORT int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx);
815 OPENSSL_EXPORT int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod,
824 const BIGNUM *mod, BN_CTX *bn_ctx);
829 OPENSSL_EXPORT int BN_to_montgomery(BIGNUM *ret, const BIGNUM *a,
835 OPENSSL_EXPORT int BN_from_montgomery(BIGNUM *ret, const BIGNUM *a,
843 OPENSSL_EXPORT int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a,
844 const BIGNUM *b,
853 OPENSSL_EXPORT int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
860 OPENSSL_EXPORT int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
861 const BIGNUM *m, BN_CTX *ctx);
863 OPENSSL_EXPORT int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
864 const BIGNUM *m, BN_CTX *ctx,
867 OPENSSL_EXPORT int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a,
868 const BIGNUM *p, const BIGNUM *m,
881 OPENSSL_EXPORT size_t BN_bn2mpi(const BIGNUM *in, uint8_t *out);
886 * If |out| is NULL then a fresh |BIGNUM| is allocated and returned, otherwise
889 OPENSSL_EXPORT BIGNUM *BN_mpi2bn(const uint8_t *in, size_t len, BIGNUM *out);
892 * given as a |BN_ULONG| instead of a |BIGNUM *|. It returns one on success
894 OPENSSL_EXPORT int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p,
895 const BIGNUM *m, BN_CTX *ctx,
900 OPENSSL_EXPORT int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1,
901 const BIGNUM *p1, const BIGNUM *a2,
902 const BIGNUM *p2, const BIGNUM *m,
918 BIGNUM RR; /* used to convert to montgomery form */
919 BIGNUM N; /* The modulus */
941 BORINGSSL_MAKE_DELETER(BIGNUM, BN_free)