summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2024-11-08 13:55:46 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2024-11-08 13:55:46 +0000
commit247f864c9133505d3978547b1c1fe549b06c0bf4 (patch)
treeb25d3ec5ddc99d03f287d2b72806182a52f759b2 /lib
parent7c34c2fe7933ffb675aeca48d3c5f3d0ce05e10d (diff)
Relocate ECParameters_dup() to ec_asn1
jsing rightly points out that this has nothing to do with ASN.1, but ec_lib.c has no EC_KEY knowledge otherwise (it's about groups and points) and moving it to ec_key.c is also not satisfactory since the weird d2i/i2d for ECParameters don't belong there either. no objection from jsing
Diffstat (limited to 'lib')
-rw-r--r--lib/libcrypto/ec/ec_asn1.c24
-rw-r--r--lib/libcrypto/ec/ec_lib.c24
2 files changed, 24 insertions, 24 deletions
diff --git a/lib/libcrypto/ec/ec_asn1.c b/lib/libcrypto/ec/ec_asn1.c
index 006ad7662a0..ed7bae16b94 100644
--- a/lib/libcrypto/ec/ec_asn1.c
+++ b/lib/libcrypto/ec/ec_asn1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ec_asn1.c,v 1.105 2024/11/02 19:21:24 tb Exp $ */
+/* $OpenBSD: ec_asn1.c,v 1.106 2024/11/08 13:55:45 tb Exp $ */
/*
* Written by Nils Larsch for the OpenSSL project.
*/
@@ -1403,6 +1403,28 @@ d2i_ECParameters(EC_KEY **out_ec_key, const unsigned char **in, long len)
LCRYPTO_ALIAS(d2i_ECParameters);
EC_KEY *
+ECParameters_dup(EC_KEY *key)
+{
+ const unsigned char *p;
+ unsigned char *der = NULL;
+ EC_KEY *dup = NULL;
+ int len;
+
+ if (key == NULL)
+ return NULL;
+
+ if ((len = i2d_ECParameters(key, &der)) <= 0)
+ return NULL;
+
+ p = der;
+ dup = d2i_ECParameters(NULL, &p, len);
+ freezero(der, len);
+
+ return dup;
+}
+LCRYPTO_ALIAS(ECParameters_dup);
+
+EC_KEY *
o2i_ECPublicKey(EC_KEY **in_ec_key, const unsigned char **in, long len)
{
EC_KEY *ec_key = NULL;
diff --git a/lib/libcrypto/ec/ec_lib.c b/lib/libcrypto/ec/ec_lib.c
index f409df1a7ba..d61dea9f125 100644
--- a/lib/libcrypto/ec/ec_lib.c
+++ b/lib/libcrypto/ec/ec_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ec_lib.c,v 1.84 2024/11/08 01:33:20 tb Exp $ */
+/* $OpenBSD: ec_lib.c,v 1.85 2024/11/08 13:55:45 tb Exp $ */
/*
* Originally written by Bodo Moeller for the OpenSSL project.
*/
@@ -1436,25 +1436,3 @@ ec_group_simple_order_bits(const EC_GROUP *group)
#endif
return BN_num_bits(&group->order);
}
-
-EC_KEY *
-ECParameters_dup(EC_KEY *key)
-{
- const unsigned char *p;
- unsigned char *der = NULL;
- EC_KEY *dup = NULL;
- int len;
-
- if (key == NULL)
- return NULL;
-
- if ((len = i2d_ECParameters(key, &der)) <= 0)
- return NULL;
-
- p = der;
- dup = d2i_ECParameters(NULL, &p, len);
- freezero(der, len);
-
- return dup;
-}
-LCRYPTO_ALIAS(ECParameters_dup);