/* * Perform a deterministic walk on the curve, by starting from |point| and * using the X-coordinate of the previous point as the next scalar for * point multiplication. * Returns the X-coordinate of the end result or NULL on error. */ static BIGNUM *walk_curve(const EC_GROUP *group, EC_POINT *point, intmax_t num) { BIGNUM *scalar = NULL; intmax_t i; if (!TEST_ptr(scalar = BN_new()) || !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(group, point, scalar, NULL, NULL))) goto err; } return scalar; err: BN_free(scalar); return NULL; }
int ec_GFp_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) { BN_CTX *new_ctx = NULL; BIGNUM *x, *y; int ret = 0; if (point->Z_is_one || EC_POINT_is_at_infinity(group, point)) return 1; if (ctx == NULL) { ctx = new_ctx = BN_CTX_new(); if (ctx == NULL) return 0; } BN_CTX_start(ctx); x = BN_CTX_get(ctx); y = BN_CTX_get(ctx); if (y == NULL) goto err; if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)) goto err; 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); goto err; } ret = 1; err: BN_CTX_end(ctx); BN_CTX_free(new_ctx); return ret; }
int EC_POINT_get_affine_coordinates_GF2m(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); }