Merge pull request #4170 from SparkiDev/sp_mingw64

SP: Don't cast number to sp_digit rather than declare as long
This commit is contained in:
David Garske
2021-06-29 13:32:28 -07:00
committed by GitHub
8 changed files with 1294 additions and 776 deletions

View File

@ -126,7 +126,7 @@ static void sp_2048_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -8621,7 +8621,7 @@ static void sp_3072_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -20282,7 +20282,7 @@ static void sp_4096_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -28385,19 +28385,22 @@ static const sp_point_256 p256_base = {
{
0xd898c296,0xf4a13945,0x2deb33a0,0x77037d81,0x63a440f2,0xf8bce6e5,
0xe12c4247,0x6b17d1f2,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* Y ordinate */
{
0x37bf51f5,0xcbb64068,0x6b315ece,0x2bce3357,0x7c0f9e16,0x8ee7eb4a,
0xfe1a7f9b,0x4fe342e2,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* Z ordinate */
{
0x00000001,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* infinity */
0
@ -29814,7 +29817,7 @@ static void sp_256_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -32183,8 +32186,9 @@ static void sp_256_proj_point_dbl_8(sp_point_256* r, const sp_point_256* p, sp_d
*/
static int sp_256_cmp_equal_8(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
(a[6] ^ b[6]) | (a[7] ^ b[7])) == 0;
}
/* Add two Montgomery form projective points.
@ -36321,7 +36325,8 @@ static int sp_256_calc_s_8(sp_digit* s, const sp_digit* r, sp_digit* k,
sp_256_cond_sub_8(s, s, p256_order, 0 - carry);
sp_256_norm_8(s);
c = sp_256_cmp_8(s, p256_order);
sp_256_cond_sub_8(s, s, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_8(s, s, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_8(s);
/* s = s * k^-1 mod order */
@ -36414,7 +36419,8 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 8U);
sp_256_norm_8(ctx->r);
c = sp_256_cmp_8(ctx->r, p256_order);
sp_256_cond_sub_8(ctx->r, ctx->r, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_8(ctx->r, ctx->r, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_8(ctx->r);
sp_256_from_mp(ctx->x, 8, priv);
@ -36460,10 +36466,12 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
int32_t c;
sp_256_norm_8(ctx->x);
carry = sp_256_add_8(ctx->s, ctx->e, ctx->x);
sp_256_cond_sub_8(ctx->s, ctx->s, p256_order, 0 - carry);
sp_256_cond_sub_8(ctx->s, ctx->s,
p256_order, 0 - carry);
sp_256_norm_8(ctx->s);
c = sp_256_cmp_8(ctx->s, p256_order);
sp_256_cond_sub_8(ctx->s, ctx->s, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_8(ctx->s, ctx->s, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_8(ctx->s);
/* s = s * k^-1 mod order */
@ -36576,7 +36584,8 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng,
XMEMCPY(r, point->x, sizeof(sp_digit) * 8U);
sp_256_norm_8(r);
c = sp_256_cmp_8(r, p256_order);
sp_256_cond_sub_8(r, r, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_8(r, r, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_8(r);
sp_256_from_mp(x, 8, priv);
@ -37877,19 +37886,25 @@ static const sp_point_384 p384_base = {
{
0x72760ab7,0x3a545e38,0xbf55296c,0x5502f25d,0x82542a38,0x59f741e0,
0x8ba79b98,0x6e1d3b62,0xf320ad74,0x8eb1c71e,0xbe8b0537,0xaa87ca22,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* Y ordinate */
{
0x90ea0e5f,0x7a431d7c,0x1d7e819d,0x0a60b1ce,0xb5f0b8c0,0xe9da3113,
0x289a147c,0xf8f41dbd,0x9292dc29,0x5d9e98bf,0x96262c6f,0x3617de4a,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* Z ordinate */
{
0x00000001,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* infinity */
0
@ -40095,7 +40110,7 @@ static void sp_384_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -41312,9 +41327,10 @@ static void sp_384_proj_point_dbl_12(sp_point_384* r, const sp_point_384* p, sp_
*/
static int sp_384_cmp_equal_12(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7]) |
(a[8] ^ b[8]) | (a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
(a[6] ^ b[6]) | (a[7] ^ b[7]) | (a[8] ^ b[8]) |
(a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11])) == 0;
}
/* Add two Montgomery form projective points.
@ -45539,7 +45555,8 @@ static int sp_384_calc_s_12(sp_digit* s, const sp_digit* r, sp_digit* k,
sp_384_cond_sub_12(s, s, p384_order, 0 - carry);
sp_384_norm_12(s);
c = sp_384_cmp_12(s, p384_order);
sp_384_cond_sub_12(s, s, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_12(s, s, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_12(s);
/* s = s * k^-1 mod order */
@ -45632,7 +45649,8 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 12U);
sp_384_norm_12(ctx->r);
c = sp_384_cmp_12(ctx->r, p384_order);
sp_384_cond_sub_12(ctx->r, ctx->r, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_12(ctx->r, ctx->r, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_12(ctx->r);
sp_384_from_mp(ctx->x, 12, priv);
@ -45678,10 +45696,12 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
int32_t c;
sp_384_norm_12(ctx->x);
carry = sp_384_add_12(ctx->s, ctx->e, ctx->x);
sp_384_cond_sub_12(ctx->s, ctx->s, p384_order, 0 - carry);
sp_384_cond_sub_12(ctx->s, ctx->s,
p384_order, 0 - carry);
sp_384_norm_12(ctx->s);
c = sp_384_cmp_12(ctx->s, p384_order);
sp_384_cond_sub_12(ctx->s, ctx->s, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_12(ctx->s, ctx->s, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_12(ctx->s);
/* s = s * k^-1 mod order */
@ -45794,7 +45814,8 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng,
XMEMCPY(r, point->x, sizeof(sp_digit) * 12U);
sp_384_norm_12(r);
c = sp_384_cmp_12(r, p384_order);
sp_384_cond_sub_12(r, r, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_12(r, r, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_12(r);
sp_384_from_mp(x, 12, priv);
@ -50689,7 +50710,13 @@ static const sp_point_1024 p1024_base = {
0xdb9dfa55,0x43d5f22c,0x30b09e10,0xab10db90,0xf6ce2308,0xb5edb6c0,
0xb6ff7cbf,0x98b2f204,0x0aec69c6,0x2b1a2fd6,0x3ed9b52a,0x0a799005,
0x332c29ad,0x53fc09ee,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* Y ordinate */
{
@ -50699,7 +50726,13 @@ static const sp_point_1024 p1024_base = {
0x9a140b2e,0x6b598ccf,0xf0de55f6,0xe7f7f5e5,0x654ec2b9,0xf5ea69f4,
0x1e141178,0x3d778d82,0x02990696,0xd3e82016,0x3634a135,0xf9f1f053,
0x3f6009f1,0x0a824906,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* Z ordinate */
{
@ -50709,7 +50742,13 @@ static const sp_point_1024 p1024_base = {
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* infinity */
0
@ -51942,7 +51981,7 @@ static void sp_1024_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -54105,14 +54144,17 @@ static sp_digit sp_1024_sub_32(sp_digit* r, const sp_digit* a,
*/
static int sp_1024_cmp_equal_32(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7]) |
(a[8] ^ b[8]) | (a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
(a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14]) | (a[15] ^ b[15]) |
(a[16] ^ b[16]) | (a[17] ^ b[17]) | (a[18] ^ b[18]) | (a[19] ^ b[19]) |
(a[20] ^ b[20]) | (a[21] ^ b[21]) | (a[22] ^ b[22]) | (a[23] ^ b[23]) |
(a[24] ^ b[24]) | (a[25] ^ b[25]) | (a[26] ^ b[26]) | (a[27] ^ b[27]) |
(a[28] ^ b[28]) | (a[29] ^ b[29]) | (a[30] ^ b[30]) | (a[31] ^ b[31])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
(a[6] ^ b[6]) | (a[7] ^ b[7]) | (a[8] ^ b[8]) |
(a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
(a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14]) |
(a[15] ^ b[15]) | (a[16] ^ b[16]) | (a[17] ^ b[17]) |
(a[18] ^ b[18]) | (a[19] ^ b[19]) | (a[20] ^ b[20]) |
(a[21] ^ b[21]) | (a[22] ^ b[22]) | (a[23] ^ b[23]) |
(a[24] ^ b[24]) | (a[25] ^ b[25]) | (a[26] ^ b[26]) |
(a[27] ^ b[27]) | (a[28] ^ b[28]) | (a[29] ^ b[29]) |
(a[30] ^ b[30]) | (a[31] ^ b[31])) == 0;
}
/* Add two Montgomery form projective points.
@ -55499,8 +55541,12 @@ int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r,
*/
static const sp_table_entry_1024 p1024_table[16] = {
/* 0 */
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
/* 1 */
{ { 0xe0162bc2,0xbf9c7ec6,0x10a89289,0xddecc6e3,0x9e499d81,0x5d599df0,
0x6d358218,0x9a96ea28,0x70c5f8db,0x01aec7d3,0x8cf5d066,0xe72e4995,
@ -55727,8 +55773,12 @@ static int sp_1024_ecc_mulmod_base_32(sp_point_1024* r, const sp_digit* k,
*/
static const sp_table_entry_1024 p1024_table[256] = {
/* 0 */
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
/* 1 */
{ { 0xe0162bc2,0xbf9c7ec6,0x10a89289,0xddecc6e3,0x9e499d81,0x5d599df0,
0x6d358218,0x9a96ea28,0x70c5f8db,0x01aec7d3,0x8cf5d066,0xe72e4995,
@ -59429,7 +59479,8 @@ static void sp_1024_proj_sqr_32(sp_digit* px, sp_digit* py, sp_digit* t)
*/
int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
{
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td;
sp_digit* t;
sp_digit* tx;
@ -59448,7 +59499,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
int bits;
int i;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 8 * 32 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (td == NULL) {
@ -59457,7 +59509,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
tx = td + 4 * 32 * 2;
ty = td + 5 * 32 * 2;
@ -59500,7 +59553,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -61324,7 +61378,8 @@ static const sp_digit sp_1024_g_table[256][32] = {
*/
int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
{
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td;
sp_digit* t;
sp_digit* tx;
@ -61342,7 +61397,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
(void)base;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 6 * 32 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (td == NULL) {
@ -61351,7 +61407,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
tx = td + 4 * 32 * 2;
ty = td + 5 * 32 * 2;
@ -61394,7 +61451,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -61664,7 +61722,8 @@ static void sp_1024_accumulate_line_add_one_32(sp_digit* vx, sp_digit* vy,
int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
{
int err = MP_OKAY;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -61693,7 +61752,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_point_new_32(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9 * 32 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -61704,7 +61764,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 32 * 2;
vy = td + 7 * 32 * 2;
@ -61760,7 +61821,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -62038,7 +62100,8 @@ static const signed char sp_1024_order_op[] = {
int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
{
int err;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -62074,7 +62137,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_point_new_32(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 32 * 2 + 16 * sizeof(sp_point_1024), NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -62085,7 +62149,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 32 * 2;
vy = td + 7 * 32 * 2;
@ -62183,7 +62248,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -62425,7 +62491,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
word32* len)
{
int err = 0;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_point_1024* pre_p;
@ -62464,7 +62531,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
err = sp_1024_point_new_32(NULL, negd, neg);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 6 * 32 * 2 + 16 * sizeof(sp_point_1024), NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -62475,7 +62543,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
pre_p = (sp_point_1024*)(td + 6 * 32 * 2);
#endif
@ -62547,7 +62616,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
*len = sizeof(sp_table_entry_1024) * 1167;
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -62581,7 +62651,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
mp_int* res, const byte* table, word32 len)
{
int err = 0;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -62623,7 +62694,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
err = sp_1024_point_new_32(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 32 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -62634,7 +62706,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 32 * 2;
vy = td + 7 * 32 * 2;
@ -62738,7 +62811,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}

View File

@ -137,7 +137,7 @@ static void sp_2048_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -6125,7 +6125,7 @@ static void sp_3072_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -14254,7 +14254,7 @@ static void sp_4096_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -19486,19 +19486,19 @@ static const sp_point_256 p256_base = {
{
0xf4a13945d898c296L,0x77037d812deb33a0L,0xf8bce6e563a440f2L,
0x6b17d1f2e12c4247L,
0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* Y ordinate */
{
0xcbb6406837bf51f5L,0x2bce33576b315eceL,0x8ee7eb4a7c0f9e16L,
0x4fe342e2fe1a7f9bL,
0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* Z ordinate */
{
0x0000000000000001L,0x0000000000000000L,0x0000000000000000L,
0x0000000000000000L,
0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* infinity */
0
@ -19925,7 +19925,7 @@ static void sp_256_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -21433,7 +21433,8 @@ static void sp_256_proj_point_dbl_n_4(sp_point_256* p, int n,
*/
static int sp_256_cmp_equal_4(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3])) == 0;
}
/* Add two Montgomery form projective points.
@ -37883,7 +37884,8 @@ static int sp_256_calc_s_4(sp_digit* s, const sp_digit* r, sp_digit* k,
sp_256_cond_sub_4(s, s, p256_order, 0 - carry);
sp_256_norm_4(s);
c = sp_256_cmp_4(s, p256_order);
sp_256_cond_sub_4(s, s, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_4(s, s, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_4(s);
/* s = s * k^-1 mod order */
@ -37976,7 +37978,8 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 4U);
sp_256_norm_4(ctx->r);
c = sp_256_cmp_4(ctx->r, p256_order);
sp_256_cond_sub_4(ctx->r, ctx->r, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_4(ctx->r, ctx->r, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_4(ctx->r);
sp_256_from_mp(ctx->x, 4, priv);
@ -38022,10 +38025,12 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
int64_t c;
sp_256_norm_4(ctx->x);
carry = sp_256_add_4(ctx->s, ctx->e, ctx->x);
sp_256_cond_sub_4(ctx->s, ctx->s, p256_order, 0 - carry);
sp_256_cond_sub_4(ctx->s, ctx->s,
p256_order, 0 - carry);
sp_256_norm_4(ctx->s);
c = sp_256_cmp_4(ctx->s, p256_order);
sp_256_cond_sub_4(ctx->s, ctx->s, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_4(ctx->s, ctx->s, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_4(ctx->s);
/* s = s * k^-1 mod order */
@ -38138,7 +38143,8 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng,
XMEMCPY(r, point->x, sizeof(sp_digit) * 4U);
sp_256_norm_4(r);
c = sp_256_cmp_4(r, p256_order);
sp_256_cond_sub_4(r, r, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_4(r, r, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_4(r);
sp_256_from_mp(x, 4, priv);
@ -39436,19 +39442,22 @@ static const sp_point_384 p384_base = {
{
0x3a545e3872760ab7L,0x5502f25dbf55296cL,0x59f741e082542a38L,
0x6e1d3b628ba79b98L,0x8eb1c71ef320ad74L,0xaa87ca22be8b0537L,
0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0
},
/* Y ordinate */
{
0x7a431d7c90ea0e5fL,0x0a60b1ce1d7e819dL,0xe9da3113b5f0b8c0L,
0xf8f41dbd289a147cL,0x5d9e98bf9292dc29L,0x3617de4a96262c6fL,
0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0
},
/* Z ordinate */
{
0x0000000000000001L,0x0000000000000000L,0x0000000000000000L,
0x0000000000000000L,0x0000000000000000L,0x0000000000000000L,
0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0
},
/* infinity */
0
@ -40200,7 +40209,7 @@ static void sp_384_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -41286,8 +41295,8 @@ static void sp_384_proj_point_dbl_n_6(sp_point_384* p, int n,
*/
static int sp_384_cmp_equal_6(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5])) == 0;
}
/* Add two Montgomery form projective points.
@ -63626,7 +63635,8 @@ static int sp_384_calc_s_6(sp_digit* s, const sp_digit* r, sp_digit* k,
sp_384_cond_sub_6(s, s, p384_order, 0 - carry);
sp_384_norm_6(s);
c = sp_384_cmp_6(s, p384_order);
sp_384_cond_sub_6(s, s, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_6(s, s, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_6(s);
/* s = s * k^-1 mod order */
@ -63719,7 +63729,8 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 6U);
sp_384_norm_6(ctx->r);
c = sp_384_cmp_6(ctx->r, p384_order);
sp_384_cond_sub_6(ctx->r, ctx->r, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_6(ctx->r, ctx->r, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_6(ctx->r);
sp_384_from_mp(ctx->x, 6, priv);
@ -63765,10 +63776,12 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
int64_t c;
sp_384_norm_6(ctx->x);
carry = sp_384_add_6(ctx->s, ctx->e, ctx->x);
sp_384_cond_sub_6(ctx->s, ctx->s, p384_order, 0 - carry);
sp_384_cond_sub_6(ctx->s, ctx->s,
p384_order, 0 - carry);
sp_384_norm_6(ctx->s);
c = sp_384_cmp_6(ctx->s, p384_order);
sp_384_cond_sub_6(ctx->s, ctx->s, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_6(ctx->s, ctx->s, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_6(ctx->s);
/* s = s * k^-1 mod order */
@ -63881,7 +63894,8 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng,
XMEMCPY(r, point->x, sizeof(sp_digit) * 6U);
sp_384_norm_6(r);
c = sp_384_cmp_6(r, p384_order);
sp_384_cond_sub_6(r, r, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_6(r, r, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_6(r);
sp_384_from_mp(x, 6, priv);
@ -66211,7 +66225,10 @@ static const sp_point_1024 p1024_base = {
0x43d5f22cdb9dfa55L,0xab10db9030b09e10L,0xb5edb6c0f6ce2308L,
0x98b2f204b6ff7cbfL,0x2b1a2fd60aec69c6L,0x0a7990053ed9b52aL,
0x53fc09ee332c29adL,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0
},
/* Y ordinate */
{
@ -66221,7 +66238,10 @@ static const sp_point_1024 p1024_base = {
0x6b598ccf9a140b2eL,0xe7f7f5e5f0de55f6L,0xf5ea69f4654ec2b9L,
0x3d778d821e141178L,0xd3e8201602990696L,0xf9f1f0533634a135L,
0x0a8249063f6009f1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0
},
/* Z ordinate */
{
@ -66231,7 +66251,10 @@ static const sp_point_1024 p1024_base = {
0x0000000000000000L,0x0000000000000000L,0x0000000000000000L,
0x0000000000000000L,0x0000000000000000L,0x0000000000000000L,
0x0000000000000000L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0
},
/* infinity */
0
@ -67006,7 +67029,7 @@ static void sp_1024_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -68651,10 +68674,12 @@ static sp_digit sp_1024_sub_16(sp_digit* r, const sp_digit* a,
*/
static int sp_1024_cmp_equal_16(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7]) |
(a[8] ^ b[8]) | (a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
(a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14]) | (a[15] ^ b[15])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
(a[6] ^ b[6]) | (a[7] ^ b[7]) | (a[8] ^ b[8]) |
(a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
(a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14]) |
(a[15] ^ b[15])) == 0;
}
/* Add two Montgomery form projective points.
@ -69845,8 +69870,10 @@ int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r,
*/
static const sp_table_entry_1024 p1024_table[256] = {
/* 0 */
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 } },
/* 1 */
{ { 0xbf9c7ec6e0162bc2L,0xddecc6e310a89289L,0x5d599df09e499d81L,
0x9a96ea286d358218L,0x01aec7d370c5f8dbL,0xe72e49958cf5d066L,
@ -73545,7 +73572,8 @@ static void sp_1024_proj_sqr_16(sp_digit* px, sp_digit* py, sp_digit* t)
*/
int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
{
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td;
sp_digit* t;
sp_digit* tx;
@ -73564,7 +73592,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
int bits;
int i;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 8 * 16 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (td == NULL) {
@ -73573,7 +73602,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
tx = td + 4 * 16 * 2;
ty = td + 5 * 16 * 2;
@ -73616,7 +73646,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -75184,7 +75215,8 @@ static const sp_digit sp_1024_g_table[256][16] = {
*/
int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
{
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td;
sp_digit* t;
sp_digit* tx;
@ -75202,7 +75234,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
(void)base;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 6 * 16 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (td == NULL) {
@ -75211,7 +75244,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
tx = td + 4 * 16 * 2;
ty = td + 5 * 16 * 2;
@ -75254,7 +75288,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -75524,7 +75559,8 @@ static void sp_1024_accumulate_line_add_one_16(sp_digit* vx, sp_digit* vy,
int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
{
int err = MP_OKAY;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -75553,7 +75589,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_point_new_16(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9 * 16 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -75564,7 +75601,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 16 * 2;
vy = td + 7 * 16 * 2;
@ -75620,7 +75658,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -75898,7 +75937,8 @@ static const signed char sp_1024_order_op[] = {
int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
{
int err;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -75934,7 +75974,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_point_new_16(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 16 * 2 + 16 * sizeof(sp_point_1024), NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -75945,7 +75986,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 16 * 2;
vy = td + 7 * 16 * 2;
@ -76043,7 +76085,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -76285,7 +76328,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
word32* len)
{
int err = 0;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_point_1024* pre_p;
@ -76324,7 +76368,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
err = sp_1024_point_new_16(NULL, negd, neg);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 6 * 16 * 2 + 16 * sizeof(sp_point_1024), NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -76335,7 +76380,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
pre_p = (sp_point_1024*)(td + 6 * 16 * 2);
#endif
@ -76407,7 +76453,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
*len = sizeof(sp_table_entry_1024) * 1167;
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -76441,7 +76488,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
mp_int* res, const byte* table, word32 len)
{
int err = 0;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -76483,7 +76531,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
err = sp_1024_point_new_16(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 16 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -76494,7 +76543,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 16 * 2;
vy = td + 7 * 16 * 2;
@ -76598,7 +76648,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}

View File

@ -126,7 +126,7 @@ static void sp_2048_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -5476,7 +5476,7 @@ static void sp_3072_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -11539,7 +11539,7 @@ static void sp_4096_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -15593,19 +15593,22 @@ static const sp_point_256 p256_base = {
{
0xd898c296,0xf4a13945,0x2deb33a0,0x77037d81,0x63a440f2,0xf8bce6e5,
0xe12c4247,0x6b17d1f2,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* Y ordinate */
{
0x37bf51f5,0xcbb64068,0x6b315ece,0x2bce3357,0x7c0f9e16,0x8ee7eb4a,
0xfe1a7f9b,0x4fe342e2,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* Z ordinate */
{
0x00000001,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* infinity */
0
@ -16163,7 +16166,7 @@ static void sp_256_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -17478,8 +17481,9 @@ static void sp_256_proj_point_dbl_8(sp_point_256* r, const sp_point_256* p, sp_d
*/
static int sp_256_cmp_equal_8(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
(a[6] ^ b[6]) | (a[7] ^ b[7])) == 0;
}
/* Add two Montgomery form projective points.
@ -21661,7 +21665,8 @@ static int sp_256_calc_s_8(sp_digit* s, const sp_digit* r, sp_digit* k,
sp_256_cond_sub_8(s, s, p256_order, 0 - carry);
sp_256_norm_8(s);
c = sp_256_cmp_8(s, p256_order);
sp_256_cond_sub_8(s, s, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_8(s, s, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_8(s);
/* s = s * k^-1 mod order */
@ -21754,7 +21759,8 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 8U);
sp_256_norm_8(ctx->r);
c = sp_256_cmp_8(ctx->r, p256_order);
sp_256_cond_sub_8(ctx->r, ctx->r, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_8(ctx->r, ctx->r, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_8(ctx->r);
sp_256_from_mp(ctx->x, 8, priv);
@ -21800,10 +21806,12 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
int32_t c;
sp_256_norm_8(ctx->x);
carry = sp_256_add_8(ctx->s, ctx->e, ctx->x);
sp_256_cond_sub_8(ctx->s, ctx->s, p256_order, 0 - carry);
sp_256_cond_sub_8(ctx->s, ctx->s,
p256_order, 0 - carry);
sp_256_norm_8(ctx->s);
c = sp_256_cmp_8(ctx->s, p256_order);
sp_256_cond_sub_8(ctx->s, ctx->s, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_8(ctx->s, ctx->s, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_8(ctx->s);
/* s = s * k^-1 mod order */
@ -21916,7 +21924,8 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng,
XMEMCPY(r, point->x, sizeof(sp_digit) * 8U);
sp_256_norm_8(r);
c = sp_256_cmp_8(r, p256_order);
sp_256_cond_sub_8(r, r, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_8(r, r, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_8(r);
sp_256_from_mp(x, 8, priv);
@ -23506,19 +23515,25 @@ static const sp_point_384 p384_base = {
{
0x72760ab7,0x3a545e38,0xbf55296c,0x5502f25d,0x82542a38,0x59f741e0,
0x8ba79b98,0x6e1d3b62,0xf320ad74,0x8eb1c71e,0xbe8b0537,0xaa87ca22,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* Y ordinate */
{
0x90ea0e5f,0x7a431d7c,0x1d7e819d,0x0a60b1ce,0xb5f0b8c0,0xe9da3113,
0x289a147c,0xf8f41dbd,0x9292dc29,0x5d9e98bf,0x96262c6f,0x3617de4a,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* Z ordinate */
{
0x00000001,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* infinity */
0
@ -24139,7 +24154,7 @@ static void sp_384_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -25092,9 +25107,10 @@ static void sp_384_proj_point_dbl_12(sp_point_384* r, const sp_point_384* p, sp_
*/
static int sp_384_cmp_equal_12(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7]) |
(a[8] ^ b[8]) | (a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
(a[6] ^ b[6]) | (a[7] ^ b[7]) | (a[8] ^ b[8]) |
(a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11])) == 0;
}
/* Add two Montgomery form projective points.
@ -29336,7 +29352,8 @@ static int sp_384_calc_s_12(sp_digit* s, const sp_digit* r, sp_digit* k,
sp_384_cond_sub_12(s, s, p384_order, 0 - carry);
sp_384_norm_12(s);
c = sp_384_cmp_12(s, p384_order);
sp_384_cond_sub_12(s, s, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_12(s, s, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_12(s);
/* s = s * k^-1 mod order */
@ -29429,7 +29446,8 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 12U);
sp_384_norm_12(ctx->r);
c = sp_384_cmp_12(ctx->r, p384_order);
sp_384_cond_sub_12(ctx->r, ctx->r, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_12(ctx->r, ctx->r, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_12(ctx->r);
sp_384_from_mp(ctx->x, 12, priv);
@ -29475,10 +29493,12 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
int32_t c;
sp_384_norm_12(ctx->x);
carry = sp_384_add_12(ctx->s, ctx->e, ctx->x);
sp_384_cond_sub_12(ctx->s, ctx->s, p384_order, 0 - carry);
sp_384_cond_sub_12(ctx->s, ctx->s,
p384_order, 0 - carry);
sp_384_norm_12(ctx->s);
c = sp_384_cmp_12(ctx->s, p384_order);
sp_384_cond_sub_12(ctx->s, ctx->s, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_12(ctx->s, ctx->s, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_12(ctx->s);
/* s = s * k^-1 mod order */
@ -29591,7 +29611,8 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng,
XMEMCPY(r, point->x, sizeof(sp_digit) * 12U);
sp_384_norm_12(r);
c = sp_384_cmp_12(r, p384_order);
sp_384_cond_sub_12(r, r, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_12(r, r, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_12(r);
sp_384_from_mp(x, 12, priv);
@ -32399,7 +32420,13 @@ static const sp_point_1024 p1024_base = {
0xdb9dfa55,0x43d5f22c,0x30b09e10,0xab10db90,0xf6ce2308,0xb5edb6c0,
0xb6ff7cbf,0x98b2f204,0x0aec69c6,0x2b1a2fd6,0x3ed9b52a,0x0a799005,
0x332c29ad,0x53fc09ee,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* Y ordinate */
{
@ -32409,7 +32436,13 @@ static const sp_point_1024 p1024_base = {
0x9a140b2e,0x6b598ccf,0xf0de55f6,0xe7f7f5e5,0x654ec2b9,0xf5ea69f4,
0x1e141178,0x3d778d82,0x02990696,0xd3e82016,0x3634a135,0xf9f1f053,
0x3f6009f1,0x0a824906,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* Z ordinate */
{
@ -32419,7 +32452,13 @@ static const sp_point_1024 p1024_base = {
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* infinity */
0
@ -32990,7 +33029,7 @@ static void sp_1024_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -35668,14 +35707,17 @@ SP_NOINLINE static sp_digit sp_1024_sub_32(sp_digit* r, const sp_digit* a,
*/
static int sp_1024_cmp_equal_32(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7]) |
(a[8] ^ b[8]) | (a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
(a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14]) | (a[15] ^ b[15]) |
(a[16] ^ b[16]) | (a[17] ^ b[17]) | (a[18] ^ b[18]) | (a[19] ^ b[19]) |
(a[20] ^ b[20]) | (a[21] ^ b[21]) | (a[22] ^ b[22]) | (a[23] ^ b[23]) |
(a[24] ^ b[24]) | (a[25] ^ b[25]) | (a[26] ^ b[26]) | (a[27] ^ b[27]) |
(a[28] ^ b[28]) | (a[29] ^ b[29]) | (a[30] ^ b[30]) | (a[31] ^ b[31])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
(a[6] ^ b[6]) | (a[7] ^ b[7]) | (a[8] ^ b[8]) |
(a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
(a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14]) |
(a[15] ^ b[15]) | (a[16] ^ b[16]) | (a[17] ^ b[17]) |
(a[18] ^ b[18]) | (a[19] ^ b[19]) | (a[20] ^ b[20]) |
(a[21] ^ b[21]) | (a[22] ^ b[22]) | (a[23] ^ b[23]) |
(a[24] ^ b[24]) | (a[25] ^ b[25]) | (a[26] ^ b[26]) |
(a[27] ^ b[27]) | (a[28] ^ b[28]) | (a[29] ^ b[29]) |
(a[30] ^ b[30]) | (a[31] ^ b[31])) == 0;
}
/* Add two Montgomery form projective points.
@ -37062,8 +37104,12 @@ int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r,
*/
static const sp_table_entry_1024 p1024_table[16] = {
/* 0 */
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
/* 1 */
{ { 0xe0162bc2,0xbf9c7ec6,0x10a89289,0xddecc6e3,0x9e499d81,0x5d599df0,
0x6d358218,0x9a96ea28,0x70c5f8db,0x01aec7d3,0x8cf5d066,0xe72e4995,
@ -37290,8 +37336,12 @@ static int sp_1024_ecc_mulmod_base_32(sp_point_1024* r, const sp_digit* k,
*/
static const sp_table_entry_1024 p1024_table[256] = {
/* 0 */
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
/* 1 */
{ { 0xe0162bc2,0xbf9c7ec6,0x10a89289,0xddecc6e3,0x9e499d81,0x5d599df0,
0x6d358218,0x9a96ea28,0x70c5f8db,0x01aec7d3,0x8cf5d066,0xe72e4995,
@ -40992,7 +41042,8 @@ static void sp_1024_proj_sqr_32(sp_digit* px, sp_digit* py, sp_digit* t)
*/
int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
{
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td;
sp_digit* t;
sp_digit* tx;
@ -41011,7 +41062,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
int bits;
int i;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 8 * 32 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (td == NULL) {
@ -41020,7 +41072,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
tx = td + 4 * 32 * 2;
ty = td + 5 * 32 * 2;
@ -41063,7 +41116,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -42887,7 +42941,8 @@ static const sp_digit sp_1024_g_table[256][32] = {
*/
int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
{
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td;
sp_digit* t;
sp_digit* tx;
@ -42905,7 +42960,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
(void)base;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 6 * 32 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (td == NULL) {
@ -42914,7 +42970,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
tx = td + 4 * 32 * 2;
ty = td + 5 * 32 * 2;
@ -42957,7 +43014,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -43227,7 +43285,8 @@ static void sp_1024_accumulate_line_add_one_32(sp_digit* vx, sp_digit* vy,
int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
{
int err = MP_OKAY;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -43256,7 +43315,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_point_new_32(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9 * 32 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -43267,7 +43327,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 32 * 2;
vy = td + 7 * 32 * 2;
@ -43323,7 +43384,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -43601,7 +43663,8 @@ static const signed char sp_1024_order_op[] = {
int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
{
int err;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -43637,7 +43700,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_point_new_32(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 32 * 2 + 16 * sizeof(sp_point_1024), NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -43648,7 +43712,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 32 * 2;
vy = td + 7 * 32 * 2;
@ -43746,7 +43811,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -43988,7 +44054,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
word32* len)
{
int err = 0;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_point_1024* pre_p;
@ -44027,7 +44094,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
err = sp_1024_point_new_32(NULL, negd, neg);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 6 * 32 * 2 + 16 * sizeof(sp_point_1024), NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -44038,7 +44106,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
pre_p = (sp_point_1024*)(td + 6 * 32 * 2);
#endif
@ -44110,7 +44179,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
*len = sizeof(sp_table_entry_1024) * 1167;
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -44144,7 +44214,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
mp_int* res, const byte* table, word32 len)
{
int err = 0;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -44186,7 +44257,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
err = sp_1024_point_new_32(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 32 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -44197,7 +44269,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 32 * 2;
vy = td + 7 * 32 * 2;
@ -44301,7 +44374,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -135,7 +135,7 @@ static void sp_2048_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -5372,7 +5372,7 @@ static void sp_3072_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -10465,7 +10465,7 @@ static void sp_4096_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -13912,19 +13912,22 @@ static const sp_point_256 p256_base = {
{
0xd898c296,0xf4a13945,0x2deb33a0,0x77037d81,0x63a440f2,0xf8bce6e5,
0xe12c4247,0x6b17d1f2,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* Y ordinate */
{
0x37bf51f5,0xcbb64068,0x6b315ece,0x2bce3357,0x7c0f9e16,0x8ee7eb4a,
0xfe1a7f9b,0x4fe342e2,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* Z ordinate */
{
0x00000001,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* infinity */
0
@ -15254,7 +15257,7 @@ static void sp_256_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -17608,8 +17611,9 @@ static void sp_256_proj_point_dbl_8(sp_point_256* r, const sp_point_256* p, sp_d
*/
static int sp_256_cmp_equal_8(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
(a[6] ^ b[6]) | (a[7] ^ b[7])) == 0;
}
/* Add two Montgomery form projective points.
@ -21667,7 +21671,8 @@ static int sp_256_calc_s_8(sp_digit* s, const sp_digit* r, sp_digit* k,
sp_256_cond_sub_8(s, s, p256_order, 0 - carry);
sp_256_norm_8(s);
c = sp_256_cmp_8(s, p256_order);
sp_256_cond_sub_8(s, s, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_8(s, s, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_8(s);
/* s = s * k^-1 mod order */
@ -21760,7 +21765,8 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 8U);
sp_256_norm_8(ctx->r);
c = sp_256_cmp_8(ctx->r, p256_order);
sp_256_cond_sub_8(ctx->r, ctx->r, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_8(ctx->r, ctx->r, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_8(ctx->r);
sp_256_from_mp(ctx->x, 8, priv);
@ -21806,10 +21812,12 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
int32_t c;
sp_256_norm_8(ctx->x);
carry = sp_256_add_8(ctx->s, ctx->e, ctx->x);
sp_256_cond_sub_8(ctx->s, ctx->s, p256_order, 0 - carry);
sp_256_cond_sub_8(ctx->s, ctx->s,
p256_order, 0 - carry);
sp_256_norm_8(ctx->s);
c = sp_256_cmp_8(ctx->s, p256_order);
sp_256_cond_sub_8(ctx->s, ctx->s, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_8(ctx->s, ctx->s, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_8(ctx->s);
/* s = s * k^-1 mod order */
@ -21922,7 +21930,8 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng,
XMEMCPY(r, point->x, sizeof(sp_digit) * 8U);
sp_256_norm_8(r);
c = sp_256_cmp_8(r, p256_order);
sp_256_cond_sub_8(r, r, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_8(r, r, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_8(r);
sp_256_from_mp(x, 8, priv);
@ -23221,19 +23230,25 @@ static const sp_point_384 p384_base = {
{
0x72760ab7,0x3a545e38,0xbf55296c,0x5502f25d,0x82542a38,0x59f741e0,
0x8ba79b98,0x6e1d3b62,0xf320ad74,0x8eb1c71e,0xbe8b0537,0xaa87ca22,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* Y ordinate */
{
0x90ea0e5f,0x7a431d7c,0x1d7e819d,0x0a60b1ce,0xb5f0b8c0,0xe9da3113,
0x289a147c,0xf8f41dbd,0x9292dc29,0x5d9e98bf,0x96262c6f,0x3617de4a,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* Z ordinate */
{
0x00000001,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* infinity */
0
@ -23805,7 +23820,7 @@ static void sp_384_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -24716,9 +24731,10 @@ static void sp_384_proj_point_dbl_12(sp_point_384* r, const sp_point_384* p, sp_
*/
static int sp_384_cmp_equal_12(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7]) |
(a[8] ^ b[8]) | (a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
(a[6] ^ b[6]) | (a[7] ^ b[7]) | (a[8] ^ b[8]) |
(a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11])) == 0;
}
/* Add two Montgomery form projective points.
@ -28830,7 +28846,8 @@ static int sp_384_calc_s_12(sp_digit* s, const sp_digit* r, sp_digit* k,
sp_384_cond_sub_12(s, s, p384_order, 0 - carry);
sp_384_norm_12(s);
c = sp_384_cmp_12(s, p384_order);
sp_384_cond_sub_12(s, s, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_12(s, s, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_12(s);
/* s = s * k^-1 mod order */
@ -28923,7 +28940,8 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 12U);
sp_384_norm_12(ctx->r);
c = sp_384_cmp_12(ctx->r, p384_order);
sp_384_cond_sub_12(ctx->r, ctx->r, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_12(ctx->r, ctx->r, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_12(ctx->r);
sp_384_from_mp(ctx->x, 12, priv);
@ -28969,10 +28987,12 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
int32_t c;
sp_384_norm_12(ctx->x);
carry = sp_384_add_12(ctx->s, ctx->e, ctx->x);
sp_384_cond_sub_12(ctx->s, ctx->s, p384_order, 0 - carry);
sp_384_cond_sub_12(ctx->s, ctx->s,
p384_order, 0 - carry);
sp_384_norm_12(ctx->s);
c = sp_384_cmp_12(ctx->s, p384_order);
sp_384_cond_sub_12(ctx->s, ctx->s, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_12(ctx->s, ctx->s, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_12(ctx->s);
/* s = s * k^-1 mod order */
@ -29085,7 +29105,8 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng,
XMEMCPY(r, point->x, sizeof(sp_digit) * 12U);
sp_384_norm_12(r);
c = sp_384_cmp_12(r, p384_order);
sp_384_cond_sub_12(r, r, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_12(r, r, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_12(r);
sp_384_from_mp(x, 12, priv);
@ -31241,7 +31262,13 @@ static const sp_point_1024 p1024_base = {
0xdb9dfa55,0x43d5f22c,0x30b09e10,0xab10db90,0xf6ce2308,0xb5edb6c0,
0xb6ff7cbf,0x98b2f204,0x0aec69c6,0x2b1a2fd6,0x3ed9b52a,0x0a799005,
0x332c29ad,0x53fc09ee,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* Y ordinate */
{
@ -31251,7 +31278,13 @@ static const sp_point_1024 p1024_base = {
0x9a140b2e,0x6b598ccf,0xf0de55f6,0xe7f7f5e5,0x654ec2b9,0xf5ea69f4,
0x1e141178,0x3d778d82,0x02990696,0xd3e82016,0x3634a135,0xf9f1f053,
0x3f6009f1,0x0a824906,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* Z ordinate */
{
@ -31261,7 +31294,13 @@ static const sp_point_1024 p1024_base = {
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0
},
/* infinity */
0
@ -31732,7 +31771,7 @@ static void sp_1024_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -33507,14 +33546,17 @@ SP_NOINLINE static sp_digit sp_1024_sub_32(sp_digit* r, const sp_digit* a,
*/
static int sp_1024_cmp_equal_32(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7]) |
(a[8] ^ b[8]) | (a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
(a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14]) | (a[15] ^ b[15]) |
(a[16] ^ b[16]) | (a[17] ^ b[17]) | (a[18] ^ b[18]) | (a[19] ^ b[19]) |
(a[20] ^ b[20]) | (a[21] ^ b[21]) | (a[22] ^ b[22]) | (a[23] ^ b[23]) |
(a[24] ^ b[24]) | (a[25] ^ b[25]) | (a[26] ^ b[26]) | (a[27] ^ b[27]) |
(a[28] ^ b[28]) | (a[29] ^ b[29]) | (a[30] ^ b[30]) | (a[31] ^ b[31])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
(a[6] ^ b[6]) | (a[7] ^ b[7]) | (a[8] ^ b[8]) |
(a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
(a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14]) |
(a[15] ^ b[15]) | (a[16] ^ b[16]) | (a[17] ^ b[17]) |
(a[18] ^ b[18]) | (a[19] ^ b[19]) | (a[20] ^ b[20]) |
(a[21] ^ b[21]) | (a[22] ^ b[22]) | (a[23] ^ b[23]) |
(a[24] ^ b[24]) | (a[25] ^ b[25]) | (a[26] ^ b[26]) |
(a[27] ^ b[27]) | (a[28] ^ b[28]) | (a[29] ^ b[29]) |
(a[30] ^ b[30]) | (a[31] ^ b[31])) == 0;
}
/* Add two Montgomery form projective points.
@ -34901,8 +34943,12 @@ int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r,
*/
static const sp_table_entry_1024 p1024_table[16] = {
/* 0 */
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
/* 1 */
{ { 0xe0162bc2,0xbf9c7ec6,0x10a89289,0xddecc6e3,0x9e499d81,0x5d599df0,
0x6d358218,0x9a96ea28,0x70c5f8db,0x01aec7d3,0x8cf5d066,0xe72e4995,
@ -35129,8 +35175,12 @@ static int sp_1024_ecc_mulmod_base_32(sp_point_1024* r, const sp_digit* k,
*/
static const sp_table_entry_1024 p1024_table[256] = {
/* 0 */
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
/* 1 */
{ { 0xe0162bc2,0xbf9c7ec6,0x10a89289,0xddecc6e3,0x9e499d81,0x5d599df0,
0x6d358218,0x9a96ea28,0x70c5f8db,0x01aec7d3,0x8cf5d066,0xe72e4995,
@ -38831,7 +38881,8 @@ static void sp_1024_proj_sqr_32(sp_digit* px, sp_digit* py, sp_digit* t)
*/
int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
{
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td;
sp_digit* t;
sp_digit* tx;
@ -38850,7 +38901,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
int bits;
int i;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 8 * 32 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (td == NULL) {
@ -38859,7 +38911,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
tx = td + 4 * 32 * 2;
ty = td + 5 * 32 * 2;
@ -38902,7 +38955,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -40726,7 +40780,8 @@ static const sp_digit sp_1024_g_table[256][32] = {
*/
int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
{
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td;
sp_digit* t;
sp_digit* tx;
@ -40744,7 +40799,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
(void)base;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 6 * 32 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (td == NULL) {
@ -40753,7 +40809,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
tx = td + 4 * 32 * 2;
ty = td + 5 * 32 * 2;
@ -40796,7 +40853,8 @@ int sp_ModExp_Fp_star_1024(const mp_int* base, mp_int* exp, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -41066,7 +41124,8 @@ static void sp_1024_accumulate_line_add_one_32(sp_digit* vx, sp_digit* vy,
int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
{
int err = MP_OKAY;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -41095,7 +41154,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_point_new_32(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9 * 32 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -41106,7 +41166,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 32 * 2;
vy = td + 7 * 32 * 2;
@ -41162,7 +41223,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -41440,7 +41502,8 @@ static const signed char sp_1024_order_op[] = {
int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
{
int err;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -41476,7 +41539,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_point_new_32(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 32 * 2 + 16 * sizeof(sp_point_1024), NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -41487,7 +41551,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 32 * 2;
vy = td + 7 * 32 * 2;
@ -41585,7 +41650,8 @@ int sp_Pairing_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -41827,7 +41893,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
word32* len)
{
int err = 0;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_point_1024* pre_p;
@ -41866,7 +41933,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
err = sp_1024_point_new_32(NULL, negd, neg);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 6 * 32 * 2 + 16 * sizeof(sp_point_1024), NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -41877,7 +41945,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
pre_p = (sp_point_1024*)(td + 6 * 32 * 2);
#endif
@ -41949,7 +42018,8 @@ int sp_Pairing_gen_precomp_1024(const ecc_point* pm, byte* table,
*len = sizeof(sp_table_entry_1024) * 1167;
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -41983,7 +42053,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
mp_int* res, const byte* table, word32 len)
{
int err = 0;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -42025,7 +42096,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
err = sp_1024_point_new_32(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 32 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -42036,7 +42108,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 32 * 2;
vy = td + 7 * 32 * 2;
@ -42140,7 +42213,8 @@ int sp_Pairing_precomp_1024(const ecc_point* pm, const ecc_point* qm,
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}

View File

@ -2717,7 +2717,7 @@ int sp_count_bits(const sp_int* a)
r *= SP_WORD_SIZE;
if (d > SP_HALF_MAX) {
r += SP_WORD_SIZE;
while ((d & (1UL << (SP_WORD_SIZE - 1))) == 0) {
while ((d & ((sp_digit)1 << (SP_WORD_SIZE - 1))) == 0) {
r--;
d <<= 1;
}

View File

@ -115,7 +115,7 @@ static void sp_2048_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -2456,7 +2456,7 @@ static void sp_3072_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -4807,7 +4807,7 @@ static void sp_4096_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -6495,19 +6495,19 @@ static const sp_point_256 p256_base = {
{
0xf4a13945d898c296L,0x77037d812deb33a0L,0xf8bce6e563a440f2L,
0x6b17d1f2e12c4247L,
0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* Y ordinate */
{
0xcbb6406837bf51f5L,0x2bce33576b315eceL,0x8ee7eb4a7c0f9e16L,
0x4fe342e2fe1a7f9bL,
0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* Z ordinate */
{
0x0000000000000001L,0x0000000000000000L,0x0000000000000000L,
0x0000000000000000L,
0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0
},
/* infinity */
0
@ -6633,7 +6633,7 @@ static void sp_256_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -7234,7 +7234,8 @@ static void sp_256_proj_point_dbl_n_4(sp_point_256* p, int n,
*/
static int sp_256_cmp_equal_4(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3])) == 0;
}
/* Add two Montgomery form projective points.
@ -23604,7 +23605,8 @@ static int sp_256_calc_s_4(sp_digit* s, const sp_digit* r, sp_digit* k,
sp_256_cond_sub_4(s, s, p256_order, 0 - carry);
sp_256_norm_4(s);
c = sp_256_cmp_4(s, p256_order);
sp_256_cond_sub_4(s, s, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_4(s, s, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_4(s);
/* s = s * k^-1 mod order */
@ -23702,7 +23704,8 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 4U);
sp_256_norm_4(ctx->r);
c = sp_256_cmp_4(ctx->r, p256_order);
sp_256_cond_sub_4(ctx->r, ctx->r, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_4(ctx->r, ctx->r, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_4(ctx->r);
sp_256_from_mp(ctx->x, 4, priv);
@ -23748,10 +23751,12 @@ int sp_ecc_sign_256_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
int64_t c;
sp_256_norm_4(ctx->x);
carry = sp_256_add_4(ctx->s, ctx->e, ctx->x);
sp_256_cond_sub_4(ctx->s, ctx->s, p256_order, 0 - carry);
sp_256_cond_sub_4(ctx->s, ctx->s,
p256_order, 0 - carry);
sp_256_norm_4(ctx->s);
c = sp_256_cmp_4(ctx->s, p256_order);
sp_256_cond_sub_4(ctx->s, ctx->s, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_4(ctx->s, ctx->s, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_4(ctx->s);
/* s = s * k^-1 mod order */
@ -23872,7 +23877,8 @@ int sp_ecc_sign_256(const byte* hash, word32 hashLen, WC_RNG* rng,
XMEMCPY(r, point->x, sizeof(sp_digit) * 4U);
sp_256_norm_4(r);
c = sp_256_cmp_4(r, p256_order);
sp_256_cond_sub_4(r, r, p256_order, 0L - (sp_digit)(c >= 0));
sp_256_cond_sub_4(r, r, p256_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_256_norm_4(r);
sp_256_from_mp(x, 4, priv);
@ -25026,19 +25032,22 @@ static const sp_point_384 p384_base = {
{
0x3a545e3872760ab7L,0x5502f25dbf55296cL,0x59f741e082542a38L,
0x6e1d3b628ba79b98L,0x8eb1c71ef320ad74L,0xaa87ca22be8b0537L,
0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0
},
/* Y ordinate */
{
0x7a431d7c90ea0e5fL,0x0a60b1ce1d7e819dL,0xe9da3113b5f0b8c0L,
0xf8f41dbd289a147cL,0x5d9e98bf9292dc29L,0x3617de4a96262c6fL,
0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0
},
/* Z ordinate */
{
0x0000000000000001L,0x0000000000000000L,0x0000000000000000L,
0x0000000000000000L,0x0000000000000000L,0x0000000000000000L,
0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0
},
/* infinity */
0
@ -25208,7 +25217,7 @@ static void sp_384_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -25912,8 +25921,8 @@ static void sp_384_proj_point_dbl_n_6(sp_point_384* p, int n,
*/
static int sp_384_cmp_equal_6(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5])) == 0;
}
/* Add two Montgomery form projective points.
@ -48093,7 +48102,8 @@ static int sp_384_calc_s_6(sp_digit* s, const sp_digit* r, sp_digit* k,
sp_384_cond_sub_6(s, s, p384_order, 0 - carry);
sp_384_norm_6(s);
c = sp_384_cmp_6(s, p384_order);
sp_384_cond_sub_6(s, s, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_6(s, s, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_6(s);
/* s = s * k^-1 mod order */
@ -48191,7 +48201,8 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
XMEMCPY(ctx->r, ctx->point.x, sizeof(sp_digit) * 6U);
sp_384_norm_6(ctx->r);
c = sp_384_cmp_6(ctx->r, p384_order);
sp_384_cond_sub_6(ctx->r, ctx->r, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_6(ctx->r, ctx->r, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_6(ctx->r);
sp_384_from_mp(ctx->x, 6, priv);
@ -48237,10 +48248,12 @@ int sp_ecc_sign_384_nb(sp_ecc_ctx_t* sp_ctx, const byte* hash, word32 hashLen, W
int64_t c;
sp_384_norm_6(ctx->x);
carry = sp_384_add_6(ctx->s, ctx->e, ctx->x);
sp_384_cond_sub_6(ctx->s, ctx->s, p384_order, 0 - carry);
sp_384_cond_sub_6(ctx->s, ctx->s,
p384_order, 0 - carry);
sp_384_norm_6(ctx->s);
c = sp_384_cmp_6(ctx->s, p384_order);
sp_384_cond_sub_6(ctx->s, ctx->s, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_6(ctx->s, ctx->s, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_6(ctx->s);
/* s = s * k^-1 mod order */
@ -48361,7 +48374,8 @@ int sp_ecc_sign_384(const byte* hash, word32 hashLen, WC_RNG* rng,
XMEMCPY(r, point->x, sizeof(sp_digit) * 6U);
sp_384_norm_6(r);
c = sp_384_cmp_6(r, p384_order);
sp_384_cond_sub_6(r, r, p384_order, 0L - (sp_digit)(c >= 0));
sp_384_cond_sub_6(r, r, p384_order,
(sp_digit)0 - (sp_digit)(c >= 0));
sp_384_norm_6(r);
sp_384_from_mp(x, 6, priv);
@ -49649,7 +49663,10 @@ static const sp_point_1024 p1024_base = {
0x43d5f22cdb9dfa55L,0xab10db9030b09e10L,0xb5edb6c0f6ce2308L,
0x98b2f204b6ff7cbfL,0x2b1a2fd60aec69c6L,0x0a7990053ed9b52aL,
0x53fc09ee332c29adL,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0
},
/* Y ordinate */
{
@ -49659,7 +49676,10 @@ static const sp_point_1024 p1024_base = {
0x6b598ccf9a140b2eL,0xe7f7f5e5f0de55f6L,0xf5ea69f4654ec2b9L,
0x3d778d821e141178L,0xd3e8201602990696L,0xf9f1f0533634a135L,
0x0a8249063f6009f1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0
},
/* Z ordinate */
{
@ -49669,7 +49689,10 @@ static const sp_point_1024 p1024_base = {
0x0000000000000000L,0x0000000000000000L,0x0000000000000000L,
0x0000000000000000L,0x0000000000000000L,0x0000000000000000L,
0x0000000000000000L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0, (sp_digit)0,
(sp_digit)0
},
/* infinity */
0
@ -49958,7 +49981,7 @@ static void sp_1024_from_mp(sp_digit* r, int size, const mp_int* a)
r[++j] = (sp_digit)(a->dp[i] >> s); /*lint !e9033*/
}
else {
r[++j] = 0L;
r[++j] = (sp_digit)0;
}
}
s = (word32)DIGIT_BIT - s;
@ -50546,10 +50569,12 @@ extern sp_digit sp_1024_sub_16(sp_digit* r, const sp_digit* a, const sp_digit* b
*/
static int sp_1024_cmp_equal_16(const sp_digit* a, const sp_digit* b)
{
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3]) |
(a[4] ^ b[4]) | (a[5] ^ b[5]) | (a[6] ^ b[6]) | (a[7] ^ b[7]) |
(a[8] ^ b[8]) | (a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
(a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14]) | (a[15] ^ b[15])) == 0;
return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) |
(a[3] ^ b[3]) | (a[4] ^ b[4]) | (a[5] ^ b[5]) |
(a[6] ^ b[6]) | (a[7] ^ b[7]) | (a[8] ^ b[8]) |
(a[9] ^ b[9]) | (a[10] ^ b[10]) | (a[11] ^ b[11]) |
(a[12] ^ b[12]) | (a[13] ^ b[13]) | (a[14] ^ b[14]) |
(a[15] ^ b[15])) == 0;
}
/* Add two Montgomery form projective points.
@ -53104,8 +53129,10 @@ int sp_ecc_mulmod_1024(const mp_int* km, const ecc_point* gm, ecc_point* r,
*/
static const sp_table_entry_1024 p1024_table[256] = {
/* 0 */
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 } },
/* 1 */
{ { 0xbf9c7ec6e0162bc2L,0xddecc6e310a89289L,0x5d599df09e499d81L,
0x9a96ea286d358218L,0x01aec7d370c5f8dbL,0xe72e49958cf5d066L,
@ -56872,7 +56899,8 @@ static void sp_1024_proj_sqr_16(sp_digit* px, sp_digit* py, sp_digit* t)
*/
static int sp_ModExp_Fp_star_x64_1024(const mp_int* base, mp_int* exp, mp_int* res)
{
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td;
sp_digit* t;
sp_digit* tx;
@ -56891,7 +56919,8 @@ static int sp_ModExp_Fp_star_x64_1024(const mp_int* base, mp_int* exp, mp_int* r
int bits;
int i;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 8 * 16 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (td == NULL) {
@ -56900,7 +56929,8 @@ static int sp_ModExp_Fp_star_x64_1024(const mp_int* base, mp_int* exp, mp_int* r
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
tx = td + 4 * 16 * 2;
ty = td + 5 * 16 * 2;
@ -56943,7 +56973,8 @@ static int sp_ModExp_Fp_star_x64_1024(const mp_int* base, mp_int* exp, mp_int* r
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -58511,7 +58542,8 @@ static const sp_digit sp_1024_g_table[256][16] = {
*/
static int sp_ModExp_Fp_star_x64_1024(const mp_int* base, mp_int* exp, mp_int* res)
{
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td;
sp_digit* t;
sp_digit* tx;
@ -58529,7 +58561,8 @@ static int sp_ModExp_Fp_star_x64_1024(const mp_int* base, mp_int* exp, mp_int* r
(void)base;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 6 * 16 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (td == NULL) {
@ -58538,7 +58571,8 @@ static int sp_ModExp_Fp_star_x64_1024(const mp_int* base, mp_int* exp, mp_int* r
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
tx = td + 4 * 16 * 2;
ty = td + 5 * 16 * 2;
@ -58581,7 +58615,8 @@ static int sp_ModExp_Fp_star_x64_1024(const mp_int* base, mp_int* exp, mp_int* r
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -58656,7 +58691,8 @@ static void sp_1024_proj_sqr_avx2_16(sp_digit* px, sp_digit* py, sp_digit* t)
*/
static int sp_ModExp_Fp_star_avx2_1024(const mp_int* base, mp_int* exp, mp_int* res)
{
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td;
sp_digit* t;
sp_digit* tx;
@ -58675,7 +58711,8 @@ static int sp_ModExp_Fp_star_avx2_1024(const mp_int* base, mp_int* exp, mp_int*
int bits;
int i;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 8 * 16 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (td == NULL) {
@ -58684,7 +58721,8 @@ static int sp_ModExp_Fp_star_avx2_1024(const mp_int* base, mp_int* exp, mp_int*
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
tx = td + 4 * 16 * 2;
ty = td + 5 * 16 * 2;
@ -58727,7 +58765,8 @@ static int sp_ModExp_Fp_star_avx2_1024(const mp_int* base, mp_int* exp, mp_int*
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -58752,7 +58791,8 @@ static int sp_ModExp_Fp_star_avx2_1024(const mp_int* base, mp_int* exp, mp_int*
*/
static int sp_ModExp_Fp_star_avx2_1024(const mp_int* base, mp_int* exp, mp_int* res)
{
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td;
sp_digit* t;
sp_digit* tx;
@ -58770,7 +58810,8 @@ static int sp_ModExp_Fp_star_avx2_1024(const mp_int* base, mp_int* exp, mp_int*
(void)base;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 6 * 16 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
if (td == NULL) {
@ -58779,7 +58820,8 @@ static int sp_ModExp_Fp_star_avx2_1024(const mp_int* base, mp_int* exp, mp_int*
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
tx = td + 4 * 16 * 2;
ty = td + 5 * 16 * 2;
@ -58822,7 +58864,8 @@ static int sp_ModExp_Fp_star_avx2_1024(const mp_int* base, mp_int* exp, mp_int*
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -59121,7 +59164,8 @@ static void sp_1024_accumulate_line_add_one_16(sp_digit* vx, sp_digit* vy,
static int sp_Pairing_x64_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
{
int err = MP_OKAY;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -59150,7 +59194,8 @@ static int sp_Pairing_x64_1024(const ecc_point* pm, const ecc_point* qm, mp_int*
err = sp_1024_point_new_16(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9 * 16 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -59161,7 +59206,8 @@ static int sp_Pairing_x64_1024(const ecc_point* pm, const ecc_point* qm, mp_int*
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 16 * 2;
vy = td + 7 * 16 * 2;
@ -59217,7 +59263,8 @@ static int sp_Pairing_x64_1024(const ecc_point* pm, const ecc_point* qm, mp_int*
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -59495,7 +59542,8 @@ static const signed char sp_1024_order_op[] = {
static int sp_Pairing_x64_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
{
int err;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -59531,7 +59579,8 @@ static int sp_Pairing_x64_1024(const ecc_point* pm, const ecc_point* qm, mp_int*
err = sp_1024_point_new_16(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 16 * 2 + 16 * sizeof(sp_point_1024), NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -59542,7 +59591,8 @@ static int sp_Pairing_x64_1024(const ecc_point* pm, const ecc_point* qm, mp_int*
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 16 * 2;
vy = td + 7 * 16 * 2;
@ -59640,7 +59690,8 @@ static int sp_Pairing_x64_1024(const ecc_point* pm, const ecc_point* qm, mp_int*
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -59914,7 +59965,8 @@ static void sp_1024_accumulate_line_add_one_avx2_16(sp_digit* vx, sp_digit* vy,
static int sp_Pairing_avx2_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
{
int err = MP_OKAY;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -59943,7 +59995,8 @@ static int sp_Pairing_avx2_1024(const ecc_point* pm, const ecc_point* qm, mp_int
err = sp_1024_point_new_16(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 9 * 16 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -59954,7 +60007,8 @@ static int sp_Pairing_avx2_1024(const ecc_point* pm, const ecc_point* qm, mp_int
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 16 * 2;
vy = td + 7 * 16 * 2;
@ -60010,7 +60064,8 @@ static int sp_Pairing_avx2_1024(const ecc_point* pm, const ecc_point* qm, mp_int
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -60261,7 +60316,8 @@ static void sp_1024_accumulate_line_dbl_n_avx2_16(sp_digit* vx, sp_digit* vy,
static int sp_Pairing_avx2_1024(const ecc_point* pm, const ecc_point* qm, mp_int* res)
{
int err;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -60297,7 +60353,8 @@ static int sp_Pairing_avx2_1024(const ecc_point* pm, const ecc_point* qm, mp_int
err = sp_1024_point_new_16(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 16 * 2 + 16 * sizeof(sp_point_1024), NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -60308,7 +60365,8 @@ static int sp_Pairing_avx2_1024(const ecc_point* pm, const ecc_point* qm, mp_int
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 16 * 2;
vy = td + 7 * 16 * 2;
@ -60406,7 +60464,8 @@ static int sp_Pairing_avx2_1024(const ecc_point* pm, const ecc_point* qm, mp_int
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -60682,7 +60741,8 @@ static int sp_Pairing_gen_precomp_x64_1024(const ecc_point* pm, byte* table,
word32* len)
{
int err = 0;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_point_1024* pre_p;
@ -60721,7 +60781,8 @@ static int sp_Pairing_gen_precomp_x64_1024(const ecc_point* pm, byte* table,
err = sp_1024_point_new_16(NULL, negd, neg);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 6 * 16 * 2 + 16 * sizeof(sp_point_1024), NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -60732,7 +60793,8 @@ static int sp_Pairing_gen_precomp_x64_1024(const ecc_point* pm, byte* table,
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
pre_p = (sp_point_1024*)(td + 6 * 16 * 2);
#endif
@ -60804,7 +60866,8 @@ static int sp_Pairing_gen_precomp_x64_1024(const ecc_point* pm, byte* table,
*len = sizeof(sp_table_entry_1024) * 1167;
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -60838,7 +60901,8 @@ static int sp_Pairing_precomp_x64_1024(const ecc_point* pm, const ecc_point* qm,
mp_int* res, const byte* table, word32 len)
{
int err = 0;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -60880,7 +60944,8 @@ static int sp_Pairing_precomp_x64_1024(const ecc_point* pm, const ecc_point* qm,
err = sp_1024_point_new_16(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 16 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -60891,7 +60956,8 @@ static int sp_Pairing_precomp_x64_1024(const ecc_point* pm, const ecc_point* qm,
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 16 * 2;
vy = td + 7 * 16 * 2;
@ -60995,7 +61061,8 @@ static int sp_Pairing_precomp_x64_1024(const ecc_point* pm, const ecc_point* qm,
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -61211,7 +61278,8 @@ static int sp_Pairing_gen_precomp_avx2_1024(const ecc_point* pm, byte* table,
word32* len)
{
int err = 0;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_point_1024* pre_p;
@ -61250,7 +61318,8 @@ static int sp_Pairing_gen_precomp_avx2_1024(const ecc_point* pm, byte* table,
err = sp_1024_point_new_16(NULL, negd, neg);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 6 * 16 * 2 + 16 * sizeof(sp_point_1024), NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -61261,7 +61330,8 @@ static int sp_Pairing_gen_precomp_avx2_1024(const ecc_point* pm, byte* table,
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
pre_p = (sp_point_1024*)(td + 6 * 16 * 2);
#endif
@ -61333,7 +61403,8 @@ static int sp_Pairing_gen_precomp_avx2_1024(const ecc_point* pm, byte* table,
*len = sizeof(sp_table_entry_1024) * 1167;
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}
@ -61367,7 +61438,8 @@ static int sp_Pairing_precomp_avx2_1024(const ecc_point* pm, const ecc_point* qm
mp_int* res, const byte* table, word32 len)
{
int err = 0;
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
sp_digit* td = NULL;
sp_digit* t;
sp_digit* vx;
@ -61409,7 +61481,8 @@ static int sp_Pairing_precomp_avx2_1024(const ecc_point* pm, const ecc_point* qm
err = sp_1024_point_new_16(NULL, cd, c);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (err == MP_OKAY) {
td = (sp_digit*)XMALLOC(sizeof(sp_digit) * 56 * 16 * 2, NULL,
DYNAMIC_TYPE_TMP_BUFFER);
@ -61420,7 +61493,8 @@ static int sp_Pairing_precomp_avx2_1024(const ecc_point* pm, const ecc_point* qm
#endif
if (err == MP_OKAY) {
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
t = td;
vx = td + 6 * 16 * 2;
vy = td + 7 * 16 * 2;
@ -61524,7 +61598,8 @@ static int sp_Pairing_precomp_avx2_1024(const ecc_point* pm, const ecc_point* qm
err = sp_1024_to_mp(r, res);
}
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && !defined(WOLFSSL_SP_NO_MALLOC)
#if (defined(WOLFSSL_SP_SMALL) || defined(WOLFSSL_SMALL_STACK)) && \
!defined(WOLFSSL_SP_NO_MALLOC)
if (td != NULL) {
XFREE(td, NULL, DYNAMIC_TYPE_TMP_BUFFER);
}