diff --git a/wolfcrypt/src/sp_arm32.c b/wolfcrypt/src/sp_arm32.c index c6450f75b64..991f5fc4783 100644 --- a/wolfcrypt/src/sp_arm32.c +++ b/wolfcrypt/src/sp_arm32.c @@ -79156,7 +79156,7 @@ static int sp_256_mont_inv_order_8_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_256_mont_mul_order_8(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 8U); @@ -97352,7 +97352,7 @@ static int sp_384_mont_inv_order_12_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const sp_384_mont_mul_order_12(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 12U); @@ -125751,7 +125751,7 @@ static int sp_521_mont_inv_order_17_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const sp_521_mont_mul_order_17(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 17U); diff --git a/wolfcrypt/src/sp_arm64.c b/wolfcrypt/src/sp_arm64.c index 963bcf25c04..f06ad68f74c 100644 --- a/wolfcrypt/src/sp_arm64.c +++ b/wolfcrypt/src/sp_arm64.c @@ -40410,7 +40410,7 @@ static int sp_256_mont_inv_order_4_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_256_mont_mul_order_4(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 4U); @@ -66248,7 +66248,7 @@ static int sp_384_mont_inv_order_6_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_384_mont_mul_order_6(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 6U); @@ -110714,7 +110714,7 @@ static int sp_521_mont_inv_order_9_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_521_mont_mul_order_9(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 9U); diff --git a/wolfcrypt/src/sp_armthumb.c b/wolfcrypt/src/sp_armthumb.c index ab5115c5759..508dbbfd435 100644 --- a/wolfcrypt/src/sp_armthumb.c +++ b/wolfcrypt/src/sp_armthumb.c @@ -104906,7 +104906,7 @@ static int sp_256_mont_inv_order_8_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_256_mont_mul_order_8(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 8U); @@ -115433,7 +115433,7 @@ static int sp_384_mont_inv_order_12_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const sp_384_mont_mul_order_12(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 12U); @@ -130970,7 +130970,7 @@ static int sp_521_mont_inv_order_17_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const sp_521_mont_mul_order_17(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 17U); diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index 05256b3d6c5..137f69cebc2 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -23764,7 +23764,7 @@ static int sp_256_mont_inv_order_9_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_256_mont_mul_order_9(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 9U); @@ -31437,7 +31437,7 @@ static int sp_384_mont_inv_order_15_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const sp_384_mont_mul_order_15(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 15U); @@ -39151,7 +39151,7 @@ static int sp_521_mont_inv_order_21_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const sp_521_mont_mul_order_21(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 21U); diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index f4948e02033..e408e871f44 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -24243,7 +24243,7 @@ static int sp_256_mont_inv_order_5_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_256_mont_mul_order_5(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 5U); @@ -31307,7 +31307,7 @@ static int sp_384_mont_inv_order_7_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_384_mont_mul_order_7(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 7U); @@ -38335,7 +38335,7 @@ static int sp_521_mont_inv_order_9_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_521_mont_mul_order_9(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 9U); diff --git a/wolfcrypt/src/sp_cortexm.c b/wolfcrypt/src/sp_cortexm.c index 4ed704a64d4..5cde3aad8ca 100644 --- a/wolfcrypt/src/sp_cortexm.c +++ b/wolfcrypt/src/sp_cortexm.c @@ -40196,7 +40196,7 @@ static int sp_256_mont_inv_order_8_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_256_mont_mul_order_8(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 8U); @@ -50204,7 +50204,7 @@ static int sp_384_mont_inv_order_12_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const sp_384_mont_mul_order_12(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 12U); @@ -63152,7 +63152,7 @@ static int sp_521_mont_inv_order_17_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const sp_521_mont_mul_order_17(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 17U); diff --git a/wolfcrypt/src/sp_x86_64.c b/wolfcrypt/src/sp_x86_64.c index 99ba9096a1e..ab682df02f1 100644 --- a/wolfcrypt/src/sp_x86_64.c +++ b/wolfcrypt/src/sp_x86_64.c @@ -24382,7 +24382,7 @@ static int sp_256_mont_inv_order_4_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_256_mont_mul_order_4(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 4U); @@ -24605,7 +24605,7 @@ static int sp_256_mont_inv_order_avx2_4_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, co sp_256_mont_mul_order_avx2_4(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 4U); @@ -48945,7 +48945,7 @@ static int sp_384_mont_inv_order_6_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_384_mont_mul_order_6(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 6U); @@ -49101,7 +49101,7 @@ static int sp_384_mont_inv_order_avx2_6_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, co sp_384_mont_mul_order_avx2_6(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 6U); @@ -89615,7 +89615,7 @@ static int sp_521_mont_inv_order_9_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, const s sp_521_mont_mul_order_9(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 9U); @@ -89784,7 +89784,7 @@ static int sp_521_mont_inv_order_avx2_9_nb(sp_ecc_ctx_t* sp_ctx, sp_digit* r, co sp_521_mont_mul_order_avx2_9(t, t, a); } ctx->i--; - ctx->state = (ctx->i == 0) ? 3 : 1; + ctx->state = (ctx->i >= 0) ? 1 : 3; break; case 3: XMEMCPY(r, t, sizeof(sp_digit) * 9U);