From 2b5e1227bde04f03fa254822d743dc87981e5ed1 Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 25 Apr 2023 19:08:30 +0000 Subject: [PATCH] Move low level BIO_new_NDEF API to internal-only --- lib/libcrypto/asn1/asn1.h | 18 +----------------- lib/libcrypto/asn1/asn1_local.h | 15 ++++++++++++++- lib/libcrypto/asn1/bio_ndef.c | 6 ++++-- lib/libcrypto/cms/cms_io.c | 3 ++- lib/libcrypto/pkcs7/bio_pk7.c | 8 +++++--- lib/libcrypto/pkcs7/pk7_mime.c | 4 +++- 6 files changed, 29 insertions(+), 25 deletions(-) diff --git a/lib/libcrypto/asn1/asn1.h b/lib/libcrypto/asn1/asn1.h index 8b224c15356..5be4668be0a 100644 --- a/lib/libcrypto/asn1/asn1.h +++ b/lib/libcrypto/asn1/asn1.h @@ -1,4 +1,4 @@ -/* $OpenBSD: asn1.h,v 1.75 2023/04/24 22:12:28 tb Exp $ */ +/* $OpenBSD: asn1.h,v 1.76 2023/04/25 19:08:30 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -881,10 +881,6 @@ ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, long len, const ASN1_ITEM *it); int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); -#if !defined(LIBRESSL_NEXT_API) || defined(LIBRESSL_VERSION_NUMBER) -int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); -#endif - void ASN1_add_oid_module(void); ASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf); @@ -928,18 +924,6 @@ void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags); const BIO_METHOD *BIO_f_asn1(void); -#if !defined(LIBRESSL_NEXT_API) || defined(LIBRESSL_INTERNAL) -BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it); - -int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, - const ASN1_ITEM *it); -int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, - const char *hdr, const ASN1_ITEM *it); -int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, - int ctype_nid, int econt_nid, STACK_OF(X509_ALGOR) *mdalgs, - const ASN1_ITEM *it); -ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it); -#endif int SMIME_crlf_copy(BIO *in, BIO *out, int flags); int SMIME_text(BIO *in, BIO *out); diff --git a/lib/libcrypto/asn1/asn1_local.h b/lib/libcrypto/asn1/asn1_local.h index ed40e18ec96..52b8a46aebe 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.1 2022/11/26 16:08:50 tb Exp $ */ +/* $OpenBSD: asn1_local.h,v 1.2 2023/04/25 19:08:30 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2006. */ @@ -248,4 +248,17 @@ int OPENSSL_gmtime_diff(int *pday, int *psec, const struct tm *from, int asn1_time_time_t_to_tm(const time_t *time, struct tm *out_tm); int asn1_time_tm_to_time_t(const struct tm *tm, time_t *out); +int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); + +BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it); + +int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, + const ASN1_ITEM *it); +int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, + const char *hdr, const ASN1_ITEM *it); +int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, + int ctype_nid, int econt_nid, STACK_OF(X509_ALGOR) *mdalgs, + const ASN1_ITEM *it); +ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it); + __END_HIDDEN_DECLS diff --git a/lib/libcrypto/asn1/bio_ndef.c b/lib/libcrypto/asn1/bio_ndef.c index 2aa323a8984..d0329ede8f4 100644 --- a/lib/libcrypto/asn1/bio_ndef.c +++ b/lib/libcrypto/asn1/bio_ndef.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_ndef.c,v 1.21 2023/03/30 14:23:50 tb Exp $ */ +/* $OpenBSD: bio_ndef.c,v 1.22 2023/04/25 19:08:30 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -52,12 +52,14 @@ * */ +#include + #include #include #include #include -#include +#include "asn1_local.h" /* Experimental NDEF ASN1 BIO support routines */ diff --git a/lib/libcrypto/cms/cms_io.c b/lib/libcrypto/cms/cms_io.c index 685bf6ad7e1..ef1bc4bc4da 100644 --- a/lib/libcrypto/cms/cms_io.c +++ b/lib/libcrypto/cms/cms_io.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_io.c,v 1.17 2023/04/21 20:36:07 tb Exp $ */ +/* $OpenBSD: cms_io.c,v 1.18 2023/04/25 19:08:30 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -58,6 +58,7 @@ #include #include +#include "asn1_local.h" #include "cms_local.h" int diff --git a/lib/libcrypto/pkcs7/bio_pk7.c b/lib/libcrypto/pkcs7/bio_pk7.c index 83cf70fd877..e452293f7fe 100644 --- a/lib/libcrypto/pkcs7/bio_pk7.c +++ b/lib/libcrypto/pkcs7/bio_pk7.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_pk7.c,v 1.7 2023/02/16 08:38:17 tb Exp $ */ +/* $OpenBSD: bio_pk7.c,v 1.8 2023/04/25 19:08:30 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -52,11 +52,13 @@ * */ +#include + #include -#include #include +#include -#include +#include "asn1_local.h" /* Streaming encode support for PKCS#7 */ BIO * diff --git a/lib/libcrypto/pkcs7/pk7_mime.c b/lib/libcrypto/pkcs7/pk7_mime.c index d5bc031e694..cd723d71f50 100644 --- a/lib/libcrypto/pkcs7/pk7_mime.c +++ b/lib/libcrypto/pkcs7/pk7_mime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pk7_mime.c,v 1.15 2023/02/16 08:38:17 tb Exp $ */ +/* $OpenBSD: pk7_mime.c,v 1.16 2023/04/25 19:08:30 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. */ @@ -58,6 +58,8 @@ #include #include +#include "asn1_local.h" + /* PKCS#7 wrappers round generalised stream and MIME routines */ int -- 2.20.1