mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +02:00
Merge pull request #4136 from SparkiDev/tfm_size_checks
tfm: fix length check in add and mul_d
This commit is contained in:
@@ -163,13 +163,12 @@ int s_fp_add(fp_int *a, fp_int *b, fp_int *c)
|
|||||||
c->dp[x] = (fp_digit)t;
|
c->dp[x] = (fp_digit)t;
|
||||||
t >>= DIGIT_BIT;
|
t >>= DIGIT_BIT;
|
||||||
}
|
}
|
||||||
if (t != 0 && x < FP_SIZE) {
|
if (t != 0) {
|
||||||
|
if (x == FP_SIZE)
|
||||||
|
return FP_VAL;
|
||||||
c->dp[c->used++] = (fp_digit)t;
|
c->dp[c->used++] = (fp_digit)t;
|
||||||
++x;
|
++x;
|
||||||
}
|
}
|
||||||
if (x == FP_SIZE) {
|
|
||||||
return FP_VAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
c->used = x;
|
c->used = x;
|
||||||
|
|
||||||
@@ -450,7 +449,9 @@ int fp_mul_d(fp_int *a, fp_digit b, fp_int *c)
|
|||||||
c->dp[x] = (fp_digit)w;
|
c->dp[x] = (fp_digit)w;
|
||||||
w = w >> DIGIT_BIT;
|
w = w >> DIGIT_BIT;
|
||||||
}
|
}
|
||||||
if (w != 0 && (a->used != FP_SIZE)) {
|
if (w != 0) {
|
||||||
|
if (a->used == FP_SIZE)
|
||||||
|
return FP_VAL;
|
||||||
c->dp[c->used++] = (fp_digit) w;
|
c->dp[c->used++] = (fp_digit) w;
|
||||||
++x;
|
++x;
|
||||||
}
|
}
|
||||||
@@ -460,8 +461,6 @@ int fp_mul_d(fp_int *a, fp_digit b, fp_int *c)
|
|||||||
for (; x < oldused && x < FP_SIZE; x++) {
|
for (; x < oldused && x < FP_SIZE; x++) {
|
||||||
c->dp[x] = 0;
|
c->dp[x] = 0;
|
||||||
}
|
}
|
||||||
if (x == FP_SIZE)
|
|
||||||
return FP_VAL;
|
|
||||||
|
|
||||||
fp_clamp(c);
|
fp_clamp(c);
|
||||||
return FP_OKAY;
|
return FP_OKAY;
|
||||||
|
Reference in New Issue
Block a user