1
- /* $OpenBSD: ec_lib.c,v 1.41 2021/09/12 16:23:19 tb Exp $ */
1
+ /* $OpenBSD: ec_lib.c,v 1.42 2022/03/29 13:44:06 tb Exp $ */
2
2
/*
3
3
* Originally written by Bodo Moeller for the OpenSSL project.
4
4
*/
@@ -114,7 +114,7 @@ EC_GROUP_new(const EC_METHOD * meth)
114
114
}
115
115
116
116
117
- void
117
+ void
118
118
EC_GROUP_free (EC_GROUP * group )
119
119
{
120
120
if (!group )
@@ -135,7 +135,7 @@ EC_GROUP_free(EC_GROUP * group)
135
135
}
136
136
137
137
138
- void
138
+ void
139
139
EC_GROUP_clear_free (EC_GROUP * group )
140
140
{
141
141
if (!group )
@@ -157,7 +157,7 @@ EC_GROUP_clear_free(EC_GROUP * group)
157
157
}
158
158
159
159
160
- int
160
+ int
161
161
EC_GROUP_copy (EC_GROUP * dest , const EC_GROUP * src )
162
162
{
163
163
EC_EXTRA_DATA * d ;
@@ -247,7 +247,7 @@ EC_GROUP_method_of(const EC_GROUP *group)
247
247
}
248
248
249
249
250
- int
250
+ int
251
251
EC_METHOD_get_field_type (const EC_METHOD * meth )
252
252
{
253
253
return meth -> field_type ;
@@ -300,7 +300,7 @@ ec_guess_cofactor(EC_GROUP *group)
300
300
if (!BN_copy (q , & group -> field ))
301
301
goto err ;
302
302
}
303
-
303
+
304
304
/*
305
305
* Compute
306
306
* h = \lfloor (q + 1)/n \rceil = \lfloor (q + 1 + n/2) / n \rfloor.
@@ -328,7 +328,7 @@ ec_guess_cofactor(EC_GROUP *group)
328
328
return ret ;
329
329
}
330
330
331
- int
331
+ int
332
332
EC_GROUP_set_generator (EC_GROUP * group , const EC_POINT * generator ,
333
333
const BIGNUM * order , const BIGNUM * cofactor )
334
334
{
@@ -392,7 +392,7 @@ EC_GROUP_get0_generator(const EC_GROUP *group)
392
392
}
393
393
394
394
395
- int
395
+ int
396
396
EC_GROUP_get_order (const EC_GROUP * group , BIGNUM * order , BN_CTX * ctx )
397
397
{
398
398
if (!BN_copy (order , & group -> order ))
@@ -407,7 +407,7 @@ EC_GROUP_order_bits(const EC_GROUP *group)
407
407
return group -> meth -> group_order_bits (group );
408
408
}
409
409
410
- int
410
+ int
411
411
EC_GROUP_get_cofactor (const EC_GROUP * group , BIGNUM * cofactor , BN_CTX * ctx )
412
412
{
413
413
if (!BN_copy (cofactor , & group -> cofactor ))
@@ -417,50 +417,50 @@ EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx)
417
417
}
418
418
419
419
420
- void
420
+ void
421
421
EC_GROUP_set_curve_name (EC_GROUP * group , int nid )
422
422
{
423
423
group -> curve_name = nid ;
424
424
}
425
425
426
426
427
- int
427
+ int
428
428
EC_GROUP_get_curve_name (const EC_GROUP * group )
429
429
{
430
430
return group -> curve_name ;
431
431
}
432
432
433
433
434
- void
434
+ void
435
435
EC_GROUP_set_asn1_flag (EC_GROUP * group , int flag )
436
436
{
437
437
group -> asn1_flag = flag ;
438
438
}
439
439
440
440
441
- int
441
+ int
442
442
EC_GROUP_get_asn1_flag (const EC_GROUP * group )
443
443
{
444
444
return group -> asn1_flag ;
445
445
}
446
446
447
447
448
- void
448
+ void
449
449
EC_GROUP_set_point_conversion_form (EC_GROUP * group ,
450
450
point_conversion_form_t form )
451
451
{
452
452
group -> asn1_form = form ;
453
453
}
454
454
455
455
456
- point_conversion_form_t
456
+ point_conversion_form_t
457
457
EC_GROUP_get_point_conversion_form (const EC_GROUP * group )
458
458
{
459
459
return group -> asn1_form ;
460
460
}
461
461
462
462
463
- size_t
463
+ size_t
464
464
EC_GROUP_set_seed (EC_GROUP * group , const unsigned char * p , size_t len )
465
465
{
466
466
if (group -> seed ) {
@@ -487,7 +487,7 @@ EC_GROUP_get0_seed(const EC_GROUP * group)
487
487
}
488
488
489
489
490
- size_t
490
+ size_t
491
491
EC_GROUP_get_seed_len (const EC_GROUP * group )
492
492
{
493
493
return group -> seed_len ;
@@ -545,7 +545,7 @@ EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a,
545
545
}
546
546
#endif
547
547
548
- int
548
+ int
549
549
EC_GROUP_get_degree (const EC_GROUP * group )
550
550
{
551
551
if (group -> meth -> group_get_degree == 0 ) {
@@ -556,7 +556,7 @@ EC_GROUP_get_degree(const EC_GROUP * group)
556
556
}
557
557
558
558
559
- int
559
+ int
560
560
EC_GROUP_check_discriminant (const EC_GROUP * group , BN_CTX * ctx )
561
561
{
562
562
if (group -> meth -> group_check_discriminant == 0 ) {
@@ -567,7 +567,7 @@ EC_GROUP_check_discriminant(const EC_GROUP * group, BN_CTX * ctx)
567
567
}
568
568
569
569
570
- int
570
+ int
571
571
EC_GROUP_cmp (const EC_GROUP * a , const EC_GROUP * b , BN_CTX * ctx )
572
572
{
573
573
int r = 0 ;
@@ -660,7 +660,7 @@ ec_point_blind_coordinates(const EC_GROUP *group, EC_POINT *p, BN_CTX *ctx)
660
660
}
661
661
662
662
/* this has 'package' visibility */
663
- int
663
+ int
664
664
EC_EX_DATA_set_data (EC_EXTRA_DATA * * ex_data , void * data ,
665
665
void * (* dup_func ) (void * ),
666
666
void (* free_func ) (void * ),
@@ -716,7 +716,7 @@ EC_EX_DATA_get_data(const EC_EXTRA_DATA * ex_data,
716
716
}
717
717
718
718
/* this has 'package' visibility */
719
- void
719
+ void
720
720
EC_EX_DATA_free_data (EC_EXTRA_DATA * * ex_data ,
721
721
void * (* dup_func ) (void * ),
722
722
void (* free_func ) (void * ),
@@ -743,7 +743,7 @@ EC_EX_DATA_free_data(EC_EXTRA_DATA ** ex_data,
743
743
}
744
744
745
745
/* this has 'package' visibility */
746
- void
746
+ void
747
747
EC_EX_DATA_clear_free_data (EC_EXTRA_DATA * * ex_data ,
748
748
void * (* dup_func ) (void * ),
749
749
void (* free_func ) (void * ),
@@ -770,7 +770,7 @@ EC_EX_DATA_clear_free_data(EC_EXTRA_DATA ** ex_data,
770
770
}
771
771
772
772
/* this has 'package' visibility */
773
- void
773
+ void
774
774
EC_EX_DATA_free_all_data (EC_EXTRA_DATA * * ex_data )
775
775
{
776
776
EC_EXTRA_DATA * d ;
@@ -791,7 +791,7 @@ EC_EX_DATA_free_all_data(EC_EXTRA_DATA ** ex_data)
791
791
}
792
792
793
793
/* this has 'package' visibility */
794
- void
794
+ void
795
795
EC_EX_DATA_clear_free_all_data (EC_EXTRA_DATA * * ex_data )
796
796
{
797
797
EC_EXTRA_DATA * d ;
@@ -842,7 +842,7 @@ EC_POINT_new(const EC_GROUP * group)
842
842
}
843
843
844
844
845
- void
845
+ void
846
846
EC_POINT_free (EC_POINT * point )
847
847
{
848
848
if (!point )
@@ -854,7 +854,7 @@ EC_POINT_free(EC_POINT * point)
854
854
}
855
855
856
856
857
- void
857
+ void
858
858
EC_POINT_clear_free (EC_POINT * point )
859
859
{
860
860
if (!point )
@@ -868,7 +868,7 @@ EC_POINT_clear_free(EC_POINT * point)
868
868
}
869
869
870
870
871
- int
871
+ int
872
872
EC_POINT_copy (EC_POINT * dest , const EC_POINT * src )
873
873
{
874
874
if (dest -> meth -> point_copy == 0 ) {
@@ -913,7 +913,7 @@ EC_POINT_method_of(const EC_POINT * point)
913
913
}
914
914
915
915
916
- int
916
+ int
917
917
EC_POINT_set_to_infinity (const EC_GROUP * group , EC_POINT * point )
918
918
{
919
919
if (group -> meth -> point_set_to_infinity == 0 ) {
@@ -1041,7 +1041,7 @@ EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *poin
1041
1041
}
1042
1042
#endif
1043
1043
1044
- int
1044
+ int
1045
1045
EC_POINT_add (const EC_GROUP * group , EC_POINT * r , const EC_POINT * a ,
1046
1046
const EC_POINT * b , BN_CTX * ctx )
1047
1047
{
@@ -1057,7 +1057,7 @@ EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
1057
1057
}
1058
1058
1059
1059
1060
- int
1060
+ int
1061
1061
EC_POINT_dbl (const EC_GROUP * group , EC_POINT * r , const EC_POINT * a , BN_CTX * ctx )
1062
1062
{
1063
1063
if (group -> meth -> dbl == 0 ) {
@@ -1072,7 +1072,7 @@ EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
1072
1072
}
1073
1073
1074
1074
1075
- int
1075
+ int
1076
1076
EC_POINT_invert (const EC_GROUP * group , EC_POINT * a , BN_CTX * ctx )
1077
1077
{
1078
1078
if (group -> meth -> invert == 0 ) {
@@ -1087,7 +1087,7 @@ EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx)
1087
1087
}
1088
1088
1089
1089
1090
- int
1090
+ int
1091
1091
EC_POINT_is_at_infinity (const EC_GROUP * group , const EC_POINT * point )
1092
1092
{
1093
1093
if (group -> meth -> is_at_infinity == 0 ) {
@@ -1102,7 +1102,7 @@ EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
1102
1102
}
1103
1103
1104
1104
1105
- int
1105
+ int
1106
1106
EC_POINT_is_on_curve (const EC_GROUP * group , const EC_POINT * point , BN_CTX * ctx )
1107
1107
{
1108
1108
if (group -> meth -> is_on_curve == 0 ) {
@@ -1117,7 +1117,7 @@ EC_POINT_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX * ct
1117
1117
}
1118
1118
1119
1119
1120
- int
1120
+ int
1121
1121
EC_POINT_cmp (const EC_GROUP * group , const EC_POINT * a , const EC_POINT * b ,
1122
1122
BN_CTX * ctx )
1123
1123
{
@@ -1133,7 +1133,7 @@ EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b,
1133
1133
}
1134
1134
1135
1135
1136
- int
1136
+ int
1137
1137
EC_POINT_make_affine (const EC_GROUP * group , EC_POINT * point , BN_CTX * ctx )
1138
1138
{
1139
1139
if (group -> meth -> make_affine == 0 ) {
@@ -1148,7 +1148,7 @@ EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
1148
1148
}
1149
1149
1150
1150
1151
- int
1151
+ int
1152
1152
EC_POINTs_make_affine (const EC_GROUP * group , size_t num , EC_POINT * points [],
1153
1153
BN_CTX * ctx )
1154
1154
{
@@ -1169,7 +1169,7 @@ EC_POINTs_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[],
1169
1169
1170
1170
1171
1171
/* Functions for point multiplication */
1172
- int
1172
+ int
1173
1173
EC_POINTs_mul (const EC_GROUP * group , EC_POINT * r , const BIGNUM * scalar ,
1174
1174
size_t num , const EC_POINT * points [], const BIGNUM * scalars [], BN_CTX * ctx )
1175
1175
{
@@ -1184,22 +1184,22 @@ EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
1184
1184
ECerror (ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED );
1185
1185
return 0 ;
1186
1186
}
1187
-
1187
+
1188
1188
/* Either bP or aG + bP, this is sane. */
1189
1189
if (num == 1 && points != NULL && scalars != NULL )
1190
1190
return EC_POINT_mul (group , r , scalar , points [0 ], scalars [0 ],
1191
1191
ctx );
1192
-
1192
+
1193
1193
/* aG, this is sane */
1194
1194
if (scalar != NULL && points == NULL && scalars == NULL )
1195
1195
return EC_POINT_mul (group , r , scalar , NULL , NULL , ctx );
1196
-
1196
+
1197
1197
/* anything else is an error */
1198
1198
ECerror (ERR_R_EC_LIB );
1199
1199
return 0 ;
1200
1200
}
1201
1201
1202
- int
1202
+ int
1203
1203
EC_POINT_mul (const EC_GROUP * group , EC_POINT * r , const BIGNUM * g_scalar ,
1204
1204
const EC_POINT * point , const BIGNUM * p_scalar , BN_CTX * ctx )
1205
1205
{
@@ -1241,13 +1241,13 @@ EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *g_scalar,
1241
1241
return group -> meth -> mul_double_nonct (group , r , g_scalar ,
1242
1242
p_scalar , point , ctx );
1243
1243
}
1244
-
1244
+
1245
1245
/* Anything else is an error. */
1246
1246
ECerror (ERR_R_EC_LIB );
1247
1247
return 0 ;
1248
1248
}
1249
1249
1250
- int
1250
+ int
1251
1251
EC_GROUP_precompute_mult (EC_GROUP * group , BN_CTX * ctx )
1252
1252
{
1253
1253
if (group -> meth -> precompute_mult != 0 )
@@ -1256,7 +1256,7 @@ EC_GROUP_precompute_mult(EC_GROUP * group, BN_CTX * ctx)
1256
1256
return 1 ; /* nothing to do, so report success */
1257
1257
}
1258
1258
1259
- int
1259
+ int
1260
1260
EC_GROUP_have_precompute_mult (const EC_GROUP * group )
1261
1261
{
1262
1262
if (group -> meth -> have_precompute_mult != 0 )
@@ -1290,5 +1290,5 @@ ECParameters_dup(EC_KEY *key)
1290
1290
if ((len = i2d_ECParameters (key , & p )) > 0 )
1291
1291
k = d2i_ECParameters (NULL , (const unsigned char * * )& p , len );
1292
1292
1293
- return (k );
1293
+ return (k );
1294
1294
}
0 commit comments