rename MP_MAXFAST to MP_MAX_COMBA
This commit is contained in:
parent
b4c42576d7
commit
93f8e7603d
@ -18,7 +18,7 @@ mp_err mp_montgomery_reduce(mp_int *x, const mp_int *n, mp_digit rho)
|
|||||||
digs = (n->used * 2) + 1;
|
digs = (n->used * 2) + 1;
|
||||||
if ((digs < MP_WARRAY) &&
|
if ((digs < MP_WARRAY) &&
|
||||||
(x->used <= MP_WARRAY) &&
|
(x->used <= MP_WARRAY) &&
|
||||||
(n->used < MP_MAXFAST)) {
|
(n->used < MP_MAX_COMBA)) {
|
||||||
return s_mp_montgomery_reduce_comba(x, n, rho);
|
return s_mp_montgomery_reduce_comba(x, n, rho);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
mp_mul.c
2
mp_mul.c
@ -39,7 +39,7 @@ mp_err mp_mul(const mp_int *a, const mp_int *b, mp_int *c)
|
|||||||
* digits won't affect carry propagation
|
* digits won't affect carry propagation
|
||||||
*/
|
*/
|
||||||
(digs < MP_WARRAY) &&
|
(digs < MP_WARRAY) &&
|
||||||
(min <= MP_MAXFAST)) {
|
(min <= MP_MAX_COMBA)) {
|
||||||
err = s_mp_mul_comba(a, b, c, digs);
|
err = s_mp_mul_comba(a, b, c, digs);
|
||||||
} else if (MP_HAS(S_MP_MUL)) {
|
} else if (MP_HAS(S_MP_MUL)) {
|
||||||
err = s_mp_mul(a, b, c, digs);
|
err = s_mp_mul(a, b, c, digs);
|
||||||
|
2
mp_sqr.c
2
mp_sqr.c
@ -15,7 +15,7 @@ mp_err mp_sqr(const mp_int *a, mp_int *b)
|
|||||||
err = s_mp_sqr_karatsuba(a, b);
|
err = s_mp_sqr_karatsuba(a, b);
|
||||||
} else if (MP_HAS(S_MP_SQR_COMBA) && /* can we use the fast comba multiplier? */
|
} else if (MP_HAS(S_MP_SQR_COMBA) && /* can we use the fast comba multiplier? */
|
||||||
(((a->used * 2) + 1) < MP_WARRAY) &&
|
(((a->used * 2) + 1) < MP_WARRAY) &&
|
||||||
(a->used < (MP_MAXFAST / 2))) {
|
(a->used < (MP_MAX_COMBA / 2))) {
|
||||||
err = s_mp_sqr_comba(a, b);
|
err = s_mp_sqr_comba(a, b);
|
||||||
} else if (MP_HAS(S_MP_SQR)) {
|
} else if (MP_HAS(S_MP_SQR)) {
|
||||||
err = s_mp_sqr(a, b);
|
err = s_mp_sqr(a, b);
|
||||||
|
@ -82,7 +82,7 @@ mp_err s_mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_i
|
|||||||
/* automatically pick the comba one if available (saves quite a few calls/ifs) */
|
/* automatically pick the comba one if available (saves quite a few calls/ifs) */
|
||||||
if (MP_HAS(S_MP_MONTGOMERY_REDUCE_COMBA) &&
|
if (MP_HAS(S_MP_MONTGOMERY_REDUCE_COMBA) &&
|
||||||
(((P->used * 2) + 1) < MP_WARRAY) &&
|
(((P->used * 2) + 1) < MP_WARRAY) &&
|
||||||
(P->used < MP_MAXFAST)) {
|
(P->used < MP_MAX_COMBA)) {
|
||||||
redux = s_mp_montgomery_reduce_comba;
|
redux = s_mp_montgomery_reduce_comba;
|
||||||
} else if (MP_HAS(MP_MONTGOMERY_REDUCE)) {
|
} else if (MP_HAS(MP_MONTGOMERY_REDUCE)) {
|
||||||
/* use slower baseline Montgomery method */
|
/* use slower baseline Montgomery method */
|
||||||
|
@ -15,7 +15,7 @@ mp_err s_mp_mul(const mp_int *a, const mp_int *b, mp_int *c, int digs)
|
|||||||
|
|
||||||
/* can we use the fast multiplier? */
|
/* can we use the fast multiplier? */
|
||||||
if ((digs < MP_WARRAY) &&
|
if ((digs < MP_WARRAY) &&
|
||||||
(MP_MIN(a->used, b->used) < MP_MAXFAST)) {
|
(MP_MIN(a->used, b->used) < MP_MAX_COMBA)) {
|
||||||
return s_mp_mul_comba(a, b, c, digs);
|
return s_mp_mul_comba(a, b, c, digs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ mp_err s_mp_mul_high(const mp_int *a, const mp_int *b, mp_int *c, int digs)
|
|||||||
/* can we use the fast multiplier? */
|
/* can we use the fast multiplier? */
|
||||||
if (MP_HAS(S_MP_MUL_HIGH_COMBA)
|
if (MP_HAS(S_MP_MUL_HIGH_COMBA)
|
||||||
&& ((a->used + b->used + 1) < MP_WARRAY)
|
&& ((a->used + b->used + 1) < MP_WARRAY)
|
||||||
&& (MP_MIN(a->used, b->used) < MP_MAXFAST)) {
|
&& (MP_MIN(a->used, b->used) < MP_MAX_COMBA)) {
|
||||||
return s_mp_mul_high_comba(a, b, c, digs);
|
return s_mp_mul_high_comba(a, b, c, digs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +124,8 @@ extern void MP_FREE(void *mem, size_t size);
|
|||||||
#define MP_STATIC_ASSERT(msg, cond) typedef char mp_static_assert_##msg[(cond) ? 1 : -1];
|
#define MP_STATIC_ASSERT(msg, cond) typedef char mp_static_assert_##msg[(cond) ? 1 : -1];
|
||||||
|
|
||||||
#define MP_SIZEOF_BITS(type) ((size_t)CHAR_BIT * sizeof(type))
|
#define MP_SIZEOF_BITS(type) ((size_t)CHAR_BIT * sizeof(type))
|
||||||
#define MP_MAXFAST (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
|
|
||||||
|
|
||||||
|
#define MP_MAX_COMBA (int)(1uL << (MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)))
|
||||||
#define MP_WARRAY (int)(1uL << ((MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)) + 1u))
|
#define MP_WARRAY (int)(1uL << ((MP_SIZEOF_BITS(mp_word) - (2u * (size_t)MP_DIGIT_BIT)) + 1u))
|
||||||
|
|
||||||
#if defined(MP_16BIT)
|
#if defined(MP_16BIT)
|
||||||
|
Loading…
Reference in New Issue
Block a user