mirror of https://github.com/wolfSSL/wolfssl.git
Merge pull request #3772 from SparkiDev/sp_ecdsa_set_k
SP ECDSA sign: fix multiple loops work of generating kpull/3807/head
commit
60614ff8b1
|
@ -36844,8 +36844,6 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 32U) {
|
||||
hashLen = 32U;
|
||||
}
|
||||
|
||||
sp_256_from_bin(e, 8, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -36887,6 +36885,7 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_256_norm_8(x);
|
||||
sp_256_from_bin(e, 8, hash, (int)hashLen);
|
||||
carry = sp_256_add_8(s, e, x);
|
||||
sp_256_cond_sub_8(s, s, p256_order, 0 - carry);
|
||||
sp_256_norm_8(s);
|
||||
|
@ -36903,6 +36902,9 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
@ -45910,8 +45912,6 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 48U) {
|
||||
hashLen = 48U;
|
||||
}
|
||||
|
||||
sp_384_from_bin(e, 12, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -45953,6 +45953,7 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_384_norm_12(x);
|
||||
sp_384_from_bin(e, 12, hash, (int)hashLen);
|
||||
carry = sp_384_add_12(s, e, x);
|
||||
sp_384_cond_sub_12(s, s, p384_order, 0 - carry);
|
||||
sp_384_norm_12(s);
|
||||
|
@ -45969,6 +45970,9 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
|
|
@ -37255,8 +37255,6 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 32U) {
|
||||
hashLen = 32U;
|
||||
}
|
||||
|
||||
sp_256_from_bin(e, 4, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -37298,6 +37296,7 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_256_norm_4(x);
|
||||
sp_256_from_bin(e, 4, hash, (int)hashLen);
|
||||
carry = sp_256_add_4(s, e, x);
|
||||
sp_256_cond_sub_4(s, s, p256_order, 0 - carry);
|
||||
sp_256_norm_4(s);
|
||||
|
@ -37314,6 +37313,9 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
@ -44027,8 +44029,6 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 48U) {
|
||||
hashLen = 48U;
|
||||
}
|
||||
|
||||
sp_384_from_bin(e, 6, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -44070,6 +44070,7 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_384_norm_6(x);
|
||||
sp_384_from_bin(e, 6, hash, (int)hashLen);
|
||||
carry = sp_384_add_6(s, e, x);
|
||||
sp_384_cond_sub_6(s, s, p384_order, 0 - carry);
|
||||
sp_384_norm_6(s);
|
||||
|
@ -44086,6 +44087,9 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
|
|
@ -21617,8 +21617,6 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 32U) {
|
||||
hashLen = 32U;
|
||||
}
|
||||
|
||||
sp_256_from_bin(e, 8, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -21660,6 +21658,7 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_256_norm_8(x);
|
||||
sp_256_from_bin(e, 8, hash, (int)hashLen);
|
||||
carry = sp_256_add_8(s, e, x);
|
||||
sp_256_cond_sub_8(s, s, p256_order, 0 - carry);
|
||||
sp_256_norm_8(s);
|
||||
|
@ -21676,6 +21675,9 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
@ -29041,8 +29043,6 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 48U) {
|
||||
hashLen = 48U;
|
||||
}
|
||||
|
||||
sp_384_from_bin(e, 12, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -29084,6 +29084,7 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_384_norm_12(x);
|
||||
sp_384_from_bin(e, 12, hash, (int)hashLen);
|
||||
carry = sp_384_add_12(s, e, x);
|
||||
sp_384_cond_sub_12(s, s, p384_order, 0 - carry);
|
||||
sp_384_norm_12(s);
|
||||
|
@ -29100,6 +29101,9 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
|
|
@ -18021,8 +18021,6 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 32U) {
|
||||
hashLen = 32U;
|
||||
}
|
||||
|
||||
sp_256_from_bin(e, 10, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -18064,6 +18062,7 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_256_norm_10(x);
|
||||
sp_256_from_bin(e, 10, hash, (int)hashLen);
|
||||
carry = sp_256_add_10(s, e, x);
|
||||
sp_256_cond_sub_10(s, s, p256_order, 0 - carry);
|
||||
sp_256_norm_10(s);
|
||||
|
@ -18080,6 +18079,9 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
@ -25536,8 +25538,6 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 48U) {
|
||||
hashLen = 48U;
|
||||
}
|
||||
|
||||
sp_384_from_bin(e, 15, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -25579,6 +25579,7 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_384_norm_15(x);
|
||||
sp_384_from_bin(e, 15, hash, (int)hashLen);
|
||||
carry = sp_384_add_15(s, e, x);
|
||||
sp_384_cond_sub_15(s, s, p384_order, 0 - carry);
|
||||
sp_384_norm_15(s);
|
||||
|
@ -25595,6 +25596,9 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
|
|
@ -17746,8 +17746,6 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 32U) {
|
||||
hashLen = 32U;
|
||||
}
|
||||
|
||||
sp_256_from_bin(e, 5, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -17789,6 +17787,7 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_256_norm_5(x);
|
||||
sp_256_from_bin(e, 5, hash, (int)hashLen);
|
||||
carry = sp_256_add_5(s, e, x);
|
||||
sp_256_cond_sub_5(s, s, p256_order, 0 - carry);
|
||||
sp_256_norm_5(s);
|
||||
|
@ -17805,6 +17804,9 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
@ -24740,8 +24742,6 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 48U) {
|
||||
hashLen = 48U;
|
||||
}
|
||||
|
||||
sp_384_from_bin(e, 7, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -24783,6 +24783,7 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_384_norm_7(x);
|
||||
sp_384_from_bin(e, 7, hash, (int)hashLen);
|
||||
carry = sp_384_add_7(s, e, x);
|
||||
sp_384_cond_sub_7(s, s, p384_order, 0 - carry);
|
||||
sp_384_norm_7(s);
|
||||
|
@ -24799,6 +24800,9 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
|
|
@ -21623,8 +21623,6 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 32U) {
|
||||
hashLen = 32U;
|
||||
}
|
||||
|
||||
sp_256_from_bin(e, 8, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -21666,6 +21664,7 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_256_norm_8(x);
|
||||
sp_256_from_bin(e, 8, hash, (int)hashLen);
|
||||
carry = sp_256_add_8(s, e, x);
|
||||
sp_256_cond_sub_8(s, s, p256_order, 0 - carry);
|
||||
sp_256_norm_8(s);
|
||||
|
@ -21682,6 +21681,9 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
@ -28535,8 +28537,6 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 48U) {
|
||||
hashLen = 48U;
|
||||
}
|
||||
|
||||
sp_384_from_bin(e, 12, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -28578,6 +28578,7 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_384_norm_12(x);
|
||||
sp_384_from_bin(e, 12, hash, (int)hashLen);
|
||||
carry = sp_384_add_12(s, e, x);
|
||||
sp_384_cond_sub_12(s, s, p384_order, 0 - carry);
|
||||
sp_384_norm_12(s);
|
||||
|
@ -28594,6 +28595,9 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
|
|
@ -23343,8 +23343,6 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 32U) {
|
||||
hashLen = 32U;
|
||||
}
|
||||
|
||||
sp_256_from_bin(e, 4, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -23406,6 +23404,7 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_256_norm_4(x);
|
||||
sp_256_from_bin(e, 4, hash, (int)hashLen);
|
||||
carry = sp_256_add_4(s, e, x);
|
||||
sp_256_cond_sub_4(s, s, p256_order, 0 - carry);
|
||||
sp_256_norm_4(s);
|
||||
|
@ -23427,6 +23426,9 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
@ -30385,8 +30387,6 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
if (hashLen > 48U) {
|
||||
hashLen = 48U;
|
||||
}
|
||||
|
||||
sp_384_from_bin(e, 6, hash, (int)hashLen);
|
||||
}
|
||||
|
||||
for (i = SP_ECC_MAX_SIG_GEN; err == MP_OKAY && i > 0; i--) {
|
||||
|
@ -30448,6 +30448,7 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
}
|
||||
if (err == MP_OKAY) {
|
||||
sp_384_norm_6(x);
|
||||
sp_384_from_bin(e, 6, hash, (int)hashLen);
|
||||
carry = sp_384_add_6(s, e, x);
|
||||
sp_384_cond_sub_6(s, s, p384_order, 0 - carry);
|
||||
sp_384_norm_6(s);
|
||||
|
@ -30469,6 +30470,9 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng, mp_int* priv,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#ifdef WOLFSSL_ECDSA_SET_K_ONE_LOOP
|
||||
i = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
|
|
Loading…
Reference in New Issue