X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=ecp_id_tc26_gost_3410_2012_256_paramSetA.c;h=1528163f4c674abd83aace96db8bde93d45d4b51;hb=259301a5adf2ef51b8f380b27fcead313669206e;hp=ad1c5f210307bbfdb67f95e1349b56e3b1a2968d;hpb=bc346202fbb3bc838a19af8c3b0e449926589c7b;p=openssl-gost%2Fengine.git diff --git a/ecp_id_tc26_gost_3410_2012_256_paramSetA.c b/ecp_id_tc26_gost_3410_2012_256_paramSetA.c index ad1c5f2..1528163 100644 --- a/ecp_id_tc26_gost_3410_2012_256_paramSetA.c +++ b/ecp_id_tc26_gost_3410_2012_256_paramSetA.c @@ -3320,7 +3320,7 @@ static void point_add_proj(pt_prj_t *R, const pt_prj_t *Q, const pt_prj_t *P) { */ static void point_edwards2legacy(pt_prj_t *Q, const pt_prj_t *P) { /* temporary variables */ - fe_t t0, t1; + fe_t t0; /* constants */ const limb_t *S = const_S; const limb_t *T = const_T; @@ -3333,13 +3333,13 @@ static void point_edwards2legacy(pt_prj_t *Q, const pt_prj_t *P) { limb_t *Z3 = Q->Z; /* the curve arith formula */ - fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_add(t0, Z1, Y1); - fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_sub(t1, Z1, Y1); - fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(T3, S, t0); + fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_add(T3, Z1, Y1); + fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_sub(t0, Z1, Y1); + fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(T3, S, T3); fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(Y3, Z1, T3); - fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(Z3, X3, t1); - fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(t1, t1, T); - fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_add(t0, T3, t1); + fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(Z3, X1, t0); + fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(t0, t0, T); + fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_add(t0, T3, t0); fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(X3, X1, t0); } @@ -3417,9 +3417,9 @@ static int scalar_get_bit(const unsigned char in[32], int idx) { * {\pm 1, \pm 3, \pm 5, \pm 7, \pm 9, ...} * i.e. signed odd digits with _no zeroes_ -- that makes it "regular". */ -static void scalar_rwnaf(char out[52], const unsigned char in[32]) { +static void scalar_rwnaf(int8_t out[52], const unsigned char in[32]) { int i; - char window, d; + int8_t window, d; window = (in[0] & (DRADIX_WNAF - 1)) | 1; for (i = 0; i < 51; i++) { @@ -3439,9 +3439,9 @@ static void scalar_rwnaf(char out[52], const unsigned char in[32]) { * Compute "textbook" wnaf representation of a scalar. * NB: not constant time */ -static void scalar_wnaf(char out[257], const unsigned char in[32]) { +static void scalar_wnaf(int8_t out[257], const unsigned char in[32]) { int i; - char window, d; + int8_t window, d; window = in[0] & (DRADIX_WNAF - 1); for (i = 0; i < 257; i++) { @@ -3461,8 +3461,8 @@ static void scalar_wnaf(char out[257], const unsigned char in[32]) { static void var_smul_wnaf_two(pt_aff_t *out, const unsigned char a[32], const unsigned char b[32], const pt_aff_t *P) { int i, d, is_neg, is_inf = 1, flipped = 0; - char anaf[257] = {0}; - char bnaf[257] = {0}; + int8_t anaf[257] = {0}; + int8_t bnaf[257] = {0}; pt_prj_t Q; pt_prj_t precomp[DRADIX / 2]; @@ -3536,7 +3536,7 @@ static void var_smul_wnaf_two(pt_aff_t *out, const unsigned char a[32], static void var_smul_rwnaf(pt_aff_t *out, const unsigned char scalar[32], const pt_aff_t *P) { int i, j, d, diff, is_neg; - char rnaf[52] = {0}; + int8_t rnaf[52] = {0}; pt_prj_t Q, lut; pt_prj_t precomp[DRADIX / 2]; @@ -3624,7 +3624,7 @@ static void var_smul_rwnaf(pt_aff_t *out, const unsigned char scalar[32], */ static void fixed_smul_cmb(pt_aff_t *out, const unsigned char scalar[32]) { int i, j, k, d, diff, is_neg = 0; - char rnaf[52] = {0}; + int8_t rnaf[52] = {0}; pt_prj_t Q, R; pt_aff_t lut; @@ -3737,6 +3737,7 @@ static void point_mul(unsigned char outx[32], unsigned char outy[32], fiat_id_tc26_gost_3410_2012_256_paramSetA_to_bytes(outy, P.Y); } + #include static const unsigned char const_zb[32] = {0}; @@ -8461,10 +8462,10 @@ static void point_add_proj(pt_prj_t *R, const pt_prj_t *Q, const pt_prj_t *P) { */ static void point_edwards2legacy(pt_prj_t *Q, const pt_prj_t *P) { /* temporary variables */ - fe_t t0, t1; + fe_t t0; /* constants */ - const limb_t *S = const_S; const limb_t *T = const_T; + const limb_t *S = const_S; const limb_t *X1 = P->X; const limb_t *Y1 = P->Y; const limb_t *Z1 = P->Z; @@ -8474,13 +8475,13 @@ static void point_edwards2legacy(pt_prj_t *Q, const pt_prj_t *P) { limb_t *Z3 = Q->Z; /* the curve arith formula */ - fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_add(t0, Z1, Y1); - fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_sub(t1, Z1, Y1); - fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(T3, S, t0); + fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_add(T3, Z1, Y1); + fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_sub(t0, Z1, Y1); + fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(T3, S, T3); fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(Y3, Z1, T3); - fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(Z3, X3, t1); - fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(t1, t1, T); - fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_add(t0, T3, t1); + fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(Z3, X1, t0); + fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(t0, t0, T); + fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_add(t0, T3, t0); fiat_id_tc26_gost_3410_2012_256_paramSetA_carry_mul(X3, X1, t0); } @@ -8491,8 +8492,8 @@ static void point_edwards2legacy(pt_prj_t *Q, const pt_prj_t *P) { */ static void point_legacy2edwards(pt_prj_t *Q, const pt_aff_t *P) { /* constants */ - const limb_t *S = const_S; const limb_t *T = const_T; + const limb_t *S = const_S; const limb_t *X1 = P->X; const limb_t *Y1 = P->Y; limb_t *X3 = Q->X; @@ -8558,9 +8559,9 @@ static int scalar_get_bit(const unsigned char in[32], int idx) { * {\pm 1, \pm 3, \pm 5, \pm 7, \pm 9, ...} * i.e. signed odd digits with _no zeroes_ -- that makes it "regular". */ -static void scalar_rwnaf(char out[52], const unsigned char in[32]) { +static void scalar_rwnaf(int8_t out[52], const unsigned char in[32]) { int i; - char window, d; + int8_t window, d; window = (in[0] & (DRADIX_WNAF - 1)) | 1; for (i = 0; i < 51; i++) { @@ -8580,9 +8581,9 @@ static void scalar_rwnaf(char out[52], const unsigned char in[32]) { * Compute "textbook" wnaf representation of a scalar. * NB: not constant time */ -static void scalar_wnaf(char out[257], const unsigned char in[32]) { +static void scalar_wnaf(int8_t out[257], const unsigned char in[32]) { int i; - char window, d; + int8_t window, d; window = in[0] & (DRADIX_WNAF - 1); for (i = 0; i < 257; i++) { @@ -8602,8 +8603,8 @@ static void scalar_wnaf(char out[257], const unsigned char in[32]) { static void var_smul_wnaf_two(pt_aff_t *out, const unsigned char a[32], const unsigned char b[32], const pt_aff_t *P) { int i, d, is_neg, is_inf = 1, flipped = 0; - char anaf[257] = {0}; - char bnaf[257] = {0}; + int8_t anaf[257] = {0}; + int8_t bnaf[257] = {0}; pt_prj_t Q; pt_prj_t precomp[DRADIX / 2]; @@ -8677,7 +8678,7 @@ static void var_smul_wnaf_two(pt_aff_t *out, const unsigned char a[32], static void var_smul_rwnaf(pt_aff_t *out, const unsigned char scalar[32], const pt_aff_t *P) { int i, j, d, diff, is_neg; - char rnaf[52] = {0}; + int8_t rnaf[52] = {0}; pt_prj_t Q, lut; pt_prj_t precomp[DRADIX / 2]; @@ -8765,7 +8766,7 @@ static void var_smul_rwnaf(pt_aff_t *out, const unsigned char scalar[32], */ static void fixed_smul_cmb(pt_aff_t *out, const unsigned char scalar[32]) { int i, j, k, d, diff, is_neg = 0; - char rnaf[52] = {0}; + int8_t rnaf[52] = {0}; pt_prj_t Q, R; pt_aff_t lut; @@ -8878,6 +8879,7 @@ static void point_mul(unsigned char outx[32], unsigned char outy[32], fiat_id_tc26_gost_3410_2012_256_paramSetA_to_bytes(outy, P.Y); } + #include static const unsigned char const_zb[32] = {0};