summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/ec/ecp_smpl.c
diff options
context:
space:
mode:
authortb <>2021-04-20 17:38:02 +0000
committertb <>2021-04-20 17:38:02 +0000
commit32070dad37b67934ecda0c27a9a74f20f48b84af (patch)
tree989d48df03f6b94e8b2cf288abee911e3827bb0d /src/lib/libcrypto/ec/ecp_smpl.c
parent3f027c2eef19e3fbfb52252b5f75fe958ccd8d8c (diff)
downloadopenbsd-32070dad37b67934ecda0c27a9a74f20f48b84af.tar.gz
openbsd-32070dad37b67934ecda0c27a9a74f20f48b84af.tar.bz2
openbsd-32070dad37b67934ecda0c27a9a74f20f48b84af.zip
Fix indent of EC_METHODs as requested by jsing.
While there zap trailing whitespace from a KNF approximation gone wrong.
Diffstat (limited to 'src/lib/libcrypto/ec/ecp_smpl.c')
-rw-r--r--src/lib/libcrypto/ec/ecp_smpl.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c
index 9223427459..96ab5bd44e 100644
--- a/src/lib/libcrypto/ec/ecp_smpl.c
+++ b/src/lib/libcrypto/ec/ecp_smpl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecp_smpl.c,v 1.31 2021/04/20 17:28:18 tb Exp $ */ 1/* $OpenBSD: ecp_smpl.c,v 1.32 2021/04/20 17:38:02 tb Exp $ */
2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> 2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * for the OpenSSL project. 3 * for the OpenSSL project.
4 * Includes code written by Bodo Moeller for the OpenSSL project. 4 * Includes code written by Bodo Moeller for the OpenSSL project.
@@ -81,20 +81,20 @@ EC_GFp_simple_method(void)
81 .group_get_curve = ec_GFp_simple_group_get_curve, 81 .group_get_curve = ec_GFp_simple_group_get_curve,
82 .group_get_degree = ec_GFp_simple_group_get_degree, 82 .group_get_degree = ec_GFp_simple_group_get_degree,
83 .group_check_discriminant = 83 .group_check_discriminant =
84 ec_GFp_simple_group_check_discriminant, 84 ec_GFp_simple_group_check_discriminant,
85 .point_init = ec_GFp_simple_point_init, 85 .point_init = ec_GFp_simple_point_init,
86 .point_finish = ec_GFp_simple_point_finish, 86 .point_finish = ec_GFp_simple_point_finish,
87 .point_clear_finish = ec_GFp_simple_point_clear_finish, 87 .point_clear_finish = ec_GFp_simple_point_clear_finish,
88 .point_copy = ec_GFp_simple_point_copy, 88 .point_copy = ec_GFp_simple_point_copy,
89 .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity, 89 .point_set_to_infinity = ec_GFp_simple_point_set_to_infinity,
90 .point_set_Jprojective_coordinates = 90 .point_set_Jprojective_coordinates =
91 ec_GFp_simple_set_Jprojective_coordinates, 91 ec_GFp_simple_set_Jprojective_coordinates,
92 .point_get_Jprojective_coordinates = 92 .point_get_Jprojective_coordinates =
93 ec_GFp_simple_get_Jprojective_coordinates, 93 ec_GFp_simple_get_Jprojective_coordinates,
94 .point_set_affine_coordinates = 94 .point_set_affine_coordinates =
95 ec_GFp_simple_point_set_affine_coordinates, 95 ec_GFp_simple_point_set_affine_coordinates,
96 .point_get_affine_coordinates = 96 .point_get_affine_coordinates =
97 ec_GFp_simple_point_get_affine_coordinates, 97 ec_GFp_simple_point_get_affine_coordinates,
98 .add = ec_GFp_simple_add, 98 .add = ec_GFp_simple_add,
99 .dbl = ec_GFp_simple_dbl, 99 .dbl = ec_GFp_simple_dbl,
100 .invert = ec_GFp_simple_invert, 100 .invert = ec_GFp_simple_invert,
@@ -129,7 +129,7 @@ EC_GFp_simple_method(void)
129 */ 129 */
130 130
131 131
132int 132int
133ec_GFp_simple_group_init(EC_GROUP * group) 133ec_GFp_simple_group_init(EC_GROUP * group)
134{ 134{
135 BN_init(&group->field); 135 BN_init(&group->field);
@@ -140,7 +140,7 @@ ec_GFp_simple_group_init(EC_GROUP * group)
140} 140}
141 141
142 142
143void 143void
144ec_GFp_simple_group_finish(EC_GROUP * group) 144ec_GFp_simple_group_finish(EC_GROUP * group)
145{ 145{
146 BN_free(&group->field); 146 BN_free(&group->field);
@@ -149,7 +149,7 @@ ec_GFp_simple_group_finish(EC_GROUP * group)
149} 149}
150 150
151 151
152void 152void
153ec_GFp_simple_group_clear_finish(EC_GROUP * group) 153ec_GFp_simple_group_clear_finish(EC_GROUP * group)
154{ 154{
155 BN_clear_free(&group->field); 155 BN_clear_free(&group->field);
@@ -158,7 +158,7 @@ ec_GFp_simple_group_clear_finish(EC_GROUP * group)
158} 158}
159 159
160 160
161int 161int
162ec_GFp_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src) 162ec_GFp_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src)
163{ 163{
164 if (!BN_copy(&dest->field, &src->field)) 164 if (!BN_copy(&dest->field, &src->field))
@@ -174,7 +174,7 @@ ec_GFp_simple_group_copy(EC_GROUP * dest, const EC_GROUP * src)
174} 174}
175 175
176 176
177int 177int
178ec_GFp_simple_group_set_curve(EC_GROUP * group, 178ec_GFp_simple_group_set_curve(EC_GROUP * group,
179 const BIGNUM * p, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) 179 const BIGNUM * p, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx)
180{ 180{
@@ -231,7 +231,7 @@ ec_GFp_simple_group_set_curve(EC_GROUP * group,
231} 231}
232 232
233 233
234int 234int
235ec_GFp_simple_group_get_curve(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BIGNUM * b, BN_CTX * ctx) 235ec_GFp_simple_group_get_curve(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BIGNUM * b, BN_CTX * ctx)
236{ 236{
237 int ret = 0; 237 int ret = 0;
@@ -275,14 +275,14 @@ ec_GFp_simple_group_get_curve(const EC_GROUP * group, BIGNUM * p, BIGNUM * a, BI
275} 275}
276 276
277 277
278int 278int
279ec_GFp_simple_group_get_degree(const EC_GROUP * group) 279ec_GFp_simple_group_get_degree(const EC_GROUP * group)
280{ 280{
281 return BN_num_bits(&group->field); 281 return BN_num_bits(&group->field);
282} 282}
283 283
284 284
285int 285int
286ec_GFp_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx) 286ec_GFp_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx)
287{ 287{
288 int ret = 0; 288 int ret = 0;
@@ -358,7 +358,7 @@ ec_GFp_simple_group_check_discriminant(const EC_GROUP * group, BN_CTX * ctx)
358} 358}
359 359
360 360
361int 361int
362ec_GFp_simple_point_init(EC_POINT * point) 362ec_GFp_simple_point_init(EC_POINT * point)
363{ 363{
364 BN_init(&point->X); 364 BN_init(&point->X);
@@ -370,7 +370,7 @@ ec_GFp_simple_point_init(EC_POINT * point)
370} 370}
371 371
372 372
373void 373void
374ec_GFp_simple_point_finish(EC_POINT * point) 374ec_GFp_simple_point_finish(EC_POINT * point)
375{ 375{
376 BN_free(&point->X); 376 BN_free(&point->X);
@@ -379,7 +379,7 @@ ec_GFp_simple_point_finish(EC_POINT * point)
379} 379}
380 380
381 381
382void 382void
383ec_GFp_simple_point_clear_finish(EC_POINT * point) 383ec_GFp_simple_point_clear_finish(EC_POINT * point)
384{ 384{
385 BN_clear_free(&point->X); 385 BN_clear_free(&point->X);
@@ -389,7 +389,7 @@ ec_GFp_simple_point_clear_finish(EC_POINT * point)
389} 389}
390 390
391 391
392int 392int
393ec_GFp_simple_point_copy(EC_POINT * dest, const EC_POINT * src) 393ec_GFp_simple_point_copy(EC_POINT * dest, const EC_POINT * src)
394{ 394{
395 if (!BN_copy(&dest->X, &src->X)) 395 if (!BN_copy(&dest->X, &src->X))
@@ -404,7 +404,7 @@ ec_GFp_simple_point_copy(EC_POINT * dest, const EC_POINT * src)
404} 404}
405 405
406 406
407int 407int
408ec_GFp_simple_point_set_to_infinity(const EC_GROUP * group, EC_POINT * point) 408ec_GFp_simple_point_set_to_infinity(const EC_GROUP * group, EC_POINT * point)
409{ 409{
410 point->Z_is_one = 0; 410 point->Z_is_one = 0;
@@ -633,7 +633,7 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POIN
633 return ret; 633 return ret;
634} 634}
635 635
636int 636int
637ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) 637ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx)
638{ 638{
639 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); 639 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
@@ -822,7 +822,7 @@ ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, cons
822} 822}
823 823
824 824
825int 825int
826ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_CTX * ctx) 826ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_CTX * ctx)
827{ 827{
828 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); 828 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
@@ -964,7 +964,7 @@ ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_C
964} 964}
965 965
966 966
967int 967int
968ec_GFp_simple_invert(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) 968ec_GFp_simple_invert(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx)
969{ 969{
970 if (EC_POINT_is_at_infinity(group, point) > 0 || BN_is_zero(&point->Y)) 970 if (EC_POINT_is_at_infinity(group, point) > 0 || BN_is_zero(&point->Y))
@@ -975,14 +975,14 @@ ec_GFp_simple_invert(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx)
975} 975}
976 976
977 977
978int 978int
979ec_GFp_simple_is_at_infinity(const EC_GROUP * group, const EC_POINT * point) 979ec_GFp_simple_is_at_infinity(const EC_GROUP * group, const EC_POINT * point)
980{ 980{
981 return BN_is_zero(&point->Z); 981 return BN_is_zero(&point->Z);
982} 982}
983 983
984 984
985int 985int
986ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ctx) 986ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ctx)
987{ 987{
988 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); 988 int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
@@ -1085,7 +1085,7 @@ ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX
1085} 1085}
1086 1086
1087 1087
1088int 1088int
1089ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx) 1089ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b, BN_CTX * ctx)
1090{ 1090{
1091 /* 1091 /*
@@ -1187,7 +1187,7 @@ ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b
1187} 1187}
1188 1188
1189 1189
1190int 1190int
1191ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) 1191ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx)
1192{ 1192{
1193 BN_CTX *new_ctx = NULL; 1193 BN_CTX *new_ctx = NULL;
@@ -1225,7 +1225,7 @@ ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx
1225} 1225}
1226 1226
1227 1227
1228int 1228int
1229ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT * points[], BN_CTX * ctx) 1229ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT * points[], BN_CTX * ctx)
1230{ 1230{
1231 BN_CTX *new_ctx = NULL; 1231 BN_CTX *new_ctx = NULL;
@@ -1271,11 +1271,11 @@ ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT *
1271 1271
1272 /* 1272 /*
1273 * The array is used as a binary tree, exactly as in heapsort: 1273 * The array is used as a binary tree, exactly as in heapsort:
1274 * 1274 *
1275 * heap[1] heap[2] heap[3] heap[4] heap[5] 1275 * heap[1] heap[2] heap[3] heap[4] heap[5]
1276 * heap[6] heap[7] heap[8]heap[9] heap[10]heap[11] 1276 * heap[6] heap[7] heap[8]heap[9] heap[10]heap[11]
1277 * heap[12]heap[13] heap[14] heap[15] 1277 * heap[12]heap[13] heap[14] heap[15]
1278 * 1278 *
1279 * We put the Z's in the last line; then we set each other node to the 1279 * We put the Z's in the last line; then we set each other node to the
1280 * product of its two child-nodes (where empty or 0 entries are 1280 * product of its two child-nodes (where empty or 0 entries are
1281 * treated as ones); then we invert heap[1]; then we invert each 1281 * treated as ones); then we invert heap[1]; then we invert each
@@ -1400,13 +1400,13 @@ ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT *
1400} 1400}
1401 1401
1402 1402
1403int 1403int
1404ec_GFp_simple_field_mul(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx) 1404ec_GFp_simple_field_mul(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, const BIGNUM * b, BN_CTX * ctx)
1405{ 1405{
1406 return BN_mod_mul(r, a, b, &group->field, ctx); 1406 return BN_mod_mul(r, a, b, &group->field, ctx);
1407} 1407}
1408 1408
1409int 1409int
1410ec_GFp_simple_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, BN_CTX * ctx) 1410ec_GFp_simple_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, BN_CTX * ctx)
1411{ 1411{
1412 return BN_mod_sqr(r, a, &group->field, ctx); 1412 return BN_mod_sqr(r, a, &group->field, ctx);
@@ -1416,7 +1416,7 @@ ec_GFp_simple_field_sqr(const EC_GROUP * group, BIGNUM * r, const BIGNUM * a, BN
1416 * Apply randomization of EC point projective coordinates: 1416 * Apply randomization of EC point projective coordinates:
1417 * 1417 *
1418 * (X, Y, Z) = (lambda^2 * X, lambda^3 * Y, lambda * Z) 1418 * (X, Y, Z) = (lambda^2 * X, lambda^3 * Y, lambda * Z)
1419 * 1419 *
1420 * where lambda is in the interval [1, group->field). 1420 * where lambda is in the interval [1, group->field).
1421 */ 1421 */
1422int 1422int
@@ -1686,7 +1686,7 @@ ec_GFp_simple_mul_ct(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
1686 } 1686 }
1687 /* one final cswap to move the right value into r */ 1687 /* one final cswap to move the right value into r */
1688 EC_POINT_CSWAP(pbit, r, s, group_top, Z_is_one); 1688 EC_POINT_CSWAP(pbit, r, s, group_top, Z_is_one);
1689 1689
1690 ret = 1; 1690 ret = 1;
1691 1691
1692 err: 1692 err: