summaryrefslogtreecommitdiffstats
path: root/crypto/ec/ec_print.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2015-12-12 01:04:25 +0000
committerDr. Stephen Henson <steve@openssl.org>2015-12-16 14:17:53 +0000
commit981bd8a2f28c17f774ecb8b60233858fe52db502 (patch)
tree2416ede4d9418b3ae878463bf5fb21a54ad1b9a3 /crypto/ec/ec_print.c
parent19a86b03010c111d4e05ce252247e30f0e940dad (diff)
New EC functions.
New functions EC_POINT_point2buf and EC_KEY_key2buf which encode a point and allocate a buffer in one call. New function EC_KEY_oct2key() which sets public key in an EC_KEY structure from an encoded point. Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/ec/ec_print.c')
-rw-r--r--crypto/ec/ec_print.c24
1 files changed, 5 insertions, 19 deletions
diff --git a/crypto/ec/ec_print.c b/crypto/ec/ec_print.c
index 5ae85ccdb0..7bc0760c5b 100644
--- a/crypto/ec/ec_print.c
+++ b/crypto/ec/ec_print.c
@@ -64,17 +64,10 @@ BIGNUM *EC_POINT_point2bn(const EC_GROUP *group,
size_t buf_len = 0;
unsigned char *buf;
- buf_len = EC_POINT_point2oct(group, point, form, NULL, 0, ctx);
- if (buf_len == 0)
- return NULL;
-
- if ((buf = OPENSSL_malloc(buf_len)) == NULL)
- return NULL;
+ buf_len = EC_POINT_point2buf(group, point, form, &buf, ctx);
- if (!EC_POINT_point2oct(group, point, form, buf, buf_len, ctx)) {
- OPENSSL_free(buf);
+ if (buf_len == 0)
return NULL;
- }
ret = BN_bin2bn(buf, buf_len, ret);
@@ -129,19 +122,12 @@ char *EC_POINT_point2hex(const EC_GROUP *group,
{
char *ret, *p;
size_t buf_len = 0, i;
- unsigned char *buf, *pbuf;
+ unsigned char *buf = NULL, *pbuf;
- buf_len = EC_POINT_point2oct(group, point, form, NULL, 0, ctx);
- if (buf_len == 0)
- return NULL;
-
- if ((buf = OPENSSL_malloc(buf_len)) == NULL)
- return NULL;
+ buf_len = EC_POINT_point2buf(group, point, form, &buf, ctx);
- if (!EC_POINT_point2oct(group, point, form, buf, buf_len, ctx)) {
- OPENSSL_free(buf);
+ if (buf_len == 0)
return NULL;
- }
ret = OPENSSL_malloc(buf_len * 2 + 2);
if (ret == NULL) {