diff --git a/wolfcrypt/src/sp_arm32.c b/wolfcrypt/src/sp_arm32.c index 3d3d0d3f6..d7938ef1d 100644 --- a/wolfcrypt/src/sp_arm32.c +++ b/wolfcrypt/src/sp_arm32.c @@ -35877,9 +35877,6 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 32U) { - hashLen = 32U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -35914,6 +35911,9 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_256_norm_8(ctx->r); + if (hashLen > 32U) { + hashLen = 32U; + } sp_256_from_mp(ctx->x, 8, priv); sp_256_from_bin(ctx->e, 8, hash, (int)hashLen); ctx->state = 4; @@ -45380,9 +45380,6 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 48U) { - hashLen = 48U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -45417,6 +45414,9 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_384_norm_12(ctx->r); + if (hashLen > 48U) { + hashLen = 48U; + } sp_384_from_mp(ctx->x, 12, priv); sp_384_from_bin(ctx->e, 12, hash, (int)hashLen); ctx->state = 4; @@ -58263,9 +58263,6 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 66U) { - hashLen = 66U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -58300,6 +58297,9 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_521_norm_17(ctx->r); + if (hashLen > 66U) { + hashLen = 66U; + } sp_521_from_mp(ctx->x, 17, priv); sp_521_from_bin(ctx->e, 17, hash, (int)hashLen); if (hashLen == 66U) { diff --git a/wolfcrypt/src/sp_arm64.c b/wolfcrypt/src/sp_arm64.c index c3459a912..c4e1d95d3 100644 --- a/wolfcrypt/src/sp_arm64.c +++ b/wolfcrypt/src/sp_arm64.c @@ -40239,9 +40239,6 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 32U) { - hashLen = 32U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -40276,6 +40273,9 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_256_norm_4(ctx->r); + if (hashLen > 32U) { + hashLen = 32U; + } sp_256_from_mp(ctx->x, 4, priv); sp_256_from_bin(ctx->e, 4, hash, (int)hashLen); ctx->state = 4; @@ -66162,9 +66162,6 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 48U) { - hashLen = 48U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -66199,6 +66196,9 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_384_norm_6(ctx->r); + if (hashLen > 48U) { + hashLen = 48U; + } sp_384_from_mp(ctx->x, 6, priv); sp_384_from_bin(ctx->e, 6, hash, (int)hashLen); ctx->state = 4; @@ -110783,9 +110783,6 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 66U) { - hashLen = 66U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -110820,6 +110817,9 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_521_norm_9(ctx->r); + if (hashLen > 66U) { + hashLen = 66U; + } sp_521_from_mp(ctx->x, 9, priv); sp_521_from_bin(ctx->e, 9, hash, (int)hashLen); if (hashLen == 66U) { diff --git a/wolfcrypt/src/sp_armthumb.c b/wolfcrypt/src/sp_armthumb.c index 686ff2ee0..36a800786 100644 --- a/wolfcrypt/src/sp_armthumb.c +++ b/wolfcrypt/src/sp_armthumb.c @@ -105595,9 +105595,6 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 32U) { - hashLen = 32U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -105632,6 +105629,9 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_256_norm_8(ctx->r); + if (hashLen > 32U) { + hashLen = 32U; + } sp_256_from_mp(ctx->x, 8, priv); sp_256_from_bin(ctx->e, 8, hash, (int)hashLen); ctx->state = 4; @@ -116203,9 +116203,6 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 48U) { - hashLen = 48U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -116240,6 +116237,9 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_384_norm_12(ctx->r); + if (hashLen > 48U) { + hashLen = 48U; + } sp_384_from_mp(ctx->x, 12, priv); sp_384_from_bin(ctx->e, 12, hash, (int)hashLen); ctx->state = 4; @@ -132241,9 +132241,6 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 66U) { - hashLen = 66U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -132278,6 +132275,9 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_521_norm_17(ctx->r); + if (hashLen > 66U) { + hashLen = 66U; + } sp_521_from_mp(ctx->x, 17, priv); sp_521_from_bin(ctx->e, 17, hash, (int)hashLen); if (hashLen == 66U) { diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index 2e58dcdd2..7cfaab93e 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -25556,9 +25556,6 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 32U) { - hashLen = 32U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -25593,6 +25590,9 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_256_norm_9(ctx->r); + if (hashLen > 32U) { + hashLen = 32U; + } sp_256_from_mp(ctx->x, 9, priv); sp_256_from_bin(ctx->e, 9, hash, (int)hashLen); ctx->state = 4; @@ -33471,9 +33471,6 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 48U) { - hashLen = 48U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -33508,6 +33505,9 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_384_norm_15(ctx->r); + if (hashLen > 48U) { + hashLen = 48U; + } sp_384_from_mp(ctx->x, 15, priv); sp_384_from_bin(ctx->e, 15, hash, (int)hashLen); ctx->state = 4; @@ -41468,9 +41468,6 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 66U) { - hashLen = 66U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -41505,6 +41502,9 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_521_norm_21(ctx->r); + if (hashLen > 66U) { + hashLen = 66U; + } sp_521_from_mp(ctx->x, 21, priv); sp_521_from_bin(ctx->e, 21, hash, (int)hashLen); if (hashLen == 66U) { diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index dbcadc3b1..f2473cb46 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -26454,9 +26454,6 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 32U) { - hashLen = 32U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -26491,6 +26488,9 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_256_norm_5(ctx->r); + if (hashLen > 32U) { + hashLen = 32U; + } sp_256_from_mp(ctx->x, 5, priv); sp_256_from_bin(ctx->e, 5, hash, (int)hashLen); ctx->state = 4; @@ -33768,9 +33768,6 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 48U) { - hashLen = 48U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -33805,6 +33802,9 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_384_norm_7(ctx->r); + if (hashLen > 48U) { + hashLen = 48U; + } sp_384_from_mp(ctx->x, 7, priv); sp_384_from_bin(ctx->e, 7, hash, (int)hashLen); ctx->state = 4; @@ -41071,9 +41071,6 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 66U) { - hashLen = 66U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -41108,6 +41105,9 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_521_norm_9(ctx->r); + if (hashLen > 66U) { + hashLen = 66U; + } sp_521_from_mp(ctx->x, 9, priv); sp_521_from_bin(ctx->e, 9, hash, (int)hashLen); if (hashLen == 66U) { diff --git a/wolfcrypt/src/sp_cortexm.c b/wolfcrypt/src/sp_cortexm.c index 3ef961ba3..28ea6ab6b 100644 --- a/wolfcrypt/src/sp_cortexm.c +++ b/wolfcrypt/src/sp_cortexm.c @@ -23476,9 +23476,6 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 32U) { - hashLen = 32U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -23513,6 +23510,9 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_256_norm_8(ctx->r); + if (hashLen > 32U) { + hashLen = 32U; + } sp_256_from_mp(ctx->x, 8, priv); sp_256_from_bin(ctx->e, 8, hash, (int)hashLen); ctx->state = 4; @@ -30640,9 +30640,6 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 48U) { - hashLen = 48U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -30677,6 +30674,9 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_384_norm_12(ctx->r); + if (hashLen > 48U) { + hashLen = 48U; + } sp_384_from_mp(ctx->x, 12, priv); sp_384_from_bin(ctx->e, 12, hash, (int)hashLen); ctx->state = 4; @@ -39431,9 +39431,6 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 66U) { - hashLen = 66U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -39468,6 +39465,9 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_521_norm_17(ctx->r); + if (hashLen > 66U) { + hashLen = 66U; + } sp_521_from_mp(ctx->x, 17, priv); sp_521_from_bin(ctx->e, 17, hash, (int)hashLen); if (hashLen == 66U) { diff --git a/wolfcrypt/src/sp_x86_64.c b/wolfcrypt/src/sp_x86_64.c index 84034a7e0..1245a6ff6 100644 --- a/wolfcrypt/src/sp_x86_64.c +++ b/wolfcrypt/src/sp_x86_64.c @@ -25498,9 +25498,6 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 32U) { - hashLen = 32U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -25535,6 +25532,9 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_256_norm_4(ctx->r); + if (hashLen > 32U) { + hashLen = 32U; + } sp_256_from_mp(ctx->x, 4, priv); sp_256_from_bin(ctx->e, 4, hash, (int)hashLen); ctx->state = 4; @@ -50230,9 +50230,6 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 48U) { - hashLen = 48U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -50267,6 +50264,9 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_384_norm_6(ctx->r); + if (hashLen > 48U) { + hashLen = 48U; + } sp_384_from_mp(ctx->x, 6, priv); sp_384_from_bin(ctx->e, 6, hash, (int)hashLen); ctx->state = 4; @@ -91201,9 +91201,6 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W case 0: /* INIT */ ctx->s = ctx->e; ctx->kInv = ctx->k; - if (hashLen > 66U) { - hashLen = 66U; - } ctx->i = SP_ECC_MAX_SIG_GEN; ctx->state = 1; @@ -91238,6 +91235,9 @@ int sp_ecc_sign_521_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W (sp_digit)0 - (sp_digit)(c >= 0)); sp_521_norm_9(ctx->r); + if (hashLen > 66U) { + hashLen = 66U; + } sp_521_from_mp(ctx->x, 9, priv); sp_521_from_bin(ctx->e, 9, hash, (int)hashLen); if (hashLen == 66U) {