summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2024-10-30 17:51:36 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2024-10-30 17:51:36 +0000
commit11248f787c06db7df9d4b3dcf4819b16291f469b (patch)
tree1c86b17e3f23d5085a9c11d22edac96275e58dae /lib
parentfb6e0ad420fd6c7ecb8c23fe744aa81bfbc8f822 (diff)
Rewrite BN_hex2point()
This can do the reverse dance: chain BN_hex2bn() with EC_POINT_bn2point(). ok jsing
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/ec/ec_print.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/libcrypto/ec/ec_print.c b/lib/libcrypto/ec/ec_print.c
index 698d2be4847..be5f845423b 100644
--- a/lib/libcrypto/ec/ec_print.c
+++ b/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);