mirror of https://github.com/wolfSSL/wolfssl.git
Fix for SP math ECC non-blocking to always check `hashLen`. ZD14141
parent
b8cff49044
commit
74d692d6d5
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue