forked from wolfSSL/wolfssl
TFM: mp_exptmod_ex didn't handle exceptional cases
fp_exptmod_ex() changed to match execptional case handling in fp_exptmod().
This commit is contained in:
@ -2895,14 +2895,21 @@ int fp_exptmod_ex(fp_int * G, fp_int * X, int digits, fp_int * P, fp_int * Y)
|
||||
int x = fp_count_bits (X);
|
||||
#endif
|
||||
|
||||
if (fp_iszero(G)) {
|
||||
/* handle modulus of zero and prevent overflows */
|
||||
if (fp_iszero(P) || (P->used > (FP_SIZE/2))) {
|
||||
return FP_VAL;
|
||||
}
|
||||
if (fp_isone(P)) {
|
||||
fp_set(Y, 0);
|
||||
return FP_OKAY;
|
||||
}
|
||||
|
||||
/* prevent overflows */
|
||||
if (P->used > (FP_SIZE/2)) {
|
||||
return FP_VAL;
|
||||
if (fp_iszero(X)) {
|
||||
fp_set(Y, 1);
|
||||
return FP_OKAY;
|
||||
}
|
||||
if (fp_iszero(G)) {
|
||||
fp_set(Y, 0);
|
||||
return FP_OKAY;
|
||||
}
|
||||
|
||||
#if defined(WOLFSSL_ESP32WROOM32_CRYPT_RSA_PRI) && \
|
||||
|
Reference in New Issue
Block a user