From 77469fb35b36aec9b9fc2a3e1be2fbd0f80ca53f Mon Sep 17 00:00:00 2001
From: tb <>
Date: Thu, 22 Aug 2024 12:21:07 +0000
Subject: Neuter EVP_PKEY_add1_attr_by_NID()

The last consumer in openssl(1) pkcs12 has been removed, so we no longer
need this function.

ok miod
---
 src/lib/libcrypto/evp/evp_pkey.c | 41 +++++-----------------------------------
 1 file changed, 5 insertions(+), 36 deletions(-)

(limited to 'src')

diff --git a/src/lib/libcrypto/evp/evp_pkey.c b/src/lib/libcrypto/evp/evp_pkey.c
index f9100e2268..dcbd51f08d 100644
--- a/src/lib/libcrypto/evp/evp_pkey.c
+++ b/src/lib/libcrypto/evp/evp_pkey.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: evp_pkey.c,v 1.30 2024/07/14 16:06:31 tb Exp $ */
+/* $OpenBSD: evp_pkey.c,v 1.31 2024/08/22 12:21:07 tb Exp $ */
 /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
  * project 1999.
  */
@@ -142,49 +142,18 @@ error:
 LCRYPTO_ALIAS(EVP_PKEY2PKCS8);
 
 /*
- * XXX - This is only used by openssl(1) pkcs12 for the Microsoft-specific
- * NID_ms_csp_name and NID_LocalKeySet. This turns out to be the only reason
- * why attributes hangs off the EVP_PKEY struct.
+ * XXX - delete all the garbage below in the next bump.
  */
+
 int
 EVP_PKEY_add1_attr_by_NID(EVP_PKEY *pkey, int nid, int type,
     const unsigned char *bytes, int len)
 {
-	STACK_OF(X509_ATTRIBUTE) *attrs = NULL;
-	X509_ATTRIBUTE *attr = NULL;
-	int ret = 0;
-
-	if ((attr = X509_ATTRIBUTE_create_by_NID(NULL, nid, type,
-	    bytes, len)) == NULL)
-		goto err;
-
-	if ((attrs = pkey->attributes) == NULL)
-		attrs = sk_X509_ATTRIBUTE_new_null();
-	if (attrs == NULL)
-		goto err;
-
-	if (sk_X509_ATTRIBUTE_push(attrs, attr) <= 0)
-		goto err;
-	attr = NULL;
-
-	pkey->attributes = attrs;
-	attrs = NULL;
-
-	ret = 1;
-
- err:
-	X509_ATTRIBUTE_free(attr);
-	if (attrs != pkey->attributes)
-		sk_X509_ATTRIBUTE_pop_free(attrs, X509_ATTRIBUTE_free);
-
-	return ret;
+	EVPerror(ERR_R_DISABLED);
+	return 0;
 }
 LCRYPTO_ALIAS(EVP_PKEY_add1_attr_by_NID);
 
-/*
- * XXX - delete all the garbage below in the next bump.
- */
-
 int
 EVP_PKEY_get_attr_count(const EVP_PKEY *key)
 {
-- 
cgit v1.2.3-55-g6feb