diff options
author | tb <> | 2025-01-11 13:38:42 +0000 |
---|---|---|
committer | tb <> | 2025-01-11 13:38:42 +0000 |
commit | 28b0d0a86ff16d35928ff812a03e9ae9abb97ac1 (patch) | |
tree | 7212ae9e38ac6f0ff09f3a7a9e0f3da09046e304 /src/lib/libcrypto/ec/ec_lib.c | |
parent | 8b8ce4611c101986c51d6e37d3113e60d5e1dd58 (diff) | |
download | openbsd-28b0d0a86ff16d35928ff812a03e9ae9abb97ac1.tar.gz openbsd-28b0d0a86ff16d35928ff812a03e9ae9abb97ac1.tar.bz2 openbsd-28b0d0a86ff16d35928ff812a03e9ae9abb97ac1.zip |
Inline ec_point_make_affine() in the public API
Whatever the EC_METHOD, this will always be equivalent to getting and
setting the affine coordinates, so this needs no dedicated method.
Also, this is a function that makes no real sense since a caller should
never need to care about this... As always, our favorite language bindings
thought they might have users who care. This time it's Ruby and Perl.
ok jsing
Diffstat (limited to '')
-rw-r--r-- | src/lib/libcrypto/ec/ec_lib.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index d7f0bc6358..c2a5545c30 100644 --- a/src/lib/libcrypto/ec/ec_lib.c +++ b/src/lib/libcrypto/ec/ec_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ec_lib.c,v 1.105 2025/01/09 11:35:46 tb Exp $ */ | 1 | /* $OpenBSD: ec_lib.c,v 1.106 2025/01/11 13:38:42 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
4 | */ | 4 | */ |
@@ -1229,6 +1229,7 @@ int | |||
1229 | EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx_in) | 1229 | EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx_in) |
1230 | { | 1230 | { |
1231 | BN_CTX *ctx; | 1231 | BN_CTX *ctx; |
1232 | BIGNUM *x, *y; | ||
1232 | int ret = 0; | 1233 | int ret = 0; |
1233 | 1234 | ||
1234 | if ((ctx = ctx_in) == NULL) | 1235 | if ((ctx = ctx_in) == NULL) |
@@ -1236,17 +1237,29 @@ EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx_in) | |||
1236 | if (ctx == NULL) | 1237 | if (ctx == NULL) |
1237 | goto err; | 1238 | goto err; |
1238 | 1239 | ||
1239 | if (group->meth->make_affine == NULL) { | 1240 | BN_CTX_start(ctx); |
1240 | ECerror(ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED); | 1241 | |
1242 | if ((x = BN_CTX_get(ctx)) == NULL) | ||
1241 | goto err; | 1243 | goto err; |
1242 | } | 1244 | if ((y = BN_CTX_get(ctx)) == NULL) |
1243 | if (group->meth != point->meth) { | 1245 | goto err; |
1244 | ECerror(EC_R_INCOMPATIBLE_OBJECTS); | 1246 | |
1247 | if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)) | ||
1248 | goto err; | ||
1249 | if (!EC_POINT_set_affine_coordinates(group, point, x, y, ctx)) | ||
1250 | goto err; | ||
1251 | |||
1252 | /* XXX - is this the right spot for this check? */ | ||
1253 | if (!point->Z_is_one) { | ||
1254 | ECerror(ERR_R_INTERNAL_ERROR); | ||
1245 | goto err; | 1255 | goto err; |
1246 | } | 1256 | } |
1247 | ret = group->meth->make_affine(group, point, ctx); | 1257 | |
1258 | ret = 1; | ||
1248 | 1259 | ||
1249 | err: | 1260 | err: |
1261 | BN_CTX_end(ctx); | ||
1262 | |||
1250 | if (ctx != ctx_in) | 1263 | if (ctx != ctx_in) |
1251 | BN_CTX_free(ctx); | 1264 | BN_CTX_free(ctx); |
1252 | 1265 | ||