• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt/router/openssl-1.0.0q/crypto/ec/

Lines Matching refs:group

130 int ec_GFp_simple_group_init(EC_GROUP *group)
132 BN_init(&group->field);
133 BN_init(&group->a);
134 BN_init(&group->b);
135 group->a_is_minus3 = 0;
140 void ec_GFp_simple_group_finish(EC_GROUP *group)
142 BN_free(&group->field);
143 BN_free(&group->a);
144 BN_free(&group->b);
148 void ec_GFp_simple_group_clear_finish(EC_GROUP *group)
150 BN_clear_free(&group->field);
151 BN_clear_free(&group->a);
152 BN_clear_free(&group->b);
168 int ec_GFp_simple_group_set_curve(EC_GROUP *group,
193 /* group->field */
194 if (!BN_copy(&group->field, p)) goto err;
195 BN_set_negative(&group->field, 0);
197 /* group->a */
199 if (group->meth->field_encode)
200 { if (!group->meth->field_encode(group, &group->a, tmp_a, ctx)) goto err; }
202 if (!BN_copy(&group->a, tmp_a)) goto err;
204 /* group->b */
205 if (!BN_nnmod(&group->b, b, p, ctx)) goto err;
206 if (group->meth->field_encode)
207 if (!group->meth->field_encode(group, &group->b, &group->b, ctx)) goto err;
209 /* group->a_is_minus3 */
211 group->a_is_minus3 = (0 == BN_cmp(tmp_a, &group->field));
223 int ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
230 if (!BN_copy(p, &group->field)) return 0;
235 if (group->meth->field_decode)
245 if (!group->meth->field_decode(group, a, &group->a, ctx)) goto err;
249 if (!group->meth->field_decode(group, b, &group->b, ctx)) goto err;
256 if (!BN_copy(a, &group->a)) goto err;
260 if (!BN_copy(b, &group->b)) goto err;
274 int ec_GFp_simple_group_get_degree(const EC_GROUP *group)
276 return BN_num_bits(&group->field);
280 int ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx)
284 const BIGNUM *p = &group->field;
304 if (group->meth->field_decode)
306 if (!group->meth->field_decode(group, a, &group->a, ctx)) goto err;
307 if (!group->meth->field_decode(group, b, &group->b, ctx)) goto err;
311 if (!BN_copy(a, &group->a)) goto err;
312 if (!BN_copy(b, &group->b)) goto err;
386 int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
394 int ec_GFp_simple_set_Jprojective_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
409 if (!BN_nnmod(&point->X, x, &group->field, ctx)) goto err;
410 if (group->meth->field_encode)
412 if (!group->meth->field_encode(group, &point->X, &point->X, ctx)) goto err;
418 if (!BN_nnmod(&point->Y, y, &group->field, ctx)) goto err;
419 if (group->meth->field_encode)
421 if (!group->meth->field_encode(group, &point->Y, &point->Y, ctx)) goto err;
429 if (!BN_nnmod(&point->Z, z, &group->field, ctx)) goto err;
431 if (group->meth->field_encode)
433 if (Z_is_one && (group->meth->field_set_to_one != 0))
435 if (!group->meth->field_set_to_one(group, &point->Z, ctx)) goto err;
439 if (!group->meth->field_encode(group, &point->Z, &point->Z, ctx)) goto err;
454 int ec_GFp_simple_get_Jprojective_coordinates_GFp(const EC_GROUP *group, const EC_POINT *point,
460 if (group->meth->field_decode != 0)
471 if (!group->meth->field_decode(group, x, &point->X, ctx)) goto err;
475 if (!group->meth->field_decode(group, y, &point->Y, ctx)) goto err;
479 if (!group->meth->field_decode(group, z, &point->Z, ctx)) goto err;
507 int ec_GFp_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *point,
517 return EC_POINT_set_Jprojective_coordinates_GFp(group, point, x, y, BN_value_one(), ctx);
521 int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point,
529 if (EC_POINT_is_at_infinity(group, point))
551 if (group->meth->field_decode)
553 if (!group->meth->field_decode(group, Z, &point->Z, ctx)) goto err;
563 if (group->meth->field_decode)
567 if (!group->meth->field_decode(group, x, &point->X, ctx)) goto err;
571 if (!group->meth->field_decode(group, y, &point->Y, ctx)) goto err;
588 if (!BN_mod_inverse(Z_1, Z_, &group->field, ctx))
594 if (group->meth->field_encode == 0)
597 if (!group->meth->field_sqr(group, Z_2, Z_1, ctx)) goto err;
601 if (!BN_mod_sqr(Z_2, Z_1, &group->field, ctx)) goto err;
607 if (!group->meth->field_mul(group, x, &point->X, Z_2, ctx)) goto err;
612 if (group->meth->field_encode == 0)
615 if (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx)) goto err;
619 if (!BN_mod_mul(Z_3, Z_2, Z_1, &group->field, ctx)) goto err;
623 if (!group->meth->field_mul(group, y, &point->Y, Z_3, ctx)) goto err;
637 int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group, EC_POINT *point,
669 if (!BN_nnmod(x, x_, &group->field,ctx)) goto err;
670 if (group->meth->field_decode == 0)
673 if (!group->meth->field_sqr(group, tmp2, x_, ctx)) goto err;
674 if (!group->meth->field_mul(group, tmp1, tmp2, x_, ctx)) goto err;
678 if (!BN_mod_sqr(tmp2, x_, &group->field, ctx)) goto err;
679 if (!BN_mod_mul(tmp1, tmp2, x_, &group->field, ctx)) goto err;
683 if (group->a_is_minus3)
685 if (!BN_mod_lshift1_quick(tmp2, x, &group->field)) goto err;
686 if (!BN_mod_add_quick(tmp2, tmp2, x, &group->field)) goto err;
687 if (!BN_mod_sub_quick(tmp1, tmp1, tmp2, &group->field)) goto err;
691 if (group->meth->field_decode)
693 if (!group->meth->field_decode(group, tmp2, &group->a, ctx)) goto err;
694 if (!BN_mod_mul(tmp2, tmp2, x, &group->field, ctx)) goto err;
699 if (!group->meth->field_mul(group, tmp2, &group->a, x, ctx)) goto err;
702 if (!BN_mod_add_quick(tmp1, tmp1, tmp2, &group->field)) goto err;
706 if (group->meth->field_decode)
708 if (!group->meth->field_decode(group, tmp2, &group->b, ctx)) goto err;
709 if (!BN_mod_add_quick(tmp1, tmp1, tmp2, &group->field)) goto err;
713 if (!BN_mod_add_quick(tmp1, tmp1, &group->b, &group->field)) goto err;
716 if (!BN_mod_sqrt(y, tmp1, &group->field, ctx))
736 kron = BN_kronecker(x, &group->field, ctx);
746 if (!BN_usub(y, &group->field, y)) goto err;
754 if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) goto err;
766 size_t ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form,
783 if (EC_POINT_is_at_infinity(group, point))
800 field_len = BN_num_bytes(&group->field);
825 if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) goto err;
892 int ec_GFp_simple_oct2point(const EC_GROUP *group, EC_POINT *point,
931 return EC_POINT_set_to_infinity(group, point);
934 field_len = BN_num_bytes(&group->field);
956 if (BN_ucmp(x, &group->field) >= 0)
964 if (!EC_POINT_set_compressed_coordinates_GFp(group, point, x, y_bit, ctx)) goto err;
969 if (BN_ucmp(y, &group->field) >= 0)
983 if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) goto err;
986 if (!EC_POINT_is_on_curve(group, point, ctx)) /* test required by X9.62 */
1002 int ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
1012 return EC_POINT_dbl(group, r, a, ctx);
1013 if (EC_POINT_is_at_infinity(group, a))
1015 if (EC_POINT_is_at_infinity(group, b))
1018 field_mul = group->meth->field_mul;
1019 field_sqr = group->meth->field_sqr;
1020 p = &group->field;
1054 if (!field_sqr(group, n0, &b->Z, ctx)) goto end;
1055 if (!field_mul(group, n1, &a->X, n0, ctx)) goto end;
1058 if (!field_mul(group, n0, n0, &b->Z, ctx)) goto end;
1059 if (!field_mul(group, n2, &a->Y, n0, ctx)) goto end;
1073 if (!field_sqr(group, n0, &a->Z, ctx)) goto end;
1074 if (!field_mul(group, n3, &b->X, n0, ctx)) goto end;
1077 if (!field_mul(group, n0, n0, &a->Z, ctx)) goto end;
1078 if (!field_mul(group, n4, &b->Y, n0, ctx)) goto end;
1094 ret = EC_POINT_dbl(group, r, a, ctx);
1126 { if (!field_mul(group, n0, &a->Z, &b->Z, ctx)) goto end; }
1127 if (!field_mul(group, &r->Z, n0, n5, ctx)) goto end;
1133 if (!field_sqr(group, n0, n6, ctx)) goto end;
1134 if (!field_sqr(group, n4, n5, ctx)) goto end;
1135 if (!field_mul(group, n3, n1, n4, ctx)) goto end;
1145 if (!field_mul(group, n0, n0, n6, ctx)) goto end;
1146 if (!field_mul(group, n5, n4, n5, ctx)) goto end; /* now n5 is n5^3 */
1147 if (!field_mul(group, n1, n2, n5, ctx)) goto end;
1166 int ec_GFp_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX *ctx)
1175 if (EC_POINT_is_at_infinity(group, a))
1182 field_mul = group->meth->field_mul;
1183 field_sqr = group->meth->field_sqr;
1184 p = &group->field;
1208 if (!field_sqr(group, n0, &a->X, ctx)) goto err;
1211 if (!BN_mod_add_quick(n1, n0, &group->a, p)) goto err;
1214 else if (group->a_is_minus3)
1216 if (!field_sqr(group, n1, &a->Z, ctx)) goto err;
1219 if (!field_mul(group, n1, n0, n2, ctx)) goto err;
1227 if (!field_sqr(group, n0, &a->X, ctx)) goto err;
1230 if (!field_sqr(group, n1, &a->Z, ctx)) goto err;
1231 if (!field_sqr(group, n1, n1, ctx)) goto err;
1232 if (!field_mul(group, n1, n1, &group->a, ctx)) goto err;
1244 if (!field_mul(group, n0, &a->Y, &a->Z, ctx)) goto err;
1251 if (!field_sqr(group, n3, &a->Y, ctx)) goto err;
1252 if (!field_mul(group, n2, &a->X, n3, ctx)) goto err;
1258 if (!field_sqr(group, &r->X, n1, ctx)) goto err;
1263 if (!field_sqr(group, n0, n3, ctx)) goto err;
1269 if (!field_mul(group, n0, n1, n0, ctx)) goto err;
1283 int ec_GFp_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
1285 if (EC_POINT_is_at_infinity(group, point) || BN_is_zero(&point->Y))
1289 return BN_usub(&point->Y, &group->field, &point->Y);
1293 int ec_GFp_simple_is_at_infinity(const EC_GROUP *group, const EC_POINT *point)
1299 int ec_GFp_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX *ctx)
1308 if (EC_POINT_is_at_infinity(group, point))
1311 field_mul = group->meth->field_mul;
1312 field_sqr = group->meth->field_sqr;
1313 p = &group->field;
1339 if (!field_sqr(group, rh, &point->X, ctx)) goto err;
1343 if (!field_sqr(group, tmp, &point->Z, ctx)) goto err;
1344 if (!field_sqr(group, Z4, tmp, ctx)) goto err;
1345 if (!field_mul(group, Z6, Z4, tmp, ctx)) goto err;
1348 if (group->a_is_minus3)
1353 if (!field_mul(group, rh, rh, &point->X, ctx)) goto err;
1357 if (!field_mul(group, tmp, Z4, &group->a, ctx)) goto err;
1359 if (!field_mul(group, rh, rh, &point->X, ctx)) goto err;
1363 if (!field_mul(group, tmp, &group->b, Z6, ctx)) goto err;
1371 if (!BN_mod_add_quick(rh, rh, &group->a, p)) goto err;
1372 if (!field_mul(group, rh, rh, &point->X, ctx)) goto err;
1374 if (!BN_mod_add_quick(rh, rh, &group->b, p)) goto err;
1378 if (!field_sqr(group, tmp, &point->Y, ctx)) goto err;
1390 int ec_GFp_simple_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
1405 if (EC_POINT_is_at_infinity(group, a))
1407 return EC_POINT_is_at_infinity(group, b) ? 0 : 1;
1410 if (EC_POINT_is_at_infinity(group, b))
1418 field_mul = group->meth->field_mul;
1419 field_sqr = group->meth->field_sqr;
1443 if (!field_sqr(group, Zb23, &b->Z, ctx)) goto end;
1444 if (!field_mul(group, tmp1, &a->X, Zb23, ctx)) goto end;
1451 if (!field_sqr(group, Za23, &a->Z, ctx)) goto end;
1452 if (!field_mul(group, tmp2, &b->X, Za23, ctx)) goto end;
1468 if (!field_mul(group, Zb23, Zb23, &b->Z, ctx)) goto end;
1469 if (!field_mul(group, tmp1, &a->Y, Zb23, ctx)) goto end;
1476 if (!field_mul(group, Za23, Za23, &a->Z, ctx)) goto end;
1477 if (!field_mul(group, tmp2, &b->Y, Za23, ctx)) goto end;
1501 int ec_GFp_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx)
1507 if (point->Z_is_one || EC_POINT_is_at_infinity(group, point))
1522 if (!EC_POINT_get_affine_coordinates_GFp(group, point, x, y, ctx)) goto err;
1523 if (!EC_POINT_set_affine_coordinates_GFp(group, point, x, y, ctx)) goto err;
1540 int ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *points[], BN_CTX *ctx)
1580 if (group->meth->field_set_to_one != 0)
1582 if (!group->meth->field_set_to_one(group, prod_Z[0], ctx)) goto err;
1594 if (!group->meth->field_mul(group, prod_Z[i], prod_Z[i - 1], &points[i]->Z, ctx)) goto err;
1605 if (!BN_mod_inverse(tmp, prod_Z[num - 1], &group->field, ctx))
1610 if (group->meth->field_encode != 0)
1615 if (!group->meth->field_encode(group, tmp, tmp, ctx)) goto err;
1616 if (!group->meth->field_encode(group, tmp, tmp, ctx)) goto err;
1627 if (!group->meth->field_mul(group, tmp_Z, prod_Z[i - 1], tmp, ctx)) goto err;
1629 if (!group->meth->field_mul(group, tmp, tmp, &points[i]->Z, ctx)) goto err;
1651 if (!group->meth->field_sqr(group, tmp, &p->Z, ctx)) goto err;
1652 if (!group->meth->field_mul(group, &p->X, &p->X, tmp, ctx)) goto err;
1654 if (!group->meth->field_mul(group, tmp, tmp, &p->Z, ctx)) goto err;
1655 if (!group->meth->field_mul(group, &p->Y, &p->Y, tmp, ctx)) goto err;
1657 if (group->meth->field_set_to_one != 0)
1659 if (!group->meth->field_set_to_one(group, &p->Z, ctx)) goto err;
1688 int ec_GFp_simple_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
1690 return BN_mod_mul(r, a, b, &group->field, ctx);
1694 int ec_GFp_simple_field_sqr(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
1696 return BN_mod_sqr(r, a, &group->field, ctx);