diff options
author | Todd Short <tshort@akamai.com> | 2021-08-09 16:56:29 -0400 |
---|---|---|
committer | Todd Short <todd.short@me.com> | 2022-10-18 09:30:18 -0400 |
commit | 12e96a23604a7aa1cd8f83486b02f1bcab6d468f (patch) | |
tree | 0b6be9589eaab31798122128c1237d40bff9bfe2 /apps | |
parent | 846975f367f75f3503b44c12e49d980dca181647 (diff) | |
download | openssl-new-12e96a23604a7aa1cd8f83486b02f1bcab6d468f.tar.gz |
Add brotli compression support (RFC7924)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18186)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/enc.c | 42 | ||||
-rw-r--r-- | apps/list.c | 3 | ||||
-rw-r--r-- | apps/progs.pl | 2 |
3 files changed, 38 insertions, 9 deletions
diff --git a/apps/enc.c b/apps/enc.c index 26ad3deb9a..4da2342791 100644 --- a/apps/enc.c +++ b/apps/enc.c @@ -134,6 +134,8 @@ int enc_main(int argc, char **argv) int do_zlib = 0; BIO *bzl = NULL; #endif + int do_brotli = 0; + BIO *bbrot = NULL; /* first check the command name */ if (strcmp(argv[0], "base64") == 0) @@ -142,6 +144,10 @@ int enc_main(int argc, char **argv) else if (strcmp(argv[0], "zlib") == 0) do_zlib = 1; #endif +#ifndef OPENSSL_NO_BROTLI + else if (strcmp(argv[0], "brotli") == 0) + do_brotli = 1; +#endif else if (strcmp(argv[0], "enc") != 0) ciphername = argv[0]; @@ -321,14 +327,18 @@ int enc_main(int argc, char **argv) BIO_printf(bio_err, "bufsize=%d\n", bsize); #ifdef ZLIB - if (!do_zlib) + if (do_zlib) + base64 = 0; #endif - if (base64) { - if (enc) - outformat = FORMAT_BASE64; - else - informat = FORMAT_BASE64; - } + if (do_brotli) + base64 = 0; + + if (base64) { + if (enc) + outformat = FORMAT_BASE64; + else + informat = FORMAT_BASE64; + } strbuf = app_malloc(SIZE, "strbuf"); buff = app_malloc(EVP_ENCODE_LENGTH(bsize), "evp buffer"); @@ -398,7 +408,8 @@ int enc_main(int argc, char **argv) rbio = in; wbio = out; -#ifdef ZLIB +#ifndef OPENSSL_NO_COMP +# ifdef ZLIB if (do_zlib) { if ((bzl = BIO_new(BIO_f_zlib())) == NULL) goto end; @@ -411,6 +422,20 @@ int enc_main(int argc, char **argv) else rbio = BIO_push(bzl, rbio); } +# endif + + if (do_brotli) { + if ((bbrot = BIO_new(BIO_f_brotli())) == NULL) + goto end; + if (debug) { + BIO_set_callback_ex(bbrot, BIO_debug_callback_ex); + BIO_set_callback_arg(bbrot, (char *)bio_err); + } + if (enc) + wbio = BIO_push(bbrot, wbio); + else + rbio = BIO_push(bbrot, rbio); + } #endif if (base64) { @@ -656,6 +681,7 @@ int enc_main(int argc, char **argv) #ifdef ZLIB BIO_free(bzl); #endif + BIO_free(bbrot); release_engine(e); OPENSSL_free(pass); return ret; diff --git a/apps/list.c b/apps/list.c index adcfaa4260..f198c1cda7 100644 --- a/apps/list.c +++ b/apps/list.c @@ -1424,6 +1424,9 @@ static void list_disabled(void) #ifndef ZLIB BIO_puts(bio_out, "ZLIB\n"); #endif +#ifdef OPENSSL_NO_BROTLI + BIO_puts(bio_out, "BROTLI\n"); +#endif } /* Unified enum for help and list commands. */ diff --git a/apps/progs.pl b/apps/progs.pl index 29f9be13ca..c4e7ae59cf 100644 --- a/apps/progs.pl +++ b/apps/progs.pl @@ -188,7 +188,7 @@ EOF "camellia-128-cbc", "camellia-128-ecb", "camellia-192-cbc", "camellia-192-ecb", "camellia-256-cbc", "camellia-256-ecb", - "base64", "zlib", + "base64", "zlib", "brotli", "des", "des3", "desx", "idea", "seed", "rc4", "rc4-40", "rc2", "bf", "cast", "rc5", "des-ecb", "des-ede", "des-ede3", |