summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2015-10-13 15:25:19 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2015-10-13 15:25:19 +0000
commit5bb0fede4645a094e76e8e8bca13e45a72924db7 (patch)
treec3fd315de66cb1ef9aa90066327393657ee35ab7
parent3e9b68198b611579eeea480030abf6b0df7b355d (diff)
Convert ECParameters_dup() from a macro that uses ASN1_dup_of() into an
actual function. This removes the last ASN1_dup_of usage from the tree. Feedback from doug@ and miod@
-rw-r--r--lib/libssl/src/crypto/ec/ec.h5
-rw-r--r--lib/libssl/src/crypto/ec/ec_lib.c18
-rw-r--r--lib/libssl/src/doc/crypto/ec.pod2
3 files changed, 20 insertions, 5 deletions
diff --git a/lib/libssl/src/crypto/ec/ec.h b/lib/libssl/src/crypto/ec/ec.h
index 3b409ff92d1..a1ece2e0d56 100644
--- a/lib/libssl/src/crypto/ec/ec.h
+++ b/lib/libssl/src/crypto/ec/ec.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ec.h,v 1.10 2015/06/20 13:26:08 jsing Exp $ */
+/* $OpenBSD: ec.h,v 1.11 2015/10/13 15:25:18 jsing Exp $ */
/*
* Originally written by Bodo Moeller for the OpenSSL project.
*/
@@ -945,8 +945,7 @@ int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
*/
int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
-
-#define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
+EC_KEY *ECParameters_dup(EC_KEY *key);
#ifndef __cplusplus
#if defined(__SUNPRO_C)
diff --git a/lib/libssl/src/crypto/ec/ec_lib.c b/lib/libssl/src/crypto/ec/ec_lib.c
index c28ab18fc00..2b5abbd4bbf 100644
--- a/lib/libssl/src/crypto/ec/ec_lib.c
+++ b/lib/libssl/src/crypto/ec/ec_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ec_lib.c,v 1.19 2015/09/10 15:56:25 jsing Exp $ */
+/* $OpenBSD: ec_lib.c,v 1.20 2015/10/13 15:25:18 jsing Exp $ */
/*
* Originally written by Bodo Moeller for the OpenSSL project.
*/
@@ -1102,3 +1102,19 @@ EC_GROUP_have_precompute_mult(const EC_GROUP * group)
return 0; /* cannot tell whether precomputation has
* been performed */
}
+
+EC_KEY *
+ECParameters_dup(EC_KEY *key)
+{
+ unsigned char *p = NULL;
+ EC_KEY *k = NULL;
+ int len;
+
+ if (key == NULL)
+ return (NULL);
+
+ if ((len = i2d_ECParameters(key, &p)) > 0)
+ k = d2i_ECParameters(NULL, (const unsigned char **)&p, len);
+
+ return (k);
+}
diff --git a/lib/libssl/src/doc/crypto/ec.pod b/lib/libssl/src/doc/crypto/ec.pod
index 7d57ba8ea07..891948e4f6e 100644
--- a/lib/libssl/src/doc/crypto/ec.pod
+++ b/lib/libssl/src/doc/crypto/ec.pod
@@ -158,7 +158,7 @@ ec - Elliptic Curve functions
int EC_KEY_print(BIO *bp, const EC_KEY *key, int off);
int ECParameters_print_fp(FILE *fp, const EC_KEY *key);
int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off);
- #define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x)
+ EC_KEY *ECParameters_dup(EC_KEY *key);
#define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, EVP_PKEY_OP_PARAMGEN, \
EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL)