actual function. This removes the last ASN1_dup_of usage from the tree.
Feedback from doug@ and miod@
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)
-/* $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.
*/
*/
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)
-/* $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.
*/
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);
+}
-/* $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.
*/
*/
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)
-/* $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.
*/
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);
+}
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)