From 7a766feb92ce83d5cd84bd160684cb87faecf7a5 Mon Sep 17 00:00:00 2001 From: tb Date: Thu, 4 Jan 2024 16:50:53 +0000 Subject: [PATCH] Neuter the remainder of the ameth lib The few pieces of the ameth lib that will stay in libcrypto were moved to p_lib.c recently. The functions that still are in ameth_lib.c will be removed in the next major bump. With disabled EVP_PKEY_asn1_add{0,_alias}() API they are completely useless now and they are getting in the way of more ameth surgery. Rip out their guts and turn them into stubs that do nothing but push an error onto the stack. ok jsing --- lib/libcrypto/asn1/ameth_lib.c | 78 ++++++---------------------------- 1 file changed, 13 insertions(+), 65 deletions(-) diff --git a/lib/libcrypto/asn1/ameth_lib.c b/lib/libcrypto/asn1/ameth_lib.c index ccde1e8ecb5..35fcb8ea085 100644 --- a/lib/libcrypto/asn1/ameth_lib.c +++ b/lib/libcrypto/asn1/ameth_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ameth_lib.c,v 1.41 2023/12/29 19:00:31 tb Exp $ */ +/* $OpenBSD: ameth_lib.c,v 1.42 2024/01/04 16:50:53 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -71,60 +71,20 @@ EVP_PKEY_ASN1_METHOD* EVP_PKEY_asn1_new(int id, int flags, const char *pem_str, const char *info) { - EVP_PKEY_ASN1_METHOD *ameth; - - if ((ameth = calloc(1, sizeof(EVP_PKEY_ASN1_METHOD))) == NULL) - return NULL; - - ameth->pkey_id = id; - ameth->pkey_base_id = id; - ameth->pkey_flags = flags | ASN1_PKEY_DYNAMIC; - - if (info != NULL) { - if ((ameth->info = strdup(info)) == NULL) - goto err; - } - - if (pem_str != NULL) { - if ((ameth->pem_str = strdup(pem_str)) == NULL) - goto err; - } - - return ameth; - - err: - EVP_PKEY_asn1_free(ameth); + EVPerror(ERR_R_DISABLED); return NULL; } void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, const EVP_PKEY_ASN1_METHOD *src) { - EVP_PKEY_ASN1_METHOD preserve; - - preserve.pkey_id = dst->pkey_id; - preserve.pkey_base_id = dst->pkey_base_id; - preserve.pkey_flags = dst->pkey_flags; - preserve.pem_str = dst->pem_str; - preserve.info = dst->info; - - *dst = *src; - - dst->pkey_id = preserve.pkey_id; - dst->pkey_base_id = preserve.pkey_base_id; - dst->pkey_flags = preserve.pkey_flags; - dst->pem_str = preserve.pem_str; - dst->info = preserve.info; + EVPerror(ERR_R_DISABLED); } void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth) { - if (ameth && (ameth->pkey_flags & ASN1_PKEY_DYNAMIC)) { - free(ameth->pem_str); - free(ameth->info); - free(ameth); - } + EVPerror(ERR_R_DISABLED); } void @@ -137,12 +97,7 @@ EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_size)(const EVP_PKEY *pk), int (*pkey_bits)(const EVP_PKEY *pk)) { - ameth->pub_decode = pub_decode; - ameth->pub_encode = pub_encode; - ameth->pub_cmp = pub_cmp; - ameth->pub_print = pub_print; - ameth->pkey_size = pkey_size; - ameth->pkey_bits = pkey_bits; + EVPerror(ERR_R_DISABLED); } void @@ -152,9 +107,7 @@ EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth, int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx)) { - ameth->priv_decode = priv_decode; - ameth->priv_encode = priv_encode; - ameth->priv_print = priv_print; + EVPerror(ERR_R_DISABLED); } void @@ -167,54 +120,49 @@ EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth, int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent, ASN1_PCTX *pctx)) { - ameth->param_decode = param_decode; - ameth->param_encode = param_encode; - ameth->param_missing = param_missing; - ameth->param_copy = param_copy; - ameth->param_cmp = param_cmp; - ameth->param_print = param_print; + EVPerror(ERR_R_DISABLED); } void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth, void (*pkey_free)(EVP_PKEY *pkey)) { - ameth->pkey_free = pkey_free; + EVPerror(ERR_R_DISABLED); } void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2)) { - ameth->pkey_ctrl = pkey_ctrl; + EVPerror(ERR_R_DISABLED); } void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_security_bits)(const EVP_PKEY *pkey)) { - ameth->pkey_security_bits = pkey_security_bits; + EVPerror(ERR_R_DISABLED); } void EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_check)(const EVP_PKEY *pk)) { - ameth->pkey_check = pkey_check; + EVPerror(ERR_R_DISABLED); } void EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_public_check)(const EVP_PKEY *pk)) { - ameth->pkey_public_check = pkey_public_check; + EVPerror(ERR_R_DISABLED); } void EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth, int (*pkey_param_check)(const EVP_PKEY *pk)) { - ameth->pkey_param_check = pkey_param_check; + EVPerror(ERR_R_DISABLED); } int -- 2.20.1