diff options
Diffstat (limited to 'src/crypto/ec/oct.c')
-rw-r--r-- | src/crypto/ec/oct.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/crypto/ec/oct.c b/src/crypto/ec/oct.c index 365dc3d..cb50e17 100644 --- a/src/crypto/ec/oct.c +++ b/src/crypto/ec/oct.c @@ -277,21 +277,39 @@ err: int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point, const uint8_t *buf, size_t len, BN_CTX *ctx) { + if (group->meth->oct2point == 0 && + !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { + OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } if (group->meth != point->meth) { OPENSSL_PUT_ERROR(EC, EC_R_INCOMPATIBLE_OBJECTS); return 0; } - return ec_GFp_simple_oct2point(group, point, buf, len, ctx); + if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) { + return ec_GFp_simple_oct2point(group, point, buf, len, ctx); + } + + return group->meth->oct2point(group, point, buf, len, ctx); } size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *point, point_conversion_form_t form, uint8_t *buf, size_t len, BN_CTX *ctx) { + if (group->meth->point2oct == 0 && + !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { + OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } if (group->meth != point->meth) { OPENSSL_PUT_ERROR(EC, EC_R_INCOMPATIBLE_OBJECTS); return 0; } - return ec_GFp_simple_point2oct(group, point, form, buf, len, ctx); + if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) { + return ec_GFp_simple_point2oct(group, point, form, buf, len, ctx); + } + + return group->meth->point2oct(group, point, form, buf, len, ctx); } int ec_GFp_simple_set_compressed_coordinates(const EC_GROUP *group, @@ -434,9 +452,19 @@ err: 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 && + !(group->meth->flags & EC_FLAGS_DEFAULT_OCT)) { + OPENSSL_PUT_ERROR(EC, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); + return 0; + } if (group->meth != point->meth) { OPENSSL_PUT_ERROR(EC, EC_R_INCOMPATIBLE_OBJECTS); return 0; } - return ec_GFp_simple_set_compressed_coordinates(group, point, x, y_bit, ctx); + if (group->meth->flags & EC_FLAGS_DEFAULT_OCT) { + return ec_GFp_simple_set_compressed_coordinates(group, point, x, y_bit, + ctx); + } + return group->meth->point_set_compressed_coordinates(group, point, x, y_bit, + ctx); } |