Implement wolfSSL_EC_GROUP_dup

This commit is contained in:
Juliusz Sosinowicz
2020-03-30 14:14:05 +02:00
parent ea8dd31de0
commit 2529ce21b0
3 changed files with 13 additions and 0 deletions

View File

@@ -32453,6 +32453,13 @@ int wolfSSL_EC_GROUP_cmp(const WOLFSSL_EC_GROUP *a, const WOLFSSL_EC_GROUP *b,
return 1;
}
WOLFSSL_EC_GROUP *wolfSSL_EC_GROUP_dup(const WOLFSSL_EC_GROUP *src)
{
if (!src)
return NULL;
return wolfSSL_EC_GROUP_new_by_curve_name(src->curve_nid);
}
#endif /* HAVE_ECC */
#endif /* OPENSSL_EXTRA */

View File

@@ -1884,6 +1884,7 @@ static void test_wolfSSL_EC(void)
#if defined(HAVE_ECC)
BN_CTX *ctx;
EC_GROUP *group;
EC_GROUP *group2;
EC_POINT *Gxy, *new_point, *set_point;
BIGNUM *k = NULL, *Gx = NULL, *Gy = NULL, *Gz = NULL;
BIGNUM *X, *Y;
@@ -1923,6 +1924,7 @@ static void test_wolfSSL_EC(void)
AssertNotNull(ctx = BN_CTX_new());
AssertNotNull(group = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1));
AssertNotNull(group2 = EC_GROUP_dup(group));
AssertIntEQ((group_bits = EC_GROUP_order_bits(group)), 256);
AssertNotNull(Gxy = EC_POINT_new(group));
AssertNotNull(new_point = EC_POINT_new(group));
@@ -2074,6 +2076,7 @@ static void test_wolfSSL_EC(void)
EC_POINT_free(set_point);
EC_POINT_free(Gxy);
EC_GROUP_free(group);
EC_GROUP_free(group2);
BN_CTX_free(ctx);
#endif /* HAVE_ECC */
}

View File

@@ -204,6 +204,8 @@ WOLFSSL_API
int wolfSSL_EC_GROUP_cmp(const WOLFSSL_EC_GROUP *a, const WOLFSSL_EC_GROUP *b,
WOLFSSL_BN_CTX *ctx);
WOLFSSL_API
WOLFSSL_EC_GROUP *wolfSSL_EC_GROUP_dup(const WOLFSSL_EC_GROUP *src);
WOLFSSL_API
int wolfSSL_EC_GROUP_get_curve_name(const WOLFSSL_EC_GROUP *group);
WOLFSSL_API
int wolfSSL_EC_GROUP_get_degree(const WOLFSSL_EC_GROUP *group);
@@ -283,6 +285,7 @@ char* wolfSSL_EC_POINT_point2hex(const WOLFSSL_EC_GROUP* group,
#define EC_GROUP_set_asn1_flag wolfSSL_EC_GROUP_set_asn1_flag
#define EC_GROUP_new_by_curve_name wolfSSL_EC_GROUP_new_by_curve_name
#define EC_GROUP_cmp wolfSSL_EC_GROUP_cmp
#define EC_GROUP_dup wolfSSL_EC_GROUP_dup
#define EC_GROUP_get_curve_name wolfSSL_EC_GROUP_get_curve_name
#define EC_GROUP_get_degree wolfSSL_EC_GROUP_get_degree
#define EC_GROUP_get_order wolfSSL_EC_GROUP_get_order