From bbb1460f03b011099930814d5c0e38c60fb6dc84 Mon Sep 17 00:00:00 2001 From: tb <> Date: Mon, 16 Dec 2024 06:11:26 +0000 Subject: Simplify ec_point_to_octets() This had an extra dance to allow a NULL output buffer. The plan was to use this in i2o_ECPublicKey() to preserve the behavior of avoiding an allocation if out == NULL. However, when I rewrote the latter I punted on preserving that complication, as it was already batshit crazy enough. Thus, remove said dance and make ec_point_to_octets() cleaner. ok jsing --- src/lib/libcrypto/ec/ec_convert.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/ec/ec_convert.c b/src/lib/libcrypto/ec/ec_convert.c index f2410c163c..b48fc85315 100644 --- a/src/lib/libcrypto/ec/ec_convert.c +++ b/src/lib/libcrypto/ec/ec_convert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_convert.c,v 1.12 2024/12/12 10:00:15 tb Exp $ */ +/* $OpenBSD: ec_convert.c,v 1.13 2024/12/16 06:11:26 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -360,15 +360,11 @@ ec_point_to_octets(const EC_GROUP *group, const EC_POINT *point, int form, *out_len = 0; - if (out_buf != NULL && *out_buf != NULL) + if (out_buf == NULL || *out_buf != NULL) goto err; if ((len = EC_POINT_point2oct(group, point, form, NULL, 0, ctx)) == 0) goto err; - - if (out_buf == NULL) - goto done; - if ((buf = calloc(1, len)) == NULL) goto err; if (EC_POINT_point2oct(group, point, form, buf, len, ctx) != len) @@ -376,9 +372,8 @@ ec_point_to_octets(const EC_GROUP *group, const EC_POINT *point, int form, *out_buf = buf; buf = NULL; - - done: *out_len = len; + len = 0; ret = 1; -- cgit v1.2.3-55-g6feb