Merge pull request #5839 from SparkiDev/sp_int_pub_apis
SP int: fix which APIs are public available wiht WOLFSSL_SP_MATH
This commit is contained in:
commit
c079455d3e
@ -7661,8 +7661,7 @@ void sp_rshd(sp_int* a, int c)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* (WOLFSSL_SP_MATH_ALL && !WOLFSSL_RSA_VERIFY_ONLY) || !NO_DH ||
|
||||
* HAVE_ECC || (!NO_RSA && !WOLFSSL_RSA_VERIFY_ONLY) */
|
||||
#endif /* WOLFSSL_SP_MATH_ALL */
|
||||
|
||||
#if defined(WOLFSSL_SP_MATH_ALL) || !defined(NO_DH) || defined(HAVE_ECC) || \
|
||||
(!defined(NO_RSA) && !defined(WOLFSSL_RSA_VERIFY_ONLY)) || \
|
||||
@ -7955,9 +7954,6 @@ static int _sp_div(sp_int* a, sp_int* d, sp_int* r, sp_int* trial)
|
||||
* @return MP_VAL when a or d is NULL, r and rem are NULL, or d is 0.
|
||||
* @return MP_MEM when dynamic memory allocation fails.
|
||||
*/
|
||||
#ifndef WOLFSSL_SP_MATH_ALL
|
||||
static
|
||||
#endif
|
||||
int sp_div(sp_int* a, sp_int* d, sp_int* r, sp_int* rem)
|
||||
{
|
||||
int err = MP_OKAY;
|
||||
|
@ -41311,7 +41311,11 @@ static int mp_test_shift(mp_int* a, mp_int* r1, WC_RNG* rng)
|
||||
mp_copy(r1, a);
|
||||
if (mp_lshd(r1, i) != MP_OKAY)
|
||||
return -12681;
|
||||
#ifndef WOLFSSL_SP_MATH
|
||||
mp_rshd(r1, i);
|
||||
#else
|
||||
mp_rshb(r1, i * SP_WORD_SIZE);
|
||||
#endif
|
||||
if (mp_cmp(a, r1) != MP_EQ)
|
||||
return -12682;
|
||||
}
|
||||
@ -41655,7 +41659,7 @@ static int mp_test_param(mp_int* a, mp_int* b, mp_int* r, WC_RNG* rng)
|
||||
if (ret != MP_LT)
|
||||
return -12772;
|
||||
|
||||
#if !defined(NO_DH) || defined(HAVE_ECC) || !defined(WOLFSSL_RSA_VERIFY_ONLY)
|
||||
#ifdef WOLFSSL_SP_MATH_ALL
|
||||
mp_rshd(NULL, 1);
|
||||
#endif
|
||||
|
||||
@ -42655,13 +42659,18 @@ static int mp_test_shbd(mp_int* a, mp_int* b, WC_RNG* rng)
|
||||
ret = mp_lshd(a, k);
|
||||
if (ret != MP_OKAY)
|
||||
return -13024;
|
||||
#ifndef WOLFSSL_SP_MATH
|
||||
mp_rshd(a, k);
|
||||
#else
|
||||
mp_rshb(a, k * SP_WORD_SIZE);
|
||||
#endif
|
||||
if (mp_cmp(a, b) != MP_EQ)
|
||||
return -13025;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef WOLFSSL_SP_MATH
|
||||
mp_zero(a);
|
||||
mp_rshd(a, 1);
|
||||
if (!mp_iszero(a))
|
||||
@ -42676,12 +42685,15 @@ static int mp_test_shbd(mp_int* a, mp_int* b, WC_RNG* rng)
|
||||
mp_rshd(a, 2);
|
||||
if (!mp_iszero(a))
|
||||
return -13028;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL)
|
||||
#if defined(WOLFSSL_SP_MATH_ALL) || !defined(NO_DH) || defined(HAVE_ECC) || \
|
||||
(!defined(NO_RSA) && !defined(WOLFSSL_RSA_VERIFY_ONLY) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
static int mp_test_div(mp_int* a, mp_int* d, mp_int* r, mp_int* rem,
|
||||
WC_RNG* rng)
|
||||
{
|
||||
@ -42788,10 +42800,10 @@ static int mp_test_div(mp_int* a, mp_int* d, mp_int* r, mp_int* rem,
|
||||
* a digit. So mp_div must detect and handle.
|
||||
* For example: 0x800000 / 0x8001, DIGIT_BIT = 8
|
||||
*/
|
||||
mp_set(a, 1);
|
||||
mp_mul_2d(a, DIGIT_BIT * 3 - 1, a);
|
||||
mp_set(d, 1);
|
||||
mp_mul_2d(d, DIGIT_BIT * 2 - 1, d);
|
||||
mp_zero(a);
|
||||
mp_set_bit(a, DIGIT_BIT * 3 - 1);
|
||||
mp_zero(d);
|
||||
mp_set_bit(d, DIGIT_BIT * 2 - 1);
|
||||
mp_add_d(d, 1, d);
|
||||
ret = mp_div(a, d, r, rem);
|
||||
if (ret != MP_OKAY)
|
||||
|
@ -881,10 +881,14 @@ MP_API int sp_addmod_ct (sp_int* a, sp_int* b, sp_int* c, sp_int* d);
|
||||
#endif
|
||||
|
||||
MP_API int sp_lshd(sp_int* a, int s);
|
||||
#ifdef WOLFSSL_SP_MATH_ALL
|
||||
MP_API void sp_rshd(sp_int* a, int c);
|
||||
#endif
|
||||
MP_API int sp_rshb(sp_int* a, int n, sp_int* r);
|
||||
|
||||
#ifdef WOLFSSL_SP_MATH_ALL
|
||||
#if defined(WOLFSSL_SP_MATH_ALL) || !defined(NO_DH) || defined(HAVE_ECC) || \
|
||||
(!defined(NO_RSA) && !defined(WOLFSSL_RSA_VERIFY_ONLY) && \
|
||||
!defined(WOLFSSL_RSA_PUBLIC_ONLY))
|
||||
MP_API int sp_div(sp_int* a, sp_int* d, sp_int* r, sp_int* rem);
|
||||
#endif
|
||||
MP_API int sp_mod(sp_int* a, sp_int* m, sp_int* r);
|
||||
|
Loading…
x
Reference in New Issue
Block a user