diff options
| author | tb <> | 2024-12-16 06:11:26 +0000 |
|---|---|---|
| committer | tb <> | 2024-12-16 06:11:26 +0000 |
| commit | b19d3762a5c9d4830000c9ee4a3b5562f5007ad4 (patch) | |
| tree | c7f3921c32e77004042972fdca02e8ffcd2bacbf /src/lib/libc | |
| parent | d58b796ca7988e98492204651c5af157949d8308 (diff) | |
| download | openbsd-b19d3762a5c9d4830000c9ee4a3b5562f5007ad4.tar.gz openbsd-b19d3762a5c9d4830000c9ee4a3b5562f5007ad4.tar.bz2 openbsd-b19d3762a5c9d4830000c9ee4a3b5562f5007ad4.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 '')
| -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 | ||
