From 9cc570d4c419e2ca97e2173dc14c484195502dd4 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Mon, 30 Jul 2018 16:40:18 +0100 Subject: [PATCH] Use the new non-curve type specific EC functions internally Fixes #6646 Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/6815) --- apps/ecparam.c | 2 +- crypto/ec/ec2_oct.c | 11 ++-- crypto/ec/ec2_smpl.c | 12 ++-- crypto/ec/ec_asn1.c | 22 ++----- crypto/ec/ec_curve.c | 2 +- crypto/ec/ec_cvt.c | 4 +- crypto/ec/ec_key.c | 29 ++------- crypto/ec/ec_lcl.h | 9 ++- crypto/ec/ecdh_ossl.c | 17 +---- crypto/ec/ecdsa_ossl.c | 39 +++--------- crypto/ec/eck_prn.c | 17 ++--- crypto/ec/ecp_nistp224.c | 2 +- crypto/ec/ecp_nistp256.c | 2 +- crypto/ec/ecp_nistp521.c | 2 +- crypto/ec/ecp_oct.c | 11 ++-- crypto/ec/ecp_smpl.c | 4 +- crypto/sm2/sm2_crypt.c | 12 ++-- crypto/sm2/sm2_sign.c | 4 +- crypto/sm2/sm2_za.c | 10 +-- test/ecstresstest.c | 11 ++-- test/ectest.c | 131 ++++++++++++++++++--------------------- test/sm2_internal_test.c | 4 +- 22 files changed, 133 insertions(+), 224 deletions(-) diff --git a/apps/ecparam.c b/apps/ecparam.c index 2290242310..917f1a86b2 100644 --- a/apps/ecparam.c +++ b/apps/ecparam.c @@ -299,7 +299,7 @@ int ecparam_main(int argc, char **argv) goto end; } - if (!EC_GROUP_get_curve_GFp(group, ec_p, ec_a, ec_b, NULL)) + if (!EC_GROUP_get_curve(group, ec_p, ec_a, ec_b, NULL)) goto end; if ((point = EC_GROUP_get0_generator(group)) == NULL) diff --git a/crypto/ec/ec2_oct.c b/crypto/ec/ec2_oct.c index 24c32ae623..d515dab811 100644 --- a/crypto/ec/ec2_oct.c +++ b/crypto/ec/ec2_oct.c @@ -94,7 +94,7 @@ int ec_GF2m_simple_set_compressed_coordinates(const EC_GROUP *group, } } - if (!EC_POINT_set_affine_coordinates_GF2m(group, point, x, y, ctx)) + if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx)) goto err; ret = 1; @@ -166,7 +166,7 @@ size_t ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, if (yxi == NULL) goto err; - if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) + if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)) goto err; buf[0] = form; @@ -301,8 +301,7 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, } if (form == POINT_CONVERSION_COMPRESSED) { - if (!EC_POINT_set_compressed_coordinates_GF2m - (group, point, x, y_bit, ctx)) + if (!EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx)) goto err; } else { if (!BN_bin2bn(buf + 1 + field_len, field_len, y)) @@ -321,10 +320,10 @@ int ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, } /* - * EC_POINT_set_affine_coordinates_GF2m is responsible for checking that + * EC_POINT_set_affine_coordinates is responsible for checking that * the point is on the curve. */ - if (!EC_POINT_set_affine_coordinates_GF2m(group, point, x, y, ctx)) + if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx)) goto err; } diff --git a/crypto/ec/ec2_smpl.c b/crypto/ec/ec2_smpl.c index 9ce332b32d..87f7ce5691 100644 --- a/crypto/ec/ec2_smpl.c +++ b/crypto/ec/ec2_smpl.c @@ -390,7 +390,7 @@ int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, if (!BN_copy(y0, a->Y)) goto err; } else { - if (!EC_POINT_get_affine_coordinates_GF2m(group, a, x0, y0, ctx)) + if (!EC_POINT_get_affine_coordinates(group, a, x0, y0, ctx)) goto err; } if (b->Z_is_one) { @@ -399,7 +399,7 @@ int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, if (!BN_copy(y1, b->Y)) goto err; } else { - if (!EC_POINT_get_affine_coordinates_GF2m(group, b, x1, y1, ctx)) + if (!EC_POINT_get_affine_coordinates(group, b, x1, y1, ctx)) goto err; } @@ -447,7 +447,7 @@ int ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, if (!BN_GF2m_add(y2, y2, y1)) goto err; - if (!EC_POINT_set_affine_coordinates_GF2m(group, r, x2, y2, ctx)) + if (!EC_POINT_set_affine_coordinates(group, r, x2, y2, ctx)) goto err; ret = 1; @@ -590,9 +590,9 @@ int ec_GF2m_simple_cmp(const EC_GROUP *group, const EC_POINT *a, if (bY == NULL) goto err; - if (!EC_POINT_get_affine_coordinates_GF2m(group, a, aX, aY, ctx)) + if (!EC_POINT_get_affine_coordinates(group, a, aX, aY, ctx)) goto err; - if (!EC_POINT_get_affine_coordinates_GF2m(group, b, bX, bY, ctx)) + if (!EC_POINT_get_affine_coordinates(group, b, bX, bY, ctx)) goto err; ret = ((BN_cmp(aX, bX) == 0) && BN_cmp(aY, bY) == 0) ? 0 : 1; @@ -625,7 +625,7 @@ int ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point, if (y == NULL) goto err; - if (!EC_POINT_get_affine_coordinates_GF2m(group, point, x, y, ctx)) + if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)) goto err; if (!BN_copy(point->X, x)) goto err; diff --git a/crypto/ec/ec_asn1.c b/crypto/ec/ec_asn1.c index cdc5d3895d..13c56a621d 100644 --- a/crypto/ec/ec_asn1.c +++ b/crypto/ec/ec_asn1.c @@ -266,7 +266,7 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) goto err; } /* the parameters are specified by the prime number p */ - if (!EC_GROUP_get_curve_GFp(group, tmp, NULL, NULL, NULL)) { + if (!EC_GROUP_get_curve(group, tmp, NULL, NULL, NULL)) { ECerr(EC_F_EC_ASN1_GROUP2FIELDID, ERR_R_EC_LIB); goto err; } @@ -365,7 +365,7 @@ static int ec_asn1_group2fieldid(const EC_GROUP *group, X9_62_FIELDID *field) static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve) { - int ok = 0, nid; + int ok = 0; BIGNUM *tmp_1 = NULL, *tmp_2 = NULL; unsigned char *a_buf = NULL, *b_buf = NULL; size_t len; @@ -378,24 +378,12 @@ static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve) goto err; } - nid = EC_METHOD_get_field_type(EC_GROUP_method_of(group)); - /* get a and b */ - if (nid == NID_X9_62_prime_field) { - if (!EC_GROUP_get_curve_GFp(group, NULL, tmp_1, tmp_2, NULL)) { - ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_EC_LIB); - goto err; - } + if (!EC_GROUP_get_curve(group, NULL, tmp_1, tmp_2, NULL)) { + ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_EC_LIB); + goto err; } -#ifndef OPENSSL_NO_EC2M - else { /* nid == NID_X9_62_characteristic_two_field */ - if (!EC_GROUP_get_curve_GF2m(group, NULL, tmp_1, tmp_2, NULL)) { - ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_EC_LIB); - goto err; - } - } -#endif /* * Per SEC 1, the curve coefficients must be padded up to size. See C.2's * definition of Curve, C.1's definition of FieldElement, and 2.3.5's diff --git a/crypto/ec/ec_curve.c b/crypto/ec/ec_curve.c index 618ec04c23..bb1ce196d0 100644 --- a/crypto/ec/ec_curve.c +++ b/crypto/ec/ec_curve.c @@ -3078,7 +3078,7 @@ static EC_GROUP *ec_group_new_from_data(const ec_list_element curve) ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_BN_LIB); goto err; } - if (!EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx)) { + if (!EC_POINT_set_affine_coordinates(group, P, x, y, ctx)) { ECerr(EC_F_EC_GROUP_NEW_FROM_DATA, ERR_R_EC_LIB); goto err; } diff --git a/crypto/ec/ec_cvt.c b/crypto/ec/ec_cvt.c index 13218237de..7f8bc1c163 100644 --- a/crypto/ec/ec_cvt.c +++ b/crypto/ec/ec_cvt.c @@ -51,7 +51,7 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, if (ret == NULL) return NULL; - if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx)) { + if (!EC_GROUP_set_curve(ret, p, a, b, ctx)) { EC_GROUP_clear_free(ret); return NULL; } @@ -72,7 +72,7 @@ EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, if (ret == NULL) return NULL; - if (!EC_GROUP_set_curve_GF2m(ret, p, a, b, ctx)) { + if (!EC_GROUP_set_curve(ret, p, a, b, ctx)) { EC_GROUP_clear_free(ret); return NULL; } diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index c841236ea9..ec10b7e4a2 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -341,9 +341,6 @@ int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, BIGNUM *tx, *ty; EC_POINT *point = NULL; int ok = 0; -#ifndef OPENSSL_NO_EC2M - int tmp_nid, is_char_two = 0; -#endif if (key == NULL || key->group == NULL || x == NULL || y == NULL) { ECerr(EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES, @@ -365,29 +362,11 @@ int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, if (ty == NULL) goto err; -#ifndef OPENSSL_NO_EC2M - tmp_nid = EC_METHOD_get_field_type(EC_GROUP_method_of(key->group)); - - if (tmp_nid == NID_X9_62_characteristic_two_field) - is_char_two = 1; + if (!EC_POINT_set_affine_coordinates(key->group, point, x, y, ctx)) + goto err; + if (!EC_POINT_get_affine_coordinates(key->group, point, tx, ty, ctx)) + goto err; - if (is_char_two) { - if (!EC_POINT_set_affine_coordinates_GF2m(key->group, point, - x, y, ctx)) - goto err; - if (!EC_POINT_get_affine_coordinates_GF2m(key->group, point, - tx, ty, ctx)) - goto err; - } else -#endif - { - if (!EC_POINT_set_affine_coordinates_GFp(key->group, point, - x, y, ctx)) - goto err; - if (!EC_POINT_get_affine_coordinates_GFp(key->group, point, - tx, ty, ctx)) - goto err; - } /* * Check if retrieved coordinates match originals and are less than field * order: if not values are out of range. diff --git a/crypto/ec/ec_lcl.h b/crypto/ec/ec_lcl.h index c706a8457c..e055ddab1c 100644 --- a/crypto/ec/ec_lcl.h +++ b/crypto/ec/ec_lcl.h @@ -50,8 +50,7 @@ struct ec_method_st { void (*group_finish) (EC_GROUP *); void (*group_clear_finish) (EC_GROUP *); int (*group_copy) (EC_GROUP *, const EC_GROUP *); - /* used by EC_GROUP_set_curve_GFp, EC_GROUP_get_curve_GFp, */ - /* EC_GROUP_set_curve_GF2m, and EC_GROUP_get_curve_GF2m: */ + /* used by EC_GROUP_set_curve, EC_GROUP_get_curve: */ int (*group_set_curve) (EC_GROUP *, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *); int (*group_get_curve) (const EC_GROUP *, BIGNUM *p, BIGNUM *a, BIGNUM *b, @@ -73,9 +72,9 @@ struct ec_method_st { * used by EC_POINT_set_to_infinity, * EC_POINT_set_Jprojective_coordinates_GFp, * EC_POINT_get_Jprojective_coordinates_GFp, - * EC_POINT_set_affine_coordinates_GFp, ..._GF2m, - * EC_POINT_get_affine_coordinates_GFp, ..._GF2m, - * EC_POINT_set_compressed_coordinates_GFp, ..._GF2m: + * EC_POINT_set_affine_coordinates, + * EC_POINT_get_affine_coordinates, + * EC_POINT_set_compressed_coordinates: */ int (*point_set_to_infinity) (const EC_GROUP *, EC_POINT *); int (*point_set_Jprojective_coordinates_GFp) (const EC_GROUP *, diff --git a/crypto/ec/ecdh_ossl.c b/crypto/ec/ecdh_ossl.c index 1c5db2212c..bd93793a18 100644 --- a/crypto/ec/ecdh_ossl.c +++ b/crypto/ec/ecdh_ossl.c @@ -83,21 +83,10 @@ int ecdh_simple_compute_key(unsigned char **pout, size_t *poutlen, goto err; } - if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == - NID_X9_62_prime_field) { - if (!EC_POINT_get_affine_coordinates_GFp(group, tmp, x, NULL, ctx)) { - ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, EC_R_POINT_ARITHMETIC_FAILURE); - goto err; - } - } -#ifndef OPENSSL_NO_EC2M - else { - if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, NULL, ctx)) { - ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, EC_R_POINT_ARITHMETIC_FAILURE); - goto err; - } + if (!EC_POINT_get_affine_coordinates(group, tmp, x, NULL, ctx)) { + ECerr(EC_F_ECDH_SIMPLE_COMPUTE_KEY, EC_R_POINT_ARITHMETIC_FAILURE); + goto err; } -#endif buflen = (EC_GROUP_get_degree(group) + 7) / 8; len = BN_num_bytes(x); diff --git a/crypto/ec/ecdsa_ossl.c b/crypto/ec/ecdsa_ossl.c index ad7a6f7525..e35c7600d8 100644 --- a/crypto/ec/ecdsa_ossl.c +++ b/crypto/ec/ecdsa_ossl.c @@ -104,23 +104,12 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB); goto err; } - if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == - NID_X9_62_prime_field) { - if (!EC_POINT_get_affine_coordinates_GFp(group, tmp_point, X, - NULL, ctx)) { - ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB); - goto err; - } - } -#ifndef OPENSSL_NO_EC2M - else { /* NID_X9_62_characteristic_two_field */ - if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp_point, X, - NULL, ctx)) { - ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB); - goto err; - } + + if (!EC_POINT_get_affine_coordinates(group, tmp_point, X, NULL, ctx)) { + ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB); + goto err; } -#endif + if (!BN_nnmod(r, X, order, ctx)) { ECerr(EC_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); goto err; @@ -408,22 +397,12 @@ int ossl_ecdsa_verify_sig(const unsigned char *dgst, int dgst_len, ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB); goto err; } - if (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == - NID_X9_62_prime_field) { - if (!EC_POINT_get_affine_coordinates_GFp(group, point, X, NULL, ctx)) { - ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB); - goto err; - } - } -#ifndef OPENSSL_NO_EC2M - else { /* NID_X9_62_characteristic_two_field */ - if (!EC_POINT_get_affine_coordinates_GF2m(group, point, X, NULL, ctx)) { - ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB); - goto err; - } + if (!EC_POINT_get_affine_coordinates(group, point, X, NULL, ctx)) { + ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_EC_LIB); + goto err; } -#endif + if (!BN_nnmod(u1, X, order, ctx)) { ECerr(EC_F_OSSL_ECDSA_VERIFY_SIG, ERR_R_BN_LIB); goto err; diff --git a/crypto/ec/eck_prn.c b/crypto/ec/eck_prn.c index 2e501b2d05..cde3090dab 100644 --- a/crypto/ec/eck_prn.c +++ b/crypto/ec/eck_prn.c @@ -125,19 +125,10 @@ int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off) reason = ERR_R_MALLOC_FAILURE; goto err; } -#ifndef OPENSSL_NO_EC2M - if (is_char_two) { - if (!EC_GROUP_get_curve_GF2m(x, p, a, b, ctx)) { - reason = ERR_R_EC_LIB; - goto err; - } - } else /* prime field */ -#endif - { - if (!EC_GROUP_get_curve_GFp(x, p, a, b, ctx)) { - reason = ERR_R_EC_LIB; - goto err; - } + + if (!EC_GROUP_get_curve(x, p, a, b, ctx)) { + reason = ERR_R_EC_LIB; + goto err; } if ((point = EC_GROUP_get0_generator(x)) == NULL) { diff --git a/crypto/ec/ecp_nistp224.c b/crypto/ec/ecp_nistp224.c index ecae5688d0..555bf307dd 100644 --- a/crypto/ec/ecp_nistp224.c +++ b/crypto/ec/ecp_nistp224.c @@ -1608,7 +1608,7 @@ int ec_GFp_nistp224_precompute_mult(EC_GROUP *group, BN_CTX *ctx) goto err; BN_bin2bn(nistp224_curve_params[3], sizeof(felem_bytearray), x); BN_bin2bn(nistp224_curve_params[4], sizeof(felem_bytearray), y); - if (!EC_POINT_set_affine_coordinates_GFp(group, generator, x, y, ctx)) + if (!EC_POINT_set_affine_coordinates(group, generator, x, y, ctx)) goto err; if ((pre = nistp224_pre_comp_new()) == NULL) goto err; diff --git a/crypto/ec/ecp_nistp256.c b/crypto/ec/ecp_nistp256.c index 22f172be74..c87a5e548d 100644 --- a/crypto/ec/ecp_nistp256.c +++ b/crypto/ec/ecp_nistp256.c @@ -2238,7 +2238,7 @@ int ec_GFp_nistp256_precompute_mult(EC_GROUP *group, BN_CTX *ctx) goto err; BN_bin2bn(nistp256_curve_params[3], sizeof(felem_bytearray), x); BN_bin2bn(nistp256_curve_params[4], sizeof(felem_bytearray), y); - if (!EC_POINT_set_affine_coordinates_GFp(group, generator, x, y, ctx)) + if (!EC_POINT_set_affine_coordinates(group, generator, x, y, ctx)) goto err; if ((pre = nistp256_pre_comp_new()) == NULL) goto err; diff --git a/crypto/ec/ecp_nistp521.c b/crypto/ec/ecp_nistp521.c index 06945b5f6b..14f2feeb69 100644 --- a/crypto/ec/ecp_nistp521.c +++ b/crypto/ec/ecp_nistp521.c @@ -2071,7 +2071,7 @@ int ec_GFp_nistp521_precompute_mult(EC_GROUP *group, BN_CTX *ctx) goto err; BN_bin2bn(nistp521_curve_params[3], sizeof(felem_bytearray), x); BN_bin2bn(nistp521_curve_params[4], sizeof(felem_bytearray), y); - if (!EC_POINT_set_affine_coordinates_GFp(group, generator, x, y, ctx)) + if (!EC_POINT_set_affine_coordinates(group, generator, x, y, ctx)) goto err; if ((pre = nistp521_pre_comp_new()) == NULL) goto err; diff --git a/crypto/ec/ecp_oct.c b/crypto/ec/ecp_oct.c index a5010bcf52..2be3c865a0 100644 --- a/crypto/ec/ecp_oct.c +++ b/crypto/ec/ecp_oct.c @@ -140,7 +140,7 @@ int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group, goto err; } - if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) + if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx)) goto err; ret = 1; @@ -206,7 +206,7 @@ size_t ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, if (y == NULL) goto err; - if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) + if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)) goto err; if ((form == POINT_CONVERSION_COMPRESSED @@ -333,8 +333,7 @@ int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point, } if (form == POINT_CONVERSION_COMPRESSED) { - if (!EC_POINT_set_compressed_coordinates_GFp - (group, point, x, y_bit, ctx)) + if (!EC_POINT_set_compressed_coordinates(group, point, x, y_bit, ctx)) goto err; } else { if (!BN_bin2bn(buf + 1 + field_len, field_len, y)) @@ -351,10 +350,10 @@ int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point, } /* - * EC_POINT_set_affine_coordinates_GFp is responsible for checking that + * EC_POINT_set_affine_coordinates is responsible for checking that * the point is on the curve. */ - if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) + if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx)) goto err; } diff --git a/crypto/ec/ecp_smpl.c b/crypto/ec/ecp_smpl.c index 18d16dd4f5..7ac519ca03 100644 --- a/crypto/ec/ecp_smpl.c +++ b/crypto/ec/ecp_smpl.c @@ -1181,9 +1181,9 @@ int ec_GFp_simple_make_affine(const EC_GROUP *group, EC_POINT *point, if (y == NULL) goto err; - if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) + if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)) goto err; - if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) + if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx)) goto err; if (!point->Z_is_one) { ECerr(EC_F_EC_GFP_SIMPLE_MAKE_AFFINE, ERR_R_INTERNAL_ERROR); diff --git a/crypto/sm2/sm2_crypt.c b/crypto/sm2/sm2_crypt.c index d6f9c81d8c..9e7887320c 100644 --- a/crypto/sm2/sm2_crypt.c +++ b/crypto/sm2/sm2_crypt.c @@ -48,7 +48,7 @@ static size_t ec_field_size(const EC_GROUP *group) if (p == NULL || a == NULL || b == NULL) goto done; - if (!EC_GROUP_get_curve_GFp(group, p, a, b, NULL)) + if (!EC_GROUP_get_curve(group, p, a, b, NULL)) goto done; field_size = (BN_num_bits(p) + 7) / 8; @@ -176,9 +176,9 @@ int sm2_encrypt(const EC_KEY *key, } if (!EC_POINT_mul(group, kG, k, NULL, NULL, ctx) - || !EC_POINT_get_affine_coordinates_GFp(group, kG, x1, y1, ctx) + || !EC_POINT_get_affine_coordinates(group, kG, x1, y1, ctx) || !EC_POINT_mul(group, kP, NULL, P, k, ctx) - || !EC_POINT_get_affine_coordinates_GFp(group, kP, x2, y2, ctx)) { + || !EC_POINT_get_affine_coordinates(group, kP, x2, y2, ctx)) { SM2err(SM2_F_SM2_ENCRYPT, ERR_R_EC_LIB); goto done; } @@ -326,11 +326,11 @@ int sm2_decrypt(const EC_KEY *key, goto done; } - if (!EC_POINT_set_affine_coordinates_GFp(group, C1, sm2_ctext->C1x, - sm2_ctext->C1y, ctx) + if (!EC_POINT_set_affine_coordinates(group, C1, sm2_ctext->C1x, + sm2_ctext->C1y, ctx) || !EC_POINT_mul(group, C1, NULL, C1, EC_KEY_get0_private_key(key), ctx) - || !EC_POINT_get_affine_coordinates_GFp(group, C1, x2, y2, ctx)) { + || !EC_POINT_get_affine_coordinates(group, C1, x2, y2, ctx)) { SM2err(SM2_F_SM2_DECRYPT, ERR_R_EC_LIB); goto done; } diff --git a/crypto/sm2/sm2_sign.c b/crypto/sm2/sm2_sign.c index 1244c05ea8..f1185c1337 100644 --- a/crypto/sm2/sm2_sign.c +++ b/crypto/sm2/sm2_sign.c @@ -115,7 +115,7 @@ static ECDSA_SIG *sm2_sig_gen(const EC_KEY *key, const BIGNUM *e) } if (!EC_POINT_mul(group, kG, k, NULL, NULL, ctx) - || !EC_POINT_get_affine_coordinates_GFp(group, kG, x1, NULL, + || !EC_POINT_get_affine_coordinates(group, kG, x1, NULL, ctx) || !BN_mod_add(r, e, x1, order, ctx)) { SM2err(SM2_F_SM2_SIG_GEN, ERR_R_INTERNAL_ERROR); @@ -224,7 +224,7 @@ static int sm2_sig_verify(const EC_KEY *key, const ECDSA_SIG *sig, } if (!EC_POINT_mul(group, pt, s, EC_KEY_get0_public_key(key), t, ctx) - || !EC_POINT_get_affine_coordinates_GFp(group, pt, x1, NULL, ctx)) { + || !EC_POINT_get_affine_coordinates(group, pt, x1, NULL, ctx)) { SM2err(SM2_F_SM2_SIG_VERIFY, ERR_R_EC_LIB); goto done; } diff --git a/crypto/sm2/sm2_za.c b/crypto/sm2/sm2_za.c index 8f45082db4..320bee1e18 100644 --- a/crypto/sm2/sm2_za.c +++ b/crypto/sm2/sm2_za.c @@ -87,7 +87,7 @@ int sm2_compute_userid_digest(uint8_t *out, goto done; } - if (!EC_GROUP_get_curve_GFp(group, p, a, b, ctx)) { + if (!EC_GROUP_get_curve(group, p, a, b, ctx)) { SM2err(SM2_F_SM2_COMPUTE_USERID_DIGEST, ERR_R_EC_LIB); goto done; } @@ -103,16 +103,16 @@ int sm2_compute_userid_digest(uint8_t *out, || !EVP_DigestUpdate(hash, buf, p_bytes) || BN_bn2binpad(b, buf, p_bytes) < 0 || !EVP_DigestUpdate(hash, buf, p_bytes) - || !EC_POINT_get_affine_coordinates_GFp(group, + || !EC_POINT_get_affine_coordinates(group, EC_GROUP_get0_generator(group), xG, yG, ctx) || BN_bn2binpad(xG, buf, p_bytes) < 0 || !EVP_DigestUpdate(hash, buf, p_bytes) || BN_bn2binpad(yG, buf, p_bytes) < 0 || !EVP_DigestUpdate(hash, buf, p_bytes) - || !EC_POINT_get_affine_coordinates_GFp(group, - EC_KEY_get0_public_key(key), - xA, yA, ctx) + || !EC_POINT_get_affine_coordinates(group, + EC_KEY_get0_public_key(key), + xA, yA, ctx) || BN_bn2binpad(xA, buf, p_bytes) < 0 || !EVP_DigestUpdate(hash, buf, p_bytes) || BN_bn2binpad(yA, buf, p_bytes) < 0 diff --git a/test/ecstresstest.c b/test/ecstresstest.c index 3c6d2d5a59..fce64e6bb5 100644 --- a/test/ecstresstest.c +++ b/test/ecstresstest.c @@ -45,16 +45,15 @@ static BIGNUM *walk_curve(const EC_GROUP *group, EC_POINT *point, int64_t num) int64_t i; if (!TEST_ptr(scalar = BN_new()) - || !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, point, - scalar, - NULL, NULL))) + || !TEST_true(EC_POINT_get_affine_coordinates(group, point, scalar, + NULL, NULL))) goto err; for (i = 0; i < num; i++) { if (!TEST_true(EC_POINT_mul(group, point, NULL, point, scalar, NULL)) - || !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, point, - scalar, - NULL, NULL))) + || !TEST_true(EC_POINT_get_affine_coordinates(group, point, + scalar, + NULL, NULL))) goto err; } return scalar; diff --git a/test/ectest.c b/test/ectest.c index 2945cd73b3..2703cb4a34 100644 --- a/test/ectest.c +++ b/test/ectest.c @@ -169,7 +169,7 @@ static int prime_field_tests(void) * that the library gets to choose the EC_METHOD */ || !TEST_ptr(group = EC_GROUP_new(EC_GFp_mont_method())) - || !TEST_true(EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) + || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx)) || !TEST_ptr(tmp = EC_GROUP_new(EC_GROUP_method_of(group))) || !TEST_true(EC_GROUP_copy(tmp, group))) goto err; @@ -177,7 +177,7 @@ static int prime_field_tests(void) group = tmp; tmp = NULL; - if (!TEST_true(EC_GROUP_get_curve_GFp(group, p, a, b, ctx))) + if (!TEST_true(EC_GROUP_get_curve(group, p, a, b, ctx))) goto err; TEST_info("Curve defined by Weierstrass equation"); @@ -200,13 +200,11 @@ static int prime_field_tests(void) || !TEST_ptr(z = BN_new()) || !TEST_ptr(yplusone = BN_new()) || !TEST_true(BN_hex2bn(&x, "D")) - || !TEST_true(EC_POINT_set_compressed_coordinates_GFp(group, Q, x, 1, - ctx))) + || !TEST_true(EC_POINT_set_compressed_coordinates(group, Q, x, 1, ctx))) goto err; if (!TEST_int_gt(EC_POINT_is_on_curve(group, Q, ctx), 0)) { - if (!TEST_true(EC_POINT_get_affine_coordinates_GFp(group, Q, x, y, - ctx))) + if (!TEST_true(EC_POINT_get_affine_coordinates(group, Q, x, y, ctx))) goto err; TEST_info("Point is not on curve"); test_output_bignum("x", x); @@ -223,8 +221,8 @@ static int prime_field_tests(void) if (EC_POINT_is_at_infinity(group, P)) { TEST_note(" point at infinity"); } else { - if (!TEST_true(EC_POINT_get_affine_coordinates_GFp(group, P, x, y, - ctx))) + if (!TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, + ctx))) goto err; test_output_bignum("x", x); @@ -293,7 +291,7 @@ static int prime_field_tests(void) "FFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC")) || !TEST_true(BN_hex2bn(&b, "1C97BEFC" "54BD7A8B65ACF89F81D4D4ADC565FA45")) - || !TEST_true(EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) + || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx)) || !TEST_true(BN_hex2bn(&x, "4A96B568" "8EF573284664698968C38BB913CBFC82")) || !TEST_true(BN_hex2bn(&y, "23a62855" @@ -303,14 +301,14 @@ static int prime_field_tests(void) * When (x, y) is on the curve, (x, y + 1) is, as it happens, not, * and therefore setting the coordinates should fail. */ - || !TEST_false(EC_POINT_set_affine_coordinates_GFp(group, P, x, - yplusone, ctx)) - || !TEST_true(EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx)) + || !TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone, + ctx)) + || !TEST_true(EC_POINT_set_affine_coordinates(group, P, x, y, ctx)) || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0) || !TEST_true(BN_hex2bn(&z, "0100000000" "000000000001F4C8F927AED3CA752257")) || !TEST_true(EC_GROUP_set_generator(group, P, z, BN_value_one())) - || !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))) + || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx))) goto err; TEST_info("SEC2 curve secp160r1 -- Generator"); test_output_bignum("x", x); @@ -333,16 +331,15 @@ static int prime_field_tests(void) "FFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC")) || !TEST_true(BN_hex2bn(&b, "64210519E59C80E7" "0FA7E9AB72243049FEB8DEECC146B9B1")) - || !TEST_true(EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) + || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx)) || !TEST_true(BN_hex2bn(&x, "188DA80EB03090F6" "7CBF20EB43A18800F4FF0AFD82FF1012")) - || !TEST_true(EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, - ctx)) + || !TEST_true(EC_POINT_set_compressed_coordinates(group, P, x, 1, ctx)) || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0) || !TEST_true(BN_hex2bn(&z, "FFFFFFFFFFFFFFFF" "FFFFFFFF99DEF836146BC9B1B4D22831")) || !TEST_true(EC_GROUP_set_generator(group, P, z, BN_value_one())) - || !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))) + || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx))) goto err; TEST_info("NIST curve P-192 -- Generator"); @@ -357,8 +354,8 @@ static int prime_field_tests(void) * When (x, y) is on the curve, (x, y + 1) is, as it happens, not, * and therefore setting the coordinates should fail. */ - || !TEST_false(EC_POINT_set_affine_coordinates_GFp(group, P, x, - yplusone, ctx)) + || !TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone, + ctx)) || !TEST_int_eq(EC_GROUP_get_degree(group), 192) || !group_order_tests(group) || !TEST_ptr(P_192 = EC_GROUP_new(EC_GROUP_method_of(group))) @@ -373,16 +370,15 @@ static int prime_field_tests(void) "FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE")) || !TEST_true(BN_hex2bn(&b, "B4050A850C04B3ABF5413256" "5044B0B7D7BFD8BA270B39432355FFB4")) - || !TEST_true(EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) + || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx)) || !TEST_true(BN_hex2bn(&x, "B70E0CBD6BB4BF7F321390B9" "4A03C1D356C21122343280D6115C1D21")) - || !TEST_true(EC_POINT_set_compressed_coordinates_GFp(group, P, x, 0, - ctx)) + || !TEST_true(EC_POINT_set_compressed_coordinates(group, P, x, 0, ctx)) || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0) || !TEST_true(BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFF" "FFFF16A2E0B8F03E13DD29455C5C2A3D")) || !TEST_true(EC_GROUP_set_generator(group, P, z, BN_value_one())) - || !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))) + || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx))) goto err; TEST_info("NIST curve P-224 -- Generator"); @@ -397,8 +393,8 @@ static int prime_field_tests(void) * When (x, y) is on the curve, (x, y + 1) is, as it happens, not, * and therefore setting the coordinates should fail. */ - || !TEST_false(EC_POINT_set_affine_coordinates_GFp(group, P, x, - yplusone, ctx)) + || !TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone, + ctx)) || !TEST_int_eq(EC_GROUP_get_degree(group), 224) || !group_order_tests(group) || !TEST_ptr(P_224 = EC_GROUP_new(EC_GROUP_method_of(group))) @@ -413,17 +409,16 @@ static int prime_field_tests(void) "00000000FFFFFFFFFFFFFFFFFFFFFFFC")) || !TEST_true(BN_hex2bn(&b, "5AC635D8AA3A93E7B3EBBD55769886BC" "651D06B0CC53B0F63BCE3C3E27D2604B")) - || !TEST_true(EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) + || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx)) || !TEST_true(BN_hex2bn(&x, "6B17D1F2E12C4247F8BCE6E563A440F2" "77037D812DEB33A0F4A13945D898C296")) - || !TEST_true(EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, - ctx)) + || !TEST_true(EC_POINT_set_compressed_coordinates(group, P, x, 1, ctx)) || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0) || !TEST_true(BN_hex2bn(&z, "FFFFFFFF00000000FFFFFFFFFFFFFFFF" "BCE6FAADA7179E84F3B9CAC2FC632551")) || !TEST_true(EC_GROUP_set_generator(group, P, z, BN_value_one())) - || !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))) + || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx))) goto err; TEST_info("NIST curve P-256 -- Generator"); @@ -438,8 +433,8 @@ static int prime_field_tests(void) * When (x, y) is on the curve, (x, y + 1) is, as it happens, not, * and therefore setting the coordinates should fail. */ - || !TEST_false(EC_POINT_set_affine_coordinates_GFp(group, P, x, - yplusone, ctx)) + || !TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone, + ctx)) || !TEST_int_eq(EC_GROUP_get_degree(group), 256) || !group_order_tests(group) || !TEST_ptr(P_256 = EC_GROUP_new(EC_GROUP_method_of(group))) @@ -457,19 +452,18 @@ static int prime_field_tests(void) || !TEST_true(BN_hex2bn(&b, "B3312FA7E23EE7E4988E056BE3F82D19" "181D9C6EFE8141120314088F5013875A" "C656398D8A2ED19D2A85C8EDD3EC2AEF")) - || !TEST_true(EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) + || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx)) || !TEST_true(BN_hex2bn(&x, "AA87CA22BE8B05378EB1C71EF320AD74" "6E1D3B628BA79B9859F741E082542A38" "5502F25DBF55296C3A545E3872760AB7")) - || !TEST_true(EC_POINT_set_compressed_coordinates_GFp(group, P, x, 1, - ctx)) + || !TEST_true(EC_POINT_set_compressed_coordinates(group, P, x, 1, ctx)) || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0) || !TEST_true(BN_hex2bn(&z, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" "FFFFFFFFFFFFFFFFC7634D81F4372DDF" "581A0DB248B0A77AECEC196ACCC52973")) || !TEST_true(EC_GROUP_set_generator(group, P, z, BN_value_one())) - || !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))) + || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx))) goto err; TEST_info("NIST curve P-384 -- Generator"); @@ -485,8 +479,8 @@ static int prime_field_tests(void) * When (x, y) is on the curve, (x, y + 1) is, as it happens, not, * and therefore setting the coordinates should fail. */ - || !TEST_false(EC_POINT_set_affine_coordinates_GFp(group, P, x, - yplusone, ctx)) + || !TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone, + ctx)) || !TEST_int_eq(EC_GROUP_get_degree(group), 384) || !group_order_tests(group) || !TEST_ptr(P_384 = EC_GROUP_new(EC_GROUP_method_of(group))) @@ -509,14 +503,13 @@ static int prime_field_tests(void) "A2DA725B99B315F3B8B489918EF109E1" "56193951EC7E937B1652C0BD3BB1BF07" "3573DF883D2C34F1EF451FD46B503F00")) - || !TEST_true(EC_GROUP_set_curve_GFp(group, p, a, b, ctx)) + || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx)) || !TEST_true(BN_hex2bn(&x, "C6" "858E06B70404E9CD9E3ECB662395B442" "9C648139053FB521F828AF606B4D3DBA" "A14B5E77EFE75928FE1DC127A2FFA8DE" "3348B3C1856A429BF97E7E31C2E5BD66")) - || !TEST_true(EC_POINT_set_compressed_coordinates_GFp(group, P, x, 0, - ctx)) + || !TEST_true(EC_POINT_set_compressed_coordinates(group, P, x, 0, ctx)) || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0) || !TEST_true(BN_hex2bn(&z, "1FF" "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" @@ -524,7 +517,7 @@ static int prime_field_tests(void) "51868783BF2F966B7FCC0148F709A5D0" "3BB5C9B8899C47AEBB6FB71E91386409")) || !TEST_true(EC_GROUP_set_generator(group, P, z, BN_value_one())) - || !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, P, x, y, ctx))) + || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx))) goto err; TEST_info("NIST curve P-521 -- Generator"); @@ -542,8 +535,8 @@ static int prime_field_tests(void) * When (x, y) is on the curve, (x, y + 1) is, as it happens, not, * and therefore setting the coordinates should fail. */ - || !TEST_false(EC_POINT_set_affine_coordinates_GFp(group, P, x, - yplusone, ctx)) + || !TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone, + ctx)) || !TEST_int_eq(EC_GROUP_get_degree(group), 521) || !group_order_tests(group) || !TEST_ptr(P_521 = EC_GROUP_new(EC_GROUP_method_of(group))) @@ -552,7 +545,7 @@ static int prime_field_tests(void) /* more tests using the last curve */ /* Restore the point that got mangled in the (x, y + 1) test. */ - || !TEST_true(EC_POINT_set_affine_coordinates_GFp(group, P, x, y, ctx)) + || !TEST_true(EC_POINT_set_affine_coordinates(group, P, x, y, ctx)) || !TEST_true(EC_POINT_copy(Q, P)) || !TEST_false(EC_POINT_is_at_infinity(group, Q)) || !TEST_true(EC_POINT_dbl(group, P, P, ctx)) @@ -834,7 +827,7 @@ static int char2_curve_test(int n) || !TEST_true(BN_hex2bn(&a, test->a)) || !TEST_true(BN_hex2bn(&b, test->b)) || !TEST_true(group = EC_GROUP_new(EC_GF2m_simple_method())) - || !TEST_true(EC_GROUP_set_curve_GF2m(group, p, a, b, ctx)) + || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx)) || !TEST_ptr(P = EC_POINT_new(group)) || !TEST_ptr(Q = EC_POINT_new(group)) || !TEST_ptr(R = EC_POINT_new(group)) @@ -849,17 +842,15 @@ static int char2_curve_test(int n) * When (x, y) is on the curve, (x, y + 1) is, as it happens, not, * and therefore setting the coordinates should fail. */ - if (!TEST_false(EC_POINT_set_affine_coordinates_GF2m(group, P, x, yplusone, - ctx)) - || !TEST_true(EC_POINT_set_compressed_coordinates_GF2m(group, P, x, - test->y_bit, - ctx)) + if (!TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone, ctx)) + || !TEST_true(EC_POINT_set_compressed_coordinates(group, P, x, + test->y_bit, + ctx)) || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0) || !TEST_true(BN_hex2bn(&z, test->order)) || !TEST_true(BN_hex2bn(&cof, test->cof)) || !TEST_true(EC_GROUP_set_generator(group, P, z, cof)) - || !TEST_true(EC_POINT_get_affine_coordinates_GF2m(group, P, x, y, - ctx))) + || !TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, ctx))) goto err; TEST_info("%s -- Generator", test->name); test_output_bignum("x", x); @@ -873,9 +864,8 @@ static int char2_curve_test(int n) * When (x, y) is on the curve, (x, y + 1) is, as it happens, not, * and therefore setting the coordinates should fail. */ - if (!TEST_false(EC_POINT_set_affine_coordinates_GF2m(group, P, x, yplusone, - ctx)) - || !TEST_true(EC_POINT_set_affine_coordinates_GF2m(group, P, x, y, ctx)) + if (!TEST_false(EC_POINT_set_affine_coordinates(group, P, x, yplusone, ctx)) + || !TEST_true(EC_POINT_set_affine_coordinates(group, P, x, y, ctx)) || !TEST_int_gt(EC_POINT_is_on_curve(group, P, ctx), 0) || !TEST_true(BN_hex2bn(&z, test->order)) || !TEST_true(BN_hex2bn(&cof, test->cof)) @@ -894,8 +884,7 @@ static int char2_curve_test(int n) /* more tests using the last curve */ if (n == OSSL_NELEM(char2_curve_tests) - 1) { - if (!TEST_true(EC_POINT_set_affine_coordinates_GF2m(group, P, x, y, - ctx)) + if (!TEST_true(EC_POINT_set_affine_coordinates(group, P, x, y, ctx)) || !TEST_true(EC_POINT_copy(Q, P)) || !TEST_false(EC_POINT_is_at_infinity(group, Q)) || !TEST_true(EC_POINT_dbl(group, P, P, ctx)) @@ -995,7 +984,7 @@ static int char2_field_tests(void) * so that the library gets * to choose the EC_METHOD */ if (!TEST_ptr(group) - || !TEST_true(EC_GROUP_set_curve_GF2m(group, p, a, b, ctx)) + || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx)) || !TEST_ptr(tmp = EC_GROUP_new(EC_GROUP_method_of(group))) || !TEST_true(EC_GROUP_copy(tmp, group))) goto err; @@ -1003,7 +992,7 @@ static int char2_field_tests(void) group = tmp; tmp = NULL; - if (!TEST_true(EC_GROUP_get_curve_GF2m(group, p, a, b, ctx))) + if (!TEST_true(EC_GROUP_get_curve(group, p, a, b, ctx))) goto err; TEST_info("Curve defined by Weierstrass equation"); @@ -1031,19 +1020,17 @@ static int char2_field_tests(void) || !TEST_true(BN_hex2bn(&x, "6")) /* Change test based on whether binary point compression is enabled or not. */ # ifdef OPENSSL_EC_BIN_PT_COMP - || !TEST_true(EC_POINT_set_compressed_coordinates_GF2m(group, Q, x, 1, - ctx)) + || !TEST_true(EC_POINT_set_compressed_coordinates(group, Q, x, 1, ctx)) # else || !TEST_true(BN_hex2bn(&y, "8")) - || !TEST_true(EC_POINT_set_affine_coordinates_GF2m(group, Q, x, y, ctx)) + || !TEST_true(EC_POINT_set_affine_coordinates(group, Q, x, y, ctx)) # endif ) goto err; if (!TEST_int_gt(EC_POINT_is_on_curve(group, Q, ctx), 0)) { /* Change test based on whether binary point compression is enabled or not. */ # ifdef OPENSSL_EC_BIN_PT_COMP - if (!TEST_true(EC_POINT_get_affine_coordinates_GF2m(group, Q, x, y, - ctx))) + if (!TEST_true(EC_POINT_get_affine_coordinates(group, Q, x, y, ctx))) goto err; # endif TEST_info("Point is not on curve"); @@ -1061,8 +1048,8 @@ static int char2_field_tests(void) if (EC_POINT_is_at_infinity(group, P)) TEST_note(" point at infinity"); else { - if (!TEST_true(EC_POINT_get_affine_coordinates_GF2m(group, P, x, y, - ctx))) + if (!TEST_true(EC_POINT_get_affine_coordinates(group, P, x, y, + ctx))) goto err; test_output_bignum("x", x); @@ -1306,7 +1293,7 @@ static int nistp_single_test(int idx) || !TEST_int_eq(1, BN_is_prime_ex(p, BN_prime_checks, ctx, NULL)) || !TEST_true(BN_hex2bn(&a, test->a)) || !TEST_true(BN_hex2bn(&b, test->b)) - || !TEST_true(EC_GROUP_set_curve_GFp(NISTP, p, a, b, ctx)) + || !TEST_true(EC_GROUP_set_curve(NISTP, p, a, b, ctx)) || !TEST_ptr(G = EC_POINT_new(NISTP)) || !TEST_ptr(P = EC_POINT_new(NISTP)) || !TEST_ptr(Q = EC_POINT_new(NISTP)) @@ -1318,13 +1305,13 @@ static int nistp_single_test(int idx) * When (x, y) is on the curve, (x, y + 1) is, as it happens, not, * and therefore setting the coordinates should fail. */ - || !TEST_false(EC_POINT_set_affine_coordinates_GFp(NISTP, Q_CHECK, x, - yplusone, ctx)) - || !TEST_true(EC_POINT_set_affine_coordinates_GFp(NISTP, Q_CHECK, x, y, - ctx)) + || !TEST_false(EC_POINT_set_affine_coordinates(NISTP, Q_CHECK, x, + yplusone, ctx)) + || !TEST_true(EC_POINT_set_affine_coordinates(NISTP, Q_CHECK, x, y, + ctx)) || !TEST_true(BN_hex2bn(&x, test->Gx)) || !TEST_true(BN_hex2bn(&y, test->Gy)) - || !TEST_true(EC_POINT_set_affine_coordinates_GFp(NISTP, G, x, y, ctx)) + || !TEST_true(EC_POINT_set_affine_coordinates(NISTP, G, x, y, ctx)) || !TEST_true(BN_hex2bn(&order, test->order)) || !TEST_true(EC_GROUP_set_generator(NISTP, G, order, BN_value_one())) || !TEST_int_eq(EC_GROUP_get_degree(NISTP), test->degree)) diff --git a/test/sm2_internal_test.c b/test/sm2_internal_test.c index ea8ac7df88..0d145e8553 100644 --- a/test/sm2_internal_test.c +++ b/test/sm2_internal_test.c @@ -107,8 +107,8 @@ static EC_GROUP *create_EC_group(const char *p_hex, const char *a_hex, if (!TEST_true(BN_hex2bn(&g_x, x_hex)) || !TEST_true(BN_hex2bn(&g_y, y_hex)) - || !TEST_true(EC_POINT_set_affine_coordinates_GFp(group, generator, - g_x, g_y, NULL))) + || !TEST_true(EC_POINT_set_affine_coordinates(group, generator, g_x, + g_y, NULL))) goto done; if (!TEST_true(BN_hex2bn(&order, order_hex)) -- 2.39.2