Lines Matching +full:in2 +full:-
2 * Copyright (C) 2017 - This file is part of libecc project
7 * Jean-Pierre FLORI <jean-pierre.flori@ssi.gouv.fr>
22 * success, -1 otherwise.
28 MUST_HAVE(((in != NULL) && (in->magic == AFF_PT_MAGIC)), ret, err); in aff_pt_check_initialized()
29 ret = ec_shortw_crv_check_initialized(in->crv); in aff_pt_check_initialized()
37 * function on given curve. Return 0 on success, -1 on error.
47 ret = fp_init(&(in->x), curve->a.ctx); EG(ret, err); in aff_pt_init()
48 ret = fp_init(&(in->y), curve->a.ctx); EG(ret, err); in aff_pt_init()
50 in->crv = curve; in aff_pt_init()
51 in->magic = AFF_PT_MAGIC; in aff_pt_init()
59 * 'xcoord' and 'ycoord'. Return 0 on success, -1 on error.
68 ret = fp_copy(&(in->x), xcoord); EG(ret, err); in aff_pt_init_from_coords()
69 ret = fp_copy(&(in->y), ycoord); in aff_pt_init_from_coords()
83 if((in != NULL) && (in->magic == AFF_PT_MAGIC) && (in->crv != NULL)){ in aff_pt_uninit()
84 in->crv = NULL; in aff_pt_uninit()
85 in->magic = WORD(0); in aff_pt_uninit()
87 fp_uninit(&(in->x)); in aff_pt_uninit()
88 fp_uninit(&(in->y)); in aff_pt_uninit()
99 * The function returns -1 on error, 0 on success.
120 ret = fp_mul(y2, y2, &(curve->a)); EG(ret, err); in aff_pt_y_from_x()
122 ret = fp_add(y1, y1, &(curve->b)); EG(ret, err); in aff_pt_y_from_x()
137 * the function returns -1 and 'on_curve' is left unmodified.
150 MUST_HAVE((x->ctx == y->ctx), ret, err); in is_on_shortw_curve()
151 MUST_HAVE((x->ctx == curve->a.ctx), ret, err); in is_on_shortw_curve()
154 * (y^2 - b) = (x^2 + a) * x in is_on_shortw_curve()
157 /* Compute y^2 - b */ in is_on_shortw_curve()
158 ret = fp_init(&tmp1, x->ctx); EG(ret, err); in is_on_shortw_curve()
160 ret = fp_sub(&tmp1, &tmp1, &(curve->b)); EG(ret, err); in is_on_shortw_curve()
163 ret = fp_init(&tmp2, x->ctx); EG(ret, err); in is_on_shortw_curve()
165 ret = fp_add(&tmp2, &tmp2, &(curve->a)); EG(ret, err); in is_on_shortw_curve()
190 ret = is_on_shortw_curve(&(pt->x), &(pt->y), pt->crv, on_curve); in aff_pt_is_on_curve()
198 * 0 is returned on success, -1 on error.
205 ret = aff_pt_init(out, in->crv); EG(ret, err); in ec_shortw_aff_copy()
206 ret = fp_copy(&(out->x), &(in->x)); EG(ret, err); in ec_shortw_aff_copy()
207 ret = fp_copy(&(out->y), &(in->y)); in ec_shortw_aff_copy()
214 * Compare affine points 'in1' and 'in2'. On success, 0 is returned and
215 * comparison value is given using 'cmp' (0 if equal, a non-zero value
216 * if they are different). -1 is returned on error.
218 int ec_shortw_aff_cmp(aff_pt_src_t in1, aff_pt_src_t in2, int *cmp) in ec_shortw_aff_cmp() argument
225 ret = aff_pt_check_initialized(in2); EG(ret, err); in ec_shortw_aff_cmp()
227 MUST_HAVE((in1->crv == in2->crv), ret, err); in ec_shortw_aff_cmp()
229 ret = fp_cmp(&(in1->x), &(in2->x), &cmp_x); EG(ret, err); in ec_shortw_aff_cmp()
230 ret = fp_cmp(&(in1->y), &(in2->y), &cmp_y); EG(ret, err); in ec_shortw_aff_cmp()
239 * Check if given affine points 'in1' and 'in2' on the same curve are equal
241 * - 1 if points are equal or opposite
242 * - 0 if not
243 * The function returns -1 on error, in which case 'aff_is_eq_or_opp'
246 int ec_shortw_aff_eq_or_opp(aff_pt_src_t in1, aff_pt_src_t in2, in ec_shortw_aff_eq_or_opp() argument
252 ret = aff_pt_check_initialized(in2); EG(ret, err); in ec_shortw_aff_eq_or_opp()
253 MUST_HAVE((in1->crv == in2->crv), ret, err); in ec_shortw_aff_eq_or_opp()
256 ret = fp_cmp(&(in1->x), &(in2->x), &cmp); EG(ret, err); in ec_shortw_aff_eq_or_opp()
257 ret = fp_eq_or_opp(&(in1->y), &(in2->y), &eq_or_opp); EG(ret, err); in ec_shortw_aff_eq_or_opp()
270 * 2 * p_len. The function returns 0 on success, -1 on error.
284 ctx = crv->a.ctx; in aff_pt_import_from_buf()
285 coord_len = (u16)BYTECEIL(ctx->p_bitlen); in aff_pt_import_from_buf()
289 ret = fp_init_from_buf(&(pt->x), ctx, pt_buf, coord_len); EG(ret, err); in aff_pt_import_from_buf()
290 ret = fp_init_from_buf(&(pt->y), ctx, pt_buf + coord_len, coord_len); EG(ret, err); in aff_pt_import_from_buf()
293 pt->crv = crv; in aff_pt_import_from_buf()
296 pt->magic = AFF_PT_MAGIC; in aff_pt_import_from_buf()
306 ret = -1; in aff_pt_import_from_buf()
337 coord_len = (u16)BYTECEIL(pt->crv->a.ctx->p_bitlen); in aff_pt_export_to_buf()
341 ret = fp_export_to_buf(pt_buf, coord_len, &(pt->x)); EG(ret, err); in aff_pt_export_to_buf()
342 ret = fp_export_to_buf(pt_buf + coord_len, coord_len, &(pt->y)); in aff_pt_export_to_buf()