From c9ae38aaca3d2f08df1c80e641aecddff4204d2d Mon Sep 17 00:00:00 2001 From: tb Date: Fri, 28 Jul 2023 10:00:10 +0000 Subject: [PATCH] Make ASN1_{primitive,template}_* internal These were long removed from the public OpenSSL API, so we can do the same. Remove ASN1_template_{d2i,i2d}() - those are unused internally. ok jsing --- lib/libcrypto/Symbols.list | 6 ------ lib/libcrypto/Symbols.namespace | 6 ------ lib/libcrypto/asn1/a_type.c | 4 +++- lib/libcrypto/asn1/asn1_local.h | 8 +++++++- lib/libcrypto/asn1/asn1t.h | 9 +-------- lib/libcrypto/asn1/tasn_dec.c | 20 +------------------- lib/libcrypto/asn1/tasn_enc.c | 10 +--------- lib/libcrypto/asn1/tasn_fre.c | 4 +--- lib/libcrypto/asn1/tasn_new.c | 4 +--- lib/libcrypto/hidden/openssl/asn1t.h | 8 +------- 10 files changed, 16 insertions(+), 63 deletions(-) diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index 7dabfa1188b..2c38d67e264 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -216,16 +216,10 @@ ASN1_mbstring_ncopy ASN1_object_size ASN1_parse ASN1_parse_dump -ASN1_primitive_free -ASN1_primitive_new ASN1_put_eoc ASN1_put_object ASN1_tag2bit ASN1_tag2str -ASN1_template_d2i -ASN1_template_free -ASN1_template_i2d -ASN1_template_new ASN1_time_parse ASN1_time_tm_clamp_notafter ASN1_time_tm_cmp diff --git a/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index d1afd92c081..18d52db63c8 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/lib/libcrypto/Symbols.namespace @@ -1248,14 +1248,8 @@ _libre_BIO_vsnprintf _libre_ERR_load_BIO_strings _libre_ASN1_item_ex_new _libre_ASN1_item_ex_free -_libre_ASN1_template_new -_libre_ASN1_primitive_new -_libre_ASN1_template_free -_libre_ASN1_template_d2i _libre_ASN1_item_ex_d2i _libre_ASN1_item_ex_i2d -_libre_ASN1_template_i2d -_libre_ASN1_primitive_free _libre_EC_GFp_simple_method _libre_EC_GFp_mont_method _libre_EC_GROUP_new diff --git a/lib/libcrypto/asn1/a_type.c b/lib/libcrypto/asn1/a_type.c index e1506cdcb4f..ef0a76e8106 100644 --- a/lib/libcrypto/asn1/a_type.c +++ b/lib/libcrypto/asn1/a_type.c @@ -1,4 +1,4 @@ -/* $OpenBSD: a_type.c,v 1.26 2023/07/05 21:23:36 beck Exp $ */ +/* $OpenBSD: a_type.c,v 1.27 2023/07/28 10:00:10 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -62,6 +62,8 @@ #include #include +#include "asn1_local.h" + typedef struct { ASN1_INTEGER *num; ASN1_OCTET_STRING *value; diff --git a/lib/libcrypto/asn1/asn1_local.h b/lib/libcrypto/asn1/asn1_local.h index 0ef5101fcbe..566ace798b2 100644 --- a/lib/libcrypto/asn1/asn1_local.h +++ b/lib/libcrypto/asn1/asn1_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1_local.h,v 1.3 2023/07/28 09:58:30 tb Exp $ */ +/* $OpenBSD: asn1_local.h,v 1.4 2023/07/28 10:00:10 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -263,4 +263,10 @@ int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, const ASN1_ITEM *it); ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it); +int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it); +void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it); + +int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); +void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); + __END_HIDDEN_DECLS diff --git a/lib/libcrypto/asn1/asn1t.h b/lib/libcrypto/asn1/asn1t.h index bb49be286fd..4d79f82ec78 100644 --- a/lib/libcrypto/asn1/asn1t.h +++ b/lib/libcrypto/asn1/asn1t.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1t.h,v 1.22 2022/09/03 16:01:23 jsing Exp $ */ +/* $OpenBSD: asn1t.h,v 1.23 2023/07/28 10:00:10 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -896,17 +896,10 @@ DECLARE_STACK_OF(ASN1_VALUE) int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); -int ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); -int ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it); - -void ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt); -int ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_TEMPLATE *tt); int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, const ASN1_ITEM *it, int tag, int aclass, char opt, ASN1_TLC *ctx); int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, int tag, int aclass); -int ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt); -void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it); #ifdef __cplusplus } diff --git a/lib/libcrypto/asn1/tasn_dec.c b/lib/libcrypto/asn1/tasn_dec.c index 553cab24943..31b9efee54a 100644 --- a/lib/libcrypto/asn1/tasn_dec.c +++ b/lib/libcrypto/asn1/tasn_dec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_dec.c,v 1.87 2023/07/05 21:23:36 beck Exp $ */ +/* $OpenBSD: tasn_dec.c,v 1.88 2023/07/28 10:00:10 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -1258,21 +1258,3 @@ ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long inlen, return ret; } LCRYPTO_ALIAS(ASN1_item_ex_d2i); - -int -ASN1_template_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, - const ASN1_TEMPLATE *at) -{ - CBS cbs; - int ret; - - if (len < 0) - return 0; - - CBS_init(&cbs, *in, len); - if ((ret = asn1_template_d2i(pval, &cbs, at, 0, 0)) == 1) - *in = CBS_data(&cbs); - - return ret; -} -LCRYPTO_ALIAS(ASN1_template_d2i); diff --git a/lib/libcrypto/asn1/tasn_enc.c b/lib/libcrypto/asn1/tasn_enc.c index be0579f840c..b71993a139a 100644 --- a/lib/libcrypto/asn1/tasn_enc.c +++ b/lib/libcrypto/asn1/tasn_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_enc.c,v 1.32 2023/07/05 21:23:36 beck Exp $ */ +/* $OpenBSD: tasn_enc.c,v 1.33 2023/07/28 10:00:10 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -271,14 +271,6 @@ ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_ITEM *it, } LCRYPTO_ALIAS(ASN1_item_ex_i2d); -int -ASN1_template_i2d(ASN1_VALUE **pval, unsigned char **out, - const ASN1_TEMPLATE *tt) -{ - return asn1_template_ex_i2d(pval, out, tt, -1, 0); -} -LCRYPTO_ALIAS(ASN1_template_i2d); - static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out, const ASN1_TEMPLATE *tt, int tag, int iclass) diff --git a/lib/libcrypto/asn1/tasn_fre.c b/lib/libcrypto/asn1/tasn_fre.c index eb205dd6ab1..83c073b55db 100644 --- a/lib/libcrypto/asn1/tasn_fre.c +++ b/lib/libcrypto/asn1/tasn_fre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_fre.c,v 1.22 2023/07/05 21:23:36 beck Exp $ */ +/* $OpenBSD: tasn_fre.c,v 1.23 2023/07/28 10:00:10 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -185,7 +185,6 @@ ASN1_template_free(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) } else asn1_item_free(pval, tt->item); } -LCRYPTO_ALIAS(ASN1_template_free); void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) @@ -242,4 +241,3 @@ ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) } *pval = NULL; } -LCRYPTO_ALIAS(ASN1_primitive_free); diff --git a/lib/libcrypto/asn1/tasn_new.c b/lib/libcrypto/asn1/tasn_new.c index 555267c48fd..10c1137dbf1 100644 --- a/lib/libcrypto/asn1/tasn_new.c +++ b/lib/libcrypto/asn1/tasn_new.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tasn_new.c,v 1.24 2023/07/05 21:23:36 beck Exp $ */ +/* $OpenBSD: tasn_new.c,v 1.25 2023/07/28 10:00:10 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2000. */ @@ -248,7 +248,6 @@ ASN1_template_new(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) done: return ret; } -LCRYPTO_ALIAS(ASN1_template_new); static void asn1_template_clear(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt) @@ -318,7 +317,6 @@ ASN1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it) return 1; return 0; } -LCRYPTO_ALIAS(ASN1_primitive_new); static void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) diff --git a/lib/libcrypto/hidden/openssl/asn1t.h b/lib/libcrypto/hidden/openssl/asn1t.h index d37d1dbbc09..666dea564c4 100644 --- a/lib/libcrypto/hidden/openssl/asn1t.h +++ b/lib/libcrypto/hidden/openssl/asn1t.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1t.h,v 1.2 2023/07/07 19:37:54 beck Exp $ */ +/* $OpenBSD: asn1t.h,v 1.3 2023/07/28 10:00:10 tb Exp $ */ /* * Copyright (c) 2023 Bob Beck * @@ -27,13 +27,7 @@ LCRYPTO_USED(ASN1_item_ex_new); LCRYPTO_USED(ASN1_item_ex_free); -LCRYPTO_USED(ASN1_template_new); -LCRYPTO_USED(ASN1_primitive_new); -LCRYPTO_USED(ASN1_template_free); -LCRYPTO_USED(ASN1_template_d2i); LCRYPTO_USED(ASN1_item_ex_d2i); LCRYPTO_USED(ASN1_item_ex_i2d); -LCRYPTO_USED(ASN1_template_i2d); -LCRYPTO_USED(ASN1_primitive_free); #endif /* _LIBCRYPTO_ASN1T_H */ -- 2.20.1