Convert ZLIB defines to OPENSSL_NO_ZLIB

Use the normal OPENSSL_NO_ prefix to enable/disable ZLIB
Make `BIO_f_zlib()` always available.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18186)
This commit is contained in:
Todd Short 2022-08-17 17:36:27 -04:00 committed by Todd Short
parent caf9317d7d
commit 59d21298df
11 changed files with 26 additions and 24 deletions

View File

@ -1845,7 +1845,7 @@ foreach my $what (sort keys %disabled) {
if (!grep { $what eq $_ } ( 'buildtest-c++', 'fips', 'threads', 'shared',
'module', 'pic', 'dynamic-engine', 'makedepend',
'zlib-dynamic', 'zlib', 'sse2', 'legacy' )) {
'sse2', 'legacy' )) {
(my $WHAT = uc $what) =~ s|-|_|g;
my $skipdir = $what;

View File

@ -91,7 +91,7 @@ const OPTIONS enc_options[] = {
{"iter", OPT_ITER, 'p', "Specify the iteration count and force use of PBKDF2"},
{"pbkdf2", OPT_PBKDF2, '-', "Use password-based key derivation function 2"},
{"none", OPT_NONE, '-', "Don't encrypt"},
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
{"z", OPT_Z, '-', "Compress or decompress encrypted data using zlib"},
#endif
{"", OPT_CIPHER, '-', "Any supported cipher"},
@ -130,7 +130,7 @@ int enc_main(int argc, char **argv)
int streamable = 1;
int wrap = 0;
struct doall_enc_ciphers dec;
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
int do_zlib = 0;
BIO *bzl = NULL;
#endif
@ -142,7 +142,7 @@ int enc_main(int argc, char **argv)
/* first check the command name */
if (strcmp(argv[0], "base64") == 0)
base64 = 1;
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
else if (strcmp(argv[0], "zlib") == 0)
do_zlib = 1;
#endif
@ -225,7 +225,7 @@ int enc_main(int argc, char **argv)
base64 = 1;
break;
case OPT_Z:
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
do_zlib = 1;
#endif
break;
@ -332,7 +332,7 @@ int enc_main(int argc, char **argv)
if (verbose)
BIO_printf(bio_err, "bufsize=%d\n", bsize);
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
if (do_zlib)
base64 = 0;
#endif
@ -417,7 +417,7 @@ int enc_main(int argc, char **argv)
wbio = out;
#ifndef OPENSSL_NO_COMP
# ifdef ZLIB
# ifndef OPENSSL_NO_ZLIB
if (do_zlib) {
if ((bzl = BIO_new(BIO_f_zlib())) == NULL)
goto end;
@ -699,7 +699,7 @@ int enc_main(int argc, char **argv)
BIO_free(b64);
EVP_MD_free(dgst);
EVP_CIPHER_free(cipher);
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
BIO_free(bzl);
#endif
BIO_free(bbrot);

View File

@ -1421,7 +1421,7 @@ static void list_disabled(void)
#ifdef OPENSSL_NO_WHIRLPOOL
BIO_puts(bio_out, "WHIRLPOOL\n");
#endif
#ifndef ZLIB
#ifdef OPENSSL_NO_ZLIB
BIO_puts(bio_out, "ZLIB\n");
#endif
#ifdef OPENSSL_NO_BROTLI

View File

@ -205,9 +205,7 @@ EOF
) {
my $str = " {FT_cipher, \"$cmd\", enc_main, enc_options, NULL},\n";
(my $algo = $cmd) =~ s/-.*//g;
if ($cmd eq "zlib") {
print "#ifdef ZLIB\n${str}#endif\n";
} elsif (grep { $algo eq $_ } @disablables) {
if (grep { $algo eq $_ } @disablables) {
print "#ifndef OPENSSL_NO_" . uc($algo) . "\n${str}#endif\n";
} elsif (my $disabler = $cipher_disabler{$algo}) {
print "#ifndef OPENSSL_NO_" . uc($disabler) . "\n${str}#endif\n";

View File

@ -17,7 +17,7 @@
#include <openssl/comp.h>
#include "cms_local.h"
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
/* CMS CompressedData Utilities */

View File

@ -174,7 +174,7 @@ BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont)
case NID_pkcs7_digest:
cmsbio = ossl_cms_DigestedData_init_bio(cms);
break;
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
case NID_id_smime_ct_compressedData:
cmsbio = ossl_cms_CompressedData_init_bio(cms);
break;

View File

@ -930,7 +930,7 @@ err:
return ret;
}
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
unsigned int flags)

View File

@ -29,7 +29,7 @@ static COMP_METHOD zlib_method_nozlib = {
NULL,
};
#ifndef ZLIB
#ifdef OPENSSL_NO_ZLIB
# undef ZLIB_SHARED
#else
@ -247,7 +247,7 @@ COMP_METHOD *COMP_zlib(void)
{
COMP_METHOD *meth = &zlib_method_nozlib;
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
if (RUN_ONCE(&zlib_once, ossl_comp_zlib_init))
meth = &zlib_stateful_method;
#endif
@ -264,7 +264,7 @@ void ossl_comp_zlib_cleanup(void)
#endif
}
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
/* Zlib based compression/decompression filter BIO */
@ -304,12 +304,18 @@ static const BIO_METHOD bio_meth_zlib = {
bio_zlib_free,
bio_zlib_callback_ctrl
};
#endif
const BIO_METHOD *BIO_f_zlib(void)
{
return &bio_meth_zlib;
#ifndef OPENSSL_NO_ZLIB
if (RUN_ONCE(&zlib_once, ossl_comp_zlib_init))
return &bio_meth_zlib;
#endif
return NULL;
}
#ifndef OPENSSL_NO_ZLIB
static int bio_zlib_new(BIO *bi)
{
BIO_ZLIB_CTX *ctx;

View File

@ -50,9 +50,7 @@ COMP_METHOD *COMP_zstd_oneshot(void);
#endif
# ifdef OPENSSL_BIO_H
# ifdef ZLIB
const BIO_METHOD *BIO_f_zlib(void);
# endif
const BIO_METHOD *BIO_f_brotli(void);
const BIO_METHOD *BIO_f_zstd(void);
# endif

View File

@ -129,7 +129,7 @@ static int test_brotli(int n)
return do_bio_comp(BIO_f_brotli(), n);
}
#endif
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
static int test_zlib(int n)
{
return do_bio_comp(BIO_f_zlib(), n);
@ -138,7 +138,7 @@ static int test_zlib(int n)
int setup_tests(void)
{
#ifdef ZLIB
#ifndef OPENSSL_NO_ZLIB
ADD_ALL_TESTS(test_zlib, NUM_SIZES * 4);
#endif
#ifndef OPENSSL_NO_BROTLI

View File

@ -2443,7 +2443,7 @@ ASN1_STRING_type_new 2494 3_0_0 EXIST::FUNCTION:
TS_STATUS_INFO_free 2495 3_0_0 EXIST::FUNCTION:TS
BN_mod_mul 2496 3_0_0 EXIST::FUNCTION:
CMS_add0_recipient_key 2497 3_0_0 EXIST::FUNCTION:CMS
BIO_f_zlib 2498 3_0_0 EXIST::FUNCTION:COMP,ZLIB
BIO_f_zlib 2498 3_0_0 EXIST::FUNCTION:COMP
AES_cfb128_encrypt 2499 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_0
ENGINE_set_EC 2500 3_0_0 EXIST::FUNCTION:DEPRECATEDIN_3_0,ENGINE
d2i_ECPKParameters 2501 3_0_0 EXIST::FUNCTION:EC