Skip to content

Commit 1afc0df

Browse files
committed
tfm fp_exptmod_nct: set result to zero when base is zero
1 parent 20115f0 commit 1afc0df

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

wolfcrypt/src/tfm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3171,8 +3171,10 @@ int fp_exptmod_nct(fp_int * G, fp_int * X, fp_int * P, fp_int * Y)
31713171
int x = fp_count_bits (X);
31723172
#endif
31733173

3174+
/* 0^X mod P = 0 mod P = 0.
3175+
* Set result to 0 and return early. */
31743176
if (fp_iszero(G)) {
3175-
fp_set(G, 0);
3177+
fp_set(Y, 0);
31763178
return FP_OKAY;
31773179
}
31783180

0 commit comments

Comments
 (0)