Lines Matching refs:ret
26 int ret; in aff_pt_check_initialized() local
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()
32 return ret; in aff_pt_check_initialized()
41 int ret; in aff_pt_init() local
43 MUST_HAVE((in != NULL), ret, err); in aff_pt_init()
44 MUST_HAVE((curve != NULL), ret, err); in aff_pt_init()
46 ret = ec_shortw_crv_check_initialized(curve); EG(ret, err); in aff_pt_init()
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()
54 return ret; in aff_pt_init()
65 int ret; in aff_pt_init_from_coords() local
67 ret = aff_pt_init(in, curve); EG(ret, err); in aff_pt_init_from_coords()
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()
72 return ret; in aff_pt_init_from_coords()
104 int ret; in aff_pt_y_from_x() local
106 MUST_HAVE((y1 != NULL) && (y2 != NULL), ret, err); in aff_pt_y_from_x()
107 ret = ec_shortw_crv_check_initialized(curve); EG(ret, err); in aff_pt_y_from_x()
108 ret = fp_check_initialized(x); EG(ret, err); in aff_pt_y_from_x()
110 MUST_HAVE((y1 != y2) && (y1 != x), ret, err); in aff_pt_y_from_x()
114 ret = fp_copy(y1, x); EG(ret, err); in aff_pt_y_from_x()
115 ret = fp_copy(y2, x); EG(ret, err); in aff_pt_y_from_x()
118 ret = fp_sqr(y1, y1); EG(ret, err); in aff_pt_y_from_x()
119 ret = fp_mul(y1, y1, x); EG(ret, err); in aff_pt_y_from_x()
120 ret = fp_mul(y2, y2, &(curve->a)); EG(ret, err); in aff_pt_y_from_x()
121 ret = fp_add(y1, y1, y2); 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()
127 ret = fp_sqrt(y1, y2, y1); in aff_pt_y_from_x()
130 return ret; in aff_pt_y_from_x()
142 int ret, cmp; in is_on_shortw_curve() local
145 ret = ec_shortw_crv_check_initialized(curve); EG(ret, err); in is_on_shortw_curve()
146 ret = fp_check_initialized(x); EG(ret, err); in is_on_shortw_curve()
147 ret = fp_check_initialized(y); EG(ret, err); in is_on_shortw_curve()
148 MUST_HAVE((on_curve != NULL), ret, err); in is_on_shortw_curve()
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()
158 ret = fp_init(&tmp1, x->ctx); EG(ret, err); in is_on_shortw_curve()
159 ret = fp_sqr(&tmp1, y); 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()
164 ret = fp_sqr(&tmp2, x); EG(ret, err); in is_on_shortw_curve()
165 ret = fp_add(&tmp2, &tmp2, &(curve->a)); EG(ret, err); in is_on_shortw_curve()
166 ret = fp_mul(&tmp2, &tmp2, x); EG(ret, err); in is_on_shortw_curve()
169 ret = fp_cmp(&tmp1, &tmp2, &cmp); EG(ret, err); in is_on_shortw_curve()
177 return ret; in is_on_shortw_curve()
186 int ret; in aff_pt_is_on_curve() local
188 MUST_HAVE((on_curve != NULL), ret, err); in aff_pt_is_on_curve()
189 ret = aff_pt_check_initialized(pt); EG(ret, err); in aff_pt_is_on_curve()
190 ret = is_on_shortw_curve(&(pt->x), &(pt->y), pt->crv, on_curve); in aff_pt_is_on_curve()
193 return ret; in aff_pt_is_on_curve()
202 int ret; in ec_shortw_aff_copy() local
204 ret = aff_pt_check_initialized(in); EG(ret, err); in ec_shortw_aff_copy()
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()
210 return ret; in ec_shortw_aff_copy()
220 int ret, cmp_x, cmp_y; in ec_shortw_aff_cmp() local
222 MUST_HAVE((cmp != NULL), ret, err); in ec_shortw_aff_cmp()
224 ret = aff_pt_check_initialized(in1); EG(ret, err); in ec_shortw_aff_cmp()
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()
235 return ret; in ec_shortw_aff_cmp()
249 int ret, cmp, eq_or_opp; in ec_shortw_aff_eq_or_opp() local
251 ret = aff_pt_check_initialized(in1); EG(ret, err); in ec_shortw_aff_eq_or_opp()
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()
254 MUST_HAVE((aff_is_eq_or_opp != NULL), 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()
262 return ret; in ec_shortw_aff_eq_or_opp()
278 int ret, on_curve; in aff_pt_import_from_buf() local
280 MUST_HAVE((pt_buf != NULL), ret, err); in aff_pt_import_from_buf()
281 MUST_HAVE((pt != NULL), ret, err); in aff_pt_import_from_buf()
282 ret = ec_shortw_crv_check_initialized(crv); EG(ret, err); in aff_pt_import_from_buf()
287 MUST_HAVE((pt_buf_len == (2 * coord_len)), ret, err); 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()
302 ret = aff_pt_is_on_curve(pt, &on_curve); EG(ret, err); in aff_pt_import_from_buf()
306 ret = -1; in aff_pt_import_from_buf()
308 ret = 0; in aff_pt_import_from_buf()
314 return ret; in aff_pt_import_from_buf()
328 int ret, on_curve; in aff_pt_export_to_buf() local
330 MUST_HAVE((pt_buf != NULL), ret, err); in aff_pt_export_to_buf()
333 ret = aff_pt_is_on_curve(pt, &on_curve); EG(ret, err); in aff_pt_export_to_buf()
334 MUST_HAVE((on_curve), ret, err); in aff_pt_export_to_buf()
338 MUST_HAVE((pt_buf_len == (2 * coord_len)), ret, err); 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()
345 return ret; in aff_pt_export_to_buf()