* The ECC Code is licensed pursuant to the OpenSSL open source
* license provided below.
*
- * In addition, Sun covenants to all licensees who provide a reciprocal
- * covenant with respect to their own patents if any, not to sue under
- * current and future patent claims necessarily infringed by the making,
- * using, practicing, selling, offering for sale and/or otherwise
- * disposing of the ECC Code as delivered hereunder (or portions thereof),
- * provided that such covenant shall not apply:
- * 1) for code that a licensee deletes from the ECC Code;
- * 2) separates from the ECC Code; or
- * 3) for infringements caused by:
- * i) the modification of the ECC Code or
- * ii) the combination of the ECC Code with other software or
- * devices where such combination causes the infringement.
- *
* The software is originally written by Sheueling Chang Shantz and
* Douglas Stebila of Sun Microsystems Laboratories.
*
ec_GF2m_simple_group_finish,
ec_GF2m_simple_group_clear_finish,
ec_GF2m_simple_group_copy,
- ec_GF2m_simple_group_set_curve_GF2m,
- ec_GF2m_simple_group_get_curve_GF2m,
+ ec_GF2m_simple_group_set_curve,
+ ec_GF2m_simple_group_get_curve,
ec_GF2m_simple_group_get_degree,
ec_GF2m_simple_group_check_discriminant,
ec_GF2m_simple_point_init,
ec_GF2m_simple_point_clear_finish,
ec_GF2m_simple_point_copy,
ec_GF2m_simple_point_set_to_infinity,
- 0 /* set_Jprojective_coordinates_GF2m */,
- 0 /* get_Jprojective_coordinates_GF2m */,
- ec_GF2m_simple_point_set_affine_coordinates_GF2m,
- ec_GF2m_simple_point_get_affine_coordinates_GF2m,
- ec_GF2m_simple_set_compressed_coordinates_GF2m,
+ 0 /* set_Jprojective_coordinates_GFp */,
+ 0 /* get_Jprojective_coordinates_GFp */,
+ ec_GF2m_simple_point_set_affine_coordinates,
+ ec_GF2m_simple_point_get_affine_coordinates,
+ ec_GF2m_simple_set_compressed_coordinates,
ec_GF2m_simple_point2oct,
ec_GF2m_simple_oct2point,
ec_GF2m_simple_add,
ec_GF2m_simple_dbl,
ec_GF2m_simple_invert,
- ec_GF2m_mont_mul,
- ec_GF2m_mont_precompute_mult,
+ ec_GF2m_simple_mul,
+ ec_GF2m_precompute_mult,
ec_GF2m_simple_is_at_infinity,
ec_GF2m_simple_is_on_curve,
ec_GF2m_simple_cmp,
/* Set the curve parameters of an EC_GROUP structure. */
-int ec_GF2m_simple_group_set_curve_GF2m(EC_GROUP *group,
+int ec_GF2m_simple_group_set_curve(EC_GROUP *group,
const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
{
int ret = 0, i;
/* group->field */
if (!BN_copy(&group->field, p)) goto err;
i = BN_GF2m_poly2arr(&group->field, group->poly, 5);
- if ((i != 5) && (i != 3)) goto err;
+ if ((i != 5) && (i != 3))
+ {
+ ECerr(EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE, EC_R_UNSUPPORTED_FIELD);
+ goto err;
+ }
/* group->a */
if (!BN_GF2m_mod_arr(&group->a, a, group->poly)) goto err;
/* Get the curve parameters of an EC_GROUP structure.
* If p, a, or b are NULL then there values will not be set but the method will return with success.
*/
-int ec_GF2m_simple_group_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
+int ec_GF2m_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
{
int ret = 0;
if (!BN_copy(p, &group->field)) return 0;
}
- if (a != NULL || b != NULL)
+ if (a != NULL)
{
- if (a != NULL)
- {
- if (!BN_copy(a, &group->a)) goto err;
- }
- if (b != NULL)
- {
- if (!BN_copy(b, &group->b)) goto err;
- }
+ if (!BN_copy(a, &group->a)) goto err;
+ }
+
+ if (b != NULL)
+ {
+ if (!BN_copy(b, &group->b)) goto err;
}
ret = 1;
/* Set the coordinates of an EC_POINT using affine coordinates.
* Note that the simple implementation only uses affine coordinates.
*/
-int ec_GF2m_simple_point_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point,
+int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
const BIGNUM *x, const BIGNUM *y, BN_CTX *ctx)
{
int ret = 0;
if (x == NULL || y == NULL)
{
- ECerr(EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES_GF2M, ERR_R_PASSED_NULL_PARAMETER);
+ ECerr(EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES, ERR_R_PASSED_NULL_PARAMETER);
return 0;
}
if (!BN_copy(&point->X, x)) goto err;
+ BN_set_sign(&point->X, 0);
if (!BN_copy(&point->Y, y)) goto err;
+ BN_set_sign(&point->Y, 0);
if (!BN_copy(&point->Z, BN_value_one())) goto err;
+ BN_set_sign(&point->Z, 0);
point->Z_is_one = 1;
ret = 1;
/* Gets the affine coordinates of an EC_POINT.
* Note that the simple implementation only uses affine coordinates.
*/
-int ec_GF2m_simple_point_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *point,
+int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point,
BIGNUM *x, BIGNUM *y, BN_CTX *ctx)
{
int ret = 0;
if (EC_POINT_is_at_infinity(group, point))
{
- ECerr(EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES_GF2M, EC_R_POINT_AT_INFINITY);
+ ECerr(EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES, EC_R_POINT_AT_INFINITY);
return 0;
}
if (BN_cmp(&point->Z, BN_value_one()))
{
- ECerr(EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES_GF2M, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
+ ECerr(EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
return 0;
}
if (x != NULL)
{
if (!BN_copy(x, &point->X)) goto err;
+ BN_set_sign(x, 0);
}
if (y != NULL)
{
if (!BN_copy(y, &point->Y)) goto err;
+ BN_set_sign(y, 0);
}
ret = 1;