Go to the documentation of this file.
128 if (
r ==
a ||
r ==
p) {
135 if (rr == NULL ||
v == NULL) {
260 if (
a == NULL ||
b == NULL ||
d == NULL ||
r == NULL) {
291 if (recp->
shift == -1) {
335 d->neg =
m->neg ^ recp->
N.
neg;
419 #define TABLE_SIZE 32
424 #define TABLE_BITS_SMALL 5
428 #define TABLE_SIZE_SMALL (1 << (TABLE_BITS_SMALL - 1))
432 int i, j,
ret = 0, wstart, window;
450 if (!aa || !val[0]) {
484 j = 1 << (window - 1);
485 for (
i = 1;
i < j;
i++) {
525 for (
i = 1;
i < window;
i++) {
526 if (wstart -
i < 0) {
530 wvalue <<= (
i - wend);
540 for (
i = 0;
i < j;
i++) {
619 if (
r == NULL || val[0] == NULL) {
626 if (new_mont == NULL) {
646 for (
int i = 1;
i < 1 << (window - 1);
i++) {
648 if (val[
i] == NULL ||
658 int wstart =
bits - 1;
674 for (
int i = 1;
i < window &&
i <= wstart;
i++) {
676 wvalue <<= (
i - wsize);
684 for (
int i = 0;
i < wsize + 1;
i++) {
692 assert(wvalue < (1 << window));
694 if (!
BN_copy(
r, val[wvalue >> 1])) {
702 if (wstart == wsize) {
723 const BN_ULONG *
p,
size_t num_p,
731 while (num_p != 0 &&
p[num_p - 1] == 0) {
754 for (
unsigned i = 1;
i < 1
u << (window - 1);
i++) {
762 unsigned wstart =
bits - 1;
778 for (
unsigned i = 1;
i < window &&
i <= wstart;
i++) {
780 wvalue <<= (
i - wsize);
788 for (
unsigned i = 0;
i < wsize + 1;
i++) {
794 assert(wvalue < (1
u << window));
801 if (wstart == wsize) {
820 const BN_ULONG *
p = mont->
N.
d;
822 if (p_minus_two[0] >= 2) {
826 for (
size_t i = 1;
i <
num;
i++) {
827 if (p_minus_two[
i]-- != 0) {
850 const int width = 1 << window;
853 for (
int j = 0; j <
top; j++) {
854 b->d[j] |=
table[j] & mask;
862 #define MOD_EXP_CTIME_MIN_CACHE_LINE_MASK \
863 (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - 1)
876 #if MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 64
878 #define BN_window_bits_for_ctime_exponent_size(b) \
879 ((b) > 937 ? 6 : (b) > 306 ? 5 : (b) > 89 ? 4 : (b) > 22 ? 3 : 1)
880 #define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (6)
882 #elif MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH == 32
884 #define BN_window_bits_for_ctime_exponent_size(b) \
885 ((b) > 306 ? 5 : (b) > 89 ? 4 : (b) > 22 ? 3 : 1)
886 #define BN_MAX_WINDOW_BITS_FOR_CTIME_EXPONENT_SIZE (5)
892 #define MOD_EXP_CTIME_ALIGN(x_) \
893 ((unsigned char *)(x_) + \
894 (MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH - \
895 (((size_t)(x_)) & (MOD_EXP_CTIME_MIN_CACHE_LINE_MASK))))
904 int i,
ret = 0, window, wvalue;
908 unsigned char *powerbufFree = NULL;
910 BN_ULONG *powerbuf = NULL;
928 int max_bits =
p->width * BN_BITS2;
942 if (new_mont == NULL) {
952 #if defined(OPENSSL_BN_ASM_MONT5) || defined(RSAZ_ENABLED)
960 #if defined(RSAZ_ENABLED)
965 rsaz_avx2_preferred()) {
980 #if defined(OPENSSL_BN_ASM_MONT5)
984 powerbufLen +=
top *
sizeof(mont->
N.
d[0]);
990 numPowers = 1 << window;
993 (
top * numPowers + ((2 *
top) > numPowers ? (2 *
top) : numPowers));
995 #if defined(OPENSSL_BN_ASM_MONT5)
996 if ((
size_t)powerbufLen <=
sizeof(
storage)) {
1000 assert(powerbuf != NULL ||
top * BN_BITS2 > 1024);
1002 if (powerbuf == NULL) {
1005 if (powerbufFree == NULL) {
1013 tmp.d = powerbuf +
top * numPowers;
1031 #if defined(OPENSSL_BN_ASM_MONT5)
1038 if (window == 5 &&
top > 1) {
1039 const BN_ULONG *n0 = mont->
n0;
1053 np[
i] = mont->
N.
d[
i];
1062 for (
i = 4;
i < 32;
i *= 2) {
1066 for (
i = 3;
i < 8;
i += 2) {
1070 for (j = 2 *
i; j < 32; j *= 2) {
1075 for (;
i < 16;
i += 2) {
1081 for (;
i < 32;
i += 2) {
1087 for (wvalue = 0,
i =
bits % 5;
i >= 0;
i--,
bits--) {
1100 for (wvalue = 0,
i = 0;
i < 5;
i++,
bits--) {
1113 assert(
bits < max_bits);
1116 assert(max_bits >= 64);
1122 if (
bits - 4 >= max_bits - 8) {
1124 wvalue = p_bytes[
p->width * BN_BYTES - 1];
1125 wvalue >>= (
bits - 4) & 7;
1132 int first_bit =
bits - 4;
1135 val >>= first_bit & 7;
1167 for (
i = 3;
i < numPowers;
i++) {
1178 for (wvalue = 0,
i =
bits % window;
i >= 0;
i--,
bits--) {
1191 for (
i = 0;
i < window;
i++,
bits--) {
1218 if (powerbuf != NULL && powerbufFree == NULL) {
1251 #define TABLE_SIZE 32
1265 if (new_mont == NULL) {
#define BN_MONT_CTX_new_consttime
void bn_mod_exp_mont_small(BN_ULONG *r, const BN_ULONG *a, size_t num, const BN_ULONG *p, size_t num_p, const BN_MONT_CTX *mont)
#define BN_R_CALLED_WITH_EVEN_MODULUS
int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, const BN_MONT_CTX *mont)
#define BN_FLG_STATIC_DATA
#define bn_one_to_montgomery
#define bn_from_montgomery_small
#define OPENSSL_PUT_ERROR(library, reason)
#define MOD_EXP_CTIME_ALIGN(x_)
OPENSSL_EXPORT pem_password_cb void * u
static int copy_from_prebuf(BIGNUM *b, int top, const BN_ULONG *table, int idx, int window)
static int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, BN_RECP_CTX *recp, BN_CTX *ctx)
int BN_mod_exp2_mont(BIGNUM *rr, const BIGNUM *a1, const BIGNUM *p1, const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, BN_CTX *ctx, const BN_MONT_CTX *mont)
static int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx)
#define BN_R_NEGATIVE_NUMBER
static int BN_window_bits_for_exponent_size(int b)
void bn_mod_inverse0_prime_mont_small(BN_ULONG *r, const BN_ULONG *a, size_t num, const BN_MONT_CTX *mont)
static void * OPENSSL_memset(void *dst, int c, size_t n)
#define BN_R_INPUT_NOT_REDUCED
static int mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx)
int BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, const BN_MONT_CTX *mont)
#define MOD_EXP_CTIME_STORAGE_LEN
#define bn_is_bit_set_words
static void copy_to_prebuf(const BIGNUM *b, int top, BN_ULONG *table, int idx, int window)
int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
#define bn_from_montgomery
static void * OPENSSL_memcpy(void *dst, const void *src, size_t n)
OPENSSL_EXPORT ASN1_BIT_STRING * bits
#define ERR_R_INTERNAL_ERROR
#define bn_mod_mul_montgomery_small
#define bn_mul_mont_gather5
struct bn_recp_ctx_st BN_RECP_CTX
#define BN_MONT_CTX_new_for_modulus
#define BN_window_bits_for_ctime_exponent_size(b)
static int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx)
int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, const BN_MONT_CTX *mont)
static int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, BN_RECP_CTX *recp, BN_CTX *ctx)
UniquePtr< SSL_SESSION > ret
int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx)
#define RSAZ_1024_mod_exp_avx2
static crypto_word_t constant_time_eq_int(int a, int b)
#define BN_SMALL_MAX_WORDS
static void BN_RECP_CTX_init(BN_RECP_CTX *recp)
#define BN_R_BAD_RECIPROCAL
#define BN_mod_mul_montgomery
static void BN_RECP_CTX_free(BN_RECP_CTX *recp)
#define BN_from_montgomery
static ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES absl::base_internal::AtomicHook< StatusPayloadPrinter > storage
#define MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH
static upb_pb_encoder_segment * top(upb_pb_encoder *e)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:58:20