summaryrefslogtreecommitdiffstats
path: root/crypto/ec/ec_oct.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_oct.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_oct.c')
-rw-r--r--crypto/ec/ec_oct.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/crypto/ec/ec_oct.c b/crypto/ec/ec_oct.c
index 040c414a33..fca50dc6bf 100644
--- a/crypto/ec/ec_oct.c
+++ b/crypto/ec/ec_oct.c
@@ -190,3 +190,24 @@ int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *point,
}
return group->meth->oct2point(group, point, buf, len, ctx);
}
+
+size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point,
+ point_conversion_form_t form,
+ unsigned char **pbuf, BN_CTX *ctx)
+{
+ size_t len;
+ unsigned char *buf;
+ len = EC_POINT_point2oct(group, point, form, NULL, 0, NULL);
+ if (len == 0)
+ return 0;
+ buf = OPENSSL_malloc(len);
+ if (buf == NULL)
+ return 0;
+ len = EC_POINT_point2oct(group, point, form, buf, len, ctx);
+ if (len == 0) {
+ OPENSSL_free(buf);
+ return 0;
+ }
+ *pbuf = buf;
+ return len;
+}