diff options
author | tb <> | 2024-12-16 06:11:26 +0000 |
---|---|---|
committer | tb <> | 2024-12-16 06:11:26 +0000 |
commit | bbb1460f03b011099930814d5c0e38c60fb6dc84 (patch) | |
tree | c7f3921c32e77004042972fdca02e8ffcd2bacbf /src | |
parent | eebf1eabd1358d87cf8dfd8bd9bf3b595b484203 (diff) | |
download | openbsd-bbb1460f03b011099930814d5c0e38c60fb6dc84.tar.gz openbsd-bbb1460f03b011099930814d5c0e38c60fb6dc84.tar.bz2 openbsd-bbb1460f03b011099930814d5c0e38c60fb6dc84.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/ec/ec_convert.c | 11 |
1 files changed, 3 insertions, 8 deletions
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 @@ | |||
1 | /* $OpenBSD: ec_convert.c,v 1.12 2024/12/12 10:00:15 tb Exp $ */ | 1 | /* $OpenBSD: ec_convert.c,v 1.13 2024/12/16 06:11:26 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 | */ |
@@ -360,15 +360,11 @@ ec_point_to_octets(const EC_GROUP *group, const EC_POINT *point, int form, | |||
360 | 360 | ||
361 | *out_len = 0; | 361 | *out_len = 0; |
362 | 362 | ||
363 | if (out_buf != NULL && *out_buf != NULL) | 363 | if (out_buf == NULL || *out_buf != NULL) |
364 | goto err; | 364 | goto err; |
365 | 365 | ||
366 | if ((len = EC_POINT_point2oct(group, point, form, NULL, 0, ctx)) == 0) | 366 | if ((len = EC_POINT_point2oct(group, point, form, NULL, 0, ctx)) == 0) |
367 | goto err; | 367 | goto err; |
368 | |||
369 | if (out_buf == NULL) | ||
370 | goto done; | ||
371 | |||
372 | if ((buf = calloc(1, len)) == NULL) | 368 | if ((buf = calloc(1, len)) == NULL) |
373 | goto err; | 369 | goto err; |
374 | if (EC_POINT_point2oct(group, point, form, buf, len, ctx) != len) | 370 | 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, | |||
376 | 372 | ||
377 | *out_buf = buf; | 373 | *out_buf = buf; |
378 | buf = NULL; | 374 | buf = NULL; |
379 | |||
380 | done: | ||
381 | *out_len = len; | 375 | *out_len = len; |
376 | len = 0; | ||
382 | 377 | ||
383 | ret = 1; | 378 | ret = 1; |
384 | 379 | ||