forked from wolfSSL/wolfssl
Merge pull request #4586 from SparkiDev/sp_gen_ecc_order
SP: fix range of k to be 1..n-1
This commit is contained in:
@ -37030,7 +37030,7 @@ static int sp_256_ecc_gen_k_8(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_256_from_bin(k, 8, buf, (int)sizeof(buf));
|
sp_256_from_bin(k, 8, buf, (int)sizeof(buf));
|
||||||
if (sp_256_cmp_8(k, p256_order2) < 0) {
|
if (sp_256_cmp_8(k, p256_order2) <= 0) {
|
||||||
sp_256_add_one_8(k);
|
sp_256_add_one_8(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -46248,7 +46248,7 @@ static int sp_384_ecc_gen_k_12(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_384_from_bin(k, 12, buf, (int)sizeof(buf));
|
sp_384_from_bin(k, 12, buf, (int)sizeof(buf));
|
||||||
if (sp_384_cmp_12(k, p384_order2) < 0) {
|
if (sp_384_cmp_12(k, p384_order2) <= 0) {
|
||||||
sp_384_add_one_12(k);
|
sp_384_add_one_12(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -37370,7 +37370,7 @@ static int sp_256_ecc_gen_k_4(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_256_from_bin(k, 4, buf, (int)sizeof(buf));
|
sp_256_from_bin(k, 4, buf, (int)sizeof(buf));
|
||||||
if (sp_256_cmp_4(k, p256_order2) < 0) {
|
if (sp_256_cmp_4(k, p256_order2) <= 0) {
|
||||||
sp_256_add_one_4(k);
|
sp_256_add_one_4(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -63093,7 +63093,7 @@ static int sp_384_ecc_gen_k_6(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_384_from_bin(k, 6, buf, (int)sizeof(buf));
|
sp_384_from_bin(k, 6, buf, (int)sizeof(buf));
|
||||||
if (sp_384_cmp_6(k, p384_order2) < 0) {
|
if (sp_384_cmp_6(k, p384_order2) <= 0) {
|
||||||
sp_384_add_one_6(k);
|
sp_384_add_one_6(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -103084,7 +103084,7 @@ static int sp_256_ecc_gen_k_8(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_256_from_bin(k, 8, buf, (int)sizeof(buf));
|
sp_256_from_bin(k, 8, buf, (int)sizeof(buf));
|
||||||
if (sp_256_cmp_8(k, p256_order2) < 0) {
|
if (sp_256_cmp_8(k, p256_order2) <= 0) {
|
||||||
sp_256_add_one_8(k);
|
sp_256_add_one_8(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -113564,7 +113564,7 @@ static int sp_384_ecc_gen_k_12(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_384_from_bin(k, 12, buf, (int)sizeof(buf));
|
sp_384_from_bin(k, 12, buf, (int)sizeof(buf));
|
||||||
if (sp_384_cmp_12(k, p384_order2) < 0) {
|
if (sp_384_cmp_12(k, p384_order2) <= 0) {
|
||||||
sp_384_add_one_12(k);
|
sp_384_add_one_12(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -25124,7 +25124,7 @@ static int sp_256_ecc_gen_k_9(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_256_from_bin(k, 9, buf, (int)sizeof(buf));
|
sp_256_from_bin(k, 9, buf, (int)sizeof(buf));
|
||||||
if (sp_256_cmp_9(k, p256_order2) < 0) {
|
if (sp_256_cmp_9(k, p256_order2) <= 0) {
|
||||||
sp_256_add_one_9(k);
|
sp_256_add_one_9(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -32903,7 +32903,7 @@ static int sp_384_ecc_gen_k_15(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_384_from_bin(k, 15, buf, (int)sizeof(buf));
|
sp_384_from_bin(k, 15, buf, (int)sizeof(buf));
|
||||||
if (sp_384_cmp_15(k, p384_order2) < 0) {
|
if (sp_384_cmp_15(k, p384_order2) <= 0) {
|
||||||
sp_384_add_one_15(k);
|
sp_384_add_one_15(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -26407,7 +26407,7 @@ static int sp_256_ecc_gen_k_5(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_256_from_bin(k, 5, buf, (int)sizeof(buf));
|
sp_256_from_bin(k, 5, buf, (int)sizeof(buf));
|
||||||
if (sp_256_cmp_5(k, p256_order2) < 0) {
|
if (sp_256_cmp_5(k, p256_order2) <= 0) {
|
||||||
sp_256_add_one_5(k);
|
sp_256_add_one_5(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -33647,7 +33647,7 @@ static int sp_384_ecc_gen_k_7(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_384_from_bin(k, 7, buf, (int)sizeof(buf));
|
sp_384_from_bin(k, 7, buf, (int)sizeof(buf));
|
||||||
if (sp_384_cmp_7(k, p384_order2) < 0) {
|
if (sp_384_cmp_7(k, p384_order2) <= 0) {
|
||||||
sp_384_add_one_7(k);
|
sp_384_add_one_7(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -22491,7 +22491,7 @@ static int sp_256_ecc_gen_k_8(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_256_from_bin(k, 8, buf, (int)sizeof(buf));
|
sp_256_from_bin(k, 8, buf, (int)sizeof(buf));
|
||||||
if (sp_256_cmp_8(k, p256_order2) < 0) {
|
if (sp_256_cmp_8(k, p256_order2) <= 0) {
|
||||||
sp_256_add_one_8(k);
|
sp_256_add_one_8(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -29688,7 +29688,7 @@ static int sp_384_ecc_gen_k_12(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_384_from_bin(k, 12, buf, (int)sizeof(buf));
|
sp_384_from_bin(k, 12, buf, (int)sizeof(buf));
|
||||||
if (sp_384_cmp_12(k, p384_order2) < 0) {
|
if (sp_384_cmp_12(k, p384_order2) <= 0) {
|
||||||
sp_384_add_one_12(k);
|
sp_384_add_one_12(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -23279,7 +23279,7 @@ static int sp_256_ecc_gen_k_4(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_256_from_bin(k, 4, buf, (int)sizeof(buf));
|
sp_256_from_bin(k, 4, buf, (int)sizeof(buf));
|
||||||
if (sp_256_cmp_4(k, p256_order2) < 0) {
|
if (sp_256_cmp_4(k, p256_order2) <= 0) {
|
||||||
sp_256_add_one_4(k);
|
sp_256_add_one_4(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -47869,7 +47869,7 @@ static int sp_384_ecc_gen_k_6(WC_RNG* rng, sp_digit* k)
|
|||||||
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
err = wc_RNG_GenerateBlock(rng, buf, sizeof(buf));
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
sp_384_from_bin(k, 6, buf, (int)sizeof(buf));
|
sp_384_from_bin(k, 6, buf, (int)sizeof(buf));
|
||||||
if (sp_384_cmp_6(k, p384_order2) < 0) {
|
if (sp_384_cmp_6(k, p384_order2) <= 0) {
|
||||||
sp_384_add_one_6(k);
|
sp_384_add_one_6(k);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user