-/* $OpenBSD: ec.h,v 1.19 2021/04/20 17:04:13 tb Exp $ */
+/* $OpenBSD: ec.h,v 1.20 2021/04/20 17:16:37 tb Exp $ */
/*
* Originally written by Bodo Moeller for the OpenSSL project.
*/
int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group,
const EC_POINT *p, BIGNUM *x, BIGNUM *y, BIGNUM *z, BN_CTX *ctx);
+#if defined(LIBRESSL_INTERNAL)
+int EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *p,
+ const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx);
+int EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *p,
+ BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
+#else
/** Sets the affine coordinates of a EC_POINT over GFp
* \param group underlying EC_GROUP object
* \param p EC_POINT object
*/
int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group,
const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
+#endif
/** Sets the x9.62 compressed coordinates of a EC_POINT over GFp
* \param group underlying EC_GROUP object
*/
int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *p,
const BIGNUM *x, int y_bit, BN_CTX *ctx);
+
#ifndef OPENSSL_NO_EC2M
+#if !defined(LIBRESSL_INTERNAL)
/** Sets the affine coordinates of a EC_POINT over GF2m
* \param group underlying EC_GROUP object
* \param p EC_POINT object
*/
int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group,
const EC_POINT *p, BIGNUM *x, BIGNUM *y, BN_CTX *ctx);
+#endif
/** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m
* \param group underlying EC_GROUP object
-/* $OpenBSD: ec2_oct.c,v 1.13 2021/04/19 17:06:37 tb Exp $ */
+/* $OpenBSD: ec2_oct.c,v 1.14 2021/04/20 17:16:37 tb Exp $ */
/* ====================================================================
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
*
}
}
- 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;
if ((yxi = BN_CTX_get(ctx)) == 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;
}
}
/*
- * EC_POINT_set_affine_coordinates_GF2m checks that the
+ * EC_POINT_set_affine_coordinates checks that the
* point is on the curve as required by X9.62.
*/
- 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;
}
-/* $OpenBSD: ec2_smpl.c,v 1.21 2018/11/05 20:18:21 tb Exp $ */
+/* $OpenBSD: ec2_smpl.c,v 1.22 2021/04/20 17:16:37 tb Exp $ */
/* ====================================================================
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
*
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) {
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;
}
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;
if ((bY = BN_CTX_get(ctx)) == 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;
if ((y = BN_CTX_get(ctx)) == 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;
-/* $OpenBSD: ec_curve.c,v 1.20 2020/06/05 17:12:09 jsing Exp $ */
+/* $OpenBSD: ec_curve.c,v 1.21 2021/04/20 17:16:37 tb Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project.
*/
ECerror(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)) {
ECerror(ERR_R_EC_LIB);
goto err;
}
-/* $OpenBSD: ec_key.c,v 1.24 2019/01/19 01:12:48 tb Exp $ */
+/* $OpenBSD: ec_key.c,v 1.25 2021/04/20 17:16:37 tb Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project.
*/
#ifndef OPENSSL_NO_EC2M
if (is_char_two) {
- if (!EC_POINT_set_affine_coordinates_GF2m(key->group, point,
+ if (!EC_POINT_set_affine_coordinates(key->group, point,
x, y, ctx))
goto err;
- if (!EC_POINT_get_affine_coordinates_GF2m(key->group, point,
+ if (!EC_POINT_get_affine_coordinates(key->group, point,
tx, ty, ctx))
goto err;
} else
#endif
{
- if (!EC_POINT_set_affine_coordinates_GFp(key->group, point,
+ if (!EC_POINT_set_affine_coordinates(key->group, point,
x, y, ctx))
goto err;
- if (!EC_POINT_get_affine_coordinates_GFp(key->group, point,
+ if (!EC_POINT_get_affine_coordinates(key->group, point,
tx, ty, ctx))
goto err;
}
-/* $OpenBSD: ec_lcl.h,v 1.14 2021/04/20 17:04:13 tb Exp $ */
+/* $OpenBSD: ec_lcl.h,v 1.15 2021/04/20 17:16:37 tb Exp $ */
/*
* Originally written by Bodo Moeller for the OpenSSL project.
*/
/* 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_affine_coordinates,
+ * EC_POINT_get_affine_coordinates,
* EC_POINT_set_compressed_coordinates_GFp, ..._GF2m:
*/
int (*point_set_to_infinity)(const EC_GROUP *, EC_POINT *);
-/* $OpenBSD: ec_lib.c,v 1.35 2021/04/20 17:06:17 tb Exp $ */
+/* $OpenBSD: ec_lib.c,v 1.36 2021/04/20 17:16:37 tb Exp $ */
/*
* Originally written by Bodo Moeller for the OpenSSL project.
*/
return group->meth->point_get_Jprojective_coordinates_GFp(group, point, x, y, z, ctx);
}
-
-int
-EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
+int
+EC_POINT_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
{
if (group->meth->point_set_affine_coordinates == 0) {
return 1;
}
+int
+EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
+ const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
+{
+ return EC_POINT_set_affine_coordinates(group, point, x, y, ctx);
+}
+
#ifndef OPENSSL_NO_EC2M
-int
+int
EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point,
const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
{
- if (group->meth->point_set_affine_coordinates == 0) {
- ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
- return 0;
- }
- if (group->meth != point->meth) {
- ECerror(EC_R_INCOMPATIBLE_OBJECTS);
- return 0;
- }
- if (!group->meth->point_set_affine_coordinates(group, point, x, y, ctx))
- return 0;
- if (EC_POINT_is_on_curve(group, point, ctx) <= 0) {
- ECerror(EC_R_POINT_IS_NOT_ON_CURVE);
- return 0;
- }
- return 1;
+ return EC_POINT_set_affine_coordinates(group, point, x, y, ctx);
}
#endif
-int
-EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,
+int
+EC_POINT_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point,
BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
{
if (group->meth->point_get_affine_coordinates == 0) {
return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
}
+int
+EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,
+ BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
+{
+ return EC_POINT_get_affine_coordinates(group, point, x, y, ctx);
+}
+
#ifndef OPENSSL_NO_EC2M
-int
+int
EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *point,
BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
{
- if (group->meth->point_get_affine_coordinates == 0) {
- ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
- return 0;
- }
- if (group->meth != point->meth) {
- ECerror(EC_R_INCOMPATIBLE_OBJECTS);
- return 0;
- }
- return group->meth->point_get_affine_coordinates(group, point, x, y, ctx);
+ return EC_POINT_get_affine_coordinates(group, point, x, y, ctx);
}
#endif
-/* $OpenBSD: ecp_nistp224.c,v 1.23 2018/11/05 20:18:21 tb Exp $ */
+/* $OpenBSD: ecp_nistp224.c,v 1.24 2021/04/20 17:16:37 tb Exp $ */
/*
* Written by Emilia Kasper (Google) for the OpenSSL project.
*/
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;
-/* $OpenBSD: ecp_nistp256.c,v 1.22 2018/11/05 20:18:21 tb Exp $ */
+/* $OpenBSD: ecp_nistp256.c,v 1.23 2021/04/20 17:16:37 tb Exp $ */
/*
* Written by Adam Langley (Google) for the OpenSSL project
*/
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;
-/* $OpenBSD: ecp_nistp521.c,v 1.23 2018/11/05 20:18:21 tb Exp $ */
+/* $OpenBSD: ecp_nistp521.c,v 1.24 2021/04/20 17:16:38 tb Exp $ */
/*
* Written by Adam Langley (Google) for the OpenSSL project
*/
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;
-/* $OpenBSD: ecp_nistz256.c,v 1.7 2018/11/05 20:18:21 tb Exp $ */
+/* $OpenBSD: ecp_nistz256.c,v 1.8 2021/04/20 17:16:38 tb Exp $ */
/* Copyright (c) 2014, Intel Corporation.
*
* Permission to use, copy, modify, and/or distribute this software for any
y.neg = 0;
y.flags = BN_FLG_STATIC_DATA;
- ret = EC_POINT_set_affine_coordinates_GFp(group, out, &x, &y, ctx);
+ ret = EC_POINT_set_affine_coordinates(group, out, &x, &y, ctx);
return ret;
}
-/* $OpenBSD: ecp_oct.c,v 1.12 2020/12/04 08:55:30 tb Exp $ */
+/* $OpenBSD: ecp_oct.c,v 1.13 2021/04/20 17:16:38 tb Exp $ */
/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
* for the OpenSSL project.
* Includes code written by Bodo Moeller for the OpenSSL project.
ECerror(ERR_R_INTERNAL_ERROR);
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;
if ((y = BN_CTX_get(ctx)) == 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 || form == POINT_CONVERSION_HYBRID) && BN_is_odd(y))
}
}
/*
- * EC_POINT_set_affine_coordinates_GFp checks that the point is
+ * EC_POINT_set_affine_coordinates checks that the point is
* on the curve as required by X9.62.
*/
- 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;
}
-/* $OpenBSD: ecp_smpl.c,v 1.29 2018/11/15 05:53:31 tb Exp $ */
+/* $OpenBSD: ecp_smpl.c,v 1.30 2021/04/20 17:16:38 tb Exp $ */
/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
* for the OpenSSL project.
* Includes code written by Bodo Moeller for the OpenSSL project.
if ((y = BN_CTX_get(ctx)) == 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) {
ECerror(ERR_R_INTERNAL_ERROR);
-/* $OpenBSD: ech_key.c,v 1.9 2019/01/19 01:12:48 tb Exp $ */
+/* $OpenBSD: ech_key.c,v 1.10 2021/04/20 17:16:38 tb Exp $ */
/* ====================================================================
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
*
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, y,
- ctx)) {
+ if (!EC_POINT_get_affine_coordinates(group, tmp, x, y, ctx)) {
ECDHerror(ECDH_R_POINT_ARITHMETIC_FAILURE);
goto err;
}
}
#ifndef OPENSSL_NO_EC2M
else {
- if (!EC_POINT_get_affine_coordinates_GF2m(group, tmp, x, y,
- ctx)) {
+ if (!EC_POINT_get_affine_coordinates(group, tmp, x, y, ctx)) {
ECDHerror(ECDH_R_POINT_ARITHMETIC_FAILURE);
goto err;
}
-/* $OpenBSD: ecs_ossl.c,v 1.20 2019/06/04 18:15:27 tb Exp $ */
+/* $OpenBSD: ecs_ossl.c,v 1.21 2021/04/20 17:16:38 tb Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project
*/
}
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,
+ if (!EC_POINT_get_affine_coordinates(group, point,
X, NULL, ctx)) {
ECDSAerror(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,
+ if (!EC_POINT_get_affine_coordinates(group, point,
X, NULL, ctx)) {
ECDSAerror(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,
+ if (!EC_POINT_get_affine_coordinates(group, point, X, NULL,
ctx)) {
ECDSAerror(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,
+ if (!EC_POINT_get_affine_coordinates(group, point, X, NULL,
ctx)) {
ECDSAerror(ERR_R_EC_LIB);
goto err;
-/* $OpenBSD: gostr341001.c,v 1.7 2017/01/29 17:49:23 beck Exp $ */
+/* $OpenBSD: gostr341001.c,v 1.8 2021/04/20 17:16:38 tb Exp $ */
/*
* Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
* Copyright (c) 2005-2006 Cryptocom LTD
GOSTerror(ERR_R_EC_LIB);
goto err;
}
- if (EC_POINT_get_affine_coordinates_GFp(group, C, X,
+ if (EC_POINT_get_affine_coordinates(group, C, X,
NULL, ctx) == 0) {
GOSTerror(ERR_R_EC_LIB);
goto err;
GOSTerror(ERR_R_EC_LIB);
goto err;
}
- if (EC_POINT_get_affine_coordinates_GFp(group, C, X, NULL, ctx) == 0) {
+ if (EC_POINT_get_affine_coordinates(group, C, X, NULL, ctx) == 0) {
GOSTerror(ERR_R_EC_LIB);
goto err;
}
goto err;
if (EC_POINT_mul(group, pnt, NULL, pub_key, p, ctx) == 0)
goto err;
- if (EC_POINT_get_affine_coordinates_GFp(group, pnt, X, Y, ctx) == 0)
+ if (EC_POINT_get_affine_coordinates(group, pnt, X, Y, ctx) == 0)
goto err;
ok = 1;
-/* $OpenBSD: gostr341001_ameth.c,v 1.16 2020/06/05 17:17:22 jsing Exp $ */
+/* $OpenBSD: gostr341001_ameth.c,v 1.17 2021/04/20 17:16:38 tb Exp $ */
/*
* Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
* Copyright (c) 2005-2006 Cryptocom LTD
goto err;
}
- if (EC_POINT_get_affine_coordinates_GFp(GOST_KEY_get0_group(ec),
+ if (EC_POINT_get_affine_coordinates(GOST_KEY_get0_group(ec),
pub_key, X, Y, NULL) == 0) {
GOSTerror(ERR_R_EC_LIB);
goto err;
goto err;
pubkey = GOST_KEY_get0_public_key(pkey->pkey.gost);
group = GOST_KEY_get0_group(pkey->pkey.gost);
- if (EC_POINT_get_affine_coordinates_GFp(group, pubkey, X, Y,
- ctx) == 0) {
+ if (EC_POINT_get_affine_coordinates(group, pubkey, X, Y, ctx) == 0) {
GOSTerror(ERR_R_EC_LIB);
goto err;
}
-/* $OpenBSD: gostr341001_key.c,v 1.8 2017/05/02 03:59:44 deraadt Exp $ */
+/* $OpenBSD: gostr341001_key.c,v 1.9 2021/04/20 17:16:38 tb Exp $ */
/*
* Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
* Copyright (c) 2005-2006 Cryptocom LTD
goto err;
if ((ty = BN_CTX_get(ctx)) == NULL)
goto err;
- if (EC_POINT_set_affine_coordinates_GFp(key->group, point, x, y,
+ if (EC_POINT_set_affine_coordinates(key->group, point, x, y,
ctx) == 0)
goto err;
- if (EC_POINT_get_affine_coordinates_GFp(key->group, point, tx, ty,
+ if (EC_POINT_get_affine_coordinates(key->group, point, tx, ty,
ctx) == 0)
goto err;
/*