summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2024-10-30 17:36:22 +0000
committertb <>2024-10-30 17:36:22 +0000
commitf174b640b45fb43e39517a8614a0e8215bad9c13 (patch)
tree59b6efe5a80d27b78810a2f0fb9a903d6823f80e /src
parent81a85e7f68dbeb3507c10c8bf69c0ba56749d71c (diff)
downloadopenbsd-f174b640b45fb43e39517a8614a0e8215bad9c13.tar.gz
openbsd-f174b640b45fb43e39517a8614a0e8215bad9c13.tar.bz2
openbsd-f174b640b45fb43e39517a8614a0e8215bad9c13.zip
Rewrite EC_POINT_point2bn()
While it makes little sens to place either one of the uncompressed, the compressed or the hybrid X9.62 octet string encoding of an elliptic curve point into a BIGNUM, it is what this API does. It's ec_point_to_octets() followed by BN_bin2bn(). ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/ec/ec_print.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/lib/libcrypto/ec/ec_print.c b/src/lib/libcrypto/ec/ec_print.c
index d0c9585007..d8261a94f5 100644
--- a/src/lib/libcrypto/ec/ec_print.c
+++ b/src/lib/libcrypto/ec/ec_print.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_print.c,v 1.15 2024/10/28 17:00:51 tb Exp $ */ 1/* $OpenBSD: ec_print.c,v 1.16 2024/10/30 17:36:22 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -62,27 +62,21 @@
62 62
63BIGNUM * 63BIGNUM *
64EC_POINT_point2bn(const EC_GROUP *group, const EC_POINT *point, 64EC_POINT_point2bn(const EC_GROUP *group, const EC_POINT *point,
65 point_conversion_form_t form, BIGNUM *ret, BN_CTX *ctx) 65 point_conversion_form_t form, BIGNUM *in_bn, BN_CTX *ctx)
66{ 66{
67 BIGNUM *bn = NULL;
68 unsigned char *buf = NULL;
67 size_t buf_len = 0; 69 size_t buf_len = 0;
68 unsigned char *buf;
69
70 buf_len = EC_POINT_point2oct(group, point, form, NULL, 0, ctx);
71 if (buf_len == 0)
72 return NULL;
73
74 if ((buf = malloc(buf_len)) == NULL)
75 return NULL;
76 70
77 if (!EC_POINT_point2oct(group, point, form, buf, buf_len, ctx)) { 71 if (!ec_point_to_octets(group, point, form, &buf, &buf_len, ctx))
78 free(buf); 72 goto err;
79 return NULL; 73 if ((bn = BN_bin2bn(buf, buf_len, in_bn)) == NULL)
80 } 74 goto err;
81 ret = BN_bin2bn(buf, buf_len, ret);
82 75
83 free(buf); 76 err:
77 freezero(buf, buf_len);
84 78
85 return ret; 79 return bn;
86} 80}
87LCRYPTO_ALIAS(EC_POINT_point2bn); 81LCRYPTO_ALIAS(EC_POINT_point2bn);
88 82