Skip to content

Commit fe85ca6

Browse files
committed
Add test for EC_POINT_dup
1 parent fc0ec06 commit fe85ca6

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tests/api/test_ossl_ec.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ int test_wolfSSL_EC_POINT(void)
314314
EC_POINT* set_point = NULL;
315315
EC_POINT* get_point = NULL;
316316
EC_POINT* infinity = NULL;
317+
EC_POINT* dup_point = NULL;
317318
BIGNUM* k = NULL;
318319
BIGNUM* Gx = NULL;
319320
BIGNUM* Gy = NULL;
@@ -507,6 +508,12 @@ int test_wolfSSL_EC_POINT(void)
507508
ExpectIntEQ(EC_POINT_copy(new_point, NULL), 0);
508509
ExpectIntEQ(EC_POINT_copy(new_point, set_point), 1);
509510

511+
/* Test duplicating */
512+
ExpectNull(EC_POINT_dup(NULL, group));
513+
ExpectNull(EC_POINT_dup(set_point, NULL));
514+
ExpectNotNull(dup_point = EC_POINT_dup(set_point, group));
515+
ExpectIntEQ(EC_POINT_cmp(group, dup_point, set_point, ctx), 0);
516+
510517
/* Test inverting */
511518
ExpectIntEQ(EC_POINT_invert(NULL, NULL, ctx), 0);
512519
ExpectIntEQ(EC_POINT_invert(NULL, new_point, ctx), 0);
@@ -526,6 +533,12 @@ int test_wolfSSL_EC_POINT(void)
526533
ExpectIntEQ(EC_POINT_add(group, orig_point, orig_point, new_point,
527534
NULL), 1);
528535
ExpectIntEQ(EC_POINT_cmp(group, orig_point, set_point, NULL), 0);
536+
/* dup_point equals set_point so let's test with that too */
537+
ExpectIntEQ(EC_POINT_add(group, orig_point, dup_point, dup_point, NULL),
538+
1);
539+
ExpectIntEQ(EC_POINT_add(group, orig_point, orig_point, new_point,
540+
NULL), 1);
541+
ExpectIntEQ(EC_POINT_cmp(group, orig_point, set_point, NULL), 0);
529542
EC_POINT_free(orig_point);
530543
}
531544
#endif
@@ -769,6 +782,7 @@ int test_wolfSSL_EC_POINT(void)
769782
BN_free(k);
770783
BN_free(set_point_bn);
771784
EC_POINT_free(infinity);
785+
EC_POINT_free(dup_point);
772786
EC_POINT_free(new_point);
773787
EC_POINT_free(set_point);
774788
EC_POINT_clear_free(Gxy);

0 commit comments

Comments
 (0)