summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2024-11-08 13:55:45 +0000
committertb <>2024-11-08 13:55:45 +0000
commit00706f427c9e58afa96c67c4b88a12253b656f4a (patch)
tree15461b9d3cf10fd9ae1208ef616b666b1da3c065 /src/lib
parentf631c6b6c7297cc0d3ef18ebf1277dc9b7d3d70d (diff)
downloadopenbsd-00706f427c9e58afa96c67c4b88a12253b656f4a.tar.gz
openbsd-00706f427c9e58afa96c67c4b88a12253b656f4a.tar.bz2
openbsd-00706f427c9e58afa96c67c4b88a12253b656f4a.zip
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 'src/lib')
-rw-r--r--src/lib/libcrypto/ec/ec_asn1.c24
-rw-r--r--src/lib/libcrypto/ec/ec_lib.c24
2 files changed, 24 insertions, 24 deletions
diff --git a/src/lib/libcrypto/ec/ec_asn1.c b/src/lib/libcrypto/ec/ec_asn1.c
index 006ad7662a..ed7bae16b9 100644
--- a/src/lib/libcrypto/ec/ec_asn1.c
+++ b/src/lib/libcrypto/ec/ec_asn1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_asn1.c,v 1.105 2024/11/02 19:21:24 tb Exp $ */ 1/* $OpenBSD: ec_asn1.c,v 1.106 2024/11/08 13:55:45 tb Exp $ */
2/* 2/*
3 * Written by Nils Larsch for the OpenSSL project. 3 * Written by Nils Larsch for the OpenSSL project.
4 */ 4 */
@@ -1403,6 +1403,28 @@ d2i_ECParameters(EC_KEY **out_ec_key, const unsigned char **in, long len)
1403LCRYPTO_ALIAS(d2i_ECParameters); 1403LCRYPTO_ALIAS(d2i_ECParameters);
1404 1404
1405EC_KEY * 1405EC_KEY *
1406ECParameters_dup(EC_KEY *key)
1407{
1408 const unsigned char *p;
1409 unsigned char *der = NULL;
1410 EC_KEY *dup = NULL;
1411 int len;
1412
1413 if (key == NULL)
1414 return NULL;
1415
1416 if ((len = i2d_ECParameters(key, &der)) <= 0)
1417 return NULL;
1418
1419 p = der;
1420 dup = d2i_ECParameters(NULL, &p, len);
1421 freezero(der, len);
1422
1423 return dup;
1424}
1425LCRYPTO_ALIAS(ECParameters_dup);
1426
1427EC_KEY *
1406o2i_ECPublicKey(EC_KEY **in_ec_key, const unsigned char **in, long len) 1428o2i_ECPublicKey(EC_KEY **in_ec_key, const unsigned char **in, long len)
1407{ 1429{
1408 EC_KEY *ec_key = NULL; 1430 EC_KEY *ec_key = NULL;
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c
index f409df1a7b..d61dea9f12 100644
--- a/src/lib/libcrypto/ec/ec_lib.c
+++ b/src/lib/libcrypto/ec/ec_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ec_lib.c,v 1.84 2024/11/08 01:33:20 tb Exp $ */ 1/* $OpenBSD: ec_lib.c,v 1.85 2024/11/08 13:55:45 tb Exp $ */
2/* 2/*
3 * Originally written by Bodo Moeller for the OpenSSL project. 3 * Originally written by Bodo Moeller for the OpenSSL project.
4 */ 4 */
@@ -1436,25 +1436,3 @@ ec_group_simple_order_bits(const EC_GROUP *group)
1436#endif 1436#endif
1437 return BN_num_bits(&group->order); 1437 return BN_num_bits(&group->order);
1438} 1438}
1439
1440EC_KEY *
1441ECParameters_dup(EC_KEY *key)
1442{
1443 const unsigned char *p;
1444 unsigned char *der = NULL;
1445 EC_KEY *dup = NULL;
1446 int len;
1447
1448 if (key == NULL)
1449 return NULL;
1450
1451 if ((len = i2d_ECParameters(key, &der)) <= 0)
1452 return NULL;
1453
1454 p = der;
1455 dup = d2i_ECParameters(NULL, &p, len);
1456 freezero(der, len);
1457
1458 return dup;
1459}
1460LCRYPTO_ALIAS(ECParameters_dup);