forked from wolfSSL/wolfssl
Merge pull request #6622 from philljj/zd16426
tfm fp_exptmod_nct: set result to zero when base is zero
This commit is contained in:
@ -3171,14 +3171,21 @@ int fp_exptmod_nct(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
|
||||
int x = fp_count_bits (X);
|
||||
#endif
|
||||
|
||||
if (fp_iszero(G)) {
|
||||
fp_set(G, 0);
|
||||
/* 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_ESP32_CRYPT_RSA_PRI) && \
|
||||
|
Reference in New Issue
Block a user