summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/ec/ec2_smpl.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/lib/libcrypto/ec/ec2_smpl.c b/src/lib/libcrypto/ec/ec2_smpl.c
index 3ab7a1d46a..8bf5895e8a 100644
--- a/src/lib/libcrypto/ec/ec2_smpl.c
+++ b/src/lib/libcrypto/ec/ec2_smpl.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec2_smpl.c,v 1.28 2022/11/26 16:08:52 tb Exp $ */ 1/* $OpenBSD: ec2_smpl.c,v 1.29 2023/03/07 05:35:13 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. 3 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4 * 4 *
@@ -123,7 +123,8 @@ EC_GF2m_simple_method(void)
123} 123}
124 124
125 125
126/* Initialize a GF(2^m)-based EC_GROUP structure. 126/*
127 * Initialize a GF(2^m)-based EC_GROUP structure.
127 * Note that all other members are handled by EC_GROUP_new. 128 * Note that all other members are handled by EC_GROUP_new.
128 */ 129 */
129int 130int
@@ -136,7 +137,8 @@ ec_GF2m_simple_group_init(EC_GROUP *group)
136} 137}
137 138
138 139
139/* Free a GF(2^m)-based EC_GROUP structure. 140/*
141 * Free a GF(2^m)-based EC_GROUP structure.
140 * Note that all other members are handled by EC_GROUP_free. 142 * Note that all other members are handled by EC_GROUP_free.
141 */ 143 */
142void 144void
@@ -148,7 +150,8 @@ ec_GF2m_simple_group_finish(EC_GROUP *group)
148} 150}
149 151
150 152
151/* Clear and free a GF(2^m)-based EC_GROUP structure. 153/*
154 * Clear and free a GF(2^m)-based EC_GROUP structure.
152 * Note that all other members are handled by EC_GROUP_clear_free. 155 * Note that all other members are handled by EC_GROUP_clear_free.
153 */ 156 */
154void 157void
@@ -166,7 +169,8 @@ ec_GF2m_simple_group_clear_finish(EC_GROUP *group)
166} 169}
167 170
168 171
169/* Copy a GF(2^m)-based EC_GROUP structure. 172/*
173 * Copy a GF(2^m)-based EC_GROUP structure.
170 * Note that all other members are handled by EC_GROUP_copy. 174 * Note that all other members are handled by EC_GROUP_copy.
171 */ 175 */
172int 176int
@@ -235,7 +239,8 @@ ec_GF2m_simple_group_set_curve(EC_GROUP *group,
235} 239}
236 240
237 241
238/* Get the curve parameters of an EC_GROUP structure. 242/*
243 * Get the curve parameters of an EC_GROUP structure.
239 * If p, a, or b are NULL then there values will not be set but the method will return with success. 244 * If p, a, or b are NULL then there values will not be set but the method will return with success.
240 */ 245 */
241int 246int
@@ -271,7 +276,8 @@ ec_GF2m_simple_group_get_degree(const EC_GROUP *group)
271} 276}
272 277
273 278
274/* Checks the discriminant of the curve. 279/*
280 * Checks the discriminant of the curve.
275 * y^2 + x*y = x^3 + a*x^2 + b is an elliptic curve <=> b != 0 (mod p) 281 * y^2 + x*y = x^3 + a*x^2 + b is an elliptic curve <=> b != 0 (mod p)
276 */ 282 */
277int 283int
@@ -360,7 +366,8 @@ ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src)
360} 366}
361 367
362 368
363/* Set an EC_POINT to the point at infinity. 369/*
370 * Set an EC_POINT to the point at infinity.
364 * A point at infinity is represented by having Z=0. 371 * A point at infinity is represented by having Z=0.
365 */ 372 */
366int 373int
@@ -372,7 +379,8 @@ ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
372} 379}
373 380
374 381
375/* Set the coordinates of an EC_POINT using affine coordinates. 382/*
383 * Set the coordinates of an EC_POINT using affine coordinates.
376 * Note that the simple implementation only uses affine coordinates. 384 * Note that the simple implementation only uses affine coordinates.
377 */ 385 */
378int 386int
@@ -401,7 +409,8 @@ ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *poi
401} 409}
402 410
403 411
404/* Gets the affine coordinates of an EC_POINT. 412/*
413 * Gets the affine coordinates of an EC_POINT.
405 * Note that the simple implementation only uses affine coordinates. 414 * Note that the simple implementation only uses affine coordinates.
406 */ 415 */
407int 416int
@@ -434,7 +443,8 @@ ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group,
434 return ret; 443 return ret;
435} 444}
436 445
437/* Computes a + b and stores the result in r. r could be a or b, a could be b. 446/*
447 * Computes a + b and stores the result in r. r could be a or b, a could be b.
438 * Uses algorithm A.10.2 of IEEE P1363. 448 * Uses algorithm A.10.2 of IEEE P1363.
439 */ 449 */
440int 450int
@@ -554,7 +564,8 @@ ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a,
554} 564}
555 565
556 566
557/* Computes 2 * a and stores the result in r. r could be a. 567/*
568 * Computes 2 * a and stores the result in r. r could be a.
558 * Uses algorithm A.10.2 of IEEE P1363. 569 * Uses algorithm A.10.2 of IEEE P1363.
559 */ 570 */
560int 571int
@@ -585,7 +596,8 @@ ec_GF2m_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
585} 596}
586 597
587 598
588/* Determines whether the given EC_POINT is an actual point on the curve defined 599/*
600 * Determines whether the given EC_POINT is an actual point on the curve defined
589 * in the EC_GROUP. A point is valid if it satisfies the Weierstrass equation: 601 * in the EC_GROUP. A point is valid if it satisfies the Weierstrass equation:
590 * y^2 + x*y = x^3 + a*x^2 + b. 602 * y^2 + x*y = x^3 + a*x^2 + b.
591 */ 603 */
@@ -647,7 +659,8 @@ ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX
647} 659}
648 660
649 661
650/* Indicates whether two points are equal. 662/*
663 * Indicates whether two points are equal.
651 * Return values: 664 * Return values:
652 * -1 error 665 * -1 error
653 * 0 equal (in affine coordinates) 666 * 0 equal (in affine coordinates)