From 3e6214259165b7da17edee3f76bb95cfafe0c5a4 Mon Sep 17 00:00:00 2001 From: tb <> Date: Wed, 30 Oct 2024 17:51:35 +0000 Subject: Rewrite BN_hex2point() This can do the reverse dance: chain BN_hex2bn() with EC_POINT_bn2point(). ok jsing --- src/lib/libcrypto/ec/ec_print.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libcrypto/ec/ec_print.c b/src/lib/libcrypto/ec/ec_print.c index 698d2be484..be5f845423 100644 --- a/src/lib/libcrypto/ec/ec_print.c +++ b/src/lib/libcrypto/ec/ec_print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_print.c,v 1.17 2024/10/30 17:49:27 tb Exp $ */ +/* $OpenBSD: ec_print.c,v 1.18 2024/10/30 17:51:35 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -137,19 +137,20 @@ EC_POINT_point2hex(const EC_GROUP *group, const EC_POINT *point, LCRYPTO_ALIAS(EC_POINT_point2hex); EC_POINT * -EC_POINT_hex2point(const EC_GROUP *group, const char *buf, - EC_POINT *point, BN_CTX *ctx) +EC_POINT_hex2point(const EC_GROUP *group, const char *hex, + EC_POINT *in_point, BN_CTX *ctx) { - EC_POINT *ret = NULL; - BIGNUM *tmp_bn = NULL; - - if (BN_hex2bn(&tmp_bn, buf) == 0) - return NULL; + EC_POINT *point = NULL; + BIGNUM *bn = NULL; - ret = EC_POINT_bn2point(group, tmp_bn, point, ctx); + if (BN_hex2bn(&bn, hex) == 0) + goto err; + if ((point = EC_POINT_bn2point(group, bn, in_point, ctx)) == NULL) + goto err; - BN_free(tmp_bn); + err: + BN_free(bn); - return ret; + return point; } LCRYPTO_ALIAS(EC_POINT_hex2point); -- cgit v1.2.3-55-g6feb