Reorganise ECC code so it can use FIPS module.
Move compression, point2oct and oct2point functions into separate files. Add a flags field to EC_METHOD. Add a flag EC_FLAGS_DEFAULT_OCT to use the default compession and oct functions (all existing methods do this). This removes dependencies from EC_METHOD while keeping original functionality. Backport from HEAD with minor changes.
This commit is contained in:
@@ -908,74 +908,6 @@ int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, const EC_POINT *
|
||||
}
|
||||
#endif
|
||||
|
||||
int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, EC_POINT *point,
|
||||
const BIGNUM *x, int y_bit, BN_CTX *ctx)
|
||||
{
|
||||
if (group->meth->point_set_compressed_coordinates == 0)
|
||||
{
|
||||
ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||
return 0;
|
||||
}
|
||||
if (group->meth != point->meth)
|
||||
{
|
||||
ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP, EC_R_INCOMPATIBLE_OBJECTS);
|
||||
return 0;
|
||||
}
|
||||
return group->meth->point_set_compressed_coordinates(group, point, x, y_bit, ctx);
|
||||
}
|
||||
|
||||
#ifndef OPENSSL_NO_EC2M
|
||||
int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, EC_POINT *point,
|
||||
const BIGNUM *x, int y_bit, BN_CTX *ctx)
|
||||
{
|
||||
if (group->meth->point_set_compressed_coordinates == 0)
|
||||
{
|
||||
ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||
return 0;
|
||||
}
|
||||
if (group->meth != point->meth)
|
||||
{
|
||||
ECerr(EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M, EC_R_INCOMPATIBLE_OBJECTS);
|
||||
return 0;
|
||||
}
|
||||
return group->meth->point_set_compressed_coordinates(group, point, x, y_bit, ctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form,
|
||||
unsigned char *buf, size_t len, BN_CTX *ctx)
|
||||
{
|
||||
if (group->meth->point2oct == 0)
|
||||
{
|
||||
ECerr(EC_F_EC_POINT_POINT2OCT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||
return 0;
|
||||
}
|
||||
if (group->meth != point->meth)
|
||||
{
|
||||
ECerr(EC_F_EC_POINT_POINT2OCT, EC_R_INCOMPATIBLE_OBJECTS);
|
||||
return 0;
|
||||
}
|
||||
return group->meth->point2oct(group, point, form, buf, len, ctx);
|
||||
}
|
||||
|
||||
|
||||
int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point,
|
||||
const unsigned char *buf, size_t len, BN_CTX *ctx)
|
||||
{
|
||||
if (group->meth->oct2point == 0)
|
||||
{
|
||||
ECerr(EC_F_EC_POINT_OCT2POINT, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
|
||||
return 0;
|
||||
}
|
||||
if (group->meth != point->meth)
|
||||
{
|
||||
ECerr(EC_F_EC_POINT_OCT2POINT, EC_R_INCOMPATIBLE_OBJECTS);
|
||||
return 0;
|
||||
}
|
||||
return group->meth->oct2point(group, point, buf, len, ctx);
|
||||
}
|
||||
|
||||
|
||||
int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const EC_POINT *b, BN_CTX *ctx)
|
||||
{
|
||||
if (group->meth->add == 0)
|
||||
|
||||
Reference in New Issue
Block a user